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

Ondřej Surý ondrej at sury.org
Tue Mar 9 14:23:24 UTC 2010


---
 Makefile.global                                    |   18 +-
 NEWS                                               |  287 +-
 README.RELEASE_PROCESS                             |    6 +-
 README.SUBMITTING_PATCH                            |  182 +-
 README.WIN32-BUILD-SYSTEM                          |  170 +-
 TSRM/TSRM.c                                        |    2 +-
 TSRM/TSRM.h                                        |    2 +-
 TSRM/tsrm_nw.c                                     |    4 +-
 TSRM/tsrm_nw.h                                     |    2 +-
 TSRM/tsrm_virtual_cwd.c                            |   65 +-
 TSRM/tsrm_virtual_cwd.h                            |    7 +-
 TSRM/tsrm_win32.c                                  |   18 +-
 TSRM/tsrm_win32.h                                  |    4 +-
 Zend/acconfig.h                                    |    4 +-
 Zend/header                                        |    4 +-
 Zend/tests/bug44827.phpt                           |   11 +
 Zend/tests/bug47516.phpt                           |    2 +-
 Zend/tests/bug48667_1.phpt                         |   10 +
 Zend/tests/bug48667_2.phpt                         |   10 +
 Zend/tests/bug49472.phpt                           |   27 +
 Zend/tests/bug49866.phpt                           |   10 +
 Zend/tests/bug50005.phpt                           |   19 +
 Zend/tests/bug50146.phpt                           |   20 +
 Zend/tests/bug50174.phpt                           |   33 +
 Zend/tests/bug50255.phpt                           |   30 +
 Zend/tests/bug50261.phpt                           |   38 +
 Zend/tests/bug50394.phpt                           |   24 +
 Zend/tests/call_user_func_004.phpt                 |   18 +
 Zend/tests/call_user_func_005.phpt                 |   35 +
 Zend/tests/call_with_refs.phpt                     |   18 +
 Zend/tests/closure_035.phpt                        |   31 +
 Zend/tests/errmsg_025.phpt                         |    4 +-
 Zend/tests/inter_01.phpt                           |    2 +-
 Zend/tests/unset_cv05.phpt                         |    2 +-
 Zend/tests/unset_cv06.phpt                         |    2 +-
 Zend/zend.c                                        |    6 +-
 Zend/zend.h                                        |   13 +-
 Zend/zend_API.c                                    |   64 +-
 Zend/zend_API.h                                    |    4 +-
 Zend/zend_alloc.c                                  |   57 +-
 Zend/zend_alloc.h                                  |    4 +-
 Zend/zend_build.h                                  |    2 +-
 Zend/zend_builtin_functions.c                      |   33 +-
 Zend/zend_builtin_functions.h                      |    4 +-
 Zend/zend_closures.c                               |    8 +-
 Zend/zend_closures.h                               |    4 +-
 Zend/zend_compile.c                                |   32 +-
 Zend/zend_compile.h                                |    4 +-
 Zend/zend_config.nw.h                              |    4 +-
 Zend/zend_config.w32.h                             |    4 +-
 Zend/zend_constants.c                              |    4 +-
 Zend/zend_constants.h                              |    4 +-
 Zend/zend_default_classes.c                        |    4 +-
 Zend/zend_dynamic_array.c                          |    4 +-
 Zend/zend_dynamic_array.h                          |    4 +-
 Zend/zend_errors.h                                 |    4 +-
 Zend/zend_exceptions.c                             |    4 +-
 Zend/zend_exceptions.h                             |    4 +-
 Zend/zend_execute.c                                |    8 +-
 Zend/zend_execute.h                                |    6 +-
 Zend/zend_execute_API.c                            |   13 +-
 Zend/zend_extensions.c                             |   28 +-
 Zend/zend_extensions.h                             |    4 +-
 Zend/zend_fast_cache.h                             |    4 +-
 Zend/zend_float.c                                  |    4 +-
 Zend/zend_float.h                                  |    4 +-
 Zend/zend_gc.c                                     |    4 +-
 Zend/zend_gc.h                                     |    4 +-
 Zend/zend_globals.h                                |    4 +-
 Zend/zend_globals_macros.h                         |    4 +-
 Zend/zend_hash.c                                   |    4 +-
 Zend/zend_hash.h                                   |    4 +-
 Zend/zend_highlight.c                              |    4 +-
 Zend/zend_highlight.h                              |    4 +-
 Zend/zend_indent.c                                 |    4 +-
 Zend/zend_indent.h                                 |    4 +-
 Zend/zend_ini.c                                    |    4 +-
 Zend/zend_ini.h                                    |    4 +-
 Zend/zend_ini_parser.c                             |    4 +-
 Zend/zend_ini_parser.y                             |    4 +-
 Zend/zend_ini_scanner.c                            | 3917 ++--
 Zend/zend_ini_scanner.h                            |    4 +-
 Zend/zend_ini_scanner.l                            |   34 +-
 Zend/zend_ini_scanner_defs.h                       |    2 +-
 Zend/zend_interfaces.c                             |   16 +-
 Zend/zend_interfaces.h                             |    4 +-
 Zend/zend_istdiostream.h                           |    4 +-
 Zend/zend_iterators.c                              |    4 +-
 Zend/zend_iterators.h                              |    4 +-
 Zend/zend_language_parser.c                        |    4 +-
 Zend/zend_language_parser.y                        |    4 +-
 Zend/zend_language_scanner.c                       |   14 +-
 Zend/zend_language_scanner.h                       |    4 +-
 Zend/zend_language_scanner.l                       |   12 +-
 Zend/zend_language_scanner_defs.h                  |    2 +-
 Zend/zend_list.c                                   |    4 +-
 Zend/zend_list.h                                   |    4 +-
 Zend/zend_llist.c                                  |    4 +-
 Zend/zend_llist.h                                  |    4 +-
 Zend/zend_modules.h                                |    4 +-
 Zend/zend_multibyte.c                              |    4 +-
 Zend/zend_multibyte.h                              |    4 +-
 Zend/zend_multiply.h                               |    4 +-
 Zend/zend_object_handlers.c                        |    4 +-
 Zend/zend_object_handlers.h                        |    4 +-
 Zend/zend_objects.c                                |    4 +-
 Zend/zend_objects.h                                |    4 +-
 Zend/zend_objects_API.c                            |    4 +-
 Zend/zend_objects_API.h                            |    4 +-
 Zend/zend_opcode.c                                 |    4 +-
 Zend/zend_operators.c                              |   10 +-
 Zend/zend_operators.h                              |    4 +-
 Zend/zend_ptr_stack.c                              |    4 +-
 Zend/zend_ptr_stack.h                              |    4 +-
 Zend/zend_qsort.c                                  |    4 +-
 Zend/zend_qsort.h                                  |    4 +-
 Zend/zend_sprintf.c                                |    4 +-
 Zend/zend_stack.c                                  |    4 +-
 Zend/zend_stack.h                                  |    4 +-
 Zend/zend_static_allocator.c                       |    4 +-
 Zend/zend_static_allocator.h                       |    4 +-
 Zend/zend_stream.c                                 |    4 +-
 Zend/zend_stream.h                                 |    4 +-
 Zend/zend_strtod.h                                 |    4 +-
 Zend/zend_ts_hash.c                                |    4 +-
 Zend/zend_ts_hash.h                                |    4 +-
 Zend/zend_types.h                                  |    4 +-
 Zend/zend_variables.c                              |   17 +-
 Zend/zend_variables.h                              |    9 +-
 Zend/zend_vm.h                                     |    4 +-
 Zend/zend_vm_def.h                                 |   12 +-
 Zend/zend_vm_execute.h                             |   54 +-
 Zend/zend_vm_gen.php                               |    6 +-
 Zend/zend_vm_opcodes.h                             |    2 +-
 acconfig.h                                         |    4 +-
 acinclude.m4                                       |   14 +-
 aclocal.m4                                         | 1700 +-
 build/libtool.m4                                   | 1686 +-
 config.guess                                       |  100 +-
 config.sub                                         |  153 +-
 configure                                          | 7923 ++++----
 configure.in                                       |   48 +-
 ext/bcmath/bcmath.c                                |    4 +-
 ext/bcmath/php_bcmath.h                            |    4 +-
 ext/bz2/bz2.c                                      |    4 +-
 ext/bz2/bz2_filter.c                               |    4 +-
 ext/bz2/php_bz2.h                                  |    4 +-
 ext/calendar/cal_unix.c                            |    2 +-
 ext/calendar/calendar.c                            |    4 +-
 ext/calendar/easter.c                              |    2 +-
 ext/com_dotnet/com_com.c                           |    4 +-
 ext/com_dotnet/com_dotnet.c                        |    4 +-
 ext/com_dotnet/com_extension.c                     |    4 +-
 ext/com_dotnet/com_handlers.c                      |    4 +-
 ext/com_dotnet/com_iterator.c                      |    4 +-
 ext/com_dotnet/com_misc.c                          |    4 +-
 ext/com_dotnet/com_olechar.c                       |    4 +-
 ext/com_dotnet/com_persist.c                       |    4 +-
 ext/com_dotnet/com_saproxy.c                       |    4 +-
 ext/com_dotnet/com_typeinfo.c                      |    4 +-
 ext/com_dotnet/com_variant.c                       |    4 +-
 ext/com_dotnet/com_wrapper.c                       |    4 +-
 ext/com_dotnet/php_com_dotnet.h                    |    4 +-
 ext/com_dotnet/php_com_dotnet_internal.h           |    4 +-
 ext/ctype/ctype.c                                  |    2 +-
 ext/ctype/php_ctype.h                              |    2 +-
 ext/curl/interface.c                               |  128 +-
 ext/curl/multi.c                                   |    4 +-
 ext/curl/php_curl.h                                |    4 +-
 ext/curl/streams.c                                 |    8 +-
 ext/curl/tests/curl_basic_016.phpt                 |   10 +-
 ext/curl/tests/curl_ftp_pasv.phpt                  |   59 +
 ext/curl/tests/curl_setopt_basic001.phpt           |    2 +-
 ext/date/config0.m4                                |    2 +-
 ext/date/lib/astro.c                               |    4 +-
 ext/date/lib/dow.c                                 |    4 +-
 ext/date/lib/interval.c                            |    4 +-
 ext/date/lib/parse_date.c                          | 2622 ++--
 ext/date/lib/parse_date.c.orig                     | 2816 ++--
 ext/date/lib/parse_date.re                         |    7 +-
 ext/date/lib/parse_tz.c                            |    4 +-
 ext/date/lib/timelib.c                             |    4 +-
 ext/date/lib/timelib.h                             |    4 +-
 ext/date/lib/timelib_structs.h                     |    4 +-
 ext/date/lib/timezonedb.h                          | 1302 +-
 ext/date/lib/tm2unixtime.c                         |    4 +-
 ext/date/lib/unixtime2tm.c                         |    4 +-
 ext/date/php_date.c                                |   40 +-
 ext/date/php_date.h                                |    4 +-
 .../tests/DateTimeZone_listIdentifiers_basic1.phpt |  824 +-
 ext/date/tests/bug45866.phpt                       |   24 +
 ext/date/tests/bug46268.phpt                       |    4 +-
 ext/date/tests/bug49585.phpt                       |   16 +
 ext/date/tests/bug50392.phpt                       |   63 +
 ext/date/tests/bug50680.phpt                       |    9 +
 ext/date/tests/oo_002.phpt                         |    2 +-
 ext/date/tests/sunfuncts.phpt                      |   42 +
 .../tests/timezone_identifiers_list_basic1.phpt    |  822 +-
 ext/dba/dba.c                                      |    4 +-
 ext/dba/dba_cdb.c                                  |    4 +-
 ext/dba/dba_db1.c                                  |    4 +-
 ext/dba/dba_db2.c                                  |    4 +-
 ext/dba/dba_db3.c                                  |    4 +-
 ext/dba/dba_db4.c                                  |    4 +-
 ext/dba/dba_dbm.c                                  |    4 +-
 ext/dba/dba_flatfile.c                             |    4 +-
 ext/dba/dba_gdbm.c                                 |    4 +-
 ext/dba/dba_inifile.c                              |    4 +-
 ext/dba/dba_ndbm.c                                 |    4 +-
 ext/dba/dba_qdbm.c                                 |    4 +-
 ext/dba/libcdb/cdb.c                               |    6 +-
 ext/dba/libcdb/cdb.h                               |    4 +-
 ext/dba/libcdb/cdb_make.c                          |    6 +-
 ext/dba/libcdb/cdb_make.h                          |    4 +-
 ext/dba/libcdb/uint32.c                            |    4 +-
 ext/dba/libcdb/uint32.h                            |    4 +-
 ext/dba/libflatfile/flatfile.c                     |    6 +-
 ext/dba/libflatfile/flatfile.h                     |    4 +-
 ext/dba/libinifile/inifile.c                       |    6 +-
 ext/dba/libinifile/inifile.h                       |    4 +-
 ext/dba/php_dba.h                                  |    4 +-
 ext/dba/tests/dba_cdb_make.phpt                    |    2 +-
 ext/dom/attr.c                                     |    4 +-
 ext/dom/cdatasection.c                             |    4 +-
 ext/dom/characterdata.c                            |    4 +-
 ext/dom/comment.c                                  |    4 +-
 ext/dom/document.c                                 |   23 +-
 ext/dom/documentfragment.c                         |    4 +-
 ext/dom/documenttype.c                             |    4 +-
 ext/dom/dom_ce.h                                   |    4 +-
 ext/dom/dom_fe.h                                   |    4 +-
 ext/dom/dom_iterators.c                            |    4 +-
 ext/dom/dom_properties.h                           |    4 +-
 ext/dom/domconfiguration.c                         |    4 +-
 ext/dom/domerror.c                                 |    4 +-
 ext/dom/domerrorhandler.c                          |    4 +-
 ext/dom/domexception.c                             |    4 +-
 ext/dom/domimplementation.c                        |    4 +-
 ext/dom/domimplementationlist.c                    |    4 +-
 ext/dom/domimplementationsource.c                  |    4 +-
 ext/dom/domlocator.c                               |    4 +-
 ext/dom/domstringlist.c                            |    4 +-
 ext/dom/element.c                                  |   21 +-
 ext/dom/entity.c                                   |    4 +-
 ext/dom/entityreference.c                          |    4 +-
 ext/dom/namednodemap.c                             |    4 +-
 ext/dom/namelist.c                                 |    4 +-
 ext/dom/node.c                                     |    8 +-
 ext/dom/nodelist.c                                 |    4 +-
 ext/dom/notation.c                                 |    4 +-
 ext/dom/php_dom.c                                  |    4 +-
 ext/dom/php_dom.h                                  |    4 +-
 ext/dom/processinginstruction.c                    |    4 +-
 ext/dom/string_extend.c                            |    4 +-
 ext/dom/tests/DOMAttr_value_basic_001.phpt         |    5 +
 .../tests/DOMCharacterData_length_error_001.phpt   |    7 +-
 ext/dom/tests/DOMText_appendData_basic.phpt        |    7 +-
 ext/dom/tests/bug42082.phpt                        |    7 +-
 ext/dom/tests/bug47848.phpt                        |   25 +
 ext/dom/tests/bug49463.phpt                        |   17 +
 ext/dom/tests/bug50661.phpt                        |   16 +
 .../tests/domdocument_createcomment_error_001.phpt |    7 +-
 .../domdocument_createentityreference_001.phpt     |    9 +-
 .../domdocument_createentityreference_002.phpt     |    7 +-
 ext/dom/text.c                                     |    4 +-
 ext/dom/typeinfo.c                                 |    4 +-
 ext/dom/userdatahandler.c                          |    4 +-
 ext/dom/xml_common.h                               |    4 +-
 ext/dom/xpath.c                                    |    4 +-
 ext/enchant/config.m4                              |    2 +-
 ext/enchant/config.w32                             |    2 +-
 ext/enchant/enchant.c                              |    6 +-
 ext/enchant/php_enchant.h                          |    4 +-
 ext/ereg/ereg.c                                    |    4 +-
 ext/ereg/php_ereg.h                                |    4 +-
 ext/ereg/php_regex.h                               |    4 +-
 ext/exif/exif.c                                    |   10 +-
 ext/exif/php_exif.h                                |    4 +-
 ext/exif/tests/exif006.phpt                        |    2 +-
 ext/fileinfo/libmagic.patch                        | 3047 +++-
 ext/fileinfo/libmagic/apprentice.c                 |   35 +-
 ext/fileinfo/libmagic/apptype.c                    |    3 +-
 ext/fileinfo/libmagic/ascmagic.c                   |   12 +-
 ext/fileinfo/libmagic/cdf.c                        |   90 +-
 ext/fileinfo/libmagic/cdf_time.c                   |    2 +-
 ext/fileinfo/libmagic/compress.c                   |   12 +-
 ext/fileinfo/libmagic/file.h                       |   13 +-
 ext/fileinfo/libmagic/fsmagic.c                    |    2 +-
 ext/fileinfo/libmagic/funcs.c                      |    8 +-
 ext/fileinfo/libmagic/is_tar.c                     |    2 +-
 ext/fileinfo/libmagic/magic.c                      |   12 +-
 ext/fileinfo/libmagic/magic.h                      |    4 +-
 ext/fileinfo/libmagic/patchlevel.h                 |   12 +-
 ext/fileinfo/libmagic/print.c                      |    2 +-
 ext/fileinfo/libmagic/readcdf.c                    |    7 +-
 ext/fileinfo/libmagic/readelf.c                    |    4 +-
 ext/fileinfo/libmagic/softmagic.c                  |   91 +-
 ext/filter/callback_filter.c                       |    4 +-
 ext/filter/filter.c                                |   42 +-
 ext/filter/filter_private.h                        |    5 +-
 ext/filter/logical_filters.c                       |   29 +-
 ext/filter/php_filter.h                            |    4 +-
 ext/filter/sanitizing_filters.c                    |    5 +-
 ext/filter/tests/033.phpt                          |    2 +-
 ext/filter/tests/bug39763.phpt                     |    2 +-
 ext/filter/tests/bug42718-2.phpt                   |    1 +
 ext/filter/tests/bug50158.phpt                     |   23 +
 ext/filter/tests/bug50632.phpt                     |   11 +
 ext/ftp/ftp.c                                      |   14 +-
 ext/ftp/ftp.h                                      |    4 +-
 ext/ftp/php_ftp.c                                  |    4 +-
 ext/ftp/php_ftp.h                                  |    4 +-
 ext/gd/gd.c                                        |   25 +-
 ext/gd/gd_ctx.c                                    |    4 +-
 ext/gd/libgd/gd.c                                  |   14 +-
 ext/gd/libgd/gd_png.c                              |    2 +-
 ext/gd/libgd/gdft.c                                |    3 +-
 ext/gd/libgd/xbm.c                                 |    4 +-
 ext/gd/php_gd.h                                    |    4 +-
 ext/gd/tests/bug49600.phpt                         |   32 +
 ext/gd/tests/image_type_to_mime_type_basic.phpt    |    5 +-
 ext/gd/tests/imagecopyresampled_basic.phpt         |    2 +-
 ext/gd/tests/imagedashedline_basic.phpt            |    2 +-
 ext/gd/tests/imagefilledpolygon_basic.phpt         |    2 +-
 ext/gd/tests/imagefilledpolygon_negative.phpt      |   15 +
 ext/gd/tests/imagepolygon_negative.phpt            |   15 +
 ext/gd/tests/imagerectangle_basic.phpt             |    2 +-
 ext/gd/tests/imagerectangle_error2.phpt            |    2 +-
 ext/gd/tests/libgd00100.phpt                       |  119 +
 ext/gettext/gettext.c                              |    4 +-
 ext/gettext/php_gettext.h                          |    4 +-
 ext/gmp/config.w32                                 |    3 +-
 ext/gmp/gmp.c                                      |   24 +-
 ext/gmp/php_gmp.h                                  |    2 +-
 ext/gmp/tests/bug50283.phpt                        |   36 +
 ext/hash/hash.c                                    |    4 +-
 ext/hash/hash_adler32.c                            |    4 +-
 ext/hash/hash_crc32.c                              |    4 +-
 ext/hash/hash_gost.c                               |    4 +-
 ext/hash/hash_haval.c                              |    4 +-
 ext/hash/hash_md.c                                 |    4 +-
 ext/hash/hash_ripemd.c                             |    4 +-
 ext/hash/hash_salsa.c                              |    4 +-
 ext/hash/hash_sha.c                                |    4 +-
 ext/hash/hash_snefru.c                             |    4 +-
 ext/hash/hash_tiger.c                              |    4 +-
 ext/hash/hash_whirlpool.c                          |    4 +-
 ext/hash/php_hash.h                                |    4 +-
 ext/hash/php_hash_adler32.h                        |    4 +-
 ext/hash/php_hash_crc32.h                          |    4 +-
 ext/hash/php_hash_crc32_tables.h                   |    4 +-
 ext/hash/php_hash_gost.h                           |    4 +-
 ext/hash/php_hash_haval.h                          |    4 +-
 ext/hash/php_hash_md.h                             |    4 +-
 ext/hash/php_hash_ripemd.h                         |    4 +-
 ext/hash/php_hash_salsa.h                          |    4 +-
 ext/hash/php_hash_sha.h                            |    4 +-
 ext/hash/php_hash_snefru.h                         |    4 +-
 ext/hash/php_hash_snefru_tables.h                  |    4 +-
 ext/hash/php_hash_tiger.h                          |    4 +-
 ext/hash/php_hash_tiger_tables.h                   |    4 +-
 ext/hash/php_hash_types.h                          |    4 +-
 ext/hash/php_hash_whirlpool.h                      |    4 +-
 ext/hash/php_hash_whirlpool_tables.h               |    4 +-
 ext/iconv/iconv.c                                  |    4 +-
 ext/iconv/php_iconv.h                              |   24 +-
 ext/iconv/tests/iconv_encoding_basic.phpt          |    6 +-
 ext/iconv/tests/iconv_substr_basic.phpt            |    6 +-
 ext/imap/config.m4                                 |   12 +-
 ext/imap/config.w32                                |    3 +-
 ext/imap/php_imap.c                                |   88 +-
 ext/imap/php_imap.h                                |    4 +-
 ext/imap/tests/bug44098.phpt                       |   20 +
 ext/imap/tests/imap_body.phpt                      |   21 +
 ext/imap/tests/imap_body_basic.phpt                |    8 +-
 ext/imap/tests/imap_bodystruct_basic.phpt          |    2 +-
 ext/imap/tests/imap_clearflag_full_basic.phpt      |    2 +-
 ext/imap/tests/imap_close_variation2.phpt          |    2 +-
 ext/imap/tests/imap_close_variation4.phpt          |    2 +-
 ext/imap/tests/imap_fetch_overview_basic.phpt      |    2 +-
 ext/imap/tests/imap_fetch_overview_error.phpt      |    2 +-
 ext/imap/tests/imap_fetch_overview_variation2.phpt |    2 +-
 ext/imap/tests/imap_fetch_overview_variation3.phpt |    2 +-
 ext/imap/tests/imap_fetch_overview_variation5.phpt |    2 +-
 ext/imap/tests/imap_fetch_overview_variation6.phpt |    2 +-
 ext/imap/tests/imap_fetchbody_basic.phpt           |    2 +-
 ext/imap/tests/imap_fetchbody_error.phpt           |    2 +-
 ext/imap/tests/imap_fetchbody_variation2.phpt      |    2 +-
 ext/imap/tests/imap_fetchbody_variation4.phpt      |    2 +-
 ext/imap/tests/imap_fetchbody_variation6.phpt      |    2 +-
 ext/imap/tests/imap_fetchheader_variation2.phpt    |    8 +-
 ext/imap/tests/imap_fetchheader_variation3.phpt    |    2 +-
 ext/imap/tests/imap_fetchheader_variation5.phpt    |    6 +-
 ext/imap/tests/imap_fetchstructure_basic.phpt      |   70 +
 ext/imap/tests/imap_gc_error.phpt                  |    7 +
 ext/imap/tests/imap_getsubscribed_basic.phpt       |   68 +
 ext/imap/tests/imap_headerinfo_basic.phpt          |  129 +
 ext/imap/tests/imap_headerinfo_error.phpt          |   36 +
 ext/imap/tests/imap_list_basic.phpt                |   47 +
 ext/imap/tests/imap_lsub_basic.phpt                |   61 +
 ext/imap/tests/imap_mail_copy.phpt                 |   54 +
 ext/imap/tests/imap_mail_copy_basic.phpt           |   46 +
 ext/imap/tests/imap_mail_move.phpt                 |   54 +
 ext/imap/tests/imap_mail_move_basic.phpt           |   46 +
 ext/imap/tests/imap_open_error.phpt                |    5 +
 ext/imap/tests/imap_renamemailbox_basic.phpt       |   66 +
 .../tests/imap_rfc822_parse_headers_basic.phpt     |  122 +
 ext/imap/tests/imap_savebody_basic.phpt            |   61 +
 ext/imap/tests/imap_timeout_basic.phpt             |   60 +
 ext/imap/tests/imap_undelete_basic.phpt            |   29 +
 ext/imap/tests/imap_undelete_error.phpt            |   36 +
 ext/interbase/ibase_blobs.c                        |    4 +-
 ext/interbase/ibase_events.c                       |    4 +-
 ext/interbase/ibase_query.c                        |    4 +-
 ext/interbase/ibase_service.c                      |    4 +-
 ext/interbase/interbase.c                          |    4 +-
 ext/interbase/php_ibase_includes.h                 |    4 +-
 ext/interbase/php_ibase_udf.c                      |    4 +-
 ext/interbase/php_interbase.h                      |    4 +-
 ext/intl/collator/collator_class.c                 |    1 +
 ext/intl/collator/collator_sort.c                  |   63 +
 ext/intl/collator/collator_sort.h                  |    1 +
 ext/intl/config.m4                                 |    4 +
 ext/intl/config.w32                                |    7 +-
 ext/intl/dateformat/dateformat.c                   |    8 +-
 ext/intl/formatter/formatter_main.c                |    2 +-
 ext/intl/grapheme/grapheme_string.c                |   10 +-
 ext/intl/grapheme/grapheme_util.c                  |    8 +-
 ext/intl/idn/idn.c                                 |    6 +-
 ext/intl/intl_error.c                              |   17 +-
 ext/intl/intl_error.h                              |    1 +
 ext/intl/locale/locale_methods.c                   |   12 +-
 ext/intl/normalizer/normalizer_class.h             |    9 -
 ext/intl/normalizer/normalizer_normalize.c         |   34 +-
 ext/intl/php_intl.c                                |   56 +-
 ext/intl/php_intl.h                                |    2 +-
 ext/intl/resourcebundle/TODO                       |    1 +
 ext/intl/resourcebundle/resourcebundle.c           |   93 +
 ext/intl/resourcebundle/resourcebundle.h           |   28 +
 ext/intl/resourcebundle/resourcebundle_class.c     |  434 +
 ext/intl/resourcebundle/resourcebundle_class.h     |   48 +
 ext/intl/resourcebundle/resourcebundle_iterator.c  |  192 +
 ext/intl/resourcebundle/resourcebundle_iterator.h  |   36 +
 ext/intl/tests/_files/es-bundle.txt                |   21 +
 ext/intl/tests/_files/res_index.txt                |    6 +
 ext/intl/tests/_files/resourcebundle.txt           |   21 +
 ext/intl/tests/_files/resourcebundle/es.res        |  Bin 0 -> 384 bytes
 ext/intl/tests/_files/resourcebundle/res_index.res |  Bin 0 -> 128 bytes
 ext/intl/tests/_files/resourcebundle/root.res      |  Bin 0 -> 388 bytes
 ext/intl/tests/badargs.phpt                        |   25 +
 ext/intl/tests/collator_get_sort_key.phpt          |   97 +
 ext/intl/tests/resourcebundle.build                |   33 +
 ext/intl/tests/resourcebundle.inc                  |   13 +
 ext/intl/tests/resourcebundle_arrayaccess.phpt     |   48 +
 ext/intl/tests/resourcebundle_create.phpt          |   62 +
 ext/intl/tests/resourcebundle_individual.phpt      |   55 +
 ext/intl/tests/resourcebundle_iterator.phpt        |   71 +
 ext/intl/tests/resourcebundle_locales.phpt         |   23 +
 ext/intl/tests/ut_common.inc                       |   30 +-
 ext/json/json.c                                    |    4 +-
 ext/json/php_json.h                                |    4 +-
 ext/ldap/ldap.c                                    |   27 +-
 ext/ldap/php_ldap.h                                |    4 +-
 ext/ldap/tests/ldap_bind_basic.phpt                |    3 +-
 ext/ldap/tests/ldap_bind_variation.phpt            |    3 +-
 ext/ldap/tests/ldap_get_entries_variation.phpt     |    5 +-
 ext/ldap/tests/ldap_mod_del_basic.phpt             |    5 +-
 ext/ldap/tests/ldap_search_error.phpt              |    5 +-
 ext/ldap/tests/ldap_start_tls_basic.phpt           |    3 +-
 ext/libxml/libxml.c                                |    7 +-
 ext/libxml/php_libxml.h                            |    4 +-
 ext/mbstring/config.m4                             |   10 +-
 ext/mbstring/libmbfl/filters/mbfilter_utf16.c      |   27 +-
 ext/mbstring/libmbfl/filters/mbfilter_utf8.c       |    2 +-
 ext/mbstring/libmbfl/mbfl/mbfilter.c               |    2 +-
 ext/mbstring/mb_gpc.c                              |    4 +-
 ext/mbstring/mbstring.c                            |    8 +-
 ext/mbstring/mbstring.h                            |    4 +-
 ext/mbstring/php_mbregex.c                         |    4 +-
 ext/mbstring/php_mbregex.h                         |    4 +-
 ext/mbstring/php_unicode.c                         |    2 +-
 ext/mbstring/php_unicode.h                         |    2 +-
 ext/mbstring/tests/bug43994.phpt                   |    2 +-
 ext/mbstring/tests/bug45722.phpt                   |    2 +
 ext/mbstring/tests/bug47399.phpt                   |    2 +
 ext/mbstring/tests/bug48697.phpt                   |   24 +
 ext/mbstring/tests/bug49354.phpt                   |   21 +
 ext/mbstring/tests/bug49528.phpt                   |   20 +
 ext/mbstring/tests/bug49536.phpt                   |   20 +
 ext/mbstring/tests/mb_encoding_aliases.phpt        |    2 +
 ext/mbstring/tests/mb_list_encodings.phpt          |    2 +
 ext/mcrypt/mcrypt.c                                |    4 +-
 ext/mcrypt/php_mcrypt.h                            |    4 +-
 ext/mcrypt/tests/bug46010.phpt                     |    2 +-
 ext/mssql/php_mssql.c                              |    4 +-
 ext/mssql/php_mssql.h                              |    4 +-
 ext/mysql/config.m4                                |   25 +-
 ext/mysql/php_mysql.c                              |   54 +-
 ext/mysql/php_mysql.h                              |    4 +-
 ext/mysql/php_mysql_structs.h                      |    9 +-
 ext/mysql/tests/connect.inc                        |   54 +-
 ext/mysql/tests/mysql_connect.phpt                 |   20 +-
 ext/mysql/tests/mysql_pconn_disable.phpt           |   16 +-
 ext/mysql/tests/mysql_pconn_max_links.phpt         |   13 +
 ext/mysql/tests/mysql_phpinfo.phpt                 |    7 +-
 .../tests/mysql_query_load_data_openbasedir.phpt   |   11 +
 ext/mysqli/mysqli.c                                |   65 +-
 ext/mysqli/mysqli_api.c                            |  145 +-
 ext/mysqli/mysqli_driver.c                         |    2 +-
 ext/mysqli/mysqli_embedded.c                       |    2 +-
 ext/mysqli/mysqli_exception.c                      |    2 +-
 ext/mysqli/mysqli_fe.c                             |    4 +-
 ext/mysqli/mysqli_libmysql.h                       |   96 +-
 ext/mysqli/mysqli_mysqlnd.h                        |    3 +-
 ext/mysqli/mysqli_nonapi.c                         |   57 +-
 ext/mysqli/mysqli_prop.c                           |    4 +-
 ext/mysqli/mysqli_report.c                         |    4 +-
 ext/mysqli/mysqli_report.h                         |    4 +-
 ext/mysqli/mysqli_warning.c                        |    2 +-
 ext/mysqli/php_mysqli.h                            |    4 +-
 ext/mysqli/php_mysqli_structs.h                    |   20 +-
 ext/mysqli/tests/001.phpt                          |    2 +-
 ext/mysqli/tests/002.phpt                          |    4 +-
 ext/mysqli/tests/003.phpt                          |    4 +-
 ext/mysqli/tests/004.phpt                          |    2 +-
 ext/mysqli/tests/005.phpt                          |    4 +-
 ext/mysqli/tests/006.phpt                          |    4 +-
 ext/mysqli/tests/007.phpt                          |    4 +-
 ext/mysqli/tests/008.phpt                          |    4 +-
 ext/mysqli/tests/009.phpt                          |    4 +-
 ext/mysqli/tests/010.phpt                          |    4 +-
 ext/mysqli/tests/011.phpt                          |    4 +-
 ext/mysqli/tests/012.phpt                          |    4 +-
 ext/mysqli/tests/013.phpt                          |    4 +-
 ext/mysqli/tests/014.phpt                          |    4 +-
 ext/mysqli/tests/015.phpt                          |    9 +-
 ext/mysqli/tests/016.phpt                          |    2 +-
 ext/mysqli/tests/017.phpt                          |    2 +-
 ext/mysqli/tests/018.phpt                          |    2 +-
 ext/mysqli/tests/019.phpt                          |    4 +-
 ext/mysqli/tests/020.phpt                          |    4 +-
 ext/mysqli/tests/021.phpt                          |    4 +-
 ext/mysqli/tests/022.phpt                          |    4 +-
 ext/mysqli/tests/023.phpt                          |    4 +-
 ext/mysqli/tests/024.phpt                          |    4 +-
 ext/mysqli/tests/025.phpt                          |    4 +-
 ext/mysqli/tests/026.phpt                          |    4 +-
 ext/mysqli/tests/027.phpt                          |    2 +-
 ext/mysqli/tests/028.phpt                          |    2 +-
 ext/mysqli/tests/029.phpt                          |    4 +-
 ext/mysqli/tests/030.phpt                          |    2 +-
 ext/mysqli/tests/031.phpt                          |    2 +-
 ext/mysqli/tests/032.phpt                          |    4 +-
 ext/mysqli/tests/033.phpt                          |    2 +-
 ext/mysqli/tests/034.phpt                          |    2 +-
 ext/mysqli/tests/035.phpt                          |    2 +-
 ext/mysqli/tests/036.phpt                          |    4 +-
 ext/mysqli/tests/037.phpt                          |    4 +-
 ext/mysqli/tests/038.phpt                          |    5 +-
 ext/mysqli/tests/039.phpt                          |    3 +-
 ext/mysqli/tests/040.phpt                          |    4 +-
 ext/mysqli/tests/041.phpt                          |    4 +-
 ext/mysqli/tests/042.phpt                          |    4 +-
 ext/mysqli/tests/043.phpt                          |    4 +-
 ext/mysqli/tests/044.phpt                          |    2 +-
 ext/mysqli/tests/045.phpt                          |    4 +-
 ext/mysqli/tests/046.phpt                          |    4 +-
 ext/mysqli/tests/047.phpt                          |    4 +-
 ext/mysqli/tests/048.phpt                          |    4 +-
 ext/mysqli/tests/049.phpt                          |    2 +-
 ext/mysqli/tests/050.phpt                          |    2 +-
 ext/mysqli/tests/051.phpt                          |    2 +-
 ext/mysqli/tests/052.phpt                          |    2 +-
 ext/mysqli/tests/053.phpt                          |    2 +-
 ext/mysqli/tests/054.phpt                          |    2 +-
 ext/mysqli/tests/055.phpt                          |    2 +-
 ext/mysqli/tests/056.phpt                          |    2 +-
 ext/mysqli/tests/057.phpt                          |    4 +-
 ext/mysqli/tests/058.phpt                          |    4 +-
 ext/mysqli/tests/059.phpt                          |    4 +-
 ext/mysqli/tests/060.phpt                          |    4 +-
 ext/mysqli/tests/061.phpt                          |    4 +-
 ext/mysqli/tests/062.phpt                          |    2 +-
 ext/mysqli/tests/063.phpt                          |    2 +-
 ext/mysqli/tests/064.phpt                          |    2 +-
 ext/mysqli/tests/065.phpt                          |    2 +-
 ext/mysqli/tests/066.phpt                          |    5 +-
 ext/mysqli/tests/067.phpt                          |    6 +-
 ext/mysqli/tests/069.phpt                          |    2 +-
 ext/mysqli/tests/070.phpt                          |    2 +-
 ext/mysqli/tests/071.phpt                          |   43 +-
 ext/mysqli/tests/072.phpt                          |    2 +-
 ext/mysqli/tests/073.phpt                          |    2 +-
 ext/mysqli/tests/074.phpt                          |    2 +-
 ext/mysqli/tests/bug28817.phpt                     |    8 +-
 ext/mysqli/tests/bug29311.phpt                     |    2 +-
 ext/mysqli/tests/bug30967.phpt                     |    8 +-
 ext/mysqli/tests/bug31668.phpt                     |    2 +-
 ext/mysqli/tests/bug32405.phpt                     |    4 +-
 ext/mysqli/tests/bug33263.phpt                     |    3 +-
 ext/mysqli/tests/bug34810.phpt                     |    8 +-
 ext/mysqli/tests/bug35103.phpt                     |    4 +-
 ext/mysqli/tests/bug35517.phpt                     |    4 +-
 ext/mysqli/tests/bug35759.phpt                     |    4 +-
 ext/mysqli/tests/bug36420.phpt                     |    2 +-
 ext/mysqli/tests/bug36745.phpt                     |    4 +-
 ext/mysqli/tests/bug36802.phpt                     |    2 +-
 ext/mysqli/tests/bug36949.phpt                     |    4 +-
 ext/mysqli/tests/bug37090.phpt                     |    2 +-
 ext/mysqli/tests/bug38710.phpt                     |    2 +-
 ext/mysqli/tests/bug39457.phpt                     |    6 +-
 ext/mysqli/tests/bug42548.phpt                     |    2 +-
 ext/mysqli/tests/bug44897.phpt                     |    3 +-
 ext/mysqli/tests/bug46109.phpt                     |    8 +-
 ext/mysqli/tests/bug48909.phpt                     |    2 +-
 ext/mysqli/tests/bug50772.phpt                     |   36 +
 ext/mysqli/tests/connect.inc                       |   79 +-
 ext/mysqli/tests/mysqli_affected_rows.phpt         |    2 +-
 ext/mysqli/tests/mysqli_affected_rows_oo.phpt      |    2 +-
 ext/mysqli/tests/mysqli_autocommit.phpt            |    2 +-
 ext/mysqli/tests/mysqli_autocommit_oo.phpt         |    2 +-
 ext/mysqli/tests/mysqli_change_user.phpt           |    2 +-
 ext/mysqli/tests/mysqli_change_user_insert_id.phpt |    7 +-
 ext/mysqli/tests/mysqli_change_user_rollback.phpt  |    5 +-
 ext/mysqli/tests/mysqli_character_set.phpt         |    2 +-
 ext/mysqli/tests/mysqli_character_set_name.phpt    |    2 +-
 ext/mysqli/tests/mysqli_character_set_name_oo.phpt |    2 +-
 .../tests/mysqli_class_mysqli_interface.phpt       |    2 +-
 .../mysqli_class_mysqli_properties_no_conn.phpt    |  282 +
 ext/mysqli/tests/mysqli_close.phpt                 |    2 +-
 ext/mysqli/tests/mysqli_close_oo.phpt              |    2 +-
 ext/mysqli/tests/mysqli_commit.phpt                |    2 +-
 ext/mysqli/tests/mysqli_commit_oo.phpt             |    2 +-
 ext/mysqli/tests/mysqli_connect.phpt               |    2 +-
 ext/mysqli/tests/mysqli_connect_errno.phpt         |    2 +-
 ext/mysqli/tests/mysqli_connect_error.phpt         |    6 +-
 ext/mysqli/tests/mysqli_connect_oo.phpt            |    2 +-
 ext/mysqli/tests/mysqli_connect_oo_defaults.phpt   |   43 +-
 ext/mysqli/tests/mysqli_connect_oo_warnings.phpt   |    2 +-
 ext/mysqli/tests/mysqli_connect_twice.phpt         |    2 +-
 ext/mysqli/tests/mysqli_constants.phpt             |    4 +-
 ext/mysqli/tests/mysqli_data_seek.phpt             |    2 +-
 ext/mysqli/tests/mysqli_data_seek_oo.phpt          |    2 +-
 .../tests/mysqli_disable_reads_from_master.phpt    |    2 +-
 ext/mysqli/tests/mysqli_driver.phpt                |    3 +-
 ext/mysqli/tests/mysqli_dump_debug_info.phpt       |    2 +-
 ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt    |    2 +-
 ext/mysqli/tests/mysqli_embedded_connect.phpt      |    6 +-
 .../tests/mysqli_enable_reads_from_master.phpt     |    2 +-
 ext/mysqli/tests/mysqli_errno.phpt                 |    2 +-
 ext/mysqli/tests/mysqli_errno_oo.phpt              |    2 +-
 ext/mysqli/tests/mysqli_error.phpt                 |    2 +-
 ext/mysqli/tests/mysqli_error_oo.phpt              |    6 +-
 ext/mysqli/tests/mysqli_error_unicode.phpt         |    2 +-
 ext/mysqli/tests/mysqli_fetch_all.phpt             |    2 +-
 ext/mysqli/tests/mysqli_fetch_all_oo.phpt          |    2 +-
 ext/mysqli/tests/mysqli_fetch_array.phpt           |    2 +-
 ext/mysqli/tests/mysqli_fetch_array_assoc.phpt     |    1 -
 ext/mysqli/tests/mysqli_fetch_array_large.phpt     |   30 +-
 ext/mysqli/tests/mysqli_fetch_array_many_rows.phpt |    1 -
 ext/mysqli/tests/mysqli_fetch_array_oo.phpt        |    2 +-
 ext/mysqli/tests/mysqli_fetch_assoc.phpt           |    2 +-
 ext/mysqli/tests/mysqli_fetch_assoc_no_alias.phpt  |    1 -
 .../tests/mysqli_fetch_assoc_no_alias_utf8.phpt    |    3 +-
 ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt        |    2 +-
 ext/mysqli/tests/mysqli_fetch_field.phpt           |    2 +-
 ext/mysqli/tests/mysqli_fetch_field_direct.phpt    |    2 +-
 ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt |    2 +-
 ext/mysqli/tests/mysqli_fetch_field_flags.phpt     |   10 +-
 ext/mysqli/tests/mysqli_fetch_field_oo.phpt        |    2 +-
 ext/mysqli/tests/mysqli_fetch_field_types.phpt     |    1 -
 ext/mysqli/tests/mysqli_fetch_fields.phpt          |    2 +-
 ext/mysqli/tests/mysqli_fetch_lengths.phpt         |    2 +-
 ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt      |    2 +-
 .../tests/mysqli_fetch_object_no_constructor.phpt  |    2 +-
 .../tests/mysqli_fetch_object_no_object.phpt       |    1 -
 ext/mysqli/tests/mysqli_fetch_object_oo.phpt       |    2 +-
 ext/mysqli/tests/mysqli_fetch_row.phpt             |    2 +-
 ext/mysqli/tests/mysqli_field_count.phpt           |    2 +-
 ext/mysqli/tests/mysqli_field_seek.phpt            |    2 +-
 ext/mysqli/tests/mysqli_field_tell.phpt            |    2 +-
 ext/mysqli/tests/mysqli_fork.phpt                  |    3 +-
 ext/mysqli/tests/mysqli_free_result.phpt           |    2 +-
 ext/mysqli/tests/mysqli_get_cache_stats.phpt       |  116 -
 .../mysqli_get_cache_stats_free_buffered.phpt      |   99 -
 ext/mysqli/tests/mysqli_get_charset.phpt           |    2 +-
 ext/mysqli/tests/mysqli_get_client_info.phpt       |    6 +-
 ext/mysqli/tests/mysqli_get_client_stats.phpt      |   68 +-
 ext/mysqli/tests/mysqli_get_connection_stats.phpt  |    5 +-
 ext/mysqli/tests/mysqli_get_host_info.phpt         |    7 +-
 ext/mysqli/tests/mysqli_get_proto_info.phpt        |    6 +-
 ext/mysqli/tests/mysqli_get_server_info.phpt       |    2 +-
 ext/mysqli/tests/mysqli_get_server_version.phpt    |    4 +-
 ext/mysqli/tests/mysqli_get_warnings.phpt          |    4 +-
 ext/mysqli/tests/mysqli_info.phpt                  |    2 +-
 ext/mysqli/tests/mysqli_insert_id.phpt             |    2 +-
 ext/mysqli/tests/mysqli_insert_id_variation.phpt   |    4 +-
 .../tests/mysqli_insert_packet_overflow.phpt       |  108 +
 ext/mysqli/tests/mysqli_kill.phpt                  |    4 +-
 ext/mysqli/tests/mysqli_more_results.phpt          |    2 +-
 ext/mysqli/tests/mysqli_multi_query.phpt           |    2 +-
 ext/mysqli/tests/mysqli_next_result.phpt           |    2 +-
 ext/mysqli/tests/mysqli_no_reconnect.phpt          |   15 +-
 ext/mysqli/tests/mysqli_num_fields.phpt            |    2 +-
 ext/mysqli/tests/mysqli_num_rows.phpt              |    2 +-
 ext/mysqli/tests/mysqli_options.phpt               |    4 +-
 ext/mysqli/tests/mysqli_options_init_command.phpt  |    2 +-
 ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt   |  164 +
 ext/mysqli/tests/mysqli_pconn_disabled.phpt        |    2 +-
 ext/mysqli/tests/mysqli_pconn_max_links.phpt       |    2 +-
 ext/mysqli/tests/mysqli_pconn_reuse.phpt           |    2 +-
 ext/mysqli/tests/mysqli_pconn_twice.phpt           |   79 +
 ext/mysqli/tests/mysqli_pconnect.phpt              |    2 +-
 ext/mysqli/tests/mysqli_phpinfo.phpt               |    3 +-
 ext/mysqli/tests/mysqli_ping.phpt                  |    2 +-
 .../tests/mysqli_poll_mixing_insert_select.phpt    |    2 +-
 ext/mysqli/tests/mysqli_prepare.phpt               |    4 +-
 ext/mysqli/tests/mysqli_prepare_no_object.phpt     |    1 -
 ext/mysqli/tests/mysqli_query.phpt                 |    4 +-
 .../tests/mysqli_query_local_infile_large.phpt     |    4 +-
 ext/mysqli/tests/mysqli_query_stored_proc.phpt     |    2 +-
 ext/mysqli/tests/mysqli_real_escape_string.phpt    |    6 +-
 .../tests/mysqli_real_escape_string_unicode.phpt   |    6 +-
 ext/mysqli/tests/mysqli_real_query.phpt            |    4 +-
 ext/mysqli/tests/mysqli_report.phpt                |    2 +-
 ext/mysqli/tests/mysqli_report_wo_ps.phpt          |    2 +-
 ext/mysqli/tests/mysqli_result_unclonable.phpt     |    2 +-
 ext/mysqli/tests/mysqli_rollback.phpt              |    2 +-
 ext/mysqli/tests/mysqli_select_db.phpt             |    2 +-
 ext/mysqli/tests/mysqli_send_query.phpt            |    2 +-
 ext/mysqli/tests/mysqli_set_charset.phpt           |    2 +-
 .../tests/mysqli_set_local_infile_handler.phpt     |    2 +-
 ...qli_set_local_infile_handler_bad_character.phpt |    2 +-
 ...i_set_local_infile_handler_buffer_overflow.phpt |    2 +-
 ...mysqli_set_local_infile_handler_close_link.phpt |    5 +-
 .../mysqli_set_local_infile_handler_closefile.phpt |    5 +-
 .../mysqli_set_local_infile_handler_closures.phpt  |    2 +-
 .../mysqli_set_local_infile_handler_kill_link.phpt |    5 +-
 ...sqli_set_local_infile_handler_negative_len.phpt |    2 +-
 ...ysqli_set_local_infile_handler_nested_call.phpt |    2 +-
 .../mysqli_set_local_infile_handler_new_query.phpt |    2 +-
 .../mysqli_set_local_infile_handler_nofileop.phpt  |    2 +-
 ...ysqli_set_local_infile_handler_openbasedir.phpt |    2 +-
 ...li_set_local_infile_handler_replace_buffer.phpt |    2 +-
 .../mysqli_set_local_infile_handler_short_len.phpt |    2 +-
 ...mysqli_set_local_infile_handler_unregister.phpt |    2 +-
 ext/mysqli/tests/mysqli_set_opt.phpt               |    2 +-
 ...li_set_opt_numeric_and_datetime_as_unicode.phpt |    3 +-
 ext/mysqli/tests/mysqli_sqlstate.phpt              |    2 +-
 ext/mysqli/tests/mysqli_ssl_set.phpt               |    2 +-
 ext/mysqli/tests/mysqli_stat.phpt                  |    6 +-
 ext/mysqli/tests/mysqli_stmt_affected_rows.phpt    |    2 +-
 ext/mysqli/tests/mysqli_stmt_attr_get.phpt         |    2 +-
 .../tests/mysqli_stmt_attr_get_prefetch.phpt       |    1 -
 ext/mysqli/tests/mysqli_stmt_attr_set.phpt         |   18 +-
 ext/mysqli/tests/mysqli_stmt_bind_param.phpt       |    2 +-
 ...sqli_stmt_bind_param_check_param_no_change.phpt |    1 -
 .../tests/mysqli_stmt_bind_param_references.phpt   |    1 -
 .../mysqli_stmt_bind_param_type_juggling.phpt      |    1 -
 ext/mysqli/tests/mysqli_stmt_bind_result.phpt      |    2 +-
 ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt  |    2 +-
 .../tests/mysqli_stmt_bind_result_references.phpt  |    1 -
 ext/mysqli/tests/mysqli_stmt_close.phpt            |    2 +-
 ext/mysqli/tests/mysqli_stmt_data_seek.phpt        |    2 +-
 ext/mysqli/tests/mysqli_stmt_datatype_change.phpt  |    4 +-
 ext/mysqli/tests/mysqli_stmt_errno.phpt            |    2 +-
 ext/mysqli/tests/mysqli_stmt_error.phpt            |    2 +-
 ext/mysqli/tests/mysqli_stmt_execute.phpt          |    2 +-
 .../tests/mysqli_stmt_execute_stored_proc.phpt     |    2 +-
 ext/mysqli/tests/mysqli_stmt_fetch.phpt            |    2 +-
 .../mysqli_stmt_fetch_fields_win32_unicode.phpt    |    4 +-
 ext/mysqli/tests/mysqli_stmt_field_count.phpt      |    2 +-
 ext/mysqli/tests/mysqli_stmt_free_result.phpt      |    2 +-
 ext/mysqli/tests/mysqli_stmt_get_result.phpt       |    2 +-
 ext/mysqli/tests/mysqli_stmt_get_result2.phpt      |    2 +-
 .../tests/mysqli_stmt_get_result_field_count.phpt  |    1 -
 .../tests/mysqli_stmt_get_result_metadata.phpt     |    1 -
 ...ysqli_stmt_get_result_metadata_fetch_field.phpt |    1 -
 .../tests/mysqli_stmt_get_result_non_select.phpt   |    1 -
 ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt  |    1 -
 ext/mysqli/tests/mysqli_stmt_init.phpt             |    2 +-
 ext/mysqli/tests/mysqli_stmt_insert_id.phpt        |    2 +-
 ext/mysqli/tests/mysqli_stmt_num_rows.phpt         |    2 +-
 ext/mysqli/tests/mysqli_stmt_param_count.phpt      |    2 +-
 ext/mysqli/tests/mysqli_stmt_prepare.phpt          |    2 +-
 ext/mysqli/tests/mysqli_stmt_reset.phpt            |    2 +-
 ext/mysqli/tests/mysqli_stmt_result_metadata.phpt  |    2 +-
 .../mysqli_stmt_result_metadata_sqltests.phpt      |    1 -
 ext/mysqli/tests/mysqli_stmt_send_long_data.phpt   |    2 +-
 ...i_stmt_send_long_data_packet_size_libmysql.phpt |    1 -
 ...li_stmt_send_long_data_packet_size_mysqlnd.phpt |    1 -
 ext/mysqli/tests/mysqli_stmt_sqlstate.phpt         |    2 +-
 ext/mysqli/tests/mysqli_stmt_store_result.phpt     |    2 +-
 ext/mysqli/tests/mysqli_stmt_unclonable.phpt       |    2 +-
 ext/mysqli/tests/mysqli_store_result.phpt          |    2 +-
 ext/mysqli/tests/mysqli_thread_id.phpt             |    2 +-
 ext/mysqli/tests/mysqli_unclonable.phpt            |    2 +-
 ext/mysqli/tests/mysqli_use_result.phpt            |    2 +-
 ext/mysqli/tests/mysqli_warning_count.phpt         |    2 +-
 ext/mysqli/tests/mysqli_warning_unclonable.phpt    |    2 +-
 ext/mysqlnd/config.w32                             |   12 +-
 ext/mysqlnd/config9.m4                             |   33 +-
 ext/mysqlnd/mysqlnd.c                              |  879 +-
 ext/mysqlnd/mysqlnd.h                              |  165 +-
 ext/mysqlnd/mysqlnd_block_alloc.c                  |    6 +-
 ext/mysqlnd/mysqlnd_block_alloc.h                  |    6 +-
 ext/mysqlnd/mysqlnd_charset.c                      |   59 +-
 ext/mysqlnd/mysqlnd_charset.h                      |    2 +-
 ext/mysqlnd/mysqlnd_debug.c                        |  158 +-
 ext/mysqlnd/mysqlnd_debug.h                        |   71 +-
 ext/mysqlnd/mysqlnd_enum_n_def.h                   |   98 +-
 ext/mysqlnd/mysqlnd_libmysql_compat.h              |    2 +-
 ext/mysqlnd/mysqlnd_loaddata.c                     |   20 +-
 ext/mysqlnd/mysqlnd_net.c                          |  744 +
 ext/mysqlnd/mysqlnd_net.h                          |   38 +
 ext/mysqlnd/mysqlnd_palloc.c                       |  605 -
 ext/mysqlnd/mysqlnd_palloc.h                       |  116 -
 ext/mysqlnd/mysqlnd_portability.h                  |   89 +-
 ext/mysqlnd/mysqlnd_priv.h                         |   22 +-
 ext/mysqlnd/mysqlnd_ps.c                           |  285 +-
 ext/mysqlnd/mysqlnd_ps_codec.c                     |    2 +-
 ext/mysqlnd/mysqlnd_qcache.c                       |  141 -
 ext/mysqlnd/mysqlnd_result.c                       |  817 +-
 ext/mysqlnd/mysqlnd_result.h                       |   20 +-
 ext/mysqlnd/mysqlnd_result_meta.c                  |   45 +-
 ext/mysqlnd/mysqlnd_result_meta.h                  |    4 +-
 ext/mysqlnd/mysqlnd_statistics.c                   |   96 +-
 ext/mysqlnd/mysqlnd_statistics.h                   |  266 +-
 ext/mysqlnd/mysqlnd_structs.h                      |  325 +-
 ext/mysqlnd/mysqlnd_wireprotocol.c                 |  857 +-
 ext/mysqlnd/mysqlnd_wireprotocol.h                 |  190 +-
 ext/mysqlnd/php_mysqlnd.c                          |   33 +-
 ext/mysqlnd/php_mysqlnd.h                          |    4 +-
 ext/oci8/README                                    |  460 +-
 ext/oci8/oci8.c                                    |  159 +-
 ext/oci8/oci8_collection.c                         |    4 +-
 ext/oci8/oci8_interface.c                          |  170 +-
 ext/oci8/oci8_lob.c                                |   34 +-
 ext/oci8/oci8_statement.c                          |  113 +-
 ext/oci8/package.xml                               |  112 +-
 ext/oci8/php_oci8.h                                |    6 +-
 ext/oci8/php_oci8_int.h                            |   21 +-
 ext/oci8/tests/bind_char_1.phpt                    |    4 +-
 ext/oci8/tests/bind_char_2.phpt                    |    4 +-
 ext/oci8/tests/bind_char_3.phpt                    |    4 +-
 ext/oci8/tests/bind_char_4.phpt                    |    4 +-
 ext/oci8/tests/bind_error.phpt                     |   70 +
 ext/oci8/tests/bug26133.phpt                       |   76 +-
 ext/oci8/tests/bug27303.phpt                       |    4 +-
 ext/oci8/tests/bug27303_2.phpt                     |    4 +-
 ext/oci8/tests/bug27303_4.phpt                     |    4 +-
 ext/oci8/tests/bug32325.phpt                       |   54 +-
 ext/oci8/tests/bug36403.phpt                       |   76 +
 ext/oci8/tests/bug43497.phpt                       |   22 +-
 ext/oci8/tests/bug47281.phpt                       |   73 +
 ext/oci8/tests/commit.phpt                         |   60 +-
 ext/oci8/tests/conn_attr.inc                       |  151 +
 ext/oci8/tests/conn_attr_1.phpt                    |  104 +
 ext/oci8/tests/conn_attr_2.phpt                    |  111 +
 ext/oci8/tests/conn_attr_3.phpt                    |   94 +
 ext/oci8/tests/conn_attr_4.phpt                    |  121 +
 ext/oci8/tests/conn_attr_5.phpt                    |   76 +
 ext/oci8/tests/cursor_bind_err.phpt                |   52 +-
 ext/oci8/tests/cursors_old.phpt                    |   66 +-
 ext/oci8/tests/debug.phpt                          |   10 +-
 ext/oci8/tests/default_prefetch.phpt               |   49 +-
 ext/oci8/tests/default_prefetch1.phpt              |   50 +-
 ext/oci8/tests/default_prefetch2.phpt              |   49 +-
 ext/oci8/tests/define.phpt                         |   51 +-
 ext/oci8/tests/define1.phpt                        |   45 +-
 ext/oci8/tests/define4.phpt                        |   55 +-
 ext/oci8/tests/define5.phpt                        |   60 +-
 ext/oci8/tests/define_old.phpt                     |   52 +-
 ext/oci8/tests/driver_name.phpt                    |   71 +
 ext/oci8/tests/drop_table.inc                      |   15 +-
 ext/oci8/tests/drop_type.inc                       |   15 +-
 ext/oci8/tests/edition_1.phpt                      |  156 +
 ext/oci8/tests/edition_2.phpt                      |  248 +
 ext/oci8/tests/extauth_01.phpt                     |    8 +-
 ext/oci8/tests/extauth_02.phpt                     |    8 +-
 ext/oci8/tests/extauth_03.phpt                     |    8 +-
 ext/oci8/tests/fetch.phpt                          |   70 +-
 ext/oci8/tests/fetch_all.phpt                      |  139 +-
 ext/oci8/tests/fetch_all3.phpt                     |  383 +-
 ext/oci8/tests/fetch_all4.phpt                     |   82 +
 ext/oci8/tests/fetch_all5.phpt                     |  127 +
 ext/oci8/tests/fetch_into.phpt                     |   88 +-
 ext/oci8/tests/fetch_object.phpt                   |  155 +-
 ext/oci8/tests/fetch_object_2.phpt                 |  127 +
 ext/oci8/tests/fetch_row.phpt                      |   86 +-
 ext/oci8/tests/field_funcs1.phpt                   |   67 +-
 ext/oci8/tests/field_funcs2.phpt                   |   11 +-
 ext/oci8/tests/lob_043.phpt                        |  101 +
 ext/oci8/tests/num.phpt                            |   65 +-
 ext/oci8/tests/oci8safemode.phpt                   |    2 +-
 ext/oci8/tests/password_new.phpt                   |   10 +-
 ext/oci8/tests/password_old.phpt                   |   10 +-
 ext/oci8/tests/prefetch.phpt                       |   51 +-
 ext/oci8/tests/prefetch_old.phpt                   |   48 +-
 ext/oci8/tests/refcur_prefetch_1.phpt              |  256 +
 ext/oci8/tests/refcur_prefetch_2.phpt              |  317 +
 ext/oci8/tests/refcur_prefetch_3.phpt              |  161 +
 ext/oci8/tests/reflection1.phpt                    |   44 +
 ext/oci8/tests/xmltype_02.phpt                     |  197 +
 ext/odbc/birdstep.c                                |    4 +-
 ext/odbc/php_birdstep.h                            |    4 +-
 ext/odbc/php_odbc.c                                |   24 +-
 ext/odbc/php_odbc.h                                |    4 +-
 ext/odbc/php_odbc_includes.h                       |    4 +-
 ext/openssl/openssl.c                              |   25 +-
 ext/openssl/php_openssl.h                          |    4 +-
 ext/openssl/tests/bug48182.phpt                    |    6 +-
 ext/openssl/tests/sni_001.phpt                     |  178 +
 ext/openssl/xp_ssl.c                               |   63 +-
 ext/pcntl/pcntl.c                                  |   21 +-
 ext/pcntl/php_pcntl.h                              |    4 +-
 ext/pcntl/php_signal.c                             |    4 +-
 ext/pcntl/php_signal.h                             |    4 +-
 ext/pcre/pcrelib/ChangeLog                         |  164 +
 ext/pcre/pcrelib/HACKING                           |   44 +-
 ext/pcre/pcrelib/LICENCE                           |    2 +-
 ext/pcre/pcrelib/NEWS                              |   15 +
 ext/pcre/pcrelib/NON-UNIX-USE                      |   96 +-
 ext/pcre/pcrelib/README                            |   52 +-
 ext/pcre/pcrelib/config.h                          |   12 +-
 ext/pcre/pcrelib/doc/pcre.txt                      | 2888 ++--
 ext/pcre/pcrelib/pcre.h                            |   12 +-
 ext/pcre/pcrelib/pcre_compile.c                    |  302 +-
 ext/pcre/pcrelib/pcre_exec.c                       | 1292 +-
 ext/pcre/pcrelib/pcre_fullinfo.c                   |   11 +-
 ext/pcre/pcrelib/pcre_internal.h                   |  116 +-
 ext/pcre/pcrelib/pcre_printint.src                 |   13 +
 ext/pcre/pcrelib/pcre_study.c                      |  424 +-
 ext/pcre/pcrelib/pcre_try_flipped.c                |    6 +-
 ext/pcre/pcrelib/pcre_ucd.c                        |   18 +
 ext/pcre/pcrelib/pcredemo.c                        |   14 +-
 ext/pcre/pcrelib/pcreposix.c                       |   49 +-
 ext/pcre/pcrelib/pcreposix.h                       |   21 +-
 ext/pcre/pcrelib/testdata/grepoutput               |   24 +
 ext/pcre/pcrelib/testdata/testinput1               |    5 +-
 ext/pcre/pcrelib/testdata/testinput10              |    2 +-
 ext/pcre/pcrelib/testdata/testinput2               |  854 +-
 ext/pcre/pcrelib/testdata/testinput3               |    6 +-
 ext/pcre/pcrelib/testdata/testinput4               |   27 +-
 ext/pcre/pcrelib/testdata/testinput5               |  307 +-
 ext/pcre/pcrelib/testdata/testinput6               |  205 +-
 ext/pcre/pcrelib/testdata/testinput7               |  123 +-
 ext/pcre/pcrelib/testdata/testinput8               |   26 +-
 ext/pcre/pcrelib/testdata/testinput9               |    6 +-
 ext/pcre/pcrelib/testdata/testoutput1              |    5 +-
 ext/pcre/pcrelib/testdata/testoutput10             |    2 +-
 ext/pcre/pcrelib/testdata/testoutput2              | 1917 ++-
 ext/pcre/pcrelib/testdata/testoutput3              |    8 +-
 ext/pcre/pcrelib/testdata/testoutput4              |   44 +-
 ext/pcre/pcrelib/testdata/testoutput5              |  548 +-
 ext/pcre/pcrelib/testdata/testoutput6              |  474 +-
 ext/pcre/pcrelib/testdata/testoutput7              |  222 +-
 ext/pcre/pcrelib/testdata/testoutput8              |   44 +-
 ext/pcre/pcrelib/testdata/testoutput9              |    6 +-
 ext/pcre/php_pcre.c                                |    8 +-
 ext/pcre/php_pcre.h                                |    4 +-
 ext/pcre/tests/bug33200.phpt                       |    2 +-
 ext/pcre/upgrade-pcre.php                          |    7 +-
 ext/pdo/pdo.c                                      |   42 +-
 ext/pdo/pdo_dbh.c                                  |   11 +-
 ext/pdo/pdo_sql_parser.c                           |    4 +-
 ext/pdo/pdo_sql_parser.c.orig                      |    4 +-
 ext/pdo/pdo_sql_parser.re                          |    4 +-
 ext/pdo/pdo_sqlstate.c                             |    4 +-
 ext/pdo/pdo_stmt.c                                 |  118 +-
 ext/pdo/php_pdo.h                                  |    4 +-
 ext/pdo/php_pdo_driver.h                           |    4 +-
 ext/pdo/php_pdo_int.h                              |    4 +-
 ext/pdo/tests/bug_44861.phpt                       |    2 +-
 ext/pdo/tests/bug_50458.phpt                       |   29 +
 ext/pdo_dblib/config.m4                            |    2 +-
 ext/pdo_dblib/dblib_driver.c                       |    6 +-
 ext/pdo_dblib/dblib_stmt.c                         |    4 +-
 ext/pdo_dblib/pdo_dblib.c                          |    4 +-
 ext/pdo_dblib/php_pdo_dblib.h                      |    4 +-
 ext/pdo_dblib/php_pdo_dblib_int.h                  |    4 +-
 ext/pdo_firebird/config.m4                         |    2 +-
 ext/pdo_firebird/firebird_driver.c                 |    6 +-
 ext/pdo_firebird/firebird_statement.c              |    4 +-
 ext/pdo_firebird/pdo_firebird.c                    |    4 +-
 ext/pdo_firebird/php_pdo_firebird.h                |    4 +-
 ext/pdo_firebird/php_pdo_firebird_int.h            |    4 +-
 ext/pdo_mysql/config.m4                            |   71 +-
 ext/pdo_mysql/mysql_driver.c                       |   10 +-
 ext/pdo_mysql/mysql_statement.c                    |   10 +-
 ext/pdo_mysql/pdo_mysql.c                          |   55 +-
 ext/pdo_mysql/php_pdo_mysql.h                      |    4 +-
 ext/pdo_mysql/php_pdo_mysql_int.h                  |   16 +-
 ext/pdo_mysql/tests/bug44327.phpt                  |   24 +-
 ext/pdo_mysql/tests/bug46292.phpt                  |   21 +-
 ext/pdo_mysql/tests/bug_33689.phpt                 |    9 +-
 ext/pdo_mysql/tests/bug_37445.phpt                 |    1 -
 ext/pdo_mysql/tests/bug_39858.phpt                 |   22 +-
 ext/pdo_mysql/tests/bug_41125.phpt                 |    7 +
 ext/pdo_mysql/tests/bug_41698.phpt                 |   10 +-
 ext/pdo_mysql/tests/bug_41997.phpt                 |   14 +-
 ext/pdo_mysql/tests/bug_42499.phpt                 |    8 +-
 ext/pdo_mysql/tests/bug_44454.phpt                 |    8 +-
 ext/pdo_mysql/tests/bug_44707.phpt                 |   10 +-
 ext/pdo_mysql/tests/bug_45120.phpt                 |    2 -
 ext/pdo_mysql/tests/bug_50323.phpt                 |   61 +
 ext/pdo_mysql/tests/bug_pecl_12925.phpt            |   10 +-
 ext/pdo_mysql/tests/bug_pecl_7976.phpt             |   25 +-
 ext/pdo_mysql/tests/mysql_pdo_test.inc             |    9 +-
 ext/pdo_mysql/tests/pdo_mysql___construct.phpt     |    6 +-
 ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt |    2 +-
 .../tests/pdo_mysql___construct_options.phpt       |   14 +-
 .../pdo_mysql___construct_options_libmysql.phpt    |    8 +-
 ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt |    1 +
 ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt |    7 +-
 ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt       |  131 +-
 .../tests/pdo_mysql_attr_client_version.phpt       |    1 +
 .../tests/pdo_mysql_attr_connection_status.phpt    |    1 +
 .../tests/pdo_mysql_attr_driver_name.phpt          |    3 +-
 .../tests/pdo_mysql_attr_fetch_table_names.phpt    |    9 +-
 .../tests/pdo_mysql_attr_init_command.phpt         |    3 +-
 .../tests/pdo_mysql_attr_max_buffer_size.phpt      |    7 +
 .../tests/pdo_mysql_attr_oracle_nulls.phpt         |   41 +-
 .../tests/pdo_mysql_attr_server_version.phpt       |    1 +
 .../tests/pdo_mysql_attr_statement_class.phpt      |   25 +-
 .../tests/pdo_mysql_begintransaction.phpt          |   29 +-
 ext/pdo_mysql/tests/pdo_mysql_bit.phpt             |   15 +-
 ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt |    6 +-
 ext/pdo_mysql/tests/pdo_mysql_commit.phpt          |    8 +-
 ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt       |    7 +-
 ext/pdo_mysql/tests/pdo_mysql_errorinfo.phpt       |    8 +-
 ext/pdo_mysql/tests/pdo_mysql_exec.phpt            |    8 +-
 ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt        |   18 +-
 ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt  |    8 +-
 ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt     |   10 +-
 ext/pdo_mysql/tests/pdo_mysql_fetch_both.phpt      |   18 +-
 ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt   |    7 +-
 ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt  |    7 +-
 ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt        |    6 +-
 ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt         |    1 +
 .../tests/pdo_mysql_prepare_emulated.phpt          |   75 +-
 .../pdo_mysql_prepare_emulated_anonymous.phpt      |   15 +-
 ...ql_prepare_emulated_placeholder_everywhere.phpt |    7 +-
 .../tests/pdo_mysql_prepare_load_data.phpt         |    9 +-
 .../tests/pdo_mysql_prepare_match_against.phpt     |    8 +-
 ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt  |    7 +-
 .../pdo_mysql_prepare_native_clear_error.phpt      |    7 +-
 .../tests/pdo_mysql_prepare_native_column.phpt     |    7 +-
 ...mysql_prepare_native_dup_named_placeholder.phpt |    7 +-
 .../pdo_mysql_prepare_native_mixed_style.phpt      |    6 +-
 ...pdo_mysql_prepare_native_named_placeholder.phpt |    7 +-
 ...ysql_prepare_native_placeholder_everywhere.phpt |    7 +-
 ext/pdo_mysql/tests/pdo_mysql_rollback.phpt        |   10 +-
 ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt |    7 +-
 ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt  |    6 +-
 .../tests/pdo_mysql_stmt_bindparam_types.phpt      |    6 +-
 ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt  |    6 +-
 .../tests/pdo_mysql_stmt_blobfromsteam.phpt        |   11 +-
 ext/pdo_mysql/tests/pdo_mysql_stmt_blobs.phpt      |    7 +
 .../tests/pdo_mysql_stmt_closecursor.phpt          |    8 +-
 .../tests/pdo_mysql_stmt_closecursor_empty.phpt    |    5 +
 .../tests/pdo_mysql_stmt_columncount.phpt          |    6 +-
 ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt  |    2 -
 ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt  |   27 +-
 .../tests/pdo_mysql_stmt_fetch_non_select.phpt     |    6 +-
 .../tests/pdo_mysql_stmt_fetch_serialize.phpt      |   25 +-
 .../tests/pdo_mysql_stmt_fetchobject.phpt          |   16 +-
 ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt |   22 +-
 ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt |  166 +-
 ext/pdo_mysql/tests/pdo_mysql_stmt_rowcount.phpt   |    6 +-
 .../tests/pdo_mysql_stmt_unbuffered_2050.phpt      |   54 +-
 .../tests/pdo_mysql_stmt_variable_columncount.phpt |    1 +
 ext/pdo_mysql/tests/pdo_mysql_subclass.phpt        |   14 +-
 ext/pdo_mysql/tests/pdo_mysql_types.phpt           |    6 +
 ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt  |    6 +
 ext/pdo_mysql/tests/pecl_bug_5200.phpt             |    8 +-
 ext/pdo_mysql/tests/pecl_bug_5780.phpt             |   15 +-
 ext/pdo_mysql/tests/pecl_bug_5802.phpt             |   21 +-
 ext/pdo_oci/config.m4                              |    4 +-
 ext/pdo_oci/oci_driver.c                           |    6 +-
 ext/pdo_oci/oci_statement.c                        |    4 +-
 ext/pdo_oci/pdo_oci.c                              |    4 +-
 ext/pdo_oci/php_pdo_oci.h                          |    4 +-
 ext/pdo_oci/php_pdo_oci_int.h                      |    4 +-
 ext/pdo_odbc/config.m4                             |    2 +-
 ext/pdo_odbc/odbc_driver.c                         |    6 +-
 ext/pdo_odbc/odbc_stmt.c                           |    4 +-
 ext/pdo_odbc/pdo_odbc.c                            |    4 +-
 ext/pdo_odbc/php_pdo_odbc.h                        |    4 +-
 ext/pdo_odbc/php_pdo_odbc_int.h                    |    4 +-
 ext/pdo_pgsql/config.m4                            |    2 +-
 ext/pdo_pgsql/pdo_pgsql.c                          |    8 +-
 ext/pdo_pgsql/pgsql_driver.c                       |   36 +-
 ext/pdo_pgsql/pgsql_statement.c                    |    6 +-
 ext/pdo_pgsql/php_pdo_pgsql.h                      |    4 +-
 ext/pdo_pgsql/php_pdo_pgsql_int.h                  |   12 +-
 ext/pdo_pgsql/tests/bug48764.phpt                  |  134 +
 ext/pdo_pgsql/tests/bug_33876.phpt                 |   10 +-
 ext/pdo_pgsql/tests/bug_49985.phpt                 |   35 +
 ext/pdo_sqlite/config.m4                           |    2 +-
 ext/pdo_sqlite/config.w32                          |    4 +-
 ext/pdo_sqlite/pdo_sqlite.c                        |    4 +-
 ext/pdo_sqlite/php_pdo_sqlite.h                    |    4 +-
 ext/pdo_sqlite/php_pdo_sqlite_int.h                |    4 +-
 ext/pdo_sqlite/sqlite_driver.c                     |   18 +-
 ext/pdo_sqlite/sqlite_statement.c                  |    4 +-
 ext/pdo_sqlite/tests/bug50728.phpt                 |   16 +
 ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt       |  130 +
 ext/pgsql/pgsql.c                                  |   28 +-
 ext/pgsql/php_pgsql.h                              |    4 +-
 ext/pgsql/tests/10pg_convert.phpt                  |    5 +-
 ext/pgsql/tests/10pg_convert_85.phpt               |   29 +
 ext/pgsql/tests/12pg_insert.phpt                   |    5 +-
 ext/pgsql/tests/12pg_insert_85.phpt                |   24 +
 ext/pgsql/tests/13pg_select.phpt                   |    5 +-
 ext/pgsql/tests/13pg_select_85.phpt                |   37 +
 ext/pgsql/tests/14pg_update.phpt                   |    5 +-
 ext/pgsql/tests/14pg_update_85.phpt                |   25 +
 ext/pgsql/tests/bug37100.phpt                      |    5 +-
 ext/pgsql/tests/bug37100_85.phpt                   |   46 +
 ext/pgsql/tests/skipif.inc                         |   15 +-
 ext/phar/phar.c                                    |    6 +-
 ext/phar/phar_object.c                             |    4 +-
 ext/phar/php_phar.h                                |    2 +-
 ext/phar/tests/phar_begin_setstub_commit.phpt      |    4 +-
 ext/phar/tests/phar_begin_setstub_commitU.phpt     |    4 +-
 ext/phar/tests/phar_buildfromdirectory6.phpt       |    2 +-
 ext/phar/tests/tar/phar_begin_setstub_commit.phpt  |    4 +-
 ext/phar/tests/tar/phar_begin_setstub_commitU.phpt |    4 +-
 ext/phar/tests/zip/phar_begin_setstub_commit.phpt  |    4 +-
 ext/phar/tests/zip/phar_begin_setstub_commitU.phpt |    4 +-
 ext/phar/tests/zip/phar_stub.phpt                  |    6 -
 ext/posix/php_posix.h                              |    4 +-
 ext/posix/posix.c                                  |    6 +-
 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_errno_variation1.phpt        |    1 +
 ext/posix/tests/posix_errno_variation2.phpt        |    1 +
 ext/posix/tests/posix_mkfifo_safemode.phpt         |    2 +-
 ext/posix/tests/posix_seteuid_variation2.phpt      |    1 +
 ext/posix/tests/posix_seteuid_variation3.phpt      |    1 +
 ext/posix/tests/posix_seteuid_variation4.phpt      |    1 +
 ext/posix/tests/posix_seteuid_variation5.phpt      |    1 +
 ext/posix/tests/posix_setgid_variation2.phpt       |    3 +-
 ext/posix/tests/posix_setgid_variation3.phpt       |    1 +
 ext/posix/tests/posix_setgid_variation4.phpt       |    3 +-
 ext/posix/tests/posix_setgid_variation5.phpt       |    3 +-
 ext/posix/tests/posix_setuid_variation2.phpt       |    1 +
 ext/posix/tests/posix_setuid_variation3.phpt       |    1 +
 ext/posix/tests/posix_setuid_variation4.phpt       |    1 +
 ext/posix/tests/posix_setuid_variation5.phpt       |    1 +
 ext/posix/tests/posix_uname.phpt                   |    4 +-
 ext/posix/tests/posix_uname_basic.phpt             |    2 +-
 ext/pspell/php_pspell.h                            |    4 +-
 ext/pspell/pspell.c                                |    4 +-
 ext/readline/config.m4                             |    4 +-
 ext/readline/php_readline.h                        |    4 +-
 ext/readline/readline.c                            |    8 +-
 ext/readline/tests/readline_add_history_001.phpt   |    2 +-
 .../readline_callback_handler_install_001.phpt     |    2 +-
 .../readline_callback_handler_remove_001.phpt      |    2 +-
 ext/readline/tests/readline_list_history_001.phpt  |    2 +-
 ext/readline/tests/readline_read_history_001.phpt  |    2 +-
 ext/readline/tests/readline_write_history_001.phpt |    2 +-
 ext/recode/php_recode.h                            |    4 +-
 ext/recode/recode.c                                |    6 +-
 ext/reflection/php_reflection.c                    |  315 +-
 ext/reflection/php_reflection.h                    |    4 +-
 ext/reflection/tests/020.phpt                      |    1 -
 .../tests/ReflectionClass_hasProperty_001.phpt     |    2 +-
 .../tests/ReflectionClass_toString_001.phpt        |   81 +
 ext/reflection/tests/ReflectionMethod_basic2.phpt  |   10 +-
 .../tests/ReflectionMethod_setAccessible.phpt      |  111 +
 ext/reflection/tests/bug49719.phpt                 |   44 +
 ext/session/mod_files.c                            |   14 +-
 ext/session/mod_files.h                            |    4 +-
 ext/session/mod_mm.c                               |    4 +-
 ext/session/mod_mm.h                               |    4 +-
 ext/session/mod_user.c                             |    4 +-
 ext/session/mod_user.h                             |    4 +-
 ext/session/php_session.h                          |    4 +-
 ext/session/session.c                              |   33 +-
 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                         |    5 +-
 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/shmop/php_shmop.h                              |    2 +-
 ext/shmop/shmop.c                                  |    4 +-
 ext/simplexml/php_simplexml.h                      |    4 +-
 ext/simplexml/php_simplexml_exports.h              |    4 +-
 ext/simplexml/simplexml.c                          |    9 +-
 ext/simplexml/sxe.c                                |    4 +-
 ext/simplexml/sxe.h                                |    4 +-
 ext/snmp/config.w32                                |   21 +-
 ext/snmp/php_snmp.h                                |    4 +-
 ext/snmp/snmp.c                                    |    9 +-
 ext/soap/php_encoding.c                            |    6 +-
 ext/soap/php_encoding.h                            |    4 +-
 ext/soap/php_http.c                                |   42 +-
 ext/soap/php_http.h                                |    4 +-
 ext/soap/php_packet_soap.c                         |    4 +-
 ext/soap/php_packet_soap.h                         |    4 +-
 ext/soap/php_schema.c                              |    4 +-
 ext/soap/php_schema.h                              |    4 +-
 ext/soap/php_sdl.c                                 |    4 +-
 ext/soap/php_sdl.h                                 |    4 +-
 ext/soap/php_soap.h                                |    4 +-
 ext/soap/php_xml.c                                 |    7 +-
 ext/soap/php_xml.h                                 |    4 +-
 ext/soap/readme.html                               |  646 -
 ext/soap/soap.c                                    |   20 +-
 ext/soap/tests/server009.phpt                      |    3 +
 ext/sockets/config.m4                              |    3 +-
 ext/sockets/php_sockets.h                          |    6 +-
 ext/sockets/sockets.c                              |   12 +-
 ext/sockets/tests/socket_getpeername_ipv6loop.phpt |    7 +-
 ext/sockets/tests/socket_set_option_rcvtimeo.phpt  |    2 +-
 ext/sockets/tests/socket_set_option_seolinger.phpt |    2 +-
 ext/sockets/tests/socket_set_option_sndtimeo.phpt  |    2 +-
 ext/sockets/unix_socket_constants.h                |    4 +-
 ext/sockets/win32_socket_constants.h               |    4 +-
 ext/spl/php_spl.c                                  |    4 +-
 ext/spl/php_spl.h                                  |    2 +-
 ext/spl/spl_array.c                                |    5 +-
 ext/spl/spl_array.h                                |    4 +-
 ext/spl/spl_directory.c                            |    4 +-
 ext/spl/spl_directory.h                            |    4 +-
 ext/spl/spl_dllist.c                               |    4 +-
 ext/spl/spl_dllist.h                               |   10 +-
 ext/spl/spl_engine.c                               |    2 +-
 ext/spl/spl_engine.h                               |    4 +-
 ext/spl/spl_exceptions.c                           |    4 +-
 ext/spl/spl_exceptions.h                           |    4 +-
 ext/spl/spl_fixedarray.c                           |    4 +-
 ext/spl/spl_fixedarray.h                           |    6 +-
 ext/spl/spl_functions.c                            |    4 +-
 ext/spl/spl_functions.h                            |    4 +-
 ext/spl/spl_heap.c                                 |    4 +-
 ext/spl/spl_heap.h                                 |   12 +-
 ext/spl/spl_iterators.c                            |   14 +-
 ext/spl/spl_iterators.h                            |    4 +-
 ext/spl/spl_observer.c                             |    6 +-
 ext/spl/spl_observer.h                             |    4 +-
 ext/spl/tests/bug49263.phpt                        |   54 +
 ext/spl/tests/bug49972.phpt                        |   11 +
 ext/spl/tests/iterator_032.phpt                    |    2 +-
 ext/spl/tests/iterator_069.phpt                    |   17 +
 ext/spl/tests/iterator_070.phpt                    |   20 +
 ext/spl/tests/iterator_071.phpt                    |   32 +
 ...ursiveIteratorIterator_beginchildren_error.phpt |   36 +
 ...siveIteratorIterator_callHasChildren_error.phpt |   36 +
 ...ecursiveIteratorIterator_endchildren_error.phpt |   42 +
 ...ecursiveIteratorIterator_nextelement_error.phpt |   36 +
 ext/sqlite/config.m4                               |    2 +-
 ext/sqlite/pdo_sqlite2.c                           |    4 +-
 ext/sqlite/php_sqlite.h                            |    4 +-
 ext/sqlite/sess_sqlite.c                           |    4 +-
 ext/sqlite/sqlite.c                                |    6 +-
 ext/sqlite3/config.w32                             |    4 +-
 ext/sqlite3/libsqlite/sqlite3.c                    |21789 ++++++++++----------
 ext/sqlite3/libsqlite/sqlite3.h                    | 2915 ++--
 ext/sqlite3/libsqlite/sqlite3ext.h                 |    2 -
 ext/sqlite3/php_sqlite3.h                          |    4 +-
 ext/sqlite3/php_sqlite3_structs.h                  |    4 +-
 ext/sqlite3/sqlite3.c                              |   16 +-
 ext/standard/array.c                               |   40 +-
 ext/standard/assert.c                              |    4 +-
 ext/standard/base64.c                              |    4 +-
 ext/standard/base64.h                              |    4 +-
 ext/standard/basic_functions.c                     |   60 +-
 ext/standard/basic_functions.h                     |    6 +-
 ext/standard/browscap.c                            |   13 +-
 ext/standard/config.m4                             |  124 +-
 ext/standard/config.w32                            |    6 +-
 ext/standard/crc32.c                               |    4 +-
 ext/standard/crc32.h                               |    4 +-
 ext/standard/credits.c                             |    4 +-
 ext/standard/credits.h                             |    4 +-
 ext/standard/crypt.c                               |  102 +-
 ext/standard/crypt_blowfish.c                      |    3 +-
 ext/standard/crypt_freesec.c                       |  130 +-
 ext/standard/crypt_sha256.c                        |  759 +
 ext/standard/crypt_sha512.c                        |  823 +
 ext/standard/css.c                                 |    4 +-
 ext/standard/css.h                                 |    4 +-
 ext/standard/cyr_convert.c                         |    4 +-
 ext/standard/cyr_convert.h                         |    4 +-
 ext/standard/datetime.c                            |    4 +-
 ext/standard/datetime.h                            |    4 +-
 ext/standard/dir.c                                 |    4 +-
 ext/standard/dl.c                                  |   14 +-
 ext/standard/dl.h                                  |    4 +-
 ext/standard/dns.c                                 |   16 +-
 ext/standard/exec.c                                |    8 +-
 ext/standard/exec.h                                |    4 +-
 ext/standard/file.c                                |   23 +-
 ext/standard/file.h                                |    4 +-
 ext/standard/filestat.c                            |   71 +-
 ext/standard/filters.c                             |    4 +-
 ext/standard/flock_compat.c                        |    4 +-
 ext/standard/flock_compat.h                        |   13 +-
 ext/standard/formatted_print.c                     |    8 +-
 ext/standard/fsock.c                               |    4 +-
 ext/standard/fsock.h                               |    4 +-
 ext/standard/ftok.c                                |    4 +-
 ext/standard/ftp_fopen_wrapper.c                   |   17 +-
 ext/standard/head.c                                |    4 +-
 ext/standard/head.h                                |    4 +-
 ext/standard/html.c                                |  308 +-
 ext/standard/html.h                                |    4 +-
 ext/standard/http.c                                |    4 +-
 ext/standard/http_fopen_wrapper.c                  |   23 +-
 ext/standard/image.c                               |    4 +-
 ext/standard/incomplete_class.c                    |    4 +-
 ext/standard/info.c                                |    4 +-
 ext/standard/info.h                                |    4 +-
 ext/standard/iptc.c                                |    4 +-
 ext/standard/lcg.c                                 |   11 +-
 ext/standard/levenshtein.c                         |    4 +-
 ext/standard/link.c                                |    4 +-
 ext/standard/link_win32.c                          |    4 +-
 ext/standard/mail.c                                |    6 +-
 ext/standard/math.c                                |    4 +-
 ext/standard/md5.c                                 |    4 +-
 ext/standard/md5.h                                 |    4 +-
 ext/standard/metaphone.c                           |    4 +-
 ext/standard/microtime.c                           |    4 +-
 ext/standard/microtime.h                           |    4 +-
 ext/standard/pack.c                                |    4 +-
 ext/standard/pack.h                                |    4 +-
 ext/standard/pageinfo.c                            |    8 +-
 ext/standard/pageinfo.h                            |    4 +-
 ext/standard/php_array.h                           |    4 +-
 ext/standard/php_assert.h                          |    4 +-
 ext/standard/php_browscap.h                        |    4 +-
 ext/standard/php_crypt.h                           |    4 +-
 ext/standard/php_crypt_r.c                         |    4 +-
 ext/standard/php_crypt_r.h                         |    6 +-
 ext/standard/php_dir.h                             |    4 +-
 ext/standard/php_dns.h                             |    8 +-
 ext/standard/php_ext_syslog.h                      |    4 +-
 ext/standard/php_filestat.h                        |    6 +-
 ext/standard/php_fopen_wrapper.c                   |    4 +-
 ext/standard/php_fopen_wrappers.h                  |    4 +-
 ext/standard/php_ftok.h                            |    4 +-
 ext/standard/php_http.h                            |    4 +-
 ext/standard/php_image.h                           |    4 +-
 ext/standard/php_incomplete_class.h                |    4 +-
 ext/standard/php_iptc.h                            |    4 +-
 ext/standard/php_lcg.h                             |    4 +-
 ext/standard/php_link.h                            |    4 +-
 ext/standard/php_mail.h                            |    4 +-
 ext/standard/php_math.h                            |    4 +-
 ext/standard/php_metaphone.h                       |    4 +-
 ext/standard/php_rand.h                            |    4 +-
 ext/standard/php_smart_str.h                       |    4 +-
 ext/standard/php_smart_str_public.h                |    4 +-
 ext/standard/php_standard.h                        |    4 +-
 ext/standard/php_string.h                          |    4 +-
 ext/standard/php_type.h                            |    4 +-
 ext/standard/php_uuencode.h                        |    4 +-
 ext/standard/php_var.h                             |    4 +-
 ext/standard/php_versioning.h                      |    4 +-
 ext/standard/proc_open.c                           |    4 +-
 ext/standard/proc_open.h                           |    4 +-
 ext/standard/quot_print.c                          |    4 +-
 ext/standard/quot_print.h                          |    4 +-
 ext/standard/rand.c                                |    4 +-
 ext/standard/scanf.c                               |    4 +-
 ext/standard/scanf.h                               |    4 +-
 ext/standard/sha1.c                                |    4 +-
 ext/standard/sha1.h                                |    4 +-
 ext/standard/soundex.c                             |    4 +-
 ext/standard/streamsfuncs.c                        |   28 +-
 ext/standard/streamsfuncs.h                        |    5 +-
 ext/standard/string.c                              |   62 +-
 ext/standard/strnatcmp.c                           |    2 +-
 ext/standard/syslog.c                              |    4 +-
 .../tests/array/array_flip_variation2.phpt         |  Bin 2178 -> 2179 bytes
 ext/standard/tests/array/bug50006.phpt             |   29 +
 ext/standard/tests/array/bug50006_1.phpt           |   29 +
 ext/standard/tests/array/bug50006_2.phpt           |   29 +
 ext/standard/tests/array/uasort_variation5.phpt    |    2 +-
 ext/standard/tests/bug49244.phpt                   |   32 +
 ext/standard/tests/file/005_variation2-win32.phpt  |   10 +-
 ext/standard/tests/file/bug26615.phpt              |    2 +-
 ext/standard/tests/file/bug47767.phpt              |    5 +
 ext/standard/tests/file/chmod_variation3.phpt      |   16 +-
 ext/standard/tests/file/fflush_basic.phpt          |    4 +
 ext/standard/tests/file/fgetss_basic1.phpt         |    6 +-
 ext/standard/tests/file/fgetss_basic2-win32.phpt   |    4 +-
 .../tests/file/fgetss_variation1-win32.phpt        |    6 +-
 .../tests/file/fgetss_variation3-win32.phpt        |    6 +-
 ext/standard/tests/file/fgetss_variation4.phpt     |    5 +
 .../tests/file/fgetss_variation5-win32.phpt        |    5 +-
 ext/standard/tests/file/file.inc                   |   20 +-
 .../tests/file/fopen_variation10-win32.phpt        |    5 +
 .../tests/file/fopen_variation11-win32.phpt        |    4 +
 ext/standard/tests/file/fopen_variation17.phpt     |    2 +-
 ext/standard/tests/file/fpassthru_basic.phpt       |    4 +-
 .../tests/file/mkdir_variation1-win32.phpt         |   16 +-
 ext/standard/tests/file/realpath_cache.phpt        |   30 +
 ext/standard/tests/file/realpath_cache_win32.phpt  |   38 +
 .../tests/file/rename_variation-win32.phpt         |    2 +-
 .../tests/file/rename_variation11-win32.phpt       |    6 +-
 .../tests/file/rename_variation12-win32.phpt       |  121 +
 ext/standard/tests/file/rename_variation12.phpt    |   12 +-
 .../tests/file/rename_variation13-win32.phpt       |  Bin 3614 -> 3947 bytes
 ext/standard/tests/file/rename_variation13.phpt    |   19 +-
 .../tests/file/rename_variation3-win32.phpt        |    5 +-
 .../tests/file/rename_variation6-win32.phpt        |    4 +
 .../tests/file/rename_variation8-win32.phpt        |   70 +
 ext/standard/tests/file/rename_variation8.phpt     |    5 +
 ext/standard/tests/file/rename_variation9.phpt     |    2 +-
 .../tests/file/rmdir_variation1-win32.phpt         |   16 +-
 ext/standard/tests/file/rmdir_variation1.phpt      |    2 +-
 .../tests/file/tempnam_variation3-win32.phpt       |  147 +-
 ext/standard/tests/file/tempnam_variation3.phpt    |    2 +-
 .../tests/file/tempnam_variation7-win32.phpt       |   73 +-
 ext/standard/tests/file/tempnam_variation7.phpt    |    2 +-
 ext/standard/tests/file/unlink_error-win32.phpt    |    6 +-
 ext/standard/tests/file/userstreams_003.phpt       |    2 +-
 ext/standard/tests/file/windows_acls/common.inc    |    2 +-
 .../tests/file/windows_links/bug48746.phpt         |   55 +
 .../tests/file/windows_links/bug48746_1.phpt       |   56 +
 .../tests/file/windows_links/bug48746_2.phpt       |   66 +
 .../tests/file/windows_links/bug48746_3.phpt       |   48 +
 .../.getservbyport_basic.phpt.swp                  |  Bin 12288 -> 0 bytes
 ext/standard/tests/general_functions/bug49692.ini  |    4 +
 ext/standard/tests/general_functions/bug49692.phpt |   20 +
 ext/standard/tests/general_functions/bug49847.phpt |   25 +
 ext/standard/tests/general_functions/bug50690.phpt |   14 +
 ext/standard/tests/general_functions/bug50732.phpt |   12 +
 .../general_functions/get_cfg_var_variation8.phpt  |    2 +-
 .../tests/general_functions/import_request.phpt    |   12 +-
 .../general_functions/is_callable_basic1.phpt      |    4 +-
 .../tests/general_functions/phpcredits.phpt        |    2 +-
 .../tests/general_functions/proc_nice_basic.phpt   |    4 +
 .../tests/general_functions/proc_nice_error.phpt   |    4 +
 .../general_functions/proc_nice_variation1.phpt    |    4 +
 .../general_functions/proc_nice_variation2.phpt    |    4 +
 .../general_functions/proc_nice_variation3.phpt    |    4 +
 .../general_functions/proc_nice_variation5.phpt    |    5 +
 .../general_functions/proc_nice_variation6.phpt    |    4 +
 .../general_functions/proc_nice_variation7.phpt    |    4 +
 .../tests/general_functions/putenv_error1.phpt     |    2 +-
 .../tests/general_functions/putenv_error2.phpt     |    2 +-
 ext/standard/tests/general_functions/strval.phpt   |    4 +-
 .../tests/general_functions/sunfuncts.phpt         |   42 -
 ext/standard/tests/mail/mail_basic.phpt            |    1 +
 ext/standard/tests/mail/mail_basic2.phpt           |   15 +-
 ext/standard/tests/mail/mail_variation2.phpt       |   11 +-
 .../tests/misc/syslog_vars_variation1.phpt         |    2 +-
 .../tests/misc/time_sleep_until_error2.phpt        |    4 +
 .../define_syslog_variables_variation-win32.phpt   |   97 -
 .../network/define_syslog_variables_variation.phpt |   13 +-
 ext/standard/tests/php_ini_loaded_file.phpt        |    5 +-
 ext/standard/tests/streams/bug49936.phpt           |   26 +
 ext/standard/tests/streams/bug49936_win32.phpt     |   30 +
 .../tests/streams/stream_resolve_include_path.phpt |   37 +
 ext/standard/tests/strings/bug49785.phpt           | 4124 ++++
 ext/standard/tests/strings/bug50052.phpt           |    2 +-
 ext/standard/tests/strings/bug50847.phpt           |   10 +
 ext/standard/tests/strings/bug51059.phpt           |   11 +
 .../strings/crypt_blowfish_invalid_rounds.phpt     |   22 +
 ext/standard/tests/strings/crypt_sha256.phpt       |   64 +
 ext/standard/tests/strings/crypt_sha512.phpt       |   65 +
 .../tests/strings/html_entity_decode_html4.phpt    |  516 +
 ext/standard/tests/strings/htmlentities-utf-2.phpt |   12 +-
 ext/standard/tests/strings/htmlentities-utf.phpt   |   12 +-
 ext/standard/tests/strings/htmlentities02.phpt     |    2 +-
 ext/standard/tests/strings/htmlentities03.phpt     |    2 +-
 ext/standard/tests/strings/htmlentities04.phpt     |    2 +-
 ext/standard/tests/strings/htmlentities15.phpt     |    2 +-
 ext/standard/tests/strings/htmlentities_html4.phpt |  305 +
 ext/standard/tests/strings/parse_str_basic3.phpt   |    2 +-
 .../tests/strings/setlocale_variation2.phpt        |    8 +-
 ext/standard/type.c                                |    4 +-
 ext/standard/uniqid.c                              |    4 +-
 ext/standard/uniqid.h                              |    4 +-
 ext/standard/url.c                                 |   27 +-
 ext/standard/url.h                                 |    4 +-
 ext/standard/url_scanner_ex.h                      |    4 +-
 ext/standard/user_filters.c                        |    4 +-
 ext/standard/uuencode.c                            |    4 +-
 ext/standard/var.c                                 |    6 +-
 ext/standard/var_unserializer.c                    |    6 +-
 ext/standard/var_unserializer.c.orig               |    6 +-
 ext/standard/var_unserializer.re                   |    4 +-
 ext/standard/versioning.c                          |    4 +-
 ext/sybase_ct/php_sybase_ct.c                      |    4 +-
 ext/sybase_ct/php_sybase_ct.h                      |    4 +-
 ext/sysvmsg/php_sysvmsg.h                          |    4 +-
 ext/sysvmsg/sysvmsg.c                              |    6 +-
 ext/sysvsem/php_sysvsem.h                          |    4 +-
 ext/sysvsem/sysvsem.c                              |    4 +-
 ext/sysvshm/php_sysvshm.h                          |    4 +-
 ext/sysvshm/sysvshm.c                              |    4 +-
 ext/tidy/php_tidy.h                                |    5 +-
 ext/tidy/tests/023.phpt                            |    8 -
 ext/tidy/tests/025.phpt                            |   14 -
 ext/tidy/tests/035.phpt                            |   12 +
 ext/tidy/tests/bug_50558.phpt                      |   28 +
 ext/tidy/tidy.c                                    |   31 +-
 ext/tokenizer/php_tokenizer.h                      |    4 +-
 ext/tokenizer/tokenizer.c                          |    4 +-
 ext/tokenizer/tokenizer_data.c                     |    4 +-
 ext/wddx/php_wddx.h                                |    4 +-
 ext/wddx/php_wddx_api.h                            |    4 +-
 ext/wddx/wddx.c                                    |    4 +-
 ext/xml/compat.c                                   |    2 +-
 ext/xml/expat_compat.h                             |    4 +-
 ext/xml/php_xml.h                                  |    4 +-
 ext/xml/tests/bug32001b.phpt                       |    4 +-
 ext/xml/tests/bug50576.phpt                        |  133 +
 ext/xml/xml.c                                      |   12 +-
 ext/xmlreader/php_xmlreader.c                      |    4 +-
 ext/xmlreader/php_xmlreader.h                      |    4 +-
 ext/xmlrpc/php_xmlrpc.h                            |    4 +-
 ext/xmlrpc/tests/bug50282.phpt                     |   43 +
 ext/xmlrpc/tests/bug50285.phpt                     |  115 +
 ext/xmlrpc/tests/bug50761.phpt                     |   62 +
 ext/xmlrpc/xmlrpc-epi-php.c                        |   76 +-
 ext/xmlwriter/php_xmlwriter.c                      |    4 +-
 ext/xmlwriter/php_xmlwriter.h                      |    4 +-
 ext/xsl/php_xsl.c                                  |    4 +-
 ext/xsl/php_xsl.h                                  |    4 +-
 ...rocessor_registerPHPFunctions-funcnostring.phpt |    4 +-
 ...ltprocessor_registerPHPFunctions-funcundef.phpt |    4 +-
 ext/xsl/xsl_fe.h                                   |    4 +-
 ext/xsl/xsltprocessor.c                            |    4 +-
 ext/zip/lib/zip_close.c                            |    9 +-
 ext/zip/lib/zip_dirent.c                           |   94 +-
 ext/zip/lib/zip_file_get_offset.c                  |    2 +-
 ext/zip/lib/zip_fread.c                            |   29 +-
 ext/zip/lib/zip_open.c                             |   21 +-
 ext/zip/lib/zipint.h                               |    5 +-
 ext/zip/php_zip.c                                  |   10 +-
 ext/zip/php_zip.h                                  |    4 +-
 ext/zip/tests/bug47667.phpt                        |    3 +-
 ext/zlib/php_zlib.h                                |    4 +-
 ext/zlib/tests/bug_40189.phpt                      |    2 +-
 ext/zlib/tests/gzencode_variation1-win32.phpt      |   37 +
 ext/zlib/zlib.c                                    |   29 +-
 ext/zlib/zlib_filter.c                             |    4 +-
 ext/zlib/zlib_fopen_wrapper.c                      |    4 +-
 ltmain.sh                                          |  823 +-
 main/SAPI.c                                        |    4 +-
 main/SAPI.h                                        |    4 +-
 main/build-defs.h.in                               |    3 +-
 main/fopen_wrappers.c                              |   67 +-
 main/fopen_wrappers.h                              |    4 +-
 main/getopt.c                                      |    4 +-
 main/internal_functions_nw.c                       |    4 +-
 main/internal_functions_win32.c                    |    4 +-
 main/logos.h                                       |    4 +-
 main/main.c                                        |   99 +-
 main/network.c                                     |    4 +-
 main/output.c                                      |    8 +-
 main/php.h                                         |    7 +-
 main/php3_compat.h                                 |    4 +-
 main/php_compat.h                                  |    4 +-
 main/php_config.h.in                               |   52 +-
 main/php_content_types.c                           |    4 +-
 main/php_content_types.h                           |    4 +-
 main/php_getopt.h                                  |    6 +-
 main/php_globals.h                                 |    4 +-
 main/php_ini.c                                     |    6 +-
 main/php_ini.h                                     |    4 +-
 main/php_logos.c                                   |    4 +-
 main/php_logos.h                                   |    4 +-
 main/php_main.h                                    |    4 +-
 main/php_memory_streams.h                          |    4 +-
 main/php_network.h                                 |   18 +-
 main/php_open_temporary_file.c                     |   14 +-
 main/php_open_temporary_file.h                     |    4 +-
 main/php_output.h                                  |    4 +-
 main/php_reentrancy.h                              |    4 +-
 main/php_scandir.c                                 |    4 +-
 main/php_scandir.h                                 |    4 +-
 main/php_sprintf.c                                 |    4 +-
 main/php_streams.h                                 |    4 +-
 main/php_syslog.h                                  |    4 +-
 main/php_ticks.c                                   |    4 +-
 main/php_ticks.h                                   |    4 +-
 main/php_variables.c                               |    4 +-
 main/php_variables.h                               |    4 +-
 main/php_version.h                                 |    6 +-
 main/reentrancy.c                                  |    4 +-
 main/rfc1867.c                                     |  307 +-
 main/rfc1867.h                                     |    4 +-
 main/safe_mode.c                                   |    4 +-
 main/safe_mode.h                                   |    4 +-
 main/snprintf.c                                    |    4 +-
 main/snprintf.h                                    |    4 +-
 main/spprintf.c                                    |    4 +-
 main/spprintf.h                                    |    4 +-
 main/streams/cast.c                                |   22 +-
 main/streams/filter.c                              |    4 +-
 main/streams/glob_wrapper.c                        |    4 +-
 main/streams/memory.c                              |    4 +-
 main/streams/mmap.c                                |    4 +-
 main/streams/php_stream_context.h                  |    4 +-
 main/streams/php_stream_filter_api.h               |    4 +-
 main/streams/php_stream_glob_wrapper.h             |    4 +-
 main/streams/php_stream_mmap.h                     |    4 +-
 main/streams/php_stream_plain_wrapper.h            |    4 +-
 main/streams/php_stream_transport.h                |    4 +-
 main/streams/php_stream_userspace.h                |    4 +-
 main/streams/php_streams_int.h                     |    9 +-
 main/streams/plain_wrapper.c                       |   48 +-
 main/streams/streams.c                             |   29 +-
 main/streams/transports.c                          |    6 +-
 main/streams/userspace.c                           |    4 +-
 main/streams/xp_socket.c                           |   12 +-
 main/strlcat.c                                     |    4 +-
 main/strlcpy.c                                     |    4 +-
 main/win32_internal_function_disabled.h            |    4 +-
 main/win95nt.h                                     |    4 +-
 netware/start.c                                    |    2 +-
 run-tests.php                                      |   66 +-
 sapi/aolserver/aolserver.c                         |    8 +-
 sapi/apache/libpre.c                               |    4 +-
 sapi/apache/mod_php5.c                             |    6 +-
 sapi/apache/mod_php5.h                             |    4 +-
 sapi/apache/php_apache.c                           |    4 +-
 sapi/apache/php_apache_http.h                      |    4 +-
 sapi/apache/sapi_apache.c                          |    4 +-
 sapi/apache2filter/apache_config.c                 |    4 +-
 sapi/apache2filter/php_apache.h                    |    4 +-
 sapi/apache2filter/php_functions.c                 |    4 +-
 sapi/apache2filter/sapi_apache2.c                  |    6 +-
 sapi/apache2handler/apache_config.c                |    4 +-
 sapi/apache2handler/mod_php5.c                     |    4 +-
 sapi/apache2handler/php_apache.h                   |    4 +-
 sapi/apache2handler/php_functions.c                |    4 +-
 sapi/apache2handler/sapi_apache2.c                 |   45 +-
 sapi/apache_hooks/mod_php5.c                       |    4 +-
 sapi/apache_hooks/mod_php5.h                       |    4 +-
 sapi/apache_hooks/php_apache.c                     |    4 +-
 sapi/apache_hooks/sapi_apache.c                    |    4 +-
 sapi/caudium/caudium.c                             |    6 +-
 sapi/cgi/cgi_main.c                                |   33 +-
 sapi/cgi/fastcgi.c                                 |    7 +-
 sapi/cgi/fastcgi.h                                 |    4 +-
 sapi/cli/php.1.in                                  |   15 +-
 sapi/cli/php_cli.c                                 |   10 +-
 sapi/cli/php_cli_readline.c                        |    8 +-
 sapi/cli/php_cli_readline.h                        |    4 +-
 sapi/cli/tests/006.phpt                            |    4 +-
 sapi/continuity/capi.c                             |    4 +-
 sapi/embed/php_embed.c                             |    4 +-
 sapi/embed/php_embed.h                             |    4 +-
 sapi/isapi/php5isapi.c                             |    4 +-
 sapi/milter/php_milter.c                           |    6 +-
 sapi/nsapi/nsapi.c                                 |   78 +-
 sapi/phttpd/php_phttpd.h                           |    2 +-
 sapi/phttpd/phttpd.c                               |    2 +-
 sapi/pi3web/pi3web_sapi.c                          |    6 +-
 sapi/roxen/roxen.c                                 |    6 +-
 sapi/thttpd/php_thttpd.h                           |    2 +-
 sapi/thttpd/thttpd.c                               |    4 +-
 sapi/tux/php_tux.c                                 |    2 +-
 sapi/webjames/php_webjames.h                       |    2 +-
 sapi/webjames/webjames.c                           |    2 +-
 server-tests.php                                   |    2 +-
 tests/basic/bug46313-win.phpt                      |    4 +-
 tests/basic/bug46313.phpt                          |    1 +
 tests/basic/bug46759.phpt                          |    1 +
 .../interface_constant_inheritance_001.phpt        |    2 +-
 .../interface_constant_inheritance_002.phpt        |    2 +-
 .../interface_constant_inheritance_003.phpt        |    2 +-
 tests/output/ob_011.phpt                           |    3 +-
 tests/output/ob_start_basic_unerasable_005.phpt    |    2 +-
 tests/security/magic_quotes_gpc.phpt               |    1 +
 win32/build/Makefile                               |    2 +-
 win32/build/config.w32                             |   11 +-
 win32/build/config.w32.h.in                        |    4 +-
 win32/build/confutils.js                           |    2 +
 win32/build/deplister.c                            |    4 +-
 win32/globals.c                                    |    4 +-
 win32/grp.h                                        |    4 +-
 win32/php_stdbool.h                                |   11 +
 win32/php_stdint.h                                 |    7 +-
 win32/php_win32_globals.h                          |    4 +-
 win32/select.c                                     |    4 +-
 win32/select.h                                     |    4 +-
 win32/sockets.c                                    |    4 +-
 win32/sockets.h                                    |    4 +-
 win32/syslog.h                                     |    4 +-
 win32/winutil.c                                    |   19 +-
 win32/winutil.h                                    |    3 +-
 1702 files changed, 62277 insertions(+), 39171 deletions(-)
 create mode 100644 Zend/tests/bug44827.phpt
 create mode 100644 Zend/tests/bug48667_1.phpt
 create mode 100644 Zend/tests/bug48667_2.phpt
 create mode 100644 Zend/tests/bug49472.phpt
 create mode 100644 Zend/tests/bug49866.phpt
 create mode 100644 Zend/tests/bug50005.phpt
 create mode 100644 Zend/tests/bug50146.phpt
 create mode 100644 Zend/tests/bug50174.phpt
 create mode 100644 Zend/tests/bug50255.phpt
 create mode 100644 Zend/tests/bug50261.phpt
 create mode 100644 Zend/tests/bug50394.phpt
 create mode 100644 Zend/tests/call_user_func_004.phpt
 create mode 100644 Zend/tests/call_user_func_005.phpt
 create mode 100644 Zend/tests/call_with_refs.phpt
 create mode 100644 Zend/tests/closure_035.phpt
 create mode 100644 ext/curl/tests/curl_ftp_pasv.phpt
 create mode 100644 ext/date/tests/bug45866.phpt
 create mode 100644 ext/date/tests/bug49585.phpt
 create mode 100644 ext/date/tests/bug50392.phpt
 create mode 100644 ext/date/tests/bug50680.phpt
 create mode 100644 ext/date/tests/sunfuncts.phpt
 create mode 100644 ext/dom/tests/bug47848.phpt
 create mode 100644 ext/dom/tests/bug49463.phpt
 create mode 100644 ext/dom/tests/bug50661.phpt
 create mode 100644 ext/filter/tests/bug50158.phpt
 create mode 100644 ext/filter/tests/bug50632.phpt
 create mode 100644 ext/gd/tests/bug49600.phpt
 create mode 100644 ext/gd/tests/imagefilledpolygon_negative.phpt
 create mode 100644 ext/gd/tests/imagepolygon_negative.phpt
 create mode 100644 ext/gd/tests/libgd00100.phpt
 create mode 100644 ext/gmp/tests/bug50283.phpt
 create mode 100644 ext/imap/tests/bug44098.phpt
 create mode 100644 ext/imap/tests/imap_fetchstructure_basic.phpt
 create mode 100644 ext/imap/tests/imap_getsubscribed_basic.phpt
 create mode 100644 ext/imap/tests/imap_headerinfo_basic.phpt
 create mode 100644 ext/imap/tests/imap_headerinfo_error.phpt
 create mode 100644 ext/imap/tests/imap_list_basic.phpt
 create mode 100644 ext/imap/tests/imap_lsub_basic.phpt
 create mode 100644 ext/imap/tests/imap_mail_copy.phpt
 create mode 100644 ext/imap/tests/imap_mail_copy_basic.phpt
 create mode 100644 ext/imap/tests/imap_mail_move.phpt
 create mode 100644 ext/imap/tests/imap_mail_move_basic.phpt
 create mode 100644 ext/imap/tests/imap_renamemailbox_basic.phpt
 create mode 100644 ext/imap/tests/imap_rfc822_parse_headers_basic.phpt
 create mode 100644 ext/imap/tests/imap_savebody_basic.phpt
 create mode 100644 ext/imap/tests/imap_timeout_basic.phpt
 create mode 100644 ext/imap/tests/imap_undelete_basic.phpt
 create mode 100644 ext/imap/tests/imap_undelete_error.phpt
 create mode 100755 ext/intl/resourcebundle/TODO
 create mode 100644 ext/intl/resourcebundle/resourcebundle.c
 create mode 100644 ext/intl/resourcebundle/resourcebundle.h
 create mode 100644 ext/intl/resourcebundle/resourcebundle_class.c
 create mode 100644 ext/intl/resourcebundle/resourcebundle_class.h
 create mode 100644 ext/intl/resourcebundle/resourcebundle_iterator.c
 create mode 100644 ext/intl/resourcebundle/resourcebundle_iterator.h
 create mode 100755 ext/intl/tests/_files/es-bundle.txt
 create mode 100755 ext/intl/tests/_files/res_index.txt
 create mode 100755 ext/intl/tests/_files/resourcebundle.txt
 create mode 100755 ext/intl/tests/_files/resourcebundle/es.res
 create mode 100755 ext/intl/tests/_files/resourcebundle/res_index.res
 create mode 100755 ext/intl/tests/_files/resourcebundle/root.res
 create mode 100755 ext/intl/tests/badargs.phpt
 create mode 100755 ext/intl/tests/collator_get_sort_key.phpt
 create mode 100755 ext/intl/tests/resourcebundle.build
 create mode 100644 ext/intl/tests/resourcebundle.inc
 create mode 100644 ext/intl/tests/resourcebundle_arrayaccess.phpt
 create mode 100644 ext/intl/tests/resourcebundle_create.phpt
 create mode 100644 ext/intl/tests/resourcebundle_individual.phpt
 create mode 100644 ext/intl/tests/resourcebundle_iterator.phpt
 create mode 100755 ext/intl/tests/resourcebundle_locales.phpt
 create mode 100644 ext/mbstring/tests/bug48697.phpt
 create mode 100644 ext/mbstring/tests/bug49354.phpt
 create mode 100644 ext/mbstring/tests/bug49528.phpt
 create mode 100644 ext/mbstring/tests/bug49536.phpt
 create mode 100644 ext/mysqli/tests/bug50772.phpt
 create mode 100644 ext/mysqli/tests/mysqli_class_mysqli_properties_no_conn.phpt
 delete mode 100644 ext/mysqli/tests/mysqli_get_cache_stats.phpt
 delete mode 100644 ext/mysqli/tests/mysqli_get_cache_stats_free_buffered.phpt
 create mode 100644 ext/mysqli/tests/mysqli_insert_packet_overflow.phpt
 create mode 100644 ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt
 create mode 100644 ext/mysqli/tests/mysqli_pconn_twice.phpt
 create mode 100644 ext/mysqlnd/mysqlnd_net.c
 create mode 100644 ext/mysqlnd/mysqlnd_net.h
 delete mode 100644 ext/mysqlnd/mysqlnd_palloc.c
 delete mode 100644 ext/mysqlnd/mysqlnd_palloc.h
 delete mode 100644 ext/mysqlnd/mysqlnd_qcache.c
 create mode 100644 ext/oci8/tests/bind_error.phpt
 create mode 100644 ext/oci8/tests/bug36403.phpt
 create mode 100644 ext/oci8/tests/bug47281.phpt
 create mode 100644 ext/oci8/tests/conn_attr.inc
 create mode 100644 ext/oci8/tests/conn_attr_1.phpt
 create mode 100644 ext/oci8/tests/conn_attr_2.phpt
 create mode 100644 ext/oci8/tests/conn_attr_3.phpt
 create mode 100644 ext/oci8/tests/conn_attr_4.phpt
 create mode 100644 ext/oci8/tests/conn_attr_5.phpt
 create mode 100644 ext/oci8/tests/driver_name.phpt
 create mode 100644 ext/oci8/tests/edition_1.phpt
 create mode 100644 ext/oci8/tests/edition_2.phpt
 create mode 100644 ext/oci8/tests/fetch_all4.phpt
 create mode 100644 ext/oci8/tests/fetch_all5.phpt
 create mode 100644 ext/oci8/tests/fetch_object_2.phpt
 create mode 100644 ext/oci8/tests/lob_043.phpt
 create mode 100644 ext/oci8/tests/refcur_prefetch_1.phpt
 create mode 100644 ext/oci8/tests/refcur_prefetch_2.phpt
 create mode 100644 ext/oci8/tests/refcur_prefetch_3.phpt
 create mode 100644 ext/oci8/tests/xmltype_02.phpt
 create mode 100644 ext/openssl/tests/sni_001.phpt
 create mode 100644 ext/pdo/tests/bug_50458.phpt
 create mode 100644 ext/pdo_mysql/tests/bug_50323.phpt
 create mode 100644 ext/pdo_pgsql/tests/bug48764.phpt
 create mode 100644 ext/pdo_pgsql/tests/bug_49985.phpt
 create mode 100644 ext/pdo_sqlite/tests/bug50728.phpt
 create mode 100644 ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
 create mode 100644 ext/pgsql/tests/10pg_convert_85.phpt
 create mode 100644 ext/pgsql/tests/12pg_insert_85.phpt
 create mode 100644 ext/pgsql/tests/13pg_select_85.phpt
 create mode 100644 ext/pgsql/tests/14pg_update_85.phpt
 create mode 100644 ext/pgsql/tests/bug37100_85.phpt
 create mode 100644 ext/reflection/tests/ReflectionMethod_setAccessible.phpt
 create mode 100644 ext/reflection/tests/bug49719.phpt
 delete mode 100644 ext/soap/readme.html
 create mode 100644 ext/spl/tests/bug49263.phpt
 create mode 100755 ext/spl/tests/bug49972.phpt
 create mode 100644 ext/spl/tests/iterator_069.phpt
 create mode 100644 ext/spl/tests/iterator_070.phpt
 create mode 100644 ext/spl/tests/iterator_071.phpt
 create mode 100644 ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
 create mode 100644 ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
 create mode 100644 ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
 create mode 100644 ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
 create mode 100644 ext/standard/crypt_sha256.c
 create mode 100644 ext/standard/crypt_sha512.c
 create mode 100644 ext/standard/tests/array/bug50006.phpt
 create mode 100644 ext/standard/tests/array/bug50006_1.phpt
 create mode 100644 ext/standard/tests/array/bug50006_2.phpt
 create mode 100644 ext/standard/tests/bug49244.phpt
 create mode 100644 ext/standard/tests/file/realpath_cache.phpt
 create mode 100644 ext/standard/tests/file/realpath_cache_win32.phpt
 create mode 100644 ext/standard/tests/file/rename_variation12-win32.phpt
 create mode 100644 ext/standard/tests/file/rename_variation8-win32.phpt
 create mode 100644 ext/standard/tests/file/windows_links/bug48746.phpt
 create mode 100644 ext/standard/tests/file/windows_links/bug48746_1.phpt
 create mode 100644 ext/standard/tests/file/windows_links/bug48746_2.phpt
 create mode 100644 ext/standard/tests/file/windows_links/bug48746_3.phpt
 delete mode 100644 ext/standard/tests/general_functions/.getservbyport_basic.phpt.swp
 create mode 100644 ext/standard/tests/general_functions/bug49692.ini
 create mode 100644 ext/standard/tests/general_functions/bug49692.phpt
 create mode 100644 ext/standard/tests/general_functions/bug49847.phpt
 create mode 100644 ext/standard/tests/general_functions/bug50690.phpt
 create mode 100644 ext/standard/tests/general_functions/bug50732.phpt
 delete mode 100644 ext/standard/tests/general_functions/sunfuncts.phpt
 delete mode 100644 ext/standard/tests/network/define_syslog_variables_variation-win32.phpt
 create mode 100644 ext/standard/tests/streams/bug49936.phpt
 create mode 100644 ext/standard/tests/streams/bug49936_win32.phpt
 create mode 100644 ext/standard/tests/streams/stream_resolve_include_path.phpt
 create mode 100644 ext/standard/tests/strings/bug49785.phpt
 create mode 100644 ext/standard/tests/strings/bug50847.phpt
 create mode 100644 ext/standard/tests/strings/bug51059.phpt
 create mode 100644 ext/standard/tests/strings/crypt_blowfish_invalid_rounds.phpt
 create mode 100644 ext/standard/tests/strings/crypt_sha256.phpt
 create mode 100644 ext/standard/tests/strings/crypt_sha512.phpt
 create mode 100644 ext/standard/tests/strings/html_entity_decode_html4.phpt
 create mode 100644 ext/standard/tests/strings/htmlentities_html4.phpt
 create mode 100644 ext/tidy/tests/035.phpt
 create mode 100644 ext/tidy/tests/bug_50558.phpt
 create mode 100644 ext/xml/tests/bug50576.phpt
 create mode 100644 ext/xmlrpc/tests/bug50282.phpt
 create mode 100644 ext/xmlrpc/tests/bug50285.phpt
 create mode 100644 ext/xmlrpc/tests/bug50761.phpt
 create mode 100644 ext/zlib/tests/gzencode_variation1-win32.phpt
 create mode 100644 win32/php_stdbool.h

diff --git a/Makefile.global b/Makefile.global
index 36d9e42..4f7d6d9 100644
--- a/Makefile.global
+++ b/Makefile.global
@@ -79,29 +79,25 @@ PHP_TEST_SHARED_EXTENSIONS =  ` \
 			. $$i; $(top_srcdir)/build/shtool echo -n -- " -d $(ZEND_EXT_TYPE)=$(top_builddir)/modules/$$dlname"; \
 		done; \
 	fi`
+PHP_DEPRECATED_DIRECTIVES_REGEX = '^(define_syslog_variables|register_(globals|long_arrays)?|safe_mode|magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*='
 
 test: all
 	- at if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
-		TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
-		TEST_PHP_SRCDIR=$(top_srcdir) \
-		CC="$(CC)" \
-			$(PHP_EXECUTABLE) $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -d extension_dir=modules/ $(PHP_TEST_SHARED_EXTENSIONS) tests/; \
-	elif test ! -z "$(SAPI_CLI_PATH)" && test -x "$(SAPI_CLI_PATH)"; then \
-		INI_FILE=`$(top_builddir)/$(SAPI_CLI_PATH) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
+		INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
 		if test "$$INI_FILE"; then \
-			$(EGREP) -v '^(magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*=' "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \
+			$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \
 		else \
 			echo > $(top_builddir)/tmp-php.ini; \
 		fi; \
-		INI_SCANNED_PATH=`$(top_builddir)/$(SAPI_CLI_PATH) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \
+		INI_SCANNED_PATH=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \
 		if test "$$INI_SCANNED_PATH"; then \
 			INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \
-			$(EGREP) -h -v '^(magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*=' "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
+			$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
 		fi; \
-		TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PATH) \
+		TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
 		TEST_PHP_SRCDIR=$(top_srcdir) \
 		CC="$(CC)" \
-			$(top_builddir)/$(SAPI_CLI_PATH) -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); \
+			$(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); \
 	else \
 		echo "ERROR: Cannot run tests without CLI sapi."; \
 	fi
diff --git a/NEWS b/NEWS
index 18ec482..bea460a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,251 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+04 Mar 2010, PHP 5.3.2
+
+- Upgraded bundled sqlite to version 3.6.22. (Ilia)
+- Upgraded bundled libmagic to version 5.03. (Mikko)
+- Upgraded bundled PCRE to version 8.00. (Scott)
+- Updated timezone database to version 2010.3. (Derick)
+
+- Improved LCG entropy. (Rasmus, Samy Kamkar)
+- Improved crypt support for edge cases (UFC compatibility). (Solar Designer,
+  Joey, Pierre)
+
+- Reverted fix for bug #49521 (PDO fetchObject sets values before calling
+  constructor). (Pierrick, Johannes)
+
+- Changed gmp_strval() to use full range from 2 to 62, and -2 to -36. FR #50283
+  (David Soria Parra)
+- Changed "post_max_size" php.ini directive to allow unlimited post size by
+  setting it to 0. (Rasmus)
+- Changed tidyNode class to disallow manual node creation. (Pierrick)
+
+- Removed automatic file descriptor unlocking happening on shutdown and/or 
+  stream close (on all OSes). (Tony, Ilia)
+
+- Added libpng 1.4.0 support. (Pierre)
+- Added support for DISABLE_AUTHENTICATOR for imap_open. (Pierre)
+- Added missing host validation for HTTP urls inside FILTER_VALIDATE_URL.
+  (Ilia)
+- Added stream_resolve_include_path(). (Mikko)
+- Added INTERNALDATE support to imap_append. (nick at mailtrust dot com)
+- Added support for SHA-256 and SHA-512 to php's crypt. (Pierre)
+- Added realpath_cache_size() and realpath_cache_get() functions. (Stas)
+- Added FILTER_FLAG_STRIP_BACKTICK option to the filter extension. (Ilia)
+- Added protection for $_SESSION from interrupt corruption and improved
+  "session.save_path" check. (Stas)
+- Added LIBXML_PARSEHUGE constant to override the maximum text size of a
+  single text node when using libxml2.7.3+. (Kalle)
+- Added ReflectionMethod::setAccessible() for invoking non-public methods
+  through the Reflection API. (Sebastian)
+- Added Collator::getSortKey for intl extension. (Stas)
+- Added support for CURLOPT_POSTREDIR. FR #49571. (Sriram Natarajan)
+- Added support for CURLOPT_CERTINFO. FR #49253.
+  (Linus Nielsen Feltzing <linus at haxx.se>)
+- Added client-side server name indication support in openssl. (Arnaud)
+
+- Improved fix for bug #50006 (Segfault caused by uksort()). (Stas)
+
+- Fixed mysqlnd hang when queries exactly 16777214 bytes long are sent. (Andrey)
+- Fixed incorrect decoding of 5-byte BIT sequences in mysqlnd. (Andrey)
+- Fixed error_log() to be binary safe when using message_type 3. (Jani)
+- Fixed unnecessary invocation of setitimer when timeouts have been disabled.
+  (Arvind Srinivasan)
+- Fixed memory leak in extension loading when an error occurs on Windows.
+  (Pierre)
+- Fixed safe_mode validation inside tempnam() when the directory path does
+  not end with a /). (Martin Jansen)
+- Fixed a possible open_basedir/safe_mode bypass in session extension
+  identified by Grzegorz Stachowiak. (Ilia)
+- Fixed possible crash when a error/warning is raised during php startup.
+  (Pierre)
+- Fixed possible bad behavior of rename on windows when used with symbolic
+  links or invalid paths. (Pierre)
+- Fixed error output to stderr on Windows. (Pierre)
+- Fixed memory leaks in is_writable/readable/etc on Windows. (Pierre)
+- Fixed memory leaks in the ACL function on Windows. (Pierre)
+- Fixed memory leak in the realpath cache on Windows. (Pierre)
+- Fixed memory leak in zip_close. (Pierre)
+- Fixed crypt's blowfish sanity check of the "setting" string, to reject
+  iteration counts encoded as 36 through 39. (Solar Designer, Joey, Pierre)
+
+- Fixed bug #51059 (crypt crashes when invalid salt are given). (Pierre)
+- Fixed bug #50952 (allow underscore _ in constants parsed in php.ini files).
+  (Jani)
+- Fixed bug #50940 (Custom content-length set incorrectly in Apache SAPIs).
+  (Brian France, Rasmus)
+- Fixed bug #50930 (Wrong date by php_date.c patch with ancient gcc/glibc
+  versions). (Derick)
+- Fixed bug #50907 (X-PHP-Originating-Script adding two new lines in *NIX).
+  (Ilia)
+- Fixed bug #50859 (build fails with openssl 1.0 due to md2 deprecation).   
+  (Ilia, hanno at hboeck dot de)
+- Fixed bug #50847 (strip_tags() removes all tags greater then 1023 bytes
+  long). (Ilia)
+- Fixed bug #50829 (php.ini directive pdo_mysql.default_socket is ignored).
+  (Ilia)
+- Fixed bug #50832 (HTTP fopen wrapper does not support passwordless HTTP
+  authentication). (Jani)
+- Fixed bug #50787 (stream_set_write_buffer() has no effect on socket streams).
+  (vnegrier at optilian dot com, Ilia)
+- Fixed bug #50761 (system.multiCall crashes in xmlrpc extension).
+  (hiroaki dot kawai at gmail dot com, Ilia)
+- Fixed bug #50756 (CURLOPT_FTP_SKIP_PASV_IP does not exist). (Sriram)
+- Fixed bug #50732 (exec() adds single byte twice to $output array). (Ilia)
+- Fixed bug #50728 (All PDOExceptions hardcode 'code' property to 0).
+  (Joey, Ilia)
+- Fixed bug #50723 (Bug in garbage collector causes crash). (Dmitry)
+- Fixed bug #50690 (putenv does not set ENV when the value is only one char).
+  (Pierre)
+- Fixed bug #50680 (strtotime() does not support eighth ordinal number). (Ilia)
+- Fixed bug #50661 (DOMDocument::loadXML does not allow UTF-16). (Rob)
+- Fixed bug #50657 (copy() with an empty (zero-byte) HTTP source succeeds but
+  returns false). (Ilia)
+- Fixed bug #50636 (MySQLi_Result sets values before calling constructor).
+  (Pierrick)
+- Fixed bug #50632 (filter_input() does not return default value if the
+  variable does not exist). (Ilia)
+- Fixed bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect). (Pierrick)
+- Fixed bug #50558 (Broken object model when extending tidy). (Pierrick)
+- Fixed bug #50540 (Crash while running ldap_next_reference test cases).
+  (Sriram)
+- Fixed bug #50519 (segfault in garbage collection when using set_error_handler
+  and DomDocument). (Dmitry)
+- Fixed bug #50508 (compile failure: Conflicting HEADER type declarations).
+  (Jani)
+- Fixed bug #50496 (Use of <stdbool.h> is valid only in a c99 compilation 
+  environment. (Sriram)
+- Fixed bug #50464 (declare encoding doesn't work within an included file).
+  (Felipe)
+- Fixed bug #50458 (PDO::FETCH_FUNC fails with Closures). (Felipe, Pierrick)
+- Fixed bug #50445 (PDO-ODBC stored procedure call from Solaris 64-bit causes
+  seg fault). (davbrown4 at yahoo dot com, Felipe)
+- Fixed bug #50416 (PROCEDURE db.myproc can't return a result set in the given
+  context). (Andrey)
+- Fixed bug #50394 (Reference argument converted to value in __call). (Stas)
+- Fixed bug #50351 (performance regression handling objects, ten times slower
+  in 5.3 than in 5.2). (Dmitry)
+- Fixed bug #50392 (date_create_from_format() enforces 6 digits for 'u'
+  format character). (Ilia)
+- Fixed bug #50345 (nanosleep not detected properly on some solaris versions).
+  (Jani)
+- Fixed bug #50340 (php.ini parser does not allow spaces in ini keys). (Jani)
+- Fixed bug #50334 (crypt ignores sha512 prefix). (Pierre)
+- Fixed bug #50323 (Allow use of ; in values via ;; in PDO DSN).
+  (Ilia, Pierrick)
+- Fixed bug #50285 (xmlrpc does not preserve keys in encoded indexed arrays).
+  (Felipe)
+- Fixed bug #50282 (xmlrpc_encode_request() changes object into array in 
+  calling function). (Felipe)
+- Fixed bug #50267 (get_browser(null) does not use HTTP_USER_AGENT). (Jani)
+- Fixed bug #50266 (conflicting types for llabs). (Jani)
+- Fixed bug #50261 (Crash When Calling Parent Constructor with
+  call_user_func()). (Dmitry)
+- Fixed bug #50255 (isset() and empty() silently casts array to object).
+  (Felipe)
+- Fixed bug #50240 (pdo_mysql.default_socket in php.ini shouldn't used
+  if it is empty). (foutrelis at gmail dot com, Ilia)
+- Fixed bug #50231 (Socket path passed using --with-mysql-sock is ignored when
+  mysqlnd is enabled). (Jani)
+- Fixed bug #50219 (soap call Segmentation fault on a redirected url).
+  (Pierrick)
+- Fixed bug #50212 (crash by ldap_get_option() with LDAP_OPT_NETWORK_TIMEOUT).
+  (Ilia, shigeru_kitazaki at cybozu dot co dot jp)
+- Fixed bug #50209 (Compiling with libedit cannot find readline.h).
+  (tcallawa at redhat dot com)
+- Fixed bug #50207 (segmentation fault when concatenating very large strings on
+  64bit linux). (Ilia)
+- Fixed bug #50196 (stream_copy_to_stream() produces warning when source is 
+  not file). (Stas)
+- Fixed bug #50195 (pg_copy_to() fails when table name contains schema. (Ilia)
+- Fixed bug #50185 (ldap_get_entries() return false instead of an empty array
+  when there is no error). (Jani)
+- Fixed bug #50174 (Incorrectly matched docComment). (Felipe)
+- Fixed bug #50168 (FastCGI fails with wrong error on HEAD request to
+  non-existant file). (Dmitry)
+- Fixed bug #50162 (Memory leak when fetching timestamp column from Oracle
+  database). (Felipe)
+- Fixed bug #50159 (wrong working directory in symlinked files). (Dmitry)
+- Fixed bug #50158 (FILTER_VALIDATE_EMAIL fails with valid addresses
+  containing = or ?). (Pierrick)
+- Fixed bug #50152 (ReflectionClass::hasProperty behaves like isset() not
+  property_exists). (Felipe)
+- Fixed bug #50146 (property_exists: Closure object cannot have properties).
+  (Felipe)
+- Fixed bug #50145 (crash while running bug35634.phpt). (Felipe)
+- Fixed bug #50140 (With default compilation option, php symbols are unresolved
+  for nsapi). (Uwe Schindler)
+- Fixed bug #50087 (NSAPI performance improvements). (Uwe Schindler)
+- Fixed bug #50073 (parse_url() incorrect when ? in fragment). (Ilia)
+- Fixed bug #50023 (pdo_mysql doesn't use PHP_MYSQL_UNIX_SOCK_ADDR). (Ilia)
+- Fixed bug #50005 (Throwing through Reflection modified Exception object
+  makes segmentation fault). (Felipe)
+- Fixed bug #49990 (SNMP3 warning message about security level printed twice).
+  (Jani)
+- Fixed bug #49985 (pdo_pgsql prepare() re-use previous aborted
+  transaction). (ben dot pineau at gmail dot com, Ilia, Matteo)  
+- Fixed bug #49938 (Phar::isBuffering() returns inverted value). (Greg)
+- Fixed bug #49936 (crash with ftp stream in php_stream_context_get_option()).
+  (Pierrick)
+- Fixed bug #49921 (Curl post upload functions changed). (Ilia)
+- Fixed bug #49866 (Making reference on string offsets crashes PHP). (Dmitry)
+- Fixed bug #49855 (import_request_variables() always returns NULL). (Ilia,
+  sjoerd at php dot net)
+- Fixed bug #49851, #50451 (http wrapper breaks on 1024 char long headers). 
+  (Ilia)
+- Fixed bug #49800 (SimpleXML allow (un)serialize() calls without warning).
+  (Ilia, wmeler at wp-sa dot pl)
+- Fixed bug #49719 (ReflectionClass::hasProperty returns true for a private
+  property in base class). (Felipe)
+- Fixed bug #49677 (ini parser crashes with apache2 and using ${something}
+  ini variables). (Jani)
+- Fixed bug #49660 (libxml 2.7.3+ limits text nodes to 10MB). (Felipe)
+- Fixed bug #49647 (DOMUserData does not exist). (Rob)
+- Fixed bug #49600 (imageTTFText text shifted right). (Takeshi Abe)
+- Fixed bug #49585 (date_format buffer not long enough for >4 digit years).
+  (Derick, Adam)
+- Fixed bug #49560 (oci8: using LOBs causes slow PHP shutdown). (Oracle Corp.)
+- Fixed bug #49521 (PDO fetchObject sets values before calling constructor).
+  (Pierrick)
+- Fixed bug #49472 (Constants defined in Interfaces can be overridden).
+  (Felipe)
+- Fixed bug #49463 (setAttributeNS fails setting default namespace). (Rob)
+- Fixed bug #49244 (Floating point NaN cause garbage characters). (Sjoerd)
+- Fixed bug #49224 (Compile error due to old DNS functions on AIX systems).
+  (Scott)
+- Fixed bug #49174 (crash when extending PDOStatement and trying to set
+  queryString property). (Felipe)
+- Fixed bug #48811 (Directives in PATH section do not get applied to
+  subdirectories). (Patch by: ct at swin dot edu dot au)
+- Fixed bug #48590 (SoapClient does not honor max_redirects). (Sriram)
+- Fixed bug #48190 (Content-type parameter "boundary" is not case-insensitive
+  in HTTP uploads). (Ilia)
+- Fixed bug #47848 (importNode doesn't preserve attribute namespaces). (Rob)
+- Fixed bug #47409 (extract() problem with array containing word "this").
+  (Ilia, chrisstocktonaz at gmail dot com)
+- Fixed bug #47281 ($php_errormsg is limited in size of characters)
+  (Oracle Corp.)
+- Fixed bug #46478 (htmlentities() uses obsolete mapping table for character
+  entity references). (Moriyoshi)
+- Fixed bug #45599 (strip_tags() truncates rest of string with invalid
+  attribute). (Ilia, hradtke)
+- Fixed bug #45120 (PDOStatement->execute() returns true then false for same
+  statement). (Pierrick)
+- Fixed bug #44827 (define() allows :: in constant names). (Ilia)
+- Fixed bug #44098 (imap_utf8() returns only capital letters).
+  (steffen at dislabs dot de, Pierre)
+- Fixed bug #34852 (Failure in odbc_exec() using oracle-supplied odbc
+  driver). (tim dot tassonis at trivadis dot com)
+
 19 Nov 2009, PHP 5.3.1
+- Upgraded bundled sqlite to version 3.6.19. (Scott)
+- Updated timezone database to version 2009.17 (2009q). (Derick)
+
+- Changed ini file directives [PATH=](on Win32) and [HOST=](on all) to be case 
+  insensitive. (garretts)
+
+- Restored shebang line check to CGI sapi (not checked by scanner anymore).
+  (Jani)
 
 - Added "max_file_uploads" INI directive, which can be set to limit the
   number of file uploads per-request to 20 by default, to prevent possible
@@ -11,8 +256,16 @@ PHP                                                                        NEWS
 - Added support for ACL on Windows for thread safe SAPI (Apache2 for example)
   and fix its support on NTS. (Pierre)
 
-- Upgraded bundled sqlite to version 3.6.19. (Scott)
-- Updated timezone database to version 2009.17 (2009q). (Derick)
+- Improved symbolic, mounted volume and junctions support for realpath on 
+  Windows. (Pierre)
+- Improved readlink on Windows, suppress \??\ and use the drive syntax only.
+  (Pierre)
+- Improved dns_get_record() AAAA support on windows. Always available when
+  IPv6 is support is installed, format is now the same than on unix. (Pierre)
+- Improved the DNS functions on OSX to use newer APIs, also use Bind 9 API
+  where available on other platforms. (Scott)
+- Improved shared extension loading on OSX to use the standard Unix dlopen()
+  API. (Scott)
 
 - Fixed crash in com_print_typeinfo when an invalid typelib is given. (Pierre)
 - Fixed a safe_mode bypass in tempnam() identified by Grzegorz Stachowiak.  
@@ -41,26 +294,14 @@ PHP                                                                        NEWS
 - Fixed memory leak in stream_is_local(). (Felipe, Tony)
 - Fixed BC break in mime_content_type(), removes the content encoding. (Scott) 
 
-- Changed ini file directives [PATH=](on Win32) and [HOST=](on all) to be case 
-  insensitive (garretts)
-- Restored shebang line check to CGI sapi (not checked by scanner anymore).
-  (Jani)
-
-- Improve symbolic, mounted volume and junctions support for realpath on 
-  Windows. (Pierre)
-- Improved readlink on Windows, suppress \??\ and use the drive syntax only.
-  (Pierre)
-- Improved dns_get_record() AAAA support on windows. Always available when
-  IPv6 is support is installed, format is now the same than on unix. (Pierre)
-- Improved the DNS functions on OSX to use newer APIs, also use Bind 9 API
-  where available on other platforms. (Scott)
-- Improved shared extension loading on OSX to use the standard Unix dlopen()
-  API. (Scott)
+- Fixed PECL bug #16842 (oci_error return false when NO_DATA_FOUND is raised).
+  (Chris Jones)
 
 - Fixed bug #50063 (safe_mode_include_dir fails). (Johannes, christian at
   elmerot dot se)
 - Fixed bug #50052 (Different Hashes on Windows and Linux on wrong Salt size).
   (Pierre)
+- Fixed bug #49986 (Missing ICU DLLs on windows package). (Pierre)
 - Fixed bug #49910 (no support for ././@LongLink for long filenames in phar
   tar support). (Greg)
 - Fixed bug #49908 (throwing exception in __autoload crashes when interface
@@ -87,9 +328,9 @@ PHP                                                                        NEWS
 - Fixed bug #49447 (php engine need to correctly check for socket API 
   return status on windows). (Sriram Natarajan)
 - Fixed bug #49391 (ldap.c utilizing deprecated ldap_modify_s). (Ilia)
+- Fixed bug #49372 (segfault in php_curl_option_curl). (Pierre)
 - Fixed bug #49361 (wordwrap() wraps incorrectly on end of line boundaries).
   (Ilia, code-it at mail dot ru)
-- Fixed bug #49372 (segfault in php_curl_option_curl). (Pierre)
 - Fixed bug #49306 (inside pdo_mysql default socket settings are ignored).
   (Ilia)
 - Fixed bug #49289 (bcmath module doesn't compile with phpize configure).
@@ -106,7 +347,6 @@ PHP                                                                        NEWS
   authentication details). (Dmitry)
 - Fixed bug #49142 (crash when exception thrown from __tostring()).
   (David Soria Parra)
-- Fixed bug #49986 (Missing ICU DLLs on windows package). (Pierre)
 - Fixed bug #49132 (posix_times returns false without error).
   (phpbugs at gunnu dot us)
 - Fixed bug #49125 (Error in dba_exists C code). (jdornan at stanford dot edu)
@@ -135,14 +375,14 @@ PHP                                                                        NEWS
 - Fixed bug #49027 (mysqli_options() doesn't work when using mysqlnd). (Andrey)
 - Fixed bug #49026 (proc_open() can bypass safe_mode_protected_env_vars
   restrictions). (Ilia)
-- Fixed bug #49012 (phar tar signature algorithm reports as Unknown (0) in
-  getSignature() call). (Greg)
 - Fixed bug #49020 (phar misinterprets ustar long filename standard).
   (Greg)
 - Fixed bug #49018 (phar tar stores long filenames wit prefix/name reversed).
   (Greg)
 - Fixed bug #49014 (dechunked filter broken when serving more than 8192 bytes
   in a chunk). (andreas dot streichardt at globalpark dot com, Ilia)
+- Fixed bug #49012 (phar tar signature algorithm reports as Unknown (0) in
+  getSignature() call). (Greg)
 - Fixed bug #49000 (PHP CLI in Interactive mode (php -a) crashes 
   when including files from function). (Stas)
 - Fixed bug #48994 (zlib.output_compression does not output HTTP headers when
@@ -160,12 +400,12 @@ PHP                                                                        NEWS
 - Fixed bug #48899 (is_callable returns true even if method does not exist in
   parent class). (Felipe)
 - Fixed bug #48893 (Problems compiling with Curl). (Felipe)
+- Fixed bug #48880 (Random Appearing open_basedir problem). (Rasmus, Gwynne)
 - Fixed bug #48872 (string.c: errors: duplicate case values). (Kalle)
 - Fixed bug #48854 (array_merge_recursive modifies arrays after first one).
   (Felipe)
 - Fixed bug #48805 (IPv6 socket transport is not working). (Ilia)
 - Fixed bug #48802 (printf() returns incorrect outputted length). (Jani)
-- Fixed bug #48880 (Random Appearing open_basedir problem). (Rasmus, Gwynne)
 - Fixed bug #48791 (open office files always reported as corrupted). (Greg)
 - Fixed bug #48788 (RecursiveDirectoryIterator doesn't descend into symlinked
   directories). (Ilia)
@@ -245,8 +485,7 @@ PHP                                                                        NEWS
 - Fixed bug #28038 (Sent incorrect RCPT TO commands to SMTP server) (Garrett)
 - Fixed bug #27051 (Impersonation with FastCGI does not exec process as 
   impersonated user). (Pierre)
-- Fixed PECL bug #16842 (oci_error return false when NO_DATA_FOUND is raised).
-  (Chris Jones)
+
 
 30 Jun 2009, PHP 5.3.0
 - Upgraded bundled PCRE to version 7.9. (Nuno)
diff --git a/README.RELEASE_PROCESS b/README.RELEASE_PROCESS
index d99c4ff..684c420 100644
--- a/README.RELEASE_PROCESS
+++ b/README.RELEASE_PROCESS
@@ -100,9 +100,9 @@ Derick) run the following commands for you:
 
 ``sudo -u ezmlm ezmlm-sub ~ezmlm/primary-qa-tester/mod moderator-email-address``
 
-3. Update the MD5 sums in ``qaweb/include/rc-md5sums.txt`` (no empty lines).
+3. Update the MD5 sums in ``web/qa/trunk/include/rc-md5sums.txt`` (no empty lines).
 
-4. Update in ``qaweb/include/release-qa.php`` constants with the new RC and
+4. Update in ``web/qa/trunk/include/release-qa.php`` constants with the new RC and
 commit this.
 
  a. ``$BUILD_TEST_RELEASES`` = array("4.4.7RC1", "5.2.2RC1")
@@ -111,7 +111,7 @@ commit this.
 
  c. ``$RELEASE_PROCESS`` = array(4 => true, 5 => true)
 
-1. Update in ``php-bugs-web/include/functions.inc`` the ``show_version_option``
+1. Update in ``php-bugs/trunk/include/functions.inc`` the ``show_version_option``
 function to include the new RC and commit.
 
 2. Update ``phpweb/include/version.inc`` (x=major version number)
diff --git a/README.SUBMITTING_PATCH b/README.SUBMITTING_PATCH
index 8229bf0..aa80a2c 100644
--- a/README.SUBMITTING_PATCH
+++ b/README.SUBMITTING_PATCH
@@ -1,106 +1,136 @@
-Submitting Patch for PHP
-========================
+Submitting Patches to PHP
+=========================
 
-This document describes how to submit a patch for PHP. Since you are
-reading this document, you are willing to submit a patch for PHP.
-Please keep reading! Submitting a patch for PHP is easy. The hard
-part is making it acceptable for inclusion into our repository. :-)
+This document describes how to submit a patch for PHP. Creating a
+patch for PHP is easy!
 
-How to create patch?  
--------------------- 
-We use Subversion (SVN) for revision control.  You need to get the
-source from SVN in order to create a patch.  Read 
-http://www.php.net/svn.php for help on using SVN.  You can check out
-older branches, but make sure you get trunk as well and make your
-patch work there.
+You don't need any login accounts or special access to download,
+build, debug and begin submitting PHP code, tests or documentation for
+inclusion in PHP. Once you've followed this README and had several
+patches accepted, PHP commit privileges are often quickly granted.
 
-Read CODING_STANDARDS file before you start working.
+An excellent article to read first is:
+http://phpadvent.org/2008/less-whining-more-coding-by-elizabeth-smith
 
-Now you are ready to create a patch. Modify source to fix a bug in PHP or
-add a new feature to PHP. After you finished editing, please test your
-patch. Read README.TESTING for testing.
 
-After you finish testing your patch, take diff file using 
-"svn diff > your.patch" command.
+Prework
+-------
+If you are fixing broken functionality then create a bug or identify
+an existing bug at http://bugs.php.net/. This can be used to track
+the patch progress and prevent your changes getting lost in the PHP
+mail archives.
 
-Read README.TESTING for submitting a test script for your patch. This is
-not strictly required, but it is preferred to submit a test script along
-with your patch. Making new test script is very easy. It also helps us
-to understand what you have been fixed or added to PHP.
+If your code change is large then first discuss it with the extension
+maintainer and/or a development mail list. Extension maintainers can
+be found in the EXTENSIONS file in the PHP source. Use the
+internals at lists.php.net mail list to discuss changes to the base PHP
+code. Use pecl-dev at lists.php.net for changes to code that is only
+available from PECL (http://pecl.php.net/). Use pear-dev at lists.php.net
+for PEAR modules (http://pear.php.net/). Mail list subscription is
+explained on http://www.php.net/mailing-lists.php.
 
+If a PHP or PECL patch affects user-functionality or makes significant
+internal changes then create a simple RFC on http://wiki.php.net/rfc
+before starting discussion. This RFC can be used for initial
+discussion and later for documentation. Wiki accounts can be requested
+on http://wiki.php.net/start?do=register
 
-Tips for creating patch 
------------------------ 
-If you would like to fix multiple bugs. It is easier for us if you
-could create 1 patch for 1 bug, but this is not strictly required.
-Note though that you might get little response, if your patch is
-too hard to review.
+There are several IRC channels where PHP developers are often
+available to discuss questions.  They include #php.pecl on the EFNet
+network and #php-dev-win on FreeNode.
 
-If you would like change/add many lines, it is better to ask module
-maintainer and/or internals at lists.php.net, or pear-dev at lists.php.net if
-you are patching PEAR. Official module maintainers can be found in
-EXTENSIONS file in PHP source.
 
-If you are new to SVN (Subversion), visit
-http://svnbook.red-bean.com/ for details.
+How to create your patch
+------------------------
+PHP uses Subversion (SVN) for revision control. Read
+http://www.php.net/svn.php for help on using SVN to get and build PHP
+source code. We recommend using a Sparse Directory checkout described
+in http://wiki.php.net/vcs/svnfaq. If you are new to SVN, read
+http://svnbook.red-bean.com.
 
+Generally we ask that patches work on the current stable PHP
+development branch and on "trunk".
 
-Check list for submitting patch
--------------------------------
- - Did you run "make test" to check if your patch didn't break
-   other features?
- - Did you compile PHP with --enable-debug and check the PHP and
-   web server error logs when you test your patch?
- - Did you build PHP for multi-threaded web servers. (Optional)
- - Did you create test script for "make test"? (Recommended)
- - Did you update SVN source before you take final patch?
- - Did you read the patch again?
+Read CODING_STANDARDS before you start working.
 
+After modifying the source see README.TESTING and
+http://qa.php.net/write-test.php for how to test. Submitting test
+scripts helps us to understand what functionality has changed. It is
+important for the stability and maintainability of PHP that tests are
+comprehensive.
 
-Where to send your patch?
--------------------------
-If you are patching C source, send the patch to internals at lists.php.net. 
-If you are patching a module, you should also send the patch to the 
-maintainer. Official module maintainers are listed in EXTENSION file 
-in source.
+After testing is finished, create a patch file using the command:
 
-If you are patching PEAR, send the patch to pear-dev at lists.php.net.
+  svn diff > your_patch.txt
 
-Please add the prefix "[PATCH]" to your email subject and make sure
-to include the patch as a MIME attachment even if it is short. 
+For ease of review and later troubleshooting, submit individual
+patches for each bug or feature.
 
-NOTE: only MIME attachments of type 'text/*' are accepted. The
-      easiest way to accomplish this, is to make the extension
-      '.txt'.
 
-Test scripts should be included in the same email.
-Explain what has been fixed/added/changed by your patch.
+Checklist for submitting your patch
+-----------------------------------
+ - Update SVN source just before running your final 'diff' and
+   before testing.
+ - Run "make test" to check your patch doesn't break other features.
+ - Rebuild PHP with --enable-debug (which will show some kinds of
+   memory errors) and check the PHP and web server error logs after
+   running the PHP tests.
+ - Rebuild PHP with --enable-maintainer-zts to check your patch compiles
+   on multi-threaded web servers.
+ - Create test scripts for use with "make test".
+ - Add in-line comments and/or have external documentation ready.
+ - Review the patch once more just before submitting it.
 
-Finally, add the bug Id(s) which can be closed by your patch, if any.
 
+Where to send your patch
+------------------------
+If you are patching PHP C source then email the patch to
+internals at lists.php.net
 
-What happens after you submit your patch
----------------------------------------- 
-If your patch is easy to review and has obviously no side-effects,
-it might take up to a few hours until someone commits it.
+If you patching a PECL extension then send the patch to
+pecl-dev at lists.php.net
+
+If you are patching PEAR then send the patch to
+pear-dev at lists.php.net
+
+The mail can be CC'd to the extension maintainer (see EXTENSIONS).
+
+Please make the subject prefix "[PATCH]".
+
+Include the patch as an attachment. Note: only MIME attachments of
+type 'text/*' are accepted. The easiest way to accomplish this is to
+make the file extension '.txt'.
+
+Explain what has been fixed/added/changed by your patch. Test scripts
+should be included in the email.
 
-Because this is a volunteer-driven effort, more complex patches will
-require more patience on your side. 
+Include the bug id(s) which can be closed by your patch.
 
-If you did not receive any feedback in a few days, please consider
-resubmitting the description of your patch, along-side with
+Finally, update any open bugs and add a link to the source of your
+patch.
+
+
+What happens after you submit your patch
+----------------------------------------
+If your patch is easy to review and obviously has no side-effects,
+it might be committed relatively quickly.
+
+Because PHP is a volunteer-driven effort more complex patches will
+require patience on your side. If you do not receive feedback in a few
+days, consider resubmitting the patch. Before doing this think about
 these questions:
 
-- Is my patch too hard to review? Because of which factors?
-- Should I split it up in multiple parts?
-- Are there any unwanted whitespace changes?
+ - Did I review the mail list archives to see if these kind of
+   changes had been discussed before?
+ - Did I explain my patch clearly?
+ - Is my patch too hard to review? Because of which factors?
+ - Are there any unwanted white space changes?
 
 
-What happens when your patch is applied?
----------------------------------------- 
+What happens when your patch is applied
+---------------------------------------
 Your name will be included together with your email address in the SVN
-commit log. If your patch affects end-users, a brief description
+commit log. If your patch affects end users, a brief description
 and your name might be added to the NEWS file.
 
-
-Thank you for submitting patch for PHP!
+Thank you for patching PHP!
diff --git a/README.WIN32-BUILD-SYSTEM b/README.WIN32-BUILD-SYSTEM
index ae864d0..d7d6e5c 100644
--- a/README.WIN32-BUILD-SYSTEM
+++ b/README.WIN32-BUILD-SYSTEM
@@ -1,174 +1,6 @@
 The Win32 Build System.
-$Id: README.WIN32-BUILD-SYSTEM 242949 2007-09-26 15:44:16Z cvs2svn $
-Wez Furlong <wez at thebrainroom.com>
 
-If you need help with the build system, send mail to
-internals at lists.php.net; please don't email me directly.
-
-===========================================================
-Contents:
-1. How to build PHP under windows
- a. Requirements
- b. Opening a command prompt
- c. Generating configure.js
- d. Configuring
- e. Building
- f. Cleaning up
- g. Running the test suite
- h. snapshot building
- 
-2. How to write config.w32 files
- x. to be written.
-
-===========================================================
-1. How to build PHP under windows
-a. Requirements
-
- You need:
-  - Windows Scripting Host (cscript.exe)
-  - Microsoft Build Tools from:
-     Microsoft Visual Studio (VC6) or later
- 
- You also need:
-  - bindlib_w32 [http://www.php.net/extra/bindlib_w32.zip]
-  - win32build  [http://www.php.net/extra/win32build.zip]
-
- b. Opening the Build Environment Command Prompt:
-  - Using Visual Studio (VC6)
-    1. Install it
-    2. If you have a VC++ Command Prompt icon on your start menu,
-       click on it to get a Command Prompt with the env vars
-       set up correctly.
-
-       If not, create a new shortcut and set the Target to:
-
-       %comspec% /k "C:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32.bat"
-
-       You might also want to set the prompt to start in
-       a convenient location (such as the root of your
-       PHP source checkout).
-
-  - Using Visual Studio .Net
-    1. Install it.
-    2. Under the Visual Studio .Net Tools sub menu of your start
-       menu, you should have a Visual Studio .Net Command Prompt
-       icon.  If not, create a new shortcut and set the Target to:
-
-       %comspec% /k "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat"
-
-       You might also want to set the prompt to start in
-       a convenient location (such as the root of your
-       PHP source checkout).
-
-  - Using the Platform SDK tools
-    1. Download the Platform SDK:
-       http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
-
-       - You need the Core SDK, which is approx 200MB to download
-         and requires approx 500MB of disk space.
-       - The other components of the SDK are not required by PHP
-       - You might be able to reduce the download size by downloading
-         the installer control component first and then selecting
-         only the Build Environment (around 30MB), but I haven't
-         tried this.
-
-         ** Note: it seems that MS don't include the 32 bit
-            build tools in the platform SDK any longer, so
-            you will probably have very limited luck if you
-            don't also have VC++ or VS.Net already installed.
-
-    2. Once installed, you will have an icon on your start menu
-       that will launch the build environment; the latest SDK's
-       install a number of different versions of this; you probably
-       want to choose the Windows 2000 Retail build environment.
-       Clicking on this will open a command prompt with its Path,
-       Include and Lib env vars set to point to the build tools
-       and win32 headers.
-
-c. Generating configure
-
- Change directory to where you have your PHP 5 sources.
- Run buildconf.bat.
-
-d. Configuring
- 
- cscript /nologo configure.js --help
- 
- Will give you a list of configuration options; these will
- have the form:
- 
- --enable-foo or --disable-foo or --with-foo or --without-foo.
- 
- --enable-foo will turn something on, and is equivalent to
- specifying --enable-foo=yes
- 
- --disable-foo will turn something off, and is equivalent to
- specifying --enable-foo=no
-
- --enable-foo=shared will attempt to build that feature as
- a shared, dynamically loadable module.
-
- Sometimes a configure option needs additional information
- about where to find headers and libraries; quite often
- you can specify --enable-foo=option where option could be
- the path to where to find those files.  If you want to
- specify a parameter and build it as shared, you can use
- this syntax instead:  --enable-foo=shared,option
-
- The same rules all apply to --with-foo and --without-foo;
- the only difference is the way the options are named;
- the convention is that --enable-foo means that you are
- switching on something that comes with PHP, whereas
- --with-foo means that you want to build in something
- external to PHP.
-
-e. Building
-
- Once you have successfully configured your build (make
- sure you read the output from the command to make sure
- it worked correctly), you can build the code; simply type
-
- "nmake" at the command prompt, and it will build everthing
- you asked for.
-
- Once the build has completed, you will find your binaries
- in the build dir determined by configure; this is typically
- Release_TS for release builds or Debug_TS for debug builds.
- If you build a non-thread-safe build, it will use Release
- or Debug to store the files.  Also in this build dir you
- will find sub directories for each module that went into
- your PHP build.  The files you'll want to keep are the
- .exe and .dll files directly in your build dir.
-
-f. Cleaning Up
- 
- You can automatically delete everything that was built
- by running "nmake clean".  This will delete everything
- that was put there when you ran nmake, including the
- .exe and .dll files.
-
-g. Running the test suite
-
- You can verify that your build is working well by running
- the regression test suite.  You do this by typing
- "nmake test".  You can specify the tests you want to run
- by defing the TESTS variable - if you wanted to run the
- sqlite test suite only, you would type
- "nmake /D TESTS=ext/sqlite/tests test"
-
-h. Snapshot Building
-
- If you want to set up an automated build that will tolerate
- breakages in some of the modules, you can use the
- --enable-snapshot-build configure option to generate a
- makefile optimized for that purpose.  A snapshot build will
- switch the argument parser so that the default option for
- configure switches that your don't specify will be set
- to "shared".  The effect of this is to turn on all options
- unless you explicitly disable them.  When you have configured
- your snapshot build, you can use "nmake build-snap" to build
- everything, ignoring build errors in individual extensions
- or SAPI.
+See http://wiki.php.net/internals/windows/stepbystepbuild 
 
 vim:tw=78:sw=1:ts=1:et
 
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index 625bd5d..368178e 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Thread Safe Resource Manager                                         |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1999-2009, Andi Gutmans, Sascha Schumann, Zeev Suraski |
+   | Copyright (c) 1999-2010, Andi Gutmans, Sascha Schumann, Zeev Suraski |
    | This source file is subject to the TSRM license, that is bundled     |
    | with this package in the file LICENSE                                |
    +----------------------------------------------------------------------+
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
index 5343779..cd6618f 100644
--- a/TSRM/TSRM.h
+++ b/TSRM/TSRM.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Thread Safe Resource Manager                                         |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1999-2009, Andi Gutmans, Sascha Schumann, Zeev Suraski |
+   | Copyright (c) 1999-2010, Andi Gutmans, Sascha Schumann, Zeev Suraski |
    | This source file is subject to the TSRM license, that is bundled     |
    | with this package in the file LICENSE                                |
    +----------------------------------------------------------------------+
diff --git a/TSRM/tsrm_nw.c b/TSRM/tsrm_nw.c
index 4a9ccab..ac566a4 100644
--- a/TSRM/tsrm_nw.c
+++ b/TSRM/tsrm_nw.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_nw.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: tsrm_nw.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/TSRM/tsrm_nw.h b/TSRM/tsrm_nw.h
index e2fe4f5..4895059 100644
--- a/TSRM/tsrm_nw.h
+++ b/TSRM/tsrm_nw.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index 37b9820..251fd2f 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_virtual_cwd.c 289780 2009-10-19 23:38:55Z pajoye $ */
+/* $Id: tsrm_virtual_cwd.c 294520 2010-02-04 09:57:30Z pajoye $ */
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -432,8 +432,8 @@ CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC) /* {{{ */
 static inline unsigned long realpath_cache_key(const char *path, int path_len TSRMLS_DC) /* {{{ */
 {
 	register unsigned long h;
-	char *bucket_key = tsrm_win32_get_path_sid_key(path TSRMLS_CC);
-	char *bucket_key_start = (char *)bucket_key;
+	char *bucket_key_start = tsrm_win32_get_path_sid_key(path TSRMLS_CC);
+	char *bucket_key = (char *)bucket_key_start;
 	const char *e = bucket_key + strlen(bucket_key);
 
 	if (!bucket_key) {
@@ -444,11 +444,7 @@ static inline unsigned long realpath_cache_key(const char *path, int path_len TS
 		h *= 16777619;
 		h ^= *bucket_key++;
 	}
-	/* if no SID were present the path is returned. Otherwise a Heap 
-	   allocated string is returned. */
-	if (bucket_key_start != path) {
-		LocalFree(bucket_key_start);
-	}
+	HeapFree(GetProcessHeap(), 0, (LPVOID)bucket_key_start);
 	return h;
 }
 /* }}} */
@@ -590,6 +586,22 @@ CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_
 }
 /* }}} */
 
+CWD_API int realpath_cache_size(TSRMLS_D) 
+{
+	return CWDG(realpath_cache_size);
+}
+
+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) 
+{
+	return CWDG(realpath_cache);
+}
+
+
 #undef LINK_MAX
 #define LINK_MAX 32
 
@@ -702,7 +714,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 && (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;
@@ -983,9 +997,19 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
 	time_t t;
 	int ret;
 	int add_slash;
+	void *tmp;
 	TSRMLS_FETCH();
 
 	if (path_length == 0 || path_length >= MAXPATHLEN-1) {
+#ifdef TSRM_WIN32
+# if _MSC_VER < 1300
+		errno = EINVAL;
+# else
+		_set_errno(EINVAL);
+# endif
+#else
+		errno = EINVAL;
+#endif
 		return 1;
 	}
 
@@ -1127,7 +1151,16 @@ verify:
 
 		CWD_STATE_COPY(&old_state, state);
 		state->cwd_length = path_length;
-		state->cwd = (char *) realloc(state->cwd, state->cwd_length+1);
+
+		tmp = realloc(state->cwd, state->cwd_length+1);
+		if (tmp == NULL) {
+#if VIRTUAL_CWD_DEBUG
+			fprintf (stderr, "Out of memory\n");
+#endif
+			return 1;
+		}
+		state->cwd = (char *) tmp;
+
 		memcpy(state->cwd, resolved_path, state->cwd_length+1);
 		if (verify_path(state)) {
 			CWD_STATE_FREE(state);
@@ -1139,7 +1172,15 @@ verify:
 		}
 	} else {
 		state->cwd_length = path_length;
-		state->cwd = (char *) realloc(state->cwd, state->cwd_length+1);
+		tmp = realloc(state->cwd, state->cwd_length+1);
+		if (tmp == NULL) {
+#if VIRTUAL_CWD_DEBUG
+			fprintf (stderr, "Out of memory\n");
+#endif
+			return 1;
+		}
+		state->cwd = (char *) tmp;
+
 		memcpy(state->cwd, resolved_path, state->cwd_length+1);
 		ret = 0;
 	}
diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h
index 7f612bf..c18bc0f 100644
--- a/TSRM/tsrm_virtual_cwd.h
+++ b/TSRM/tsrm_virtual_cwd.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_virtual_cwd.h 287673 2009-08-25 09:16:53Z pajoye $ */
+/* $Id: tsrm_virtual_cwd.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef VIRTUAL_CWD_H
 #define VIRTUAL_CWD_H
@@ -238,6 +238,9 @@ extern virtual_cwd_globals cwd_globals;
 CWD_API void realpath_cache_clean(TSRMLS_D);
 CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC);
 CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t TSRMLS_DC);
+CWD_API int realpath_cache_size(TSRMLS_D);
+CWD_API int realpath_cache_max_buckets(TSRMLS_D);
+CWD_API 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
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index b224d4b..2267488 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_win32.c 290166 2009-11-03 10:48:12Z pajoye $ */
+/* $Id: tsrm_win32.c 294728 2010-02-07 21:09:19Z pajoye $ */
 
 #include <stdio.h>
 #include <fcntl.h>
@@ -176,6 +176,7 @@ PSID tsrm_win32_get_token_sid(HANDLE hToken)
 	if (!CopySid(sid_len, pResultSid, pTokenUser->User.Sid)) {
 		goto Finished;
 	}
+	HeapFree(GetProcessHeap(), 0, (LPVOID)pTokenUser);
 	return pResultSid;
 
 Finished:
@@ -222,11 +223,13 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
  		}
 
 		if(access(pathname, mode)) {
+			free(real_path);
 			return errno;
 		}
 
  		/* If only existence check is made, return now */
  		if (mode == 0) {
+			free(real_path);
 			return 0;
 		}
 
@@ -271,6 +274,9 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
 			if (!DuplicateToken(thread_token, SecurityImpersonation, &TWG(impersonation_token))) {
 				goto Finished;
 			}
+		} else {
+			/* we already have it, free it then */
+			free(token_sid);
 		}
 
 		if (CWDG(realpath_cache_size_limit)) {
@@ -299,7 +305,7 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
 				fAccess = bucket->is_writable;
 				goto Finished;
 			}
-			desired_access = FILE_GENERIC_READ | FILE_GENERIC_WRITE;
+			desired_access = FILE_GENERIC_WRITE;
  		} else if(mode <= 4) {
 			if(bucket != NULL && bucket->is_rvalid) {
 				fAccess = bucket->is_readable;
@@ -344,6 +350,11 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
 			else if(desired_access == FILE_GENERIC_WRITE) {
 				bucket->is_wvalid = 1;
 				bucket->is_writable = fAccess;
+			} else if (desired_access == (FILE_GENERIC_READ | FILE_GENERIC_WRITE)) {
+				bucket->is_rvalid = 1;
+				bucket->is_readable = fAccess;
+				bucket->is_wvalid = 1;
+				bucket->is_writable = fAccess;
 			}
 		}
 
@@ -518,7 +529,6 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
 		if (err == ERROR_NO_TOKEN) {
 			asuser = FALSE;
 		}
-
 	}
 
 	cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c ")+2);
diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h
index 7cd9669..0d6f2ab 100644
--- a/TSRM/tsrm_win32.h
+++ b/TSRM/tsrm_win32.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_win32.h 289780 2009-10-19 23:38:55Z pajoye $ */
+/* $Id: tsrm_win32.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef TSRM_WIN32_H
 #define TSRM_WIN32_H
diff --git a/Zend/acconfig.h b/Zend/acconfig.h
index bb949a6..75d1cd8 100644
--- a/Zend/acconfig.h
+++ b/Zend/acconfig.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: acconfig.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: acconfig.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #if defined(__GNUC__) && __GNUC__ >= 4
 # define ZEND_API __attribute__ ((visibility("default")))
diff --git a/Zend/header b/Zend/header
index 68bf97b..8686062 100644
--- a/Zend/header
+++ b/Zend/header
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -16,4 +16,4 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: header 272619 2009-01-02 20:45:43Z felipe $ */
+/* $Id: header 294437 2010-02-03 18:47:13Z pajoye $ */
diff --git a/Zend/tests/bug44827.phpt b/Zend/tests/bug44827.phpt
new file mode 100644
index 0000000..a9f1d87
--- /dev/null
+++ b/Zend/tests/bug44827.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #44827 (define() allows :: in constant names)
+--FILE--
+<?php
+define('foo::bar', 1);
+define('::', 1);
+?>
+--EXPECTF--
+Warning: Class constants cannot be defined or redefined in %sbug44827.php on line %d
+
+Warning: Class constants cannot be defined or redefined in %sbug44827.php on line %d
diff --git a/Zend/tests/bug47516.phpt b/Zend/tests/bug47516.phpt
index 66304fe..a9a2071 100644
--- a/Zend/tests/bug47516.phpt
+++ b/Zend/tests/bug47516.phpt
@@ -30,7 +30,7 @@ ppp
 
 echo "$htm\n";
 ?>
---EXPECT---
+--EXPECT--
 abc
 abc
 abc
diff --git a/Zend/tests/bug48667_1.phpt b/Zend/tests/bug48667_1.phpt
new file mode 100644
index 0000000..2d94aed
--- /dev/null
+++ b/Zend/tests/bug48667_1.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #48667 (Implementing both iterator and iteratoraggregate)
+--FILE--
+<?php
+
+abstract class A implements Iterator, IteratorAggregate { }
+
+?>
+--EXPECTF--
+Fatal error: Class A cannot implement both IteratorAggregate and Iterator at the same time in %s on line %d
diff --git a/Zend/tests/bug48667_2.phpt b/Zend/tests/bug48667_2.phpt
new file mode 100644
index 0000000..57cd5eb
--- /dev/null
+++ b/Zend/tests/bug48667_2.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #48667 (Implementing both iterator and iteratoraggregate)
+--FILE--
+<?php
+
+abstract class A implements IteratorAggregate, Iterator { }
+
+?>
+--EXPECTF--
+Fatal error: Class A cannot implement both Iterator and IteratorAggregate at the same time in %s on line %d
diff --git a/Zend/tests/bug49472.phpt b/Zend/tests/bug49472.phpt
new file mode 100644
index 0000000..1803d18
--- /dev/null
+++ b/Zend/tests/bug49472.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #49472 (Constants defined in Interfaces can be overridden)
+--FILE--
+<?php
+
+interface ia {
+    const c = 'Sea';
+    const y = 2;
+}
+
+class Foo implements ia {
+}
+
+class FooBar extends Foo implements ia {
+	const x = 1;
+	const c = 'Ocean';
+	
+	public function show() {
+		return ia::c;
+	}
+}
+
+new FooBar;
+
+?>
+--EXPECTF--
+Fatal error: Cannot inherit previously-inherited or override constant c from interface ia in %s on line %d
diff --git a/Zend/tests/bug49866.phpt b/Zend/tests/bug49866.phpt
new file mode 100644
index 0000000..7fbc0d8
--- /dev/null
+++ b/Zend/tests/bug49866.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #49866 (Making reference on string offsets crashes PHP)
+--FILE--
+<?php
+$a = "string";
+$b = &$a[1];
+$b = "f";
+echo $a;
+--EXPECTF--
+Fatal error: Cannot create references to/from string offsets nor overloaded objects in %sbug49866.php on line 3
diff --git a/Zend/tests/bug50005.phpt b/Zend/tests/bug50005.phpt
new file mode 100644
index 0000000..bf4fbbd
--- /dev/null
+++ b/Zend/tests/bug50005.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #50005 (Throwing through Reflection modified Exception object makes segmentation fault)
+--FILE--
+<?php
+
+class a extends exception {
+	public function __construct() {
+		$this->file = null;
+	}
+}
+
+throw new a;
+
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'a' in :%d
+Stack trace:
+#0 {main}
+  thrown in Unknown on line %d
diff --git a/Zend/tests/bug50146.phpt b/Zend/tests/bug50146.phpt
new file mode 100644
index 0000000..7aa26a6
--- /dev/null
+++ b/Zend/tests/bug50146.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #50146 (property_exists: Closure object cannot have properties)
+--FILE--
+<?php
+
+$obj = function(){};
+
+var_dump(property_exists($obj,'foo'));
+
+$ref = new ReflectionObject($obj);
+var_dump($ref->hasProperty('b'));
+
+var_dump(isset($obj->a));
+
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+
+Catchable fatal error: Closure object cannot have properties in %s on line %d
diff --git a/Zend/tests/bug50174.phpt b/Zend/tests/bug50174.phpt
new file mode 100644
index 0000000..fef6513
--- /dev/null
+++ b/Zend/tests/bug50174.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #50174 (Incorrectly matched docComment)
+--SKIPIF--
+<?php if (!extension_loaded('reflection') || !extension_loaded('spl')) print "skip"; ?>
+--FILE--
+<?php
+
+class TestClass
+{
+	/** const comment */
+	const C = 0;
+
+	function x() {}
+}
+
+$rm = new ReflectionMethod('TestClass', 'x');
+var_dump($rm->getDocComment());
+
+class TestClass2
+{
+	/** const comment */
+	const C = 0;
+
+	public $x;
+}
+
+$rp = new ReflectionProperty('TestClass2', 'x');
+var_dump($rp->getDocComment());
+
+?>
+--EXPECT--
+bool(false)
+bool(false)
diff --git a/Zend/tests/bug50255.phpt b/Zend/tests/bug50255.phpt
new file mode 100644
index 0000000..9f390af
--- /dev/null
+++ b/Zend/tests/bug50255.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #50255 (isset() and empty() silently casts array to object)
+--FILE--
+<?php
+
+$arr = array('foo' => 'bar');
+
+print "isset\n";
+var_dump(isset($arr->foo));
+var_dump(isset($arr->bar));
+var_dump(isset($arr['foo']));
+var_dump(isset($arr['bar']));
+print "empty\n";
+var_dump(empty($arr->foo));
+var_dump(empty($arr->bar));
+var_dump(empty($arr['foo']));
+var_dump(empty($arr['bar']));
+
+?>
+--EXPECT--
+isset
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+empty
+bool(true)
+bool(true)
+bool(false)
+bool(true)
diff --git a/Zend/tests/bug50261.phpt b/Zend/tests/bug50261.phpt
new file mode 100644
index 0000000..271a2c4
--- /dev/null
+++ b/Zend/tests/bug50261.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #50261 (Crash When Calling Parent Constructor with call_user_func())
+--FILE--
+<?php
+
+class testClass {
+	function testClass($x) {
+		echo __METHOD__, " (". $x . ")\n";
+	}
+}
+
+class testClass2 extends testClass {
+	function __construct() {
+		static $x = 0;
+		
+		if ($x) {
+			print "Infinite loop...\n";
+		} else {
+			$x++;
+			
+			parent::__construct(1);
+			testclass::__construct(2);
+			call_user_func(array('parent', '__construct'), 3);
+			call_user_func(array('testclass', '__construct'), 4);
+			call_user_func(array('testclass', 'testclass'), 5);
+		}
+	}
+}
+
+new testClass2;
+
+?>
+--EXPECT--
+testClass::testClass (1)
+testClass::testClass (2)
+testClass::testClass (3)
+testClass::testClass (4)
+testClass::testClass (5)
diff --git a/Zend/tests/bug50394.phpt b/Zend/tests/bug50394.phpt
new file mode 100644
index 0000000..e6069d3
--- /dev/null
+++ b/Zend/tests/bug50394.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #50394: Reference argument converted to value in __call
+--FILE--
+<?php
+function inc( &$x ) { $x++; }
+
+class Proxy {
+        function __call( $name, $args ) {
+		echo "$name called!\n";
+                call_user_func_array( 'inc', $args );
+        }
+}
+
+$arg = 1;
+$args = array( &$arg );
+$proxy = new Proxy;
+call_user_func_array( array( $proxy, 'bar' ), $args );
+call_user_func_array( array( $proxy, 'bar' ), array(&$arg) );
+var_dump($arg);
+--EXPECT--	
+bar called!
+bar called!
+int(3)
+
diff --git a/Zend/tests/call_user_func_004.phpt b/Zend/tests/call_user_func_004.phpt
new file mode 100644
index 0000000..4885c4d
--- /dev/null
+++ b/Zend/tests/call_user_func_004.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Calling non-static method with call_user_func()
+--FILE--
+<?php
+
+class foo {
+	public function teste() {
+		$this->a = 1;
+	}
+}
+
+call_user_func(array('foo', 'teste'));
+
+?>
+--EXPECTF--
+Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method foo::teste() should not be called statically in %s on line %d
+
+Fatal error: Using $this when not in object context in %s on line %d
diff --git a/Zend/tests/call_user_func_005.phpt b/Zend/tests/call_user_func_005.phpt
new file mode 100644
index 0000000..6c1fa19
--- /dev/null
+++ b/Zend/tests/call_user_func_005.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Passing Closure as parameter to an non-existent function
+--FILE--
+<?php
+
+class foo {
+	public static function __callstatic($x, $y) {
+		var_dump($x,$y);
+		return 1;
+	}
+	
+	public function teste() {
+		return foo::x(function &($a=1,$b) { });
+	}
+}
+
+var_dump(call_user_func(array('foo', 'teste')));
+
+?>
+--EXPECTF--
+Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method foo::teste() should not be called statically in %s on line %d
+%string|unicode%(1) "x"
+array(1) {
+  [0]=>
+  object(Closure)#%d (1) {
+    ["parameter"]=>
+    array(2) {
+      ["$a"]=>
+      string(10) "<required>"
+      ["$b"]=>
+      string(10) "<required>"
+    }
+  }
+}
+int(1)
diff --git a/Zend/tests/call_with_refs.phpt b/Zend/tests/call_with_refs.phpt
new file mode 100644
index 0000000..acad134
--- /dev/null
+++ b/Zend/tests/call_with_refs.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Check call to non-ref function with call-time refs
+--FILE--
+<?php
+function my_errorhandler($errno,$errormsg) {
+  global $my_var;
+  $my_var=0x12345;
+  echo $errormsg."\n";
+  return true;
+}
+$oldhandler = set_error_handler("my_errorhandler");
+$my_var = str_repeat("A",64);
+$data = call_user_func_array("substr_replace",array(&$my_var, new StdClass(),1));
+echo "OK!";
+--EXPECT--	
+Object of class stdClass could not be converted to string
+Object of class stdClass to string conversion
+OK!
diff --git a/Zend/tests/closure_035.phpt b/Zend/tests/closure_035.phpt
new file mode 100644
index 0000000..ac8b4ca
--- /dev/null
+++ b/Zend/tests/closure_035.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Testing recursion detection with Closures
+--FILE--
+<?php
+
+$x = function () use (&$x) {
+	$h = function () use ($x) {
+		var_dump($x);
+		return 1;
+	};	
+	return $h();
+};
+
+var_dump($x());
+
+?>
+--EXPECTF--
+object(Closure)#%d (1) {
+  ["static"]=>
+  array(1) {
+    [%u|b%"x"]=>
+    &object(Closure)#%d (1) {
+      ["static"]=>
+      array(1) {
+        [%u|b%"x"]=>
+        *RECURSION*
+      }
+    }
+  }
+}
+int(1)
diff --git a/Zend/tests/errmsg_025.phpt b/Zend/tests/errmsg_025.phpt
index d853f73..014b409 100644
--- a/Zend/tests/errmsg_025.phpt
+++ b/Zend/tests/errmsg_025.phpt
@@ -16,5 +16,5 @@ class test implements test1, test2 {
 
 echo "Done\n";
 ?>
---EXPECTF--	
-Fatal error: Cannot inherit previously-inherited constant FOO from interface test2 in %s on line %d
+--EXPECTF--
+Fatal error: Cannot inherit previously-inherited or override constant FOO from interface test2 in %s on line %d
diff --git a/Zend/tests/inter_01.phpt b/Zend/tests/inter_01.phpt
index db2e86d..c73397c 100644
--- a/Zend/tests/inter_01.phpt
+++ b/Zend/tests/inter_01.phpt
@@ -15,4 +15,4 @@ class foobar implements foo {
 }
 ?>
 --EXPECTF--
-Fatal error: Cannot inherit previously-inherited constant foo from interface foo in %s on line %d
+Fatal error: Cannot inherit previously-inherited or override constant foo from interface foo in %s on line %d
diff --git a/Zend/tests/unset_cv05.phpt b/Zend/tests/unset_cv05.phpt
index 24f9c00..8e3c634 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--
-PHP Warning:  Directive 'register_long_arrays' is deprecated in PHP %d.%d and greater in Unknown on line 0
+Warning: 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 b682594..b1ef0cc 100644
--- a/Zend/tests/unset_cv06.phpt
+++ b/Zend/tests/unset_cv06.phpt
@@ -19,7 +19,7 @@ echo $x;
 echo "ok\n";
 ?>
 --EXPECTF--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP %d.%d and greater in Unknown on line 0
+Warning: 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.c b/Zend/zend.c
index df9a86c..cd8ba77 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend.c 290026 2009-10-28 11:08:33Z pajoye $ */
+/* $Id: zend.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_extensions.h"
@@ -114,7 +114,7 @@ ZEND_API zval zval_used_for_init; /* True global variable */
 /* version information */
 static char *zend_version_info;
 static uint zend_version_info_length;
-#define ZEND_CORE_VERSION_INFO	"Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2009 Zend Technologies\n"
+#define ZEND_CORE_VERSION_INFO	"Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2010 Zend Technologies\n"
 #define PRINT_ZVAL_INDENT 4
 
 static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent, zend_bool is_object TSRMLS_DC) /* {{{ */
diff --git a/Zend/zend.h b/Zend/zend.h
index 58f0e59..3332e7c 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend.h 286859 2009-08-06 01:33:54Z scottmac $ */
+/* $Id: zend.h 294459 2010-02-03 20:44:43Z pajoye $ */
 
 #ifndef ZEND_H
 #define ZEND_H
@@ -166,7 +166,7 @@ char *alloca ();
 # define ZEND_ATTRIBUTE_DEPRECATED
 #endif
 
-#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3400 && defined(__i386__)
+#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__)
 # define ZEND_FASTCALL __attribute__((fastcall))
 #elif defined(_MSC_VER) && defined(_M_IX86)
 # define ZEND_FASTCALL __fastcall
@@ -174,7 +174,7 @@ char *alloca ();
 # define ZEND_FASTCALL
 #endif
 
-#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3400
+#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004
 #else
 # define __restrict__
 #endif
@@ -710,6 +710,11 @@ END_EXTERN_C()
 		FREE_ZVAL(pzv);						\
 	}										\
 	INIT_PZVAL(&(zv));
+	
+#define MAKE_COPY_ZVAL(ppzv, pzv) \
+	*(pzv) = **(ppzv);            \
+	zval_copy_ctor((pzv));        \
+	INIT_PZVAL((pzv));
 
 #define REPLACE_ZVAL_VALUE(ppzv_dest, pzv_src, copy) {	\
 	int is_ref, refcount;						\
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 6a5c5f8..6d939e6 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_API.c 289431 2009-10-09 17:21:20Z pajoye $ */
+/* $Id: zend_API.c 293980 2010-01-25 14:02:09Z johannes $ */
 
 #include "zend.h"
 #include "zend_execute.h"
@@ -923,7 +923,7 @@ ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC,
 		RETURN_IF_ZERO_ARGS(num_args, p, quiet);
 
 		va_start(va, type_spec);
-		retval = zend_parse_va_args(num_args, type_spec, &va, 0 TSRMLS_CC);
+		retval = zend_parse_va_args(num_args, type_spec, &va, flags TSRMLS_CC);
 		va_end(va);
 	} else {
 		p++;
@@ -2335,12 +2335,13 @@ ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_
 }
 /* }}} */
 
-static int zend_is_callable_check_class(const char *name, int name_len, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */
+static int zend_is_callable_check_class(const char *name, int name_len, zend_fcall_info_cache *fcc, int *strict_class, char **error TSRMLS_DC) /* {{{ */
 {
 	int ret = 0;
 	zend_class_entry **pce;
 	char *lcname = zend_str_tolower_dup(name, name_len);
 
+	*strict_class = 0;
 	if (name_len == sizeof("self") - 1 &&
 	    !memcmp(lcname, "self", sizeof("self") - 1)) {
 		if (!EG(scope)) {
@@ -2365,6 +2366,7 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca
 			if (!fcc->object_ptr) {
 				fcc->object_ptr = EG(This);
 			}
+			*strict_class = 1;
 			ret = 1;
 		}
 	} else if (name_len == sizeof("static") - 1 &&
@@ -2377,6 +2379,7 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca
 			if (!fcc->object_ptr) {
 				fcc->object_ptr = EG(This);
 			}
+			*strict_class = 1;
 			ret = 1;
 		}
 	} else if (zend_lookup_class_ex(name, name_len, 1, &pce TSRMLS_CC) == SUCCESS) {
@@ -2391,6 +2394,7 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca
 		} else {
 			fcc->called_scope = fcc->object_ptr ? Z_OBJCE_P(fcc->object_ptr) : fcc->calling_scope;
 		}
+		*strict_class = 1;
 		ret = 1;
 	} else {
 		if (error) zend_spprintf(error, 0, "class '%.*s' not found", name_len, name);
@@ -2401,7 +2405,7 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca
 /* }}} */
 
 
-static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */
+static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fcall_info_cache *fcc, int strict_class, char **error TSRMLS_DC) /* {{{ */
 {
 	zend_class_entry *ce_org = fcc->calling_scope;
 	int retval = 0;
@@ -2459,7 +2463,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
 			EG(scope) = ce_org;
 		}
 
-		if (!zend_is_callable_check_class(Z_STRVAL_P(callable), clen, fcc, error TSRMLS_CC)) {
+		if (!zend_is_callable_check_class(Z_STRVAL_P(callable), clen, fcc, &strict_class, error TSRMLS_CC)) {
 			EG(scope) = last_scope;
 			return 0;
 		}
@@ -2486,7 +2490,15 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
 	}
 
 	lmname = zend_str_tolower_dup(mname, mlen);
-	if (zend_hash_find(ftable, lmname, mlen+1, (void**)&fcc->function_handler) == SUCCESS) {
+	if (strict_class &&
+	    fcc->calling_scope &&
+	    mlen == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1 &&
+	    !memcmp(lmname, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {
+		fcc->function_handler = fcc->calling_scope->constructor;
+		if (fcc->function_handler) {
+			retval = 1;
+		}
+	} else if (zend_hash_find(ftable, lmname, mlen+1, (void**)&fcc->function_handler) == SUCCESS) {
 		retval = 1;
 		if ((fcc->function_handler->op_array.fn_flags & ZEND_ACC_CHANGED) &&
 		    EG(scope) &&
@@ -2520,11 +2532,36 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
 	} else {
 get_function_via_handler:
 		if (fcc->object_ptr && fcc->calling_scope == ce_org) {
-			if (Z_OBJ_HT_P(fcc->object_ptr)->get_method) {
+			if (strict_class && ce_org->__call) {
+				fcc->function_handler = emalloc(sizeof(zend_internal_function));
+				fcc->function_handler->internal_function.type = ZEND_INTERNAL_FUNCTION;
+				fcc->function_handler->internal_function.module = ce_org->module;
+				fcc->function_handler->internal_function.handler = zend_std_call_user_call;
+				fcc->function_handler->internal_function.arg_info = NULL;
+				fcc->function_handler->internal_function.num_args = 0;
+				fcc->function_handler->internal_function.scope = ce_org;
+				fcc->function_handler->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
+				fcc->function_handler->internal_function.function_name = estrndup(mname, mlen);
+				fcc->function_handler->internal_function.pass_rest_by_reference = 0;
+				fcc->function_handler->internal_function.return_reference = ZEND_RETURN_VALUE;
+				call_via_handler = 1;
+				retval = 1;
+			} else if (Z_OBJ_HT_P(fcc->object_ptr)->get_method) {
 				fcc->function_handler = Z_OBJ_HT_P(fcc->object_ptr)->get_method(&fcc->object_ptr, mname, mlen TSRMLS_CC);
 				if (fcc->function_handler) {
-					retval = 1;
-					call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
+					if (strict_class &&
+					    (!fcc->function_handler->common.scope ||
+					     !instanceof_function(ce_org, fcc->function_handler->common.scope TSRMLS_CC))) {
+						if ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) {
+							if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+								efree(fcc->function_handler->common.function_name);
+							}
+							efree(fcc->function_handler);
+						}
+					} else {
+						retval = 1;
+						call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
+					}
 				}
 			}
 		} else if (fcc->calling_scope) {
@@ -2680,7 +2717,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
 				return 1;
 			}
 
-			ret = zend_is_callable_check_func(check_flags, callable, fcc, error TSRMLS_CC);
+			ret = zend_is_callable_check_func(check_flags, callable, fcc, 0, error TSRMLS_CC);
 			if (fcc == &fcc_local &&
 			    fcc->function_handler &&
 				((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION &&
@@ -2698,6 +2735,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
 			{
 				zval **method = NULL;
 				zval **obj = NULL;
+				int strict_class = 0;
 
 				if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2) {
 					zend_hash_index_find(Z_ARRVAL_P(callable), 0, (void **) &obj);
@@ -2725,7 +2763,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
 							return 1;
 						}
 
-						if (!zend_is_callable_check_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), fcc, error TSRMLS_CC)) {
+						if (!zend_is_callable_check_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), fcc, &strict_class, error TSRMLS_CC)) {
 							return 0;
 						}
 
@@ -2757,7 +2795,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
 						}
 					}
 
-					ret = zend_is_callable_check_func(check_flags, *method, fcc, error TSRMLS_CC);
+					ret = zend_is_callable_check_func(check_flags, *method, fcc, strict_class, error TSRMLS_CC);
 					if (fcc == &fcc_local &&
 					    fcc->function_handler &&
 						((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION &&
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 032f830..7368958 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_API.h 286469 2009-07-28 21:12:42Z jani $ */
+/* $Id: zend_API.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_API_H
 #define ZEND_API_H
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 683ccf9..dac5454 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_alloc.c 287992 2009-09-03 14:33:11Z dmitry $ */
+/* $Id: zend_alloc.c 294518 2010-02-04 09:48:02Z pajoye $ */
 
 #include "zend.h"
 #include "zend_alloc.h"
@@ -84,6 +84,10 @@ static void zend_mm_panic(const char *message) __attribute__ ((noreturn));
 static void zend_mm_panic(const char *message)
 {
 	fprintf(stderr, "%s\n", message);
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+	fflush(stderr);
+#endif
 #if ZEND_DEBUG && defined(HAVE_KILL) && defined(HAVE_GETPID)
 	kill(getpid(), SIGSEGV);
 #endif
@@ -940,15 +944,27 @@ static void zend_mm_free_cache(zend_mm_heap *heap)
 #endif
 
 #if ZEND_MM_HEAP_PROTECTION || ZEND_MM_COOKIES
-static void zend_mm_random(unsigned char *buf, size_t size)
+static void zend_mm_random(unsigned char *buf, size_t size) /* {{{ */
 {
 	size_t i = 0;
 	unsigned char t;
 
 #ifdef ZEND_WIN32
 	HCRYPTPROV   hCryptProv;
-
-	if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) {
+	int has_context = 0;
+
+	if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) {
+		/* Could mean that the key container does not exist, let try 
+		   again by asking for a new one */
+		if (GetLastError() == NTE_BAD_KEYSET) {
+			if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
+				has_context = 1;
+			}
+		}
+	} else {
+		has_context = 1;
+	}
+	if (has_context) {
 		do {
 			BOOL ret = CryptGenRandom(hCryptProv, size, buf);
 			CryptReleaseContext(hCryptProv, 0);
@@ -957,7 +973,7 @@ static void zend_mm_random(unsigned char *buf, size_t size)
 					i++;
 				}
 				if (i == size) {
-				    return;
+					return;
 				}
 		   }
 		} while (0);
@@ -986,6 +1002,7 @@ static void zend_mm_random(unsigned char *buf, size_t size)
 		t = buf[i++] << 1;
     }
 }
+/* }}} */
 #endif
 
 /* Notes:
@@ -1031,11 +1048,19 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers,
 
 	if (zend_mm_low_bit(block_size) != zend_mm_high_bit(block_size)) {
 		fprintf(stderr, "'block_size' must be a power of two\n");
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+		fflush(stderr);
+#endif
 		exit(255);
 	}
 	storage = handlers->init(params);
 	if (!storage) {
 		fprintf(stderr, "Cannot initialize zend_mm storage [%s]\n", handlers->name);
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+		fflush(stderr);
+#endif
 		exit(255);
 	}
 	storage->handlers = handlers;
@@ -1118,9 +1143,17 @@ ZEND_API zend_mm_heap *zend_mm_startup(void)
 		if (!mem_handlers[i].name) {
 			fprintf(stderr, "Wrong or unsupported zend_mm storage type '%s'\n", mem_type);
 			fprintf(stderr, "  supported types:\n");
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+			fflush(stderr);
+#endif
 			for (i = 0; mem_handlers[i].name; i++) {
 				fprintf(stderr, "    '%s'\n", mem_handlers[i].name);
 			}
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+			fflush(stderr);
+#endif
 			exit(255);
 		}
 	}
@@ -1131,9 +1164,17 @@ ZEND_API zend_mm_heap *zend_mm_startup(void)
 		seg_size = zend_atoi(tmp, 0);
 		if (zend_mm_low_bit(seg_size) != zend_mm_high_bit(seg_size)) {
 			fprintf(stderr, "ZEND_MM_SEG_SIZE must be a power of two\n");
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+			fflush(stderr);
+#endif
 			exit(255);
 		} else if (seg_size < ZEND_MM_ALIGNED_SEGMENT_SIZE + ZEND_MM_ALIGNED_HEADER_SIZE) {
 			fprintf(stderr, "ZEND_MM_SEG_SIZE is too small\n");
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+			fflush(stderr);
+#endif
 			exit(255);
 		}
 	} else {
@@ -1672,6 +1713,10 @@ static void zend_mm_safe_error(zend_mm_heap *heap,
 					size);
 				fprintf(stderr, " in %s on line %d\n", error_filename, error_lineno);
 			}
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+			fflush(stderr);
+#endif
 		} zend_end_try();
 	} else {
 		heap->overflow = 2;
diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h
index b1ecab9..ac64a30 100644
--- a/Zend/zend_alloc.h
+++ b/Zend/zend_alloc.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_alloc.h 287992 2009-09-03 14:33:11Z dmitry $ */
+/* $Id: zend_alloc.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_ALLOC_H
 #define ZEND_ALLOC_H
diff --git a/Zend/zend_build.h b/Zend/zend_build.h
index 4c81fcc..2c821f3 100755
--- a/Zend/zend_build.h
+++ b/Zend/zend_build.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index ec29a49..93dbe49 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.c 286878 2009-08-06 11:02:25Z jani $ */
+/* $Id: zend_builtin_functions.c 294034 2010-01-25 23:41:18Z johannes $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -629,7 +629,6 @@ ZEND_FUNCTION(define)
 	zend_bool non_cs = 0;
 	int case_sensitive = CONST_CS;
 	zend_constant c;
-	char *p;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|b", &name, &name_len, &val, &non_cs) == FAILURE) {
 		return;
@@ -640,31 +639,9 @@ ZEND_FUNCTION(define)
 	}
 
 	/* class constant, check if there is name and make sure class is valid & exists */
-	if ((p = zend_memnstr(name, "::", sizeof("::") - 1, name + name_len))) {
-		char *class_name;
-		int found;
-		zend_class_entry **ce;
-		ALLOCA_FLAG(use_heap)
-
-		if (p == (name + name_len - sizeof("::") + 1)) {
-			zend_error(E_WARNING, "Class constant must have a name");
-			RETURN_FALSE;
-		} else if (p == name) {
-			zend_error(E_WARNING, "Missing class name");
-			RETURN_FALSE;
-		}
-
-		class_name = do_alloca((p - name + 1), use_heap);
-		zend_str_tolower_copy(class_name, name, (p - name));
-
-		found = zend_hash_find(EG(class_table), class_name, p - name + 1, (void **) &ce);
-
-		if (found != SUCCESS) {
-			zend_error(E_WARNING, "Class '%s' does not exist", class_name);
-			free_alloca(class_name, use_heap);
-			RETURN_FALSE;
-		}
-		free_alloca(class_name, use_heap);
+	if (zend_memnstr(name, "::", sizeof("::") - 1, name + name_len)) {
+		zend_error(E_WARNING, "Class constants cannot be defined or redefined");
+		RETURN_FALSE;
 	}
 
 repeat:
diff --git a/Zend/zend_builtin_functions.h b/Zend/zend_builtin_functions.h
index aca6d77..03bfd37 100644
--- a/Zend/zend_builtin_functions.h
+++ b/Zend/zend_builtin_functions.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_builtin_functions.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_BUILTIN_FUNCTIONS_H
 #define ZEND_BUILTIN_FUNCTIONS_H
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index 96fc567..a5a2f84 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_closures.c 287043 2009-08-10 15:18:13Z colder $ */
+/* $Id: zend_closures.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -152,7 +152,9 @@ static zval **zend_closure_get_property_ptr_ptr(zval *object, zval *member TSRML
 
 static int zend_closure_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC) /* {{{ */
 {
-	ZEND_CLOSURE_PROPERTY_ERROR();
+	if (has_set_exists != 2) {
+		ZEND_CLOSURE_PROPERTY_ERROR();
+	}
 	return 0;
 }
 /* }}} */
diff --git a/Zend/zend_closures.h b/Zend/zend_closures.h
index 64c476b..c51079e 100644
--- a/Zend/zend_closures.h
+++ b/Zend/zend_closures.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_closures.h 274683 2009-01-26 22:54:34Z cseiler $ */
+/* $Id: zend_closures.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_CLOSURES_H
 #define ZEND_CLOSURES_H
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index a02278f..791a08e 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.c 289432 2009-10-09 17:23:01Z pajoye $ */
+/* $Id: zend_compile.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include <zend_language_parser.h>
 #include "zend.h"
@@ -161,6 +161,7 @@ void zend_init_compiler_data_structures(TSRMLS_D) /* {{{ */
 	CG(encoding_detector) = NULL;
 	CG(encoding_converter) = NULL;
 	CG(encoding_oddlen) = NULL;
+	CG(encoding_declared) = 0;
 #endif /* ZEND_MULTIBYTE */
 }
 /* }}} */
@@ -2875,8 +2876,8 @@ static zend_bool do_inherit_constant_check(HashTable *child_constants_table, con
 	zval **old_constant;
 
 	if (zend_hash_quick_find(child_constants_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void**)&old_constant) == SUCCESS) {
-	  if (*old_constant != *parent_constant) {
-			zend_error(E_COMPILE_ERROR, "Cannot inherit previously-inherited constant %s from interface %s", hash_key->arKey, iface->name);
+		if (*old_constant != *parent_constant) {
+			zend_error(E_COMPILE_ERROR, "Cannot inherit previously-inherited or override constant %s from interface %s", hash_key->arKey, iface->name);
 		}
 		return 0;
 	}
@@ -2884,6 +2885,16 @@ static zend_bool do_inherit_constant_check(HashTable *child_constants_table, con
 }
 /* }}} */
 
+static int do_interface_constant_check(zval **val TSRMLS_DC, int num_args, va_list args, const zend_hash_key *key) /* {{{ */
+{
+	zend_class_entry **iface = va_arg(args, zend_class_entry**);
+
+	do_inherit_constant_check(&(*iface)->constants_table, (const zval **) val, key, *iface);
+
+	return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
 ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC) /* {{{ */
 {
 	zend_uint i, ignore = 0;
@@ -2902,7 +2913,10 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry
 			}
 		}
 	}
-	if (!ignore) {
+	if (ignore) {
+		/* Check for attempt to redeclare interface constants */
+		zend_hash_apply_with_arguments(&ce->constants_table TSRMLS_CC, (apply_func_args_t) do_interface_constant_check, 1, &iface);
+	} else {
 		if (ce->num_interfaces >= current_iface_num) {
 			if (ce->type == ZEND_INTERNAL_CLASS) {
 				ce->interfaces = (zend_class_entry **) realloc(ce->interfaces, sizeof(zend_class_entry *) * (++current_iface_num));
@@ -3658,6 +3672,12 @@ void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_D
 		zend_error(E_COMPILE_ERROR, "Cannot redefine class constant %s::%s", CG(active_class_entry)->name, var_name->u.constant.value.str.val);
 	}
 	FREE_PNODE(var_name);
+	
+	if (CG(doc_comment)) {
+		efree(CG(doc_comment));
+		CG(doc_comment) = NULL;
+		CG(doc_comment_len) = 0;
+	}
 }
 /* }}} */
 
@@ -4644,7 +4664,7 @@ void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC) /* {{{ */
 				--num;
 			}
 
-			if (num > 0 || CG(encoding_declared)) {
+			if (num > 0) {
 				zend_error(E_COMPILE_ERROR, "Encoding declaration pragma must be the very first statement in the script");
 			}
 		}
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index 3ccd199..6b24d09 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.h 281737 2009-06-05 23:20:59Z shire $ */
+/* $Id: zend_compile.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_COMPILE_H
 #define ZEND_COMPILE_H
diff --git a/Zend/zend_config.nw.h b/Zend/zend_config.nw.h
index ce2a49e..14467c2 100644
--- a/Zend/zend_config.nw.h
+++ b/Zend/zend_config.nw.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_config.nw.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_config.nw.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_CONFIG_NW_H
 #define ZEND_CONFIG_NW_H
diff --git a/Zend/zend_config.w32.h b/Zend/zend_config.w32.h
index 57f08b1..4313ec1 100644
--- a/Zend/zend_config.w32.h
+++ b/Zend/zend_config.w32.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_config.w32.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_config.w32.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_CONFIG_W32_H
 #define ZEND_CONFIG_W32_H
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c
index d7f13de..2713019 100644
--- a/Zend/zend_constants.c
+++ b/Zend/zend_constants.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_constants.c 273405 2009-01-12 21:54:37Z stas $ */
+/* $Id: zend_constants.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_constants.h"
diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h
index 0ae8337..b041c98 100644
--- a/Zend/zend_constants.h
+++ b/Zend/zend_constants.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_constants.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_constants.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_CONSTANTS_H
 #define ZEND_CONSTANTS_H
diff --git a/Zend/zend_default_classes.c b/Zend/zend_default_classes.c
index 52c9588..d36dabb 100644
--- a/Zend/zend_default_classes.c
+++ b/Zend/zend_default_classes.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_default_classes.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_default_classes.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_API.h"
diff --git a/Zend/zend_dynamic_array.c b/Zend/zend_dynamic_array.c
index 3c98ffa..b6ad419 100644
--- a/Zend/zend_dynamic_array.c
+++ b/Zend/zend_dynamic_array.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_dynamic_array.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_dynamic_array.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 
diff --git a/Zend/zend_dynamic_array.h b/Zend/zend_dynamic_array.h
index b153a34..c0e22f6 100644
--- a/Zend/zend_dynamic_array.h
+++ b/Zend/zend_dynamic_array.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_dynamic_array.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_dynamic_array.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_DYNAMIC_ARRAY_H
 #define ZEND_DYNAMIC_ARRAY_H
diff --git a/Zend/zend_errors.h b/Zend/zend_errors.h
index dbfba46..df5da6e 100644
--- a/Zend/zend_errors.h
+++ b/Zend/zend_errors.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_errors.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_errors.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_ERRORS_H
 #define ZEND_ERRORS_H
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 6c3560d..fcd9f25 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_exceptions.c 280362 2009-05-11 15:03:47Z felipe $ */
+/* $Id: zend_exceptions.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_API.h"
diff --git a/Zend/zend_exceptions.h b/Zend/zend_exceptions.h
index 28a9be8..ee2ced9 100644
--- a/Zend/zend_exceptions.h
+++ b/Zend/zend_exceptions.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_exceptions.h 272584 2009-01-02 13:14:49Z helly $ */
+/* $Id: zend_exceptions.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_EXCEPTIONS_H
 #define ZEND_EXCEPTIONS_H
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 696112f..e20312e 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute.c 281670 2009-06-04 18:20:45Z mattwil $ */
+/* $Id: zend_execute.c 294505 2010-02-04 09:13:14Z pajoye $ */
 
 #define ZEND_INTENSIVE_DEBUGGING 0
 
@@ -1232,6 +1232,10 @@ static int zend_check_symbol(zval **pz TSRMLS_DC)
 {
 	if (Z_TYPE_PP(pz) > 9) {
 		fprintf(stderr, "Warning!  %x has invalid type!\n", *pz);
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+		fflush(stderr);
+#endif
 	} else if (Z_TYPE_PP(pz) == IS_ARRAY) {
 		zend_hash_apply(Z_ARRVAL_PP(pz), (apply_func_t) zend_check_symbol TSRMLS_CC);
 	} else if (Z_TYPE_PP(pz) == IS_OBJECT) {
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index 6a1f06a..6ea325f 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute.h 287992 2009-09-03 14:33:11Z dmitry $ */
+/* $Id: zend_execute.h 294526 2010-02-04 10:21:05Z pajoye $ */
 
 #ifndef ZEND_EXECUTE_H
 #define ZEND_EXECUTE_H
@@ -228,7 +228,7 @@ static inline void *zend_vm_stack_alloc(size_t size TSRMLS_DC)
 		int extra = (ZEND_MM_ALIGNMENT - ((zend_uintptr_t)EG(argument_stack)->top & (ZEND_MM_ALIGNMENT - 1))) / sizeof(void*);
 
 		if (UNEXPECTED(size + extra + ZEND_MM_ALIGNED_SIZE(sizeof(void*)) / sizeof(void*) >
-		    EG(argument_stack)->end - EG(argument_stack)->top)) {
+		    (zend_uintptr_t)(EG(argument_stack)->end - EG(argument_stack)->top))) {
 			zend_vm_stack_extend(size TSRMLS_CC);
 		} else {
 			void **old_top = EG(argument_stack)->top;
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 88df13e..849391b 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute_API.c 287466 2009-08-18 20:51:49Z stas $ */
+/* $Id: zend_execute_API.c 294505 2010-02-04 09:13:14Z pajoye $ */
 
 #include <stdio.h>
 #include <signal.h>
@@ -74,6 +74,10 @@ static void zend_handle_sigsegv(int dummy) /* {{{ */
 				get_active_function_name(TSRMLS_C),
 				zend_get_executed_filename(TSRMLS_C),
 				zend_get_executed_lineno(TSRMLS_C));
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+		fflush(stderr);
+#endif
 	}
 	if (original_sigsegv_handler!=zend_handle_sigsegv) {
 		original_sigsegv_handler(dummy);
@@ -837,7 +841,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
 	for (i=0; i<fci->param_count; i++) {
 		zval *param;
 
-        	if(EX(function_state).function->type == ZEND_INTERNAL_FUNCTION 
+		if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION 
+			&& (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0 
 			&& !ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1)
 			&& PZVAL_IS_REF(*fci->params[i])) {
 			SEPARATE_ZVAL(fci->params[i]);
@@ -1481,7 +1486,7 @@ void zend_unset_timeout(TSRMLS_D) /* {{{ */
 	}
 #else
 #	ifdef HAVE_SETITIMER
-	{
+	if (EG(timeout_seconds)) {
 		struct itimerval no_timeout;
 
 		no_timeout.it_value.tv_sec = no_timeout.it_value.tv_usec = no_timeout.it_interval.tv_sec = no_timeout.it_interval.tv_usec = 0;
diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c
index 0a15a8c..cbe6b86 100644
--- a/Zend/zend_extensions.c
+++ b/Zend/zend_extensions.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_extensions.c 286859 2009-08-06 01:33:54Z scottmac $ */
+/* $Id: zend_extensions.c 294505 2010-02-04 09:13:14Z pajoye $ */
 
 #include "zend_extensions.h"
 
@@ -35,6 +35,10 @@ int zend_load_extension(const char *path)
 	if (!handle) {
 #ifndef ZEND_WIN32
 		fprintf(stderr, "Failed loading %s:  %s\n", path, DL_ERROR());
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+		fflush(stderr);
+#endif
 #else
 		fprintf(stderr, "Failed loading %s\n", path);
 #endif
@@ -51,6 +55,10 @@ int zend_load_extension(const char *path)
 	}
 	if (!extension_version_info || !new_extension) {
 		fprintf(stderr, "%s doesn't appear to be a valid Zend extension\n", path);
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+		fflush(stderr);
+#endif
 		DL_UNLOAD(handle);
 		return FAILURE;
 	}
@@ -64,6 +72,10 @@ int zend_load_extension(const char *path)
 					new_extension->name,
 					extension_version_info->zend_extension_api_no,
 					ZEND_EXTENSION_API_NO);
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+			fflush(stderr);
+#endif
 			DL_UNLOAD(handle);
 			return FAILURE;
 		} else if (extension_version_info->zend_extension_api_no < ZEND_EXTENSION_API_NO) {
@@ -76,6 +88,10 @@ int zend_load_extension(const char *path)
 					new_extension->author,
 					new_extension->URL,
 					new_extension->name);
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+			fflush(stderr);
+#endif
 			DL_UNLOAD(handle);
 			return FAILURE;
 		}
@@ -83,6 +99,10 @@ int zend_load_extension(const char *path)
 	           (!new_extension->build_id_check || new_extension->build_id_check(ZEND_EXTENSION_BUILD_ID) != SUCCESS)) {
 		fprintf(stderr, "Cannot load %s - it was built with configuration %s, whereas running engine is %s\n",
 					new_extension->name, extension_version_info->build_id, ZEND_EXTENSION_BUILD_ID);
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+		fflush(stderr);
+#endif
 		DL_UNLOAD(handle);
 		return FAILURE;
 	}
@@ -90,6 +110,10 @@ int zend_load_extension(const char *path)
 	return zend_register_extension(new_extension, handle);
 #else
 	fprintf(stderr, "Extensions are not supported on this platform.\n");
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+	fflush(stderr);
+#endif
 	return FAILURE;
 #endif
 }
diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h
index 449f37b..98747ce 100644
--- a/Zend/zend_extensions.h
+++ b/Zend/zend_extensions.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_extensions.h 282827 2009-06-26 15:44:19Z johannes $ */
+/* $Id: zend_extensions.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_EXTENSIONS_H
 #define ZEND_EXTENSIONS_H
diff --git a/Zend/zend_fast_cache.h b/Zend/zend_fast_cache.h
index e67c09b..afc708b 100644
--- a/Zend/zend_fast_cache.h
+++ b/Zend/zend_fast_cache.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_fast_cache.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_fast_cache.h 293155 2010-01-05 20:46:53Z sebastian $ */
 #if 0
 #ifndef ZEND_FAST_CACHE_H
 #define ZEND_FAST_CACHE_H
diff --git a/Zend/zend_float.c b/Zend/zend_float.c
index 263e0c7..d1ac404 100644
--- a/Zend/zend_float.c
+++ b/Zend/zend_float.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_float.c 277413 2009-03-18 11:53:10Z dmitry $ */
+/* $Id: zend_float.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_compile.h"
diff --git a/Zend/zend_float.h b/Zend/zend_float.h
index 45acbfd..9fdb469 100644
--- a/Zend/zend_float.h
+++ b/Zend/zend_float.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_float.h 277398 2009-03-18 10:18:10Z dmitry $ */
+/* $Id: zend_float.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_FLOAT_H
 #define ZEND_FLOAT_H
diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c
index 0c31668..6db682e 100644
--- a/Zend/zend_gc.c
+++ b/Zend/zend_gc.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_gc.c 278220 2009-04-03 18:52:21Z dmitry $ */
+/* $Id: zend_gc.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_API.h"
diff --git a/Zend/zend_gc.h b/Zend/zend_gc.h
index 5b99e97..0fbc9f1 100644
--- a/Zend/zend_gc.h
+++ b/Zend/zend_gc.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_gc.h 272619 2009-01-02 20:45:43Z felipe $ */
+/* $Id: zend_gc.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_GC_H
 #define ZEND_GC_H
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h
index d199019..f1f6c50 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_globals.h 277761 2009-03-25 15:23:58Z dmitry $ */
+/* $Id: zend_globals.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_GLOBALS_H
 #define ZEND_GLOBALS_H
diff --git a/Zend/zend_globals_macros.h b/Zend/zend_globals_macros.h
index 3175fc5..72ea598 100644
--- a/Zend/zend_globals_macros.h
+++ b/Zend/zend_globals_macros.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_globals_macros.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_globals_macros.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_GLOBALS_MACROS_H
 #define ZEND_GLOBALS_MACROS_H
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index e62ecbb..70d6bf7 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_hash.c 281778 2009-06-07 19:28:15Z mattwil $ */
+/* $Id: zend_hash.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h
index a80cd56..166003b 100644
--- a/Zend/zend_hash.h
+++ b/Zend/zend_hash.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_hash.h 281050 2009-05-25 01:18:00Z pollita $ */
+/* $Id: zend_hash.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_HASH_H
 #define ZEND_HASH_H
diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c
index 60b2bc3..7694565 100644
--- a/Zend/zend_highlight.c
+++ b/Zend/zend_highlight.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_highlight.c 279941 2009-05-05 01:35:44Z mattwil $ */
+/* $Id: zend_highlight.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include <zend_language_parser.h>
diff --git a/Zend/zend_highlight.h b/Zend/zend_highlight.h
index 756175f..3402f6f 100644
--- a/Zend/zend_highlight.h
+++ b/Zend/zend_highlight.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_highlight.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_highlight.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_HIGHLIGHT_H
 #define ZEND_HIGHLIGHT_H
diff --git a/Zend/zend_indent.c b/Zend/zend_indent.c
index 32d99cb..7542e48 100644
--- a/Zend/zend_indent.c
+++ b/Zend/zend_indent.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_indent.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_indent.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 /* This indenter doesn't really work, it's here for no particular reason. */
 
diff --git a/Zend/zend_indent.h b/Zend/zend_indent.h
index cc00d11..2615164 100644
--- a/Zend/zend_indent.h
+++ b/Zend/zend_indent.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_indent.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_indent.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_INDENT_H
 #define ZEND_INDENT_H
diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c
index 6914d7b..ef6ef37 100644
--- a/Zend/zend_ini.c
+++ b/Zend/zend_ini.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini.c 284254 2009-07-17 11:49:50Z jani $ */
+/* $Id: zend_ini.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_qsort.h"
diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h
index 7f866d9..4b4ab02 100644
--- a/Zend/zend_ini.h
+++ b/Zend/zend_ini.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_ini.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_INI_H
 #define ZEND_INI_H
diff --git a/Zend/zend_ini_parser.c b/Zend/zend_ini_parser.c
index cfaf583..d4e4084 100644
--- a/Zend/zend_ini_parser.c
+++ b/Zend/zend_ini_parser.c
@@ -116,7 +116,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -131,7 +131,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini_parser.y 272368 2008-12-31 11:13:47Z sebastian $ */
+/* $Id: zend_ini_parser.y 293154 2010-01-05 20:40:23Z sebastian $ */
 
 #define DEBUG_CFG_PARSER 0
 
diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y
index 121236d..e4755fb 100644
--- a/Zend/zend_ini_parser.y
+++ b/Zend/zend_ini_parser.y
@@ -3,7 +3,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini_parser.y 272368 2008-12-31 11:13:47Z sebastian $ */
+/* $Id: zend_ini_parser.y 293154 2010-01-05 20:40:23Z sebastian $ */
 
 #define DEBUG_CFG_PARSER 0
 
diff --git a/Zend/zend_ini_scanner.c b/Zend/zend_ini_scanner.c
index b09018e..d05d78a 100644
--- a/Zend/zend_ini_scanner.c
+++ b/Zend/zend_ini_scanner.c
@@ -1,10 +1,10 @@
-/* Generated by re2c 0.13.5 on Fri Aug  7 18:29:12 2009 */
+/* Generated by re2c 0.13.5 on Sun Feb  7 13:25:37 2010 */
 #line 1 "Zend/zend_ini_scanner.l"
 /*
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -22,7 +22,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini_scanner.c 286914 2009-08-07 15:45:56Z jani $ */
+/* $Id: zend_ini_scanner.c 294698 2010-02-07 12:08:22Z pajoye $ */
 
 #include <errno.h>
 #include "zend.h"
@@ -107,6 +107,17 @@ ZEND_API ts_rsrc_id ini_scanner_globals_id;
 ZEND_API zend_ini_scanner_globals ini_scanner_globals;
 #endif
 
+/* Eat leading whitespace */
+#define EAT_LEADING_WHITESPACE()                     \
+	while (yytext[0]) {                              \
+		if (yytext[0] == ' ' || yytext[0] == '\t') { \
+			SCNG(yy_text)++;                         \
+			yyleng--;                                \
+		} else {                                     \
+			break;                                   \
+		}                                            \
+	}
+
 /* Eat trailing whitespace + extra char */
 #define EAT_TRAILING_WHITESPACE_EX(ch)              \
 	while (yyleng > 0 && (                          \
@@ -319,7 +330,7 @@ restart:
 		}
 	}
 
-#line 323 "Zend/zend_ini_scanner.c"
+#line 334 "Zend/zend_ini_scanner.c"
 {
 	YYCTYPE yych;
 	unsigned int yyaccept = 0;
@@ -356,49 +367,49 @@ restart:
 yyc_INITIAL:
 	{
 		static const unsigned char yybm[] = {
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 192,   0, 160, 160,   0, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			192, 128, 128, 160, 128, 160, 128, 160, 
-			128, 128, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 128, 160, 128, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 128, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 128, 128, 128, 128, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
-			160, 160, 160, 160, 160, 160, 160, 160, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 160,   0, 144, 144,   0, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			240, 128, 128, 144, 128, 144, 128, 144, 
+			128, 128, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 128, 144, 128, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 128, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 128, 128, 128, 128, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
+			144, 144, 144, 144, 144, 144, 144, 144, 
 		};
 
 		YYDEBUG(0, *YYCURSOR);
-		YYFILL(6);
+		YYFILL(5);
 		yych = *YYCURSOR;
 		YYDEBUG(-1, yych);
 		switch (yych) {
-		case '\t':
-		case ' ':	goto yy4;
+		case '\t':	goto yy4;
 		case '\n':	goto yy6;
 		case '\r':	goto yy8;
+		case ' ':	goto yy9;
 		case '!':
 		case '"':
 		case '$':
@@ -408,8 +419,8 @@ yyc_INITIAL:
 		case '{':
 		case '|':
 		case '}':
-		case '~':	goto yy9;
-		case '#':	goto yy11;
+		case '~':	goto yy10;
+		case '#':	goto yy12;
 		case '%':
 		case '\'':
 		case '*':
@@ -424,106 +435,136 @@ yyc_INITIAL:
 		case '?':
 		case '@':
 		case ']':
-		case '^':	goto yy12;
-		case ';':	goto yy13;
-		case '=':	goto yy15;
+		case '^':	goto yy13;
+		case ';':	goto yy14;
+		case '=':	goto yy16;
 		case 'F':
-		case 'f':	goto yy17;
+		case 'f':	goto yy18;
 		case 'N':
-		case 'n':	goto yy18;
+		case 'n':	goto yy19;
 		case 'O':
-		case 'o':	goto yy19;
+		case 'o':	goto yy20;
 		case 'T':
-		case 't':	goto yy20;
+		case 't':	goto yy21;
 		case 'Y':
-		case 'y':	goto yy21;
-		case '[':	goto yy22;
+		case 'y':	goto yy22;
+		case '[':	goto yy23;
 		default:	goto yy2;
 		}
 yy2:
 		YYDEBUG(2, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy25;
+		goto yy26;
 yy3:
 		YYDEBUG(3, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 406 "Zend/zend_ini_scanner.l"
+#line 426 "Zend/zend_ini_scanner.l"
 		{ /* Get option name */
+	/* Eat leading whitespace */
+	EAT_LEADING_WHITESPACE();
+
+	/* Eat trailing whitespace */
+	EAT_TRAILING_WHITESPACE();
+
 	RETURN_TOKEN(TC_LABEL, yytext, yyleng);
 }
-#line 456 "Zend/zend_ini_scanner.c"
+#line 473 "Zend/zend_ini_scanner.c"
 yy4:
 		YYDEBUG(4, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy66;
+		goto yy68;
 yy5:
 		YYDEBUG(5, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 518 "Zend/zend_ini_scanner.l"
+#line 544 "Zend/zend_ini_scanner.l"
 		{
 	/* eat whitespace */
 	goto restart;
 }
-#line 470 "Zend/zend_ini_scanner.c"
+#line 487 "Zend/zend_ini_scanner.c"
 yy6:
 		YYDEBUG(6, *YYCURSOR);
 		++YYCURSOR;
 yy7:
 		YYDEBUG(7, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 523 "Zend/zend_ini_scanner.l"
+#line 549 "Zend/zend_ini_scanner.l"
 		{
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 482 "Zend/zend_ini_scanner.c"
+#line 499 "Zend/zend_ini_scanner.c"
 yy8:
 		YYDEBUG(8, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy64;
+		if (yych == '\n') goto yy71;
 		goto yy7;
 yy9:
 		YYDEBUG(9, *YYCURSOR);
-		++YYCURSOR;
+		yyaccept = 1;
+		yych = *(YYMARKER = ++YYCURSOR);
+		if (yych <= ' ') {
+			if (yych <= '\n') {
+				if (yych <= 0x08) goto yy26;
+				if (yych <= '\t') goto yy67;
+				goto yy71;
+			} else {
+				if (yych == '\r') goto yy72;
+				if (yych <= 0x1F) goto yy26;
+				goto yy69;
+			}
+		} else {
+			if (yych <= ':') {
+				if (yych == '#') goto yy58;
+				goto yy26;
+			} else {
+				if (yych <= ';') goto yy53;
+				if (yych == '=') goto yy51;
+				goto yy26;
+			}
+		}
+yy10:
 		YYDEBUG(10, *YYCURSOR);
+		++YYCURSOR;
+		YYDEBUG(11, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 446 "Zend/zend_ini_scanner.l"
+#line 472 "Zend/zend_ini_scanner.l"
 		{ /* Disallow these chars outside option values */
 	return yytext[0];
 }
-#line 497 "Zend/zend_ini_scanner.c"
-yy11:
-		YYDEBUG(11, *YYCURSOR);
-		yyaccept = 1;
-		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy56;
+#line 538 "Zend/zend_ini_scanner.c"
 yy12:
 		YYDEBUG(12, *YYCURSOR);
-		yych = *++YYCURSOR;
-		goto yy25;
+		yyaccept = 1;
+		yych = *(YYMARKER = ++YYCURSOR);
+		goto yy59;
 yy13:
 		YYDEBUG(13, *YYCURSOR);
+		yych = *++YYCURSOR;
+		goto yy26;
+yy14:
+		YYDEBUG(14, *YYCURSOR);
 		yyaccept = 2;
 		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy51;
-		YYDEBUG(14, *YYCURSOR);
+		goto yy54;
+		YYDEBUG(15, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 546 "Zend/zend_ini_scanner.l"
+#line 572 "Zend/zend_ini_scanner.l"
 		{
 	return 0;
 }
-#line 518 "Zend/zend_ini_scanner.c"
-yy15:
-		YYDEBUG(15, *YYCURSOR);
-		++YYCURSOR;
-		yych = *YYCURSOR;
-		goto yy49;
+#line 559 "Zend/zend_ini_scanner.c"
 yy16:
 		YYDEBUG(16, *YYCURSOR);
+		++YYCURSOR;
+		yych = *YYCURSOR;
+		goto yy52;
+yy17:
+		YYDEBUG(17, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 410 "Zend/zend_ini_scanner.l"
+#line 436 "Zend/zend_ini_scanner.l"
 		{ /* Start option value */
 	if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
 		yy_push_state(ST_RAW TSRMLS_CC);
@@ -532,63 +573,63 @@ yy16:
 	}
 	return '=';
 }
-#line 536 "Zend/zend_ini_scanner.c"
-yy17:
-		YYDEBUG(17, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == 'A') goto yy45;
-		if (yych == 'a') goto yy45;
-		goto yy25;
+#line 577 "Zend/zend_ini_scanner.c"
 yy18:
 		YYDEBUG(18, *YYCURSOR);
 		yych = *++YYCURSOR;
+		if (yych == 'A') goto yy48;
+		if (yych == 'a') goto yy48;
+		goto yy26;
+yy19:
+		YYDEBUG(19, *YYCURSOR);
+		yych = *++YYCURSOR;
 		if (yych <= 'U') {
-			if (yych == 'O') goto yy41;
-			if (yych <= 'T') goto yy25;
-			goto yy42;
+			if (yych == 'O') goto yy44;
+			if (yych <= 'T') goto yy26;
+			goto yy45;
 		} else {
 			if (yych <= 'o') {
-				if (yych <= 'n') goto yy25;
-				goto yy41;
+				if (yych <= 'n') goto yy26;
+				goto yy44;
 			} else {
-				if (yych == 'u') goto yy42;
-				goto yy25;
+				if (yych == 'u') goto yy45;
+				goto yy26;
 			}
 		}
-yy19:
-		YYDEBUG(19, *YYCURSOR);
+yy20:
+		YYDEBUG(20, *YYCURSOR);
 		yych = *++YYCURSOR;
 		if (yych <= 'N') {
-			if (yych == 'F') goto yy36;
-			if (yych <= 'M') goto yy25;
-			goto yy30;
+			if (yych == 'F') goto yy38;
+			if (yych <= 'M') goto yy26;
+			goto yy31;
 		} else {
 			if (yych <= 'f') {
-				if (yych <= 'e') goto yy25;
-				goto yy36;
+				if (yych <= 'e') goto yy26;
+				goto yy38;
 			} else {
-				if (yych == 'n') goto yy30;
-				goto yy25;
+				if (yych == 'n') goto yy31;
+				goto yy26;
 			}
 		}
-yy20:
-		YYDEBUG(20, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == 'R') goto yy34;
-		if (yych == 'r') goto yy34;
-		goto yy25;
 yy21:
 		YYDEBUG(21, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == 'E') goto yy26;
-		if (yych == 'e') goto yy26;
-		goto yy25;
+		if (yych == 'R') goto yy36;
+		if (yych == 'r') goto yy36;
+		goto yy26;
 yy22:
 		YYDEBUG(22, *YYCURSOR);
-		++YYCURSOR;
+		yych = *++YYCURSOR;
+		if (yych == 'E') goto yy27;
+		if (yych == 'e') goto yy27;
+		goto yy26;
+yy23:
 		YYDEBUG(23, *YYCURSOR);
+		++YYCURSOR;
+		YYDEBUG(24, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 344 "Zend/zend_ini_scanner.l"
+#line 355 "Zend/zend_ini_scanner.l"
 		{ /* Section start */
 	/* Enter section data lookup state */
 	if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
@@ -598,38 +639,41 @@ yy22:
 	}
 	return TC_SECTION;
 }
-#line 602 "Zend/zend_ini_scanner.c"
-yy24:
-		YYDEBUG(24, *YYCURSOR);
+#line 643 "Zend/zend_ini_scanner.c"
+yy25:
+		YYDEBUG(25, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy25:
-		YYDEBUG(25, *YYCURSOR);
-		if (yybm[0+yych] & 32) {
-			goto yy24;
-		}
-		if (yych == '[') goto yy27;
-		goto yy3;
 yy26:
 		YYDEBUG(26, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == 'S') goto yy30;
-		if (yych == 's') goto yy30;
-		goto yy25;
+		if (yybm[0+yych] & 16) {
+			goto yy25;
+		}
+		if (yych == '[') goto yy28;
+		goto yy3;
 yy27:
 		YYDEBUG(27, *YYCURSOR);
+		yych = *++YYCURSOR;
+		if (yych == 'S') goto yy31;
+		if (yych == 's') goto yy31;
+		goto yy26;
+yy28:
+		YYDEBUG(28, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(28, *YYCURSOR);
-		if (yybm[0+yych] & 64) {
-			goto yy27;
-		}
 		YYDEBUG(29, *YYCURSOR);
+		if (yybm[0+yych] & 32) {
+			goto yy28;
+		}
+		YYDEBUG(30, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 369 "Zend/zend_ini_scanner.l"
+#line 380 "Zend/zend_ini_scanner.l"
 		{ /* Start of option with offset */
+	/* Eat leading whitespace */
+	EAT_LEADING_WHITESPACE();
+	
 	/* Eat trailing whitespace and [ */
 	EAT_TRAILING_WHITESPACE_EX('[');
 
@@ -638,371 +682,431 @@ yy27:
 
 	RETURN_TOKEN(TC_OFFSET, yytext, yyleng);
 }
-#line 642 "Zend/zend_ini_scanner.c"
-yy30:
-		YYDEBUG(30, *YYCURSOR);
+#line 686 "Zend/zend_ini_scanner.c"
+yy31:
+		YYDEBUG(31, *YYCURSOR);
 		++YYCURSOR;
-		if ((yych = *YYCURSOR) <= '$') {
+		YYFILL(1);
+		yych = *YYCURSOR;
+		YYDEBUG(32, *YYCURSOR);
+		if (yybm[0+yych] & 64) {
+			goto yy31;
+		}
+		if (yych <= '&') {
 			if (yych <= '\r') {
 				if (yych <= '\t') {
 					if (yych <= 0x08) goto yy25;
-					goto yy32;
+					goto yy34;
 				} else {
-					if (yych <= '\n') goto yy31;
+					if (yych <= '\n') goto yy33;
 					if (yych <= '\f') goto yy25;
 				}
 			} else {
-				if (yych <= ' ') {
-					if (yych <= 0x1F) goto yy25;
-					goto yy32;
+				if (yych <= '#') {
+					if (yych <= ' ') goto yy25;
+					if (yych >= '#') goto yy25;
 				} else {
-					if (yych == '#') goto yy25;
+					if (yych == '%') goto yy25;
 				}
 			}
 		} else {
-			if (yych <= ':') {
-				if (yych <= '&') {
-					if (yych <= '%') goto yy25;
-				} else {
+			if (yych <= '<') {
+				if (yych <= ')') {
 					if (yych <= '\'') goto yy25;
-					if (yych >= '*') goto yy25;
+				} else {
+					if (yych != ';') goto yy25;
 				}
 			} else {
-				if (yych <= '=') {
-					if (yych == '<') goto yy25;
+				if (yych <= '[') {
+					if (yych <= '=') goto yy33;
+					if (yych <= 'Z') goto yy25;
+					goto yy28;
 				} else {
 					if (yych <= 'z') goto yy25;
 					if (yych >= 0x7F) goto yy25;
 				}
 			}
 		}
-yy31:
-		YYDEBUG(31, *YYCURSOR);
+yy33:
+		YYDEBUG(33, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 398 "Zend/zend_ini_scanner.l"
+#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 687 "Zend/zend_ini_scanner.c"
-yy32:
-		YYDEBUG(32, *YYCURSOR);
+#line 738 "Zend/zend_ini_scanner.c"
+yy34:
+		YYDEBUG(34, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(33, *YYCURSOR);
-		if (yych == '\t') goto yy32;
-		if (yych == ' ') goto yy32;
-		goto yy31;
-yy34:
-		YYDEBUG(34, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == 'U') goto yy35;
-		if (yych != 'u') goto yy25;
-yy35:
 		YYDEBUG(35, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == 'E') goto yy30;
-		if (yych == 'e') goto yy30;
-		goto yy25;
+		if (yych == '\t') goto yy34;
+		if (yych == ' ') goto yy34;
+		goto yy33;
 yy36:
 		YYDEBUG(36, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == 'F') goto yy37;
-		if (yych != 'f') goto yy25;
+		if (yych == 'U') goto yy37;
+		if (yych != 'u') goto yy26;
 yy37:
 		YYDEBUG(37, *YYCURSOR);
+		yych = *++YYCURSOR;
+		if (yych == 'E') goto yy31;
+		if (yych == 'e') goto yy31;
+		goto yy26;
+yy38:
+		YYDEBUG(38, *YYCURSOR);
+		yych = *++YYCURSOR;
+		if (yych == 'F') goto yy39;
+		if (yych != 'f') goto yy26;
+yy39:
+		YYDEBUG(39, *YYCURSOR);
 		++YYCURSOR;
-		if ((yych = *YYCURSOR) <= '$') {
+		YYFILL(1);
+		yych = *YYCURSOR;
+		YYDEBUG(40, *YYCURSOR);
+		if (yych <= '%') {
 			if (yych <= '\r') {
 				if (yych <= '\t') {
 					if (yych <= 0x08) goto yy25;
-					goto yy39;
+					goto yy42;
 				} else {
-					if (yych <= '\n') goto yy38;
+					if (yych <= '\n') goto yy41;
 					if (yych <= '\f') goto yy25;
 				}
 			} else {
-				if (yych <= ' ') {
+				if (yych <= '"') {
 					if (yych <= 0x1F) goto yy25;
-					goto yy39;
+					if (yych <= ' ') goto yy39;
 				} else {
-					if (yych == '#') goto yy25;
+					if (yych != '$') goto yy25;
 				}
 			}
 		} else {
-			if (yych <= ':') {
-				if (yych <= '&') {
-					if (yych <= '%') goto yy25;
+			if (yych <= '<') {
+				if (yych <= ')') {
+					if (yych == '\'') goto yy25;
 				} else {
-					if (yych <= '\'') goto yy25;
-					if (yych >= '*') goto yy25;
+					if (yych != ';') goto yy25;
 				}
 			} else {
-				if (yych <= '=') {
-					if (yych == '<') goto yy25;
+				if (yych <= '[') {
+					if (yych <= '=') goto yy41;
+					if (yych <= 'Z') goto yy25;
+					goto yy28;
 				} else {
 					if (yych <= 'z') goto yy25;
 					if (yych >= 0x7F) goto yy25;
 				}
 			}
 		}
-yy38:
-		YYDEBUG(38, *YYCURSOR);
+yy41:
+		YYDEBUG(41, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 402 "Zend/zend_ini_scanner.l"
+#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 757 "Zend/zend_ini_scanner.c"
-yy39:
-		YYDEBUG(39, *YYCURSOR);
+#line 812 "Zend/zend_ini_scanner.c"
+yy42:
+		YYDEBUG(42, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(40, *YYCURSOR);
-		if (yych == '\t') goto yy39;
-		if (yych == ' ') goto yy39;
-		goto yy38;
-yy41:
-		YYDEBUG(41, *YYCURSOR);
+		YYDEBUG(43, *YYCURSOR);
+		if (yych == '\t') goto yy42;
+		if (yych == ' ') goto yy42;
+		goto yy41;
+yy44:
+		YYDEBUG(44, *YYCURSOR);
 		yych = *++YYCURSOR;
 		if (yych <= '&') {
 			if (yych <= 0x1F) {
 				if (yych <= '\n') {
-					if (yych <= 0x08) goto yy25;
-					if (yych <= '\t') goto yy39;
-					goto yy38;
+					if (yych <= 0x08) goto yy26;
+					if (yych <= '\t') goto yy42;
+					goto yy41;
 				} else {
-					if (yych == '\r') goto yy38;
-					goto yy25;
+					if (yych == '\r') goto yy41;
+					goto yy26;
 				}
 			} else {
 				if (yych <= '#') {
 					if (yych <= ' ') goto yy39;
-					if (yych <= '"') goto yy38;
-					goto yy25;
+					if (yych <= '"') goto yy41;
+					goto yy26;
 				} else {
-					if (yych == '%') goto yy25;
-					goto yy38;
+					if (yych == '%') goto yy26;
+					goto yy41;
 				}
 			}
 		} else {
 			if (yych <= '=') {
 				if (yych <= ':') {
-					if (yych <= '\'') goto yy25;
-					if (yych <= ')') goto yy38;
-					goto yy25;
+					if (yych <= '\'') goto yy26;
+					if (yych <= ')') goto yy41;
+					goto yy26;
 				} else {
-					if (yych == '<') goto yy25;
-					goto yy38;
+					if (yych == '<') goto yy26;
+					goto yy41;
 				}
 			} else {
 				if (yych <= 'm') {
-					if (yych == 'N') goto yy44;
-					goto yy25;
+					if (yych == 'N') goto yy47;
+					goto yy26;
 				} else {
-					if (yych <= 'n') goto yy44;
-					if (yych <= 'z') goto yy25;
-					if (yych <= '~') goto yy38;
-					goto yy25;
+					if (yych <= 'n') goto yy47;
+					if (yych <= 'z') goto yy26;
+					if (yych <= '~') goto yy41;
+					goto yy26;
 				}
 			}
 		}
-yy42:
-		YYDEBUG(42, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == 'L') goto yy43;
-		if (yych != 'l') goto yy25;
-yy43:
-		YYDEBUG(43, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == 'L') goto yy37;
-		if (yych == 'l') goto yy37;
-		goto yy25;
-yy44:
-		YYDEBUG(44, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == 'E') goto yy37;
-		if (yych == 'e') goto yy37;
-		goto yy25;
 yy45:
 		YYDEBUG(45, *YYCURSOR);
 		yych = *++YYCURSOR;
 		if (yych == 'L') goto yy46;
-		if (yych != 'l') goto yy25;
+		if (yych != 'l') goto yy26;
 yy46:
 		YYDEBUG(46, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == 'S') goto yy47;
-		if (yych != 's') goto yy25;
+		if (yych == 'L') goto yy39;
+		if (yych == 'l') goto yy39;
+		goto yy26;
 yy47:
 		YYDEBUG(47, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == 'E') goto yy37;
-		if (yych == 'e') goto yy37;
-		goto yy25;
+		if (yych == 'E') goto yy39;
+		if (yych == 'e') goto yy39;
+		goto yy26;
 yy48:
 		YYDEBUG(48, *YYCURSOR);
-		++YYCURSOR;
-		YYFILL(1);
-		yych = *YYCURSOR;
+		yych = *++YYCURSOR;
+		if (yych == 'L') goto yy49;
+		if (yych != 'l') goto yy26;
 yy49:
 		YYDEBUG(49, *YYCURSOR);
-		if (yych == '\t') goto yy48;
-		if (yych == ' ') goto yy48;
-		goto yy16;
+		yych = *++YYCURSOR;
+		if (yych == 'S') goto yy50;
+		if (yych != 's') goto yy26;
 yy50:
 		YYDEBUG(50, *YYCURSOR);
-		++YYCURSOR;
-		YYFILL(2);
-		yych = *YYCURSOR;
+		yych = *++YYCURSOR;
+		if (yych == 'E') goto yy39;
+		if (yych == 'e') goto yy39;
+		goto yy26;
 yy51:
 		YYDEBUG(51, *YYCURSOR);
-		if (yybm[0+yych] & 128) {
-			goto yy50;
-		}
-		if (yych >= '\r') goto yy54;
+		++YYCURSOR;
+		YYFILL(1);
+		yych = *YYCURSOR;
 yy52:
 		YYDEBUG(52, *YYCURSOR);
-		++YYCURSOR;
+		if (yych == '\t') goto yy51;
+		if (yych == ' ') goto yy51;
+		goto yy17;
 yy53:
 		YYDEBUG(53, *YYCURSOR);
+		++YYCURSOR;
+		YYFILL(2);
+		yych = *YYCURSOR;
+yy54:
+		YYDEBUG(54, *YYCURSOR);
+		if (yybm[0+yych] & 128) {
+			goto yy53;
+		}
+		if (yych >= '\r') goto yy57;
+yy55:
+		YYDEBUG(55, *YYCURSOR);
+		++YYCURSOR;
+yy56:
+		YYDEBUG(56, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 528 "Zend/zend_ini_scanner.l"
+#line 554 "Zend/zend_ini_scanner.l"
 		{ /* Comment */
 	BEGIN(INITIAL);
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 878 "Zend/zend_ini_scanner.c"
-yy54:
-		YYDEBUG(54, *YYCURSOR);
+#line 933 "Zend/zend_ini_scanner.c"
+yy57:
+		YYDEBUG(57, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy52;
-		goto yy53;
-yy55:
-		YYDEBUG(55, *YYCURSOR);
+		if (yych == '\n') goto yy55;
+		goto yy56;
+yy58:
+		YYDEBUG(58, *YYCURSOR);
 		yyaccept = 1;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy56:
-		YYDEBUG(56, *YYCURSOR);
+yy59:
+		YYDEBUG(59, *YYCURSOR);
 		if (yych <= '&') {
 			if (yych <= '\r') {
 				if (yych <= '\t') {
-					if (yych <= 0x08) goto yy55;
+					if (yych <= 0x08) goto yy58;
 				} else {
-					if (yych <= '\n') goto yy61;
-					if (yych <= '\f') goto yy55;
-					goto yy63;
+					if (yych <= '\n') goto yy64;
+					if (yych <= '\f') goto yy58;
+					goto yy66;
 				}
 			} else {
 				if (yych <= '#') {
-					if (yych <= 0x1F) goto yy55;
-					if (yych >= '#') goto yy55;
+					if (yych <= ' ') goto yy58;
+					if (yych >= '#') goto yy58;
 				} else {
-					if (yych == '%') goto yy55;
+					if (yych == '%') goto yy58;
 				}
 			}
 		} else {
 			if (yych <= '<') {
 				if (yych <= ')') {
-					if (yych <= '\'') goto yy55;
+					if (yych <= '\'') goto yy58;
 				} else {
-					if (yych != ';') goto yy55;
+					if (yych != ';') goto yy58;
 				}
 			} else {
 				if (yych <= '[') {
-					if (yych <= '=') goto yy57;
-					if (yych <= 'Z') goto yy55;
-					goto yy59;
+					if (yych <= '=') goto yy60;
+					if (yych <= 'Z') goto yy58;
+					goto yy62;
 				} else {
-					if (yych <= 'z') goto yy55;
-					if (yych >= 0x7F) goto yy55;
+					if (yych <= 'z') goto yy58;
+					if (yych >= 0x7F) goto yy58;
 				}
 			}
 		}
-yy57:
-		YYDEBUG(57, *YYCURSOR);
+yy60:
+		YYDEBUG(60, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-		YYDEBUG(58, *YYCURSOR);
-		if (yych == '\n') goto yy61;
-		if (yych == '\r') goto yy63;
-		goto yy57;
-yy59:
-		YYDEBUG(59, *YYCURSOR);
+		YYDEBUG(61, *YYCURSOR);
+		if (yych == '\n') goto yy64;
+		if (yych == '\r') goto yy66;
+		goto yy60;
+yy62:
+		YYDEBUG(62, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-		YYDEBUG(60, *YYCURSOR);
+		YYDEBUG(63, *YYCURSOR);
 		if (yych <= '\f') {
-			if (yych <= 0x08) goto yy57;
-			if (yych <= '\t') goto yy59;
-			if (yych >= '\v') goto yy57;
+			if (yych <= 0x08) goto yy60;
+			if (yych <= '\t') goto yy62;
+			if (yych >= '\v') goto yy60;
 		} else {
-			if (yych <= '\r') goto yy63;
-			if (yych == ' ') goto yy59;
-			goto yy57;
+			if (yych <= '\r') goto yy66;
+			if (yych == ' ') goto yy62;
+			goto yy60;
 		}
-yy61:
-		YYDEBUG(61, *YYCURSOR);
+yy64:
+		YYDEBUG(64, *YYCURSOR);
 		++YYCURSOR;
-yy62:
-		YYDEBUG(62, *YYCURSOR);
+yy65:
+		YYDEBUG(65, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 534 "Zend/zend_ini_scanner.l"
+#line 560 "Zend/zend_ini_scanner.l"
 		{ /* #Comment */
 	zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", zend_ini_scanner_get_filename(TSRMLS_C), SCNG(lineno));
 	BEGIN(INITIAL);
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 965 "Zend/zend_ini_scanner.c"
-yy63:
-		YYDEBUG(63, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy61;
-		goto yy62;
-yy64:
-		YYDEBUG(64, *YYCURSOR);
+#line 1020 "Zend/zend_ini_scanner.c"
+yy66:
+		YYDEBUG(66, *YYCURSOR);
 		yych = *++YYCURSOR;
-		goto yy7;
-yy65:
-		YYDEBUG(65, *YYCURSOR);
+		if (yych == '\n') goto yy64;
+		goto yy65;
+yy67:
+		YYDEBUG(67, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy66:
-		YYDEBUG(66, *YYCURSOR);
+yy68:
+		YYDEBUG(68, *YYCURSOR);
 		if (yych <= ' ') {
 			if (yych <= '\n') {
 				if (yych <= 0x08) goto yy5;
-				if (yych <= '\t') goto yy65;
-				goto yy64;
+				if (yych <= '\t') goto yy67;
+				goto yy71;
 			} else {
-				if (yych == '\r') goto yy67;
+				if (yych == '\r') goto yy72;
 				if (yych <= 0x1F) goto yy5;
-				goto yy65;
+				goto yy67;
 			}
 		} else {
 			if (yych <= ':') {
-				if (yych == '#') goto yy57;
+				if (yych == '#') goto yy60;
 				goto yy5;
 			} else {
-				if (yych <= ';') goto yy50;
-				if (yych == '=') goto yy48;
+				if (yych <= ';') goto yy53;
+				if (yych == '=') goto yy51;
 				goto yy5;
 			}
 		}
-yy67:
-		YYDEBUG(67, *YYCURSOR);
+yy69:
+		YYDEBUG(69, *YYCURSOR);
+		yyaccept = 1;
+		YYMARKER = ++YYCURSOR;
+		YYFILL(2);
+		yych = *YYCURSOR;
+		YYDEBUG(70, *YYCURSOR);
+		if (yych <= '%') {
+			if (yych <= '\r') {
+				if (yych <= '\t') {
+					if (yych <= 0x08) goto yy25;
+					goto yy67;
+				} else {
+					if (yych <= '\n') goto yy71;
+					if (yych <= '\f') goto yy25;
+					goto yy72;
+				}
+			} else {
+				if (yych <= '"') {
+					if (yych <= 0x1F) goto yy25;
+					if (yych <= ' ') goto yy69;
+					goto yy3;
+				} else {
+					if (yych <= '#') goto yy58;
+					if (yych <= '$') goto yy3;
+					goto yy25;
+				}
+			}
+		} else {
+			if (yych <= '<') {
+				if (yych <= ')') {
+					if (yych == '\'') goto yy25;
+					goto yy3;
+				} else {
+					if (yych == ';') goto yy53;
+					goto yy25;
+				}
+			} else {
+				if (yych <= '[') {
+					if (yych <= '=') goto yy51;
+					if (yych <= 'Z') goto yy25;
+					goto yy28;
+				} else {
+					if (yych <= 'z') goto yy25;
+					if (yych <= '~') goto yy3;
+					goto yy25;
+				}
+			}
+		}
+yy71:
+		YYDEBUG(71, *YYCURSOR);
+		yych = *++YYCURSOR;
+		goto yy7;
+yy72:
+		YYDEBUG(72, *YYCURSOR);
 		++YYCURSOR;
-		if ((yych = *YYCURSOR) == '\n') goto yy64;
+		if ((yych = *YYCURSOR) == '\n') goto yy71;
 		goto yy7;
 	}
 /* *********************************** */
@@ -1042,17 +1146,17 @@ yyc_ST_DOUBLE_QUOTES:
 			  0,   0,   0,   0,   0,   0,   0,   0, 
 			  0,   0,   0,   0,   0,   0,   0,   0, 
 		};
-		YYDEBUG(68, *YYCURSOR);
+		YYDEBUG(73, *YYCURSOR);
 		YYFILL(2);
 		yych = *YYCURSOR;
-		if (yych == '"') goto yy72;
-		if (yych == '$') goto yy74;
-		YYDEBUG(70, *YYCURSOR);
+		if (yych == '"') goto yy77;
+		if (yych == '$') goto yy79;
+		YYDEBUG(75, *YYCURSOR);
 		++YYCURSOR;
-yy71:
-		YYDEBUG(71, *YYCURSOR);
+yy76:
+		YYDEBUG(76, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 478 "Zend/zend_ini_scanner.l"
+#line 504 "Zend/zend_ini_scanner.l"
 		{ /* Escape double quoted string contents */
 	if (YYCURSOR > YYLIMIT) {
 		return 0;
@@ -1088,46 +1192,46 @@ yy71:
 	zend_ini_escape_string(ini_lval, yytext, yyleng, '"' TSRMLS_CC);
 	return TC_QUOTED_STRING;
 }
-#line 1092 "Zend/zend_ini_scanner.c"
-yy72:
-		YYDEBUG(72, *YYCURSOR);
+#line 1196 "Zend/zend_ini_scanner.c"
+yy77:
+		YYDEBUG(77, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy78;
-yy73:
-		YYDEBUG(73, *YYCURSOR);
+		goto yy83;
+yy78:
+		YYDEBUG(78, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 473 "Zend/zend_ini_scanner.l"
+#line 499 "Zend/zend_ini_scanner.l"
 		{ /* Double quoted '"' string ends */
 	yy_pop_state(TSRMLS_C);
 	return '"';
 }
-#line 1106 "Zend/zend_ini_scanner.c"
-yy74:
-		YYDEBUG(74, *YYCURSOR);
+#line 1210 "Zend/zend_ini_scanner.c"
+yy79:
+		YYDEBUG(79, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych != '{') goto yy71;
-		YYDEBUG(75, *YYCURSOR);
+		if (yych != '{') goto yy76;
+		YYDEBUG(80, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(76, *YYCURSOR);
+		YYDEBUG(81, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 384 "Zend/zend_ini_scanner.l"
+#line 398 "Zend/zend_ini_scanner.l"
 		{ /* Variable start */
 	yy_push_state(ST_VARNAME TSRMLS_CC);
 	return TC_DOLLAR_CURLY;
 }
-#line 1120 "Zend/zend_ini_scanner.c"
-yy77:
-		YYDEBUG(77, *YYCURSOR);
+#line 1224 "Zend/zend_ini_scanner.c"
+yy82:
+		YYDEBUG(82, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy78:
-		YYDEBUG(78, *YYCURSOR);
+yy83:
+		YYDEBUG(83, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy77;
+			goto yy82;
 		}
-		goto yy73;
+		goto yy78;
 	}
 /* *********************************** */
 yyc_ST_OFFSET:
@@ -1166,495 +1270,496 @@ yyc_ST_OFFSET:
 			 66,  66,  66,  66,  66,  66,  66,  66, 
 			 66,  66,  66,  66,  66,  66,  66,  66, 
 		};
-		YYDEBUG(79, *YYCURSOR);
+		YYDEBUG(84, *YYCURSOR);
 		YYFILL(2);
 		yych = *YYCURSOR;
-		if (yych <= ',') {
+		if (yych <= '-') {
 			if (yych <= ' ') {
 				if (yych <= '\n') {
-					if (yych <= 0x08) goto yy81;
-					if (yych <= '\t') goto yy83;
-					goto yy84;
+					if (yych <= 0x08) goto yy86;
+					if (yych <= '\t') goto yy88;
+					goto yy89;
 				} else {
-					if (yych == '\r') goto yy84;
-					if (yych >= ' ') goto yy83;
+					if (yych == '\r') goto yy89;
+					if (yych >= ' ') goto yy88;
 				}
 			} else {
-				if (yych <= '#') {
-					if (yych == '"') goto yy86;
+				if (yych <= '$') {
+					if (yych == '"') goto yy91;
+					if (yych >= '$') goto yy93;
 				} else {
-					if (yych <= '$') goto yy88;
-					if (yych == '\'') goto yy89;
+					if (yych == '\'') goto yy94;
+					if (yych >= '-') goto yy95;
 				}
 			}
 		} else {
-			if (yych <= '@') {
-				if (yych <= '/') {
-					if (yych <= '-') goto yy90;
-					if (yych <= '.') goto yy91;
+			if (yych <= 'Z') {
+				if (yych <= '9') {
+					if (yych <= '.') goto yy96;
+					if (yych >= '0') goto yy97;
 				} else {
-					if (yych <= '9') goto yy92;
-					if (yych == ';') goto yy84;
+					if (yych == ';') goto yy89;
+					if (yych >= 'A') goto yy99;
 				}
 			} else {
-				if (yych <= '\\') {
-					if (yych <= 'Z') goto yy94;
-					if (yych >= '\\') goto yy96;
+				if (yych <= '^') {
+					if (yych <= '[') goto yy86;
+					if (yych <= '\\') goto yy101;
+					if (yych <= ']') goto yy102;
 				} else {
-					if (yych <= ']') goto yy97;
-					if (yych <= '`') goto yy81;
-					if (yych <= 'z') goto yy94;
+					if (yych == '`') goto yy86;
+					if (yych <= 'z') goto yy99;
 				}
 			}
 		}
-yy81:
-		YYDEBUG(81, *YYCURSOR);
+yy86:
+		YYDEBUG(86, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy100;
-yy82:
-		YYDEBUG(82, *YYCURSOR);
+		goto yy105;
+yy87:
+		YYDEBUG(87, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 464 "Zend/zend_ini_scanner.l"
+#line 490 "Zend/zend_ini_scanner.l"
 		{ /* Get rest as section/offset value */
 	RETURN_TOKEN(TC_STRING, yytext, yyleng);
 }
-#line 1223 "Zend/zend_ini_scanner.c"
-yy83:
-		YYDEBUG(83, *YYCURSOR);
+#line 1328 "Zend/zend_ini_scanner.c"
+yy88:
+		YYDEBUG(88, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy126;
+			goto yy131;
 		}
-		if (yych == '"') goto yy128;
-		if (yych == ']') goto yy129;
-		goto yy100;
-yy84:
-		YYDEBUG(84, *YYCURSOR);
+		if (yych == '"') goto yy133;
+		if (yych == ']') goto yy134;
+		goto yy105;
+yy89:
+		YYDEBUG(89, *YYCURSOR);
 		++YYCURSOR;
-yy85:
-		YYDEBUG(85, *YYCURSOR);
+yy90:
+		YYDEBUG(90, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 546 "Zend/zend_ini_scanner.l"
+#line 572 "Zend/zend_ini_scanner.l"
 		{
 	return 0;
 }
-#line 1244 "Zend/zend_ini_scanner.c"
-yy86:
-		YYDEBUG(86, *YYCURSOR);
+#line 1349 "Zend/zend_ini_scanner.c"
+yy91:
+		YYDEBUG(91, *YYCURSOR);
 		++YYCURSOR;
-yy87:
-		YYDEBUG(87, *YYCURSOR);
+yy92:
+		YYDEBUG(92, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 468 "Zend/zend_ini_scanner.l"
+#line 494 "Zend/zend_ini_scanner.l"
 		{ /* Double quoted '"' string start */
 	yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC);
 	return '"';
 }
-#line 1256 "Zend/zend_ini_scanner.c"
-yy88:
-		YYDEBUG(88, *YYCURSOR);
+#line 1361 "Zend/zend_ini_scanner.c"
+yy93:
+		YYDEBUG(93, *YYCURSOR);
 		yych = *++YYCURSOR;
 		if (yych <= '\\') {
-			if (yych <= 0x00) goto yy85;
-			if (yych <= '[') goto yy99;
-			goto yy104;
+			if (yych <= 0x00) goto yy90;
+			if (yych <= '[') goto yy104;
+			goto yy109;
 		} else {
-			if (yych == '{') goto yy124;
-			goto yy99;
+			if (yych == '{') goto yy129;
+			goto yy104;
 		}
-yy89:
-		YYDEBUG(89, *YYCURSOR);
+yy94:
+		YYDEBUG(94, *YYCURSOR);
 		yyaccept = 1;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy120;
+			goto yy125;
 		}
-		goto yy85;
-yy90:
-		YYDEBUG(90, *YYCURSOR);
+		goto yy90;
+yy95:
+		YYDEBUG(95, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		if (yych <= '/') goto yy100;
-		if (yych <= '9') goto yy118;
-		goto yy100;
-yy91:
-		YYDEBUG(91, *YYCURSOR);
+		if (yych <= '/') goto yy105;
+		if (yych <= '9') goto yy123;
+		goto yy105;
+yy96:
+		YYDEBUG(96, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		if (yych <= '/') goto yy100;
-		if (yych <= '9') goto yy116;
-		goto yy100;
-yy92:
-		YYDEBUG(92, *YYCURSOR);
+		if (yych <= '/') goto yy105;
+		if (yych <= '9') goto yy121;
+		goto yy105;
+yy97:
+		YYDEBUG(97, *YYCURSOR);
 		yyaccept = 2;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '\'') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy93;
-				if (yych <= '\f') goto yy100;
+				if (yych == '\n') goto yy98;
+				if (yych <= '\f') goto yy105;
 			} else {
-				if (yych == '"') goto yy93;
-				if (yych <= '&') goto yy100;
+				if (yych == '"') goto yy98;
+				if (yych <= '&') goto yy105;
 			}
 		} else {
 			if (yych <= '9') {
-				if (yych == '.') goto yy112;
-				if (yych <= '/') goto yy100;
-				goto yy114;
+				if (yych == '.') goto yy117;
+				if (yych <= '/') goto yy105;
+				goto yy119;
 			} else {
 				if (yych <= ';') {
-					if (yych <= ':') goto yy100;
+					if (yych <= ':') goto yy105;
 				} else {
-					if (yych != ']') goto yy100;
+					if (yych != ']') goto yy105;
 				}
 			}
 		}
-yy93:
-		YYDEBUG(93, *YYCURSOR);
+yy98:
+		YYDEBUG(98, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 442 "Zend/zend_ini_scanner.l"
+#line 468 "Zend/zend_ini_scanner.l"
 		{ /* Get number option value as string */
 	RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
 }
-#line 1322 "Zend/zend_ini_scanner.c"
-yy94:
-		YYDEBUG(94, *YYCURSOR);
+#line 1427 "Zend/zend_ini_scanner.c"
+yy99:
+		YYDEBUG(99, *YYCURSOR);
 		yyaccept = 3;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 16) {
-			goto yy110;
+			goto yy115;
 		}
 		if (yych <= '"') {
 			if (yych <= '\f') {
-				if (yych != '\n') goto yy100;
+				if (yych != '\n') goto yy105;
 			} else {
-				if (yych <= '\r') goto yy95;
-				if (yych <= '!') goto yy100;
+				if (yych <= '\r') goto yy100;
+				if (yych <= '!') goto yy105;
 			}
 		} else {
 			if (yych <= ':') {
-				if (yych != '\'') goto yy100;
+				if (yych != '\'') goto yy105;
 			} else {
-				if (yych <= ';') goto yy95;
-				if (yych != ']') goto yy100;
+				if (yych <= ';') goto yy100;
+				if (yych != ']') goto yy105;
 			}
 		}
-yy95:
-		YYDEBUG(95, *YYCURSOR);
+yy100:
+		YYDEBUG(100, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 438 "Zend/zend_ini_scanner.l"
+#line 464 "Zend/zend_ini_scanner.l"
 		{ /* Get constant option value */
 	RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
 }
-#line 1352 "Zend/zend_ini_scanner.c"
-yy96:
-		YYDEBUG(96, *YYCURSOR);
+#line 1457 "Zend/zend_ini_scanner.c"
+yy101:
+		YYDEBUG(101, *YYCURSOR);
 		yych = *++YYCURSOR;
-		goto yy99;
-yy97:
-		YYDEBUG(97, *YYCURSOR);
+		goto yy104;
+yy102:
+		YYDEBUG(102, *YYCURSOR);
 		++YYCURSOR;
-yy98:
-		YYDEBUG(98, *YYCURSOR);
+yy103:
+		YYDEBUG(103, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 379 "Zend/zend_ini_scanner.l"
+#line 393 "Zend/zend_ini_scanner.l"
 		{ /* End of section or an option offset */
 	BEGIN(INITIAL);
 	return ']';
 }
-#line 1368 "Zend/zend_ini_scanner.c"
-yy99:
-		YYDEBUG(99, *YYCURSOR);
+#line 1473 "Zend/zend_ini_scanner.c"
+yy104:
+		YYDEBUG(104, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy100:
-		YYDEBUG(100, *YYCURSOR);
+yy105:
+		YYDEBUG(105, *YYCURSOR);
 		if (yybm[0+yych] & 2) {
-			goto yy99;
+			goto yy104;
 		}
-		if (yych == '$') goto yy102;
-		if (yych != '\\') goto yy82;
-yy101:
-		YYDEBUG(101, *YYCURSOR);
+		if (yych == '$') goto yy107;
+		if (yych != '\\') goto yy87;
+yy106:
+		YYDEBUG(106, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		goto yy99;
-yy102:
-		YYDEBUG(102, *YYCURSOR);
+		goto yy104;
+yy107:
+		YYDEBUG(107, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yych <= '\\') {
-			if (yych <= 0x00) goto yy103;
-			if (yych <= '[') goto yy99;
-			goto yy104;
+			if (yych <= 0x00) goto yy108;
+			if (yych <= '[') goto yy104;
+			goto yy109;
 		} else {
-			if (yych != '{') goto yy99;
+			if (yych != '{') goto yy104;
 		}
-yy103:
-		YYDEBUG(103, *YYCURSOR);
+yy108:
+		YYDEBUG(108, *YYCURSOR);
 		YYCURSOR = YYMARKER;
 		if (yyaccept <= 1) {
 			if (yyaccept <= 0) {
-				goto yy82;
+				goto yy87;
 			} else {
-				goto yy85;
+				goto yy90;
 			}
 		} else {
 			if (yyaccept <= 2) {
-				goto yy93;
+				goto yy98;
 			} else {
-				goto yy95;
+				goto yy100;
 			}
 		}
-yy104:
-		YYDEBUG(104, *YYCURSOR);
+yy109:
+		YYDEBUG(109, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yybm[0+yych] & 4) {
-			goto yy105;
+			goto yy110;
 		}
-		if (yych == '\\') goto yy107;
-		goto yy99;
-yy105:
-		YYDEBUG(105, *YYCURSOR);
+		if (yych == '\\') goto yy112;
+		goto yy104;
+yy110:
+		YYDEBUG(110, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(106, *YYCURSOR);
+		YYDEBUG(111, *YYCURSOR);
 		if (yybm[0+yych] & 4) {
-			goto yy105;
+			goto yy110;
 		}
-		if (yych == '\\') goto yy109;
-		goto yy99;
-yy107:
-		YYDEBUG(107, *YYCURSOR);
+		if (yych == '\\') goto yy114;
+		goto yy104;
+yy112:
+		YYDEBUG(112, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(108, *YYCURSOR);
+		YYDEBUG(113, *YYCURSOR);
 		if (yybm[0+yych] & 4) {
-			goto yy105;
+			goto yy110;
 		}
-		if (yych == '\\') goto yy107;
-		goto yy99;
-yy109:
-		YYDEBUG(109, *YYCURSOR);
+		if (yych == '\\') goto yy112;
+		goto yy104;
+yy114:
+		YYDEBUG(114, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yybm[0+yych] & 4) {
-			goto yy105;
+			goto yy110;
 		}
-		if (yych == '\\') goto yy107;
-		goto yy99;
-yy110:
-		YYDEBUG(110, *YYCURSOR);
+		if (yych == '\\') goto yy112;
+		goto yy104;
+yy115:
+		YYDEBUG(115, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(111, *YYCURSOR);
+		YYDEBUG(116, *YYCURSOR);
 		if (yybm[0+yych] & 16) {
-			goto yy110;
+			goto yy115;
 		}
 		if (yych <= '$') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy95;
-				if (yych <= '\f') goto yy99;
-				goto yy95;
+				if (yych == '\n') goto yy100;
+				if (yych <= '\f') goto yy104;
+				goto yy100;
 			} else {
-				if (yych == '"') goto yy95;
-				if (yych <= '#') goto yy99;
-				goto yy102;
+				if (yych == '"') goto yy100;
+				if (yych <= '#') goto yy104;
+				goto yy107;
 			}
 		} else {
 			if (yych <= ';') {
-				if (yych == '\'') goto yy95;
-				if (yych <= ':') goto yy99;
-				goto yy95;
+				if (yych == '\'') goto yy100;
+				if (yych <= ':') goto yy104;
+				goto yy100;
 			} else {
-				if (yych <= '[') goto yy99;
-				if (yych <= '\\') goto yy101;
-				if (yych <= ']') goto yy95;
-				goto yy99;
+				if (yych <= '[') goto yy104;
+				if (yych <= '\\') goto yy106;
+				if (yych <= ']') goto yy100;
+				goto yy104;
 			}
 		}
-yy112:
-		YYDEBUG(112, *YYCURSOR);
+yy117:
+		YYDEBUG(117, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(113, *YYCURSOR);
+		YYDEBUG(118, *YYCURSOR);
 		if (yybm[0+yych] & 32) {
-			goto yy112;
+			goto yy117;
 		}
 		if (yych <= '$') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy93;
-				if (yych <= '\f') goto yy99;
-				goto yy93;
+				if (yych == '\n') goto yy98;
+				if (yych <= '\f') goto yy104;
+				goto yy98;
 			} else {
-				if (yych == '"') goto yy93;
-				if (yych <= '#') goto yy99;
-				goto yy102;
+				if (yych == '"') goto yy98;
+				if (yych <= '#') goto yy104;
+				goto yy107;
 			}
 		} else {
 			if (yych <= ';') {
-				if (yych == '\'') goto yy93;
-				if (yych <= ':') goto yy99;
-				goto yy93;
+				if (yych == '\'') goto yy98;
+				if (yych <= ':') goto yy104;
+				goto yy98;
 			} else {
-				if (yych <= '[') goto yy99;
-				if (yych <= '\\') goto yy101;
-				if (yych <= ']') goto yy93;
-				goto yy99;
+				if (yych <= '[') goto yy104;
+				if (yych <= '\\') goto yy106;
+				if (yych <= ']') goto yy98;
+				goto yy104;
 			}
 		}
-yy114:
-		YYDEBUG(114, *YYCURSOR);
+yy119:
+		YYDEBUG(119, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(115, *YYCURSOR);
+		YYDEBUG(120, *YYCURSOR);
 		if (yych <= '\'') {
 			if (yych <= '!') {
 				if (yych <= '\n') {
-					if (yych <= '\t') goto yy99;
-					goto yy93;
+					if (yych <= '\t') goto yy104;
+					goto yy98;
 				} else {
-					if (yych == '\r') goto yy93;
-					goto yy99;
+					if (yych == '\r') goto yy98;
+					goto yy104;
 				}
 			} else {
 				if (yych <= '#') {
-					if (yych <= '"') goto yy93;
-					goto yy99;
+					if (yych <= '"') goto yy98;
+					goto yy104;
 				} else {
-					if (yych <= '$') goto yy102;
-					if (yych <= '&') goto yy99;
-					goto yy93;
+					if (yych <= '$') goto yy107;
+					if (yych <= '&') goto yy104;
+					goto yy98;
 				}
 			}
 		} else {
 			if (yych <= ':') {
 				if (yych <= '.') {
-					if (yych <= '-') goto yy99;
-					goto yy112;
+					if (yych <= '-') goto yy104;
+					goto yy117;
 				} else {
-					if (yych <= '/') goto yy99;
-					if (yych <= '9') goto yy114;
-					goto yy99;
+					if (yych <= '/') goto yy104;
+					if (yych <= '9') goto yy119;
+					goto yy104;
 				}
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy93;
-					goto yy99;
+					if (yych <= ';') goto yy98;
+					goto yy104;
 				} else {
-					if (yych <= '\\') goto yy101;
-					if (yych <= ']') goto yy93;
-					goto yy99;
+					if (yych <= '\\') goto yy106;
+					if (yych <= ']') goto yy98;
+					goto yy104;
 				}
 			}
 		}
-yy116:
-		YYDEBUG(116, *YYCURSOR);
+yy121:
+		YYDEBUG(121, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(117, *YYCURSOR);
+		YYDEBUG(122, *YYCURSOR);
 		if (yych <= '&') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy93;
-				if (yych <= '\f') goto yy99;
-				goto yy93;
+				if (yych == '\n') goto yy98;
+				if (yych <= '\f') goto yy104;
+				goto yy98;
 			} else {
 				if (yych <= '"') {
-					if (yych <= '!') goto yy99;
-					goto yy93;
+					if (yych <= '!') goto yy104;
+					goto yy98;
 				} else {
-					if (yych == '$') goto yy102;
-					goto yy99;
+					if (yych == '$') goto yy107;
+					goto yy104;
 				}
 			}
 		} else {
 			if (yych <= ':') {
-				if (yych <= '\'') goto yy93;
-				if (yych <= '/') goto yy99;
-				if (yych <= '9') goto yy116;
-				goto yy99;
+				if (yych <= '\'') goto yy98;
+				if (yych <= '/') goto yy104;
+				if (yych <= '9') goto yy121;
+				goto yy104;
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy93;
-					goto yy99;
+					if (yych <= ';') goto yy98;
+					goto yy104;
 				} else {
-					if (yych <= '\\') goto yy101;
-					if (yych <= ']') goto yy93;
-					goto yy99;
+					if (yych <= '\\') goto yy106;
+					if (yych <= ']') goto yy98;
+					goto yy104;
 				}
 			}
 		}
-yy118:
-		YYDEBUG(118, *YYCURSOR);
+yy123:
+		YYDEBUG(123, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(119, *YYCURSOR);
+		YYDEBUG(124, *YYCURSOR);
 		if (yych <= '&') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy93;
-				if (yych <= '\f') goto yy99;
-				goto yy93;
+				if (yych == '\n') goto yy98;
+				if (yych <= '\f') goto yy104;
+				goto yy98;
 			} else {
 				if (yych <= '"') {
-					if (yych <= '!') goto yy99;
-					goto yy93;
+					if (yych <= '!') goto yy104;
+					goto yy98;
 				} else {
-					if (yych == '$') goto yy102;
-					goto yy99;
+					if (yych == '$') goto yy107;
+					goto yy104;
 				}
 			}
 		} else {
 			if (yych <= ':') {
-				if (yych <= '\'') goto yy93;
-				if (yych <= '/') goto yy99;
-				if (yych <= '9') goto yy118;
-				goto yy99;
+				if (yych <= '\'') goto yy98;
+				if (yych <= '/') goto yy104;
+				if (yych <= '9') goto yy123;
+				goto yy104;
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy93;
-					goto yy99;
+					if (yych <= ';') goto yy98;
+					goto yy104;
 				} else {
-					if (yych <= '\\') goto yy101;
-					if (yych <= ']') goto yy93;
-					goto yy99;
+					if (yych <= '\\') goto yy106;
+					if (yych <= ']') goto yy98;
+					goto yy104;
 				}
 			}
 		}
-yy120:
-		YYDEBUG(120, *YYCURSOR);
+yy125:
+		YYDEBUG(125, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(121, *YYCURSOR);
+		YYDEBUG(126, *YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy120;
+			goto yy125;
 		}
-		YYDEBUG(122, *YYCURSOR);
+		YYDEBUG(127, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(123, *YYCURSOR);
+		YYDEBUG(128, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 354 "Zend/zend_ini_scanner.l"
+#line 365 "Zend/zend_ini_scanner.l"
 		{ /* Raw string */
 	/* Eat leading and trailing single quotes */
 	if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
@@ -1663,59 +1768,59 @@ yy120:
 	}
 	RETURN_TOKEN(TC_RAW, yytext, yyleng);
 }
-#line 1667 "Zend/zend_ini_scanner.c"
-yy124:
-		YYDEBUG(124, *YYCURSOR);
+#line 1772 "Zend/zend_ini_scanner.c"
+yy129:
+		YYDEBUG(129, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(125, *YYCURSOR);
+		YYDEBUG(130, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 384 "Zend/zend_ini_scanner.l"
+#line 398 "Zend/zend_ini_scanner.l"
 		{ /* Variable start */
 	yy_push_state(ST_VARNAME TSRMLS_CC);
 	return TC_DOLLAR_CURLY;
 }
-#line 1678 "Zend/zend_ini_scanner.c"
-yy126:
-		YYDEBUG(126, *YYCURSOR);
+#line 1783 "Zend/zend_ini_scanner.c"
+yy131:
+		YYDEBUG(131, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(127, *YYCURSOR);
+		YYDEBUG(132, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy126;
+			goto yy131;
 		}
 		if (yych <= '$') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy82;
-				if (yych <= '\f') goto yy99;
-				goto yy82;
+				if (yych == '\n') goto yy87;
+				if (yych <= '\f') goto yy104;
+				goto yy87;
 			} else {
-				if (yych == '"') goto yy128;
-				if (yych <= '#') goto yy99;
-				goto yy102;
+				if (yych == '"') goto yy133;
+				if (yych <= '#') goto yy104;
+				goto yy107;
 			}
 		} else {
 			if (yych <= ';') {
-				if (yych == '\'') goto yy82;
-				if (yych <= ':') goto yy99;
-				goto yy82;
+				if (yych == '\'') goto yy87;
+				if (yych <= ':') goto yy104;
+				goto yy87;
 			} else {
-				if (yych <= '[') goto yy99;
-				if (yych <= '\\') goto yy101;
-				if (yych <= ']') goto yy129;
-				goto yy99;
+				if (yych <= '[') goto yy104;
+				if (yych <= '\\') goto yy106;
+				if (yych <= ']') goto yy134;
+				goto yy104;
 			}
 		}
-yy128:
-		YYDEBUG(128, *YYCURSOR);
+yy133:
+		YYDEBUG(133, *YYCURSOR);
 		yych = *++YYCURSOR;
-		goto yy87;
-yy129:
-		YYDEBUG(129, *YYCURSOR);
+		goto yy92;
+yy134:
+		YYDEBUG(134, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy98;
+		goto yy103;
 	}
 /* *********************************** */
 yyc_ST_RAW:
@@ -1754,31 +1859,31 @@ yyc_ST_RAW:
 			160, 160, 160, 160, 160, 160, 160, 160, 
 			160, 160, 160, 160, 160, 160, 160, 160, 
 		};
-		YYDEBUG(130, *YYCURSOR);
+		YYDEBUG(135, *YYCURSOR);
 		YYFILL(3);
 		yych = *YYCURSOR;
 		if (yych <= '\r') {
 			if (yych <= '\t') {
-				if (yych >= '\t') goto yy134;
+				if (yych >= '\t') goto yy139;
 			} else {
-				if (yych <= '\n') goto yy135;
-				if (yych >= '\r') goto yy137;
+				if (yych <= '\n') goto yy140;
+				if (yych >= '\r') goto yy142;
 			}
 		} else {
 			if (yych <= ' ') {
-				if (yych >= ' ') goto yy134;
+				if (yych >= ' ') goto yy139;
 			} else {
-				if (yych == ';') goto yy138;
+				if (yych == ';') goto yy143;
 			}
 		}
-		YYDEBUG(132, *YYCURSOR);
+		YYDEBUG(137, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy150;
-yy133:
-		YYDEBUG(133, *YYCURSOR);
+		goto yy155;
+yy138:
+		YYDEBUG(138, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 419 "Zend/zend_ini_scanner.l"
+#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 */
 	if (yytext[0] == '"' && yytext[yyleng - 1] == '"') {
@@ -1787,120 +1892,120 @@ yy133:
 	}
 	RETURN_TOKEN(TC_RAW, yytext, yyleng);
 }
-#line 1791 "Zend/zend_ini_scanner.c"
-yy134:
-		YYDEBUG(134, *YYCURSOR);
+#line 1896 "Zend/zend_ini_scanner.c"
+yy139:
+		YYDEBUG(139, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy146;
+			goto yy151;
 		}
 		if (yych <= '\f') {
-			if (yych == '\n') goto yy145;
-			goto yy149;
+			if (yych == '\n') goto yy150;
+			goto yy154;
 		} else {
-			if (yych <= '\r') goto yy148;
-			if (yych == ';') goto yy140;
-			goto yy149;
+			if (yych <= '\r') goto yy153;
+			if (yych == ';') goto yy145;
+			goto yy154;
 		}
-yy135:
-		YYDEBUG(135, *YYCURSOR);
+yy140:
+		YYDEBUG(140, *YYCURSOR);
 		++YYCURSOR;
-yy136:
-		YYDEBUG(136, *YYCURSOR);
+yy141:
+		YYDEBUG(141, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 432 "Zend/zend_ini_scanner.l"
+#line 458 "Zend/zend_ini_scanner.l"
 		{ /* End of option value */
 	BEGIN(INITIAL);
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 1819 "Zend/zend_ini_scanner.c"
-yy137:
-		YYDEBUG(137, *YYCURSOR);
+#line 1924 "Zend/zend_ini_scanner.c"
+yy142:
+		YYDEBUG(142, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy145;
-		goto yy136;
-yy138:
-		YYDEBUG(138, *YYCURSOR);
+		if (yych == '\n') goto yy150;
+		goto yy141;
+yy143:
+		YYDEBUG(143, *YYCURSOR);
 		yyaccept = 1;
 		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy141;
-		YYDEBUG(139, *YYCURSOR);
+		goto yy146;
+		YYDEBUG(144, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 541 "Zend/zend_ini_scanner.l"
+#line 567 "Zend/zend_ini_scanner.l"
 		{ /* End of option value (if EOF is reached before EOL */
 	BEGIN(INITIAL);
 	return END_OF_LINE;
 }
-#line 1837 "Zend/zend_ini_scanner.c"
-yy140:
-		YYDEBUG(140, *YYCURSOR);
+#line 1942 "Zend/zend_ini_scanner.c"
+yy145:
+		YYDEBUG(145, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy141:
-		YYDEBUG(141, *YYCURSOR);
+yy146:
+		YYDEBUG(146, *YYCURSOR);
 		if (yybm[0+yych] & 32) {
-			goto yy140;
+			goto yy145;
 		}
-		if (yych >= '\r') goto yy144;
-yy142:
-		YYDEBUG(142, *YYCURSOR);
+		if (yych >= '\r') goto yy149;
+yy147:
+		YYDEBUG(147, *YYCURSOR);
 		++YYCURSOR;
-yy143:
-		YYDEBUG(143, *YYCURSOR);
+yy148:
+		YYDEBUG(148, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 528 "Zend/zend_ini_scanner.l"
+#line 554 "Zend/zend_ini_scanner.l"
 		{ /* Comment */
 	BEGIN(INITIAL);
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 1861 "Zend/zend_ini_scanner.c"
-yy144:
-		YYDEBUG(144, *YYCURSOR);
+#line 1966 "Zend/zend_ini_scanner.c"
+yy149:
+		YYDEBUG(149, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy142;
-		goto yy143;
-yy145:
-		YYDEBUG(145, *YYCURSOR);
+		if (yych == '\n') goto yy147;
+		goto yy148;
+yy150:
+		YYDEBUG(150, *YYCURSOR);
 		yych = *++YYCURSOR;
-		goto yy136;
-yy146:
-		YYDEBUG(146, *YYCURSOR);
+		goto yy141;
+yy151:
+		YYDEBUG(151, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-		YYDEBUG(147, *YYCURSOR);
+		YYDEBUG(152, *YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy146;
+			goto yy151;
 		}
 		if (yych <= '\f') {
-			if (yych == '\n') goto yy145;
-			goto yy149;
+			if (yych == '\n') goto yy150;
+			goto yy154;
 		} else {
-			if (yych <= '\r') goto yy148;
-			if (yych == ';') goto yy140;
-			goto yy149;
+			if (yych <= '\r') goto yy153;
+			if (yych == ';') goto yy145;
+			goto yy154;
 		}
-yy148:
-		YYDEBUG(148, *YYCURSOR);
+yy153:
+		YYDEBUG(153, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy145;
-		goto yy136;
-yy149:
-		YYDEBUG(149, *YYCURSOR);
+		if (yych == '\n') goto yy150;
+		goto yy141;
+yy154:
+		YYDEBUG(154, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy150:
-		YYDEBUG(150, *YYCURSOR);
+yy155:
+		YYDEBUG(155, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy149;
+			goto yy154;
 		}
-		goto yy133;
+		goto yy138;
 	}
 /* *********************************** */
 yyc_ST_SECTION_RAW:
@@ -1939,85 +2044,85 @@ yyc_ST_SECTION_RAW:
 			128, 128, 128, 128, 128, 128, 128, 128, 
 			128, 128, 128, 128, 128, 128, 128, 128, 
 		};
-		YYDEBUG(151, *YYCURSOR);
+		YYDEBUG(156, *YYCURSOR);
 		YYFILL(3);
 		yych = *YYCURSOR;
 		if (yych <= '\f') {
-			if (yych == '\n') goto yy155;
+			if (yych == '\n') goto yy160;
 		} else {
-			if (yych <= '\r') goto yy155;
-			if (yych == ']') goto yy157;
+			if (yych <= '\r') goto yy160;
+			if (yych == ']') goto yy162;
 		}
-		YYDEBUG(153, *YYCURSOR);
+		YYDEBUG(158, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy164;
-yy154:
-		YYDEBUG(154, *YYCURSOR);
+		goto yy169;
+yy159:
+		YYDEBUG(159, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 428 "Zend/zend_ini_scanner.l"
+#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 1963 "Zend/zend_ini_scanner.c"
-yy155:
-		YYDEBUG(155, *YYCURSOR);
+#line 2068 "Zend/zend_ini_scanner.c"
+yy160:
+		YYDEBUG(160, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(156, *YYCURSOR);
+		YYDEBUG(161, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 546 "Zend/zend_ini_scanner.l"
+#line 572 "Zend/zend_ini_scanner.l"
 		{
 	return 0;
 }
-#line 1973 "Zend/zend_ini_scanner.c"
-yy157:
-		YYDEBUG(157, *YYCURSOR);
+#line 2078 "Zend/zend_ini_scanner.c"
+yy162:
+		YYDEBUG(162, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy160;
-yy158:
-		YYDEBUG(158, *YYCURSOR);
+		goto yy165;
+yy163:
+		YYDEBUG(163, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 363 "Zend/zend_ini_scanner.l"
+#line 374 "Zend/zend_ini_scanner.l"
 		{ /* End of section */
 	BEGIN(INITIAL);
 	SCNG(lineno)++;
 	return ']';
 }
-#line 1988 "Zend/zend_ini_scanner.c"
-yy159:
-		YYDEBUG(159, *YYCURSOR);
+#line 2093 "Zend/zend_ini_scanner.c"
+yy164:
+		YYDEBUG(164, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy160:
-		YYDEBUG(160, *YYCURSOR);
+yy165:
+		YYDEBUG(165, *YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy159;
+			goto yy164;
 		}
-		if (yych == '\n') goto yy161;
-		if (yych == '\r') goto yy162;
-		goto yy158;
-yy161:
-		YYDEBUG(161, *YYCURSOR);
+		if (yych == '\n') goto yy166;
+		if (yych == '\r') goto yy167;
+		goto yy163;
+yy166:
+		YYDEBUG(166, *YYCURSOR);
 		yych = *++YYCURSOR;
-		goto yy158;
-yy162:
-		YYDEBUG(162, *YYCURSOR);
+		goto yy163;
+yy167:
+		YYDEBUG(167, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy161;
-		goto yy158;
-yy163:
-		YYDEBUG(163, *YYCURSOR);
+		if (yych == '\n') goto yy166;
+		goto yy163;
+yy168:
+		YYDEBUG(168, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy164:
-		YYDEBUG(164, *YYCURSOR);
+yy169:
+		YYDEBUG(169, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy163;
+			goto yy168;
 		}
-		goto yy154;
+		goto yy159;
 	}
 /* *********************************** */
 yyc_ST_SECTION_VALUE:
@@ -2056,522 +2161,523 @@ yyc_ST_SECTION_VALUE:
 			132, 132, 132, 132, 132, 132, 132, 132, 
 			132, 132, 132, 132, 132, 132, 132, 132, 
 		};
-		YYDEBUG(165, *YYCURSOR);
+		YYDEBUG(170, *YYCURSOR);
 		YYFILL(3);
 		yych = *YYCURSOR;
-		if (yych <= ',') {
+		if (yych <= '-') {
 			if (yych <= ' ') {
 				if (yych <= '\n') {
-					if (yych <= 0x08) goto yy167;
-					if (yych <= '\t') goto yy169;
-					goto yy170;
+					if (yych <= 0x08) goto yy172;
+					if (yych <= '\t') goto yy174;
+					goto yy175;
 				} else {
-					if (yych == '\r') goto yy170;
-					if (yych >= ' ') goto yy169;
+					if (yych == '\r') goto yy175;
+					if (yych >= ' ') goto yy174;
 				}
 			} else {
-				if (yych <= '#') {
-					if (yych == '"') goto yy172;
+				if (yych <= '$') {
+					if (yych == '"') goto yy177;
+					if (yych >= '$') goto yy179;
 				} else {
-					if (yych <= '$') goto yy174;
-					if (yych == '\'') goto yy175;
+					if (yych == '\'') goto yy180;
+					if (yych >= '-') goto yy181;
 				}
 			}
 		} else {
-			if (yych <= '@') {
-				if (yych <= '/') {
-					if (yych <= '-') goto yy176;
-					if (yych <= '.') goto yy177;
+			if (yych <= 'Z') {
+				if (yych <= '9') {
+					if (yych <= '.') goto yy182;
+					if (yych >= '0') goto yy183;
 				} else {
-					if (yych <= '9') goto yy178;
-					if (yych == ';') goto yy170;
+					if (yych == ';') goto yy175;
+					if (yych >= 'A') goto yy185;
 				}
 			} else {
-				if (yych <= '\\') {
-					if (yych <= 'Z') goto yy180;
-					if (yych >= '\\') goto yy182;
+				if (yych <= '^') {
+					if (yych <= '[') goto yy172;
+					if (yych <= '\\') goto yy187;
+					if (yych <= ']') goto yy188;
 				} else {
-					if (yych <= ']') goto yy183;
-					if (yych <= '`') goto yy167;
-					if (yych <= 'z') goto yy180;
+					if (yych == '`') goto yy172;
+					if (yych <= 'z') goto yy185;
 				}
 			}
 		}
-yy167:
-		YYDEBUG(167, *YYCURSOR);
+yy172:
+		YYDEBUG(172, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy190;
-yy168:
-		YYDEBUG(168, *YYCURSOR);
+		goto yy195;
+yy173:
+		YYDEBUG(173, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 464 "Zend/zend_ini_scanner.l"
+#line 490 "Zend/zend_ini_scanner.l"
 		{ /* Get rest as section/offset value */
 	RETURN_TOKEN(TC_STRING, yytext, yyleng);
 }
-#line 2113 "Zend/zend_ini_scanner.c"
-yy169:
-		YYDEBUG(169, *YYCURSOR);
+#line 2219 "Zend/zend_ini_scanner.c"
+yy174:
+		YYDEBUG(174, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= 0x1F) {
-			if (yych == '\t') goto yy216;
-			goto yy190;
+			if (yych == '\t') goto yy221;
+			goto yy195;
 		} else {
-			if (yych <= ' ') goto yy216;
-			if (yych == '"') goto yy218;
-			goto yy190;
+			if (yych <= ' ') goto yy221;
+			if (yych == '"') goto yy223;
+			goto yy195;
 		}
-yy170:
-		YYDEBUG(170, *YYCURSOR);
+yy175:
+		YYDEBUG(175, *YYCURSOR);
 		++YYCURSOR;
-yy171:
-		YYDEBUG(171, *YYCURSOR);
+yy176:
+		YYDEBUG(176, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 546 "Zend/zend_ini_scanner.l"
+#line 572 "Zend/zend_ini_scanner.l"
 		{
 	return 0;
 }
-#line 2136 "Zend/zend_ini_scanner.c"
-yy172:
-		YYDEBUG(172, *YYCURSOR);
+#line 2242 "Zend/zend_ini_scanner.c"
+yy177:
+		YYDEBUG(177, *YYCURSOR);
 		++YYCURSOR;
-yy173:
-		YYDEBUG(173, *YYCURSOR);
+yy178:
+		YYDEBUG(178, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 468 "Zend/zend_ini_scanner.l"
+#line 494 "Zend/zend_ini_scanner.l"
 		{ /* Double quoted '"' string start */
 	yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC);
 	return '"';
 }
-#line 2148 "Zend/zend_ini_scanner.c"
-yy174:
-		YYDEBUG(174, *YYCURSOR);
+#line 2254 "Zend/zend_ini_scanner.c"
+yy179:
+		YYDEBUG(179, *YYCURSOR);
 		yych = *++YYCURSOR;
 		if (yych <= '\\') {
-			if (yych <= 0x00) goto yy171;
-			if (yych <= '[') goto yy189;
-			goto yy194;
+			if (yych <= 0x00) goto yy176;
+			if (yych <= '[') goto yy194;
+			goto yy199;
 		} else {
-			if (yych == '{') goto yy214;
-			goto yy189;
+			if (yych == '{') goto yy219;
+			goto yy194;
 		}
-yy175:
-		YYDEBUG(175, *YYCURSOR);
+yy180:
+		YYDEBUG(180, *YYCURSOR);
 		yyaccept = 1;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy210;
+			goto yy215;
 		}
-		goto yy171;
-yy176:
-		YYDEBUG(176, *YYCURSOR);
+		goto yy176;
+yy181:
+		YYDEBUG(181, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		if (yych <= '/') goto yy190;
-		if (yych <= '9') goto yy208;
-		goto yy190;
-yy177:
-		YYDEBUG(177, *YYCURSOR);
+		if (yych <= '/') goto yy195;
+		if (yych <= '9') goto yy213;
+		goto yy195;
+yy182:
+		YYDEBUG(182, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		if (yych <= '/') goto yy190;
-		if (yych <= '9') goto yy206;
-		goto yy190;
-yy178:
-		YYDEBUG(178, *YYCURSOR);
+		if (yych <= '/') goto yy195;
+		if (yych <= '9') goto yy211;
+		goto yy195;
+yy183:
+		YYDEBUG(183, *YYCURSOR);
 		yyaccept = 2;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '\'') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy179;
-				if (yych <= '\f') goto yy190;
+				if (yych == '\n') goto yy184;
+				if (yych <= '\f') goto yy195;
 			} else {
-				if (yych == '"') goto yy179;
-				if (yych <= '&') goto yy190;
+				if (yych == '"') goto yy184;
+				if (yych <= '&') goto yy195;
 			}
 		} else {
 			if (yych <= '9') {
-				if (yych == '.') goto yy202;
-				if (yych <= '/') goto yy190;
-				goto yy204;
+				if (yych == '.') goto yy207;
+				if (yych <= '/') goto yy195;
+				goto yy209;
 			} else {
 				if (yych <= ';') {
-					if (yych <= ':') goto yy190;
+					if (yych <= ':') goto yy195;
 				} else {
-					if (yych != ']') goto yy190;
+					if (yych != ']') goto yy195;
 				}
 			}
 		}
-yy179:
-		YYDEBUG(179, *YYCURSOR);
+yy184:
+		YYDEBUG(184, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 442 "Zend/zend_ini_scanner.l"
+#line 468 "Zend/zend_ini_scanner.l"
 		{ /* Get number option value as string */
 	RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
 }
-#line 2214 "Zend/zend_ini_scanner.c"
-yy180:
-		YYDEBUG(180, *YYCURSOR);
+#line 2320 "Zend/zend_ini_scanner.c"
+yy185:
+		YYDEBUG(185, *YYCURSOR);
 		yyaccept = 3;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 32) {
-			goto yy200;
+			goto yy205;
 		}
 		if (yych <= '"') {
 			if (yych <= '\f') {
-				if (yych != '\n') goto yy190;
+				if (yych != '\n') goto yy195;
 			} else {
-				if (yych <= '\r') goto yy181;
-				if (yych <= '!') goto yy190;
+				if (yych <= '\r') goto yy186;
+				if (yych <= '!') goto yy195;
 			}
 		} else {
 			if (yych <= ':') {
-				if (yych != '\'') goto yy190;
+				if (yych != '\'') goto yy195;
 			} else {
-				if (yych <= ';') goto yy181;
-				if (yych != ']') goto yy190;
+				if (yych <= ';') goto yy186;
+				if (yych != ']') goto yy195;
 			}
 		}
-yy181:
-		YYDEBUG(181, *YYCURSOR);
+yy186:
+		YYDEBUG(186, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 438 "Zend/zend_ini_scanner.l"
+#line 464 "Zend/zend_ini_scanner.l"
 		{ /* Get constant option value */
 	RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
 }
-#line 2244 "Zend/zend_ini_scanner.c"
-yy182:
-		YYDEBUG(182, *YYCURSOR);
+#line 2350 "Zend/zend_ini_scanner.c"
+yy187:
+		YYDEBUG(187, *YYCURSOR);
 		yych = *++YYCURSOR;
-		goto yy189;
-yy183:
-		YYDEBUG(183, *YYCURSOR);
+		goto yy194;
+yy188:
+		YYDEBUG(188, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy186;
-yy184:
-		YYDEBUG(184, *YYCURSOR);
+		goto yy191;
+yy189:
+		YYDEBUG(189, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 363 "Zend/zend_ini_scanner.l"
+#line 374 "Zend/zend_ini_scanner.l"
 		{ /* End of section */
 	BEGIN(INITIAL);
 	SCNG(lineno)++;
 	return ']';
 }
-#line 2263 "Zend/zend_ini_scanner.c"
-yy185:
-		YYDEBUG(185, *YYCURSOR);
+#line 2369 "Zend/zend_ini_scanner.c"
+yy190:
+		YYDEBUG(190, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy186:
-		YYDEBUG(186, *YYCURSOR);
+yy191:
+		YYDEBUG(191, *YYCURSOR);
 		if (yybm[0+yych] & 2) {
-			goto yy185;
+			goto yy190;
 		}
-		if (yych == '\n') goto yy187;
-		if (yych == '\r') goto yy188;
-		goto yy184;
-yy187:
-		YYDEBUG(187, *YYCURSOR);
+		if (yych == '\n') goto yy192;
+		if (yych == '\r') goto yy193;
+		goto yy189;
+yy192:
+		YYDEBUG(192, *YYCURSOR);
 		yych = *++YYCURSOR;
-		goto yy184;
-yy188:
-		YYDEBUG(188, *YYCURSOR);
+		goto yy189;
+yy193:
+		YYDEBUG(193, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy187;
-		goto yy184;
-yy189:
-		YYDEBUG(189, *YYCURSOR);
+		if (yych == '\n') goto yy192;
+		goto yy189;
+yy194:
+		YYDEBUG(194, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy190:
-		YYDEBUG(190, *YYCURSOR);
+yy195:
+		YYDEBUG(195, *YYCURSOR);
 		if (yybm[0+yych] & 4) {
-			goto yy189;
+			goto yy194;
 		}
-		if (yych == '$') goto yy192;
-		if (yych != '\\') goto yy168;
-yy191:
-		YYDEBUG(191, *YYCURSOR);
+		if (yych == '$') goto yy197;
+		if (yych != '\\') goto yy173;
+yy196:
+		YYDEBUG(196, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		goto yy189;
-yy192:
-		YYDEBUG(192, *YYCURSOR);
+		goto yy194;
+yy197:
+		YYDEBUG(197, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yych <= '\\') {
-			if (yych <= 0x00) goto yy193;
-			if (yych <= '[') goto yy189;
-			goto yy194;
+			if (yych <= 0x00) goto yy198;
+			if (yych <= '[') goto yy194;
+			goto yy199;
 		} else {
-			if (yych != '{') goto yy189;
+			if (yych != '{') goto yy194;
 		}
-yy193:
-		YYDEBUG(193, *YYCURSOR);
+yy198:
+		YYDEBUG(198, *YYCURSOR);
 		YYCURSOR = YYMARKER;
 		if (yyaccept <= 1) {
 			if (yyaccept <= 0) {
-				goto yy168;
+				goto yy173;
 			} else {
-				goto yy171;
+				goto yy176;
 			}
 		} else {
 			if (yyaccept <= 2) {
-				goto yy179;
+				goto yy184;
 			} else {
-				goto yy181;
+				goto yy186;
 			}
 		}
-yy194:
-		YYDEBUG(194, *YYCURSOR);
+yy199:
+		YYDEBUG(199, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yybm[0+yych] & 8) {
-			goto yy195;
+			goto yy200;
 		}
-		if (yych == '\\') goto yy197;
-		goto yy189;
-yy195:
-		YYDEBUG(195, *YYCURSOR);
+		if (yych == '\\') goto yy202;
+		goto yy194;
+yy200:
+		YYDEBUG(200, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(196, *YYCURSOR);
+		YYDEBUG(201, *YYCURSOR);
 		if (yybm[0+yych] & 8) {
-			goto yy195;
+			goto yy200;
 		}
-		if (yych == '\\') goto yy199;
-		goto yy189;
-yy197:
-		YYDEBUG(197, *YYCURSOR);
+		if (yych == '\\') goto yy204;
+		goto yy194;
+yy202:
+		YYDEBUG(202, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(198, *YYCURSOR);
+		YYDEBUG(203, *YYCURSOR);
 		if (yybm[0+yych] & 8) {
-			goto yy195;
+			goto yy200;
 		}
-		if (yych == '\\') goto yy197;
-		goto yy189;
-yy199:
-		YYDEBUG(199, *YYCURSOR);
+		if (yych == '\\') goto yy202;
+		goto yy194;
+yy204:
+		YYDEBUG(204, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yybm[0+yych] & 8) {
-			goto yy195;
+			goto yy200;
 		}
-		if (yych == '\\') goto yy197;
-		goto yy189;
-yy200:
-		YYDEBUG(200, *YYCURSOR);
+		if (yych == '\\') goto yy202;
+		goto yy194;
+yy205:
+		YYDEBUG(205, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(201, *YYCURSOR);
+		YYDEBUG(206, *YYCURSOR);
 		if (yybm[0+yych] & 32) {
-			goto yy200;
+			goto yy205;
 		}
 		if (yych <= '$') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy181;
-				if (yych <= '\f') goto yy189;
-				goto yy181;
+				if (yych == '\n') goto yy186;
+				if (yych <= '\f') goto yy194;
+				goto yy186;
 			} else {
-				if (yych == '"') goto yy181;
-				if (yych <= '#') goto yy189;
-				goto yy192;
+				if (yych == '"') goto yy186;
+				if (yych <= '#') goto yy194;
+				goto yy197;
 			}
 		} else {
 			if (yych <= ';') {
-				if (yych == '\'') goto yy181;
-				if (yych <= ':') goto yy189;
-				goto yy181;
+				if (yych == '\'') goto yy186;
+				if (yych <= ':') goto yy194;
+				goto yy186;
 			} else {
-				if (yych <= '[') goto yy189;
-				if (yych <= '\\') goto yy191;
-				if (yych <= ']') goto yy181;
-				goto yy189;
+				if (yych <= '[') goto yy194;
+				if (yych <= '\\') goto yy196;
+				if (yych <= ']') goto yy186;
+				goto yy194;
 			}
 		}
-yy202:
-		YYDEBUG(202, *YYCURSOR);
+yy207:
+		YYDEBUG(207, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(203, *YYCURSOR);
+		YYDEBUG(208, *YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy202;
+			goto yy207;
 		}
 		if (yych <= '$') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy179;
-				if (yych <= '\f') goto yy189;
-				goto yy179;
+				if (yych == '\n') goto yy184;
+				if (yych <= '\f') goto yy194;
+				goto yy184;
 			} else {
-				if (yych == '"') goto yy179;
-				if (yych <= '#') goto yy189;
-				goto yy192;
+				if (yych == '"') goto yy184;
+				if (yych <= '#') goto yy194;
+				goto yy197;
 			}
 		} else {
 			if (yych <= ';') {
-				if (yych == '\'') goto yy179;
-				if (yych <= ':') goto yy189;
-				goto yy179;
+				if (yych == '\'') goto yy184;
+				if (yych <= ':') goto yy194;
+				goto yy184;
 			} else {
-				if (yych <= '[') goto yy189;
-				if (yych <= '\\') goto yy191;
-				if (yych <= ']') goto yy179;
-				goto yy189;
+				if (yych <= '[') goto yy194;
+				if (yych <= '\\') goto yy196;
+				if (yych <= ']') goto yy184;
+				goto yy194;
 			}
 		}
-yy204:
-		YYDEBUG(204, *YYCURSOR);
+yy209:
+		YYDEBUG(209, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(205, *YYCURSOR);
+		YYDEBUG(210, *YYCURSOR);
 		if (yych <= '\'') {
 			if (yych <= '!') {
 				if (yych <= '\n') {
-					if (yych <= '\t') goto yy189;
-					goto yy179;
+					if (yych <= '\t') goto yy194;
+					goto yy184;
 				} else {
-					if (yych == '\r') goto yy179;
-					goto yy189;
+					if (yych == '\r') goto yy184;
+					goto yy194;
 				}
 			} else {
 				if (yych <= '#') {
-					if (yych <= '"') goto yy179;
-					goto yy189;
+					if (yych <= '"') goto yy184;
+					goto yy194;
 				} else {
-					if (yych <= '$') goto yy192;
-					if (yych <= '&') goto yy189;
-					goto yy179;
+					if (yych <= '$') goto yy197;
+					if (yych <= '&') goto yy194;
+					goto yy184;
 				}
 			}
 		} else {
 			if (yych <= ':') {
 				if (yych <= '.') {
-					if (yych <= '-') goto yy189;
-					goto yy202;
+					if (yych <= '-') goto yy194;
+					goto yy207;
 				} else {
-					if (yych <= '/') goto yy189;
-					if (yych <= '9') goto yy204;
-					goto yy189;
+					if (yych <= '/') goto yy194;
+					if (yych <= '9') goto yy209;
+					goto yy194;
 				}
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy179;
-					goto yy189;
+					if (yych <= ';') goto yy184;
+					goto yy194;
 				} else {
-					if (yych <= '\\') goto yy191;
-					if (yych <= ']') goto yy179;
-					goto yy189;
+					if (yych <= '\\') goto yy196;
+					if (yych <= ']') goto yy184;
+					goto yy194;
 				}
 			}
 		}
-yy206:
-		YYDEBUG(206, *YYCURSOR);
+yy211:
+		YYDEBUG(211, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(207, *YYCURSOR);
+		YYDEBUG(212, *YYCURSOR);
 		if (yych <= '&') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy179;
-				if (yych <= '\f') goto yy189;
-				goto yy179;
+				if (yych == '\n') goto yy184;
+				if (yych <= '\f') goto yy194;
+				goto yy184;
 			} else {
 				if (yych <= '"') {
-					if (yych <= '!') goto yy189;
-					goto yy179;
+					if (yych <= '!') goto yy194;
+					goto yy184;
 				} else {
-					if (yych == '$') goto yy192;
-					goto yy189;
+					if (yych == '$') goto yy197;
+					goto yy194;
 				}
 			}
 		} else {
 			if (yych <= ':') {
-				if (yych <= '\'') goto yy179;
-				if (yych <= '/') goto yy189;
-				if (yych <= '9') goto yy206;
-				goto yy189;
+				if (yych <= '\'') goto yy184;
+				if (yych <= '/') goto yy194;
+				if (yych <= '9') goto yy211;
+				goto yy194;
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy179;
-					goto yy189;
+					if (yych <= ';') goto yy184;
+					goto yy194;
 				} else {
-					if (yych <= '\\') goto yy191;
-					if (yych <= ']') goto yy179;
-					goto yy189;
+					if (yych <= '\\') goto yy196;
+					if (yych <= ']') goto yy184;
+					goto yy194;
 				}
 			}
 		}
-yy208:
-		YYDEBUG(208, *YYCURSOR);
+yy213:
+		YYDEBUG(213, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(209, *YYCURSOR);
+		YYDEBUG(214, *YYCURSOR);
 		if (yych <= '&') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy179;
-				if (yych <= '\f') goto yy189;
-				goto yy179;
+				if (yych == '\n') goto yy184;
+				if (yych <= '\f') goto yy194;
+				goto yy184;
 			} else {
 				if (yych <= '"') {
-					if (yych <= '!') goto yy189;
-					goto yy179;
+					if (yych <= '!') goto yy194;
+					goto yy184;
 				} else {
-					if (yych == '$') goto yy192;
-					goto yy189;
+					if (yych == '$') goto yy197;
+					goto yy194;
 				}
 			}
 		} else {
 			if (yych <= ':') {
-				if (yych <= '\'') goto yy179;
-				if (yych <= '/') goto yy189;
-				if (yych <= '9') goto yy208;
-				goto yy189;
+				if (yych <= '\'') goto yy184;
+				if (yych <= '/') goto yy194;
+				if (yych <= '9') goto yy213;
+				goto yy194;
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy179;
-					goto yy189;
+					if (yych <= ';') goto yy184;
+					goto yy194;
 				} else {
-					if (yych <= '\\') goto yy191;
-					if (yych <= ']') goto yy179;
-					goto yy189;
+					if (yych <= '\\') goto yy196;
+					if (yych <= ']') goto yy184;
+					goto yy194;
 				}
 			}
 		}
-yy210:
-		YYDEBUG(210, *YYCURSOR);
+yy215:
+		YYDEBUG(215, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(211, *YYCURSOR);
+		YYDEBUG(216, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy210;
+			goto yy215;
 		}
-		YYDEBUG(212, *YYCURSOR);
+		YYDEBUG(217, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(213, *YYCURSOR);
+		YYDEBUG(218, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 354 "Zend/zend_ini_scanner.l"
+#line 365 "Zend/zend_ini_scanner.l"
 		{ /* Raw string */
 	/* Eat leading and trailing single quotes */
 	if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
@@ -2580,65 +2686,65 @@ yy210:
 	}
 	RETURN_TOKEN(TC_RAW, yytext, yyleng);
 }
-#line 2584 "Zend/zend_ini_scanner.c"
-yy214:
-		YYDEBUG(214, *YYCURSOR);
+#line 2690 "Zend/zend_ini_scanner.c"
+yy219:
+		YYDEBUG(219, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(215, *YYCURSOR);
+		YYDEBUG(220, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 384 "Zend/zend_ini_scanner.l"
+#line 398 "Zend/zend_ini_scanner.l"
 		{ /* Variable start */
 	yy_push_state(ST_VARNAME TSRMLS_CC);
 	return TC_DOLLAR_CURLY;
 }
-#line 2595 "Zend/zend_ini_scanner.c"
-yy216:
-		YYDEBUG(216, *YYCURSOR);
+#line 2701 "Zend/zend_ini_scanner.c"
+yy221:
+		YYDEBUG(221, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(217, *YYCURSOR);
+		YYDEBUG(222, *YYCURSOR);
 		if (yych <= '"') {
 			if (yych <= '\f') {
-				if (yych <= 0x08) goto yy189;
-				if (yych <= '\t') goto yy216;
-				if (yych <= '\n') goto yy168;
-				goto yy189;
+				if (yych <= 0x08) goto yy194;
+				if (yych <= '\t') goto yy221;
+				if (yych <= '\n') goto yy173;
+				goto yy194;
 			} else {
 				if (yych <= 0x1F) {
-					if (yych <= '\r') goto yy168;
-					goto yy189;
+					if (yych <= '\r') goto yy173;
+					goto yy194;
 				} else {
-					if (yych <= ' ') goto yy216;
-					if (yych <= '!') goto yy189;
+					if (yych <= ' ') goto yy221;
+					if (yych <= '!') goto yy194;
 				}
 			}
 		} else {
 			if (yych <= ':') {
 				if (yych <= '$') {
-					if (yych <= '#') goto yy189;
-					goto yy192;
+					if (yych <= '#') goto yy194;
+					goto yy197;
 				} else {
-					if (yych == '\'') goto yy168;
-					goto yy189;
+					if (yych == '\'') goto yy173;
+					goto yy194;
 				}
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy168;
-					goto yy189;
+					if (yych <= ';') goto yy173;
+					goto yy194;
 				} else {
-					if (yych <= '\\') goto yy191;
-					if (yych <= ']') goto yy168;
-					goto yy189;
+					if (yych <= '\\') goto yy196;
+					if (yych <= ']') goto yy173;
+					goto yy194;
 				}
 			}
 		}
-yy218:
-		YYDEBUG(218, *YYCURSOR);
+yy223:
+		YYDEBUG(223, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy173;
+		goto yy178;
 	}
 /* *********************************** */
 yyc_ST_VALUE:
@@ -2677,27 +2783,27 @@ yyc_ST_VALUE:
 			162, 162, 162, 162, 162, 162, 162, 162, 
 			162, 162, 162, 162, 162, 162, 162, 162, 
 		};
-		YYDEBUG(219, *YYCURSOR);
+		YYDEBUG(224, *YYCURSOR);
 		YYFILL(6);
 		yych = *YYCURSOR;
 		YYDEBUG(-1, yych);
 		switch (yych) {
-		case 0x00:	goto yy221;
+		case 0x00:	goto yy226;
 		case '\t':
-		case ' ':	goto yy225;
-		case '\n':	goto yy227;
-		case '\r':	goto yy229;
+		case ' ':	goto yy230;
+		case '\n':	goto yy232;
+		case '\r':	goto yy234;
 		case '!':
 		case '&':
 		case '(':
 		case ')':
 		case '|':
-		case '~':	goto yy230;
-		case '"':	goto yy232;
-		case '$':	goto yy234;
-		case '\'':	goto yy235;
-		case '-':	goto yy236;
-		case '.':	goto yy237;
+		case '~':	goto yy235;
+		case '"':	goto yy237;
+		case '$':	goto yy239;
+		case '\'':	goto yy240;
+		case '-':	goto yy241;
+		case '.':	goto yy242;
 		case '0':
 		case '1':
 		case '2':
@@ -2707,9 +2813,9 @@ yyc_ST_VALUE:
 		case '6':
 		case '7':
 		case '8':
-		case '9':	goto yy238;
-		case ';':	goto yy240;
-		case '=':	goto yy241;
+		case '9':	goto yy243;
+		case ';':	goto yy245;
+		case '=':	goto yy246;
 		case 'A':
 		case 'B':
 		case 'C':
@@ -2731,6 +2837,7 @@ yyc_ST_VALUE:
 		case 'W':
 		case 'X':
 		case 'Z':
+		case '_':
 		case 'a':
 		case 'b':
 		case 'c':
@@ -2751,1531 +2858,1531 @@ yyc_ST_VALUE:
 		case 'v':
 		case 'w':
 		case 'x':
-		case 'z':	goto yy243;
+		case 'z':	goto yy248;
 		case 'F':
-		case 'f':	goto yy245;
+		case 'f':	goto yy250;
 		case 'N':
-		case 'n':	goto yy246;
+		case 'n':	goto yy251;
 		case 'O':
-		case 'o':	goto yy247;
+		case 'o':	goto yy252;
 		case 'T':
-		case 't':	goto yy248;
+		case 't':	goto yy253;
 		case 'Y':
-		case 'y':	goto yy249;
-		default:	goto yy223;
+		case 'y':	goto yy254;
+		default:	goto yy228;
 		}
-yy221:
-		YYDEBUG(221, *YYCURSOR);
+yy226:
+		YYDEBUG(226, *YYCURSOR);
 		++YYCURSOR;
-yy222:
-		YYDEBUG(222, *YYCURSOR);
+yy227:
+		YYDEBUG(227, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 541 "Zend/zend_ini_scanner.l"
+#line 567 "Zend/zend_ini_scanner.l"
 		{ /* End of option value (if EOF is reached before EOL */
 	BEGIN(INITIAL);
 	return END_OF_LINE;
 }
-#line 2779 "Zend/zend_ini_scanner.c"
-yy223:
-		YYDEBUG(223, *YYCURSOR);
+#line 2886 "Zend/zend_ini_scanner.c"
+yy228:
+		YYDEBUG(228, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy251;
-yy224:
-		YYDEBUG(224, *YYCURSOR);
+		goto yy256;
+yy229:
+		YYDEBUG(229, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 460 "Zend/zend_ini_scanner.l"
+#line 486 "Zend/zend_ini_scanner.l"
 		{ /* Get everything else as option/offset value */
 	RETURN_TOKEN(TC_STRING, yytext, yyleng);
 }
-#line 2792 "Zend/zend_ini_scanner.c"
-yy225:
-		YYDEBUG(225, *YYCURSOR);
+#line 2899 "Zend/zend_ini_scanner.c"
+yy230:
+		YYDEBUG(230, *YYCURSOR);
 		yyaccept = 1;
 		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy301;
-yy226:
-		YYDEBUG(226, *YYCURSOR);
+		goto yy306;
+yy231:
+		YYDEBUG(231, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 514 "Zend/zend_ini_scanner.l"
+#line 540 "Zend/zend_ini_scanner.l"
 		{
 	RETURN_TOKEN(TC_WHITESPACE, yytext, yyleng);
 }
-#line 2805 "Zend/zend_ini_scanner.c"
-yy227:
-		YYDEBUG(227, *YYCURSOR);
+#line 2912 "Zend/zend_ini_scanner.c"
+yy232:
+		YYDEBUG(232, *YYCURSOR);
 		++YYCURSOR;
-yy228:
-		YYDEBUG(228, *YYCURSOR);
+yy233:
+		YYDEBUG(233, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 432 "Zend/zend_ini_scanner.l"
+#line 458 "Zend/zend_ini_scanner.l"
 		{ /* End of option value */
 	BEGIN(INITIAL);
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 2818 "Zend/zend_ini_scanner.c"
-yy229:
-		YYDEBUG(229, *YYCURSOR);
+#line 2925 "Zend/zend_ini_scanner.c"
+yy234:
+		YYDEBUG(234, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy299;
-		goto yy228;
-yy230:
-		YYDEBUG(230, *YYCURSOR);
+		if (yych == '\n') goto yy304;
+		goto yy233;
+yy235:
+		YYDEBUG(235, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy298;
-yy231:
-		YYDEBUG(231, *YYCURSOR);
+		goto yy303;
+yy236:
+		YYDEBUG(236, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 450 "Zend/zend_ini_scanner.l"
+#line 476 "Zend/zend_ini_scanner.l"
 		{ /* Boolean operators */
 	return yytext[0];
 }
-#line 2836 "Zend/zend_ini_scanner.c"
-yy232:
-		YYDEBUG(232, *YYCURSOR);
+#line 2943 "Zend/zend_ini_scanner.c"
+yy237:
+		YYDEBUG(237, *YYCURSOR);
 		++YYCURSOR;
-yy233:
-		YYDEBUG(233, *YYCURSOR);
+yy238:
+		YYDEBUG(238, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 468 "Zend/zend_ini_scanner.l"
+#line 494 "Zend/zend_ini_scanner.l"
 		{ /* Double quoted '"' string start */
 	yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC);
 	return '"';
 }
-#line 2848 "Zend/zend_ini_scanner.c"
-yy234:
-		YYDEBUG(234, *YYCURSOR);
+#line 2955 "Zend/zend_ini_scanner.c"
+yy239:
+		YYDEBUG(239, *YYCURSOR);
 		yych = *++YYCURSOR;
 		if (yych <= '\\') {
-			if (yych <= 0x00) goto yy222;
-			if (yych <= '[') goto yy250;
-			goto yy257;
+			if (yych <= 0x00) goto yy227;
+			if (yych <= '[') goto yy255;
+			goto yy262;
 		} else {
-			if (yych == '{') goto yy295;
-			goto yy250;
+			if (yych == '{') goto yy300;
+			goto yy255;
 		}
-yy235:
-		YYDEBUG(235, *YYCURSOR);
+yy240:
+		YYDEBUG(240, *YYCURSOR);
 		yyaccept = 2;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy291;
+			goto yy296;
 		}
-		goto yy222;
-yy236:
-		YYDEBUG(236, *YYCURSOR);
+		goto yy227;
+yy241:
+		YYDEBUG(241, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		if (yych <= '/') goto yy251;
-		if (yych <= '9') goto yy289;
-		goto yy251;
-yy237:
-		YYDEBUG(237, *YYCURSOR);
+		if (yych <= '/') goto yy256;
+		if (yych <= '9') goto yy294;
+		goto yy256;
+yy242:
+		YYDEBUG(242, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		if (yych <= '/') goto yy251;
-		if (yych <= '9') goto yy287;
-		goto yy251;
-yy238:
-		YYDEBUG(238, *YYCURSOR);
+		if (yych <= '/') goto yy256;
+		if (yych <= '9') goto yy292;
+		goto yy256;
+yy243:
+		YYDEBUG(243, *YYCURSOR);
 		yyaccept = 3;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '.') {
 			if (yych <= '\r') {
 				if (yych <= 0x08) {
-					if (yych >= 0x01) goto yy251;
+					if (yych >= 0x01) goto yy256;
 				} else {
-					if (yych <= '\n') goto yy239;
-					if (yych <= '\f') goto yy251;
+					if (yych <= '\n') goto yy244;
+					if (yych <= '\f') goto yy256;
 				}
 			} else {
 				if (yych <= '%') {
-					if (yych <= 0x1F) goto yy251;
-					if (yych >= '#') goto yy251;
+					if (yych <= 0x1F) goto yy256;
+					if (yych >= '#') goto yy256;
 				} else {
-					if (yych <= ')') goto yy239;
-					if (yych <= '-') goto yy251;
-					goto yy283;
+					if (yych <= ')') goto yy244;
+					if (yych <= '-') goto yy256;
+					goto yy288;
 				}
 			}
 		} else {
 			if (yych <= '<') {
 				if (yych <= '9') {
-					if (yych <= '/') goto yy251;
-					goto yy285;
+					if (yych <= '/') goto yy256;
+					goto yy290;
 				} else {
-					if (yych != ';') goto yy251;
+					if (yych != ';') goto yy256;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '=') goto yy239;
-					if (yych <= '{') goto yy251;
+					if (yych <= '=') goto yy244;
+					if (yych <= '{') goto yy256;
 				} else {
-					if (yych != '~') goto yy251;
+					if (yych != '~') goto yy256;
 				}
 			}
 		}
-yy239:
-		YYDEBUG(239, *YYCURSOR);
+yy244:
+		YYDEBUG(244, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 442 "Zend/zend_ini_scanner.l"
+#line 468 "Zend/zend_ini_scanner.l"
 		{ /* Get number option value as string */
 	RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
 }
-#line 2928 "Zend/zend_ini_scanner.c"
-yy240:
-		YYDEBUG(240, *YYCURSOR);
+#line 3035 "Zend/zend_ini_scanner.c"
+yy245:
+		YYDEBUG(245, *YYCURSOR);
 		yyaccept = 2;
 		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy279;
-yy241:
-		YYDEBUG(241, *YYCURSOR);
+		goto yy284;
+yy246:
+		YYDEBUG(246, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(242, *YYCURSOR);
+		YYDEBUG(247, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 454 "Zend/zend_ini_scanner.l"
+#line 480 "Zend/zend_ini_scanner.l"
 		{ /* Make = used in option value to trigger error */
 	yyless(0);
 	BEGIN(INITIAL);
 	return END_OF_LINE;
 }
-#line 2945 "Zend/zend_ini_scanner.c"
-yy243:
-		YYDEBUG(243, *YYCURSOR);
+#line 3052 "Zend/zend_ini_scanner.c"
+yy248:
+		YYDEBUG(248, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 4) {
-			goto yy252;
+			goto yy257;
 		}
 		if (yych <= ')') {
 			if (yych <= '\f') {
-				if (yych <= 0x00) goto yy244;
-				if (yych <= 0x08) goto yy251;
-				if (yych >= '\v') goto yy251;
+				if (yych <= 0x00) goto yy249;
+				if (yych <= 0x08) goto yy256;
+				if (yych >= '\v') goto yy256;
 			} else {
 				if (yych <= 0x1F) {
-					if (yych >= 0x0E) goto yy251;
+					if (yych >= 0x0E) goto yy256;
 				} else {
-					if (yych <= '"') goto yy244;
-					if (yych <= '%') goto yy251;
+					if (yych <= '"') goto yy249;
+					if (yych <= '%') goto yy256;
 				}
 			}
 		} else {
 			if (yych <= '=') {
-				if (yych == ';') goto yy244;
-				if (yych <= '<') goto yy251;
+				if (yych == ';') goto yy249;
+				if (yych <= '<') goto yy256;
 			} else {
 				if (yych <= '|') {
-					if (yych <= '{') goto yy251;
+					if (yych <= '{') goto yy256;
 				} else {
-					if (yych != '~') goto yy251;
+					if (yych != '~') goto yy256;
 				}
 			}
 		}
-yy244:
-		YYDEBUG(244, *YYCURSOR);
+yy249:
+		YYDEBUG(249, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 438 "Zend/zend_ini_scanner.l"
+#line 464 "Zend/zend_ini_scanner.l"
 		{ /* Get constant option value */
 	RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
 }
-#line 2985 "Zend/zend_ini_scanner.c"
-yy245:
-		YYDEBUG(245, *YYCURSOR);
+#line 3092 "Zend/zend_ini_scanner.c"
+yy250:
+		YYDEBUG(250, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '<') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '/') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					goto yy251;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					goto yy256;
 				} else {
-					if (yych <= '9') goto yy252;
-					if (yych == ';') goto yy244;
-					goto yy251;
+					if (yych <= '9') goto yy257;
+					if (yych == ';') goto yy249;
+					goto yy256;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'A') {
-					if (yych <= '=') goto yy244;
-					if (yych <= '@') goto yy251;
-					goto yy275;
+					if (yych <= '=') goto yy249;
+					if (yych <= '@') goto yy256;
+					goto yy280;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych <= 'a') goto yy275;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych <= 'a') goto yy280;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy246:
-		YYDEBUG(246, *YYCURSOR);
+yy251:
+		YYDEBUG(251, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= 'N') {
 			if (yych <= '%') {
 				if (yych <= '\f') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					if (yych <= '\n') goto yy244;
-					goto yy251;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					if (yych <= '\n') goto yy249;
+					goto yy256;
 				} else {
-					if (yych <= '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					if (yych <= '"') goto yy244;
-					goto yy251;
+					if (yych <= '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					if (yych <= '"') goto yy249;
+					goto yy256;
 				}
 			} else {
 				if (yych <= ':') {
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					if (yych <= '9') goto yy252;
-					goto yy251;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					if (yych <= '9') goto yy257;
+					goto yy256;
 				} else {
 					if (yych <= '<') {
-						if (yych <= ';') goto yy244;
-						goto yy251;
+						if (yych <= ';') goto yy249;
+						goto yy256;
 					} else {
-						if (yych <= '=') goto yy244;
-						if (yych <= '@') goto yy251;
-						goto yy252;
+						if (yych <= '=') goto yy249;
+						if (yych <= '@') goto yy256;
+						goto yy257;
 					}
 				}
 			}
 		} else {
 			if (yych <= 'n') {
 				if (yych <= 'Z') {
-					if (yych <= 'O') goto yy271;
-					if (yych == 'U') goto yy272;
-					goto yy252;
+					if (yych <= 'O') goto yy276;
+					if (yych == 'U') goto yy277;
+					goto yy257;
 				} else {
-					if (yych == '_') goto yy252;
-					if (yych <= '`') goto yy251;
-					goto yy252;
+					if (yych == '_') goto yy257;
+					if (yych <= '`') goto yy256;
+					goto yy257;
 				}
 			} else {
 				if (yych <= 'z') {
-					if (yych <= 'o') goto yy271;
-					if (yych == 'u') goto yy272;
-					goto yy252;
+					if (yych <= 'o') goto yy276;
+					if (yych == 'u') goto yy277;
+					goto yy257;
 				} else {
 					if (yych <= '|') {
-						if (yych <= '{') goto yy251;
-						goto yy244;
+						if (yych <= '{') goto yy256;
+						goto yy249;
 					} else {
-						if (yych == '~') goto yy244;
-						goto yy251;
+						if (yych == '~') goto yy249;
+						goto yy256;
 					}
 				}
 			}
 		}
-yy247:
-		YYDEBUG(247, *YYCURSOR);
+yy252:
+		YYDEBUG(252, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= 'E') {
 			if (yych <= '%') {
 				if (yych <= '\f') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					if (yych <= '\n') goto yy244;
-					goto yy251;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					if (yych <= '\n') goto yy249;
+					goto yy256;
 				} else {
-					if (yych <= '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					if (yych <= '"') goto yy244;
-					goto yy251;
+					if (yych <= '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					if (yych <= '"') goto yy249;
+					goto yy256;
 				}
 			} else {
 				if (yych <= ':') {
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					if (yych <= '9') goto yy252;
-					goto yy251;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					if (yych <= '9') goto yy257;
+					goto yy256;
 				} else {
 					if (yych <= '<') {
-						if (yych <= ';') goto yy244;
-						goto yy251;
+						if (yych <= ';') goto yy249;
+						goto yy256;
 					} else {
-						if (yych <= '=') goto yy244;
-						if (yych <= '@') goto yy251;
-						goto yy252;
+						if (yych <= '=') goto yy249;
+						if (yych <= '@') goto yy256;
+						goto yy257;
 					}
 				}
 			}
 		} else {
 			if (yych <= 'e') {
 				if (yych <= 'Z') {
-					if (yych <= 'F') goto yy266;
-					if (yych == 'N') goto yy260;
-					goto yy252;
+					if (yych <= 'F') goto yy271;
+					if (yych == 'N') goto yy265;
+					goto yy257;
 				} else {
-					if (yych == '_') goto yy252;
-					if (yych <= '`') goto yy251;
-					goto yy252;
+					if (yych == '_') goto yy257;
+					if (yych <= '`') goto yy256;
+					goto yy257;
 				}
 			} else {
 				if (yych <= 'z') {
-					if (yych <= 'f') goto yy266;
-					if (yych == 'n') goto yy260;
-					goto yy252;
+					if (yych <= 'f') goto yy271;
+					if (yych == 'n') goto yy265;
+					goto yy257;
 				} else {
 					if (yych <= '|') {
-						if (yych <= '{') goto yy251;
-						goto yy244;
+						if (yych <= '{') goto yy256;
+						goto yy249;
 					} else {
-						if (yych == '~') goto yy244;
-						goto yy251;
+						if (yych == '~') goto yy249;
+						goto yy256;
 					}
 				}
 			}
 		}
-yy248:
-		YYDEBUG(248, *YYCURSOR);
+yy253:
+		YYDEBUG(253, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'R') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'Q') goto yy252;
-					goto yy264;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'Q') goto yy257;
+					goto yy269;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'r') goto yy264;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'r') goto yy269;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy249:
-		YYDEBUG(249, *YYCURSOR);
+yy254:
+		YYDEBUG(254, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'E') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'D') goto yy252;
-					goto yy254;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'D') goto yy257;
+					goto yy259;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'e') goto yy254;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'e') goto yy259;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy250:
-		YYDEBUG(250, *YYCURSOR);
+yy255:
+		YYDEBUG(255, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy251:
-		YYDEBUG(251, *YYCURSOR);
+yy256:
+		YYDEBUG(256, *YYCURSOR);
 		if (yybm[0+yych] & 2) {
-			goto yy250;
+			goto yy255;
 		}
-		if (yych == '$') goto yy255;
-		goto yy224;
-yy252:
-		YYDEBUG(252, *YYCURSOR);
+		if (yych == '$') goto yy260;
+		goto yy229;
+yy257:
+		YYDEBUG(257, *YYCURSOR);
 		yyaccept = 4;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(253, *YYCURSOR);
+		YYDEBUG(258, *YYCURSOR);
 		if (yybm[0+yych] & 4) {
-			goto yy252;
+			goto yy257;
 		}
 		if (yych <= '%') {
 			if (yych <= '\r') {
 				if (yych <= 0x08) {
-					if (yych <= 0x00) goto yy244;
-					goto yy250;
+					if (yych <= 0x00) goto yy249;
+					goto yy255;
 				} else {
-					if (yych <= '\n') goto yy244;
-					if (yych <= '\f') goto yy250;
-					goto yy244;
+					if (yych <= '\n') goto yy249;
+					if (yych <= '\f') goto yy255;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '"') {
-					if (yych <= 0x1F) goto yy250;
-					goto yy244;
+					if (yych <= 0x1F) goto yy255;
+					goto yy249;
 				} else {
-					if (yych == '$') goto yy255;
-					goto yy250;
+					if (yych == '$') goto yy260;
+					goto yy255;
 				}
 			}
 		} else {
 			if (yych <= '=') {
 				if (yych <= ':') {
-					if (yych <= ')') goto yy244;
-					goto yy250;
+					if (yych <= ')') goto yy249;
+					goto yy255;
 				} else {
-					if (yych == '<') goto yy250;
-					goto yy244;
+					if (yych == '<') goto yy255;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '{') goto yy250;
-					goto yy244;
+					if (yych <= '{') goto yy255;
+					goto yy249;
 				} else {
-					if (yych == '~') goto yy244;
-					goto yy250;
+					if (yych == '~') goto yy249;
+					goto yy255;
 				}
 			}
 		}
-yy254:
-		YYDEBUG(254, *YYCURSOR);
+yy259:
+		YYDEBUG(259, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'S') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'R') goto yy252;
-					goto yy260;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'R') goto yy257;
+					goto yy265;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 's') goto yy260;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 's') goto yy265;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy255:
-		YYDEBUG(255, *YYCURSOR);
+yy260:
+		YYDEBUG(260, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yych <= '\\') {
-			if (yych <= 0x00) goto yy256;
-			if (yych <= '[') goto yy250;
-			goto yy257;
+			if (yych <= 0x00) goto yy261;
+			if (yych <= '[') goto yy255;
+			goto yy262;
 		} else {
-			if (yych != '{') goto yy250;
+			if (yych != '{') goto yy255;
 		}
-yy256:
-		YYDEBUG(256, *YYCURSOR);
+yy261:
+		YYDEBUG(261, *YYCURSOR);
 		YYCURSOR = YYMARKER;
 		if (yyaccept <= 3) {
 			if (yyaccept <= 1) {
 				if (yyaccept <= 0) {
-					goto yy224;
+					goto yy229;
 				} else {
-					goto yy226;
+					goto yy231;
 				}
 			} else {
 				if (yyaccept <= 2) {
-					goto yy222;
+					goto yy227;
 				} else {
-					goto yy239;
+					goto yy244;
 				}
 			}
 		} else {
 			if (yyaccept <= 5) {
 				if (yyaccept <= 4) {
-					goto yy244;
+					goto yy249;
 				} else {
-					goto yy261;
+					goto yy266;
 				}
 			} else {
-				goto yy268;
+				goto yy273;
 			}
 		}
-yy257:
-		YYDEBUG(257, *YYCURSOR);
+yy262:
+		YYDEBUG(262, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yybm[0+yych] & 8) {
-			goto yy258;
+			goto yy263;
 		}
-		goto yy250;
-yy258:
-		YYDEBUG(258, *YYCURSOR);
+		goto yy255;
+yy263:
+		YYDEBUG(263, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(259, *YYCURSOR);
+		YYDEBUG(264, *YYCURSOR);
 		if (yybm[0+yych] & 8) {
-			goto yy258;
+			goto yy263;
 		}
-		if (yych <= 0x00) goto yy224;
-		if (yych == '\\') goto yy257;
-		goto yy250;
-yy260:
-		YYDEBUG(260, *YYCURSOR);
+		if (yych <= 0x00) goto yy229;
+		if (yych == '\\') goto yy262;
+		goto yy255;
+yy265:
+		YYDEBUG(265, *YYCURSOR);
 		yyaccept = 5;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 16) {
-			goto yy262;
+			goto yy267;
 		}
 		if (yych <= ';') {
 			if (yych <= ' ') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy261;
-					if (yych <= '\t') goto yy251;
+					if (yych <= 0x00) goto yy266;
+					if (yych <= '\t') goto yy256;
 				} else {
-					if (yych != '\r') goto yy251;
+					if (yych != '\r') goto yy256;
 				}
 			} else {
 				if (yych <= ')') {
-					if (yych <= '"') goto yy261;
-					if (yych <= '%') goto yy251;
+					if (yych <= '"') goto yy266;
+					if (yych <= '%') goto yy256;
 				} else {
-					if (yych <= '/') goto yy251;
-					if (yych <= '9') goto yy252;
-					if (yych <= ':') goto yy251;
+					if (yych <= '/') goto yy256;
+					if (yych <= '9') goto yy257;
+					if (yych <= ':') goto yy256;
 				}
 			}
 		} else {
 			if (yych <= '_') {
 				if (yych <= '@') {
-					if (yych != '=') goto yy251;
+					if (yych != '=') goto yy256;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych <= '^') goto yy251;
-					goto yy252;
+					if (yych <= 'Z') goto yy257;
+					if (yych <= '^') goto yy256;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych <= '`') goto yy251;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych <= '`') goto yy256;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych >= 0x7F) goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych >= 0x7F) goto yy256;
 				}
 			}
 		}
-yy261:
-		YYDEBUG(261, *YYCURSOR);
+yy266:
+		YYDEBUG(266, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 398 "Zend/zend_ini_scanner.l"
+#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 3481 "Zend/zend_ini_scanner.c"
-yy262:
-		YYDEBUG(262, *YYCURSOR);
+#line 3588 "Zend/zend_ini_scanner.c"
+yy267:
+		YYDEBUG(267, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(263, *YYCURSOR);
+		YYDEBUG(268, *YYCURSOR);
 		if (yybm[0+yych] & 16) {
-			goto yy262;
+			goto yy267;
 		}
-		goto yy261;
-yy264:
-		YYDEBUG(264, *YYCURSOR);
+		goto yy266;
+yy269:
+		YYDEBUG(269, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'U') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'T') goto yy252;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'T') goto yy257;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'u') goto yy265;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'u') goto yy270;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy265:
-		YYDEBUG(265, *YYCURSOR);
+yy270:
+		YYDEBUG(270, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'E') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'D') goto yy252;
-					goto yy260;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'D') goto yy257;
+					goto yy265;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'e') goto yy260;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'e') goto yy265;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy266:
-		YYDEBUG(266, *YYCURSOR);
+yy271:
+		YYDEBUG(271, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'F') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'E') goto yy252;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'E') goto yy257;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'f') goto yy267;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'f') goto yy272;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy267:
-		YYDEBUG(267, *YYCURSOR);
+yy272:
+		YYDEBUG(272, *YYCURSOR);
 		yyaccept = 6;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 4) {
-			goto yy252;
+			goto yy257;
 		}
 		if (yych <= '%') {
 			if (yych <= '\f') {
 				if (yych <= 0x08) {
-					if (yych >= 0x01) goto yy251;
+					if (yych >= 0x01) goto yy256;
 				} else {
-					if (yych <= '\t') goto yy269;
-					if (yych >= '\v') goto yy251;
+					if (yych <= '\t') goto yy274;
+					if (yych >= '\v') goto yy256;
 				}
 			} else {
 				if (yych <= 0x1F) {
-					if (yych >= 0x0E) goto yy251;
+					if (yych >= 0x0E) goto yy256;
 				} else {
-					if (yych <= ' ') goto yy269;
-					if (yych >= '#') goto yy251;
+					if (yych <= ' ') goto yy274;
+					if (yych >= '#') goto yy256;
 				}
 			}
 		} else {
 			if (yych <= '=') {
 				if (yych <= ':') {
-					if (yych >= '*') goto yy251;
+					if (yych >= '*') goto yy256;
 				} else {
-					if (yych == '<') goto yy251;
+					if (yych == '<') goto yy256;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '{') goto yy251;
+					if (yych <= '{') goto yy256;
 				} else {
-					if (yych != '~') goto yy251;
+					if (yych != '~') goto yy256;
 				}
 			}
 		}
-yy268:
-		YYDEBUG(268, *YYCURSOR);
+yy273:
+		YYDEBUG(273, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 402 "Zend/zend_ini_scanner.l"
+#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 3685 "Zend/zend_ini_scanner.c"
-yy269:
-		YYDEBUG(269, *YYCURSOR);
+#line 3792 "Zend/zend_ini_scanner.c"
+yy274:
+		YYDEBUG(274, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(270, *YYCURSOR);
-		if (yych == '\t') goto yy269;
-		if (yych == ' ') goto yy269;
-		goto yy268;
-yy271:
-		YYDEBUG(271, *YYCURSOR);
+		YYDEBUG(275, *YYCURSOR);
+		if (yych == '\t') goto yy274;
+		if (yych == ' ') goto yy274;
+		goto yy273;
+yy276:
+		YYDEBUG(276, *YYCURSOR);
 		yyaccept = 6;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '<') {
 			if (yych <= ' ') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy268;
-					if (yych <= 0x08) goto yy251;
-					if (yych <= '\t') goto yy269;
-					goto yy268;
+					if (yych <= 0x00) goto yy273;
+					if (yych <= 0x08) goto yy256;
+					if (yych <= '\t') goto yy274;
+					goto yy273;
 				} else {
-					if (yych == '\r') goto yy268;
-					if (yych <= 0x1F) goto yy251;
-					goto yy269;
+					if (yych == '\r') goto yy273;
+					if (yych <= 0x1F) goto yy256;
+					goto yy274;
 				}
 			} else {
 				if (yych <= '/') {
-					if (yych <= '"') goto yy268;
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy268;
-					goto yy251;
+					if (yych <= '"') goto yy273;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy273;
+					goto yy256;
 				} else {
-					if (yych <= '9') goto yy252;
-					if (yych == ';') goto yy268;
-					goto yy251;
+					if (yych <= '9') goto yy257;
+					if (yych == ';') goto yy273;
+					goto yy256;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'N') {
-					if (yych <= '=') goto yy268;
-					if (yych <= '@') goto yy251;
-					if (yych <= 'M') goto yy252;
-					goto yy274;
+					if (yych <= '=') goto yy273;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'M') goto yy257;
+					goto yy279;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'n') goto yy274;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'n') goto yy279;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy268;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy273;
+					goto yy256;
 				}
 			}
 		}
-yy272:
-		YYDEBUG(272, *YYCURSOR);
+yy277:
+		YYDEBUG(277, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'L') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'K') goto yy252;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'K') goto yy257;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'l') goto yy273;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'l') goto yy278;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy273:
-		YYDEBUG(273, *YYCURSOR);
+yy278:
+		YYDEBUG(278, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'L') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'K') goto yy252;
-					goto yy267;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'K') goto yy257;
+					goto yy272;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'l') goto yy267;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'l') goto yy272;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy274:
-		YYDEBUG(274, *YYCURSOR);
+yy279:
+		YYDEBUG(279, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'E') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'D') goto yy252;
-					goto yy267;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'D') goto yy257;
+					goto yy272;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'e') goto yy267;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'e') goto yy272;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy275:
-		YYDEBUG(275, *YYCURSOR);
+yy280:
+		YYDEBUG(280, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'L') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'K') goto yy252;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'K') goto yy257;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'l') goto yy276;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'l') goto yy281;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy276:
-		YYDEBUG(276, *YYCURSOR);
+yy281:
+		YYDEBUG(281, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'S') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'R') goto yy252;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'R') goto yy257;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 's') goto yy277;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 's') goto yy282;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy277:
-		YYDEBUG(277, *YYCURSOR);
+yy282:
+		YYDEBUG(282, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy251;
-					goto yy244;
+					if (yych <= 0x00) goto yy249;
+					if (yych <= 0x08) goto yy256;
+					goto yy249;
 				} else {
-					if (yych == '\r') goto yy244;
-					if (yych <= 0x1F) goto yy251;
-					goto yy244;
+					if (yych == '\r') goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy249;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy251;
-					if (yych <= ')') goto yy244;
-					if (yych <= '/') goto yy251;
-					goto yy252;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy249;
+					if (yych <= '/') goto yy256;
+					goto yy257;
 				} else {
-					if (yych == ';') goto yy244;
-					if (yych <= '<') goto yy251;
-					goto yy244;
+					if (yych == ';') goto yy249;
+					if (yych <= '<') goto yy256;
+					goto yy249;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'E') {
-					if (yych <= '@') goto yy251;
-					if (yych <= 'D') goto yy252;
-					goto yy267;
+					if (yych <= '@') goto yy256;
+					if (yych <= 'D') goto yy257;
+					goto yy272;
 				} else {
-					if (yych <= 'Z') goto yy252;
-					if (yych == '_') goto yy252;
-					goto yy251;
+					if (yych <= 'Z') goto yy257;
+					if (yych == '_') goto yy257;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'e') goto yy267;
-					if (yych <= 'z') goto yy252;
-					goto yy251;
+					if (yych == 'e') goto yy272;
+					if (yych <= 'z') goto yy257;
+					goto yy256;
 				} else {
-					if (yych == '}') goto yy251;
-					if (yych <= '~') goto yy244;
-					goto yy251;
+					if (yych == '}') goto yy256;
+					if (yych <= '~') goto yy249;
+					goto yy256;
 				}
 			}
 		}
-yy278:
-		YYDEBUG(278, *YYCURSOR);
+yy283:
+		YYDEBUG(283, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy279:
-		YYDEBUG(279, *YYCURSOR);
+yy284:
+		YYDEBUG(284, *YYCURSOR);
 		if (yybm[0+yych] & 32) {
-			goto yy278;
+			goto yy283;
 		}
-		if (yych >= '\r') goto yy282;
-yy280:
-		YYDEBUG(280, *YYCURSOR);
+		if (yych >= '\r') goto yy287;
+yy285:
+		YYDEBUG(285, *YYCURSOR);
 		++YYCURSOR;
-yy281:
-		YYDEBUG(281, *YYCURSOR);
+yy286:
+		YYDEBUG(286, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 528 "Zend/zend_ini_scanner.l"
+#line 554 "Zend/zend_ini_scanner.l"
 		{ /* Comment */
 	BEGIN(INITIAL);
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 4067 "Zend/zend_ini_scanner.c"
-yy282:
-		YYDEBUG(282, *YYCURSOR);
+#line 4174 "Zend/zend_ini_scanner.c"
+yy287:
+		YYDEBUG(287, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy280;
-		goto yy281;
-yy283:
-		YYDEBUG(283, *YYCURSOR);
+		if (yych == '\n') goto yy285;
+		goto yy286;
+yy288:
+		YYDEBUG(288, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(284, *YYCURSOR);
+		YYDEBUG(289, *YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy283;
+			goto yy288;
 		}
 		if (yych <= '%') {
 			if (yych <= '\r') {
 				if (yych <= 0x08) {
-					if (yych <= 0x00) goto yy239;
-					goto yy250;
+					if (yych <= 0x00) goto yy244;
+					goto yy255;
 				} else {
-					if (yych <= '\n') goto yy239;
-					if (yych <= '\f') goto yy250;
-					goto yy239;
+					if (yych <= '\n') goto yy244;
+					if (yych <= '\f') goto yy255;
+					goto yy244;
 				}
 			} else {
 				if (yych <= '"') {
-					if (yych <= 0x1F) goto yy250;
-					goto yy239;
+					if (yych <= 0x1F) goto yy255;
+					goto yy244;
 				} else {
-					if (yych == '$') goto yy255;
-					goto yy250;
+					if (yych == '$') goto yy260;
+					goto yy255;
 				}
 			}
 		} else {
 			if (yych <= '=') {
 				if (yych <= ':') {
-					if (yych <= ')') goto yy239;
-					goto yy250;
+					if (yych <= ')') goto yy244;
+					goto yy255;
 				} else {
-					if (yych == '<') goto yy250;
-					goto yy239;
+					if (yych == '<') goto yy255;
+					goto yy244;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '{') goto yy250;
-					goto yy239;
+					if (yych <= '{') goto yy255;
+					goto yy244;
 				} else {
-					if (yych == '~') goto yy239;
-					goto yy250;
+					if (yych == '~') goto yy244;
+					goto yy255;
 				}
 			}
 		}
-yy285:
-		YYDEBUG(285, *YYCURSOR);
+yy290:
+		YYDEBUG(290, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(286, *YYCURSOR);
+		YYDEBUG(291, *YYCURSOR);
 		if (yych <= '-') {
 			if (yych <= 0x1F) {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy239;
-					if (yych <= 0x08) goto yy250;
-					goto yy239;
+					if (yych <= 0x00) goto yy244;
+					if (yych <= 0x08) goto yy255;
+					goto yy244;
 				} else {
-					if (yych == '\r') goto yy239;
-					goto yy250;
+					if (yych == '\r') goto yy244;
+					goto yy255;
 				}
 			} else {
 				if (yych <= '$') {
-					if (yych <= '"') goto yy239;
-					if (yych <= '#') goto yy250;
-					goto yy255;
+					if (yych <= '"') goto yy244;
+					if (yych <= '#') goto yy255;
+					goto yy260;
 				} else {
-					if (yych <= '%') goto yy250;
-					if (yych <= ')') goto yy239;
-					goto yy250;
+					if (yych <= '%') goto yy255;
+					if (yych <= ')') goto yy244;
+					goto yy255;
 				}
 			}
 		} else {
 			if (yych <= '<') {
 				if (yych <= '9') {
-					if (yych <= '.') goto yy283;
-					if (yych <= '/') goto yy250;
-					goto yy285;
+					if (yych <= '.') goto yy288;
+					if (yych <= '/') goto yy255;
+					goto yy290;
 				} else {
-					if (yych == ';') goto yy239;
-					goto yy250;
+					if (yych == ';') goto yy244;
+					goto yy255;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '=') goto yy239;
-					if (yych <= '{') goto yy250;
-					goto yy239;
+					if (yych <= '=') goto yy244;
+					if (yych <= '{') goto yy255;
+					goto yy244;
 				} else {
-					if (yych == '~') goto yy239;
-					goto yy250;
+					if (yych == '~') goto yy244;
+					goto yy255;
 				}
 			}
 		}
-yy287:
-		YYDEBUG(287, *YYCURSOR);
+yy292:
+		YYDEBUG(292, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(288, *YYCURSOR);
+		YYDEBUG(293, *YYCURSOR);
 		if (yych <= ')') {
 			if (yych <= '\r') {
 				if (yych <= 0x08) {
-					if (yych <= 0x00) goto yy239;
-					goto yy250;
+					if (yych <= 0x00) goto yy244;
+					goto yy255;
 				} else {
-					if (yych <= '\n') goto yy239;
-					if (yych <= '\f') goto yy250;
-					goto yy239;
+					if (yych <= '\n') goto yy244;
+					if (yych <= '\f') goto yy255;
+					goto yy244;
 				}
 			} else {
 				if (yych <= '#') {
-					if (yych <= 0x1F) goto yy250;
-					if (yych <= '"') goto yy239;
-					goto yy250;
+					if (yych <= 0x1F) goto yy255;
+					if (yych <= '"') goto yy244;
+					goto yy255;
 				} else {
-					if (yych <= '$') goto yy255;
-					if (yych <= '%') goto yy250;
-					goto yy239;
+					if (yych <= '$') goto yy260;
+					if (yych <= '%') goto yy255;
+					goto yy244;
 				}
 			}
 		} else {
 			if (yych <= '<') {
 				if (yych <= '9') {
-					if (yych <= '/') goto yy250;
-					goto yy287;
+					if (yych <= '/') goto yy255;
+					goto yy292;
 				} else {
-					if (yych == ';') goto yy239;
-					goto yy250;
+					if (yych == ';') goto yy244;
+					goto yy255;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '=') goto yy239;
-					if (yych <= '{') goto yy250;
-					goto yy239;
+					if (yych <= '=') goto yy244;
+					if (yych <= '{') goto yy255;
+					goto yy244;
 				} else {
-					if (yych == '~') goto yy239;
-					goto yy250;
+					if (yych == '~') goto yy244;
+					goto yy255;
 				}
 			}
 		}
-yy289:
-		YYDEBUG(289, *YYCURSOR);
+yy294:
+		YYDEBUG(294, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(290, *YYCURSOR);
+		YYDEBUG(295, *YYCURSOR);
 		if (yych <= ')') {
 			if (yych <= '\r') {
 				if (yych <= 0x08) {
-					if (yych <= 0x00) goto yy239;
-					goto yy250;
+					if (yych <= 0x00) goto yy244;
+					goto yy255;
 				} else {
-					if (yych <= '\n') goto yy239;
-					if (yych <= '\f') goto yy250;
-					goto yy239;
+					if (yych <= '\n') goto yy244;
+					if (yych <= '\f') goto yy255;
+					goto yy244;
 				}
 			} else {
 				if (yych <= '#') {
-					if (yych <= 0x1F) goto yy250;
-					if (yych <= '"') goto yy239;
-					goto yy250;
+					if (yych <= 0x1F) goto yy255;
+					if (yych <= '"') goto yy244;
+					goto yy255;
 				} else {
-					if (yych <= '$') goto yy255;
-					if (yych <= '%') goto yy250;
-					goto yy239;
+					if (yych <= '$') goto yy260;
+					if (yych <= '%') goto yy255;
+					goto yy244;
 				}
 			}
 		} else {
 			if (yych <= '<') {
 				if (yych <= '9') {
-					if (yych <= '/') goto yy250;
-					goto yy289;
+					if (yych <= '/') goto yy255;
+					goto yy294;
 				} else {
-					if (yych == ';') goto yy239;
-					goto yy250;
+					if (yych == ';') goto yy244;
+					goto yy255;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '=') goto yy239;
-					if (yych <= '{') goto yy250;
-					goto yy239;
+					if (yych <= '=') goto yy244;
+					if (yych <= '{') goto yy255;
+					goto yy244;
 				} else {
-					if (yych == '~') goto yy239;
-					goto yy250;
+					if (yych == '~') goto yy244;
+					goto yy255;
 				}
 			}
 		}
-yy291:
-		YYDEBUG(291, *YYCURSOR);
+yy296:
+		YYDEBUG(296, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(292, *YYCURSOR);
+		YYDEBUG(297, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy291;
+			goto yy296;
 		}
-		YYDEBUG(293, *YYCURSOR);
+		YYDEBUG(298, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(294, *YYCURSOR);
+		YYDEBUG(299, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 354 "Zend/zend_ini_scanner.l"
+#line 365 "Zend/zend_ini_scanner.l"
 		{ /* Raw string */
 	/* Eat leading and trailing single quotes */
 	if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
@@ -4284,66 +4391,66 @@ yy291:
 	}
 	RETURN_TOKEN(TC_RAW, yytext, yyleng);
 }
-#line 4288 "Zend/zend_ini_scanner.c"
-yy295:
-		YYDEBUG(295, *YYCURSOR);
+#line 4395 "Zend/zend_ini_scanner.c"
+yy300:
+		YYDEBUG(300, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(296, *YYCURSOR);
+		YYDEBUG(301, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 384 "Zend/zend_ini_scanner.l"
+#line 398 "Zend/zend_ini_scanner.l"
 		{ /* Variable start */
 	yy_push_state(ST_VARNAME TSRMLS_CC);
 	return TC_DOLLAR_CURLY;
 }
-#line 4299 "Zend/zend_ini_scanner.c"
-yy297:
-		YYDEBUG(297, *YYCURSOR);
+#line 4406 "Zend/zend_ini_scanner.c"
+yy302:
+		YYDEBUG(302, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy298:
-		YYDEBUG(298, *YYCURSOR);
-		if (yych == '\t') goto yy297;
-		if (yych == ' ') goto yy297;
-		goto yy231;
-yy299:
-		YYDEBUG(299, *YYCURSOR);
+yy303:
+		YYDEBUG(303, *YYCURSOR);
+		if (yych == '\t') goto yy302;
+		if (yych == ' ') goto yy302;
+		goto yy236;
+yy304:
+		YYDEBUG(304, *YYCURSOR);
 		yych = *++YYCURSOR;
-		goto yy228;
-yy300:
-		YYDEBUG(300, *YYCURSOR);
+		goto yy233;
+yy305:
+		YYDEBUG(305, *YYCURSOR);
 		yyaccept = 1;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy301:
-		YYDEBUG(301, *YYCURSOR);
+yy306:
+		YYDEBUG(306, *YYCURSOR);
 		if (yych <= 0x1F) {
 			if (yych <= '\n') {
-				if (yych <= 0x08) goto yy226;
-				if (yych <= '\t') goto yy300;
-				goto yy299;
+				if (yych <= 0x08) goto yy231;
+				if (yych <= '\t') goto yy305;
+				goto yy304;
 			} else {
-				if (yych == '\r') goto yy303;
-				goto yy226;
+				if (yych == '\r') goto yy308;
+				goto yy231;
 			}
 		} else {
 			if (yych <= '"') {
-				if (yych <= ' ') goto yy300;
-				if (yych <= '!') goto yy226;
+				if (yych <= ' ') goto yy305;
+				if (yych <= '!') goto yy231;
 			} else {
-				if (yych == ';') goto yy278;
-				goto yy226;
+				if (yych == ';') goto yy283;
+				goto yy231;
 			}
 		}
-		YYDEBUG(302, *YYCURSOR);
+		YYDEBUG(307, *YYCURSOR);
 		yych = *++YYCURSOR;
-		goto yy233;
-yy303:
-		YYDEBUG(303, *YYCURSOR);
+		goto yy238;
+yy308:
+		YYDEBUG(308, *YYCURSOR);
 		++YYCURSOR;
-		if ((yych = *YYCURSOR) == '\n') goto yy299;
-		goto yy228;
+		if ((yych = *YYCURSOR) == '\n') goto yy304;
+		goto yy233;
 	}
 /* *********************************** */
 yyc_ST_VARNAME:
@@ -4353,7 +4460,7 @@ yyc_ST_VARNAME:
 			128,   0,   0, 128, 128,   0, 128, 128, 
 			128, 128, 128, 128, 128, 128, 128, 128, 
 			128, 128, 128, 128, 128, 128, 128, 128, 
-			  0,   0,   0, 128,   0, 128,   0, 128, 
+			128,   0,   0, 128,   0, 128,   0, 128, 
 			  0,   0, 128, 128, 128, 128, 128, 128, 
 			128, 128, 128, 128, 128, 128, 128, 128, 
 			128, 128, 128,   0, 128,   0, 128, 128, 
@@ -4382,87 +4489,93 @@ yyc_ST_VARNAME:
 			128, 128, 128, 128, 128, 128, 128, 128, 
 			128, 128, 128, 128, 128, 128, 128, 128, 
 		};
-		YYDEBUG(304, *YYCURSOR);
+		YYDEBUG(309, *YYCURSOR);
 		YYFILL(2);
 		yych = *YYCURSOR;
 		if (yych <= '\'') {
-			if (yych <= 0x1F) {
+			if (yych <= ' ') {
 				if (yych <= '\n') {
-					if (yych >= '\t') goto yy308;
+					if (yych >= '\t') goto yy313;
 				} else {
-					if (yych == '\r') goto yy308;
+					if (yych == '\r') goto yy313;
 				}
 			} else {
 				if (yych <= '$') {
-					if (yych != '#') goto yy308;
+					if (yych != '#') goto yy313;
 				} else {
-					if (yych == '&') goto yy308;
+					if (yych == '&') goto yy313;
 				}
 			}
 		} else {
 			if (yych <= 'Z') {
 				if (yych <= ';') {
-					if (yych <= ')') goto yy308;
-					if (yych >= ';') goto yy308;
+					if (yych <= ')') goto yy313;
+					if (yych >= ';') goto yy313;
 				} else {
-					if (yych == '=') goto yy308;
+					if (yych == '=') goto yy313;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '[') goto yy308;
-					if (yych >= '{') goto yy308;
+					if (yych <= '[') goto yy313;
+					if (yych >= '{') goto yy313;
 				} else {
-					if (yych <= '}') goto yy310;
-					if (yych <= '~') goto yy308;
+					if (yych <= '}') goto yy315;
+					if (yych <= '~') goto yy313;
 				}
 			}
 		}
-		YYDEBUG(306, *YYCURSOR);
+		YYDEBUG(311, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy313;
-yy307:
-		YYDEBUG(307, *YYCURSOR);
+		goto yy318;
+yy312:
+		YYDEBUG(312, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 389 "Zend/zend_ini_scanner.l"
+#line 403 "Zend/zend_ini_scanner.l"
 		{ /* Variable name */
+	/* Eat leading whitespace */
+	EAT_LEADING_WHITESPACE();
+
+	/* Eat trailing whitespace */
+	EAT_TRAILING_WHITESPACE();
+
 	RETURN_TOKEN(TC_VARNAME, yytext, yyleng);
 }
-#line 4432 "Zend/zend_ini_scanner.c"
-yy308:
-		YYDEBUG(308, *YYCURSOR);
+#line 4545 "Zend/zend_ini_scanner.c"
+yy313:
+		YYDEBUG(313, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(309, *YYCURSOR);
+		YYDEBUG(314, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 546 "Zend/zend_ini_scanner.l"
+#line 572 "Zend/zend_ini_scanner.l"
 		{
 	return 0;
 }
-#line 4442 "Zend/zend_ini_scanner.c"
-yy310:
-		YYDEBUG(310, *YYCURSOR);
+#line 4555 "Zend/zend_ini_scanner.c"
+yy315:
+		YYDEBUG(315, *YYCURSOR);
 		++YYCURSOR;
-		YYDEBUG(311, *YYCURSOR);
+		YYDEBUG(316, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 393 "Zend/zend_ini_scanner.l"
+#line 413 "Zend/zend_ini_scanner.l"
 		{ /* Variable end */
 	yy_pop_state(TSRMLS_C);
 	return '}';
 }
-#line 4453 "Zend/zend_ini_scanner.c"
-yy312:
-		YYDEBUG(312, *YYCURSOR);
+#line 4566 "Zend/zend_ini_scanner.c"
+yy317:
+		YYDEBUG(317, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy313:
-		YYDEBUG(313, *YYCURSOR);
+yy318:
+		YYDEBUG(318, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy312;
+			goto yy317;
 		}
-		goto yy307;
+		goto yy312;
 	}
 }
-#line 550 "Zend/zend_ini_scanner.l"
+#line 576 "Zend/zend_ini_scanner.l"
 
 }
diff --git a/Zend/zend_ini_scanner.h b/Zend/zend_ini_scanner.h
index f3109b1..07d1102 100644
--- a/Zend/zend_ini_scanner.h
+++ b/Zend/zend_ini_scanner.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini_scanner.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_ini_scanner.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef _ZEND_INI_SCANNER_H
 #define _ZEND_INI_SCANNER_H
diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l
index e87c6d7..998665b 100644
--- a/Zend/zend_ini_scanner.l
+++ b/Zend/zend_ini_scanner.l
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini_scanner.l 286913 2009-08-07 15:44:37Z jani $ */
+/* $Id: zend_ini_scanner.l 294698 2010-02-07 12:08:22Z pajoye $ */
 
 #include <errno.h>
 #include "zend.h"
@@ -105,6 +105,17 @@ ZEND_API ts_rsrc_id ini_scanner_globals_id;
 ZEND_API zend_ini_scanner_globals ini_scanner_globals;
 #endif
 
+/* Eat leading whitespace */
+#define EAT_LEADING_WHITESPACE()                     \
+	while (yytext[0]) {                              \
+		if (yytext[0] == ' ' || yytext[0] == '\t') { \
+			SCNG(yy_text)++;                         \
+			yyleng--;                                \
+		} else {                                     \
+			break;                                   \
+		}                                            \
+	}
+
 /* Eat trailing whitespace + extra char */
 #define EAT_TRAILING_WHITESPACE_EX(ch)              \
 	while (yyleng > 0 && (                          \
@@ -325,8 +336,8 @@ ANY_CHAR (.|[\n\t])
 NEWLINE	("\r"|"\n"|"\r\n")
 TABS_AND_SPACES [ \t]
 WHITESPACE [ \t]+
-CONSTANT [a-zA-Z][a-zA-Z0-9_]*
-LABEL [^=\n\r\t ;|&$~(){}!"\[]+
+CONSTANT [a-zA-Z_][a-zA-Z0-9_]*
+LABEL [^=\n\r\t;|&$~(){}!"\[]+
 TOKENS [:,.\[\]"'()|^&+-/*=%$!~<>?@{}]
 OPERATORS [&|~()!]
 DOLLAR_CURLY "${"
@@ -367,6 +378,9 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
 }
 
 <INITIAL>{LABEL}"["{TABS_AND_SPACES}* { /* Start of option with offset */
+	/* Eat leading whitespace */
+	EAT_LEADING_WHITESPACE();
+	
 	/* Eat trailing whitespace and [ */
 	EAT_TRAILING_WHITESPACE_EX('[');
 
@@ -387,6 +401,12 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
 }
 
 <ST_VARNAME>{LABEL} { /* Variable name */
+	/* Eat leading whitespace */
+	EAT_LEADING_WHITESPACE();
+
+	/* Eat trailing whitespace */
+	EAT_TRAILING_WHITESPACE();
+
 	RETURN_TOKEN(TC_VARNAME, yytext, yyleng);
 }
 
@@ -404,6 +424,12 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
 }
 
 <INITIAL>{LABEL} { /* Get option name */
+	/* Eat leading whitespace */
+	EAT_LEADING_WHITESPACE();
+
+	/* Eat trailing whitespace */
+	EAT_TRAILING_WHITESPACE();
+
 	RETURN_TOKEN(TC_LABEL, yytext, yyleng);
 }
 
diff --git a/Zend/zend_ini_scanner_defs.h b/Zend/zend_ini_scanner_defs.h
index 280132a..1956b62 100644
--- a/Zend/zend_ini_scanner_defs.h
+++ b/Zend/zend_ini_scanner_defs.h
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Fri Aug  7 18:29:12 2009 */
+/* Generated by re2c 0.13.5 on Sun Feb  7 13:25:37 2010 */
 #line 3 "Zend/zend_ini_scanner_defs.h"
 
 enum YYCONDTYPE {
diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c
index c14c524..7dc47b1 100755
--- a/Zend/zend_interfaces.c
+++ b/Zend/zend_interfaces.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_interfaces.c 277750 2009-03-25 10:39:26Z dmitry $ */
+/* $Id: zend_interfaces.c 294549 2010-02-05 00:37:07Z pajoye $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -353,6 +353,10 @@ static int zend_implement_aggregate(zend_class_entry *interface, zend_class_entr
 			if (class_type->num_interfaces) {
 				for (i = 0; i < class_type->num_interfaces; i++) {
 					if (class_type->interfaces[i] == zend_ce_iterator) {
+						zend_error(E_ERROR, "Class %s cannot implement both %s and %s at the same time",
+									class_type->name,
+									interface->name,
+									zend_ce_iterator->name);
 						return FAILURE;
 					}
 					if (class_type->interfaces[i] == zend_ce_traversable) {
@@ -378,8 +382,14 @@ static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry
 		if (class_type->type == ZEND_INTERNAL_CLASS) {
 			/* inheritance ensures the class has the necessary userland methods */
 			return SUCCESS;
-		} else if (class_type->get_iterator != zend_user_it_get_new_iterator) {
+		} else {
 			/* c-level get_iterator cannot be changed */
+			if (class_type->get_iterator == zend_user_it_get_new_iterator) {
+				zend_error(E_ERROR, "Class %s cannot implement both %s and %s at the same time",
+							class_type->name,
+							interface->name,
+							zend_ce_aggregate->name);
+			}
 			return FAILURE;
 		}
 	}
diff --git a/Zend/zend_interfaces.h b/Zend/zend_interfaces.h
index 7ff9065..c75e6dd 100755
--- a/Zend/zend_interfaces.h
+++ b/Zend/zend_interfaces.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_interfaces.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_interfaces.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_INTERFACES_H
 #define ZEND_INTERFACES_H
diff --git a/Zend/zend_istdiostream.h b/Zend/zend_istdiostream.h
index da1cfed..4b38a8c 100644
--- a/Zend/zend_istdiostream.h
+++ b/Zend/zend_istdiostream.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_istdiostream.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_istdiostream.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef _ZEND_STDIOSTREAM
 #define _ZEND_STDIOSTREAM
diff --git a/Zend/zend_iterators.c b/Zend/zend_iterators.c
index 9d9f045..76588e2 100755
--- a/Zend/zend_iterators.c
+++ b/Zend/zend_iterators.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_iterators.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_iterators.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_API.h"
diff --git a/Zend/zend_iterators.h b/Zend/zend_iterators.h
index 6c90d81..b108403 100755
--- a/Zend/zend_iterators.h
+++ b/Zend/zend_iterators.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_iterators.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_iterators.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 /* These iterators were designed to operate within the foreach()
  * structures provided by the engine, but could be extended for use
diff --git a/Zend/zend_language_parser.c b/Zend/zend_language_parser.c
index faf71f8..6461dc1 100644
--- a/Zend/zend_language_parser.c
+++ b/Zend/zend_language_parser.c
@@ -334,7 +334,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -349,7 +349,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_language_parser.y 277815 2009-03-26 12:37:54Z dmitry $ */
+/* $Id: zend_language_parser.y 293154 2010-01-05 20:40:23Z sebastian $ */
 
 /*
  * LALR shift/reduce conflicts and how they are resolved:
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index 5923ff5..2635fdb 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -3,7 +3,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_language_parser.y 277815 2009-03-26 12:37:54Z dmitry $ */
+/* $Id: zend_language_parser.y 293154 2010-01-05 20:40:23Z sebastian $ */
 
 /*
  * LALR shift/reduce conflicts and how they are resolved:
diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c
index 1cb027f..3f5fefa 100644
--- a/Zend/zend_language_scanner.c
+++ b/Zend/zend_language_scanner.c
@@ -1,10 +1,10 @@
-/* Generated by re2c 0.13.5 on Mon May 04 19:38:30 2009 */
+/* Generated by re2c 0.13.5 on Mon Nov 16 23:30:01 2009 */
 #line 1 "Zend/zend_language_scanner.l"
 /*
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -23,7 +23,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_language_scanner.c 279948 2009-05-05 01:44:52Z mattwil $ */
+/* $Id: zend_language_scanner.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #if 0
 # define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c)
@@ -685,12 +685,12 @@ ZEND_API int zend_multibyte_read_script(unsigned char *buf, size_t n TSRMLS_DC)
 {
 	if (SCNG(script_org)) {
 		efree(SCNG(script_org));
+		SCNG(script_org) = NULL;
 	}
-	SCNG(script_org_size) = n;
-	SCNG(script_org) = (unsigned char*)erealloc(SCNG(script_org), SCNG(script_org_size));
-	memcpy(SCNG(script_org) + SCNG(script_org_size) - n, buf, n);
+	SCNG(script_org_size) = n;	
 	
-	SCNG(script_org) = (unsigned char*)erealloc(SCNG(script_org), SCNG(script_org_size) + 1);
+	SCNG(script_org) = (unsigned char*)emalloc(SCNG(script_org_size) + 1);
+	memcpy(SCNG(script_org), buf, n);
 	*(SCNG(script_org)+SCNG(script_org_size)) = '\0';
 
 	return 0;
diff --git a/Zend/zend_language_scanner.h b/Zend/zend_language_scanner.h
index 5add51c..f564c03 100644
--- a/Zend/zend_language_scanner.h
+++ b/Zend/zend_language_scanner.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_language_scanner.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_language_scanner.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_SCANNER_H
 #define ZEND_SCANNER_H
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 9d42299..250d307 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_language_scanner.l 279941 2009-05-05 01:35:44Z mattwil $ */
+/* $Id: zend_language_scanner.l 293154 2010-01-05 20:40:23Z sebastian $ */
 
 #if 0
 # define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c)
@@ -683,12 +683,12 @@ ZEND_API int zend_multibyte_read_script(unsigned char *buf, size_t n TSRMLS_DC)
 {
 	if (SCNG(script_org)) {
 		efree(SCNG(script_org));
+		SCNG(script_org) = NULL;
 	}
-	SCNG(script_org_size) = n;
-	SCNG(script_org) = (unsigned char*)erealloc(SCNG(script_org), SCNG(script_org_size));
-	memcpy(SCNG(script_org) + SCNG(script_org_size) - n, buf, n);
+	SCNG(script_org_size) = n;	
 	
-	SCNG(script_org) = (unsigned char*)erealloc(SCNG(script_org), SCNG(script_org_size) + 1);
+	SCNG(script_org) = (unsigned char*)emalloc(SCNG(script_org_size) + 1);
+	memcpy(SCNG(script_org), buf, n);
 	*(SCNG(script_org)+SCNG(script_org_size)) = '\0';
 
 	return 0;
diff --git a/Zend/zend_language_scanner_defs.h b/Zend/zend_language_scanner_defs.h
index 48bd8d5..b2bce82 100644
--- a/Zend/zend_language_scanner_defs.h
+++ b/Zend/zend_language_scanner_defs.h
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Mon May 04 19:38:30 2009 */
+/* Generated by re2c 0.13.5 on Thu Sep 10 15:34:33 2009 */
 #line 3 "Zend/zend_language_scanner_defs.h"
 
 enum YYCONDTYPE {
diff --git a/Zend/zend_list.c b/Zend/zend_list.c
index 2f71ea7..985a1fb 100644
--- a/Zend/zend_list.c
+++ b/Zend/zend_list.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_list.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_list.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 /* resource lists */
 
diff --git a/Zend/zend_list.h b/Zend/zend_list.h
index a38e057..74ee451 100644
--- a/Zend/zend_list.h
+++ b/Zend/zend_list.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_list.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_list.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_LIST_H
 #define ZEND_LIST_H
diff --git a/Zend/zend_llist.c b/Zend/zend_llist.c
index b48b150..b23fe1c 100644
--- a/Zend/zend_llist.c
+++ b/Zend/zend_llist.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_llist.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_llist.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_llist.h"
diff --git a/Zend/zend_llist.h b/Zend/zend_llist.h
index 47ec5a0..ab1e643 100644
--- a/Zend/zend_llist.h
+++ b/Zend/zend_llist.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_llist.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_llist.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_LLIST_H
 #define ZEND_LLIST_H
diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h
index 6773670..86807ee 100644
--- a/Zend/zend_modules.h
+++ b/Zend/zend_modules.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_modules.h 282827 2009-06-26 15:44:19Z johannes $ */
+/* $Id: zend_modules.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef MODULES_H
 #define MODULES_H
diff --git a/Zend/zend_multibyte.c b/Zend/zend_multibyte.c
index 7d270ad..4b82a67 100644
--- a/Zend/zend_multibyte.c
+++ b/Zend/zend_multibyte.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_multibyte.c 277438 2009-03-18 17:44:25Z moriyoshi $ */
+/* $Id: zend_multibyte.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_compile.h"
diff --git a/Zend/zend_multibyte.h b/Zend/zend_multibyte.h
index ee3e274..c4c0f1c 100644
--- a/Zend/zend_multibyte.h
+++ b/Zend/zend_multibyte.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_multibyte.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_multibyte.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_MULTIBYTE_H
 #define ZEND_MULTIBYTE_H
diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h
index afac089..cb790b7 100644
--- a/Zend/zend_multiply.h
+++ b/Zend/zend_multiply.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_multiply.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_multiply.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #if defined(__i386__) && defined(__GNUC__)
 
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 7c081ca..f43ed7f 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_object_handlers.c 282413 2009-06-19 03:29:47Z scottmac $ */
+/* $Id: zend_object_handlers.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_globals.h"
diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h
index 88871ef..721bfed 100644
--- a/Zend/zend_object_handlers.h
+++ b/Zend/zend_object_handlers.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_object_handlers.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_object_handlers.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_OBJECT_HANDLERS_H
 #define ZEND_OBJECT_HANDLERS_H
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index f69b82d..5aa1555 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_objects.c 289775 2009-10-19 21:43:34Z johannes $ */
+/* $Id: zend_objects.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_globals.h"
diff --git a/Zend/zend_objects.h b/Zend/zend_objects.h
index 1a87ca3..c27de0a 100644
--- a/Zend/zend_objects.h
+++ b/Zend/zend_objects.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_objects.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_objects.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_OBJECTS_H
 #define ZEND_OBJECTS_H
diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c
index 020796e..9f83fd4 100644
--- a/Zend/zend_objects_API.c
+++ b/Zend/zend_objects_API.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_objects_API.c 275561 2009-02-11 09:58:23Z tony2001 $ */
+/* $Id: zend_objects_API.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_globals.h"
diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h
index 643eaff..1f1a0ff 100644
--- a/Zend/zend_objects_API.h
+++ b/Zend/zend_objects_API.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_objects_API.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_objects_API.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_OBJECTS_API_H
 #define ZEND_OBJECTS_API_H
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index a721b0d..f31ba24 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_opcode.c 281737 2009-06-05 23:20:59Z shire $ */
+/* $Id: zend_opcode.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include <stdio.h>
 
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 6ee0d8e..fa02c75 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_operators.c 281670 2009-06-04 18:20:45Z mattwil $ */
+/* $Id: zend_operators.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include <ctype.h>
 
@@ -1227,6 +1227,12 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{
 	if (result==op1) {	/* special case, perform operations on result */
 		uint res_len = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);
 
+		if (Z_STRLEN_P(result) < 0 || (int) (Z_STRLEN_P(op1) + Z_STRLEN_P(op2)) < 0) {
+			efree(Z_STRVAL_P(result));
+			ZVAL_EMPTY_STRING(result);
+			zend_error(E_ERROR, "String size overflow");
+		}
+
 		Z_STRVAL_P(result) = erealloc(Z_STRVAL_P(result), res_len+1);
 
 		memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(result), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 03cd707..bc24284 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_operators.h 281670 2009-06-04 18:20:45Z mattwil $ */
+/* $Id: zend_operators.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_OPERATORS_H
 #define ZEND_OPERATORS_H
diff --git a/Zend/zend_ptr_stack.c b/Zend/zend_ptr_stack.c
index 5625a34..d866e6b 100644
--- a/Zend/zend_ptr_stack.c
+++ b/Zend/zend_ptr_stack.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ptr_stack.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_ptr_stack.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_ptr_stack.h"
diff --git a/Zend/zend_ptr_stack.h b/Zend/zend_ptr_stack.h
index bd2f8b2..490b982 100644
--- a/Zend/zend_ptr_stack.h
+++ b/Zend/zend_ptr_stack.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ptr_stack.h 281712 2009-06-05 11:21:31Z lbarnaud $ */
+/* $Id: zend_ptr_stack.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_PTR_STACK_H
 #define ZEND_PTR_STACK_H
diff --git a/Zend/zend_qsort.c b/Zend/zend_qsort.c
index 8b65f96..b144742 100644
--- a/Zend/zend_qsort.c
+++ b/Zend/zend_qsort.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_qsort.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_qsort.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 
diff --git a/Zend/zend_qsort.h b/Zend/zend_qsort.h
index 1044320..667df71 100644
--- a/Zend/zend_qsort.h
+++ b/Zend/zend_qsort.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_qsort.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_qsort.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_QSORT_H
 #define ZEND_QSORT_H
diff --git a/Zend/zend_sprintf.c b/Zend/zend_sprintf.c
index de1dd20..4e9eb8e 100644
--- a/Zend/zend_sprintf.c
+++ b/Zend/zend_sprintf.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_sprintf.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_sprintf.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include <stdio.h>
 
diff --git a/Zend/zend_stack.c b/Zend/zend_stack.c
index a8da824..caa7f36 100644
--- a/Zend/zend_stack.c
+++ b/Zend/zend_stack.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_stack.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_stack.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_stack.h"
diff --git a/Zend/zend_stack.h b/Zend/zend_stack.h
index 5aed032..408c383 100644
--- a/Zend/zend_stack.h
+++ b/Zend/zend_stack.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_stack.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_stack.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_STACK_H
 #define ZEND_STACK_H
diff --git a/Zend/zend_static_allocator.c b/Zend/zend_static_allocator.c
index efa299e..6a985c7 100644
--- a/Zend/zend_static_allocator.c
+++ b/Zend/zend_static_allocator.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_static_allocator.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_static_allocator.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend_static_allocator.h"
 
diff --git a/Zend/zend_static_allocator.h b/Zend/zend_static_allocator.h
index 70cfab7..9921a87 100644
--- a/Zend/zend_static_allocator.h
+++ b/Zend/zend_static_allocator.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_static_allocator.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_static_allocator.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_STATIC_ALLOCATOR_H
 #define ZEND_STATIC_ALLOCATOR_H
diff --git a/Zend/zend_stream.c b/Zend/zend_stream.c
index 2b99358..d354851 100644
--- a/Zend/zend_stream.c
+++ b/Zend/zend_stream.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_stream.c 277834 2009-03-26 17:28:49Z dmitry $ */
+/* $Id: zend_stream.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 
 #include "zend.h"
diff --git a/Zend/zend_stream.h b/Zend/zend_stream.h
index f9c08ea..e40a33b 100644
--- a/Zend/zend_stream.h
+++ b/Zend/zend_stream.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_stream.h 282248 2009-06-16 14:33:33Z felipe $ */
+/* $Id: zend_stream.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_STREAM_H
 #define ZEND_STREAM_H
diff --git a/Zend/zend_strtod.h b/Zend/zend_strtod.h
index 01eb993..c112d29 100644
--- a/Zend/zend_strtod.h
+++ b/Zend/zend_strtod.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_strtod.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_strtod.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 /* This is a header file for the strtod implementation by David M. Gay which
  * can be found in zend_strtod.c */
diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c
index cc27dc9..43f719d 100644
--- a/Zend/zend_ts_hash.c
+++ b/Zend/zend_ts_hash.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ts_hash.c 273192 2009-01-09 19:16:55Z tony2001 $ */
+/* $Id: zend_ts_hash.c 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #include "zend.h"
 #include "zend_ts_hash.h"
diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h
index d6ffb77..bdc2a8d 100644
--- a/Zend/zend_ts_hash.h
+++ b/Zend/zend_ts_hash.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ts_hash.h 273192 2009-01-09 19:16:55Z tony2001 $ */
+/* $Id: zend_ts_hash.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_TS_HASH_H
 #define ZEND_TS_HASH_H
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
index 100b279..374f600 100644
--- a/Zend/zend_types.h
+++ b/Zend/zend_types.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_types.h 281712 2009-06-05 11:21:31Z lbarnaud $ */
+/* $Id: zend_types.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_TYPES_H
 #define ZEND_TYPES_H
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index 5aad679..987351c 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_variables.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_variables.c 294427 2010-02-03 18:07:25Z pajoye $ */
 
 #include <stdio.h>
 #include "zend.h"
@@ -151,16 +151,19 @@ ZEND_API int zend_print_variable(zval *var)
 }
 
 
-#if ZEND_DEBUG
-ZEND_API void _zval_copy_ctor_wrapper(zval *zvalue)
+ZEND_API void _zval_dtor_wrapper(zval *zvalue)
 {
-	zval_copy_ctor(zvalue);
+	TSRMLS_FETCH();
+
+	GC_REMOVE_ZVAL_FROM_BUFFER(zvalue);
+	zval_dtor(zvalue);
 }
 
 
-ZEND_API void _zval_dtor_wrapper(zval *zvalue)
+#if ZEND_DEBUG
+ZEND_API void _zval_copy_ctor_wrapper(zval *zvalue)
 {
-	zval_dtor(zvalue);
+	zval_copy_ctor(zvalue);
 }
 
 
diff --git a/Zend/zend_variables.h b/Zend/zend_variables.h
index fbc9893..b73602e 100644
--- a/Zend/zend_variables.h
+++ b/Zend/zend_variables.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        | 
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_variables.h 279681 2009-05-01 21:46:53Z jani $ */
+/* $Id: zend_variables.h 294427 2010-02-03 18:07:25Z pajoye $ */
 
 #ifndef ZEND_VARIABLES_H
 #define ZEND_VARIABLES_H
@@ -50,26 +50,25 @@ ZEND_API int zend_print_variable(zval *var);
 ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
 ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC);
 ZEND_API void _zval_internal_ptr_dtor(zval **zvalue ZEND_FILE_LINE_DC);
+ZEND_API void _zval_dtor_wrapper(zval *zvalue);
 #define zval_copy_ctor(zvalue) _zval_copy_ctor((zvalue) ZEND_FILE_LINE_CC)
 #define zval_dtor(zvalue) _zval_dtor((zvalue) ZEND_FILE_LINE_CC)
 #define zval_ptr_dtor(zval_ptr) _zval_ptr_dtor((zval_ptr) ZEND_FILE_LINE_CC)
 #define zval_internal_dtor(zvalue) _zval_internal_dtor((zvalue) ZEND_FILE_LINE_CC)
 #define zval_internal_ptr_dtor(zvalue) _zval_internal_ptr_dtor((zvalue) ZEND_FILE_LINE_CC)
+#define zval_dtor_wrapper _zval_dtor_wrapper
 
 #if ZEND_DEBUG
 ZEND_API void _zval_copy_ctor_wrapper(zval *zvalue);
-ZEND_API void _zval_dtor_wrapper(zval *zvalue);
 ZEND_API void _zval_ptr_dtor_wrapper(zval **zval_ptr);
 ZEND_API void _zval_internal_dtor_wrapper(zval *zvalue);
 ZEND_API void _zval_internal_ptr_dtor_wrapper(zval **zvalue);
 #define zval_copy_ctor_wrapper _zval_copy_ctor_wrapper
-#define zval_dtor_wrapper _zval_dtor_wrapper
 #define zval_ptr_dtor_wrapper _zval_ptr_dtor_wrapper
 #define zval_internal_dtor_wrapper _zval_internal_dtor_wrapper
 #define zval_internal_ptr_dtor_wrapper _zval_internal_ptr_dtor_wrapper
 #else
 #define zval_copy_ctor_wrapper _zval_copy_ctor_func
-#define zval_dtor_wrapper _zval_dtor_func
 #define zval_ptr_dtor_wrapper _zval_ptr_dtor
 #define zval_internal_dtor_wrapper _zval_internal_dtor
 #define zval_internal_ptr_dtor_wrapper _zval_internal_ptr_dtor
diff --git a/Zend/zend_vm.h b/Zend/zend_vm.h
index a80a4b8..61390d0 100644
--- a/Zend/zend_vm.h
+++ b/Zend/zend_vm.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_vm.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: zend_vm.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #ifndef ZEND_VM_H
 #define ZEND_VM_H
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 485f2cc..06040f3 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_vm_def.h 290152 2009-11-02 18:11:33Z pajoye $ */
+/* $Id: zend_vm_def.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 /* If you change this file, please regenerate the zend_vm_execute.h and
  * zend_vm_opcodes.h files by running:
@@ -1100,7 +1100,7 @@ ZEND_VM_HANDLER(84, ZEND_FETCH_DIM_W, VAR|CV, CONST|TMP|VAR|UNUSED|CV)
 	FREE_OP1_VAR_PTR();
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -3691,7 +3691,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)
 {
 	zend_op *opline = EX(opline);
 	zend_free_op free_op1;
-	zval *array = GET_OP1_ZVAL_PTR(BP_VAR_R);
+	zval *array = EX_T(opline->op1.u.var).var.ptr;
 	zval **value;
 	char *str_key;
 	uint str_key_len;
@@ -3701,8 +3701,6 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)
 	int key_type = 0;
 	zend_bool use_key = (zend_bool)(opline->extended_value & ZEND_FE_FETCH_WITH_KEY);
 
-	PZVAL_LOCK(array);
-
 	switch (zend_iterator_unwrap(array, &iter TSRMLS_CC)) {
 		default:
 		case ZEND_ITER_INVALID:
@@ -3915,7 +3913,7 @@ ZEND_VM_HELPER_EX(zend_isset_isempty_dim_prop_obj_handler, VAR|UNUSED|CV, CONST|
 		zend_free_op free_op2;
 		zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 9d93110..826ba57 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -1332,6 +1332,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST(int type, ZEND
 
 	if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) {
 		retval = zend_std_get_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), 0 TSRMLS_CC);
+
 	} else {
 		target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), type, varname TSRMLS_CC);
 /*
@@ -8850,8 +8851,8 @@ static int ZEND_FASTCALL  ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
 static int ZEND_FASTCALL  ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
 {
 	zend_op *opline = EX(opline);
-	zend_free_op free_op1;
-	zval *array = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
+
+	zval *array = EX_T(opline->op1.u.var).var.ptr;
 	zval **value;
 	char *str_key;
 	uint str_key_len;
@@ -8861,8 +8862,6 @@ static int ZEND_FASTCALL  ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
 	int key_type = 0;
 	zend_bool use_key = (zend_bool)(opline->extended_value & ZEND_FE_FETCH_WITH_KEY);
 
-	PZVAL_LOCK(array);
-
 	switch (zend_iterator_unwrap(array, &iter TSRMLS_CC)) {
 		default:
 		case ZEND_ITER_INVALID:
@@ -9865,7 +9864,7 @@ static int ZEND_FASTCALL  ZEND_FETCH_DIM_W_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA
 	if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -10805,7 +10804,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_CONST(
 
 		zval *offset = &opline->op2.u.constant;
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -11668,7 +11667,7 @@ static int ZEND_FASTCALL  ZEND_FETCH_DIM_W_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND
 	if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -12554,7 +12553,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_TMP(in
 		zend_free_op free_op2;
 		zval *offset = _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC);
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -13417,7 +13416,7 @@ static int ZEND_FASTCALL  ZEND_FETCH_DIM_W_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND
 	if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -14354,7 +14353,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_VAR(in
 		zend_free_op free_op2;
 		zval *offset = _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC);
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -14757,7 +14756,7 @@ static int ZEND_FASTCALL  ZEND_FETCH_DIM_W_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_H
 	if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -15808,7 +15807,7 @@ static int ZEND_FASTCALL  ZEND_FETCH_DIM_W_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL
 	if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -16740,7 +16739,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_CV(int
 
 		zval *offset = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC);
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -17930,7 +17929,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_CON
 
 		zval *offset = &opline->op2.u.constant;
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -18987,7 +18986,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_TMP
 		zend_free_op free_op2;
 		zval *offset = _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC);
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -20044,7 +20043,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_VAR
 		zend_free_op free_op2;
 		zval *offset = _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC);
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -21360,7 +21359,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_CV(
 
 		zval *offset = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC);
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -21712,6 +21711,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV(int type, ZEND_OP
 
 	if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) {
 		retval = zend_std_get_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), 0 TSRMLS_CC);
+
 	} else {
 		target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), type, varname TSRMLS_CC);
 /*
@@ -23567,7 +23567,7 @@ static int ZEND_FASTCALL  ZEND_FETCH_DIM_W_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN
 	}
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -24345,7 +24345,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_CONST(i
 
 		zval *offset = &opline->op2.u.constant;
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -25204,7 +25204,7 @@ static int ZEND_FASTCALL  ZEND_FETCH_DIM_W_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL
 	}
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -25985,7 +25985,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_TMP(int
 		zend_free_op free_op2;
 		zval *offset = _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC);
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -26844,7 +26844,7 @@ static int ZEND_FASTCALL  ZEND_FETCH_DIM_W_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL
 	}
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -27675,7 +27675,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_VAR(int
 		zend_free_op free_op2;
 		zval *offset = _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC);
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
@@ -28074,7 +28074,7 @@ static int ZEND_FASTCALL  ZEND_FETCH_DIM_W_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HA
 	}
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -29026,7 +29026,7 @@ static int ZEND_FASTCALL  ZEND_FETCH_DIM_W_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE
 	}
 
 	/* We are going to assign the result by reference */
-	if (opline->extended_value) {
+	if (opline->extended_value && EX_T(opline->result.u.var).var.ptr_ptr) {
 		Z_DELREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(EX_T(opline->result.u.var).var.ptr_ptr);
 		Z_ADDREF_PP(EX_T(opline->result.u.var).var.ptr_ptr);
@@ -29852,7 +29852,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_CV(int
 
 		zval *offset = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC);
 
-		if (Z_TYPE_PP(container) == IS_ARRAY) {
+		if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
 			HashTable *ht;
 			int isset = 0;
 
diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php
index f67296b..d7dca6e 100644
--- a/Zend/zend_vm_gen.php
+++ b/Zend/zend_vm_gen.php
@@ -3,7 +3,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
    | Authors: Dmitry Stogov <dmitry at zend.com>                             |
    +----------------------------------------------------------------------+
 
-	 $Id: zend_vm_gen.php 272370 2008-12-31 11:15:49Z sebastian $
+	 $Id: zend_vm_gen.php 293155 2010-01-05 20:46:53Z sebastian $
 */
 
 $header_text = <<< DATA
@@ -24,7 +24,7 @@ $header_text = <<< DATA
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
diff --git a/Zend/zend_vm_opcodes.h b/Zend/zend_vm_opcodes.h
index 502529b..d048a85 100644
--- a/Zend/zend_vm_opcodes.h
+++ b/Zend/zend_vm_opcodes.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
diff --git a/acconfig.h b/acconfig.h
index 4c5d4a1..9d6b0f7 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -3,7 +3,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: acconfig.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: acconfig.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #if defined(__GNUC__) && __GNUC__ >= 4
 # define ZEND_API __attribute__ ((visibility("default")))
diff --git a/acinclude.m4 b/acinclude.m4
index 46e6eb7..e54b5e3 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: acinclude.m4 287126 2009-08-11 23:45:35Z srinatar $
+dnl $Id: acinclude.m4 291414 2009-11-29 06:13:22Z rasmus $
 dnl
 dnl This file contains local autoconf functions.
 dnl
@@ -1688,7 +1688,7 @@ dnl PHP_BROKEN_GLIBC_FOPEN_APPEND
 dnl
 AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [
   AC_MSG_CHECKING([for broken libc stdio])
-  AC_CACHE_VAL(have_broken_glibc_fopen_append,[
+  AC_CACHE_VAL(_cv_have_broken_glibc_fopen_append,[
   AC_TRY_RUN([
 #include <stdio.h>
 int main(int argc, char *argv[])
@@ -1714,8 +1714,8 @@ int main(int argc, char *argv[])
   return 0;
 }
 ],
-[have_broken_glibc_fopen_append=no],
-[have_broken_glibc_fopen_append=yes ],
+[_cv_have_broken_glibc_fopen_append=no],
+[_cv_have_broken_glibc_fopen_append=yes ],
 AC_TRY_COMPILE([
 #include <features.h>
 ],[
@@ -1723,11 +1723,11 @@ AC_TRY_COMPILE([
 choke me
 #endif
 ],
-[have_broken_glibc_fopen_append=yes],
-[have_broken_glibc_fopen_append=no ])
+[_cv_have_broken_glibc_fopen_append=yes],
+[_cv_have_broken_glibc_fopen_append=no ])
 )])
 
-  if test "$have_broken_glibc_fopen_append" = "yes"; then
+  if test "$_cv_have_broken_glibc_fopen_append" = "yes"; then
     AC_MSG_RESULT(yes)
     AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+])
   else
diff --git a/aclocal.m4 b/aclocal.m4
index 68a847c..27db09c 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: acinclude.m4 287126 2009-08-11 23:45:35Z srinatar $
+dnl $Id: acinclude.m4 291414 2009-11-29 06:13:22Z rasmus $
 dnl
 dnl This file contains local autoconf functions.
 dnl
@@ -1688,7 +1688,7 @@ dnl PHP_BROKEN_GLIBC_FOPEN_APPEND
 dnl
 AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [
   AC_MSG_CHECKING([for broken libc stdio])
-  AC_CACHE_VAL(have_broken_glibc_fopen_append,[
+  AC_CACHE_VAL(_cv_have_broken_glibc_fopen_append,[
   AC_TRY_RUN([
 #include <stdio.h>
 int main(int argc, char *argv[])
@@ -1714,8 +1714,8 @@ int main(int argc, char *argv[])
   return 0;
 }
 ],
-[have_broken_glibc_fopen_append=no],
-[have_broken_glibc_fopen_append=yes ],
+[_cv_have_broken_glibc_fopen_append=no],
+[_cv_have_broken_glibc_fopen_append=yes ],
 AC_TRY_COMPILE([
 #include <features.h>
 ],[
@@ -1723,11 +1723,11 @@ AC_TRY_COMPILE([
 choke me
 #endif
 ],
-[have_broken_glibc_fopen_append=yes],
-[have_broken_glibc_fopen_append=no ])
+[_cv_have_broken_glibc_fopen_append=yes],
+[_cv_have_broken_glibc_fopen_append=no ])
 )])
 
-  if test "$have_broken_glibc_fopen_append" = "yes"; then
+  if test "$_cv_have_broken_glibc_fopen_append" = "yes"; then
     AC_MSG_RESULT(yes)
     AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+])
   else
@@ -2875,15 +2875,15 @@ main()
 ])
 
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
-## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
-## Free Software Foundation, Inc.
+## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007,
+## 2008  Free Software Foundation, Inc.
 ## Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 ##
 ## This file is free software; the Free Software Foundation gives
 ## unlimited permission to copy and/or distribute it, with or without
 ## modifications, as long as this notice is preserved.
 
-# serial 47 AC_PROG_LIBTOOL
+# serial 52 AC_PROG_LIBTOOL
 
 ifdef([AC_ACVERSION],[
 # autoconf 2.13 compatibility
@@ -2920,30 +2920,6 @@ dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
     [AC_LIBTOOL_CXX],
     [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
   ])])
-
-dnl dnl And a similar setup for Fortran 77 support
-dnl   AC_PROVIDE_IFELSE([AC_PROG_F77],
-dnl     [AC_LIBTOOL_F77],
-dnl     [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
-dnl ])])
-
-dnl dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
-dnl dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
-dnl dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
-dnl   AC_PROVIDE_IFELSE([AC_PROG_GCJ],
-dnl     [AC_LIBTOOL_GCJ],
-dnl     [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
-dnl       [AC_LIBTOOL_GCJ],
-dnl       [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
-dnl 	[AC_LIBTOOL_GCJ],
-dnl       [ifdef([AC_PROG_GCJ],
-dnl 	     [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
-dnl        ifdef([A][M_PROG_GCJ],
-dnl 	     [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
-dnl        ifdef([LT_AC_PROG_GCJ],
-dnl 	     [define([LT_AC_PROG_GCJ],
-dnl 		defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
-dnl ])
 ])# AC_PROG_LIBTOOL
 
 
@@ -2952,8 +2928,6 @@ dnl ])
 AC_DEFUN([_AC_PROG_LIBTOOL],
 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
 AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
-dnl AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
-dnl AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
 
 # This can be used to rebuild libtool when needed
 LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
@@ -2987,7 +2961,6 @@ AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
 AC_REQUIRE([AC_OBJEXT])dnl
 AC_REQUIRE([AC_EXEEXT])dnl
 dnl
-
 AC_LIBTOOL_SYS_MAX_CMD_LEN
 AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
 AC_LIBTOOL_OBJDIR
@@ -3049,6 +3022,7 @@ test -z "$AR_FLAGS" && AR_FLAGS=cru
 test -z "$AS" && AS=as
 test -z "$CC" && CC=cc
 test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 test -z "$DLLTOOL" && DLLTOOL=dlltool
 test -z "$LD" && LD=ld
 test -z "$LN_S" && LN_S="ln -s"
@@ -3061,17 +3035,17 @@ test -z "$STRIP" && STRIP=:
 test -z "$ac_objext" && ac_objext=o
 
 # Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
 old_postinstall_cmds='chmod 644 $oldlib'
 old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
   openbsd*)
-    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
     ;;
   *)
-    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
     ;;
   esac
   old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
@@ -3088,6 +3062,8 @@ file_magic*)
   ;;
 esac
 
+_LT_REQUIRED_DARWIN_CHECKS
+
 AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
 AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
 enable_win32_dll=yes, enable_win32_dll=no)
@@ -3117,6 +3093,9 @@ AC_DEFUN([_LT_AC_SYS_COMPILER],
 # If no C compiler was specified, use CC.
 LTCC=${LTCC-"$CC"}
 
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
 # Allow CC to be a program name with arguments.
 compiler=$CC
 ])# _LT_AC_SYS_COMPILER
@@ -3143,9 +3122,10 @@ cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 # Check for compiler boilerplate output or warnings with
 # the simple compiler test code.
 AC_DEFUN([_LT_COMPILER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_compiler_boilerplate=`cat conftest.err`
 $rm conftest*
 ])# _LT_COMPILER_BOILERPLATE
@@ -3156,11 +3136,12 @@ $rm conftest*
 # Check for linker boilerplate output or warnings with
 # the simple link test code.
 AC_DEFUN([_LT_LINKER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+$rm -r conftest*
 ])# _LT_LINKER_BOILERPLATE
 
 
@@ -3176,7 +3157,7 @@ int main() {
 ; return 0; }
 EOF
 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
-  ifelse([$1], , :, [$1
+ ifelse([$1], , :, [$1
   rm -rf conftest*])
 else
   echo "configure: failed program was:" >&5
@@ -3187,6 +3168,75 @@ ifelse([$2], , , [$2
 fi
 rm -f conftest*])
 
+# _LT_REQUIRED_DARWIN_CHECKS
+# --------------------------
+# Check for some things on darwin
+AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS],[
+  case $host_os in
+    rhapsody* | darwin*)
+    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+
+    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+      [lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+   # By default we will add the -single_module flag. You can override
+   # by either setting the environment variable LT_MULTI_MODULE
+   # non-empty at configure time, or by adding -multi_module to the
+   # link flags.
+   echo "int foo(void){return 1;}" > conftest.c
+   $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+     -dynamiclib ${wl}-single_module conftest.c
+   if test -f libconftest.dylib; then
+     lt_cv_apple_cc_single_mod=yes
+     rm -rf libconftest.dylib*
+   fi
+   rm conftest.c
+      fi])
+    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+      [lt_cv_ld_exported_symbols_list],
+      [lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      _LT_AC_TRY_LINK([lt_cv_ld_exported_symbols_list=yes],[lt_cv_ld_exported_symbols_list=no])
+   LDFLAGS="$save_LDFLAGS"
+    ])
+    case $host_os in
+    rhapsody* | darwin1.[[0123]])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*)
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+   10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+   10.[[012]]*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+   10.*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}"
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil="~$DSYMUTIL \$lib || :"
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+])
 
 # _LT_AC_SYS_LIBPATH_AIX
 # ----------------------
@@ -3197,12 +3247,20 @@ rm -f conftest*])
 # If we don't find anything, use the default library path according
 # to the aix ld manual.
 AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
-[_LT_AC_TRY_LINK([
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+_LT_AC_TRY_LINK([
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
 # Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi],[])
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi],[])
 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 ])# _LT_AC_SYS_LIBPATH_AIX
 
@@ -3433,13 +3491,17 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+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 AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
     *32-bit*)
       case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_i386_fbsd"
+          ;;
         x86_64-*linux*)
           LD="${LD-ld} -m elf_i386"
           ;;
@@ -3456,6 +3518,9 @@ x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
       ;;
     *64-bit*)
       case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_x86_64_fbsd"
+          ;;
         x86_64-*linux*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
@@ -3489,6 +3554,26 @@ x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
     CFLAGS="$SAVE_CFLAGS"
   fi
   ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+        if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
 AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
 [*-*-cygwin* | *-*-mingw* | *-*-pw32*)
   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
@@ -3512,7 +3597,7 @@ AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
 AC_CACHE_CHECK([$1], [$2],
   [$2=no
   ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
    lt_compiler_flag="$3"
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
@@ -3531,9 +3616,9 @@ AC_CACHE_CHECK([$1], [$2],
    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.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
        $2=yes
      fi
    fi
@@ -3553,19 +3638,20 @@ fi
 # ------------------------------------------------------------
 # Check whether the given compiler option works
 AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
-[AC_CACHE_CHECK([$1], [$2],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
   [$2=no
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $3"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
      # The linker can only warn and ignore the option if not recognized
      # So say no if there are warnings
      if test -s conftest.err; then
        # Append any errors to the config.log.
        cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
-       $SED '/^$/d' conftest.err >conftest.er2
+       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
        if diff conftest.exp conftest.er2 >/dev/null; then
          $2=yes
        fi
@@ -3573,7 +3659,7 @@ AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
        $2=yes
      fi
    fi
-   $rm conftest*
+   $rm -r conftest*
    LDFLAGS="$save_LDFLAGS"
 ])
 
@@ -3634,44 +3720,64 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     elif test -x /usr/sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
     else
-      lt_cv_sys_max_cmd_len=65536     # usable default for all BSDs
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
     fi
     # And add a safety zone
     lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
     lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
   osf*)
     # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
     # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
     # nice to cause kernel panics so lets avoid the loop below.
     # First set a reasonable default.
     lt_cv_sys_max_cmd_len=16384
-    # 
+    #
     if test -x /sbin/sysconfig; then
       case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
         *1*) lt_cv_sys_max_cmd_len=-1 ;;
       esac
     fi
     ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ 	]]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
   *)
-    # If test is not a shell built-in, we'll probably end up computing a
-    # maximum length that is only half of the actual maximum length, but
-    # we can't tell.
-    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-    while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
 	       = "XX$teststring") >/dev/null 2>&1 &&
-	    new_result=`expr "X$teststring" : ".*" 2>&1` &&
-	    lt_cv_sys_max_cmd_len=$new_result &&
-	    test $i != 17 # 1/2 MB should be enough
-    do
-      i=`expr $i + 1`
-      teststring=$teststring$teststring
-    done
-    teststring=
-    # Add a significant safety factor because C++ compilers can tack on massive
-    # amounts of additional arguments before passing them to the linker.
-    # It appears as though 1/2 is a usable value.
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+	      new_result=`expr "X$teststring" : ".*" 2>&1` &&
+	      lt_cv_sys_max_cmd_len=$new_result &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on massive
+      # amounts of additional arguments before passing them to the linker.
+      # It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
     ;;
   esac
 ])
@@ -3684,7 +3790,7 @@ fi
 
 
 # _LT_AC_CHECK_DLFCN
-# --------------------
+# ------------------
 AC_DEFUN([_LT_AC_CHECK_DLFCN],
 [AC_CHECK_HEADERS(dlfcn.h)dnl
 ])# _LT_AC_CHECK_DLFCN
@@ -3692,7 +3798,7 @@ AC_DEFUN([_LT_AC_CHECK_DLFCN],
 
 # _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
 #                           ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
-# ------------------------------------------------------------------
+# ---------------------------------------------------------------------
 AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
 [AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
 if test "$cross_compiling" = yes; then :
@@ -3758,6 +3864,8 @@ int main ()
       else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
       /* dlclose (self); */
     }
+  else
+    puts (dlerror ());
 
     exit (status);
 }]
@@ -3768,7 +3876,7 @@ EOF
     case x$lt_status in
       x$lt_dlno_uscore) $1 ;;
       x$lt_dlneed_uscore) $2 ;;
-      x$lt_unknown|x*) $3 ;;
+      x$lt_dlunknown|x*) $3 ;;
     esac
   else :
     # compilation failed
@@ -3780,7 +3888,7 @@ rm -fr conftest*
 
 
 # AC_LIBTOOL_DLOPEN_SELF
-# -------------------
+# ----------------------
 AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
 [AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
 if test "x$enable_dlopen" != xyes; then
@@ -3822,7 +3930,7 @@ else
     AC_CHECK_FUNC([shl_load],
 	  [lt_cv_dlopen="shl_load"],
       [AC_CHECK_LIB([dld], [shl_load],
-	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
 	[AC_CHECK_FUNC([dlopen],
 	      [lt_cv_dlopen="dlopen"],
 	  [AC_CHECK_LIB([dl], [dlopen],
@@ -3830,7 +3938,7 @@ else
 	    [AC_CHECK_LIB([svld], [dlopen],
 		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
 	      [AC_CHECK_LIB([dld], [dld_link],
-		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
 	      ])
 	    ])
 	  ])
@@ -3851,7 +3959,7 @@ else
     test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
     save_LDFLAGS="$LDFLAGS"
-    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
     save_LIBS="$LIBS"
     LIBS="$lt_cv_dlopen_libs $LIBS"
@@ -3864,7 +3972,7 @@ else
     ])
 
     if test "x$lt_cv_dlopen_self" = xyes; then
-      LDFLAGS="$LDFLAGS $link_static_flag"
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
     	  lt_cv_dlopen_self_static, [dnl
 	  _LT_AC_TRY_DLOPEN_SELF(
@@ -3896,7 +4004,8 @@ fi
 # ---------------------------------
 # Check to see if options -c and -o are simultaneously supported by compiler
 AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
 AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
   [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
   [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
@@ -3904,7 +4013,7 @@ AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
    mkdir conftest
    cd conftest
    mkdir out
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
    lt_compiler_flag="-o out/conftest2.$ac_objext"
    # Insert the option either (1) after the last *FLAGS variable, or
@@ -3924,9 +4033,9 @@ AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
        _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
      fi
    fi
@@ -4044,6 +4153,7 @@ else
    darwin*)
        if test -n "$STRIP" ; then
          striplib="$STRIP -x"
+         old_striplib="$STRIP -S"
          AC_MSG_RESULT([yes])
        else
   AC_MSG_RESULT([no])
@@ -4061,7 +4171,8 @@ fi
 # -----------------------------
 # PORTME Fill in your ld.so characteristics
 AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
-[AC_MSG_CHECKING([dynamic linker characteristics])
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
@@ -4075,20 +4186,58 @@ shlibpath_overrides_runpath=unknown
 version_type=none
 dynamic_linker="$host_os ld.so"
 sys_lib_dlsearch_path_spec="/lib /usr/lib"
+ifelse($1,[],[
 if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$lt_search_path_spec" | grep ';' >/dev/null ; then
     # if the path contains ";" then we assume it to be the separator
     # otherwise default to the standard path separator (i.e. ":") - it is
     # assumed that no part of a normal pathname contains ";" but that should
     # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e 's/;/ /g'`
   else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
   fi
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`echo $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+  sys_lib_search_path_spec=`echo $lt_search_path_spec`
 else
   sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
+fi])
 need_lib_prefix=unknown
 hardcode_into_libs=no
 
@@ -4106,7 +4255,7 @@ aix3*)
   soname_spec='${libname}${release}${shared_ext}$major'
   ;;
 
-aix4* | aix5*)
+aix[[4-9]]*)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -4245,12 +4394,8 @@ darwin* | rhapsody*)
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
+  ifelse([$1], [],[
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) 
   sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
   ;;
 
@@ -4267,18 +4412,6 @@ freebsd1*)
   dynamic_linker=no
   ;;
 
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
@@ -4311,10 +4444,15 @@ freebsd* | dragonfly*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
-  *) # from 3.2 on
+  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
     shlibpath_overrides_runpath=no
     hardcode_into_libs=yes
     ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
   esac
   ;;
 
@@ -4374,6 +4512,18 @@ hpux9* | hpux10* | hpux11*)
   postinstall_cmds='chmod 555 $lib'
   ;;
 
+interix[[3-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
 irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
@@ -4417,7 +4567,7 @@ linux*oldld* | linux*aout* | linux*coff*)
   ;;
 
 # This must be Linux ELF.
-linux*)
+linux* | k*bsd*-gnu)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -4431,27 +4581,10 @@ linux*)
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # find out which ABI we are using
-  libsuff=
-  case $host_cpu in
-  x86_64*|s390x*|powerpc64*)
-    echo '[#]line __oline__ "configure"' > conftest.$ac_ext
-    if AC_TRY_EVAL(ac_compile); then
-      case `/usr/bin/file conftest.$ac_objext` in
-      *64-bit*)
-        libsuff=64
-        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
-        ;;
-      esac
-    fi
-    rm -rf conftest*
-    ;;
-  esac
-
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ 	]*hwcap[ 	]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -4463,18 +4596,6 @@ linux*)
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -4512,6 +4633,7 @@ nto-qnx*)
 
 openbsd*)
   version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
   need_lib_prefix=no
   # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
   case $host_os in
@@ -4555,11 +4677,8 @@ osf3* | osf4* | osf5*)
   sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
   ;;
 
-sco3.2v5*)
-  version_type=osf
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
+rdos*)
+  dynamic_linker=no
   ;;
 
 solaris*)
@@ -4587,7 +4706,7 @@ sunos4*)
   need_version=yes
   ;;
 
-sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+sysv4 | sysv4.3*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
@@ -4620,6 +4739,29 @@ sysv4*MP*)
   fi
   ;;
 
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+    shlibpath_overrides_runpath=no
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    shlibpath_overrides_runpath=yes
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
 uts4*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -4633,13 +4775,26 @@ uts4*)
 esac
 AC_MSG_RESULT([$dynamic_linker])
 test "$dynamic_linker" = no && can_build_shared=no
+
+AC_CACHE_VAL([lt_cv_sys_lib_search_path_spec],
+[lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"])
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+AC_CACHE_VAL([lt_cv_sys_lib_dlsearch_path_spec],
+[lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"])
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
 ])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
 
 
 # _LT_AC_TAGCONFIG
 # ----------------
 AC_DEFUN([_LT_AC_TAGCONFIG],
-[AC_ARG_WITH([tags],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_ARG_WITH([tags],
 [  --with-tags[=TAGS]      include additional configurations [automatic]
 ],
 [tagnames="$withval"])
@@ -4657,6 +4812,9 @@ if test -f "$ltmain" && test -n "$tagnames"; then
       AC_MSG_WARN([using \`LTCC=$LTCC', extracted from \`$ofile'])
     fi
   fi
+  if test -z "$LTCFLAGS"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
+  fi
 
   # Extract list of available tagged configurations in $ofile.
   # Note that this assumes the entire list is on one line.
@@ -4692,26 +4850,6 @@ if test -f "$ltmain" && test -n "$tagnames"; then
 	fi
 	;;
 
-#      F77)
-#	if test -n "$F77" && test "X$F77" != "Xno"; then
-#	  AC_LIBTOOL_LANG_F77_CONFIG
-#	else
-#	  tagname=""
-#	fi
-#	;;
-#
-#      GCJ)
-#	if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
-#	  AC_LIBTOOL_LANG_GCJ_CONFIG
-#	else
-#	  tagname=""
-#	fi
-#	;;
-#
-#      RC)
-#	AC_LIBTOOL_LANG_RC_CONFIG
-#	;;
-
       *)
 	AC_MSG_ERROR([Unsupported tag name: $tagname])
 	;;
@@ -4786,7 +4924,7 @@ changequote([, ])dnl
 
 # AC_DISABLE_SHARED
 # -----------------
-#- set the default shared flag to --disable-shared
+# set the default shared flag to --disable-shared
 AC_DEFUN([AC_DISABLE_SHARED],
 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
 AC_ENABLE_SHARED(no)
@@ -4885,8 +5023,6 @@ pic_mode=ifelse($#,1,$1,default)
 
 # AC_PROG_EGREP
 # -------------
-# This is predefined starting with Autoconf 2.54, so this conditional
-# definition can be removed once we require Autoconf 2.54 or later.
 ifdef([AC_PROG_EGREP], [], [AC_DEFUN([AC_PROG_EGREP],
 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
@@ -4900,7 +5036,7 @@ ifdef([AC_PROG_EGREP], [], [AC_DEFUN([AC_PROG_EGREP],
 
 # AC_PATH_TOOL_PREFIX
 # -------------------
-# find a file program which can recognise shared library
+# find a file program which can recognize shared library
 AC_DEFUN([AC_PATH_TOOL_PREFIX],
 [AC_REQUIRE([AC_PROG_EGREP])dnl
 AC_MSG_CHECKING([for $1])
@@ -4963,7 +5099,7 @@ fi
 
 # AC_PATH_MAGIC
 # -------------
-# find a file program which can recognise a shared library
+# find a file program which can recognize a shared library
 AC_DEFUN([AC_PATH_MAGIC],
 [AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
 if test -z "$lt_cv_path_MAGIC_CMD"; then
@@ -5095,7 +5231,7 @@ reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   darwin*)
     if test "$GCC" = yes; then
-      reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs'
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -5109,7 +5245,7 @@ esac
 # how to check for library dependencies
 #  -- PORTME fill in with the dynamic library characteristics
 AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
-[AC_CACHE_CHECK([how to recognise dependent libraries],
+[AC_CACHE_CHECK([how to recognize dependent libraries],
 lt_cv_deplibs_check_method,
 [lt_cv_file_magic_cmd='$MAGIC_CMD'
 lt_cv_file_magic_test_file=
@@ -5126,7 +5262,7 @@ lt_cv_deplibs_check_method='unknown'
 # whether `pass_all' will *always* work, you probably want this one.
 
 case $host_os in
-aix4* | aix5*)
+aix[[4-9]]*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -5148,16 +5284,22 @@ cygwin*)
 
 mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
-  # func_win32_libid shell function, so use a weaker test based on 'objdump'.
-  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
-  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
   ;;
 
 darwin* | rhapsody*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | kfreebsd*-gnu | dragonfly*)
+freebsd* | dragonfly*)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
@@ -5195,6 +5337,11 @@ hpux10.20* | hpux11*)
   esac
   ;;
 
+interix[[3-9]]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+  ;;
+
 irix5* | irix6* | nonstopux*)
   case $LD in
   *-32|*"-32 ") libmagic=32-bit;;
@@ -5206,7 +5353,7 @@ irix5* | irix6* | nonstopux*)
   ;;
 
 # This must be Linux ELF.
-linux*)
+linux* | k*bsd*-gnu)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -5240,7 +5387,7 @@ osf3* | osf4* | osf5*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-sco3.2v5*)
+rdos*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -5248,7 +5395,7 @@ solaris*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+sysv4 | sysv4.3*)
   case $host_vendor in
   motorola)
     lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
@@ -5269,10 +5416,13 @@ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
   siemens)
     lt_cv_deplibs_check_method=pass_all
     ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
   esac
   ;;
 
-sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*)
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 esac
@@ -5292,36 +5442,43 @@ AC_DEFUN([AC_PROG_NM],
   # Let the user override the test.
   lt_cv_path_NM="$NM"
 else
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    tmp_nm="$ac_dir/${ac_tool_prefix}nm"
-    if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-      # Check to see if the nm accepts a BSD-compat flag.
-      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
-      #   nm: unknown option "B" ignored
-      # Tru64's nm complains that /dev/null is an invalid object file
-      case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-      */dev/null* | *'Invalid file or object type'*)
-	lt_cv_path_NM="$tmp_nm -B"
-	break
-        ;;
-      *)
-	case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	*/dev/null*)
-	  lt_cv_path_NM="$tmp_nm -p"
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
 	  break
 	  ;;
 	*)
-	  lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	  continue # so that we can try to find one that supports BSD flags
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
 	  ;;
 	esac
-      esac
-    fi
+      fi
+    done
+    IFS="$lt_save_ifs"
   done
-  IFS="$lt_save_ifs"
   test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
 fi])
 NM="$lt_cv_path_NM"
@@ -5427,7 +5584,7 @@ _LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
 ])# _LT_AC_LANG_CXX
 
 # _LT_AC_PROG_CXXCPP
-# ---------------
+# ------------------
 AC_DEFUN([_LT_AC_PROG_CXXCPP],
 [
 AC_REQUIRE([AC_PROG_CXX])
@@ -5438,52 +5595,6 @@ if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
 fi
 ])# _LT_AC_PROG_CXXCPP
 
-# AC_LIBTOOL_F77
-# --------------
-# enable support for Fortran 77 libraries
-#AC_DEFUN([AC_LIBTOOL_F77],
-#[AC_REQUIRE([_LT_AC_LANG_F77])
-#])# AC_LIBTOOL_F77
-
-
-# _LT_AC_LANG_F77
-# ---------------
-#AC_DEFUN([_LT_AC_LANG_F77],
-#[AC_REQUIRE([AC_PROG_F77])
-#_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
-#])# _LT_AC_LANG_F77
-
-
-# AC_LIBTOOL_GCJ
-# --------------
-# enable support for GCJ libraries
-#AC_DEFUN([AC_LIBTOOL_GCJ],
-#[AC_REQUIRE([_LT_AC_LANG_GCJ])
-#])# AC_LIBTOOL_GCJ
-
-
-# _LT_AC_LANG_GCJ
-# ---------------
-#AC_DEFUN([_LT_AC_LANG_GCJ],
-#[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
-#  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
-#    [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
-#      [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
-#	 [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
-#	   [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
-#_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
-#])# _LT_AC_LANG_GCJ
-
-
-# AC_LIBTOOL_RC
-# --------------
-# enable support for Windows resource files
-#AC_DEFUN([AC_LIBTOOL_RC],
-#[AC_REQUIRE([LT_AC_PROG_RC])
-#_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
-#])# AC_LIBTOOL_RC
-
-
 # AC_LIBTOOL_LANG_C_CONFIG
 # ------------------------
 # Ensure that the configuration vars for the C compiler are
@@ -5503,10 +5614,10 @@ objext=o
 _LT_AC_TAGVAR(objext, $1)=$objext
 
 # Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
+lt_simple_compile_test_code="int some_variable = 0;"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
+lt_simple_link_test_code='int main(){return(0);}'
 
 _LT_AC_SYS_COMPILER
 
@@ -5514,37 +5625,6 @@ _LT_AC_SYS_COMPILER
 _LT_COMPILER_BOILERPLATE
 _LT_LINKER_BOILERPLATE
 
-#
-# Check for any special shared library compilation flags.
-#
-_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)=
-if test "$GCC" = no; then
-  case $host_os in
-  sco3.2v5*)
-    _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf'
-    ;;
-  esac
-fi
-if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then
-  AC_MSG_WARN([\`$CC' requires \`$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries])
-  if echo "$old_CC $old_CFLAGS " | grep "[[ 	]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[ 	]]" >/dev/null; then :
-  else
-    AC_MSG_WARN([add \`$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure])
-    _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no
-  fi
-fi
-
-
-#
-# Check to make sure the static flag actually works.
-#
-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works],
-  _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
-  $_LT_AC_TAGVAR(lt_prog_compiler_static, $1),
-  [],
-  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
-
-
 ## CAVEAT EMPTOR:
 ## There is no encapsulation within the following macros, do not change
 ## the running order or otherwise move them around unless you know exactly
@@ -5557,9 +5637,9 @@ AC_LIBTOOL_PROG_LD_SHLIBS($1)
 AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
 AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
 AC_LIBTOOL_SYS_LIB_STRIP
-AC_LIBTOOL_DLOPEN_SELF($1)
+AC_LIBTOOL_DLOPEN_SELF
 
-# Report which librarie types wil actually be built
+# Report which library types will actually be built
 AC_MSG_CHECKING([if libtool supports shared libraries])
 AC_MSG_RESULT([$can_build_shared])
 
@@ -5577,7 +5657,7 @@ aix3*)
   fi
   ;;
 
-aix4* | aix5*)
+aix[[4-9]]*)
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
@@ -5619,6 +5699,7 @@ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
 _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
 _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
 _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
 _LT_AC_TAGVAR(hardcode_automatic, $1)=no
 _LT_AC_TAGVAR(module_cmds, $1)=
 _LT_AC_TAGVAR(module_expsym_cmds, $1)=
@@ -5634,6 +5715,7 @@ _LT_AC_TAGVAR(postdep_objects, $1)=
 _LT_AC_TAGVAR(predeps, $1)=
 _LT_AC_TAGVAR(postdeps, $1)=
 _LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=
 
 # Source file extension for C++ test sources.
 ac_ext=cpp
@@ -5643,10 +5725,10 @@ objext=o
 _LT_AC_TAGVAR(objext, $1)=$objext
 
 # Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
+lt_simple_compile_test_code="int some_variable = 0;"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
+lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
@@ -5743,7 +5825,7 @@ case $host_os in
     # FIXME: insert proper C++ library support
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
-  aix4* | aix5*)
+  aix[[4-9]]*)
     if test "$host_cpu" = ia64; then
       # On IA64, the linker does run time linking by default, so we don't
       # have to do anything special.
@@ -5756,7 +5838,7 @@ case $host_os in
       # Test if we are trying to use run time linking or normal
       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
       # need to do runtime linking.
-      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	for ld_flag in $LDFLAGS; do
 	  case $ld_flag in
 	  *-brtl*)
@@ -5765,6 +5847,7 @@ case $host_os in
 	    ;;
 	  esac
 	done
+	;;
       esac
 
       exp_sym_flag='-bexport'
@@ -5791,7 +5874,7 @@ case $host_os in
 	   strings "$collect2name" | grep resolve_lib_name >/dev/null
 	then
 	  # We have reworked collect2
-	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	  :
 	else
 	  # We have old collect2
 	  _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
@@ -5802,6 +5885,7 @@ case $host_os in
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
 	fi
+	;;
       esac
       shared_flag='-shared'
       if test "$aix_use_runtimelinking" = yes; then
@@ -5833,12 +5917,12 @@ case $host_os in
       _LT_AC_SYS_LIBPATH_AIX
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
 
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
      else
       if test "$host_cpu" = ia64; then
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
       else
 	# Determine the default libpath from the value encoded in an empty executable.
 	_LT_AC_SYS_LIBPATH_AIX
@@ -5847,16 +5931,26 @@ case $host_os in
 	# -berok will link without error, but may produce a broken library.
 	_LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	# -bexpall does not export symbols beginning with underscore (_)
-	_LT_AC_TAGVAR(always_export_symbols, $1)=yes
 	# Exported symbols can be pulled into shared objects from archives
-	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
 	# This is similar to how AIX traditionally builds its shared libraries.
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
       fi
     fi
     ;;
+
+  beos*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+      # support --undefined.  This deserves some investigation.  FIXME
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+    ;;
+
   chorus*)
     case $cc_basename in
       *)
@@ -5866,7 +5960,6 @@ case $host_os in
     esac
     ;;
 
-
   cygwin* | mingw* | pw32*)
     # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
     # as there is no search path for DLLs.
@@ -5876,7 +5969,7 @@ case $host_os in
     _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
     if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       # If the export-symbols file already is a .def file (1st line
       # is EXPORTS), use it as is; otherwise, prepend...
       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
@@ -5885,65 +5978,37 @@ case $host_os in
 	echo EXPORTS > $output_objdir/$soname.def;
 	cat $export_symbols >> $output_objdir/$soname.def;
       fi~
-      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
     else
       _LT_AC_TAGVAR(ld_shlibs, $1)=no
     fi
   ;;
       darwin* | rhapsody*)
-        case $host_os in
-        rhapsody* | darwin1.[[012]])
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[[012]])
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+      if test "$GXX" = yes ; then
       output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
+      _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+      _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+      _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+      if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+        _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
       fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      else
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       else
       case $cc_basename in
         xlc*)
          output_verbose_link_cmd='echo'
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
           _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
           # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
        *)
@@ -5977,7 +6042,7 @@ case $host_os in
   freebsd-elf*)
     _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
     ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
+  freebsd* | dragonfly*)
     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
     # conventions
     _LT_AC_TAGVAR(ld_shlibs, $1)=yes
@@ -6022,34 +6087,21 @@ case $host_os in
     ;;
   hpux10*|hpux11*)
     if test $with_gnu_ld = no; then
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
       case $host_cpu in
-      hppa*64*)
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
-	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-        ;;
-      ia64*)
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-        ;;
+      hppa*64*|ia64*) ;;
       *)
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         ;;
       esac
     fi
     case $host_cpu in
-    hppa*64*)
+    hppa*64*|ia64*)
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
-    ia64*)
-      _LT_AC_TAGVAR(hardcode_direct, $1)=no
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
-					      # but as the default
-					      # location of the library.
-      ;;
     *)
       _LT_AC_TAGVAR(hardcode_direct, $1)=yes
       _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
@@ -6065,8 +6117,11 @@ case $host_os in
 	;;
       aCC*)
 	case $host_cpu in
-	hppa*64*|ia64*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+	hppa*64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	  ;;
 	*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -6086,8 +6141,11 @@ case $host_os in
 	if test "$GXX" = yes; then
 	  if test $with_gnu_ld = no; then
 	    case $host_cpu in
-	    ia64*|hppa*64*)
-	      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+	    hppa*64*)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    ia64*)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	      ;;
 	    *)
 	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -6101,6 +6159,20 @@ case $host_os in
 	;;
     esac
     ;;
+  interix[[3-9]]*)
+    _LT_AC_TAGVAR(hardcode_direct, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+    # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+    # Instead, shared libraries are loaded at an image base (0x10000000 by
+    # default) and relocated if they conflict, which is a slow very memory
+    # consuming and fragmenting process.  To avoid this, we pick a random,
+    # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+    # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    ;;
   irix5* | irix6*)
     case $cc_basename in
       CC*)
@@ -6127,7 +6199,7 @@ case $host_os in
     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
     _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
     ;;
-  linux*)
+  linux* | k*bsd*-gnu)
     case $cc_basename in
       KCC*)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
@@ -6179,7 +6251,7 @@ case $host_os in
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
+      pgCC* | pgcpp*)
         # Portland Group C++ compiler
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
   	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
@@ -6207,6 +6279,29 @@ case $host_os in
 	# dependencies.
 	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
 	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C++ 5.9
+	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+
+	  # Not sure whether something based on
+	  # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	  # would be better.
+	  output_verbose_link_cmd='echo'
+
+	  # Archives containing C++ object files must be created using
+	  # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	  # necessary to make sure instantiated templates are included
+	  # in the archive.
+	  _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	  ;;
+	esac
+	;;
     esac
     ;;
   lynxos*)
@@ -6245,16 +6340,20 @@ case $host_os in
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
   openbsd*)
-    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    if test -f /usr/libexec/ld.so; then
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      fi
+      output_verbose_link_cmd='echo'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
     fi
-    output_verbose_link_cmd='echo'
     ;;
   osf3*)
     case $cc_basename in
@@ -6383,19 +6482,6 @@ case $host_os in
     # FIXME: insert proper C++ library support
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
-  sco*)
-    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-    case $cc_basename in
-      CC*)
-	# FIXME: insert proper C++ library support
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
-	;;
-      *)
-	# FIXME: insert proper C++ library support
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
-	;;
-    esac
-    ;;
   sunos4*)
     case $cc_basename in
       CC*)
@@ -6418,26 +6504,21 @@ case $host_os in
     case $cc_basename in
       CC*)
 	# Sun C++ 4.2, 5.x and Centerline C++
-     _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
+        _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
 	_LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	$CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
 	case $host_os in
 	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 	  *)
-	    # The C++ compiler is used as linker so we must use $wl
-	    # flag to pass the commands to the underlying system
-	    # linker. We must also pass each convience library through
-	    # to the system linker between allextract/defaultextract.
-	    # The C++ compiler will combine linker options so we
-	    # cannot just pass the convience library names through
-	    # without $wl.
+	    # The compiler driver will combine and reorder linker options,
+	    # but understands `-z linker_flag'.
 	    # Supported since Solaris 2.6 (maybe 2.5.1?)
-	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	    ;;
 	esac
 	_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
@@ -6484,12 +6565,69 @@ case $host_os in
 	  fi
 
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	  case $host_os in
+	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	  *)
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	    ;;
+	  esac
 	fi
 	;;
     esac
     ;;
-  sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*)
+  sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
     _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
+    ;;
+  sysv5* | sco3.2v5* | sco5v6*)
+    # Note: We can NOT use -z defs as we might desire, because we do not
+    # link with -lc, and that would cause any symbols used from libc to
+    # always be unresolved, which means just about no library would
+    # ever link correctly.  If we're not using GNU ld we use -z text
+    # though, which does catch some bad symbols but isn't as heavy-handed
+    # as -z defs.
+    # For security reasons, it is highly recommended that you always
+    # use absolute paths for naming shared libraries, and exclude the
+    # DT_RUNPATH tag from executables and libraries.  But doing so
+    # requires that you compile everything twice, which is a pain.
+    # So that behaviour is only enabled if SCOABSPATH is set to a
+    # non-empty value in the environment.  Most likely only useful for
+    # creating official distributions of packages.
+    # This is a hack until libtool officially supports absolute path
+    # names for shared libraries.
+    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+    _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
     ;;
   tandem*)
     case $cc_basename in
@@ -6530,8 +6668,6 @@ AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
 AC_LIBTOOL_PROG_LD_SHLIBS($1)
 AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
 AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-AC_LIBTOOL_SYS_LIB_STRIP
-AC_LIBTOOL_DLOPEN_SELF($1)
 
 AC_LIBTOOL_CONFIG($1)
 
@@ -6549,12 +6685,13 @@ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
 ])# AC_LIBTOOL_LANG_CXX_CONFIG
 
 # AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
-# ------------------------
+# ------------------------------------
 # Figure out "hidden" library dependencies from verbose
 # compiler output when linking a shared library.
 # Parse the compiler output and extract the necessary
 # objects, libraries and library flags.
-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
 dnl we can't use the lt_simple_compile_test_code here,
 dnl because it contains code intended for an executable,
 dnl not a library.  It's possible we should let each
@@ -6679,239 +6816,72 @@ fi
 
 $rm -f confest.$objext
 
+_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+  _LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_AC_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
 # PORTME: override above test on systems where it is broken
 ifelse([$1],[CXX],
 [case $host_os in
+interix[[3-9]]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  _LT_AC_TAGVAR(predep_objects,$1)=
+  _LT_AC_TAGVAR(postdep_objects,$1)=
+  _LT_AC_TAGVAR(postdeps,$1)=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+    #
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
 solaris*)
   case $cc_basename in
   CC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
     # Adding this requires a known-good setup of shared libraries for
     # Sun compiler versions before 5.6, else PIC objects from an old
     # archive will be linked into the output, leading to subtle bugs.
-    _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
     ;;
   esac
+  ;;
 esac
 ])
-
 case " $_LT_AC_TAGVAR(postdeps, $1) " in
 *" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
 esac
 ])# AC_LIBTOOL_POSTDEP_PREDEP
 
-# AC_LIBTOOL_LANG_F77_CONFIG
-# ------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-#AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
-#AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
-#[AC_REQUIRE([AC_PROG_F77])
-#AC_LANG_SAVE
-#AC_LANG_FORTRAN77
-#
-#_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-#_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-#_LT_AC_TAGVAR(always_export_symbols, $1)=no
-#_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-#_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-#_LT_AC_TAGVAR(hardcode_direct, $1)=no
-#_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-#_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-#_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-#_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-#_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-#_LT_AC_TAGVAR(module_cmds, $1)=
-#_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-#_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-#_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-#_LT_AC_TAGVAR(no_undefined_flag, $1)=
-#_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-#_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-#
-## Source file extension for f77 test sources.
-#ac_ext=f
-#
-## Object file extension for compiled f77 test sources.
-#objext=o
-#_LT_AC_TAGVAR(objext, $1)=$objext
-#
-## Code to be used in simple compile tests
-#lt_simple_compile_test_code="      subroutine t\n      return\n      end\n"
-#
-## Code to be used in simple link tests
-#lt_simple_link_test_code="      program t\n      end\n"
-#
-## ltmain only uses $CC for tagged configurations so make sure $CC is set.
-#_LT_AC_SYS_COMPILER
-#
-## save warnings/boilerplate of simple test code
-#_LT_COMPILER_BOILERPLATE
-#_LT_LINKER_BOILERPLATE
-#
-## Allow CC to be a program name with arguments.
-#lt_save_CC="$CC"
-#CC=${F77-"f77"}
-#compiler=$CC
-#_LT_AC_TAGVAR(compiler, $1)=$CC
-#_LT_CC_BASENAME([$compiler])
-#
-#AC_MSG_CHECKING([if libtool supports shared libraries])
-#AC_MSG_RESULT([$can_build_shared])
-#
-#AC_MSG_CHECKING([whether to build shared libraries])
-#test "$can_build_shared" = "no" && enable_shared=no
-#
-## On AIX, shared libraries and static libraries use the same namespace, and
-## are all built from PIC.
-#case "$host_os" in
-#aix3*)
-#  test "$enable_shared" = yes && enable_static=no
-#  if test -n "$RANLIB"; then
-#    archive_cmds="$archive_cmds~\$RANLIB \$lib"
-#    postinstall_cmds='$RANLIB $lib'
-#  fi
-#  ;;
-#aix4* | aix5*)
-#  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-#    test "$enable_shared" = yes && enable_static=no
-#  fi
-#  ;;
-#esac
-#AC_MSG_RESULT([$enable_shared])
-#
-#AC_MSG_CHECKING([whether to build static libraries])
-## Make sure either enable_shared or enable_static is yes.
-#test "$enable_shared" = yes || enable_static=yes
-#AC_MSG_RESULT([$enable_static])
-#
-#test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-#
-#_LT_AC_TAGVAR(GCC, $1)="$G77"
-#_LT_AC_TAGVAR(LD, $1)="$LD"
-#
-#AC_LIBTOOL_PROG_COMPILER_PIC($1)
-#AC_LIBTOOL_PROG_CC_C_O($1)
-#AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-#AC_LIBTOOL_PROG_LD_SHLIBS($1)
-#AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-#AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-#AC_LIBTOOL_SYS_LIB_STRIP
-#
-#
-#AC_LIBTOOL_CONFIG($1)
-#
-#AC_LANG_RESTORE
-#CC="$lt_save_CC"
-#])# AC_LIBTOOL_LANG_F77_CONFIG
-
-
-# AC_LIBTOOL_LANG_GCJ_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-#AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
-#AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
-#[AC_LANG_SAVE
-#
-## Source file extension for Java test sources.
-#ac_ext=java
-#
-## Object file extension for compiled Java test sources.
-#objext=o
-#_LT_AC_TAGVAR(objext, $1)=$objext
-#
-## Code to be used in simple compile tests
-#lt_simple_compile_test_code="class foo {}\n"
-#
-## Code to be used in simple link tests
-#lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
-#
-## ltmain only uses $CC for tagged configurations so make sure $CC is set.
-#_LT_AC_SYS_COMPILER
-#
-## save warnings/boilerplate of simple test code
-#_LT_COMPILER_BOILERPLATE
-#_LT_LINKER_BOILERPLATE
-#
-## Allow CC to be a program name with arguments.
-#lt_save_CC="$CC"
-#CC=${GCJ-"gcj"}
-#compiler=$CC
-#_LT_AC_TAGVAR(compiler, $1)=$CC
-#_LT_CC_BASENAME([$compiler])
-#
-## GCJ did not exist at the time GCC didn't implicitly link libc in.
-#_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-#
-#_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-#
-### CAVEAT EMPTOR:
-### There is no encapsulation within the following macros, do not change
-### the running order or otherwise move them around unless you know exactly
-### what you are doing...
-#AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-#AC_LIBTOOL_PROG_COMPILER_PIC($1)
-#AC_LIBTOOL_PROG_CC_C_O($1)
-#AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-#AC_LIBTOOL_PROG_LD_SHLIBS($1)
-#AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-#AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-#AC_LIBTOOL_SYS_LIB_STRIP
-#AC_LIBTOOL_DLOPEN_SELF($1)
-#
-#AC_LIBTOOL_CONFIG($1)
-#
-#AC_LANG_RESTORE
-#CC="$lt_save_CC"
-#])# AC_LIBTOOL_LANG_GCJ_CONFIG
-
-
-# AC_LIBTOOL_LANG_RC_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the Windows resource compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-#AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
-#AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
-#[AC_LANG_SAVE
-#
-## Source file extension for RC test sources.
-#ac_ext=rc
-#
-## Object file extension for compiled RC test sources.
-#objext=o
-#_LT_AC_TAGVAR(objext, $1)=$objext
-#
-## Code to be used in simple compile tests
-#lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-#
-## Code to be used in simple link tests
-#lt_simple_link_test_code="$lt_simple_compile_test_code"
-#
-## ltmain only uses $CC for tagged configurations so make sure $CC is set.
-#_LT_AC_SYS_COMPILER
-#
-## save warnings/boilerplate of simple test code
-#_LT_COMPILER_BOILERPLATE
-#_LT_LINKER_BOILERPLATE
-#
-## Allow CC to be a program name with arguments.
-#lt_save_CC="$CC"
-#CC=${RC-"windres"}
-#compiler=$CC
-#_LT_AC_TAGVAR(compiler, $1)=$CC
-#_LT_CC_BASENAME([$compiler])
-#_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-#
-#AC_LIBTOOL_CONFIG($1)
-#
-#AC_LANG_RESTORE
-#CC="$lt_save_CC"
-#])# AC_LIBTOOL_LANG_RC_CONFIG
-
-
 # AC_LIBTOOL_CONFIG([TAGNAME])
 # ----------------------------
 # If TAGNAME is not passed, then create an initial libtool script
@@ -6932,7 +6902,7 @@ if test -f "$ltmain"; then
   # Now quote all the things that may contain metacharacters while being
   # careful not to overquote the AC_SUBSTed values.  We take copies of the
   # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
     SED SHELL STRIP \
     libname_spec library_names_spec soname_spec extract_expsyms_cmds \
     old_striplib striplib file_magic_cmd finish_cmds finish_eval \
@@ -6959,6 +6929,7 @@ if test -f "$ltmain"; then
     _LT_AC_TAGVAR(predeps, $1) \
     _LT_AC_TAGVAR(postdeps, $1) \
     _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+    _LT_AC_TAGVAR(compiler_lib_search_dirs, $1) \
     _LT_AC_TAGVAR(archive_cmds, $1) \
     _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
     _LT_AC_TAGVAR(postinstall_cmds, $1) \
@@ -6974,6 +6945,7 @@ if test -f "$ltmain"; then
     _LT_AC_TAGVAR(module_cmds, $1) \
     _LT_AC_TAGVAR(module_expsym_cmds, $1) \
     _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+    _LT_AC_TAGVAR(fix_srcfile_path, $1) \
     _LT_AC_TAGVAR(exclude_expsyms, $1) \
     _LT_AC_TAGVAR(include_expsyms, $1); do
 
@@ -7021,7 +6993,7 @@ ifelse([$1], [],
 # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 #
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 # Free Software Foundation, Inc.
 #
 # This file is part of GNU Libtool:
@@ -7102,6 +7074,9 @@ AR_FLAGS=$lt_AR_FLAGS
 # A C compiler.
 LTCC=$lt_LTCC
 
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
 # A language-specific compiler.
 CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
 
@@ -7255,6 +7230,10 @@ predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
 # shared library.
 postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
 
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)
+
 # The library search path used internally by the compiler when linking
 # a shared library.
 compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
@@ -7343,7 +7322,7 @@ sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
 
 # Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
+fix_srcfile_path=$lt_fix_srcfile_path
 
 # Set to yes if exported symbols are required.
 always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
@@ -7426,6 +7405,7 @@ fi
 # ---------------------------------
 AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
 [AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([LT_AC_PROG_SED])
 AC_REQUIRE([AC_PROG_NM])
 AC_REQUIRE([AC_OBJEXT])
 # Check for command to grab the raw symbol name followed by C symbol from nm.
@@ -7462,7 +7442,7 @@ hpux*) # Its linker distinguishes data from code symbols
   lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
   lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
   ;;
-linux*)
+linux* | k*bsd*-gnu)
   if test "$host_cpu" = ia64; then
     symcode='[[ABCDGIRSTW]]'
     lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
@@ -7475,9 +7455,18 @@ irix* | nonstopux*)
 osf*)
   symcode='[[BCDEGQRST]]'
   ;;
-solaris* | sysv5*)
+solaris*)
   symcode='[[BDRT]]'
   ;;
+sco3.2v5*)
+  symcode='[[DT]]'
+  ;;
+sysv4.2uw2*)
+  symcode='[[DT]]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[[ABDT]]'
+  ;;
 sysv4)
   symcode='[[DFNSTU]]'
   ;;
@@ -7594,7 +7583,7 @@ EOF
     echo "$progname: failed program was:" >&5
     cat conftest.$ac_ext >&5
   fi
-  rm -f conftest* conftst*
+  rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
   if test "$pipe_works" = yes; then
@@ -7643,13 +7632,15 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       # like `-m68040'.
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
       ;;
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
       # PIC is the default for these OSes.
       ;;
-    mingw* | os2* | pw32*)
+    mingw* | cygwin* | os2* | pw32*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -7660,6 +7651,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       # DJGPP does not support shared libraries at all
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
       ;;
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
     sysv4*MP*)
       if test -d /usr/nec; then
 	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
@@ -7682,7 +7677,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
     esac
   else
     case $host_os in
-      aix4* | aix5*)
+      aix[[4-9]]*)
 	# All AIX code is PIC.
 	if test "$host_cpu" = ia64; then
 	  # AIX 5 now supports IA64 processor
@@ -7722,21 +7717,21 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    ;;
 	esac
 	;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
+      freebsd* | dragonfly*)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
 	case $cc_basename in
 	  CC*)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
 	    if test "$host_cpu" != ia64; then
 	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -7750,6 +7745,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    ;;
 	esac
 	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
       irix5* | irix6* | nonstopux*)
 	case $cc_basename in
 	  CC*)
@@ -7761,7 +7760,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    ;;
 	esac
 	;;
-      linux*)
+      linux* | k*bsd*-gnu)
 	case $cc_basename in
 	  KCC*)
 	    # KAI C++ Compiler
@@ -7780,7 +7779,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
         _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
         ;;
-	  pgCC*)
+	  pgCC* | pgcpp*)
 	    # Portland Group C++ compiler.
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
@@ -7794,6 +7793,14 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
 	    ;;
 	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	      ;;
+	    esac
 	    ;;
 	esac
 	;;
@@ -7835,15 +7842,6 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	;;
       psos*)
 	;;
-      sco*)
-	case $cc_basename in
-	  CC*)
-	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
       solaris*)
 	case $cc_basename in
 	  CC*)
@@ -7885,7 +7883,14 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    ;;
 	esac
 	;;
-      unixware*)
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	esac
 	;;
       vxworks*)
 	;;
@@ -7916,14 +7921,16 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
       ;;
 
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | pw32* | os2*)
+    mingw* | cygwin* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
       ;;
 
     darwin* | rhapsody*)
@@ -7932,6 +7939,11 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
       ;;
 
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
     msdosdjgpp*)
       # Just because we use GCC doesn't mean we suddenly get shared libraries
       # on systems that don't support them.
@@ -7985,10 +7997,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
        esac
        ;;
 
-    mingw* | pw32* | os2*)
+    mingw* | cygwin* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -8018,7 +8030,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       ;;
 
-    linux*)
+    linux* | k*bsd*-gnu)
       case $cc_basename in
       # old Intel for x86_64 which still supported -KPIC.
       ecc*)
@@ -8045,6 +8057,22 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
         # All Alpha code is PIC.
         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
         ;;
+      *)
+        case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=''
+	  ;;
+	esac
+	;;
       esac
       ;;
 
@@ -8054,9 +8082,8 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
       ;;
 
-    sco3.2v5*)
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic'
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn'
+    rdos*)
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
       ;;
 
     solaris*)
@@ -8076,7 +8103,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       ;;
 
-    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+    sysv4 | sysv4.2uw2* | sysv4.3*)
       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
@@ -8089,6 +8116,12 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       fi
       ;;
 
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
     unicos*)
       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
@@ -8112,7 +8145,7 @@ AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
 #
 if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
   AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
-    _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
+    _LT_AC_TAGVAR(lt_cv_prog_compiler_pic_works, $1),
     [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
     [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
      "" | " "*) ;;
@@ -8130,6 +8163,16 @@ case $host_os in
     _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
     ;;
 esac
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
+AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+  _LT_AC_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+  $lt_tmp_static_flag,
+  [],
+  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
 ])
 
 
@@ -8137,11 +8180,12 @@ esac
 # ------------------------------------
 # See if the linker supports building shared libraries.
 AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
-[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
 ifelse([$1],[CXX],[
   _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   case $host_os in
-  aix4* | aix5*)
+  aix[[4-9]]*)
     # If we're using GNU nm, then we don't want the "-C" option.
     # -C means demangle to AIX nm, but means don't demangle with GNU nm
     if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
@@ -8154,12 +8198,13 @@ ifelse([$1],[CXX],[
     _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
   ;;
   cygwin* | mingw*)
-    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
   ;;
   *)
     _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   esac
+  _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
 ],[
   runpath_var=
   _LT_AC_TAGVAR(allow_undefined_flag, $1)=
@@ -8190,12 +8235,14 @@ ifelse([$1],[CXX],[
   # it will be wrapped by ` (' and `)$', so one must not match beginning or
   # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
   # as well as any symbol that contains `d'.
-  _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
+  _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
   # the symbol is explicitly referenced.  Since portable code cannot
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
   extract_expsyms_cmds=
   # Just being paranoid about ensuring that cc_basename is set.
   _LT_CC_BASENAME([$compiler])
@@ -8208,6 +8255,10 @@ ifelse([$1],[CXX],[
       with_gnu_ld=no
     fi
     ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
   openbsd*)
     with_gnu_ld=no
     ;;
@@ -8217,7 +8268,7 @@ ifelse([$1],[CXX],[
   if test "$with_gnu_ld" = yes; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
-    
+
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
@@ -8238,10 +8289,10 @@ ifelse([$1],[CXX],[
       *\ 2.11.*) ;; # other 2.11 versions
       *) supports_anon_versioning=yes ;;
     esac
-    
+
     # See if GNU ld supports shared libraries.
     case $host_os in
-    aix3* | aix4* | aix5*)
+    aix[[3-9]]*)
       # On AIX/PPC, the GNU linker is very broken
       if test "$host_cpu" != ia64; then
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -8289,10 +8340,10 @@ EOF
       _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_AC_TAGVAR(always_export_symbols, $1)=no
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	# If the export-symbols file already is a .def file (1st line
 	# is EXPORTS), use it as is; otherwise, prepend...
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
@@ -8301,13 +8352,28 @@ EOF
 	  echo EXPORTS > $output_objdir/$soname.def;
 	  cat $export_symbols >> $output_objdir/$soname.def;
 	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
 
-    linux*)
+    interix[[3-9]]*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | k*bsd*-gnu)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	tmp_addflag=
 	case $cc_basename,$host_cpu in
@@ -8315,7 +8381,7 @@ EOF
 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
-	pgf77* | pgf90* | pgf95*)			# Portland Group f77 and f90 compilers
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
@@ -8325,13 +8391,22 @@ EOF
 	ifc* | ifort*)			# Intel Fortran compiler
 	  tmp_addflag=' -nofor_main' ;;
 	esac
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	*)
+	  tmp_sharedflag='-shared' ;;
+	esac
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 
 	if test $supports_anon_versioning = yes; then
 	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
   cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
   $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	  $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
 	fi
       else
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -8348,7 +8423,7 @@ EOF
       fi
       ;;
 
-    solaris* | sysv5*)
+    solaris*)
       if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	cat <<EOF 1>&2
@@ -8369,6 +8444,33 @@ EOF
       fi
       ;;
 
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+	    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+	  else
+	    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+	  fi
+	;;
+      esac
+      ;;
+
     sunos4*)
       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
       wlarc=
@@ -8402,14 +8504,14 @@ EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      if test "$GCC" = yes && test -z "$link_static_flag"; then
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	_LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
       fi
       ;;
 
-    aix4* | aix5*)
+    aix[[4-9]]*)
       if test "$host_cpu" = ia64; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
@@ -8429,13 +8531,14 @@ EOF
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
 	# need to do runtime linking.
-	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	  for ld_flag in $LDFLAGS; do
   	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
   	    aix_use_runtimelinking=yes
   	    break
   	  fi
 	  done
+	  ;;
 	esac
 
 	exp_sym_flag='-bexport'
@@ -8462,7 +8565,7 @@ EOF
   	   strings "$collect2name" | grep resolve_lib_name >/dev/null
 	  then
   	  # We have reworked collect2
-  	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+  	  :
 	  else
   	  # We have old collect2
   	  _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
@@ -8473,6 +8576,7 @@ EOF
   	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
   	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
 	  fi
+	  ;;
 	esac
 	shared_flag='-shared'
 	if test "$aix_use_runtimelinking" = yes; then
@@ -8485,11 +8589,11 @@ EOF
   	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-  	if test "$aix_use_runtimelinking" = yes; then
+	  if test "$aix_use_runtimelinking" = yes; then
 	    shared_flag='${wl}-G'
 	  else
 	    shared_flag='${wl}-bM:SRE'
-  	fi
+	  fi
 	fi
       fi
 
@@ -8503,12 +8607,12 @@ EOF
        # Determine the default libpath from the value encoded in an empty executable.
        _LT_AC_SYS_LIBPATH_AIX
        _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
        else
 	if test "$host_cpu" = ia64; then
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an empty executable.
 	 _LT_AC_SYS_LIBPATH_AIX
@@ -8517,13 +8621,11 @@ EOF
 	  # -berok will link without error, but may produce a broken library.
 	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	  # -bexpall does not export symbols beginning with underscore (_)
-	  _LT_AC_TAGVAR(always_export_symbols, $1)=yes
 	  # Exported symbols can be pulled into shared objects from archives
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
 	  # This is similar to how AIX traditionally builds its shared libraries.
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
       ;;
@@ -8556,7 +8658,7 @@ EOF
       # The linker will automatically build a .lib file if we build a DLL.
       _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
       # FIXME: Should let the user specify the lib program.
-      _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      _LT_AC_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
       _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
@@ -8589,19 +8691,18 @@ EOF
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
     if test "$GCC" = yes ; then
     	output_verbose_link_cmd='echo'
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
     else
       case $cc_basename in
         xlc*)
          output_verbose_link_cmd='echo'
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
           # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
        *)
@@ -8641,7 +8742,7 @@ EOF
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | dragonfly*)
       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
       _LT_AC_TAGVAR(hardcode_direct, $1)=yes
@@ -8664,47 +8765,62 @@ EOF
       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
       ;;
 
-    hpux10* | hpux11*)
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	_LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	_LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      fi
+      ;;
+
+    hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
 	case $host_cpu in
-	hppa*64*|ia64*)
+	hppa*64*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
 	*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
-	hppa*64*|ia64*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hppa*64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       fi
       if test "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
 	case $host_cpu in
-	hppa*64*)
-	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	hppa*64*|ia64*)
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
-	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
 	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
 	  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
 	  ;;
-	ia64*)
-	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
-	  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-	  ;;
 	*)
-	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
 	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
 
@@ -8748,24 +8864,28 @@ EOF
       ;;
 
     openbsd*)
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      if test -f /usr/libexec/ld.so; then
+	_LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+	if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+	     _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	     ;;
+	   *)
+	     _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+        fi
       else
-       case $host_os in
-	 openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
-	   _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	   _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	   ;;
-	 *)
-	   _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	   _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	   ;;
-       esac
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
 
@@ -8806,14 +8926,6 @@ EOF
       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
       ;;
 
-    sco3.2v5*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
-      runpath_var=LD_RUN_PATH
-      hardcode_runpath_var=yes
-      ;;
-
     solaris*)
       _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
       if test "$GCC" = yes; then
@@ -8832,17 +8944,16 @@ EOF
       case $host_os in
       solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
       *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
  	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+	if test "$GCC" = yes; then
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	fi
+	;;
       esac
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
       ;;
@@ -8899,36 +9010,45 @@ EOF
       fi
       ;;
 
-    sysv4.2uw2*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      hardcode_runpath_var=yes
-      runpath_var=LD_RUN_PATH
-      ;;
+      runpath_var='LD_RUN_PATH'
 
-   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[[78]]* | unixware7*)
-      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text'
       if test "$GCC" = yes; then
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
-      runpath_var='LD_RUN_PATH'
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
 
-    sysv5*)
-      _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
-      # $CC -shared without GNU ld will not create a library from C++
-      # object files and a static libstdc++, better avoid it by now
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-  		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
       runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
       ;;
 
     uts4*)
@@ -8946,11 +9066,6 @@ EOF
 AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
 test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
 #
 # Do we need to explicitly link libc?
 #
@@ -8970,7 +9085,7 @@ x|xyes)
       # to ld, don't add -lc before -lgcc.
       AC_MSG_CHECKING([whether -lc should be explicitly linked in])
       $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
       if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
         soname=conftest
@@ -8978,6 +9093,7 @@ x|xyes)
         libobjs=conftest.$ac_objext
         deplibs=
         wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+	pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
         compiler_flags=-v
         linker_flags=-v
         verstring=
@@ -9062,16 +9178,6 @@ AC_DEFUN([AM_PROG_NM],        [AC_PROG_NM])
 # This is just to silence aclocal about the macro not being used
 ifelse([AC_DISABLE_FAST_INSTALL])
 
-#AC_DEFUN([LT_AC_PROG_GCJ],
-#[AC_CHECK_TOOL(GCJ, gcj, no)
-#  test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
-#  AC_SUBST(GCJFLAGS)
-#])
-
-#AC_DEFUN([LT_AC_PROG_RC],
-#[AC_CHECK_TOOL(RC, windres, no)
-#])
-
 ############################################################
 # NOTE: This macro has been submitted for inclusion into   #
 #  GNU Autoconf as AC_PROG_SED.  When it is available in   #
diff --git a/build/libtool.m4 b/build/libtool.m4
index 064582c..268cad9 100644
--- a/build/libtool.m4
+++ b/build/libtool.m4
@@ -1,13 +1,13 @@
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
-## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
-## Free Software Foundation, Inc.
+## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007,
+## 2008  Free Software Foundation, Inc.
 ## Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 ##
 ## This file is free software; the Free Software Foundation gives
 ## unlimited permission to copy and/or distribute it, with or without
 ## modifications, as long as this notice is preserved.
 
-# serial 47 AC_PROG_LIBTOOL
+# serial 52 AC_PROG_LIBTOOL
 
 ifdef([AC_ACVERSION],[
 # autoconf 2.13 compatibility
@@ -44,30 +44,6 @@ dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
     [AC_LIBTOOL_CXX],
     [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
   ])])
-
-dnl dnl And a similar setup for Fortran 77 support
-dnl   AC_PROVIDE_IFELSE([AC_PROG_F77],
-dnl     [AC_LIBTOOL_F77],
-dnl     [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
-dnl ])])
-
-dnl dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
-dnl dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
-dnl dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
-dnl   AC_PROVIDE_IFELSE([AC_PROG_GCJ],
-dnl     [AC_LIBTOOL_GCJ],
-dnl     [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
-dnl       [AC_LIBTOOL_GCJ],
-dnl       [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
-dnl 	[AC_LIBTOOL_GCJ],
-dnl       [ifdef([AC_PROG_GCJ],
-dnl 	     [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
-dnl        ifdef([A][M_PROG_GCJ],
-dnl 	     [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
-dnl        ifdef([LT_AC_PROG_GCJ],
-dnl 	     [define([LT_AC_PROG_GCJ],
-dnl 		defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
-dnl ])
 ])# AC_PROG_LIBTOOL
 
 
@@ -76,8 +52,6 @@ dnl ])
 AC_DEFUN([_AC_PROG_LIBTOOL],
 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
 AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
-dnl AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
-dnl AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
 
 # This can be used to rebuild libtool when needed
 LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
@@ -111,7 +85,6 @@ AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
 AC_REQUIRE([AC_OBJEXT])dnl
 AC_REQUIRE([AC_EXEEXT])dnl
 dnl
-
 AC_LIBTOOL_SYS_MAX_CMD_LEN
 AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
 AC_LIBTOOL_OBJDIR
@@ -173,6 +146,7 @@ test -z "$AR_FLAGS" && AR_FLAGS=cru
 test -z "$AS" && AS=as
 test -z "$CC" && CC=cc
 test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 test -z "$DLLTOOL" && DLLTOOL=dlltool
 test -z "$LD" && LD=ld
 test -z "$LN_S" && LN_S="ln -s"
@@ -185,17 +159,17 @@ test -z "$STRIP" && STRIP=:
 test -z "$ac_objext" && ac_objext=o
 
 # Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
 old_postinstall_cmds='chmod 644 $oldlib'
 old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
   openbsd*)
-    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
     ;;
   *)
-    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
     ;;
   esac
   old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
@@ -212,6 +186,8 @@ file_magic*)
   ;;
 esac
 
+_LT_REQUIRED_DARWIN_CHECKS
+
 AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
 AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
 enable_win32_dll=yes, enable_win32_dll=no)
@@ -241,6 +217,9 @@ AC_DEFUN([_LT_AC_SYS_COMPILER],
 # If no C compiler was specified, use CC.
 LTCC=${LTCC-"$CC"}
 
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
 # Allow CC to be a program name with arguments.
 compiler=$CC
 ])# _LT_AC_SYS_COMPILER
@@ -267,9 +246,10 @@ cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 # Check for compiler boilerplate output or warnings with
 # the simple compiler test code.
 AC_DEFUN([_LT_COMPILER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_compiler_boilerplate=`cat conftest.err`
 $rm conftest*
 ])# _LT_COMPILER_BOILERPLATE
@@ -280,11 +260,12 @@ $rm conftest*
 # Check for linker boilerplate output or warnings with
 # the simple link test code.
 AC_DEFUN([_LT_LINKER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+$rm -r conftest*
 ])# _LT_LINKER_BOILERPLATE
 
 
@@ -300,7 +281,7 @@ int main() {
 ; return 0; }
 EOF
 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
-  ifelse([$1], , :, [$1
+ ifelse([$1], , :, [$1
   rm -rf conftest*])
 else
   echo "configure: failed program was:" >&5
@@ -311,6 +292,75 @@ ifelse([$2], , , [$2
 fi
 rm -f conftest*])
 
+# _LT_REQUIRED_DARWIN_CHECKS
+# --------------------------
+# Check for some things on darwin
+AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS],[
+  case $host_os in
+    rhapsody* | darwin*)
+    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+
+    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+      [lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+   # By default we will add the -single_module flag. You can override
+   # by either setting the environment variable LT_MULTI_MODULE
+   # non-empty at configure time, or by adding -multi_module to the
+   # link flags.
+   echo "int foo(void){return 1;}" > conftest.c
+   $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+     -dynamiclib ${wl}-single_module conftest.c
+   if test -f libconftest.dylib; then
+     lt_cv_apple_cc_single_mod=yes
+     rm -rf libconftest.dylib*
+   fi
+   rm conftest.c
+      fi])
+    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+      [lt_cv_ld_exported_symbols_list],
+      [lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      _LT_AC_TRY_LINK([lt_cv_ld_exported_symbols_list=yes],[lt_cv_ld_exported_symbols_list=no])
+   LDFLAGS="$save_LDFLAGS"
+    ])
+    case $host_os in
+    rhapsody* | darwin1.[[0123]])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*)
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+   10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+   10.[[012]]*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+   10.*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}"
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil="~$DSYMUTIL \$lib || :"
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+])
 
 # _LT_AC_SYS_LIBPATH_AIX
 # ----------------------
@@ -321,12 +371,20 @@ rm -f conftest*])
 # If we don't find anything, use the default library path according
 # to the aix ld manual.
 AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
-[_LT_AC_TRY_LINK([
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+_LT_AC_TRY_LINK([
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
 # Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi],[])
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi],[])
 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 ])# _LT_AC_SYS_LIBPATH_AIX
 
@@ -557,13 +615,17 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+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 AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
     *32-bit*)
       case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_i386_fbsd"
+          ;;
         x86_64-*linux*)
           LD="${LD-ld} -m elf_i386"
           ;;
@@ -580,6 +642,9 @@ x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
       ;;
     *64-bit*)
       case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_x86_64_fbsd"
+          ;;
         x86_64-*linux*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
@@ -613,6 +678,26 @@ x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
     CFLAGS="$SAVE_CFLAGS"
   fi
   ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+        if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
 AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
 [*-*-cygwin* | *-*-mingw* | *-*-pw32*)
   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
@@ -636,7 +721,7 @@ AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
 AC_CACHE_CHECK([$1], [$2],
   [$2=no
   ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
    lt_compiler_flag="$3"
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
@@ -655,9 +740,9 @@ AC_CACHE_CHECK([$1], [$2],
    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.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
        $2=yes
      fi
    fi
@@ -677,19 +762,20 @@ fi
 # ------------------------------------------------------------
 # Check whether the given compiler option works
 AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
-[AC_CACHE_CHECK([$1], [$2],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
   [$2=no
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $3"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
      # The linker can only warn and ignore the option if not recognized
      # So say no if there are warnings
      if test -s conftest.err; then
        # Append any errors to the config.log.
        cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
-       $SED '/^$/d' conftest.err >conftest.er2
+       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
        if diff conftest.exp conftest.er2 >/dev/null; then
          $2=yes
        fi
@@ -697,7 +783,7 @@ AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
        $2=yes
      fi
    fi
-   $rm conftest*
+   $rm -r conftest*
    LDFLAGS="$save_LDFLAGS"
 ])
 
@@ -758,44 +844,64 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     elif test -x /usr/sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
     else
-      lt_cv_sys_max_cmd_len=65536     # usable default for all BSDs
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
     fi
     # And add a safety zone
     lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
     lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
   osf*)
     # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
     # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
     # nice to cause kernel panics so lets avoid the loop below.
     # First set a reasonable default.
     lt_cv_sys_max_cmd_len=16384
-    # 
+    #
     if test -x /sbin/sysconfig; then
       case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
         *1*) lt_cv_sys_max_cmd_len=-1 ;;
       esac
     fi
     ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ 	]]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
   *)
-    # If test is not a shell built-in, we'll probably end up computing a
-    # maximum length that is only half of the actual maximum length, but
-    # we can't tell.
-    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-    while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
 	       = "XX$teststring") >/dev/null 2>&1 &&
-	    new_result=`expr "X$teststring" : ".*" 2>&1` &&
-	    lt_cv_sys_max_cmd_len=$new_result &&
-	    test $i != 17 # 1/2 MB should be enough
-    do
-      i=`expr $i + 1`
-      teststring=$teststring$teststring
-    done
-    teststring=
-    # Add a significant safety factor because C++ compilers can tack on massive
-    # amounts of additional arguments before passing them to the linker.
-    # It appears as though 1/2 is a usable value.
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+	      new_result=`expr "X$teststring" : ".*" 2>&1` &&
+	      lt_cv_sys_max_cmd_len=$new_result &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on massive
+      # amounts of additional arguments before passing them to the linker.
+      # It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
     ;;
   esac
 ])
@@ -808,7 +914,7 @@ fi
 
 
 # _LT_AC_CHECK_DLFCN
-# --------------------
+# ------------------
 AC_DEFUN([_LT_AC_CHECK_DLFCN],
 [AC_CHECK_HEADERS(dlfcn.h)dnl
 ])# _LT_AC_CHECK_DLFCN
@@ -816,7 +922,7 @@ AC_DEFUN([_LT_AC_CHECK_DLFCN],
 
 # _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
 #                           ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
-# ------------------------------------------------------------------
+# ---------------------------------------------------------------------
 AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
 [AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
 if test "$cross_compiling" = yes; then :
@@ -882,6 +988,8 @@ int main ()
       else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
       /* dlclose (self); */
     }
+  else
+    puts (dlerror ());
 
     exit (status);
 }]
@@ -892,7 +1000,7 @@ EOF
     case x$lt_status in
       x$lt_dlno_uscore) $1 ;;
       x$lt_dlneed_uscore) $2 ;;
-      x$lt_unknown|x*) $3 ;;
+      x$lt_dlunknown|x*) $3 ;;
     esac
   else :
     # compilation failed
@@ -904,7 +1012,7 @@ rm -fr conftest*
 
 
 # AC_LIBTOOL_DLOPEN_SELF
-# -------------------
+# ----------------------
 AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
 [AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
 if test "x$enable_dlopen" != xyes; then
@@ -946,7 +1054,7 @@ else
     AC_CHECK_FUNC([shl_load],
 	  [lt_cv_dlopen="shl_load"],
       [AC_CHECK_LIB([dld], [shl_load],
-	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
 	[AC_CHECK_FUNC([dlopen],
 	      [lt_cv_dlopen="dlopen"],
 	  [AC_CHECK_LIB([dl], [dlopen],
@@ -954,7 +1062,7 @@ else
 	    [AC_CHECK_LIB([svld], [dlopen],
 		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
 	      [AC_CHECK_LIB([dld], [dld_link],
-		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
 	      ])
 	    ])
 	  ])
@@ -975,7 +1083,7 @@ else
     test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
     save_LDFLAGS="$LDFLAGS"
-    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
     save_LIBS="$LIBS"
     LIBS="$lt_cv_dlopen_libs $LIBS"
@@ -988,7 +1096,7 @@ else
     ])
 
     if test "x$lt_cv_dlopen_self" = xyes; then
-      LDFLAGS="$LDFLAGS $link_static_flag"
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
     	  lt_cv_dlopen_self_static, [dnl
 	  _LT_AC_TRY_DLOPEN_SELF(
@@ -1020,7 +1128,8 @@ fi
 # ---------------------------------
 # Check to see if options -c and -o are simultaneously supported by compiler
 AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
 AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
   [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
   [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
@@ -1028,7 +1137,7 @@ AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
    mkdir conftest
    cd conftest
    mkdir out
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
    lt_compiler_flag="-o out/conftest2.$ac_objext"
    # Insert the option either (1) after the last *FLAGS variable, or
@@ -1048,9 +1157,9 @@ AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
        _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
      fi
    fi
@@ -1168,6 +1277,7 @@ else
    darwin*)
        if test -n "$STRIP" ; then
          striplib="$STRIP -x"
+         old_striplib="$STRIP -S"
          AC_MSG_RESULT([yes])
        else
   AC_MSG_RESULT([no])
@@ -1185,7 +1295,8 @@ fi
 # -----------------------------
 # PORTME Fill in your ld.so characteristics
 AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
-[AC_MSG_CHECKING([dynamic linker characteristics])
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
@@ -1199,20 +1310,58 @@ shlibpath_overrides_runpath=unknown
 version_type=none
 dynamic_linker="$host_os ld.so"
 sys_lib_dlsearch_path_spec="/lib /usr/lib"
+ifelse($1,[],[
 if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$lt_search_path_spec" | grep ';' >/dev/null ; then
     # if the path contains ";" then we assume it to be the separator
     # otherwise default to the standard path separator (i.e. ":") - it is
     # assumed that no part of a normal pathname contains ";" but that should
     # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e 's/;/ /g'`
   else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
   fi
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`echo $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+  sys_lib_search_path_spec=`echo $lt_search_path_spec`
 else
   sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
+fi])
 need_lib_prefix=unknown
 hardcode_into_libs=no
 
@@ -1230,7 +1379,7 @@ aix3*)
   soname_spec='${libname}${release}${shared_ext}$major'
   ;;
 
-aix4* | aix5*)
+aix[[4-9]]*)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -1369,12 +1518,8 @@ darwin* | rhapsody*)
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
+  ifelse([$1], [],[
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) 
   sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
   ;;
 
@@ -1391,18 +1536,6 @@ freebsd1*)
   dynamic_linker=no
   ;;
 
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
@@ -1435,10 +1568,15 @@ freebsd* | dragonfly*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
-  *) # from 3.2 on
+  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
     shlibpath_overrides_runpath=no
     hardcode_into_libs=yes
     ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
   esac
   ;;
 
@@ -1498,6 +1636,18 @@ hpux9* | hpux10* | hpux11*)
   postinstall_cmds='chmod 555 $lib'
   ;;
 
+interix[[3-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
 irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
@@ -1541,7 +1691,7 @@ linux*oldld* | linux*aout* | linux*coff*)
   ;;
 
 # This must be Linux ELF.
-linux*)
+linux* | k*bsd*-gnu)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -1555,27 +1705,10 @@ linux*)
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # find out which ABI we are using
-  libsuff=
-  case $host_cpu in
-  x86_64*|s390x*|powerpc64*)
-    echo '[#]line __oline__ "configure"' > conftest.$ac_ext
-    if AC_TRY_EVAL(ac_compile); then
-      case `/usr/bin/file conftest.$ac_objext` in
-      *64-bit*)
-        libsuff=64
-        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
-        ;;
-      esac
-    fi
-    rm -rf conftest*
-    ;;
-  esac
-
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ 	]*hwcap[ 	]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -1587,18 +1720,6 @@ linux*)
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -1636,6 +1757,7 @@ nto-qnx*)
 
 openbsd*)
   version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
   need_lib_prefix=no
   # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
   case $host_os in
@@ -1679,11 +1801,8 @@ osf3* | osf4* | osf5*)
   sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
   ;;
 
-sco3.2v5*)
-  version_type=osf
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
+rdos*)
+  dynamic_linker=no
   ;;
 
 solaris*)
@@ -1711,7 +1830,7 @@ sunos4*)
   need_version=yes
   ;;
 
-sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+sysv4 | sysv4.3*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
@@ -1744,6 +1863,29 @@ sysv4*MP*)
   fi
   ;;
 
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+    shlibpath_overrides_runpath=no
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    shlibpath_overrides_runpath=yes
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
 uts4*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -1757,13 +1899,26 @@ uts4*)
 esac
 AC_MSG_RESULT([$dynamic_linker])
 test "$dynamic_linker" = no && can_build_shared=no
+
+AC_CACHE_VAL([lt_cv_sys_lib_search_path_spec],
+[lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"])
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+AC_CACHE_VAL([lt_cv_sys_lib_dlsearch_path_spec],
+[lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"])
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
 ])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
 
 
 # _LT_AC_TAGCONFIG
 # ----------------
 AC_DEFUN([_LT_AC_TAGCONFIG],
-[AC_ARG_WITH([tags],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_ARG_WITH([tags],
 [  --with-tags[=TAGS]      include additional configurations [automatic]
 ],
 [tagnames="$withval"])
@@ -1781,6 +1936,9 @@ if test -f "$ltmain" && test -n "$tagnames"; then
       AC_MSG_WARN([using \`LTCC=$LTCC', extracted from \`$ofile'])
     fi
   fi
+  if test -z "$LTCFLAGS"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
+  fi
 
   # Extract list of available tagged configurations in $ofile.
   # Note that this assumes the entire list is on one line.
@@ -1816,26 +1974,6 @@ if test -f "$ltmain" && test -n "$tagnames"; then
 	fi
 	;;
 
-#      F77)
-#	if test -n "$F77" && test "X$F77" != "Xno"; then
-#	  AC_LIBTOOL_LANG_F77_CONFIG
-#	else
-#	  tagname=""
-#	fi
-#	;;
-#
-#      GCJ)
-#	if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
-#	  AC_LIBTOOL_LANG_GCJ_CONFIG
-#	else
-#	  tagname=""
-#	fi
-#	;;
-#
-#      RC)
-#	AC_LIBTOOL_LANG_RC_CONFIG
-#	;;
-
       *)
 	AC_MSG_ERROR([Unsupported tag name: $tagname])
 	;;
@@ -1910,7 +2048,7 @@ changequote([, ])dnl
 
 # AC_DISABLE_SHARED
 # -----------------
-#- set the default shared flag to --disable-shared
+# set the default shared flag to --disable-shared
 AC_DEFUN([AC_DISABLE_SHARED],
 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
 AC_ENABLE_SHARED(no)
@@ -2009,8 +2147,6 @@ pic_mode=ifelse($#,1,$1,default)
 
 # AC_PROG_EGREP
 # -------------
-# This is predefined starting with Autoconf 2.54, so this conditional
-# definition can be removed once we require Autoconf 2.54 or later.
 ifdef([AC_PROG_EGREP], [], [AC_DEFUN([AC_PROG_EGREP],
 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
@@ -2024,7 +2160,7 @@ ifdef([AC_PROG_EGREP], [], [AC_DEFUN([AC_PROG_EGREP],
 
 # AC_PATH_TOOL_PREFIX
 # -------------------
-# find a file program which can recognise shared library
+# find a file program which can recognize shared library
 AC_DEFUN([AC_PATH_TOOL_PREFIX],
 [AC_REQUIRE([AC_PROG_EGREP])dnl
 AC_MSG_CHECKING([for $1])
@@ -2087,7 +2223,7 @@ fi
 
 # AC_PATH_MAGIC
 # -------------
-# find a file program which can recognise a shared library
+# find a file program which can recognize a shared library
 AC_DEFUN([AC_PATH_MAGIC],
 [AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
 if test -z "$lt_cv_path_MAGIC_CMD"; then
@@ -2219,7 +2355,7 @@ reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   darwin*)
     if test "$GCC" = yes; then
-      reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs'
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -2233,7 +2369,7 @@ esac
 # how to check for library dependencies
 #  -- PORTME fill in with the dynamic library characteristics
 AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
-[AC_CACHE_CHECK([how to recognise dependent libraries],
+[AC_CACHE_CHECK([how to recognize dependent libraries],
 lt_cv_deplibs_check_method,
 [lt_cv_file_magic_cmd='$MAGIC_CMD'
 lt_cv_file_magic_test_file=
@@ -2250,7 +2386,7 @@ lt_cv_deplibs_check_method='unknown'
 # whether `pass_all' will *always* work, you probably want this one.
 
 case $host_os in
-aix4* | aix5*)
+aix[[4-9]]*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -2272,16 +2408,22 @@ cygwin*)
 
 mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
-  # func_win32_libid shell function, so use a weaker test based on 'objdump'.
-  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
-  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
   ;;
 
 darwin* | rhapsody*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | kfreebsd*-gnu | dragonfly*)
+freebsd* | dragonfly*)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
@@ -2319,6 +2461,11 @@ hpux10.20* | hpux11*)
   esac
   ;;
 
+interix[[3-9]]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+  ;;
+
 irix5* | irix6* | nonstopux*)
   case $LD in
   *-32|*"-32 ") libmagic=32-bit;;
@@ -2330,7 +2477,7 @@ irix5* | irix6* | nonstopux*)
   ;;
 
 # This must be Linux ELF.
-linux*)
+linux* | k*bsd*-gnu)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -2364,7 +2511,7 @@ osf3* | osf4* | osf5*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-sco3.2v5*)
+rdos*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -2372,7 +2519,7 @@ solaris*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+sysv4 | sysv4.3*)
   case $host_vendor in
   motorola)
     lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
@@ -2393,10 +2540,13 @@ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
   siemens)
     lt_cv_deplibs_check_method=pass_all
     ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
   esac
   ;;
 
-sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*)
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 esac
@@ -2416,36 +2566,43 @@ AC_DEFUN([AC_PROG_NM],
   # Let the user override the test.
   lt_cv_path_NM="$NM"
 else
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    tmp_nm="$ac_dir/${ac_tool_prefix}nm"
-    if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-      # Check to see if the nm accepts a BSD-compat flag.
-      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
-      #   nm: unknown option "B" ignored
-      # Tru64's nm complains that /dev/null is an invalid object file
-      case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-      */dev/null* | *'Invalid file or object type'*)
-	lt_cv_path_NM="$tmp_nm -B"
-	break
-        ;;
-      *)
-	case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	*/dev/null*)
-	  lt_cv_path_NM="$tmp_nm -p"
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
 	  break
 	  ;;
 	*)
-	  lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	  continue # so that we can try to find one that supports BSD flags
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
 	  ;;
 	esac
-      esac
-    fi
+      fi
+    done
+    IFS="$lt_save_ifs"
   done
-  IFS="$lt_save_ifs"
   test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
 fi])
 NM="$lt_cv_path_NM"
@@ -2551,7 +2708,7 @@ _LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
 ])# _LT_AC_LANG_CXX
 
 # _LT_AC_PROG_CXXCPP
-# ---------------
+# ------------------
 AC_DEFUN([_LT_AC_PROG_CXXCPP],
 [
 AC_REQUIRE([AC_PROG_CXX])
@@ -2562,52 +2719,6 @@ if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
 fi
 ])# _LT_AC_PROG_CXXCPP
 
-# AC_LIBTOOL_F77
-# --------------
-# enable support for Fortran 77 libraries
-#AC_DEFUN([AC_LIBTOOL_F77],
-#[AC_REQUIRE([_LT_AC_LANG_F77])
-#])# AC_LIBTOOL_F77
-
-
-# _LT_AC_LANG_F77
-# ---------------
-#AC_DEFUN([_LT_AC_LANG_F77],
-#[AC_REQUIRE([AC_PROG_F77])
-#_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
-#])# _LT_AC_LANG_F77
-
-
-# AC_LIBTOOL_GCJ
-# --------------
-# enable support for GCJ libraries
-#AC_DEFUN([AC_LIBTOOL_GCJ],
-#[AC_REQUIRE([_LT_AC_LANG_GCJ])
-#])# AC_LIBTOOL_GCJ
-
-
-# _LT_AC_LANG_GCJ
-# ---------------
-#AC_DEFUN([_LT_AC_LANG_GCJ],
-#[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
-#  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
-#    [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
-#      [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
-#	 [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
-#	   [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
-#_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
-#])# _LT_AC_LANG_GCJ
-
-
-# AC_LIBTOOL_RC
-# --------------
-# enable support for Windows resource files
-#AC_DEFUN([AC_LIBTOOL_RC],
-#[AC_REQUIRE([LT_AC_PROG_RC])
-#_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
-#])# AC_LIBTOOL_RC
-
-
 # AC_LIBTOOL_LANG_C_CONFIG
 # ------------------------
 # Ensure that the configuration vars for the C compiler are
@@ -2627,10 +2738,10 @@ objext=o
 _LT_AC_TAGVAR(objext, $1)=$objext
 
 # Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
+lt_simple_compile_test_code="int some_variable = 0;"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
+lt_simple_link_test_code='int main(){return(0);}'
 
 _LT_AC_SYS_COMPILER
 
@@ -2638,37 +2749,6 @@ _LT_AC_SYS_COMPILER
 _LT_COMPILER_BOILERPLATE
 _LT_LINKER_BOILERPLATE
 
-#
-# Check for any special shared library compilation flags.
-#
-_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)=
-if test "$GCC" = no; then
-  case $host_os in
-  sco3.2v5*)
-    _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf'
-    ;;
-  esac
-fi
-if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then
-  AC_MSG_WARN([\`$CC' requires \`$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries])
-  if echo "$old_CC $old_CFLAGS " | grep "[[ 	]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[ 	]]" >/dev/null; then :
-  else
-    AC_MSG_WARN([add \`$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure])
-    _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no
-  fi
-fi
-
-
-#
-# Check to make sure the static flag actually works.
-#
-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works],
-  _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
-  $_LT_AC_TAGVAR(lt_prog_compiler_static, $1),
-  [],
-  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
-
-
 ## CAVEAT EMPTOR:
 ## There is no encapsulation within the following macros, do not change
 ## the running order or otherwise move them around unless you know exactly
@@ -2681,9 +2761,9 @@ AC_LIBTOOL_PROG_LD_SHLIBS($1)
 AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
 AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
 AC_LIBTOOL_SYS_LIB_STRIP
-AC_LIBTOOL_DLOPEN_SELF($1)
+AC_LIBTOOL_DLOPEN_SELF
 
-# Report which librarie types wil actually be built
+# Report which library types will actually be built
 AC_MSG_CHECKING([if libtool supports shared libraries])
 AC_MSG_RESULT([$can_build_shared])
 
@@ -2701,7 +2781,7 @@ aix3*)
   fi
   ;;
 
-aix4* | aix5*)
+aix[[4-9]]*)
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
@@ -2743,6 +2823,7 @@ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
 _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
 _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
 _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
 _LT_AC_TAGVAR(hardcode_automatic, $1)=no
 _LT_AC_TAGVAR(module_cmds, $1)=
 _LT_AC_TAGVAR(module_expsym_cmds, $1)=
@@ -2758,6 +2839,7 @@ _LT_AC_TAGVAR(postdep_objects, $1)=
 _LT_AC_TAGVAR(predeps, $1)=
 _LT_AC_TAGVAR(postdeps, $1)=
 _LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=
 
 # Source file extension for C++ test sources.
 ac_ext=cpp
@@ -2767,10 +2849,10 @@ objext=o
 _LT_AC_TAGVAR(objext, $1)=$objext
 
 # Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
+lt_simple_compile_test_code="int some_variable = 0;"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
+lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
@@ -2867,7 +2949,7 @@ case $host_os in
     # FIXME: insert proper C++ library support
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
-  aix4* | aix5*)
+  aix[[4-9]]*)
     if test "$host_cpu" = ia64; then
       # On IA64, the linker does run time linking by default, so we don't
       # have to do anything special.
@@ -2880,7 +2962,7 @@ case $host_os in
       # Test if we are trying to use run time linking or normal
       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
       # need to do runtime linking.
-      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	for ld_flag in $LDFLAGS; do
 	  case $ld_flag in
 	  *-brtl*)
@@ -2889,6 +2971,7 @@ case $host_os in
 	    ;;
 	  esac
 	done
+	;;
       esac
 
       exp_sym_flag='-bexport'
@@ -2915,7 +2998,7 @@ case $host_os in
 	   strings "$collect2name" | grep resolve_lib_name >/dev/null
 	then
 	  # We have reworked collect2
-	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	  :
 	else
 	  # We have old collect2
 	  _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
@@ -2926,6 +3009,7 @@ case $host_os in
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
 	fi
+	;;
       esac
       shared_flag='-shared'
       if test "$aix_use_runtimelinking" = yes; then
@@ -2957,12 +3041,12 @@ case $host_os in
       _LT_AC_SYS_LIBPATH_AIX
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
 
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
      else
       if test "$host_cpu" = ia64; then
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
       else
 	# Determine the default libpath from the value encoded in an empty executable.
 	_LT_AC_SYS_LIBPATH_AIX
@@ -2971,16 +3055,26 @@ case $host_os in
 	# -berok will link without error, but may produce a broken library.
 	_LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	# -bexpall does not export symbols beginning with underscore (_)
-	_LT_AC_TAGVAR(always_export_symbols, $1)=yes
 	# Exported symbols can be pulled into shared objects from archives
-	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
 	# This is similar to how AIX traditionally builds its shared libraries.
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
       fi
     fi
     ;;
+
+  beos*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+      # support --undefined.  This deserves some investigation.  FIXME
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+    ;;
+
   chorus*)
     case $cc_basename in
       *)
@@ -2990,7 +3084,6 @@ case $host_os in
     esac
     ;;
 
-
   cygwin* | mingw* | pw32*)
     # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
     # as there is no search path for DLLs.
@@ -3000,7 +3093,7 @@ case $host_os in
     _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
     if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       # If the export-symbols file already is a .def file (1st line
       # is EXPORTS), use it as is; otherwise, prepend...
       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
@@ -3009,65 +3102,37 @@ case $host_os in
 	echo EXPORTS > $output_objdir/$soname.def;
 	cat $export_symbols >> $output_objdir/$soname.def;
       fi~
-      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
     else
       _LT_AC_TAGVAR(ld_shlibs, $1)=no
     fi
   ;;
       darwin* | rhapsody*)
-        case $host_os in
-        rhapsody* | darwin1.[[012]])
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[[012]])
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+      if test "$GXX" = yes ; then
       output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
+      _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+      _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+      _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+      if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+        _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
       fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      else
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       else
       case $cc_basename in
         xlc*)
          output_verbose_link_cmd='echo'
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
           _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
           # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
        *)
@@ -3101,7 +3166,7 @@ case $host_os in
   freebsd-elf*)
     _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
     ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
+  freebsd* | dragonfly*)
     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
     # conventions
     _LT_AC_TAGVAR(ld_shlibs, $1)=yes
@@ -3146,34 +3211,21 @@ case $host_os in
     ;;
   hpux10*|hpux11*)
     if test $with_gnu_ld = no; then
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
       case $host_cpu in
-      hppa*64*)
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
-	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-        ;;
-      ia64*)
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-        ;;
+      hppa*64*|ia64*) ;;
       *)
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         ;;
       esac
     fi
     case $host_cpu in
-    hppa*64*)
+    hppa*64*|ia64*)
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
-    ia64*)
-      _LT_AC_TAGVAR(hardcode_direct, $1)=no
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
-					      # but as the default
-					      # location of the library.
-      ;;
     *)
       _LT_AC_TAGVAR(hardcode_direct, $1)=yes
       _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
@@ -3189,8 +3241,11 @@ case $host_os in
 	;;
       aCC*)
 	case $host_cpu in
-	hppa*64*|ia64*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+	hppa*64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	  ;;
 	*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -3210,8 +3265,11 @@ case $host_os in
 	if test "$GXX" = yes; then
 	  if test $with_gnu_ld = no; then
 	    case $host_cpu in
-	    ia64*|hppa*64*)
-	      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+	    hppa*64*)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    ia64*)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	      ;;
 	    *)
 	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -3225,6 +3283,20 @@ case $host_os in
 	;;
     esac
     ;;
+  interix[[3-9]]*)
+    _LT_AC_TAGVAR(hardcode_direct, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+    # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+    # Instead, shared libraries are loaded at an image base (0x10000000 by
+    # default) and relocated if they conflict, which is a slow very memory
+    # consuming and fragmenting process.  To avoid this, we pick a random,
+    # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+    # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    ;;
   irix5* | irix6*)
     case $cc_basename in
       CC*)
@@ -3251,7 +3323,7 @@ case $host_os in
     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
     _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
     ;;
-  linux*)
+  linux* | k*bsd*-gnu)
     case $cc_basename in
       KCC*)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
@@ -3303,7 +3375,7 @@ case $host_os in
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
+      pgCC* | pgcpp*)
         # Portland Group C++ compiler
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
   	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
@@ -3331,6 +3403,29 @@ case $host_os in
 	# dependencies.
 	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
 	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C++ 5.9
+	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+
+	  # Not sure whether something based on
+	  # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	  # would be better.
+	  output_verbose_link_cmd='echo'
+
+	  # Archives containing C++ object files must be created using
+	  # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	  # necessary to make sure instantiated templates are included
+	  # in the archive.
+	  _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	  ;;
+	esac
+	;;
     esac
     ;;
   lynxos*)
@@ -3369,16 +3464,20 @@ case $host_os in
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
   openbsd*)
-    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    if test -f /usr/libexec/ld.so; then
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      fi
+      output_verbose_link_cmd='echo'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
     fi
-    output_verbose_link_cmd='echo'
     ;;
   osf3*)
     case $cc_basename in
@@ -3507,19 +3606,6 @@ case $host_os in
     # FIXME: insert proper C++ library support
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
-  sco*)
-    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-    case $cc_basename in
-      CC*)
-	# FIXME: insert proper C++ library support
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
-	;;
-      *)
-	# FIXME: insert proper C++ library support
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
-	;;
-    esac
-    ;;
   sunos4*)
     case $cc_basename in
       CC*)
@@ -3542,26 +3628,21 @@ case $host_os in
     case $cc_basename in
       CC*)
 	# Sun C++ 4.2, 5.x and Centerline C++
-     _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
+        _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
 	_LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	$CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
 	case $host_os in
 	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 	  *)
-	    # The C++ compiler is used as linker so we must use $wl
-	    # flag to pass the commands to the underlying system
-	    # linker. We must also pass each convience library through
-	    # to the system linker between allextract/defaultextract.
-	    # The C++ compiler will combine linker options so we
-	    # cannot just pass the convience library names through
-	    # without $wl.
+	    # The compiler driver will combine and reorder linker options,
+	    # but understands `-z linker_flag'.
 	    # Supported since Solaris 2.6 (maybe 2.5.1?)
-	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	    ;;
 	esac
 	_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
@@ -3608,12 +3689,69 @@ case $host_os in
 	  fi
 
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	  case $host_os in
+	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	  *)
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	    ;;
+	  esac
 	fi
 	;;
     esac
     ;;
-  sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*)
+  sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
     _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
+    ;;
+  sysv5* | sco3.2v5* | sco5v6*)
+    # Note: We can NOT use -z defs as we might desire, because we do not
+    # link with -lc, and that would cause any symbols used from libc to
+    # always be unresolved, which means just about no library would
+    # ever link correctly.  If we're not using GNU ld we use -z text
+    # though, which does catch some bad symbols but isn't as heavy-handed
+    # as -z defs.
+    # For security reasons, it is highly recommended that you always
+    # use absolute paths for naming shared libraries, and exclude the
+    # DT_RUNPATH tag from executables and libraries.  But doing so
+    # requires that you compile everything twice, which is a pain.
+    # So that behaviour is only enabled if SCOABSPATH is set to a
+    # non-empty value in the environment.  Most likely only useful for
+    # creating official distributions of packages.
+    # This is a hack until libtool officially supports absolute path
+    # names for shared libraries.
+    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+    _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
     ;;
   tandem*)
     case $cc_basename in
@@ -3654,8 +3792,6 @@ AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
 AC_LIBTOOL_PROG_LD_SHLIBS($1)
 AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
 AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-AC_LIBTOOL_SYS_LIB_STRIP
-AC_LIBTOOL_DLOPEN_SELF($1)
 
 AC_LIBTOOL_CONFIG($1)
 
@@ -3673,12 +3809,13 @@ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
 ])# AC_LIBTOOL_LANG_CXX_CONFIG
 
 # AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
-# ------------------------
+# ------------------------------------
 # Figure out "hidden" library dependencies from verbose
 # compiler output when linking a shared library.
 # Parse the compiler output and extract the necessary
 # objects, libraries and library flags.
-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
 dnl we can't use the lt_simple_compile_test_code here,
 dnl because it contains code intended for an executable,
 dnl not a library.  It's possible we should let each
@@ -3803,239 +3940,72 @@ fi
 
 $rm -f confest.$objext
 
+_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+  _LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_AC_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
 # PORTME: override above test on systems where it is broken
 ifelse([$1],[CXX],
 [case $host_os in
+interix[[3-9]]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  _LT_AC_TAGVAR(predep_objects,$1)=
+  _LT_AC_TAGVAR(postdep_objects,$1)=
+  _LT_AC_TAGVAR(postdeps,$1)=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+    #
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
 solaris*)
   case $cc_basename in
   CC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
     # Adding this requires a known-good setup of shared libraries for
     # Sun compiler versions before 5.6, else PIC objects from an old
     # archive will be linked into the output, leading to subtle bugs.
-    _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
     ;;
   esac
+  ;;
 esac
 ])
-
 case " $_LT_AC_TAGVAR(postdeps, $1) " in
 *" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
 esac
 ])# AC_LIBTOOL_POSTDEP_PREDEP
 
-# AC_LIBTOOL_LANG_F77_CONFIG
-# ------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-#AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
-#AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
-#[AC_REQUIRE([AC_PROG_F77])
-#AC_LANG_SAVE
-#AC_LANG_FORTRAN77
-#
-#_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-#_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-#_LT_AC_TAGVAR(always_export_symbols, $1)=no
-#_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-#_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-#_LT_AC_TAGVAR(hardcode_direct, $1)=no
-#_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-#_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-#_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-#_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-#_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-#_LT_AC_TAGVAR(module_cmds, $1)=
-#_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-#_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-#_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-#_LT_AC_TAGVAR(no_undefined_flag, $1)=
-#_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-#_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-#
-## Source file extension for f77 test sources.
-#ac_ext=f
-#
-## Object file extension for compiled f77 test sources.
-#objext=o
-#_LT_AC_TAGVAR(objext, $1)=$objext
-#
-## Code to be used in simple compile tests
-#lt_simple_compile_test_code="      subroutine t\n      return\n      end\n"
-#
-## Code to be used in simple link tests
-#lt_simple_link_test_code="      program t\n      end\n"
-#
-## ltmain only uses $CC for tagged configurations so make sure $CC is set.
-#_LT_AC_SYS_COMPILER
-#
-## save warnings/boilerplate of simple test code
-#_LT_COMPILER_BOILERPLATE
-#_LT_LINKER_BOILERPLATE
-#
-## Allow CC to be a program name with arguments.
-#lt_save_CC="$CC"
-#CC=${F77-"f77"}
-#compiler=$CC
-#_LT_AC_TAGVAR(compiler, $1)=$CC
-#_LT_CC_BASENAME([$compiler])
-#
-#AC_MSG_CHECKING([if libtool supports shared libraries])
-#AC_MSG_RESULT([$can_build_shared])
-#
-#AC_MSG_CHECKING([whether to build shared libraries])
-#test "$can_build_shared" = "no" && enable_shared=no
-#
-## On AIX, shared libraries and static libraries use the same namespace, and
-## are all built from PIC.
-#case "$host_os" in
-#aix3*)
-#  test "$enable_shared" = yes && enable_static=no
-#  if test -n "$RANLIB"; then
-#    archive_cmds="$archive_cmds~\$RANLIB \$lib"
-#    postinstall_cmds='$RANLIB $lib'
-#  fi
-#  ;;
-#aix4* | aix5*)
-#  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-#    test "$enable_shared" = yes && enable_static=no
-#  fi
-#  ;;
-#esac
-#AC_MSG_RESULT([$enable_shared])
-#
-#AC_MSG_CHECKING([whether to build static libraries])
-## Make sure either enable_shared or enable_static is yes.
-#test "$enable_shared" = yes || enable_static=yes
-#AC_MSG_RESULT([$enable_static])
-#
-#test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-#
-#_LT_AC_TAGVAR(GCC, $1)="$G77"
-#_LT_AC_TAGVAR(LD, $1)="$LD"
-#
-#AC_LIBTOOL_PROG_COMPILER_PIC($1)
-#AC_LIBTOOL_PROG_CC_C_O($1)
-#AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-#AC_LIBTOOL_PROG_LD_SHLIBS($1)
-#AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-#AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-#AC_LIBTOOL_SYS_LIB_STRIP
-#
-#
-#AC_LIBTOOL_CONFIG($1)
-#
-#AC_LANG_RESTORE
-#CC="$lt_save_CC"
-#])# AC_LIBTOOL_LANG_F77_CONFIG
-
-
-# AC_LIBTOOL_LANG_GCJ_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-#AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
-#AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
-#[AC_LANG_SAVE
-#
-## Source file extension for Java test sources.
-#ac_ext=java
-#
-## Object file extension for compiled Java test sources.
-#objext=o
-#_LT_AC_TAGVAR(objext, $1)=$objext
-#
-## Code to be used in simple compile tests
-#lt_simple_compile_test_code="class foo {}\n"
-#
-## Code to be used in simple link tests
-#lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
-#
-## ltmain only uses $CC for tagged configurations so make sure $CC is set.
-#_LT_AC_SYS_COMPILER
-#
-## save warnings/boilerplate of simple test code
-#_LT_COMPILER_BOILERPLATE
-#_LT_LINKER_BOILERPLATE
-#
-## Allow CC to be a program name with arguments.
-#lt_save_CC="$CC"
-#CC=${GCJ-"gcj"}
-#compiler=$CC
-#_LT_AC_TAGVAR(compiler, $1)=$CC
-#_LT_CC_BASENAME([$compiler])
-#
-## GCJ did not exist at the time GCC didn't implicitly link libc in.
-#_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-#
-#_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-#
-### CAVEAT EMPTOR:
-### There is no encapsulation within the following macros, do not change
-### the running order or otherwise move them around unless you know exactly
-### what you are doing...
-#AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-#AC_LIBTOOL_PROG_COMPILER_PIC($1)
-#AC_LIBTOOL_PROG_CC_C_O($1)
-#AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-#AC_LIBTOOL_PROG_LD_SHLIBS($1)
-#AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-#AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-#AC_LIBTOOL_SYS_LIB_STRIP
-#AC_LIBTOOL_DLOPEN_SELF($1)
-#
-#AC_LIBTOOL_CONFIG($1)
-#
-#AC_LANG_RESTORE
-#CC="$lt_save_CC"
-#])# AC_LIBTOOL_LANG_GCJ_CONFIG
-
-
-# AC_LIBTOOL_LANG_RC_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the Windows resource compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-#AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
-#AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
-#[AC_LANG_SAVE
-#
-## Source file extension for RC test sources.
-#ac_ext=rc
-#
-## Object file extension for compiled RC test sources.
-#objext=o
-#_LT_AC_TAGVAR(objext, $1)=$objext
-#
-## Code to be used in simple compile tests
-#lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-#
-## Code to be used in simple link tests
-#lt_simple_link_test_code="$lt_simple_compile_test_code"
-#
-## ltmain only uses $CC for tagged configurations so make sure $CC is set.
-#_LT_AC_SYS_COMPILER
-#
-## save warnings/boilerplate of simple test code
-#_LT_COMPILER_BOILERPLATE
-#_LT_LINKER_BOILERPLATE
-#
-## Allow CC to be a program name with arguments.
-#lt_save_CC="$CC"
-#CC=${RC-"windres"}
-#compiler=$CC
-#_LT_AC_TAGVAR(compiler, $1)=$CC
-#_LT_CC_BASENAME([$compiler])
-#_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-#
-#AC_LIBTOOL_CONFIG($1)
-#
-#AC_LANG_RESTORE
-#CC="$lt_save_CC"
-#])# AC_LIBTOOL_LANG_RC_CONFIG
-
-
 # AC_LIBTOOL_CONFIG([TAGNAME])
 # ----------------------------
 # If TAGNAME is not passed, then create an initial libtool script
@@ -4056,7 +4026,7 @@ if test -f "$ltmain"; then
   # Now quote all the things that may contain metacharacters while being
   # careful not to overquote the AC_SUBSTed values.  We take copies of the
   # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
     SED SHELL STRIP \
     libname_spec library_names_spec soname_spec extract_expsyms_cmds \
     old_striplib striplib file_magic_cmd finish_cmds finish_eval \
@@ -4083,6 +4053,7 @@ if test -f "$ltmain"; then
     _LT_AC_TAGVAR(predeps, $1) \
     _LT_AC_TAGVAR(postdeps, $1) \
     _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+    _LT_AC_TAGVAR(compiler_lib_search_dirs, $1) \
     _LT_AC_TAGVAR(archive_cmds, $1) \
     _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
     _LT_AC_TAGVAR(postinstall_cmds, $1) \
@@ -4098,6 +4069,7 @@ if test -f "$ltmain"; then
     _LT_AC_TAGVAR(module_cmds, $1) \
     _LT_AC_TAGVAR(module_expsym_cmds, $1) \
     _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+    _LT_AC_TAGVAR(fix_srcfile_path, $1) \
     _LT_AC_TAGVAR(exclude_expsyms, $1) \
     _LT_AC_TAGVAR(include_expsyms, $1); do
 
@@ -4145,7 +4117,7 @@ ifelse([$1], [],
 # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 #
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 # Free Software Foundation, Inc.
 #
 # This file is part of GNU Libtool:
@@ -4226,6 +4198,9 @@ AR_FLAGS=$lt_AR_FLAGS
 # A C compiler.
 LTCC=$lt_LTCC
 
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
 # A language-specific compiler.
 CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
 
@@ -4379,6 +4354,10 @@ predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
 # shared library.
 postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
 
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)
+
 # The library search path used internally by the compiler when linking
 # a shared library.
 compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
@@ -4467,7 +4446,7 @@ sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
 
 # Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
+fix_srcfile_path=$lt_fix_srcfile_path
 
 # Set to yes if exported symbols are required.
 always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
@@ -4550,6 +4529,7 @@ fi
 # ---------------------------------
 AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
 [AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([LT_AC_PROG_SED])
 AC_REQUIRE([AC_PROG_NM])
 AC_REQUIRE([AC_OBJEXT])
 # Check for command to grab the raw symbol name followed by C symbol from nm.
@@ -4586,7 +4566,7 @@ hpux*) # Its linker distinguishes data from code symbols
   lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
   lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
   ;;
-linux*)
+linux* | k*bsd*-gnu)
   if test "$host_cpu" = ia64; then
     symcode='[[ABCDGIRSTW]]'
     lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
@@ -4599,9 +4579,18 @@ irix* | nonstopux*)
 osf*)
   symcode='[[BCDEGQRST]]'
   ;;
-solaris* | sysv5*)
+solaris*)
   symcode='[[BDRT]]'
   ;;
+sco3.2v5*)
+  symcode='[[DT]]'
+  ;;
+sysv4.2uw2*)
+  symcode='[[DT]]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[[ABDT]]'
+  ;;
 sysv4)
   symcode='[[DFNSTU]]'
   ;;
@@ -4718,7 +4707,7 @@ EOF
     echo "$progname: failed program was:" >&5
     cat conftest.$ac_ext >&5
   fi
-  rm -f conftest* conftst*
+  rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
   if test "$pipe_works" = yes; then
@@ -4767,13 +4756,15 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       # like `-m68040'.
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
       ;;
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
       # PIC is the default for these OSes.
       ;;
-    mingw* | os2* | pw32*)
+    mingw* | cygwin* | os2* | pw32*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -4784,6 +4775,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       # DJGPP does not support shared libraries at all
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
       ;;
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
     sysv4*MP*)
       if test -d /usr/nec; then
 	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
@@ -4806,7 +4801,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
     esac
   else
     case $host_os in
-      aix4* | aix5*)
+      aix[[4-9]]*)
 	# All AIX code is PIC.
 	if test "$host_cpu" = ia64; then
 	  # AIX 5 now supports IA64 processor
@@ -4846,21 +4841,21 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    ;;
 	esac
 	;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
+      freebsd* | dragonfly*)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
 	case $cc_basename in
 	  CC*)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
 	    if test "$host_cpu" != ia64; then
 	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -4874,6 +4869,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    ;;
 	esac
 	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
       irix5* | irix6* | nonstopux*)
 	case $cc_basename in
 	  CC*)
@@ -4885,7 +4884,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    ;;
 	esac
 	;;
-      linux*)
+      linux* | k*bsd*-gnu)
 	case $cc_basename in
 	  KCC*)
 	    # KAI C++ Compiler
@@ -4904,7 +4903,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
         _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
         ;;
-	  pgCC*)
+	  pgCC* | pgcpp*)
 	    # Portland Group C++ compiler.
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
@@ -4918,6 +4917,14 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
 	    ;;
 	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	      ;;
+	    esac
 	    ;;
 	esac
 	;;
@@ -4959,15 +4966,6 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	;;
       psos*)
 	;;
-      sco*)
-	case $cc_basename in
-	  CC*)
-	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
       solaris*)
 	case $cc_basename in
 	  CC*)
@@ -5009,7 +5007,14 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    ;;
 	esac
 	;;
-      unixware*)
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	esac
 	;;
       vxworks*)
 	;;
@@ -5040,14 +5045,16 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
       ;;
 
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | pw32* | os2*)
+    mingw* | cygwin* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
       ;;
 
     darwin* | rhapsody*)
@@ -5056,6 +5063,11 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
       ;;
 
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
     msdosdjgpp*)
       # Just because we use GCC doesn't mean we suddenly get shared libraries
       # on systems that don't support them.
@@ -5109,10 +5121,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
        esac
        ;;
 
-    mingw* | pw32* | os2*)
+    mingw* | cygwin* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -5142,7 +5154,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       ;;
 
-    linux*)
+    linux* | k*bsd*-gnu)
       case $cc_basename in
       # old Intel for x86_64 which still supported -KPIC.
       ecc*)
@@ -5169,6 +5181,22 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
         # All Alpha code is PIC.
         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
         ;;
+      *)
+        case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=''
+	  ;;
+	esac
+	;;
       esac
       ;;
 
@@ -5178,9 +5206,8 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
       ;;
 
-    sco3.2v5*)
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic'
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn'
+    rdos*)
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
       ;;
 
     solaris*)
@@ -5200,7 +5227,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       ;;
 
-    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+    sysv4 | sysv4.2uw2* | sysv4.3*)
       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
@@ -5213,6 +5240,12 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       fi
       ;;
 
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
     unicos*)
       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
@@ -5236,7 +5269,7 @@ AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
 #
 if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
   AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
-    _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
+    _LT_AC_TAGVAR(lt_cv_prog_compiler_pic_works, $1),
     [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
     [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
      "" | " "*) ;;
@@ -5254,6 +5287,16 @@ case $host_os in
     _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
     ;;
 esac
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
+AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+  _LT_AC_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+  $lt_tmp_static_flag,
+  [],
+  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
 ])
 
 
@@ -5261,11 +5304,12 @@ esac
 # ------------------------------------
 # See if the linker supports building shared libraries.
 AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
-[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
 ifelse([$1],[CXX],[
   _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   case $host_os in
-  aix4* | aix5*)
+  aix[[4-9]]*)
     # If we're using GNU nm, then we don't want the "-C" option.
     # -C means demangle to AIX nm, but means don't demangle with GNU nm
     if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
@@ -5278,12 +5322,13 @@ ifelse([$1],[CXX],[
     _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
   ;;
   cygwin* | mingw*)
-    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
   ;;
   *)
     _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   esac
+  _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
 ],[
   runpath_var=
   _LT_AC_TAGVAR(allow_undefined_flag, $1)=
@@ -5314,12 +5359,14 @@ ifelse([$1],[CXX],[
   # it will be wrapped by ` (' and `)$', so one must not match beginning or
   # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
   # as well as any symbol that contains `d'.
-  _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
+  _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
   # the symbol is explicitly referenced.  Since portable code cannot
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
   extract_expsyms_cmds=
   # Just being paranoid about ensuring that cc_basename is set.
   _LT_CC_BASENAME([$compiler])
@@ -5332,6 +5379,10 @@ ifelse([$1],[CXX],[
       with_gnu_ld=no
     fi
     ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
   openbsd*)
     with_gnu_ld=no
     ;;
@@ -5341,7 +5392,7 @@ ifelse([$1],[CXX],[
   if test "$with_gnu_ld" = yes; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
-    
+
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
@@ -5362,10 +5413,10 @@ ifelse([$1],[CXX],[
       *\ 2.11.*) ;; # other 2.11 versions
       *) supports_anon_versioning=yes ;;
     esac
-    
+
     # See if GNU ld supports shared libraries.
     case $host_os in
-    aix3* | aix4* | aix5*)
+    aix[[3-9]]*)
       # On AIX/PPC, the GNU linker is very broken
       if test "$host_cpu" != ia64; then
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -5413,10 +5464,10 @@ EOF
       _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_AC_TAGVAR(always_export_symbols, $1)=no
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	# If the export-symbols file already is a .def file (1st line
 	# is EXPORTS), use it as is; otherwise, prepend...
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
@@ -5425,13 +5476,28 @@ EOF
 	  echo EXPORTS > $output_objdir/$soname.def;
 	  cat $export_symbols >> $output_objdir/$soname.def;
 	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
 
-    linux*)
+    interix[[3-9]]*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | k*bsd*-gnu)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	tmp_addflag=
 	case $cc_basename,$host_cpu in
@@ -5439,7 +5505,7 @@ EOF
 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
-	pgf77* | pgf90* | pgf95*)			# Portland Group f77 and f90 compilers
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
@@ -5449,13 +5515,22 @@ EOF
 	ifc* | ifort*)			# Intel Fortran compiler
 	  tmp_addflag=' -nofor_main' ;;
 	esac
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	*)
+	  tmp_sharedflag='-shared' ;;
+	esac
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 
 	if test $supports_anon_versioning = yes; then
 	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
   cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
   $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	  $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
 	fi
       else
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -5472,7 +5547,7 @@ EOF
       fi
       ;;
 
-    solaris* | sysv5*)
+    solaris*)
       if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	cat <<EOF 1>&2
@@ -5493,6 +5568,33 @@ EOF
       fi
       ;;
 
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+	    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+	  else
+	    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+	  fi
+	;;
+      esac
+      ;;
+
     sunos4*)
       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
       wlarc=
@@ -5526,14 +5628,14 @@ EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      if test "$GCC" = yes && test -z "$link_static_flag"; then
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	_LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
       fi
       ;;
 
-    aix4* | aix5*)
+    aix[[4-9]]*)
       if test "$host_cpu" = ia64; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
@@ -5553,13 +5655,14 @@ EOF
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
 	# need to do runtime linking.
-	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	  for ld_flag in $LDFLAGS; do
   	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
   	    aix_use_runtimelinking=yes
   	    break
   	  fi
 	  done
+	  ;;
 	esac
 
 	exp_sym_flag='-bexport'
@@ -5586,7 +5689,7 @@ EOF
   	   strings "$collect2name" | grep resolve_lib_name >/dev/null
 	  then
   	  # We have reworked collect2
-  	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+  	  :
 	  else
   	  # We have old collect2
   	  _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
@@ -5597,6 +5700,7 @@ EOF
   	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
   	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
 	  fi
+	  ;;
 	esac
 	shared_flag='-shared'
 	if test "$aix_use_runtimelinking" = yes; then
@@ -5609,11 +5713,11 @@ EOF
   	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-  	if test "$aix_use_runtimelinking" = yes; then
+	  if test "$aix_use_runtimelinking" = yes; then
 	    shared_flag='${wl}-G'
 	  else
 	    shared_flag='${wl}-bM:SRE'
-  	fi
+	  fi
 	fi
       fi
 
@@ -5627,12 +5731,12 @@ EOF
        # Determine the default libpath from the value encoded in an empty executable.
        _LT_AC_SYS_LIBPATH_AIX
        _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
        else
 	if test "$host_cpu" = ia64; then
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an empty executable.
 	 _LT_AC_SYS_LIBPATH_AIX
@@ -5641,13 +5745,11 @@ EOF
 	  # -berok will link without error, but may produce a broken library.
 	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	  # -bexpall does not export symbols beginning with underscore (_)
-	  _LT_AC_TAGVAR(always_export_symbols, $1)=yes
 	  # Exported symbols can be pulled into shared objects from archives
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
 	  # This is similar to how AIX traditionally builds its shared libraries.
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
       ;;
@@ -5680,7 +5782,7 @@ EOF
       # The linker will automatically build a .lib file if we build a DLL.
       _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
       # FIXME: Should let the user specify the lib program.
-      _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      _LT_AC_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
       _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
@@ -5713,19 +5815,18 @@ EOF
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
     if test "$GCC" = yes ; then
     	output_verbose_link_cmd='echo'
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
     else
       case $cc_basename in
         xlc*)
          output_verbose_link_cmd='echo'
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
           # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
        *)
@@ -5765,7 +5866,7 @@ EOF
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | dragonfly*)
       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
       _LT_AC_TAGVAR(hardcode_direct, $1)=yes
@@ -5788,47 +5889,62 @@ EOF
       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
       ;;
 
-    hpux10* | hpux11*)
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	_LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	_LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      fi
+      ;;
+
+    hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
 	case $host_cpu in
-	hppa*64*|ia64*)
+	hppa*64*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
 	*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
-	hppa*64*|ia64*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hppa*64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       fi
       if test "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
 	case $host_cpu in
-	hppa*64*)
-	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	hppa*64*|ia64*)
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
-	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
 	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
 	  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
 	  ;;
-	ia64*)
-	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
-	  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-	  ;;
 	*)
-	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
 	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
 
@@ -5872,24 +5988,28 @@ EOF
       ;;
 
     openbsd*)
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      if test -f /usr/libexec/ld.so; then
+	_LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+	if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+	     _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	     ;;
+	   *)
+	     _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+        fi
       else
-       case $host_os in
-	 openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
-	   _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	   _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	   ;;
-	 *)
-	   _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	   _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	   ;;
-       esac
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
 
@@ -5930,14 +6050,6 @@ EOF
       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
       ;;
 
-    sco3.2v5*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
-      runpath_var=LD_RUN_PATH
-      hardcode_runpath_var=yes
-      ;;
-
     solaris*)
       _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
       if test "$GCC" = yes; then
@@ -5956,17 +6068,16 @@ EOF
       case $host_os in
       solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
       *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
  	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+	if test "$GCC" = yes; then
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	fi
+	;;
       esac
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
       ;;
@@ -6023,36 +6134,45 @@ EOF
       fi
       ;;
 
-    sysv4.2uw2*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      hardcode_runpath_var=yes
-      runpath_var=LD_RUN_PATH
-      ;;
+      runpath_var='LD_RUN_PATH'
 
-   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[[78]]* | unixware7*)
-      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text'
       if test "$GCC" = yes; then
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
-      runpath_var='LD_RUN_PATH'
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
 
-    sysv5*)
-      _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
-      # $CC -shared without GNU ld will not create a library from C++
-      # object files and a static libstdc++, better avoid it by now
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-  		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
       runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
       ;;
 
     uts4*)
@@ -6070,11 +6190,6 @@ EOF
 AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
 test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
 #
 # Do we need to explicitly link libc?
 #
@@ -6094,7 +6209,7 @@ x|xyes)
       # to ld, don't add -lc before -lgcc.
       AC_MSG_CHECKING([whether -lc should be explicitly linked in])
       $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
       if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
         soname=conftest
@@ -6102,6 +6217,7 @@ x|xyes)
         libobjs=conftest.$ac_objext
         deplibs=
         wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+	pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
         compiler_flags=-v
         linker_flags=-v
         verstring=
@@ -6186,16 +6302,6 @@ AC_DEFUN([AM_PROG_NM],        [AC_PROG_NM])
 # This is just to silence aclocal about the macro not being used
 ifelse([AC_DISABLE_FAST_INSTALL])
 
-#AC_DEFUN([LT_AC_PROG_GCJ],
-#[AC_CHECK_TOOL(GCJ, gcj, no)
-#  test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
-#  AC_SUBST(GCJFLAGS)
-#])
-
-#AC_DEFUN([LT_AC_PROG_RC],
-#[AC_CHECK_TOOL(RC, windres, no)
-#])
-
 ############################################################
 # NOTE: This macro has been submitted for inclusion into   #
 #  GNU Autoconf as AC_PROG_SED.  When it is available in   #
diff --git a/config.guess b/config.guess
index ad5281e..f32079a 100644
--- a/config.guess
+++ b/config.guess
@@ -1,9 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 
-timestamp='2005-08-03'
+timestamp='2008-01-23'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -55,8 +56,8 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -106,7 +107,7 @@ set_cc_for_build='
 trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
 : ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
  { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
  { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
  { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
@@ -160,6 +161,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	    arm*) machine=arm-unknown ;;
 	    sh3el) machine=shl-unknown ;;
 	    sh3eb) machine=sh-unknown ;;
+	    sh5el) machine=sh5le-unknown ;;
 	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
 	esac
 	# The Operating System including object format, if it has switched
@@ -206,8 +208,11 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:ekkoBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
 	exit ;;
+    *:SolidBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+	exit ;;
     macppc:MirBSD:*:*)
-	echo powerppc-unknown-mirbsd${UNAME_RELEASE}
+	echo powerpc-unknown-mirbsd${UNAME_RELEASE}
 	exit ;;
     *:MirBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
@@ -325,7 +330,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
 	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
-    i86pc:SunOS:5.*:*)
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
 	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
     sun4*:SunOS:6*:*)
@@ -527,7 +532,7 @@ EOF
 		echo rs6000-ibm-aix3.2
 	fi
 	exit ;;
-    *:AIX:*:[45])
+    *:AIX:*:[456])
 	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
 	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
 		IBM_ARCH=rs6000
@@ -764,12 +769,19 @@ EOF
 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit ;;
     *:FreeBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	case ${UNAME_MACHINE} in
+	    pc98)
+		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    amd64)
+		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    *)
+		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	esac
 	exit ;;
     i*:CYGWIN*:*)
 	echo ${UNAME_MACHINE}-pc-cygwin
 	exit ;;
-    i*:MINGW*:*)
+    *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
     i*:windows32*:*)
@@ -779,9 +791,18 @@ EOF
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
 	exit ;;
-    x86:Interix*:[34]*)
-	echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
-	exit ;;
+    *:Interix*:[3456]*)
+    	case ${UNAME_MACHINE} in
+	    x86)
+		echo i586-pc-interix${UNAME_RELEASE}
+		exit ;;
+	    EM64T | authenticamd)
+		echo x86_64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	    IA64)
+		echo ia64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	esac ;;
     [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
 	echo i${UNAME_MACHINE}-pc-mks
 	exit ;;
@@ -815,6 +836,16 @@ EOF
 	echo ${UNAME_MACHINE}-pc-minix
 	exit ;;
     arm*:Linux:*:*)
+	eval $set_cc_for_build
+	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+	    | grep -q __ARM_EABI__
+	then
+	    echo ${UNAME_MACHINE}-unknown-linux-gnu
+	else
+	    echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+	fi
+	exit ;;
+    avr32*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     cris:Linux:*:*)
@@ -851,7 +882,11 @@ EOF
 	#endif
 	#endif
 EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^CPU/{
+		s: ::g
+		p
+	    }'`"
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
 	;;
     mips64:Linux:*:*)
@@ -870,7 +905,11 @@ EOF
 	#endif
 	#endif
 EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^CPU/{
+		s: ::g
+		p
+	    }'`"
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
 	;;
     or32:Linux:*:*)
@@ -919,9 +958,15 @@ EOF
     sparc:Linux:*:* | sparc64:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
+    vax:Linux:*:*)
+	echo ${UNAME_MACHINE}-dec-linux-gnu
+	exit ;;
     x86_64:Linux:*:*)
 	echo x86_64-unknown-linux-gnu
 	exit ;;
+    xtensa*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
     i*86:Linux:*:*)
 	# The BFD linker knows what the default object file format is, so
 	# first see if it will tell us. cd to the root directory to prevent
@@ -964,7 +1009,7 @@ EOF
 	LIBC=gnulibc1
 	# endif
 	#else
-	#ifdef __INTEL_COMPILER
+	#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
 	LIBC=gnu
 	#else
 	LIBC=gnuaout
@@ -974,7 +1019,11 @@ EOF
 	LIBC=dietlibc
 	#endif
 EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^LIBC/{
+		s: ::g
+		p
+	    }'`"
 	test x"${LIBC}" != x && {
 		echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
 		exit
@@ -1176,6 +1225,15 @@ EOF
     SX-6:SUPER-UX:*:*)
 	echo sx6-nec-superux${UNAME_RELEASE}
 	exit ;;
+    SX-7:SUPER-UX:*:*)
+	echo sx7-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8:SUPER-UX:*:*)
+	echo sx8-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8R:SUPER-UX:*:*)
+	echo sx8r-nec-superux${UNAME_RELEASE}
+	exit ;;
     Power*:Rhapsody:*:*)
 	echo powerpc-apple-rhapsody${UNAME_RELEASE}
 	exit ;;
@@ -1185,7 +1243,6 @@ EOF
     *:Darwin:*:*)
 	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
 	case $UNAME_PROCESSOR in
-	    *86) UNAME_PROCESSOR=i686 ;;
 	    unknown) UNAME_PROCESSOR=powerpc ;;
 	esac
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
@@ -1264,6 +1321,9 @@ EOF
     i*86:skyos:*:*)
 	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
 	exit ;;
+    i*86:rdos:*:*)
+	echo ${UNAME_MACHINE}-pc-rdos
+	exit ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
@@ -1424,9 +1484,9 @@ This script, last modified $timestamp, has failed to recognize
 the operating system you are using. It is advised that you
 download the most up to date version of the config scripts from
 
-  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 and
-  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
 
 If the version you run ($0) is already up to date, please
 send the following data and any information you think might be
diff --git a/config.sub b/config.sub
index 1c366df..6759825 100644
--- a/config.sub
+++ b/config.sub
@@ -1,9 +1,10 @@
 #! /bin/sh
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 
-timestamp='2005-07-08'
+timestamp='2008-01-16'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -71,8 +72,8 @@ Report bugs and patches to <config-patches at gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -119,8 +120,9 @@ esac
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
-  kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
@@ -171,6 +173,10 @@ case $os in
 	-hiux*)
 		os=-hiuxwe2
 		;;
+	-sco6)
+		os=-sco5v6
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
 	-sco5)
 		os=-sco3.2v5
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -187,6 +193,10 @@ case $os in
 		# Don't forget version if it is 3.2v4 or newer.
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
+	-sco5v6*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
 	-sco*)
 		os=-sco3.2v2
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -231,15 +241,16 @@ case $basic_machine in
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
-	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
 	| bfin \
 	| c4x | clipper \
 	| d10v | d30v | dlx | dsp16xx \
-	| fr30 | frv \
+	| fido | fr30 | frv \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
-	| m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
+	| m32c | m32r | m32rle | m68000 | m68k | m88k \
+	| maxq | mb | microblaze | mcore | mep \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
@@ -257,28 +268,27 @@ case $basic_machine in
 	| mipsisa64sr71k | mipsisa64sr71kel \
 	| mipstx39 | mipstx39el \
 	| mn10200 | mn10300 \
-	| ms1 \
+	| mt \
 	| msp430 \
+	| nios | nios2 \
 	| ns16k | ns32k \
 	| or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
 	| pyramid \
-	| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+	| score \
+	| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
-	| sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
-	| sparcv8 | sparcv9 | sparcv9b \
-	| strongarm \
+	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+	| spu | strongarm \
 	| tahoe | thumb | tic4x | tic80 | tron \
 	| v850 | v850e \
 	| we32k \
-	| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
 	| z8k)
 		basic_machine=$basic_machine-unknown
 		;;
-	m32c)
-		basic_machine=$basic_machine-unknown
-		;;
 	m6811 | m68hc11 | m6812 | m68hc12)
 		# Motorola 68HC11/12.
 		basic_machine=$basic_machine-unknown
@@ -286,6 +296,9 @@ case $basic_machine in
 		;;
 	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
 		;;
+	ms1)
+		basic_machine=mt-unknown
+		;;
 
 	# We use `pc' rather than `unknown'
 	# because (1) that's what they normally are, and
@@ -305,18 +318,18 @@ case $basic_machine in
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
-	| avr-* \
+	| avr-* | avr32-* \
 	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
 	| clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
 	| elxsi-* \
-	| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| ip2k-* | iq2000-* \
-	| m32r-* | m32rle-* \
+	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
 	| m88110-* | m88k-* | maxq-* | mcore-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
@@ -336,30 +349,33 @@ case $basic_machine in
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
 	| mipstx39-* | mipstx39el-* \
 	| mmix-* \
-	| ms1-* \
+	| mt-* \
 	| msp430-* \
+	| nios-* | nios2-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
 	| pyramid-* \
 	| romp-* | rs6000-* \
-	| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+	| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
-	| sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
+	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
 	| tahoe-* | thumb-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
 	| tron-* \
 	| v850-* | v850e-* | vax-* \
 	| we32k-* \
-	| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
-	| xstormy16-* | xtensa-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| xstormy16-* | xtensa*-* \
 	| ymp-* \
 	| z8k-*)
 		;;
-	m32c-*)
+	# Recognize the basic CPU types without company name, with glob match.
+	xtensa*)
+		basic_machine=$basic_machine-unknown
 		;;
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
@@ -431,6 +447,14 @@ case $basic_machine in
 		basic_machine=ns32k-sequent
 		os=-dynix
 		;;
+	blackfin)
+		basic_machine=bfin-unknown
+		os=-linux
+		;;
+	blackfin-*)
+		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
 	c90)
 		basic_machine=c90-cray
 		os=-unicos
@@ -463,8 +487,8 @@ case $basic_machine in
 		basic_machine=craynv-cray
 		os=-unicosmp
 		;;
-	cr16c)
-		basic_machine=cr16c-unknown
+	cr16)
+		basic_machine=cr16-unknown
 		os=-elf
 		;;
 	crds | unos)
@@ -656,6 +680,14 @@ case $basic_machine in
 		basic_machine=m68k-isi
 		os=-sysv
 		;;
+	m68knommu)
+		basic_machine=m68k-unknown
+		os=-linux
+		;;
+	m68knommu-*)
+		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
 	m88k-omron*)
 		basic_machine=m88k-omron
 		;;
@@ -671,6 +703,10 @@ case $basic_machine in
 		basic_machine=i386-pc
 		os=-mingw32
 		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
 	miniframe)
 		basic_machine=m68000-convergent
 		;;
@@ -696,6 +732,9 @@ case $basic_machine in
 		basic_machine=i386-pc
 		os=-msdos
 		;;
+	ms1-*)
+		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+		;;
 	mvs)
 		basic_machine=i370-ibm
 		os=-mvs
@@ -794,6 +833,14 @@ case $basic_machine in
 		basic_machine=i860-intel
 		os=-osf
 		;;
+	parisc)
+		basic_machine=hppa-unknown
+		os=-linux
+		;;
+	parisc-*)
+		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
 	pbd)
 		basic_machine=sparc-tti
 		;;
@@ -803,6 +850,12 @@ case $basic_machine in
 	pc532 | pc532-*)
 		basic_machine=ns32k-pc532
 		;;
+	pc98)
+		basic_machine=i386-pc
+		;;
+	pc98-*)
+		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
 	pentium | p5 | k5 | k6 | nexgen | viac3)
 		basic_machine=i586-pc
 		;;
@@ -859,6 +912,10 @@ case $basic_machine in
 		basic_machine=i586-unknown
 		os=-pw32
 		;;
+	rdos)
+		basic_machine=i386-pc
+		os=-rdos
+		;;
 	rom68k)
 		basic_machine=m68k-rom68k
 		os=-coff
@@ -885,6 +942,10 @@ case $basic_machine in
 	sb1el)
 		basic_machine=mipsisa64sb1el-unknown
 		;;
+	sde)
+		basic_machine=mipsisa32-sde
+		os=-elf
+		;;
 	sei)
 		basic_machine=mips-sei
 		os=-seiux
@@ -896,6 +957,9 @@ case $basic_machine in
 		basic_machine=sh-hitachi
 		os=-hms
 		;;
+	sh5el)
+		basic_machine=sh5le-unknown
+		;;
 	sh64)
 		basic_machine=sh64-unknown
 		;;
@@ -985,6 +1049,10 @@ case $basic_machine in
 		basic_machine=tic6x-unknown
 		os=-coff
 		;;
+	tile*)
+		basic_machine=tile-unknown
+		os=-linux-gnu
+		;;
 	tx39)
 		basic_machine=mipstx39-unknown
 		;;
@@ -1101,7 +1169,7 @@ case $basic_machine in
 	sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
 		basic_machine=sh-unknown
 		;;
-	sparc | sparcv8 | sparcv9 | sparcv9b)
+	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
 		basic_machine=sparc-sun
 		;;
 	cydra)
@@ -1174,21 +1242,23 @@ case $os in
 	      | -aos* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
+	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+	      | -openbsd* | -solidbsd* \
 	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
 	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku*)
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
@@ -1340,6 +1410,12 @@ else
 # system, and we'll never get to this point.
 
 case $basic_machine in
+        score-*)
+		os=-elf
+		;;
+        spu-*)
+		os=-elf
+		;;
 	*-acorn)
 		os=-riscix1.2
 		;;
@@ -1349,9 +1425,9 @@ case $basic_machine in
 	arm*-semi)
 		os=-aout
 		;;
-    c4x-* | tic4x-*)
-        os=-coff
-        ;;
+        c4x-* | tic4x-*)
+        	os=-coff
+		;;
 	# This must come before the *-dec entry.
 	pdp10-*)
 		os=-tops20
@@ -1377,6 +1453,9 @@ case $basic_machine in
 	m68*-cisco)
 		os=-aout
 		;;
+        mep-*)
+		os=-elf
+		;;
 	mips*-cisco)
 		os=-elf
 		;;
diff --git a/configure b/configure
index 2200efd..f6b1013 100755
--- a/configure
+++ b/configure
@@ -255,15 +255,15 @@
 
 
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
-## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
-## Free Software Foundation, Inc.
+## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007,
+## 2008  Free Software Foundation, Inc.
 ## Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 ##
 ## This file is free software; the Free Software Foundation gives
 ## unlimited permission to copy and/or distribute it, with or without
 ## modifications, as long as this notice is preserved.
 
-# serial 47 AC_PROG_LIBTOOL
+# serial 52 AC_PROG_LIBTOOL
 
 
 # autoconf 2.13 compatibility
@@ -328,6 +328,10 @@ fi
 
 
 
+# _LT_REQUIRED_DARWIN_CHECKS
+# --------------------------
+# Check for some things on darwin
+
 
 # _LT_AC_SYS_LIBPATH_AIX
 # ----------------------
@@ -377,18 +381,18 @@ fi
 
 
 # _LT_AC_CHECK_DLFCN
-# --------------------
+# ------------------
 # _LT_AC_CHECK_DLFCN
 
 
 # _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
 #                           ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
-# ------------------------------------------------------------------
+# ---------------------------------------------------------------------
 # _LT_AC_TRY_DLOPEN_SELF
 
 
 # AC_LIBTOOL_DLOPEN_SELF
-# -------------------
+# ----------------------
 # AC_LIBTOOL_DLOPEN_SELF
 
 
@@ -452,7 +456,7 @@ fi
 
 # AC_DISABLE_SHARED
 # -----------------
-#- set the default shared flag to --disable-shared
+# set the default shared flag to --disable-shared
 # AC_DISABLE_SHARED
 
 
@@ -491,20 +495,18 @@ fi
 
 # AC_PROG_EGREP
 # -------------
-# This is predefined starting with Autoconf 2.54, so this conditional
-# definition can be removed once we require Autoconf 2.54 or later.
 
 
 
 # AC_PATH_TOOL_PREFIX
 # -------------------
-# find a file program which can recognise shared library
+# find a file program which can recognize shared library
 # AC_PATH_TOOL_PREFIX
 
 
 # AC_PATH_MAGIC
 # -------------
-# find a file program which can recognise a shared library
+# find a file program which can recognize a shared library
 # AC_PATH_MAGIC
 
 
@@ -585,55 +587,9 @@ fi
 # _LT_AC_LANG_CXX
 
 # _LT_AC_PROG_CXXCPP
-# ---------------
+# ------------------
 # _LT_AC_PROG_CXXCPP
 
-# AC_LIBTOOL_F77
-# --------------
-# enable support for Fortran 77 libraries
-#AC_DEFUN([AC_LIBTOOL_F77],
-#[AC_REQUIRE([_LT_AC_LANG_F77])
-#])# AC_LIBTOOL_F77
-
-
-# _LT_AC_LANG_F77
-# ---------------
-#AC_DEFUN([_LT_AC_LANG_F77],
-#[AC_REQUIRE([AC_PROG_F77])
-#_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
-#])# _LT_AC_LANG_F77
-
-
-# AC_LIBTOOL_GCJ
-# --------------
-# enable support for GCJ libraries
-#AC_DEFUN([AC_LIBTOOL_GCJ],
-#[AC_REQUIRE([_LT_AC_LANG_GCJ])
-#])# AC_LIBTOOL_GCJ
-
-
-# _LT_AC_LANG_GCJ
-# ---------------
-#AC_DEFUN([_LT_AC_LANG_GCJ],
-#[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
-#  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
-#    [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
-#      [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
-#	 [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
-#	   [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
-#_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
-#])# _LT_AC_LANG_GCJ
-
-
-# AC_LIBTOOL_RC
-# --------------
-# enable support for Windows resource files
-#AC_DEFUN([AC_LIBTOOL_RC],
-#[AC_REQUIRE([LT_AC_PROG_RC])
-#_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
-#])# AC_LIBTOOL_RC
-
-
 # AC_LIBTOOL_LANG_C_CONFIG
 # ------------------------
 # Ensure that the configuration vars for the C compiler are
@@ -652,226 +608,13 @@ fi
 # AC_LIBTOOL_LANG_CXX_CONFIG
 
 # AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
-# ------------------------
+# ------------------------------------
 # Figure out "hidden" library dependencies from verbose
 # compiler output when linking a shared library.
 # Parse the compiler output and extract the necessary
 # objects, libraries and library flags.
 # AC_LIBTOOL_POSTDEP_PREDEP
 
-# AC_LIBTOOL_LANG_F77_CONFIG
-# ------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-#AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
-#AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
-#[AC_REQUIRE([AC_PROG_F77])
-#AC_LANG_SAVE
-#AC_LANG_FORTRAN77
-#
-#_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-#_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-#_LT_AC_TAGVAR(always_export_symbols, $1)=no
-#_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-#_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-#_LT_AC_TAGVAR(hardcode_direct, $1)=no
-#_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-#_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-#_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-#_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-#_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-#_LT_AC_TAGVAR(module_cmds, $1)=
-#_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-#_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-#_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-#_LT_AC_TAGVAR(no_undefined_flag, $1)=
-#_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-#_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-#
-## Source file extension for f77 test sources.
-#ac_ext=f
-#
-## Object file extension for compiled f77 test sources.
-#objext=o
-#_LT_AC_TAGVAR(objext, $1)=$objext
-#
-## Code to be used in simple compile tests
-#lt_simple_compile_test_code="      subroutine t\n      return\n      end\n"
-#
-## Code to be used in simple link tests
-#lt_simple_link_test_code="      program t\n      end\n"
-#
-## ltmain only uses $CC for tagged configurations so make sure $CC is set.
-#_LT_AC_SYS_COMPILER
-#
-## save warnings/boilerplate of simple test code
-#_LT_COMPILER_BOILERPLATE
-#_LT_LINKER_BOILERPLATE
-#
-## Allow CC to be a program name with arguments.
-#lt_save_CC="$CC"
-#CC=${F77-"f77"}
-#compiler=$CC
-#_LT_AC_TAGVAR(compiler, $1)=$CC
-#_LT_CC_BASENAME([$compiler])
-#
-#AC_MSG_CHECKING([if libtool supports shared libraries])
-#AC_MSG_RESULT([$can_build_shared])
-#
-#AC_MSG_CHECKING([whether to build shared libraries])
-#test "$can_build_shared" = "no" && enable_shared=no
-#
-## On AIX, shared libraries and static libraries use the same namespace, and
-## are all built from PIC.
-#case "$host_os" in
-#aix3*)
-#  test "$enable_shared" = yes && enable_static=no
-#  if test -n "$RANLIB"; then
-#    archive_cmds="$archive_cmds~\$RANLIB \$lib"
-#    postinstall_cmds='$RANLIB $lib'
-#  fi
-#  ;;
-#aix4* | aix5*)
-#  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-#    test "$enable_shared" = yes && enable_static=no
-#  fi
-#  ;;
-#esac
-#AC_MSG_RESULT([$enable_shared])
-#
-#AC_MSG_CHECKING([whether to build static libraries])
-## Make sure either enable_shared or enable_static is yes.
-#test "$enable_shared" = yes || enable_static=yes
-#AC_MSG_RESULT([$enable_static])
-#
-#test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-#
-#_LT_AC_TAGVAR(GCC, $1)="$G77"
-#_LT_AC_TAGVAR(LD, $1)="$LD"
-#
-#AC_LIBTOOL_PROG_COMPILER_PIC($1)
-#AC_LIBTOOL_PROG_CC_C_O($1)
-#AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-#AC_LIBTOOL_PROG_LD_SHLIBS($1)
-#AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-#AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-#AC_LIBTOOL_SYS_LIB_STRIP
-#
-#
-#AC_LIBTOOL_CONFIG($1)
-#
-#AC_LANG_RESTORE
-#CC="$lt_save_CC"
-#])# AC_LIBTOOL_LANG_F77_CONFIG
-
-
-# AC_LIBTOOL_LANG_GCJ_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-#AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
-#AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
-#[AC_LANG_SAVE
-#
-## Source file extension for Java test sources.
-#ac_ext=java
-#
-## Object file extension for compiled Java test sources.
-#objext=o
-#_LT_AC_TAGVAR(objext, $1)=$objext
-#
-## Code to be used in simple compile tests
-#lt_simple_compile_test_code="class foo {}\n"
-#
-## Code to be used in simple link tests
-#lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
-#
-## ltmain only uses $CC for tagged configurations so make sure $CC is set.
-#_LT_AC_SYS_COMPILER
-#
-## save warnings/boilerplate of simple test code
-#_LT_COMPILER_BOILERPLATE
-#_LT_LINKER_BOILERPLATE
-#
-## Allow CC to be a program name with arguments.
-#lt_save_CC="$CC"
-#CC=${GCJ-"gcj"}
-#compiler=$CC
-#_LT_AC_TAGVAR(compiler, $1)=$CC
-#_LT_CC_BASENAME([$compiler])
-#
-## GCJ did not exist at the time GCC didn't implicitly link libc in.
-#_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-#
-#_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-#
-### CAVEAT EMPTOR:
-### There is no encapsulation within the following macros, do not change
-### the running order or otherwise move them around unless you know exactly
-### what you are doing...
-#AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-#AC_LIBTOOL_PROG_COMPILER_PIC($1)
-#AC_LIBTOOL_PROG_CC_C_O($1)
-#AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-#AC_LIBTOOL_PROG_LD_SHLIBS($1)
-#AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-#AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-#AC_LIBTOOL_SYS_LIB_STRIP
-#AC_LIBTOOL_DLOPEN_SELF($1)
-#
-#AC_LIBTOOL_CONFIG($1)
-#
-#AC_LANG_RESTORE
-#CC="$lt_save_CC"
-#])# AC_LIBTOOL_LANG_GCJ_CONFIG
-
-
-# AC_LIBTOOL_LANG_RC_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the Windows resource compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-#AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
-#AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
-#[AC_LANG_SAVE
-#
-## Source file extension for RC test sources.
-#ac_ext=rc
-#
-## Object file extension for compiled RC test sources.
-#objext=o
-#_LT_AC_TAGVAR(objext, $1)=$objext
-#
-## Code to be used in simple compile tests
-#lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-#
-## Code to be used in simple link tests
-#lt_simple_link_test_code="$lt_simple_compile_test_code"
-#
-## ltmain only uses $CC for tagged configurations so make sure $CC is set.
-#_LT_AC_SYS_COMPILER
-#
-## save warnings/boilerplate of simple test code
-#_LT_COMPILER_BOILERPLATE
-#_LT_LINKER_BOILERPLATE
-#
-## Allow CC to be a program name with arguments.
-#lt_save_CC="$CC"
-#CC=${RC-"windres"}
-#compiler=$CC
-#_LT_AC_TAGVAR(compiler, $1)=$CC
-#_LT_CC_BASENAME([$compiler])
-#_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-#
-#AC_LIBTOOL_CONFIG($1)
-#
-#AC_LANG_RESTORE
-#CC="$lt_save_CC"
-#])# AC_LIBTOOL_LANG_RC_CONFIG
-
-
 # AC_LIBTOOL_CONFIG([TAGNAME])
 # ----------------------------
 # If TAGNAME is not passed, then create an initial libtool script
@@ -925,16 +668,6 @@ fi
 # This is just to silence aclocal about the macro not being used
 
 
-#AC_DEFUN([LT_AC_PROG_GCJ],
-#[AC_CHECK_TOOL(GCJ, gcj, no)
-#  test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
-#  AC_SUBST(GCJFLAGS)
-#])
-
-#AC_DEFUN([LT_AC_PROG_RC],
-#[AC_CHECK_TOOL(RC, windres, no)
-#])
-
 ############################################################
 # NOTE: This macro has been submitted for inclusion into   #
 #  GNU Autoconf as AC_PROG_SED.  When it is available in   #
@@ -1425,9 +1158,10 @@ ac_help="$ac_help
 ac_help="$ac_help
   --with-pcre-dir           ZIP: pcre install prefix"
 ac_help="$ac_help
-  --enable-mysqlnd-threading
-                            EXPERIMENTAL: Enable mysqlnd threaded fetch.
-                            Note: This forces ZTS on!"
+  --disable-mysqlnd-compression-support
+                            Enable support for the MySQL compressed protocol in mysqlnd"
+ac_help="$ac_help
+  --with-zlib-dir[=DIR]       mysqlnd: Set the path to libz install prefix"
 ac_help="$ac_help
 
 PEAR:
@@ -2147,12 +1881,12 @@ fi
 
 
 echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
-echo "configure:2151: checking for Cygwin environment" >&5
+echo "configure:1885: 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 2156 "configure"
+#line 1890 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -2163,7 +1897,7 @@ int main() {
 return __CYGWIN__;
 ; return 0; }
 EOF
-if { (eval echo configure:2167: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1901: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_cygwin=yes
 else
@@ -2180,19 +1914,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:2184: checking for mingw32 environment" >&5
+echo "configure:1918: 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 2189 "configure"
+#line 1923 "configure"
 #include "confdefs.h"
 
 int main() {
 return __MINGW32__;
 ; return 0; }
 EOF
-if { (eval echo configure:2196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1930: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_mingw32=yes
 else
@@ -2211,7 +1945,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes
 
 
 echo $ac_n "checking for egrep""... $ac_c" 1>&6
-echo "configure:2215: checking for egrep" >&5
+echo "configure:1949: checking for egrep" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_egrep'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2226,7 +1960,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:2230: checking for a sed that does not truncate output" >&5
+echo "configure:1964: 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
@@ -2376,7 +2110,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:2380: checking host system type" >&5
+echo "configure:2114: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -2397,7 +2131,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:2401: checking target system type" >&5
+echo "configure:2135: checking target system type" >&5
 
 target_alias=$target
 case "$target_alias" in
@@ -2427,7 +2161,7 @@ echo "$ac_t""$target" 1>&6
 
 PHP_MAJOR_VERSION=5
 PHP_MINOR_VERSION=3
-PHP_RELEASE_VERSION=1
+PHP_RELEASE_VERSION=2
 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`
@@ -2505,22 +2239,11 @@ php_abs_top_builddir=$abs_builddir
 $php_shtool mkdir -p libs
 rm -f libs/*
 
-php_did_darwin9_cheat=0
-case $host_alias in
-*darwin9*)
-  hasg=`echo $CFLAGS | grep -E '(^-g)|([:space:]-g)'`
-  if test x"$hasg" = "x"; then
-    php_did_darwin9_cheat=1
-    CFLAGS="$CFLAGS -gstabs"
-  fi
-  ;;
-esac
-
 
 # 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:2524: checking for $ac_word" >&5
+echo "configure:2247: 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
@@ -2550,7 +2273,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:2554: checking for $ac_word" >&5
+echo "configure:2277: 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
@@ -2601,7 +2324,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:2605: checking for $ac_word" >&5
+echo "configure:2328: 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
@@ -2633,7 +2356,7 @@ fi
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:2637: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:2360: 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.
@@ -2644,12 +2367,12 @@ cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 2648 "configure"
+#line 2371 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:2653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2376: \"$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
@@ -2675,12 +2398,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:2679: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2402: 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:2684: checking whether we are using GNU C" >&5
+echo "configure:2407: 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
@@ -2689,7 +2412,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2693: \"$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:2416: \"$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
@@ -2708,7 +2431,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:2712: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:2435: 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
@@ -2740,7 +2463,7 @@ else
 fi
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:2744: checking how to run the C preprocessor" >&5
+echo "configure:2467: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -2755,13 +2478,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 2759 "configure"
+#line 2482 "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:2765: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2488: \"$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
   :
@@ -2772,13 +2495,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 2776 "configure"
+#line 2499 "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:2782: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2505: \"$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
   :
@@ -2789,13 +2512,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 2793 "configure"
+#line 2516 "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:2799: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2522: \"$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
   :
@@ -2822,9 +2545,9 @@ echo "$ac_t""$CPP" 1>&6
 
   ICC="no"
   echo $ac_n "checking for icc""... $ac_c" 1>&6
-echo "configure:2826: checking for icc" >&5
+echo "configure:2549: checking for icc" >&5
   cat > conftest.$ac_ext <<EOF
-#line 2828 "configure"
+#line 2551 "configure"
 #include "confdefs.h"
 __INTEL_COMPILER
 EOF
@@ -2846,9 +2569,9 @@ rm -f conftest*
 
   SUNCC="no"
   echo $ac_n "checking for suncc""... $ac_c" 1>&6
-echo "configure:2850: checking for suncc" >&5
+echo "configure:2573: checking for suncc" >&5
   cat > conftest.$ac_ext <<EOF
-#line 2852 "configure"
+#line 2575 "configure"
 #include "confdefs.h"
 __SUNPRO_C
 EOF
@@ -2871,10 +2594,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:2875: checking whether $CC and cc understand -c and -o together" >&5
+echo "configure:2598: 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:2878: checking whether cc understands -c and -o together" >&5
+echo "configure:2601: 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]/_/'`"
@@ -2886,16 +2609,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:2890: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } &&
-   test -f conftest.o && { (eval echo configure:2891: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; };
+if { (eval echo configure:2613: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } &&
+   test -f conftest.o && { (eval echo configure:2614: \"$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:2896: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+    if { ac_try='cc -c conftest.c 1>&5'; { (eval echo configure:2619: \"$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:2898: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } &&
-	 test -f conftest.o && { (eval echo configure:2899: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; };
+      if { (eval echo configure:2621: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } &&
+	 test -f conftest.o && { (eval echo configure:2622: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; };
       then
         # cc works too.
         :
@@ -2922,7 +2645,7 @@ EOF
 fi
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:2926: checking how to run the C preprocessor" >&5
+echo "configure:2649: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -2937,13 +2660,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 2941 "configure"
+#line 2664 "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:2947: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2670: \"$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
   :
@@ -2954,13 +2677,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 2958 "configure"
+#line 2681 "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:2964: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2687: \"$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
   :
@@ -2971,13 +2694,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 2975 "configure"
+#line 2698 "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:2981: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2704: \"$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
   :
@@ -3002,9 +2725,9 @@ fi
 echo "$ac_t""$CPP" 1>&6
 
 echo $ac_n "checking for AIX""... $ac_c" 1>&6
-echo "configure:3006: checking for AIX" >&5
+echo "configure:2729: checking for AIX" >&5
 cat > conftest.$ac_ext <<EOF
-#line 3008 "configure"
+#line 2731 "configure"
 #include "confdefs.h"
 #ifdef _AIX
   yes
@@ -3026,7 +2749,7 @@ rm -f conftest*
 
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:3030: checking whether ln -s works" >&5
+echo "configure:2753: 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
@@ -3051,7 +2774,7 @@ fi
 php_with_libdir=lib
 
 echo $ac_n "checking for system library directory""... $ac_c" 1>&6
-echo "configure:3055: checking for system library directory" >&5
+echo "configure:2778: 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"
@@ -3077,7 +2800,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:3081: checking whether to enable runpaths" >&5
+echo "configure:2804: 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"
@@ -3101,7 +2824,7 @@ echo "$ac_t""$ext_output" 1>&6
 
 
 echo $ac_n "checking if compiler supports -R""... $ac_c" 1>&6
-echo "configure:3105: checking if compiler supports -R" >&5
+echo "configure:2828: 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
@@ -3109,14 +2832,14 @@ else
   SAVE_LIBS=$LIBS
   LIBS="-R /usr/$PHP_LIBDIR $LIBS"
   cat > conftest.$ac_ext <<EOF
-#line 3113 "configure"
+#line 2836 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2843: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   php_cv_cc_dashr=yes
 else
@@ -3134,7 +2857,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:3138: checking if compiler supports -Wl,-rpath," >&5
+echo "configure:2861: 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
@@ -3142,14 +2865,14 @@ else
     SAVE_LIBS=$LIBS
     LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS"
     cat > conftest.$ac_ext <<EOF
-#line 3146 "configure"
+#line 2869 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   php_cv_cc_rpath=yes
 else
@@ -3180,7 +2903,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:3184: checking for $ac_word" >&5
+echo "configure:2907: 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
@@ -3221,7 +2944,7 @@ test -n "$AWK" || AWK="bork"
       ;;
     *)
       echo $ac_n "checking if $AWK is broken""... $ac_c" 1>&6
-echo "configure:3225: checking if $AWK is broken" >&5
+echo "configure:2948: 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; }
@@ -3240,7 +2963,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:3244: checking for $ac_word" >&5
+echo "configure:2967: 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
@@ -3280,7 +3003,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:3284: checking for bison version" >&5
+echo "configure:3007: 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
@@ -3318,7 +3041,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:3322: checking for $ac_word" >&5
+echo "configure:3045: 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
@@ -3346,7 +3069,7 @@ fi
 
   if test -n "$RE2C"; then
     echo $ac_n "checking for re2c version""... $ac_c" 1>&6
-echo "configure:3350: checking for re2c version" >&5
+echo "configure:3073: 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
@@ -3385,7 +3108,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:3389: checking whether to enable computed goto gcc extension with re2c" >&5
+echo "configure:3112: 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"
@@ -3411,9 +3134,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:3415: checking whether re2c -g works" >&5
+echo "configure:3138: checking whether re2c -g works" >&5
   cat > conftest.$ac_ext <<EOF
-#line 3417 "configure"
+#line 3140 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3431,7 +3154,7 @@ label2:
   
 ; return 0; }
 EOF
-if { (eval echo configure:3435: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3158: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     RE2C_FLAGS=""
@@ -3497,7 +3220,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:3501: checking whether $CC supports -no-cpp-precomp" >&5
+echo "configure:3224: 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
@@ -3698,7 +3421,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:3702: checking whether to force non-PIC code in shared modules" >&5
+echo "configure:3425: 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
@@ -3728,7 +3451,7 @@ esac
 
 
 echo $ac_n "checking whether /dev/urandom exists""... $ac_c" 1>&6
-echo "configure:3732: checking whether /dev/urandom exists" >&5 
+echo "configure:3455: 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
@@ -3789,7 +3512,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3793 "configure"
+#line 3516 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -3807,7 +3530,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:3811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -3827,7 +3550,7 @@ fi
   CFLAGS=$save_CFLAGS
 
   echo $ac_n "checking for pthreads_cflags""... $ac_c" 1>&6
-echo "configure:3831: checking for pthreads_cflags" >&5
+echo "configure:3554: 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
@@ -3849,7 +3572,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3853 "configure"
+#line 3576 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -3867,7 +3590,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:3871: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -3897,7 +3620,7 @@ fi
 echo "$ac_t""$ac_cv_pthreads_cflags" 1>&6
 
 echo $ac_n "checking for pthreads_lib""... $ac_c" 1>&6
-echo "configure:3901: checking for pthreads_lib" >&5
+echo "configure:3624: 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
@@ -3919,7 +3642,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3923 "configure"
+#line 3646 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -3937,7 +3660,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:3941: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -4071,7 +3794,7 @@ ext_output=$PHP_AOLSERVER
 
 
 echo $ac_n "checking for AOLserver support""... $ac_c" 1>&6
-echo "configure:4075: checking for AOLserver support" >&5
+echo "configure:3798: checking for AOLserver support" >&5
 
 if test "$PHP_AOLSERVER" != "no"; then
   if test -d "$PHP_AOLSERVER/include"; then
@@ -4328,7 +4051,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:4332: checking for Apache 1.x module support via DSO through APXS" >&5
+echo "configure:4055: checking for Apache 1.x module support via DSO through APXS" >&5
 
 if test "$PHP_APXS" != "no"; then
   if test "$PHP_APXS" = "yes"; then
@@ -4651,7 +4374,7 @@ ext_output=$PHP_APACHE
 
 
 echo $ac_n "checking for Apache 1.x module support""... $ac_c" 1>&6
-echo "configure:4655: checking for Apache 1.x module support" >&5
+echo "configure:4378: checking for Apache 1.x module support" >&5
 
 if test "$PHP_SAPI" != "apache" && test "$PHP_APACHE" != "no"; then
   
@@ -5484,7 +5207,7 @@ fi
 php_enable_mod_charset=no
 
 echo $ac_n "checking whether to enable Apache charset compatibility option""... $ac_c" 1>&6
-echo "configure:5488: checking whether to enable Apache charset compatibility option" >&5
+echo "configure:5211: 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"
@@ -5519,7 +5242,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:5523: checking whether $CC supports -rdynamic" >&5
+echo "configure:5246: 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
@@ -5562,7 +5285,7 @@ if test -n "$APACHE_INSTALL"; then
 
   
 echo $ac_n "checking for member fd in BUFF *""... $ac_c" 1>&6
-echo "configure:5566: checking for member fd in BUFF *" >&5
+echo "configure:5289: 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
@@ -5574,14 +5297,14 @@ else
     CPPFLAGS="$CPPFLAGS $APACHE_INCLUDE"
   fi
   cat > conftest.$ac_ext <<EOF
-#line 5578 "configure"
+#line 5301 "configure"
 #include "confdefs.h"
 #include <httpd.h>
 int main() {
 conn_rec *c; int fd = c->client->fd;
 ; return 0; }
 EOF
-if { (eval echo configure:5585: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5308: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     ac_cv_php_fd_in_buff=yes
@@ -5657,7 +5380,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:5661: checking for Apache 2.0 filter-module support via DSO through APXS" >&5
+echo "configure:5384: 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
@@ -6505,7 +6228,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:6509: checking for Apache 2.0 handler-module support via DSO through APXS" >&5
+echo "configure:6232: 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
@@ -7354,7 +7077,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:7358: checking for Apache 1.x (hooks) module support via DSO through APXS" >&5
+echo "configure:7081: 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
@@ -7677,7 +7400,7 @@ ext_output=$PHP_APACHE_HOOKS_STATIC
 
 
 echo $ac_n "checking for Apache 1.x (hooks) module support""... $ac_c" 1>&6
-echo "configure:7681: checking for Apache 1.x (hooks) module support" >&5
+echo "configure:7404: 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
 
@@ -8510,7 +8233,7 @@ fi
 php_enable_mod_charset=no
 
 echo $ac_n "checking whether to enable Apache charset compatibility option""... $ac_c" 1>&6
-echo "configure:8514: checking whether to enable Apache charset compatibility option" >&5
+echo "configure:8237: 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"
@@ -8545,7 +8268,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:8549: checking whether $CC supports -rdynamic" >&5
+echo "configure:8272: 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
@@ -8588,7 +8311,7 @@ if test -n "$APACHE_HOOKS_INSTALL"; then
 
   
 echo $ac_n "checking for member fd in BUFF *""... $ac_c" 1>&6
-echo "configure:8592: checking for member fd in BUFF *" >&5
+echo "configure:8315: 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
@@ -8600,14 +8323,14 @@ else
     CPPFLAGS="$CPPFLAGS $APACHE_INCLUDE"
   fi
   cat > conftest.$ac_ext <<EOF
-#line 8604 "configure"
+#line 8327 "configure"
 #include "confdefs.h"
 #include <httpd.h>
 int main() {
 conn_rec *c; int fd = c->client->fd;
 ; return 0; }
 EOF
-if { (eval echo configure:8611: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8334: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     ac_cv_php_fd_in_buff=yes
@@ -8684,7 +8407,7 @@ ext_output=$PHP_CAUDIUM
 
 
 echo $ac_n "checking for Caudium support""... $ac_c" 1>&6
-echo "configure:8688: checking for Caudium support" >&5
+echo "configure:8411: checking for Caudium support" >&5
 
 if test "$PHP_CAUDIUM" != "no"; then
   if test "$prefix" = "NONE"; then CPREF=/usr/local/; fi
@@ -8754,7 +8477,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:8758: checking for C includes in $PIKE_C_INCLUDE" >&5
+echo "configure:8481: 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 #######
@@ -9035,7 +8758,7 @@ ext_output=$PHP_CLI
 
 
 echo $ac_n "checking for CLI build""... $ac_c" 1>&6
-echo "configure:9039: checking for CLI build" >&5
+echo "configure:8762: checking for CLI build" >&5
 if test "$PHP_CLI" != "no"; then
   
   src=$abs_srcdir/sapi/cli/Makefile.frag
@@ -9085,7 +8808,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:9089: checking for Continuity support" >&5
+echo "configure:8812: checking for Continuity support" >&5
 # Check whether --with-continuity or --without-continuity was given.
 if test "${with_continuity+set}" = set; then
   withval="$with_continuity"
@@ -9112,7 +8835,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:9116: checking for Continuity include files" >&5
+echo "configure:8839: 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
@@ -9362,7 +9085,7 @@ ext_output=$PHP_EMBED
 
 
 echo $ac_n "checking for embedded SAPI library support""... $ac_c" 1>&6
-echo "configure:9366: checking for embedded SAPI library support" >&5
+echo "configure:9089: checking for embedded SAPI library support" >&5
 
 if test "$PHP_EMBED" != "no"; then
   case "$PHP_EMBED" in
@@ -9579,7 +9302,7 @@ fi
 php_with_isapi=no
 
 echo $ac_n "checking for Zeus ISAPI support""... $ac_c" 1>&6
-echo "configure:9583: checking for Zeus ISAPI support" >&5
+echo "configure:9306: 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"
@@ -9825,7 +9548,7 @@ fi
 
 
 echo $ac_n "checking for LiteSpeed support""... $ac_c" 1>&6
-echo "configure:9829: checking for LiteSpeed support" >&5
+echo "configure:9552: checking for LiteSpeed support" >&5
 
 
 php_with_litespeed=no
@@ -10079,7 +9802,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:10083: checking for Milter support" >&5
+echo "configure:9806: checking for Milter support" >&5
 # Check whether --with-milter or --without-milter was given.
 if test "${with_milter+set}" = set; then
   withval="$with_milter"
@@ -10363,7 +10086,7 @@ fi
 php_with_nsapi=no
 
 echo $ac_n "checking for NSAPI support""... $ac_c" 1>&6
-echo "configure:10367: checking for NSAPI support" >&5
+echo "configure:10090: checking for NSAPI support" >&5
 # Check whether --with-nsapi or --without-nsapi was given.
 if test "${with_nsapi+set}" = set; then
   withval="$with_nsapi"
@@ -10390,7 +10113,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:10394: checking for NSAPI include files" >&5
+echo "configure:10117: 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
@@ -10398,17 +10121,17 @@ echo "configure:10394: 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:10402: checking for $ac_hdr" >&5
+echo "configure:10125: 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 10407 "configure"
+#line 10130 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10412: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10135: \"$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*
@@ -10443,17 +10166,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:10447: checking for $ac_hdr" >&5
+echo "configure:10170: 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 10452 "configure"
+#line 10175 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10457: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10180: \"$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*
@@ -10715,7 +10438,7 @@ fi
 php_with_phttpd=no
 
 echo $ac_n "checking for PHTTPD support""... $ac_c" 1>&6
-echo "configure:10719: checking for PHTTPD support" >&5
+echo "configure:10442: checking for PHTTPD support" >&5
 # Check whether --with-phttpd or --without-phttpd was given.
 if test "${with_phttpd+set}" = set; then
   withval="$with_phttpd"
@@ -10961,7 +10684,7 @@ fi
 php_with_pi3web=no
 
 echo $ac_n "checking for Pi3Web support""... $ac_c" 1>&6
-echo "configure:10965: checking for Pi3Web support" >&5
+echo "configure:10688: checking for Pi3Web support" >&5
 # Check whether --with-pi3web or --without-pi3web was given.
 if test "${with_pi3web+set}" = set; then
   withval="$with_pi3web"
@@ -11328,7 +11051,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:11332: checking whether Roxen module is build using ZTS" >&5
+echo "configure:11055: 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"
@@ -11352,7 +11075,7 @@ echo "$ac_t""$ext_output" 1>&6
 
 RESULT=
 echo $ac_n "checking for Roxen/Pike support""... $ac_c" 1>&6
-echo "configure:11356: checking for Roxen/Pike support" >&5
+echo "configure:11079: 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; }
@@ -11630,7 +11353,7 @@ ext_output=$PHP_THTTPD
 
 
 echo $ac_n "checking for thttpd""... $ac_c" 1>&6
-echo "configure:11634: checking for thttpd" >&5
+echo "configure:11357: checking for thttpd" >&5
 
 if test "$PHP_THTTPD" != "no"; then
   if test ! -d $PHP_THTTPD; then
@@ -11663,7 +11386,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:11667: checking whether $CC supports -rdynamic" >&5
+echo "configure:11390: 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
@@ -11891,24 +11614,24 @@ ext_output=$PHP_TUX
 
 
 echo $ac_n "checking for TUX""... $ac_c" 1>&6
-echo "configure:11895: checking for TUX" >&5
+echo "configure:11618: 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:11902: checking for $ac_hdr" >&5
+echo "configure:11625: 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 11907 "configure"
+#line 11630 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11912: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11635: \"$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*
@@ -12137,7 +11860,7 @@ ext_output=$PHP_WEBJAMES
 
 
 echo $ac_n "checking for webjames""... $ac_c" 1>&6
-echo "configure:12141: checking for webjames" >&5
+echo "configure:11864: checking for webjames" >&5
 
 if test "$PHP_WEBJAMES" != "no"; then
   
@@ -12389,14 +12112,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:12393: checking whether to build CGI binary" >&5
+echo "configure:12116: 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:12398: checking for socklen_t in sys/socket.h" >&5
+echo "configure:12121: checking for socklen_t in sys/socket.h" >&5
     cat > conftest.$ac_ext <<EOF
-#line 12400 "configure"
+#line 12123 "configure"
 #include "confdefs.h"
 #include <sys/socket.h>
 EOF
@@ -12416,9 +12139,9 @@ rm -f conftest*
 
 
     echo $ac_n "checking for sun_len in sys/un.h""... $ac_c" 1>&6
-echo "configure:12420: checking for sun_len in sys/un.h" >&5
+echo "configure:12143: checking for sun_len in sys/un.h" >&5
     cat > conftest.$ac_ext <<EOF
-#line 12422 "configure"
+#line 12145 "configure"
 #include "confdefs.h"
 #include <sys/un.h>
 EOF
@@ -12438,7 +12161,7 @@ rm -f conftest*
 
 
     echo $ac_n "checking whether cross-process locking is required by accept()""... $ac_c" 1>&6
-echo "configure:12442: checking whether cross-process locking is required by accept()" >&5
+echo "configure:12165: 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
@@ -12671,7 +12394,7 @@ fi
 
 
 echo $ac_n "checking for chosen SAPI module""... $ac_c" 1>&6
-echo "configure:12675: checking for chosen SAPI module" >&5
+echo "configure:12398: checking for chosen SAPI module" >&5
 echo "$ac_t""$PHP_SAPI" 1>&6
 
 if test "$enable_maintainer_zts" = "yes"; then
@@ -12728,7 +12451,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:12732: checking for $ac_word" >&5
+echo "configure:12455: 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
@@ -12767,7 +12490,7 @@ fi
 
 
   echo $ac_n "checking whether system uses EBCDIC""... $ac_c" 1>&6
-echo "configure:12771: checking whether system uses EBCDIC" >&5
+echo "configure:12494: 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
@@ -12778,7 +12501,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 12782 "configure"
+#line 12505 "configure"
 #include "confdefs.h"
 
 int main(void) { 
@@ -12786,7 +12509,7 @@ int main(void) {
 } 
 
 EOF
-if { (eval echo configure:12790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:12513: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_ebcdic=yes
@@ -12814,7 +12537,7 @@ EOF
 
 
 echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:12818: checking whether byte ordering is bigendian" >&5
+echo "configure:12541: 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
@@ -12824,7 +12547,7 @@ else
   ac_cv_c_bigendian_php=unknown
 else
   cat > conftest.$ac_ext <<EOF
-#line 12828 "configure"
+#line 12551 "configure"
 #include "confdefs.h"
 
 int main(void)
@@ -12840,7 +12563,7 @@ int main(void)
 }
   
 EOF
-if { (eval echo configure:12844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:12567: \"$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
@@ -12866,7 +12589,7 @@ EOF
 
 
   echo $ac_n "checking whether writing to stdout works""... $ac_c" 1>&6
-echo "configure:12870: checking whether writing to stdout works" >&5
+echo "configure:12593: 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
@@ -12877,7 +12600,7 @@ else
     
 else
   cat > conftest.$ac_ext <<EOF
-#line 12881 "configure"
+#line 12604 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_UNISTD_H
@@ -12895,7 +12618,7 @@ main()
 }
     
 EOF
-if { (eval echo configure:12899: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:12622: \"$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
@@ -12970,12 +12693,12 @@ test -d /usr/ucblib &&
   unset found
   
   echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:12974: checking for socket" >&5
+echo "configure:12697: 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 12979 "configure"
+#line 12702 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -12998,7 +12721,7 @@ socket();
 
 ; return 0; }
 EOF
-if { (eval echo configure:13002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12725: \"$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
@@ -13016,12 +12739,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:13020: checking for __socket" >&5
+echo "configure:12743: 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 13025 "configure"
+#line 12748 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __socket(); below.  */
@@ -13044,7 +12767,7 @@ __socket();
 
 ; return 0; }
 EOF
-if { (eval echo configure:13048: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12771: \"$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
@@ -13082,7 +12805,7 @@ EOF
   unset ac_cv_lib_socket___socket
   unset found
   echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:13086: checking for socket in -lsocket" >&5
+echo "configure:12809: 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
@@ -13090,7 +12813,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 13094 "configure"
+#line 12817 "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
@@ -13101,7 +12824,7 @@ int main() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:13105: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12828: \"$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
@@ -13121,7 +12844,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __socket in -lsocket""... $ac_c" 1>&6
-echo "configure:13125: checking for __socket in -lsocket" >&5
+echo "configure:12848: 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
@@ -13129,7 +12852,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 13133 "configure"
+#line 12856 "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
@@ -13140,7 +12863,7 @@ int main() {
 __socket()
 ; return 0; }
 EOF
-if { (eval echo configure:13144: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12867: \"$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
@@ -13172,11 +12895,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 13176 "configure"
+#line 12899 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:13180: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:12903: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -13227,12 +12950,12 @@ EOF
   unset found
   
   echo $ac_n "checking for socketpair""... $ac_c" 1>&6
-echo "configure:13231: checking for socketpair" >&5
+echo "configure:12954: 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 13236 "configure"
+#line 12959 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socketpair(); below.  */
@@ -13255,7 +12978,7 @@ socketpair();
 
 ; return 0; }
 EOF
-if { (eval echo configure:13259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12982: \"$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
@@ -13273,12 +12996,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:13277: checking for __socketpair" >&5
+echo "configure:13000: 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 13282 "configure"
+#line 13005 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __socketpair(); below.  */
@@ -13301,7 +13024,7 @@ __socketpair();
 
 ; return 0; }
 EOF
-if { (eval echo configure:13305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13028: \"$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
@@ -13339,7 +13062,7 @@ EOF
   unset ac_cv_lib_socket___socketpair
   unset found
   echo $ac_n "checking for socketpair in -lsocket""... $ac_c" 1>&6
-echo "configure:13343: checking for socketpair in -lsocket" >&5
+echo "configure:13066: 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
@@ -13347,7 +13070,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 13351 "configure"
+#line 13074 "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
@@ -13358,7 +13081,7 @@ int main() {
 socketpair()
 ; return 0; }
 EOF
-if { (eval echo configure:13362: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13085: \"$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
@@ -13378,7 +13101,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __socketpair in -lsocket""... $ac_c" 1>&6
-echo "configure:13382: checking for __socketpair in -lsocket" >&5
+echo "configure:13105: 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
@@ -13386,7 +13109,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 13390 "configure"
+#line 13113 "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
@@ -13397,7 +13120,7 @@ int main() {
 __socketpair()
 ; return 0; }
 EOF
-if { (eval echo configure:13401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13124: \"$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
@@ -13429,11 +13152,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 13433 "configure"
+#line 13156 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:13437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:13160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -13484,12 +13207,12 @@ EOF
   unset found
   
   echo $ac_n "checking for htonl""... $ac_c" 1>&6
-echo "configure:13488: checking for htonl" >&5
+echo "configure:13211: 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 13493 "configure"
+#line 13216 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char htonl(); below.  */
@@ -13512,7 +13235,7 @@ htonl();
 
 ; return 0; }
 EOF
-if { (eval echo configure:13516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13239: \"$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
@@ -13530,12 +13253,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:13534: checking for __htonl" >&5
+echo "configure:13257: 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 13539 "configure"
+#line 13262 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __htonl(); below.  */
@@ -13558,7 +13281,7 @@ __htonl();
 
 ; return 0; }
 EOF
-if { (eval echo configure:13562: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13285: \"$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
@@ -13596,7 +13319,7 @@ EOF
   unset ac_cv_lib_socket___htonl
   unset found
   echo $ac_n "checking for htonl in -lsocket""... $ac_c" 1>&6
-echo "configure:13600: checking for htonl in -lsocket" >&5
+echo "configure:13323: 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
@@ -13604,7 +13327,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 13608 "configure"
+#line 13331 "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
@@ -13615,7 +13338,7 @@ int main() {
 htonl()
 ; return 0; }
 EOF
-if { (eval echo configure:13619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13342: \"$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
@@ -13635,7 +13358,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __htonl in -lsocket""... $ac_c" 1>&6
-echo "configure:13639: checking for __htonl in -lsocket" >&5
+echo "configure:13362: 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
@@ -13643,7 +13366,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 13647 "configure"
+#line 13370 "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
@@ -13654,7 +13377,7 @@ int main() {
 __htonl()
 ; return 0; }
 EOF
-if { (eval echo configure:13658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13381: \"$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
@@ -13686,11 +13409,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 13690 "configure"
+#line 13413 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:13694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:13417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -13741,12 +13464,12 @@ EOF
   unset found
   
   echo $ac_n "checking for gethostname""... $ac_c" 1>&6
-echo "configure:13745: checking for gethostname" >&5
+echo "configure:13468: 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 13750 "configure"
+#line 13473 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostname(); below.  */
@@ -13769,7 +13492,7 @@ gethostname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:13773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13496: \"$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
@@ -13787,12 +13510,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:13791: checking for __gethostname" >&5
+echo "configure:13514: 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 13796 "configure"
+#line 13519 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __gethostname(); below.  */
@@ -13815,7 +13538,7 @@ __gethostname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:13819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13542: \"$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
@@ -13853,7 +13576,7 @@ EOF
   unset ac_cv_lib_nsl___gethostname
   unset found
   echo $ac_n "checking for gethostname in -lnsl""... $ac_c" 1>&6
-echo "configure:13857: checking for gethostname in -lnsl" >&5
+echo "configure:13580: 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
@@ -13861,7 +13584,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 13865 "configure"
+#line 13588 "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
@@ -13872,7 +13595,7 @@ int main() {
 gethostname()
 ; return 0; }
 EOF
-if { (eval echo configure:13876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13599: \"$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
@@ -13892,7 +13615,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __gethostname in -lnsl""... $ac_c" 1>&6
-echo "configure:13896: checking for __gethostname in -lnsl" >&5
+echo "configure:13619: 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
@@ -13900,7 +13623,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 13904 "configure"
+#line 13627 "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
@@ -13911,7 +13634,7 @@ int main() {
 __gethostname()
 ; return 0; }
 EOF
-if { (eval echo configure:13915: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13638: \"$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
@@ -13943,11 +13666,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 13947 "configure"
+#line 13670 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:13951: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:13674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -13998,12 +13721,12 @@ EOF
   unset found
   
   echo $ac_n "checking for gethostbyaddr""... $ac_c" 1>&6
-echo "configure:14002: checking for gethostbyaddr" >&5
+echo "configure:13725: 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 14007 "configure"
+#line 13730 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyaddr(); below.  */
@@ -14026,7 +13749,7 @@ gethostbyaddr();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14030: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13753: \"$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
@@ -14044,12 +13767,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:14048: checking for __gethostbyaddr" >&5
+echo "configure:13771: 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 14053 "configure"
+#line 13776 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __gethostbyaddr(); below.  */
@@ -14072,7 +13795,7 @@ __gethostbyaddr();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13799: \"$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
@@ -14110,7 +13833,7 @@ EOF
   unset ac_cv_lib_nsl___gethostbyaddr
   unset found
   echo $ac_n "checking for gethostbyaddr in -lnsl""... $ac_c" 1>&6
-echo "configure:14114: checking for gethostbyaddr in -lnsl" >&5
+echo "configure:13837: 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
@@ -14118,7 +13841,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14122 "configure"
+#line 13845 "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
@@ -14129,7 +13852,7 @@ int main() {
 gethostbyaddr()
 ; return 0; }
 EOF
-if { (eval echo configure:14133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13856: \"$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
@@ -14149,7 +13872,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __gethostbyaddr in -lnsl""... $ac_c" 1>&6
-echo "configure:14153: checking for __gethostbyaddr in -lnsl" >&5
+echo "configure:13876: 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
@@ -14157,7 +13880,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14161 "configure"
+#line 13884 "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
@@ -14168,7 +13891,7 @@ int main() {
 __gethostbyaddr()
 ; return 0; }
 EOF
-if { (eval echo configure:14172: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13895: \"$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
@@ -14200,11 +13923,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 14204 "configure"
+#line 13927 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:14208: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:13931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -14255,12 +13978,12 @@ EOF
   unset found
   
   echo $ac_n "checking for yp_get_default_domain""... $ac_c" 1>&6
-echo "configure:14259: checking for yp_get_default_domain" >&5
+echo "configure:13982: 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 14264 "configure"
+#line 13987 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char yp_get_default_domain(); below.  */
@@ -14283,7 +14006,7 @@ yp_get_default_domain();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14010: \"$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
@@ -14301,12 +14024,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:14305: checking for __yp_get_default_domain" >&5
+echo "configure:14028: 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 14310 "configure"
+#line 14033 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __yp_get_default_domain(); below.  */
@@ -14329,7 +14052,7 @@ __yp_get_default_domain();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14056: \"$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
@@ -14367,7 +14090,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:14371: checking for yp_get_default_domain in -lnsl" >&5
+echo "configure:14094: 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
@@ -14375,7 +14098,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14379 "configure"
+#line 14102 "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
@@ -14386,7 +14109,7 @@ int main() {
 yp_get_default_domain()
 ; return 0; }
 EOF
-if { (eval echo configure:14390: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14113: \"$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
@@ -14406,7 +14129,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:14410: checking for __yp_get_default_domain in -lnsl" >&5
+echo "configure:14133: 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
@@ -14414,7 +14137,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14418 "configure"
+#line 14141 "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
@@ -14425,7 +14148,7 @@ int main() {
 __yp_get_default_domain()
 ; return 0; }
 EOF
-if { (eval echo configure:14429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14152: \"$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
@@ -14457,11 +14180,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 14461 "configure"
+#line 14184 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:14465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -14513,12 +14236,12 @@ EOF
   unset found
   
   echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:14517: checking for dlopen" >&5
+echo "configure:14240: 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 14522 "configure"
+#line 14245 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dlopen(); below.  */
@@ -14541,7 +14264,7 @@ dlopen();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14268: \"$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
@@ -14559,12 +14282,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:14563: checking for __dlopen" >&5
+echo "configure:14286: 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 14568 "configure"
+#line 14291 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __dlopen(); below.  */
@@ -14587,7 +14310,7 @@ __dlopen();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14314: \"$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
@@ -14625,7 +14348,7 @@ EOF
   unset ac_cv_lib_dl___dlopen
   unset found
   echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:14629: checking for dlopen in -ldl" >&5
+echo "configure:14352: 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
@@ -14633,7 +14356,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14637 "configure"
+#line 14360 "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
@@ -14644,7 +14367,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:14648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14371: \"$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
@@ -14664,7 +14387,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:14668: checking for __dlopen in -ldl" >&5
+echo "configure:14391: 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
@@ -14672,7 +14395,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14676 "configure"
+#line 14399 "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
@@ -14683,7 +14406,7 @@ int main() {
 __dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:14687: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14410: \"$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
@@ -14715,11 +14438,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 14719 "configure"
+#line 14442 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:14723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14446: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -14771,7 +14494,7 @@ EOF
 
 fi
 echo $ac_n "checking for sin in -lm""... $ac_c" 1>&6
-echo "configure:14775: checking for sin in -lm" >&5
+echo "configure:14498: 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
@@ -14779,7 +14502,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14783 "configure"
+#line 14506 "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
@@ -14790,7 +14513,7 @@ int main() {
 sin()
 ; return 0; }
 EOF
-if { (eval echo configure:14794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14517: \"$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
@@ -14824,12 +14547,12 @@ fi
   unset found
   
   echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
-echo "configure:14828: checking for inet_aton" >&5
+echo "configure:14551: 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 14833 "configure"
+#line 14556 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char inet_aton(); below.  */
@@ -14852,7 +14575,7 @@ inet_aton();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14579: \"$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
@@ -14870,12 +14593,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:14874: checking for __inet_aton" >&5
+echo "configure:14597: 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 14879 "configure"
+#line 14602 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __inet_aton(); below.  */
@@ -14898,7 +14621,7 @@ __inet_aton();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14625: \"$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
@@ -14936,7 +14659,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:14940: checking for inet_aton in -lresolv" >&5
+echo "configure:14663: 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
@@ -14944,7 +14667,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14948 "configure"
+#line 14671 "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
@@ -14955,7 +14678,7 @@ int main() {
 inet_aton()
 ; return 0; }
 EOF
-if { (eval echo configure:14959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14682: \"$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
@@ -14975,7 +14698,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __inet_aton in -lresolv""... $ac_c" 1>&6
-echo "configure:14979: checking for __inet_aton in -lresolv" >&5
+echo "configure:14702: 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
@@ -14983,7 +14706,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14987 "configure"
+#line 14710 "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
@@ -14994,7 +14717,7 @@ int main() {
 __inet_aton()
 ; return 0; }
 EOF
-if { (eval echo configure:14998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14721: \"$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
@@ -15026,11 +14749,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 15030 "configure"
+#line 14753 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:15034: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14757: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -15072,7 +14795,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:15076: checking for inet_aton in -lbind" >&5
+echo "configure:14799: 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
@@ -15080,7 +14803,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15084 "configure"
+#line 14807 "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
@@ -15091,7 +14814,7 @@ int main() {
 inet_aton()
 ; return 0; }
 EOF
-if { (eval echo configure:15095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14818: \"$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
@@ -15111,7 +14834,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __inet_aton in -lbind""... $ac_c" 1>&6
-echo "configure:15115: checking for __inet_aton in -lbind" >&5
+echo "configure:14838: 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
@@ -15119,7 +14842,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15123 "configure"
+#line 14846 "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
@@ -15130,7 +14853,7 @@ int main() {
 __inet_aton()
 ; return 0; }
 EOF
-if { (eval echo configure:15134: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14857: \"$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
@@ -15162,11 +14885,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 15166 "configure"
+#line 14889 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:15170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -15216,271 +14939,13 @@ EOF
 
 
 
-  unset ac_cv_func_nanosleep
-  unset ac_cv_func___nanosleep
-  unset found
-  
-  echo $ac_n "checking for nanosleep""... $ac_c" 1>&6
-echo "configure:15225: 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 15230 "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:15253: \"$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:15271: 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 15276 "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:15299: \"$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:15337: 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
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-lrt  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 15345 "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
-    builtin and then its argument prototype would still apply.  */
-char nanosleep();
-
-int main() {
-nanosleep()
-; return 0; }
-EOF
-if { (eval echo configure:15356: \"$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
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  found=yes
-else
-  echo "$ac_t""no" 1>&6
-
-    echo $ac_n "checking for __nanosleep in -lrt""... $ac_c" 1>&6
-echo "configure:15376: 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
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-lrt  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 15384 "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
-    builtin and then its argument prototype would still apply.  */
-char __nanosleep();
-
-int main() {
-__nanosleep()
-; return 0; }
-EOF
-if { (eval echo configure:15395: \"$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
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  found=yes
-else
-  echo "$ac_t""no" 1>&6
-found=no
-fi
-
-  
-fi
-
-
-  if test "$found" = "yes"; then
-    ac_libs=$LIBS
-    LIBS="$LIBS -lrt"
-    if test "$cross_compiling" = yes; then
-  found=no
-else
-  cat > conftest.$ac_ext <<EOF
-#line 15427 "configure"
-#include "confdefs.h"
-main() { return (0); }
-EOF
-if { (eval echo configure:15431: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
-  found=yes
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  found=no
-fi
-rm -fr conftest*
-fi
-
-    LIBS=$ac_libs
-  fi
-
-  if test "$found" = "yes"; then
-    
-  
-  case rt in
-  c|c_r|pthread*) ;;
-  *) 
-      LIBS="-lrt $LIBS" 
-   ;;
-  esac
-
-
-    cat >> confdefs.h <<\EOF
-#define HAVE_NANOSLEEP 1
-EOF
-
-    cat >> confdefs.h <<\EOF
-#define HAVE_LIBRT 1
-EOF
-
-    ac_cv_func_nanosleep=yes
-  else
-    
-  :
-
-  fi
-  
- ;;
-  
-  esac
-
-
-
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:15479: checking for ANSI C header files" >&5
+echo "configure:14944: 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 15484 "configure"
+#line 14949 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -15488,7 +14953,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:15492: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:14957: \"$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*
@@ -15505,7 +14970,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 15509 "configure"
+#line 14974 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -15523,7 +14988,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 15527 "configure"
+#line 14992 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -15544,7 +15009,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 15548 "configure"
+#line 15013 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -15555,7 +15020,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:15559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:15024: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -15583,12 +15048,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:15587: checking for $ac_hdr that defines DIR" >&5
+echo "configure:15052: 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 15592 "configure"
+#line 15057 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -15596,7 +15061,7 @@ int main() {
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:15600: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15065: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -15621,7 +15086,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:15625: checking for opendir in -ldir" >&5
+echo "configure:15090: 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
@@ -15629,7 +15094,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15633 "configure"
+#line 15098 "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
@@ -15640,7 +15105,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:15644: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15109: \"$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
@@ -15662,7 +15127,7 @@ fi
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:15666: checking for opendir in -lx" >&5
+echo "configure:15131: 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
@@ -15670,7 +15135,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15674 "configure"
+#line 15139 "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
@@ -15681,7 +15146,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:15685: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15150: \"$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
@@ -15715,7 +15180,6 @@ sys/time.h \
 netinet/in.h \
 alloca.h \
 arpa/inet.h \
-arpa/nameser_compat.h \
 arpa/nameser.h \
 assert.h \
 crypt.h \
@@ -15764,17 +15228,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:15768: checking for $ac_hdr" >&5
+echo "configure:15232: 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 15773 "configure"
+#line 15237 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:15778: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:15242: \"$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*
@@ -15803,12 +15267,12 @@ done
 
 
   echo $ac_n "checking for fopencookie""... $ac_c" 1>&6
-echo "configure:15807: checking for fopencookie" >&5
+echo "configure:15271: 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 15812 "configure"
+#line 15276 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char fopencookie(); below.  */
@@ -15831,7 +15295,7 @@ fopencookie();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15835: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15299: \"$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
@@ -15853,7 +15317,7 @@ fi
 
   if test "$have_glibc_fopencookie" = "yes"; then
 cat > conftest.$ac_ext <<EOF
-#line 15857 "configure"
+#line 15321 "configure"
 #include "confdefs.h"
 
 #define _GNU_SOURCE
@@ -15863,7 +15327,7 @@ int main() {
 cookie_io_functions_t cookie;
 ; return 0; }
 EOF
-if { (eval echo configure:15867: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15331: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   have_cookie_io_functions_t=yes
 else
@@ -15882,7 +15346,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 15886 "configure"
+#line 15350 "configure"
 #include "confdefs.h"
 
 #define _GNU_SOURCE
@@ -15914,7 +15378,7 @@ main() {
 
 
 EOF
-if { (eval echo configure:15918: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:15382: \"$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
@@ -15934,7 +15398,7 @@ fi
     else
 
 cat > conftest.$ac_ext <<EOF
-#line 15938 "configure"
+#line 15402 "configure"
 #include "confdefs.h"
 
 #define _GNU_SOURCE
@@ -15944,7 +15408,7 @@ int main() {
  _IO_cookie_io_functions_t cookie; 
 ; return 0; }
 EOF
-if { (eval echo configure:15948: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15412: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   have_IO_cookie_io_functions_t=yes
 else
@@ -15978,7 +15442,7 @@ EOF
 
 
   echo $ac_n "checking for broken getcwd""... $ac_c" 1>&6
-echo "configure:15982: checking for broken getcwd" >&5
+echo "configure:15446: checking for broken getcwd" >&5
   os=`uname -sr 2>/dev/null`
   case $os in
     SunOS*)
@@ -15993,14 +15457,14 @@ EOF
 
 
   echo $ac_n "checking for broken libc stdio""... $ac_c" 1>&6
-echo "configure:15997: checking for broken libc stdio" >&5
-  if eval "test \"`echo '$''{'have_broken_glibc_fopen_append'+set}'`\" = set"; then
+echo "configure:15461: 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 16004 "configure"
+#line 15468 "configure"
 #include "confdefs.h"
 
 #include <features.h>
@@ -16013,20 +15477,20 @@ choke me
 
 ; return 0; }
 EOF
-if { (eval echo configure:16017: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15481: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
-  have_broken_glibc_fopen_append=yes
+  _cv_have_broken_glibc_fopen_append=yes
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  have_broken_glibc_fopen_append=no 
+  _cv_have_broken_glibc_fopen_append=no 
 fi
 rm -f conftest*
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 16030 "configure"
+#line 15494 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -16054,14 +15518,14 @@ int main(int argc, char *argv[])
 }
 
 EOF
-if { (eval echo configure:16058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:15522: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
-  have_broken_glibc_fopen_append=no
+  _cv_have_broken_glibc_fopen_append=no
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -fr conftest*
-  have_broken_glibc_fopen_append=yes 
+  _cv_have_broken_glibc_fopen_append=yes 
 fi
 rm -fr conftest*
 fi
@@ -16069,7 +15533,7 @@ fi
 fi
 
 
-  if test "$have_broken_glibc_fopen_append" = "yes"; then
+  if test "$_cv_have_broken_glibc_fopen_append" = "yes"; then
     echo "$ac_t""yes" 1>&6
     cat >> confdefs.h <<\EOF
 #define HAVE_BROKEN_GLIBC_FOPEN_APPEND 1
@@ -16082,12 +15546,12 @@ EOF
 
 
 echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:16086: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:15550: 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 16091 "configure"
+#line 15555 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -16095,7 +15559,7 @@ int main() {
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:16099: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15563: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -16116,12 +15580,12 @@ EOF
 fi
 
 echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:16120: checking for tm_zone in struct tm" >&5
+echo "configure:15584: 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 16125 "configure"
+#line 15589 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -16129,7 +15593,7 @@ int main() {
 struct tm tm; tm.tm_zone;
 ; return 0; }
 EOF
-if { (eval echo configure:16133: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15597: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_zone=yes
 else
@@ -16149,12 +15613,12 @@ EOF
 
 else
   echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:16153: checking for tzname" >&5
+echo "configure:15617: 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 16158 "configure"
+#line 15622 "configure"
 #include "confdefs.h"
 #include <time.h>
 #ifndef tzname /* For SGI.  */
@@ -16164,7 +15628,7 @@ int main() {
 atoi(*tzname);
 ; return 0; }
 EOF
-if { (eval echo configure:16168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_var_tzname=yes
 else
@@ -16188,16 +15652,16 @@ fi
 
 
   echo $ac_n "checking for missing declarations of reentrant functions""... $ac_c" 1>&6
-echo "configure:16192: checking for missing declarations of reentrant functions" >&5
+echo "configure:15656: checking for missing declarations of reentrant functions" >&5
   cat > conftest.$ac_ext <<EOF
-#line 16194 "configure"
+#line 15658 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 struct tm *(*func)() = localtime_r
 ; return 0; }
 EOF
-if { (eval echo configure:16201: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15665: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     :
@@ -16215,14 +15679,14 @@ EOF
 fi
 rm -f conftest*
   cat > conftest.$ac_ext <<EOF
-#line 16219 "configure"
+#line 15683 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 struct tm *(*func)() = gmtime_r
 ; return 0; }
 EOF
-if { (eval echo configure:16226: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15690: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     :
@@ -16240,14 +15704,14 @@ EOF
 fi
 rm -f conftest*
   cat > conftest.$ac_ext <<EOF
-#line 16244 "configure"
+#line 15708 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 char *(*func)() = asctime_r
 ; return 0; }
 EOF
-if { (eval echo configure:16251: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15715: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     :
@@ -16265,14 +15729,14 @@ EOF
 fi
 rm -f conftest*
   cat > conftest.$ac_ext <<EOF
-#line 16269 "configure"
+#line 15733 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 char *(*func)() = ctime_r
 ; return 0; }
 EOF
-if { (eval echo configure:16276: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15740: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     :
@@ -16290,14 +15754,14 @@ EOF
 fi
 rm -f conftest*
   cat > conftest.$ac_ext <<EOF
-#line 16294 "configure"
+#line 15758 "configure"
 #include "confdefs.h"
 #include <string.h>
 int main() {
 char *(*func)() = strtok_r
 ; return 0; }
 EOF
-if { (eval echo configure:16301: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15765: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     :
@@ -16318,16 +15782,16 @@ rm -f conftest*
 
 
   echo $ac_n "checking for fclose declaration""... $ac_c" 1>&6
-echo "configure:16322: checking for fclose declaration" >&5
+echo "configure:15786: checking for fclose declaration" >&5
   cat > conftest.$ac_ext <<EOF
-#line 16324 "configure"
+#line 15788 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main() {
 int (*func)() = fclose
 ; return 0; }
 EOF
-if { (eval echo configure:16331: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15795: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     cat >> confdefs.h <<\EOF
@@ -16353,12 +15817,12 @@ rm -f conftest*
 
 
 echo $ac_n "checking for tm_gmtoff in struct tm""... $ac_c" 1>&6
-echo "configure:16357: checking for tm_gmtoff in struct tm" >&5
+echo "configure:15821: 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 16362 "configure"
+#line 15826 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -16366,7 +15830,7 @@ int main() {
 struct tm tm; tm.tm_gmtoff;
 ; return 0; }
 EOF
-if { (eval echo configure:16370: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15834: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_gmtoff=yes
 else
@@ -16389,12 +15853,12 @@ fi
 
 
 echo $ac_n "checking for struct flock""... $ac_c" 1>&6
-echo "configure:16393: checking for struct flock" >&5
+echo "configure:15857: 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 16398 "configure"
+#line 15862 "configure"
 #include "confdefs.h"
 
 #include <unistd.h>
@@ -16404,7 +15868,7 @@ int main() {
 struct flock x;
 ; return 0; }
 EOF
-if { (eval echo configure:16408: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15872: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
           ac_cv_struct_flock=yes
@@ -16431,12 +15895,12 @@ fi
 
 
 echo $ac_n "checking for socklen_t""... $ac_c" 1>&6
-echo "configure:16435: checking for socklen_t" >&5
+echo "configure:15899: 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 16440 "configure"
+#line 15904 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -16448,7 +15912,7 @@ socklen_t x;
 
 ; return 0; }
 EOF
-if { (eval echo configure:16452: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:15916: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   ac_cv_socklen_t=yes
@@ -16474,7 +15938,7 @@ fi
 
 
 echo $ac_n "checking size of size_t""... $ac_c" 1>&6
-echo "configure:16478: checking size of size_t" >&5
+echo "configure:15942: 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
@@ -16482,7 +15946,7 @@ else
   ac_cv_sizeof_size_t=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 16486 "configure"
+#line 15950 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -16493,7 +15957,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:16497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:15961: \"$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
@@ -16513,7 +15977,7 @@ EOF
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:16517: checking size of long long" >&5
+echo "configure:15981: 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
@@ -16521,7 +15985,7 @@ else
   ac_cv_sizeof_long_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 16525 "configure"
+#line 15989 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -16532,7 +15996,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:16536: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16000: \"$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
@@ -16552,7 +16016,7 @@ EOF
 
 
 echo $ac_n "checking size of long long int""... $ac_c" 1>&6
-echo "configure:16556: checking size of long long int" >&5
+echo "configure:16020: 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
@@ -16560,7 +16024,7 @@ else
   ac_cv_sizeof_long_long_int=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 16564 "configure"
+#line 16028 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -16571,7 +16035,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:16575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16039: \"$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
@@ -16591,7 +16055,7 @@ EOF
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:16595: checking size of long" >&5
+echo "configure:16059: 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
@@ -16599,7 +16063,7 @@ else
   ac_cv_sizeof_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 16603 "configure"
+#line 16067 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -16610,7 +16074,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:16614: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16078: \"$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
@@ -16630,7 +16094,7 @@ EOF
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:16634: checking size of int" >&5
+echo "configure:16098: 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
@@ -16638,7 +16102,7 @@ else
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 16642 "configure"
+#line 16106 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -16649,7 +16113,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:16653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16117: \"$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
@@ -16671,7 +16135,7 @@ EOF
 
 
   echo $ac_n "checking size of intmax_t""... $ac_c" 1>&6
-echo "configure:16675: checking size of intmax_t" >&5
+echo "configure:16139: 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
@@ -16688,7 +16152,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 16692 "configure"
+#line 16156 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #if STDC_HEADERS
@@ -16712,7 +16176,7 @@ int main()
 }
   
 EOF
-if { (eval echo configure:16716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16180: \"$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`
@@ -16751,7 +16215,7 @@ EOF
 
 
   echo $ac_n "checking size of ssize_t""... $ac_c" 1>&6
-echo "configure:16755: checking size of ssize_t" >&5
+echo "configure:16219: 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
@@ -16768,7 +16232,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 16772 "configure"
+#line 16236 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #if STDC_HEADERS
@@ -16792,7 +16256,7 @@ int main()
 }
   
 EOF
-if { (eval echo configure:16796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16260: \"$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`
@@ -16831,7 +16295,7 @@ EOF
 
 
   echo $ac_n "checking size of ptrdiff_t""... $ac_c" 1>&6
-echo "configure:16835: checking size of ptrdiff_t" >&5
+echo "configure:16299: 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
@@ -16848,7 +16312,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 16852 "configure"
+#line 16316 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #if STDC_HEADERS
@@ -16872,7 +16336,7 @@ int main()
 }
   
 EOF
-if { (eval echo configure:16876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16340: \"$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`
@@ -16911,12 +16375,12 @@ EOF
 
 
 echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6
-echo "configure:16915: checking for st_blksize in struct stat" >&5
+echo "configure:16379: 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 16920 "configure"
+#line 16384 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -16924,7 +16388,7 @@ int main() {
 struct stat s; s.st_blksize;
 ; return 0; }
 EOF
-if { (eval echo configure:16928: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16392: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_blksize=yes
 else
@@ -16946,12 +16410,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:16950: checking for st_blocks in struct stat" >&5
+echo "configure:16414: 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 16955 "configure"
+#line 16419 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -16959,7 +16423,7 @@ int main() {
 struct stat s; s.st_blocks;
 ; return 0; }
 EOF
-if { (eval echo configure:16963: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16427: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_blocks=yes
 else
@@ -16986,12 +16450,12 @@ else
   WARNING_LEVEL=0
 fi
 echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6
-echo "configure:16990: checking for st_rdev in struct stat" >&5
+echo "configure:16454: 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 16995 "configure"
+#line 16459 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -16999,7 +16463,7 @@ int main() {
 struct stat s; s.st_rdev;
 ; return 0; }
 EOF
-if { (eval echo configure:17003: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16467: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_rdev=yes
 else
@@ -17021,12 +16485,12 @@ fi
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:17025: checking for size_t" >&5
+echo "configure:16489: 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 17030 "configure"
+#line 16494 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -17054,12 +16518,12 @@ EOF
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:17058: checking for uid_t in sys/types.h" >&5
+echo "configure:16522: 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 17063 "configure"
+#line 16527 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -17090,12 +16554,12 @@ fi
 
 
     echo $ac_n "checking for struct sockaddr_storage""... $ac_c" 1>&6
-echo "configure:17094: checking for struct sockaddr_storage" >&5
+echo "configure:16558: 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 17099 "configure"
+#line 16563 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -17103,7 +16567,7 @@ int main() {
 struct sockaddr_storage s; s
 ; return 0; }
 EOF
-if { (eval echo configure:17107: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16571: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_sockaddr_storage=yes
 else
@@ -17124,13 +16588,13 @@ EOF
 
   fi
     echo $ac_n "checking for field sa_len in struct sockaddr""... $ac_c" 1>&6
-echo "configure:17128: checking for field sa_len in struct sockaddr" >&5
+echo "configure:16592: 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 17134 "configure"
+#line 16598 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -17138,7 +16602,7 @@ int main() {
 static struct sockaddr sa; int n = (int) sa.sa_len; return n;
 ; return 0; }
 EOF
-if { (eval echo configure:17142: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16606: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_sockaddr_sa_len=yes
 else
@@ -17161,12 +16625,12 @@ EOF
 
 
 echo $ac_n "checking for IPv6 support""... $ac_c" 1>&6
-echo "configure:17165: checking for IPv6 support" >&5
+echo "configure:16629: 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 17170 "configure"
+#line 16634 "configure"
 #include "confdefs.h"
  #include <sys/types.h>
 #include <sys/socket.h>
@@ -17175,7 +16639,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:17179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_ipv6_support=yes
 else
@@ -17191,12 +16655,12 @@ echo "$ac_t""$ac_cv_ipv6_support" 1>&6
 
 
 echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:17195: checking for vprintf" >&5
+echo "configure:16659: 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 17200 "configure"
+#line 16664 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char vprintf(); below.  */
@@ -17219,7 +16683,7 @@ vprintf();
 
 ; return 0; }
 EOF
-if { (eval echo configure:17223: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16687: \"$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
@@ -17243,12 +16707,12 @@ fi
 
 if test "$ac_cv_func_vprintf" != yes; then
 echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:17247: checking for _doprnt" >&5
+echo "configure:16711: 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 17252 "configure"
+#line 16716 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char _doprnt(); below.  */
@@ -17271,7 +16735,7 @@ _doprnt();
 
 ; return 0; }
 EOF
-if { (eval echo configure:17275: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16739: \"$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
@@ -17379,12 +16843,12 @@ asprintf \
 
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:17383: checking for $ac_func" >&5
+echo "configure:16847: 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 17388 "configure"
+#line 16852 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -17407,7 +16871,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:17411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16875: \"$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
@@ -17432,26 +16896,177 @@ fi
 done
 
 
+echo $ac_n "checking for nanosleep""... $ac_c" 1>&6
+echo "configure:16901: checking for nanosleep" >&5
+if eval "test \"`echo '$''{'ac_cv_func_nanosleep'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+  
+  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:16911: 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
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lrt  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 16919 "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
+    builtin and then its argument prototype would still apply.  */
+char nanosleep();
+
+int main() {
+nanosleep()
+; return 0; }
+EOF
+if { (eval echo configure:16930: \"$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
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  found=yes
+else
+  echo "$ac_t""no" 1>&6
+
+    echo $ac_n "checking for __nanosleep in -lrt""... $ac_c" 1>&6
+echo "configure:16950: 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
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lrt  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 16958 "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
+    builtin and then its argument prototype would still apply.  */
+char __nanosleep();
+
+int main() {
+__nanosleep()
+; return 0; }
+EOF
+if { (eval echo configure:16969: \"$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
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  found=yes
+else
+  echo "$ac_t""no" 1>&6
+found=no
+fi
+
+  
+fi
+
+
+  if test "$found" = "yes"; then
+    ac_libs=$LIBS
+    LIBS="$LIBS -lrt"
+    if test "$cross_compiling" = yes; then
+  found=no
+else
+  cat > conftest.$ac_ext <<EOF
+#line 17001 "configure"
+#include "confdefs.h"
+main() { return (0); }
+EOF
+if { (eval echo configure:17005: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  found=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  found=no
+fi
+rm -fr conftest*
+fi
+
+    LIBS=$ac_libs
+  fi
+
+  if test "$found" = "yes"; then
+    
+  
+  case rt in
+  c|c_r|pthread*) ;;
+  *) 
+      LIBS="-lrt $LIBS" 
+   ;;
+  esac
+
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_NANOSLEEP 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_LIBRT 1
+EOF
+
+    ac_cv_func_nanosleep=yes
+  else
+    
+  :
+
+  fi
+  
+
+fi
+
+echo "$ac_t""$ac_cv_func_nanosleep" 1>&6
+
 echo $ac_n "checking for getaddrinfo""... $ac_c" 1>&6
-echo "configure:17437: checking for getaddrinfo" >&5
+echo "configure:17052: 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 17442 "configure"
+#line 17057 "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:17449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17064: \"$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 17455 "configure"
+#line 17070 "configure"
 #include "confdefs.h"
 
 #include <netdb.h>
@@ -17491,7 +17106,7 @@ int main(void) {
 }
   
 EOF
-if { (eval echo configure:17495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17110: \"$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
@@ -17523,12 +17138,12 @@ fi
 for ac_func in strlcat strlcpy getopt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:17527: checking for $ac_func" >&5
+echo "configure:17142: 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 17532 "configure"
+#line 17147 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -17551,7 +17166,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:17555: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17170: \"$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
@@ -17578,7 +17193,7 @@ done
 
 
 echo $ac_n "checking whether utime accepts a null argument""... $ac_c" 1>&6
-echo "configure:17582: checking whether utime accepts a null argument" >&5
+echo "configure:17197: 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
@@ -17588,7 +17203,7 @@ if test "$cross_compiling" = yes; then
   ac_cv_func_utime_null=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 17592 "configure"
+#line 17207 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -17599,7 +17214,7 @@ exit(!(stat ("conftestdata", &s) == 0 && utime("conftestdata", (long *)0) == 0
 && t.st_mtime - s.st_mtime < 120));
 }
 EOF
-if { (eval echo configure:17603: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17218: \"$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
@@ -17625,19 +17240,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:17629: checking for working alloca.h" >&5
+echo "configure:17244: 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 17634 "configure"
+#line 17249 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:17641: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17256: \"$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
@@ -17658,12 +17273,12 @@ EOF
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:17662: checking for alloca" >&5
+echo "configure:17277: 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 17667 "configure"
+#line 17282 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -17691,7 +17306,7 @@ int main() {
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:17695: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17310: \"$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
@@ -17723,12 +17338,12 @@ EOF
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:17727: checking whether alloca needs Cray hooks" >&5
+echo "configure:17342: 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 17732 "configure"
+#line 17347 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -17753,12 +17368,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:17757: checking for $ac_func" >&5
+echo "configure:17372: 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 17762 "configure"
+#line 17377 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -17781,7 +17396,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:17785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17400: \"$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
@@ -17808,7 +17423,7 @@ done
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:17812: checking stack direction for C alloca" >&5
+echo "configure:17427: 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
@@ -17816,7 +17431,7 @@ else
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 17820 "configure"
+#line 17435 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -17835,7 +17450,7 @@ main ()
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:17839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17454: \"$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
@@ -17858,13 +17473,13 @@ fi
 
 
   echo $ac_n "checking for declared timezone""... $ac_c" 1>&6
-echo "configure:17862: checking for declared timezone" >&5
+echo "configure:17477: 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 17868 "configure"
+#line 17483 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -17879,7 +17494,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:17883: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17498: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   ac_cv_declared_timezone=yes
@@ -17905,7 +17520,7 @@ EOF
 
 
 echo $ac_n "checking for type of reentrant time-related functions""... $ac_c" 1>&6
-echo "configure:17909: checking for type of reentrant time-related functions" >&5
+echo "configure:17524: 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
@@ -17916,7 +17531,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 17920 "configure"
+#line 17535 "configure"
 #include "confdefs.h"
 
 #include <time.h>
@@ -17934,7 +17549,7 @@ return (1);
 }
 
 EOF
-if { (eval echo configure:17938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17553: \"$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
@@ -17950,7 +17565,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 17954 "configure"
+#line 17569 "configure"
 #include "confdefs.h"
 
 #include <time.h>
@@ -17966,7 +17581,7 @@ main() {
 }
   
 EOF
-if { (eval echo configure:17970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17585: \"$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
@@ -18004,12 +17619,12 @@ EOF
 
 
     echo $ac_n "checking for readdir_r""... $ac_c" 1>&6
-echo "configure:18008: checking for readdir_r" >&5
+echo "configure:17623: 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 18013 "configure"
+#line 17628 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char readdir_r(); below.  */
@@ -18032,7 +17647,7 @@ readdir_r();
 
 ; return 0; }
 EOF
-if { (eval echo configure:18036: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17651: \"$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
@@ -18054,7 +17669,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:18058: checking for type of readdir_r" >&5
+echo "configure:17673: 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
@@ -18065,7 +17680,7 @@ else
    
 else
   cat > conftest.$ac_ext <<EOF
-#line 18069 "configure"
+#line 17684 "configure"
 #include "confdefs.h"
 
 #define _REENTRANT
@@ -18090,7 +17705,7 @@ main() {
 }
     
 EOF
-if { (eval echo configure:18094: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17709: \"$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
@@ -18101,7 +17716,7 @@ else
   rm -fr conftest*
   
       cat > conftest.$ac_ext <<EOF
-#line 18105 "configure"
+#line 17720 "configure"
 #include "confdefs.h"
 
 #define _REENTRANT
@@ -18111,7 +17726,7 @@ int readdir_r(DIR *, struct dirent *);
         
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:18115: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:17730: \"$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*
@@ -18153,12 +17768,12 @@ EOF
 
 
 echo $ac_n "checking for in_addr_t""... $ac_c" 1>&6
-echo "configure:18157: checking for in_addr_t" >&5
+echo "configure:17772: 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 18162 "configure"
+#line 17777 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -18192,12 +17807,12 @@ fi
 for ac_func in crypt_r
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:18196: checking for $ac_func" >&5
+echo "configure:17811: 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 18201 "configure"
+#line 17816 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -18220,7 +17835,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:18224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17839: \"$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
@@ -18248,14 +17863,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:18252: checking which data struct is used by crypt_r" >&5
+echo "configure:17867: 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 18259 "configure"
+#line 17874 "configure"
 #include "confdefs.h"
 
 #define _REENTRANT 1
@@ -18268,7 +17883,7 @@ crypt_r("passwd", "hash", &buffer);
 
 ; return 0; }
 EOF
-if { (eval echo configure:18272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17887: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   php_cv_crypt_r_style=cryptd
 else
@@ -18279,7 +17894,7 @@ rm -f conftest*
 
     if test "$php_cv_crypt_r_style" = "none"; then
       cat > conftest.$ac_ext <<EOF
-#line 18283 "configure"
+#line 17898 "configure"
 #include "confdefs.h"
 
 #define _REENTRANT 1
@@ -18292,7 +17907,7 @@ crypt_r("passwd", "hash", &buffer);
 
 ; return 0; }
 EOF
-if { (eval echo configure:18296: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17911: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   php_cv_crypt_r_style=struct_crypt_data
 else
@@ -18304,7 +17919,7 @@ rm -f conftest*
 
     if test "$php_cv_crypt_r_style" = "none"; then
       cat > conftest.$ac_ext <<EOF
-#line 18308 "configure"
+#line 17923 "configure"
 #include "confdefs.h"
 
 #define _REENTRANT 1
@@ -18318,7 +17933,7 @@ crypt_r("passwd", "hash", &buffer);
 
 ; return 0; }
 EOF
-if { (eval echo configure:18322: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17937: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   php_cv_crypt_r_style=struct_crypt_data_gnu_source
 else
@@ -18377,7 +17992,7 @@ fi
 php_enable_gcov=no
 
 echo $ac_n "checking whether to include gcov symbols""... $ac_c" 1>&6
-echo "configure:18381: checking whether to include gcov symbols" >&5
+echo "configure:17996: 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"
@@ -18419,7 +18034,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:18423: checking for $ac_word" >&5
+echo "configure:18038: 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
@@ -18448,7 +18063,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:18452: checking for $ac_word" >&5
+echo "configure:18067: 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
@@ -18483,7 +18098,7 @@ fi
 
   if test "$LTP"; then
     echo $ac_n "checking for ltp version""... $ac_c" 1>&6
-echo "configure:18487: checking for ltp version" >&5
+echo "configure:18102: 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
@@ -18540,7 +18155,7 @@ fi
 php_enable_debug=no
 
 echo $ac_n "checking whether to include debugging symbols""... $ac_c" 1>&6
-echo "configure:18544: checking whether to include debugging symbols" >&5
+echo "configure:18159: 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"
@@ -18591,7 +18206,7 @@ fi
 php_with_layout=PHP
 
 echo $ac_n "checking layout of installed files""... $ac_c" 1>&6
-echo "configure:18595: checking layout of installed files" >&5
+echo "configure:18210: 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"
@@ -18626,7 +18241,7 @@ esac
 php_with_config_file_path=DEFAULT
 
 echo $ac_n "checking path to configuration file""... $ac_c" 1>&6
-echo "configure:18630: checking path to configuration file" >&5
+echo "configure:18245: 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"
@@ -18660,7 +18275,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:18664: checking where to scan for configuration files" >&5
+echo "configure:18279: checking where to scan for configuration files" >&5
 
 php_with_config_file_scan_dir=DEFAULT
 
@@ -18696,7 +18311,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:18700: checking whether to enable safe mode by default" >&5
+echo "configure:18315: 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"
@@ -18731,7 +18346,7 @@ EOF
 fi
 
 echo $ac_n "checking for safe mode exec dir""... $ac_c" 1>&6
-echo "configure:18735: checking for safe mode exec dir" >&5
+echo "configure:18350: checking for safe mode exec dir" >&5
 
 php_with_exec_dir=no
 
@@ -18775,7 +18390,7 @@ fi
 php_enable_sigchild=no
 
 echo $ac_n "checking whether to enable PHP's own SIGCHLD handler""... $ac_c" 1>&6
-echo "configure:18779: checking whether to enable PHP's own SIGCHLD handler" >&5
+echo "configure:18394: 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"
@@ -18813,7 +18428,7 @@ fi
 php_enable_magic_quotes=no
 
 echo $ac_n "checking whether to enable magic quotes by default""... $ac_c" 1>&6
-echo "configure:18817: checking whether to enable magic quotes by default" >&5
+echo "configure:18432: 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"
@@ -18851,7 +18466,7 @@ fi
 php_enable_libgcc=no
 
 echo $ac_n "checking whether to explicitly link against libgcc""... $ac_c" 1>&6
-echo "configure:18855: checking whether to explicitly link against libgcc" >&5
+echo "configure:18470: 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"
@@ -18931,7 +18546,7 @@ fi
 php_enable_short_tags=yes
 
 echo $ac_n "checking whether to enable short tags by default""... $ac_c" 1>&6
-echo "configure:18935: checking whether to enable short tags by default" >&5
+echo "configure:18550: 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"
@@ -18969,7 +18584,7 @@ fi
 php_enable_dmalloc=no
 
 echo $ac_n "checking whether to enable dmalloc""... $ac_c" 1>&6
-echo "configure:18973: checking whether to enable dmalloc" >&5
+echo "configure:18588: 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"
@@ -18993,7 +18608,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:18997: checking for dmalloc_error in -ldmalloc" >&5
+echo "configure:18612: 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
@@ -19001,7 +18616,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldmalloc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 19005 "configure"
+#line 18620 "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
@@ -19012,7 +18627,7 @@ int main() {
 dmalloc_error()
 ; return 0; }
 EOF
-if { (eval echo configure:19016: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18631: \"$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
@@ -19057,7 +18672,7 @@ fi
 php_enable_ipv6=yes
 
 echo $ac_n "checking whether to enable IPv6 support""... $ac_c" 1>&6
-echo "configure:19061: checking whether to enable IPv6 support" >&5
+echo "configure:18676: 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"
@@ -19087,7 +18702,7 @@ EOF
 fi
 
 echo $ac_n "checking how big to make fd sets""... $ac_c" 1>&6
-echo "configure:19091: checking how big to make fd sets" >&5
+echo "configure:18706: checking how big to make fd sets" >&5
 
 php_enable_fd_setsize=no
 
@@ -19158,7 +18773,7 @@ fi
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:19162: checking size of long" >&5
+echo "configure:18777: 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
@@ -19166,7 +18781,7 @@ else
   ac_cv_sizeof_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 19170 "configure"
+#line 18785 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -19177,7 +18792,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:19181: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:18796: \"$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
@@ -19197,7 +18812,7 @@ EOF
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:19201: checking size of int" >&5
+echo "configure:18816: 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
@@ -19205,7 +18820,7 @@ else
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 19209 "configure"
+#line 18824 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -19216,7 +18831,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:19220: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:18835: \"$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
@@ -19237,13 +18852,13 @@ EOF
 
 
 echo $ac_n "checking for int32_t""... $ac_c" 1>&6
-echo "configure:19241: checking for int32_t" >&5
+echo "configure:18856: 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 19247 "configure"
+#line 18862 "configure"
 #include "confdefs.h"
 
 #if HAVE_SYS_TYPES_H
@@ -19262,7 +18877,7 @@ if (sizeof (int32_t))
 
 ; return 0; }
 EOF
-if { (eval echo configure:19266: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:18881: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_int_type_int32_t=yes
 else
@@ -19285,13 +18900,13 @@ fi
 
 
 echo $ac_n "checking for uint32_t""... $ac_c" 1>&6
-echo "configure:19289: checking for uint32_t" >&5
+echo "configure:18904: 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 19295 "configure"
+#line 18910 "configure"
 #include "confdefs.h"
 
 #if HAVE_SYS_TYPES_H
@@ -19310,7 +18925,7 @@ if (sizeof (uint32_t))
 
 ; return 0; }
 EOF
-if { (eval echo configure:19314: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:18929: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_int_type_uint32_t=yes
 else
@@ -19342,17 +18957,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:19346: checking for $ac_hdr" >&5
+echo "configure:18961: 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 19351 "configure"
+#line 18966 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:19356: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:18971: \"$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*
@@ -19382,12 +18997,12 @@ done
 for ac_func in strtoll atoll strftime
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:19386: checking for $ac_func" >&5
+echo "configure:19001: 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 19391 "configure"
+#line 19006 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -19410,7 +19025,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:19414: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:19029: \"$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
@@ -19875,7 +19490,7 @@ case $PHP_REGEX in
 esac
 
 echo $ac_n "checking which regex library to use""... $ac_c" 1>&6
-echo "configure:19879: checking which regex library to use" >&5
+echo "configure:19494: checking which regex library to use" >&5
 echo "$ac_t""$REGEX_TYPE" 1>&6
 
 if test "$REGEX_TYPE" = "php"; then
@@ -20252,13 +19867,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:20256: checking whether field re_magic exists in struct regex_t" >&5
+echo "configure:19871: 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 20262 "configure"
+#line 19877 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <regex.h>
@@ -20266,7 +19881,7 @@ int main() {
 regex_t rt; rt.re_magic;
 ; return 0; }
 EOF
-if { (eval echo configure:20270: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:19885: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_regex_t_re_magic=yes
 else
@@ -20292,7 +19907,7 @@ fi
 php_enable_libxml=yes
 
 echo $ac_n "checking whether to enable LIBXML support""... $ac_c" 1>&6
-echo "configure:20296: checking whether to enable LIBXML support" >&5
+echo "configure:19911: 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"
@@ -20340,7 +19955,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:20344: checking libxml2 install dir" >&5
+echo "configure:19959: 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"
@@ -20369,7 +19984,7 @@ if test "$PHP_LIBXML" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:20373: checking for xml2-config path" >&5
+echo "configure:19988: 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
@@ -20527,7 +20142,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:20531: checking whether libxml build works" >&5
+echo "configure:20146: 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
@@ -20543,7 +20158,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 20547 "configure"
+#line 20162 "configure"
 #include "confdefs.h"
 
     
@@ -20554,7 +20169,7 @@ else
     }
   
 EOF
-if { (eval echo configure:20558: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:20173: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -20919,7 +20534,7 @@ fi
 php_with_openssl=no
 
 echo $ac_n "checking for OpenSSL support""... $ac_c" 1>&6
-echo "configure:20923: checking for OpenSSL support" >&5
+echo "configure:20538: checking for OpenSSL support" >&5
 # Check whether --with-openssl or --without-openssl was given.
 if test "${with_openssl+set}" = set; then
   withval="$with_openssl"
@@ -20966,7 +20581,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:20970: checking for Kerberos support" >&5
+echo "configure:20585: checking for Kerberos support" >&5
 # Check whether --with-kerberos or --without-kerberos was given.
 if test "${with_kerberos+set}" = set; then
   withval="$with_kerberos"
@@ -21295,7 +20910,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:21299: checking for $ac_word" >&5
+echo "configure:20914: 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
@@ -21655,7 +21270,7 @@ fi
   fi
 
   echo $ac_n "checking for DSA_get_default_method in -lssl""... $ac_c" 1>&6
-echo "configure:21659: checking for DSA_get_default_method in -lssl" >&5
+echo "configure:21274: 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
@@ -21663,7 +21278,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 21667 "configure"
+#line 21282 "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
@@ -21674,7 +21289,7 @@ int main() {
 DSA_get_default_method()
 ; return 0; }
 EOF
-if { (eval echo configure:21678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:21293: \"$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
@@ -21716,7 +21331,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:21720: checking for $ac_word" >&5
+echo "configure:21335: 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
@@ -21921,9 +21536,9 @@ fi
     old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=-I$OPENSSL_INCDIR
     echo $ac_n "checking for OpenSSL version""... $ac_c" 1>&6
-echo "configure:21925: checking for OpenSSL version" >&5
+echo "configure:21540: checking for OpenSSL version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 21927 "configure"
+#line 21542 "configure"
 #include "confdefs.h"
 
 #include <openssl/opensslv.h>
@@ -22078,7 +21693,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for CRYPTO_free in -lcrypto""... $ac_c" 1>&6
-echo "configure:22082: checking for CRYPTO_free in -lcrypto" >&5
+echo "configure:21697: 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
@@ -22086,7 +21701,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 22090 "configure"
+#line 21705 "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
@@ -22097,7 +21712,7 @@ int main() {
 CRYPTO_free()
 ; return 0; }
 EOF
-if { (eval echo configure:22101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:21716: \"$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
@@ -22254,7 +21869,7 @@ fi
   done
 
   echo $ac_n "checking for SSL_CTX_set_ssl_version in -lssl""... $ac_c" 1>&6
-echo "configure:22258: checking for SSL_CTX_set_ssl_version in -lssl" >&5
+echo "configure:21873: 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
@@ -22262,7 +21877,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 22266 "configure"
+#line 21881 "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
@@ -22273,7 +21888,7 @@ int main() {
 SSL_CTX_set_ssl_version()
 ; return 0; }
 EOF
-if { (eval echo configure:22277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:21892: \"$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
@@ -22418,7 +22033,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:22422: checking for PCRE headers location" >&5
+echo "configure:22037: 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
@@ -22429,7 +22044,7 @@ echo "configure:22422: 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:22433: checking for PCRE library location" >&5
+echo "configure:22048: 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
@@ -22851,7 +22466,7 @@ EOF
 
   else
     echo $ac_n "checking for PCRE library to use""... $ac_c" 1>&6
-echo "configure:22855: checking for PCRE library to use" >&5
+echo "configure:22470: 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 \
@@ -23188,7 +22803,7 @@ EOF
 php_with_sqlite3=yes
 
 echo $ac_n "checking whether to enable the SQLite3 extension""... $ac_c" 1>&6
-echo "configure:23192: checking whether to enable the SQLite3 extension" >&5
+echo "configure:22807: 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"
@@ -23246,7 +22861,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:23250: checking for sqlite3 files in default path" >&5
+echo "configure:22865: 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
@@ -23261,7 +22876,7 @@ echo "configure:23250: checking for sqlite3 files in default path" >&5
     fi
 
     echo $ac_n "checking for SQLite 3.3.9+""... $ac_c" 1>&6
-echo "configure:23265: checking for SQLite 3.3.9+" >&5
+echo "configure:22880: checking for SQLite 3.3.9+" >&5
     
   save_old_LDFLAGS=$LDFLAGS
   ac_stuff="
@@ -23360,7 +22975,7 @@ echo "configure:23265: checking for SQLite 3.3.9+" >&5
   done
 
   echo $ac_n "checking for sqlite3_prepare_v2 in -lsqlite3""... $ac_c" 1>&6
-echo "configure:23364: checking for sqlite3_prepare_v2 in -lsqlite3" >&5
+echo "configure:22979: 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
@@ -23368,7 +22983,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsqlite3  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 23372 "configure"
+#line 22987 "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
@@ -23379,7 +22994,7 @@ int main() {
 sqlite3_prepare_v2()
 ; return 0; }
 EOF
-if { (eval echo configure:23383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:22998: \"$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
@@ -23639,7 +23254,7 @@ fi
   done
 
   echo $ac_n "checking for sqlite3_key in -lsqlite3""... $ac_c" 1>&6
-echo "configure:23643: checking for sqlite3_key in -lsqlite3" >&5
+echo "configure:23258: 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
@@ -23647,7 +23262,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsqlite3  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 23651 "configure"
+#line 23266 "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
@@ -23658,7 +23273,7 @@ int main() {
 sqlite3_key()
 ; return 0; }
 EOF
-if { (eval echo configure:23662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:23277: \"$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
@@ -23790,7 +23405,7 @@ fi
   done
 
   echo $ac_n "checking for sqlite3_load_extension in -lsqlite3""... $ac_c" 1>&6
-echo "configure:23794: checking for sqlite3_load_extension in -lsqlite3" >&5
+echo "configure:23409: 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
@@ -23798,7 +23413,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsqlite3  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 23802 "configure"
+#line 23417 "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
@@ -23809,7 +23424,7 @@ int main() {
 sqlite3_load_extension()
 ; return 0; }
 EOF
-if { (eval echo configure:23813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:23428: \"$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
@@ -23846,7 +23461,7 @@ fi
 
   else
     echo $ac_n "checking bundled sqlite3 library""... $ac_c" 1>&6
-echo "configure:23850: checking bundled sqlite3 library" >&5
+echo "configure:23465: checking bundled sqlite3 library" >&5
     echo "$ac_t""yes" 1>&6
 
     sqlite3_extra_sources="libsqlite/sqlite3.c"
@@ -24184,7 +23799,7 @@ fi
 php_with_zlib=no
 
 echo $ac_n "checking for ZLIB support""... $ac_c" 1>&6
-echo "configure:24188: checking for ZLIB support" >&5
+echo "configure:23803: checking for ZLIB support" >&5
 # Check whether --with-zlib or --without-zlib was given.
 if test "${with_zlib+set}" = set; then
   withval="$with_zlib"
@@ -24231,7 +23846,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:24235: checking if the location of ZLIB install directory is defined" >&5
+echo "configure:23850: 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"
@@ -24677,7 +24292,7 @@ EOF
   done
 
   echo $ac_n "checking for gzgets in -lz""... $ac_c" 1>&6
-echo "configure:24681: checking for gzgets in -lz" >&5
+echo "configure:24296: 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
@@ -24685,7 +24300,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lz  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 24689 "configure"
+#line 24304 "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
@@ -24696,7 +24311,7 @@ int main() {
 gzgets()
 ; return 0; }
 EOF
-if { (eval echo configure:24700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:24315: \"$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
@@ -24836,7 +24451,7 @@ fi
 php_enable_bcmath=no
 
 echo $ac_n "checking whether to enable bc style precision math functions""... $ac_c" 1>&6
-echo "configure:24840: checking whether to enable bc style precision math functions" >&5
+echo "configure:24455: 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"
@@ -25204,7 +24819,7 @@ fi
 php_with_bz2=no
 
 echo $ac_n "checking for BZip2 support""... $ac_c" 1>&6
-echo "configure:25208: checking for BZip2 support" >&5
+echo "configure:24823: checking for BZip2 support" >&5
 # Check whether --with-bz2 or --without-bz2 was given.
 if test "${with_bz2+set}" = set; then
   withval="$with_bz2"
@@ -25252,7 +24867,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:25256: checking for BZip2 in default path" >&5
+echo "configure:24871: 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
@@ -25365,7 +24980,7 @@ echo "configure:25256: checking for BZip2 in default path" >&5
   done
 
   echo $ac_n "checking for BZ2_bzerror in -lbz2""... $ac_c" 1>&6
-echo "configure:25369: checking for BZ2_bzerror in -lbz2" >&5
+echo "configure:24984: 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
@@ -25373,7 +24988,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbz2  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 25377 "configure"
+#line 24992 "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
@@ -25384,7 +24999,7 @@ int main() {
 BZ2_bzerror()
 ; return 0; }
 EOF
-if { (eval echo configure:25388: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:25003: \"$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
@@ -25852,7 +25467,7 @@ fi
 php_enable_calendar=no
 
 echo $ac_n "checking whether to enable calendar conversion support""... $ac_c" 1>&6
-echo "configure:25856: checking whether to enable calendar conversion support" >&5
+echo "configure:25471: 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"
@@ -26199,7 +25814,7 @@ fi
 php_enable_ctype=yes
 
 echo $ac_n "checking whether to enable ctype functions""... $ac_c" 1>&6
-echo "configure:26203: checking whether to enable ctype functions" >&5
+echo "configure:25818: 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"
@@ -26546,7 +26161,7 @@ fi
 php_with_curl=no
 
 echo $ac_n "checking for cURL support""... $ac_c" 1>&6
-echo "configure:26550: checking for cURL support" >&5
+echo "configure:26165: checking for cURL support" >&5
 # Check whether --with-curl or --without-curl was given.
 if test "${with_curl+set}" = set; then
   withval="$with_curl"
@@ -26593,7 +26208,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:26597: checking if we should use cURL for url streams" >&5
+echo "configure:26212: 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"
@@ -26620,7 +26235,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:26624: checking for cURL in default path" >&5
+echo "configure:26239: 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
@@ -26638,7 +26253,7 @@ echo "configure:26624: 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:26642: checking for cURL 7.10.5 or greater" >&5
+echo "configure:26257: 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
@@ -26876,7 +26491,7 @@ echo "configure:26642: checking for cURL 7.10.5 or greater" >&5
 
   
   echo $ac_n "checking for SSL support in libcurl""... $ac_c" 1>&6
-echo "configure:26880: checking for SSL support in libcurl" >&5
+echo "configure:26495: 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
@@ -26889,7 +26504,7 @@ EOF
     CFLAGS="`$CURL_CONFIG --cflags`"
    
     echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:26893: checking how to run the C preprocessor" >&5
+echo "configure:26508: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -26904,13 +26519,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 26908 "configure"
+#line 26523 "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:26914: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:26529: \"$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
   :
@@ -26921,13 +26536,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 26925 "configure"
+#line 26540 "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:26931: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:26546: \"$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
   :
@@ -26938,13 +26553,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 26942 "configure"
+#line 26557 "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:26948: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:26563: \"$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
   :
@@ -26969,14 +26584,14 @@ fi
 echo "$ac_t""$CPP" 1>&6
 
     echo $ac_n "checking for openssl support in libcurl""... $ac_c" 1>&6
-echo "configure:26973: checking for openssl support in libcurl" >&5
+echo "configure:26588: 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 26980 "configure"
+#line 26595 "configure"
 #include "confdefs.h"
 
 #include <curl/curl.h>
@@ -26995,7 +26610,7 @@ int main(int argc, char *argv[])
 }
     
 EOF
-if { (eval echo configure:26999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:26614: \"$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
@@ -27003,17 +26618,17 @@ then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:27007: checking for $ac_hdr" >&5
+echo "configure:26622: 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 27012 "configure"
+#line 26627 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:27017: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:26632: \"$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*
@@ -27058,14 +26673,14 @@ fi
 
    
     echo $ac_n "checking for gnutls support in libcurl""... $ac_c" 1>&6
-echo "configure:27062: checking for gnutls support in libcurl" >&5
+echo "configure:26677: 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 27069 "configure"
+#line 26684 "configure"
 #include "confdefs.h"
 
 #include <curl/curl.h>
@@ -27084,23 +26699,23 @@ int main(int argc, char *argv[])
 }
 
 EOF
-if { (eval echo configure:27088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:26703: \"$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:27094: checking for gcrypt.h" >&5
+echo "configure:26709: 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 27099 "configure"
+#line 26714 "configure"
 #include "confdefs.h"
 #include <gcrypt.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:27104: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:26719: \"$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*
@@ -27242,7 +26857,7 @@ fi
   done
 
   echo $ac_n "checking for curl_easy_perform in -lcurl""... $ac_c" 1>&6
-echo "configure:27246: checking for curl_easy_perform in -lcurl" >&5
+echo "configure:26861: 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
@@ -27250,7 +26865,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcurl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 27254 "configure"
+#line 26869 "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
@@ -27261,7 +26876,7 @@ int main() {
 curl_easy_perform()
 ; return 0; }
 EOF
-if { (eval echo configure:27265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:26880: \"$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
@@ -27397,7 +27012,7 @@ fi
   done
 
   echo $ac_n "checking for curl_version_info in -lcurl""... $ac_c" 1>&6
-echo "configure:27401: checking for curl_version_info in -lcurl" >&5
+echo "configure:27016: 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
@@ -27405,7 +27020,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcurl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 27409 "configure"
+#line 27024 "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
@@ -27416,7 +27031,7 @@ int main() {
 curl_version_info()
 ; return 0; }
 EOF
-if { (eval echo configure:27420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:27035: \"$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
@@ -27550,7 +27165,7 @@ fi
   done
 
   echo $ac_n "checking for curl_easy_strerror in -lcurl""... $ac_c" 1>&6
-echo "configure:27554: checking for curl_easy_strerror in -lcurl" >&5
+echo "configure:27169: 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
@@ -27558,7 +27173,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcurl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 27562 "configure"
+#line 27177 "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
@@ -27569,7 +27184,7 @@ int main() {
 curl_easy_strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:27573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:27188: \"$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
@@ -27703,7 +27318,7 @@ fi
   done
 
   echo $ac_n "checking for curl_multi_strerror in -lcurl""... $ac_c" 1>&6
-echo "configure:27707: checking for curl_multi_strerror in -lcurl" >&5
+echo "configure:27322: 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
@@ -27711,7 +27326,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcurl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 27715 "configure"
+#line 27330 "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
@@ -27722,7 +27337,7 @@ int main() {
 curl_multi_strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:27726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:27341: \"$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
@@ -28435,7 +28050,7 @@ if test "$PHP_QDBM" != "no"; then
   done
 
   echo $ac_n "checking for dpopen in -l$LIB""... $ac_c" 1>&6
-echo "configure:28439: checking for dpopen in -l$LIB" >&5
+echo "configure:28054: 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
@@ -28443,7 +28058,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 28447 "configure"
+#line 28062 "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
@@ -28454,7 +28069,7 @@ int main() {
 dpopen()
 ; return 0; }
 EOF
-if { (eval echo configure:28458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:28073: \"$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
@@ -28623,7 +28238,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:28627: checking for $THIS_FULL_NAME support" >&5
+echo "configure:28242: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -28651,7 +28266,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:28655: checking for $THIS_FULL_NAME support" >&5
+echo "configure:28270: 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
@@ -28770,7 +28385,7 @@ echo "configure:28655: checking for $THIS_FULL_NAME support" >&5
   done
 
   echo $ac_n "checking for gdbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:28774: checking for gdbm_open in -lgdbm" >&5
+echo "configure:28389: 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
@@ -28778,7 +28393,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgdbm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 28782 "configure"
+#line 28397 "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
@@ -28789,7 +28404,7 @@ int main() {
 gdbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:28793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:28408: \"$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
@@ -28954,7 +28569,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:28958: checking for $THIS_FULL_NAME support" >&5
+echo "configure:28573: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -29083,7 +28698,7 @@ if test "$PHP_NDBM" != "no"; then
   done
 
   echo $ac_n "checking for dbm_open in -l$LIB""... $ac_c" 1>&6
-echo "configure:29087: checking for dbm_open in -l$LIB" >&5
+echo "configure:28702: 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
@@ -29091,7 +28706,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 29095 "configure"
+#line 28710 "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
@@ -29102,7 +28717,7 @@ int main() {
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:29106: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:28721: \"$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
@@ -29271,7 +28886,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:29275: checking for $THIS_FULL_NAME support" >&5
+echo "configure:28890: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -29338,7 +28953,7 @@ if test "$PHP_DB4" != "no"; then
   LIBS="-l$LIB $LIBS"
   
         cat > conftest.$ac_ext <<EOF
-#line 29342 "configure"
+#line 28957 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -29349,11 +28964,11 @@ int main() {
         
 ; return 0; }
 EOF
-if { (eval echo configure:29353: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:28968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
           cat > conftest.$ac_ext <<EOF
-#line 29357 "configure"
+#line 28972 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -29390,14 +29005,14 @@ rm -f conftest*
   done
   if test -z "$THIS_LIBS"; then
     echo $ac_n "checking for db4 major version""... $ac_c" 1>&6
-echo "configure:29394: checking for db4 major version" >&5
+echo "configure:29009: 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:29399: checking for db4 minor version and patch level" >&5
+echo "configure:29014: checking for db4 minor version and patch level" >&5
     cat > conftest.$ac_ext <<EOF
-#line 29401 "configure"
+#line 29016 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -29423,9 +29038,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:29427: checking if dba can be used as shared extension" >&5
+echo "configure:29042: checking if dba can be used as shared extension" >&5
     cat > conftest.$ac_ext <<EOF
-#line 29429 "configure"
+#line 29044 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -29582,7 +29197,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:29586: checking for $THIS_FULL_NAME support" >&5
+echo "configure:29201: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -29610,7 +29225,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:29614: checking for $THIS_FULL_NAME support" >&5
+echo "configure:29229: 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
@@ -29661,7 +29276,7 @@ echo "configure:29614: checking for $THIS_FULL_NAME support" >&5
   LIBS="-l$LIB $LIBS"
   
         cat > conftest.$ac_ext <<EOF
-#line 29665 "configure"
+#line 29280 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -29672,11 +29287,11 @@ int main() {
         
 ; return 0; }
 EOF
-if { (eval echo configure:29676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:29291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
           cat > conftest.$ac_ext <<EOF
-#line 29680 "configure"
+#line 29295 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -29713,14 +29328,14 @@ rm -f conftest*
   done
   if test -z "$THIS_LIBS"; then
     echo $ac_n "checking for db3 major version""... $ac_c" 1>&6
-echo "configure:29717: checking for db3 major version" >&5
+echo "configure:29332: 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:29722: checking for db4 minor version and patch level" >&5
+echo "configure:29337: checking for db4 minor version and patch level" >&5
     cat > conftest.$ac_ext <<EOF
-#line 29724 "configure"
+#line 29339 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -29746,9 +29361,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:29750: checking if dba can be used as shared extension" >&5
+echo "configure:29365: checking if dba can be used as shared extension" >&5
     cat > conftest.$ac_ext <<EOF
-#line 29752 "configure"
+#line 29367 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -29905,7 +29520,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:29909: checking for $THIS_FULL_NAME support" >&5
+echo "configure:29524: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -29933,7 +29548,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:29937: checking for $THIS_FULL_NAME support" >&5
+echo "configure:29552: 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
@@ -29984,7 +29599,7 @@ echo "configure:29937: checking for $THIS_FULL_NAME support" >&5
   LIBS="-l$LIB $LIBS"
   
         cat > conftest.$ac_ext <<EOF
-#line 29988 "configure"
+#line 29603 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -29995,11 +29610,11 @@ int main() {
         
 ; return 0; }
 EOF
-if { (eval echo configure:29999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:29614: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
           cat > conftest.$ac_ext <<EOF
-#line 30003 "configure"
+#line 29618 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -30036,14 +29651,14 @@ rm -f conftest*
   done
   if test -z "$THIS_LIBS"; then
     echo $ac_n "checking for db2 major version""... $ac_c" 1>&6
-echo "configure:30040: checking for db2 major version" >&5
+echo "configure:29655: 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:30045: checking for db4 minor version and patch level" >&5
+echo "configure:29660: checking for db4 minor version and patch level" >&5
     cat > conftest.$ac_ext <<EOF
-#line 30047 "configure"
+#line 29662 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -30069,9 +29684,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:30073: checking if dba can be used as shared extension" >&5
+echo "configure:29688: checking if dba can be used as shared extension" >&5
     cat > conftest.$ac_ext <<EOF
-#line 30075 "configure"
+#line 29690 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -30228,7 +29843,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:30232: checking for $THIS_FULL_NAME support" >&5
+echo "configure:29847: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -30248,7 +29863,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:30252: checking for DB1 in library" >&5
+echo "configure:29867: checking for DB1 in library" >&5
   if test "$HAVE_DB4" = "1"; then
     THIS_VERSION=4
     THIS_LIBS=$DB4_LIBS
@@ -30296,7 +29911,7 @@ EOF
   fi
   echo "$ac_t""$THIS_LIBS" 1>&6
   echo $ac_n "checking for DB1 in header""... $ac_c" 1>&6
-echo "configure:30300: checking for DB1 in header" >&5
+echo "configure:29915: checking for DB1 in header" >&5
   echo "$ac_t""$THIS_INCLUDE" 1>&6
   if test -n "$THIS_INCLUDE"; then
     
@@ -30306,7 +29921,7 @@ echo "configure:30300: checking for DB1 in header" >&5
   LIBS="-l$THIS_LIBS $LIBS"
   
       cat > conftest.$ac_ext <<EOF
-#line 30310 "configure"
+#line 29925 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -30317,7 +29932,7 @@ int main() {
       
 ; return 0; }
 EOF
-if { (eval echo configure:30321: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:29936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
         cat >> confdefs.h <<EOF
@@ -30467,7 +30082,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:30471: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30086: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -30495,7 +30110,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:30499: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30114: 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
@@ -30619,7 +30234,7 @@ echo "configure:30499: checking for $THIS_FULL_NAME support" >&5
   done
 
   echo $ac_n "checking for dbminit in -l$LIB""... $ac_c" 1>&6
-echo "configure:30623: checking for dbminit in -l$LIB" >&5
+echo "configure:30238: 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
@@ -30627,7 +30242,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 30631 "configure"
+#line 30246 "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
@@ -30638,7 +30253,7 @@ int main() {
 dbminit()
 ; return 0; }
 EOF
-if { (eval echo configure:30642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:30257: \"$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
@@ -30658,7 +30273,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:30662: checking for DBM using GDBM" >&5
+echo "configure:30277: checking for DBM using GDBM" >&5
         cat >> confdefs.h <<EOF
 #define DBM_INCLUDE_FILE "$THIS_INCLUDE"
 EOF
@@ -30822,7 +30437,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:30826: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30441: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -31043,7 +30658,7 @@ elif test "$PHP_CDB" != "no"; then
   done
 
   echo $ac_n "checking for cdb_read in -l$LIB""... $ac_c" 1>&6
-echo "configure:31047: checking for cdb_read in -l$LIB" >&5
+echo "configure:30662: 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
@@ -31051,7 +30666,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 31055 "configure"
+#line 30670 "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
@@ -31062,7 +30677,7 @@ int main() {
 cdb_read()
 ; return 0; }
 EOF
-if { (eval echo configure:31066: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:30681: \"$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
@@ -31231,7 +30846,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:31235: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30850: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -31262,7 +30877,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:31266: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30881: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -31293,7 +30908,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:31297: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30912: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -31308,7 +30923,7 @@ echo "configure:31297: checking for $THIS_FULL_NAME support" >&5
 
 
 echo $ac_n "checking whether to enable DBA interface""... $ac_c" 1>&6
-echo "configure:31312: checking whether to enable DBA interface" >&5
+echo "configure:30927: 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
@@ -31638,7 +31253,7 @@ fi
 php_enable_dom=yes
 
 echo $ac_n "checking whether to enable DOM support""... $ac_c" 1>&6
-echo "configure:31642: checking whether to enable DOM support" >&5
+echo "configure:31257: 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"
@@ -31686,7 +31301,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:31690: checking libxml2 install dir" >&5
+echo "configure:31305: 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"
@@ -31717,7 +31332,7 @@ if test "$PHP_DOM" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:31721: checking for xml2-config path" >&5
+echo "configure:31336: 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
@@ -31875,7 +31490,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:31879: checking whether libxml build works" >&5
+echo "configure:31494: 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
@@ -31891,7 +31506,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 31895 "configure"
+#line 31510 "configure"
 #include "confdefs.h"
 
     
@@ -31902,7 +31517,7 @@ else
     }
   
 EOF
-if { (eval echo configure:31906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:31521: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -32325,7 +31940,7 @@ fi
 php_with_enchant=no
 
 echo $ac_n "checking for ENCHANT support""... $ac_c" 1>&6
-echo "configure:32329: checking for ENCHANT support" >&5
+echo "configure:31944: checking for ENCHANT support" >&5
 # Check whether --with-enchant or --without-enchant was given.
 if test "${with_enchant+set}" = set; then
   withval="$with_enchant"
@@ -32913,7 +32528,7 @@ EOF
   done
 
   echo $ac_n "checking for enchant_broker_set_param in -lenchant""... $ac_c" 1>&6
-echo "configure:32917: checking for enchant_broker_set_param in -lenchant" >&5
+echo "configure:32532: 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
@@ -32921,7 +32536,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lenchant  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 32925 "configure"
+#line 32540 "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
@@ -32932,7 +32547,7 @@ int main() {
 enchant_broker_set_param()
 ; return 0; }
 EOF
-if { (eval echo configure:32936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:32551: \"$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
@@ -32979,7 +32594,7 @@ fi
 php_enable_exif=no
 
 echo $ac_n "checking whether to enable EXIF (metadata from images) support""... $ac_c" 1>&6
-echo "configure:32983: checking whether to enable EXIF (metadata from images) support" >&5
+echo "configure:32598: 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"
@@ -33326,7 +32941,7 @@ fi
 php_enable_fileinfo=yes
 
 echo $ac_n "checking for fileinfo support""... $ac_c" 1>&6
-echo "configure:33330: checking for fileinfo support" >&5
+echo "configure:32945: checking for fileinfo support" >&5
 # Check whether --enable-fileinfo or --disable-fileinfo was given.
 if test "${enable_fileinfo+set}" = set; then
   enableval="$enable_fileinfo"
@@ -33679,12 +33294,12 @@ EOF
   for ac_func in utimes strndup
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:33683: checking for $ac_func" >&5
+echo "configure:33298: 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 33688 "configure"
+#line 33303 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -33707,7 +33322,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:33711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:33326: \"$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
@@ -33745,7 +33360,7 @@ fi
 php_enable_filter=yes
 
 echo $ac_n "checking whether to enable input filter support""... $ac_c" 1>&6
-echo "configure:33749: checking whether to enable input filter support" >&5
+echo "configure:33364: 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"
@@ -33792,7 +33407,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:33796: checking pcre install prefix" >&5
+echo "configure:33411: 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"
@@ -33822,7 +33437,7 @@ if test "$PHP_FILTER" != "no"; then
         old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=$INCLUDES
     cat > conftest.$ac_ext <<EOF
-#line 33826 "configure"
+#line 33441 "configure"
 #include "confdefs.h"
 
 #include <main/php_config.h>
@@ -33841,7 +33456,7 @@ else
   rm -rf conftest*
   
       cat > conftest.$ac_ext <<EOF
-#line 33845 "configure"
+#line 33460 "configure"
 #include "confdefs.h"
 
 #include <main/php_config.h>
@@ -34211,7 +33826,7 @@ fi
 php_enable_ftp=no
 
 echo $ac_n "checking whether to enable FTP support""... $ac_c" 1>&6
-echo "configure:34215: checking whether to enable FTP support" >&5
+echo "configure:33830: 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"
@@ -34258,7 +33873,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:34262: checking OpenSSL dir for FTP" >&5
+echo "configure:33877: 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"
@@ -34599,7 +34214,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:34603: checking for $ac_word" >&5
+echo "configure:34218: 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
@@ -34804,9 +34419,9 @@ fi
     old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=-I$OPENSSL_INCDIR
     echo $ac_n "checking for OpenSSL version""... $ac_c" 1>&6
-echo "configure:34808: checking for OpenSSL version" >&5
+echo "configure:34423: checking for OpenSSL version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 34810 "configure"
+#line 34425 "configure"
 #include "confdefs.h"
 
 #include <openssl/opensslv.h>
@@ -34961,7 +34576,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for CRYPTO_free in -lcrypto""... $ac_c" 1>&6
-echo "configure:34965: checking for CRYPTO_free in -lcrypto" >&5
+echo "configure:34580: 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
@@ -34969,7 +34584,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 34973 "configure"
+#line 34588 "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
@@ -34980,7 +34595,7 @@ int main() {
 CRYPTO_free()
 ; return 0; }
 EOF
-if { (eval echo configure:34984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:34599: \"$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
@@ -35137,7 +34752,7 @@ fi
   done
 
   echo $ac_n "checking for SSL_CTX_set_ssl_version in -lssl""... $ac_c" 1>&6
-echo "configure:35141: checking for SSL_CTX_set_ssl_version in -lssl" >&5
+echo "configure:34756: 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
@@ -35145,7 +34760,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 35149 "configure"
+#line 34764 "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
@@ -35156,7 +34771,7 @@ int main() {
 SSL_CTX_set_ssl_version()
 ; return 0; }
 EOF
-if { (eval echo configure:35160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:34775: \"$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
@@ -35275,7 +34890,7 @@ fi
 php_with_gd=no
 
 echo $ac_n "checking for GD support""... $ac_c" 1>&6
-echo "configure:35279: checking for GD support" >&5
+echo "configure:34894: checking for GD support" >&5
 # Check whether --with-gd or --without-gd was given.
 if test "${with_gd+set}" = set; then
   withval="$with_gd"
@@ -35323,7 +34938,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:35327: checking for the location of libjpeg" >&5
+echo "configure:34942: 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"
@@ -35351,7 +34966,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:35355: checking for the location of libpng" >&5
+echo "configure:34970: 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"
@@ -35379,7 +34994,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:35383: checking for the location of libz" >&5
+echo "configure:34998: 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"
@@ -35406,7 +35021,7 @@ fi
 php_with_xpm_dir=no
 
 echo $ac_n "checking for the location of libXpm""... $ac_c" 1>&6
-echo "configure:35410: checking for the location of libXpm" >&5
+echo "configure:35025: 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"
@@ -35432,7 +35047,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:35436: checking for FreeType 2" >&5
+echo "configure:35051: 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"
@@ -35458,7 +35073,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:35462: checking for T1lib support" >&5
+echo "configure:35077: checking for T1lib support" >&5
 # Check whether --with-t1lib or --without-t1lib was given.
 if test "${with_t1lib+set}" = set; then
   withval="$with_t1lib"
@@ -35484,7 +35099,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:35488: checking whether to enable truetype string function in GD" >&5
+echo "configure:35103: 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"
@@ -35510,7 +35125,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:35514: checking whether to enable JIS-mapped Japanese font support in GD" >&5
+echo "configure:35129: 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"
@@ -35565,12 +35180,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:35569: checking for $ac_func" >&5
+echo "configure:35184: 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 35574 "configure"
+#line 35189 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -35593,7 +35208,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:35597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:35212: \"$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
@@ -35765,7 +35380,7 @@ EOF
   done
 
   echo $ac_n "checking for jpeg_read_header in -ljpeg""... $ac_c" 1>&6
-echo "configure:35769: checking for jpeg_read_header in -ljpeg" >&5
+echo "configure:35384: 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
@@ -35773,7 +35388,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ljpeg  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 35777 "configure"
+#line 35392 "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
@@ -35784,7 +35399,7 @@ int main() {
 jpeg_read_header()
 ; return 0; }
 EOF
-if { (eval echo configure:35788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:35403: \"$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
@@ -36066,7 +35681,7 @@ fi
   done
 
   echo $ac_n "checking for png_write_image in -lpng""... $ac_c" 1>&6
-echo "configure:36070: checking for png_write_image in -lpng" >&5
+echo "configure:35685: 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
@@ -36074,7 +35689,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpng  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 36078 "configure"
+#line 35693 "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
@@ -36085,7 +35700,7 @@ int main() {
 png_write_image()
 ; return 0; }
 EOF
-if { (eval echo configure:36089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:35704: \"$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
@@ -36465,7 +36080,7 @@ fi
   done
 
   echo $ac_n "checking for XpmFreeXpmImage in -lXpm""... $ac_c" 1>&6
-echo "configure:36469: checking for XpmFreeXpmImage in -lXpm" >&5
+echo "configure:36084: 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
@@ -36473,7 +36088,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXpm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 36477 "configure"
+#line 36092 "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
@@ -36484,7 +36099,7 @@ int main() {
 XpmFreeXpmImage()
 ; return 0; }
 EOF
-if { (eval echo configure:36488: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:36103: \"$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
@@ -36859,7 +36474,7 @@ fi
   done
 
   echo $ac_n "checking for FT_New_Face in -lfreetype""... $ac_c" 1>&6
-echo "configure:36863: checking for FT_New_Face in -lfreetype" >&5
+echo "configure:36478: 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
@@ -36867,7 +36482,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lfreetype  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 36871 "configure"
+#line 36486 "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
@@ -36878,7 +36493,7 @@ int main() {
 FT_New_Face()
 ; return 0; }
 EOF
-if { (eval echo configure:36882: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:36497: \"$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
@@ -37195,7 +36810,7 @@ fi
   done
 
   echo $ac_n "checking for T1_StrError in -lt1""... $ac_c" 1>&6
-echo "configure:37199: checking for T1_StrError in -lt1" >&5
+echo "configure:36814: 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
@@ -37203,7 +36818,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lt1  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 37207 "configure"
+#line 36822 "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
@@ -37214,7 +36829,7 @@ int main() {
 T1_StrError()
 ; return 0; }
 EOF
-if { (eval echo configure:37218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:36833: \"$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
@@ -37657,7 +37272,7 @@ EOF
   done
 
   echo $ac_n "checking for jpeg_read_header in -ljpeg""... $ac_c" 1>&6
-echo "configure:37661: checking for jpeg_read_header in -ljpeg" >&5
+echo "configure:37276: 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
@@ -37665,7 +37280,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ljpeg  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 37669 "configure"
+#line 37284 "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
@@ -37676,7 +37291,7 @@ int main() {
 jpeg_read_header()
 ; return 0; }
 EOF
-if { (eval echo configure:37680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:37295: \"$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
@@ -37958,7 +37573,7 @@ fi
   done
 
   echo $ac_n "checking for png_write_image in -lpng""... $ac_c" 1>&6
-echo "configure:37962: checking for png_write_image in -lpng" >&5
+echo "configure:37577: 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
@@ -37966,7 +37581,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpng  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 37970 "configure"
+#line 37585 "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
@@ -37977,7 +37592,7 @@ int main() {
 png_write_image()
 ; return 0; }
 EOF
-if { (eval echo configure:37981: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:37596: \"$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
@@ -38357,7 +37972,7 @@ fi
   done
 
   echo $ac_n "checking for XpmFreeXpmImage in -lXpm""... $ac_c" 1>&6
-echo "configure:38361: checking for XpmFreeXpmImage in -lXpm" >&5
+echo "configure:37976: 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
@@ -38365,7 +37980,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXpm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 38369 "configure"
+#line 37984 "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
@@ -38376,7 +37991,7 @@ int main() {
 XpmFreeXpmImage()
 ; return 0; }
 EOF
-if { (eval echo configure:38380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:37995: \"$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
@@ -38751,7 +38366,7 @@ fi
   done
 
   echo $ac_n "checking for FT_New_Face in -lfreetype""... $ac_c" 1>&6
-echo "configure:38755: checking for FT_New_Face in -lfreetype" >&5
+echo "configure:38370: 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
@@ -38759,7 +38374,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lfreetype  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 38763 "configure"
+#line 38378 "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
@@ -38770,7 +38385,7 @@ int main() {
 FT_New_Face()
 ; return 0; }
 EOF
-if { (eval echo configure:38774: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:38389: \"$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
@@ -39087,7 +38702,7 @@ fi
   done
 
   echo $ac_n "checking for T1_StrError in -lt1""... $ac_c" 1>&6
-echo "configure:39091: checking for T1_StrError in -lt1" >&5
+echo "configure:38706: 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
@@ -39095,7 +38710,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lt1  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 39099 "configure"
+#line 38714 "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
@@ -39106,7 +38721,7 @@ int main() {
 T1_StrError()
 ; return 0; }
 EOF
-if { (eval echo configure:39110: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:38725: \"$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
@@ -39481,7 +39096,7 @@ EOF
   done
 
   echo $ac_n "checking for gdImageString16 in -lgd""... $ac_c" 1>&6
-echo "configure:39485: checking for gdImageString16 in -lgd" >&5
+echo "configure:39100: 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
@@ -39489,7 +39104,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 39493 "configure"
+#line 39108 "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
@@ -39500,7 +39115,7 @@ int main() {
 gdImageString16()
 ; return 0; }
 EOF
-if { (eval echo configure:39504: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:39119: \"$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
@@ -39629,7 +39244,7 @@ fi
   done
 
   echo $ac_n "checking for gdImagePaletteCopy in -lgd""... $ac_c" 1>&6
-echo "configure:39633: checking for gdImagePaletteCopy in -lgd" >&5
+echo "configure:39248: 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
@@ -39637,7 +39252,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 39641 "configure"
+#line 39256 "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
@@ -39648,7 +39263,7 @@ int main() {
 gdImagePaletteCopy()
 ; return 0; }
 EOF
-if { (eval echo configure:39652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:39267: \"$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
@@ -39777,7 +39392,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateFromPng in -lgd""... $ac_c" 1>&6
-echo "configure:39781: checking for gdImageCreateFromPng in -lgd" >&5
+echo "configure:39396: 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
@@ -39785,7 +39400,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 39789 "configure"
+#line 39404 "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
@@ -39796,7 +39411,7 @@ int main() {
 gdImageCreateFromPng()
 ; return 0; }
 EOF
-if { (eval echo configure:39800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:39415: \"$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
@@ -39925,7 +39540,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateFromGif in -lgd""... $ac_c" 1>&6
-echo "configure:39929: checking for gdImageCreateFromGif in -lgd" >&5
+echo "configure:39544: 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
@@ -39933,7 +39548,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 39937 "configure"
+#line 39552 "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
@@ -39944,7 +39559,7 @@ int main() {
 gdImageCreateFromGif()
 ; return 0; }
 EOF
-if { (eval echo configure:39948: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:39563: \"$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
@@ -40073,7 +39688,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageGif in -lgd""... $ac_c" 1>&6
-echo "configure:40077: checking for gdImageGif in -lgd" >&5
+echo "configure:39692: 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
@@ -40081,7 +39696,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40085 "configure"
+#line 39700 "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
@@ -40092,7 +39707,7 @@ int main() {
 gdImageGif()
 ; return 0; }
 EOF
-if { (eval echo configure:40096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:39711: \"$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
@@ -40221,7 +39836,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageWBMP in -lgd""... $ac_c" 1>&6
-echo "configure:40225: checking for gdImageWBMP in -lgd" >&5
+echo "configure:39840: 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
@@ -40229,7 +39844,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40233 "configure"
+#line 39848 "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
@@ -40240,7 +39855,7 @@ int main() {
 gdImageWBMP()
 ; return 0; }
 EOF
-if { (eval echo configure:40244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:39859: \"$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
@@ -40369,7 +39984,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateFromJpeg in -lgd""... $ac_c" 1>&6
-echo "configure:40373: checking for gdImageCreateFromJpeg in -lgd" >&5
+echo "configure:39988: 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
@@ -40377,7 +39992,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40381 "configure"
+#line 39996 "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
@@ -40388,7 +40003,7 @@ int main() {
 gdImageCreateFromJpeg()
 ; return 0; }
 EOF
-if { (eval echo configure:40392: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40007: \"$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
@@ -40517,7 +40132,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateFromXpm in -lgd""... $ac_c" 1>&6
-echo "configure:40521: checking for gdImageCreateFromXpm in -lgd" >&5
+echo "configure:40136: 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
@@ -40525,7 +40140,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40529 "configure"
+#line 40144 "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
@@ -40536,7 +40151,7 @@ int main() {
 gdImageCreateFromXpm()
 ; return 0; }
 EOF
-if { (eval echo configure:40540: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40155: \"$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
@@ -40665,7 +40280,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateFromGd2 in -lgd""... $ac_c" 1>&6
-echo "configure:40669: checking for gdImageCreateFromGd2 in -lgd" >&5
+echo "configure:40284: 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
@@ -40673,7 +40288,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40677 "configure"
+#line 40292 "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
@@ -40684,7 +40299,7 @@ int main() {
 gdImageCreateFromGd2()
 ; return 0; }
 EOF
-if { (eval echo configure:40688: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40303: \"$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
@@ -40813,7 +40428,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateTrueColor in -lgd""... $ac_c" 1>&6
-echo "configure:40817: checking for gdImageCreateTrueColor in -lgd" >&5
+echo "configure:40432: 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
@@ -40821,7 +40436,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40825 "configure"
+#line 40440 "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
@@ -40832,7 +40447,7 @@ int main() {
 gdImageCreateTrueColor()
 ; return 0; }
 EOF
-if { (eval echo configure:40836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40451: \"$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
@@ -40961,7 +40576,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageSetTile in -lgd""... $ac_c" 1>&6
-echo "configure:40965: checking for gdImageSetTile in -lgd" >&5
+echo "configure:40580: 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
@@ -40969,7 +40584,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40973 "configure"
+#line 40588 "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
@@ -40980,7 +40595,7 @@ int main() {
 gdImageSetTile()
 ; return 0; }
 EOF
-if { (eval echo configure:40984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40599: \"$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
@@ -41109,7 +40724,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageEllipse in -lgd""... $ac_c" 1>&6
-echo "configure:41113: checking for gdImageEllipse in -lgd" >&5
+echo "configure:40728: 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
@@ -41117,7 +40732,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41121 "configure"
+#line 40736 "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
@@ -41128,7 +40743,7 @@ int main() {
 gdImageEllipse()
 ; return 0; }
 EOF
-if { (eval echo configure:41132: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40747: \"$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
@@ -41257,7 +40872,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageSetBrush in -lgd""... $ac_c" 1>&6
-echo "configure:41261: checking for gdImageSetBrush in -lgd" >&5
+echo "configure:40876: 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
@@ -41265,7 +40880,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41269 "configure"
+#line 40884 "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
@@ -41276,7 +40891,7 @@ int main() {
 gdImageSetBrush()
 ; return 0; }
 EOF
-if { (eval echo configure:41280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40895: \"$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
@@ -41405,7 +41020,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageStringTTF in -lgd""... $ac_c" 1>&6
-echo "configure:41409: checking for gdImageStringTTF in -lgd" >&5
+echo "configure:41024: 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
@@ -41413,7 +41028,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41417 "configure"
+#line 41032 "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
@@ -41424,7 +41039,7 @@ int main() {
 gdImageStringTTF()
 ; return 0; }
 EOF
-if { (eval echo configure:41428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41043: \"$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
@@ -41553,7 +41168,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageStringFT in -lgd""... $ac_c" 1>&6
-echo "configure:41557: checking for gdImageStringFT in -lgd" >&5
+echo "configure:41172: 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
@@ -41561,7 +41176,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41565 "configure"
+#line 41180 "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
@@ -41572,7 +41187,7 @@ int main() {
 gdImageStringFT()
 ; return 0; }
 EOF
-if { (eval echo configure:41576: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41191: \"$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
@@ -41701,7 +41316,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageStringFTEx in -lgd""... $ac_c" 1>&6
-echo "configure:41705: checking for gdImageStringFTEx in -lgd" >&5
+echo "configure:41320: 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
@@ -41709,7 +41324,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41713 "configure"
+#line 41328 "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
@@ -41720,7 +41335,7 @@ int main() {
 gdImageStringFTEx()
 ; return 0; }
 EOF
-if { (eval echo configure:41724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41339: \"$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
@@ -41849,7 +41464,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageColorClosestHWB in -lgd""... $ac_c" 1>&6
-echo "configure:41853: checking for gdImageColorClosestHWB in -lgd" >&5
+echo "configure:41468: 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
@@ -41857,7 +41472,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41861 "configure"
+#line 41476 "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
@@ -41868,7 +41483,7 @@ int main() {
 gdImageColorClosestHWB()
 ; return 0; }
 EOF
-if { (eval echo configure:41872: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41487: \"$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
@@ -41997,7 +41612,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageColorResolve in -lgd""... $ac_c" 1>&6
-echo "configure:42001: checking for gdImageColorResolve in -lgd" >&5
+echo "configure:41616: 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
@@ -42005,7 +41620,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42009 "configure"
+#line 41624 "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
@@ -42016,7 +41631,7 @@ int main() {
 gdImageColorResolve()
 ; return 0; }
 EOF
-if { (eval echo configure:42020: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41635: \"$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
@@ -42145,7 +41760,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageGifCtx in -lgd""... $ac_c" 1>&6
-echo "configure:42149: checking for gdImageGifCtx in -lgd" >&5
+echo "configure:41764: 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
@@ -42153,7 +41768,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42157 "configure"
+#line 41772 "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
@@ -42164,7 +41779,7 @@ int main() {
 gdImageGifCtx()
 ; return 0; }
 EOF
-if { (eval echo configure:42168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41783: \"$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
@@ -42293,7 +41908,7 @@ fi
   done
 
   echo $ac_n "checking for gdCacheCreate in -lgd""... $ac_c" 1>&6
-echo "configure:42297: checking for gdCacheCreate in -lgd" >&5
+echo "configure:41912: 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
@@ -42301,7 +41916,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42305 "configure"
+#line 41920 "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
@@ -42312,7 +41927,7 @@ int main() {
 gdCacheCreate()
 ; return 0; }
 EOF
-if { (eval echo configure:42316: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41931: \"$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
@@ -42441,7 +42056,7 @@ fi
   done
 
   echo $ac_n "checking for gdFontCacheShutdown in -lgd""... $ac_c" 1>&6
-echo "configure:42445: checking for gdFontCacheShutdown in -lgd" >&5
+echo "configure:42060: 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
@@ -42449,7 +42064,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42453 "configure"
+#line 42068 "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
@@ -42460,7 +42075,7 @@ int main() {
 gdFontCacheShutdown()
 ; return 0; }
 EOF
-if { (eval echo configure:42464: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:42079: \"$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
@@ -42589,7 +42204,7 @@ fi
   done
 
   echo $ac_n "checking for gdFreeFontCache in -lgd""... $ac_c" 1>&6
-echo "configure:42593: checking for gdFreeFontCache in -lgd" >&5
+echo "configure:42208: 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
@@ -42597,7 +42212,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42601 "configure"
+#line 42216 "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
@@ -42608,7 +42223,7 @@ int main() {
 gdFreeFontCache()
 ; return 0; }
 EOF
-if { (eval echo configure:42612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:42227: \"$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
@@ -42737,7 +42352,7 @@ fi
   done
 
   echo $ac_n "checking for gdFontCacheMutexSetup in -lgd""... $ac_c" 1>&6
-echo "configure:42741: checking for gdFontCacheMutexSetup in -lgd" >&5
+echo "configure:42356: 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
@@ -42745,7 +42360,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42749 "configure"
+#line 42364 "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
@@ -42756,7 +42371,7 @@ int main() {
 gdFontCacheMutexSetup()
 ; return 0; }
 EOF
-if { (eval echo configure:42760: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:42375: \"$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
@@ -42885,7 +42500,7 @@ fi
   done
 
   echo $ac_n "checking for gdNewDynamicCtxEx in -lgd""... $ac_c" 1>&6
-echo "configure:42889: checking for gdNewDynamicCtxEx in -lgd" >&5
+echo "configure:42504: 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
@@ -42893,7 +42508,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42897 "configure"
+#line 42512 "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
@@ -42904,7 +42519,7 @@ int main() {
 gdNewDynamicCtxEx()
 ; return 0; }
 EOF
-if { (eval echo configure:42908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:42523: \"$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
@@ -42959,7 +42574,7 @@ fi
         old_CPPFLAGS=$CPPFLAGS
   CPPFLAGS=-I$GD_INCLUDE
   cat > conftest.$ac_ext <<EOF
-#line 42963 "configure"
+#line 42578 "configure"
 #include "confdefs.h"
 
 #include <gd.h>
@@ -42973,7 +42588,7 @@ ctx->gd_free = 1;
   
 ; return 0; }
 EOF
-if { (eval echo configure:42977: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:42592: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     cat >> confdefs.h <<\EOF
@@ -43304,7 +42919,7 @@ EOF
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 43308 "configure"
+#line 42923 "configure"
 #include "confdefs.h"
 
     char foobar () {}
@@ -43315,7 +42930,7 @@ else
     }
   
 EOF
-if { (eval echo configure:43319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:42934: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -43466,7 +43081,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreate in -lgd""... $ac_c" 1>&6
-echo "configure:43470: checking for gdImageCreate in -lgd" >&5
+echo "configure:43085: 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
@@ -43474,7 +43089,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 43478 "configure"
+#line 43093 "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
@@ -43485,7 +43100,7 @@ int main() {
 gdImageCreate()
 ; return 0; }
 EOF
-if { (eval echo configure:43489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43104: \"$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
@@ -43550,7 +43165,7 @@ fi
 php_with_gettext=no
 
 echo $ac_n "checking for GNU gettext support""... $ac_c" 1>&6
-echo "configure:43554: checking for GNU gettext support" >&5
+echo "configure:43169: 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"
@@ -43608,7 +43223,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:43612: checking for bindtextdomain in -lintl" >&5
+echo "configure:43227: 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
@@ -43616,7 +43231,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lintl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 43620 "configure"
+#line 43235 "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
@@ -43627,7 +43242,7 @@ int main() {
 bindtextdomain()
 ; return 0; }
 EOF
-if { (eval echo configure:43631: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43246: \"$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
@@ -43649,7 +43264,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:43653: checking for bindtextdomain in -lc" >&5
+echo "configure:43268: 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
@@ -43657,7 +43272,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 43661 "configure"
+#line 43276 "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
@@ -43668,7 +43283,7 @@ int main() {
 bindtextdomain()
 ; return 0; }
 EOF
-if { (eval echo configure:43672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43287: \"$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
@@ -44132,7 +43747,7 @@ EOF
 
 
   echo $ac_n "checking for ngettext in -l$GETTEXT_CHECK_IN_LIB""... $ac_c" 1>&6
-echo "configure:44136: checking for ngettext in -l$GETTEXT_CHECK_IN_LIB" >&5
+echo "configure:43751: 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
@@ -44140,7 +43755,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$GETTEXT_CHECK_IN_LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 44144 "configure"
+#line 43759 "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
@@ -44151,7 +43766,7 @@ int main() {
 ngettext()
 ; return 0; }
 EOF
-if { (eval echo configure:44155: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43770: \"$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
@@ -44175,7 +43790,7 @@ else
 fi
 
   echo $ac_n "checking for dngettext in -l$GETTEXT_CHECK_IN_LIB""... $ac_c" 1>&6
-echo "configure:44179: checking for dngettext in -l$GETTEXT_CHECK_IN_LIB" >&5
+echo "configure:43794: 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
@@ -44183,7 +43798,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$GETTEXT_CHECK_IN_LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 44187 "configure"
+#line 43802 "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
@@ -44194,7 +43809,7 @@ int main() {
 dngettext()
 ; return 0; }
 EOF
-if { (eval echo configure:44198: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43813: \"$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
@@ -44218,7 +43833,7 @@ else
 fi
 
   echo $ac_n "checking for dcngettext in -l$GETTEXT_CHECK_IN_LIB""... $ac_c" 1>&6
-echo "configure:44222: checking for dcngettext in -l$GETTEXT_CHECK_IN_LIB" >&5
+echo "configure:43837: 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
@@ -44226,7 +43841,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$GETTEXT_CHECK_IN_LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 44230 "configure"
+#line 43845 "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
@@ -44237,7 +43852,7 @@ int main() {
 dcngettext()
 ; return 0; }
 EOF
-if { (eval echo configure:44241: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43856: \"$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
@@ -44261,7 +43876,7 @@ else
 fi
 
   echo $ac_n "checking for bind_textdomain_codeset in -l$GETTEXT_CHECK_IN_LIB""... $ac_c" 1>&6
-echo "configure:44265: checking for bind_textdomain_codeset in -l$GETTEXT_CHECK_IN_LIB" >&5
+echo "configure:43880: 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
@@ -44269,7 +43884,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$GETTEXT_CHECK_IN_LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 44273 "configure"
+#line 43888 "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
@@ -44280,7 +43895,7 @@ int main() {
 bind_textdomain_codeset()
 ; return 0; }
 EOF
-if { (eval echo configure:44284: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43899: \"$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
@@ -44311,7 +43926,7 @@ fi
 php_with_gmp=no
 
 echo $ac_n "checking for GNU MP support""... $ac_c" 1>&6
-echo "configure:44315: checking for GNU MP support" >&5
+echo "configure:43930: 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"
@@ -44462,7 +44077,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:44466: checking for __gmp_randinit_lc_2exp_size in -lgmp" >&5
+echo "configure:44081: 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
@@ -44470,7 +44085,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgmp  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 44474 "configure"
+#line 44089 "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
@@ -44481,7 +44096,7 @@ int main() {
 __gmp_randinit_lc_2exp_size()
 ; return 0; }
 EOF
-if { (eval echo configure:44485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:44100: \"$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
@@ -44606,7 +44221,7 @@ else
   done
 
   echo $ac_n "checking for gmp_randinit_lc_2exp_size in -lgmp""... $ac_c" 1>&6
-echo "configure:44610: checking for gmp_randinit_lc_2exp_size in -lgmp" >&5
+echo "configure:44225: 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
@@ -44614,7 +44229,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgmp  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 44618 "configure"
+#line 44233 "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
@@ -44625,7 +44240,7 @@ int main() {
 gmp_randinit_lc_2exp_size()
 ; return 0; }
 EOF
-if { (eval echo configure:44629: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:44244: \"$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
@@ -45097,7 +44712,7 @@ fi
 php_with_mhash=no
 
 echo $ac_n "checking for mhash support""... $ac_c" 1>&6
-echo "configure:45101: checking for mhash support" >&5
+echo "configure:44716: checking for mhash support" >&5
 # Check whether --with-mhash or --without-mhash was given.
 if test "${with_mhash+set}" = set; then
   withval="$with_mhash"
@@ -45144,7 +44759,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:45148: checking whether to enable hash support" >&5
+echo "configure:44763: 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"
@@ -45205,7 +44820,7 @@ EOF
 
 
   echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:45209: checking whether byte ordering is bigendian" >&5
+echo "configure:44824: 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
@@ -45215,7 +44830,7 @@ else
   ac_cv_c_bigendian_php=unknown
 else
   cat > conftest.$ac_ext <<EOF
-#line 45219 "configure"
+#line 44834 "configure"
 #include "confdefs.h"
 
 int main(void)
@@ -45231,7 +44846,7 @@ int main(void)
 }
   
 EOF
-if { (eval echo configure:45235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:44850: \"$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
@@ -45256,7 +44871,7 @@ EOF
 
 
   echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:45260: checking size of short" >&5
+echo "configure:44875: 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
@@ -45264,7 +44879,7 @@ else
   ac_cv_sizeof_short=2
 else
   cat > conftest.$ac_ext <<EOF
-#line 45268 "configure"
+#line 44883 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -45275,7 +44890,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:45279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:44894: \"$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
@@ -45295,7 +44910,7 @@ EOF
 
 
   echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:45299: checking size of int" >&5
+echo "configure:44914: 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
@@ -45303,7 +44918,7 @@ else
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 45307 "configure"
+#line 44922 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -45314,7 +44929,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:45318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:44933: \"$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
@@ -45334,7 +44949,7 @@ EOF
 
 
   echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:45338: checking size of long" >&5
+echo "configure:44953: 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
@@ -45342,7 +44957,7 @@ else
   ac_cv_sizeof_long=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 45346 "configure"
+#line 44961 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -45353,7 +44968,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:45357: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:44972: \"$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
@@ -45373,7 +44988,7 @@ EOF
 
 
   echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:45377: checking size of long long" >&5
+echo "configure:44992: 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
@@ -45381,7 +44996,7 @@ else
   ac_cv_sizeof_long_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 45385 "configure"
+#line 45000 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -45392,7 +45007,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:45396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:45011: \"$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
@@ -45741,7 +45356,7 @@ fi
 php_with_iconv=yes
 
 echo $ac_n "checking for iconv support""... $ac_c" 1>&6
-echo "configure:45745: checking for iconv support" >&5
+echo "configure:45360: checking for iconv support" >&5
 # Check whether --with-iconv or --without-iconv was given.
 if test "${with_iconv+set}" = set; then
   withval="$with_iconv"
@@ -45804,12 +45419,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:45808: checking for iconv" >&5
+echo "configure:45423: 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 45813 "configure"
+#line 45428 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char iconv(); below.  */
@@ -45832,7 +45447,7 @@ iconv();
 
 ; return 0; }
 EOF
-if { (eval echo configure:45836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:45451: \"$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
@@ -45853,12 +45468,12 @@ else
   echo "$ac_t""no" 1>&6
 
       echo $ac_n "checking for libiconv""... $ac_c" 1>&6
-echo "configure:45857: checking for libiconv" >&5
+echo "configure:45472: 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 45862 "configure"
+#line 45477 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char libiconv(); below.  */
@@ -45881,7 +45496,7 @@ libiconv();
 
 ; return 0; }
 EOF
-if { (eval echo configure:45885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:45500: \"$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
@@ -46037,7 +45652,7 @@ EOF
   done
 
   echo $ac_n "checking for libiconv in -l$iconv_lib_name""... $ac_c" 1>&6
-echo "configure:46041: checking for libiconv in -l$iconv_lib_name" >&5
+echo "configure:45656: 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
@@ -46045,7 +45660,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$iconv_lib_name  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 46049 "configure"
+#line 45664 "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
@@ -46056,7 +45671,7 @@ int main() {
 libiconv()
 ; return 0; }
 EOF
-if { (eval echo configure:46060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:45675: \"$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
@@ -46190,7 +45805,7 @@ else
   done
 
   echo $ac_n "checking for iconv in -l$iconv_lib_name""... $ac_c" 1>&6
-echo "configure:46194: checking for iconv in -l$iconv_lib_name" >&5
+echo "configure:45809: 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
@@ -46198,7 +45813,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$iconv_lib_name  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 46202 "configure"
+#line 45817 "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
@@ -46209,7 +45824,7 @@ int main() {
 iconv()
 ; return 0; }
 EOF
-if { (eval echo configure:46213: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:45828: \"$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
@@ -46420,16 +46035,16 @@ else
     fi 
 
     echo $ac_n "checking if iconv is glibc's""... $ac_c" 1>&6
-echo "configure:46424: checking if iconv is glibc's" >&5
+echo "configure:46039: checking if iconv is glibc's" >&5
     cat > conftest.$ac_ext <<EOF
-#line 46426 "configure"
+#line 46041 "configure"
 #include "confdefs.h"
 #include <gnu/libc-version.h>
 int main() {
 gnu_get_libc_version();
 ; return 0; }
 EOF
-if { (eval echo configure:46433: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:46048: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
       echo "$ac_t""yes" 1>&6
@@ -46447,7 +46062,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:46451: checking if using GNU libiconv" >&5
+echo "configure:46066: checking if using GNU libiconv" >&5
       php_iconv_old_ld="$LDFLAGS"
       LDFLAGS="-liconv $LDFLAGS"
       if test "$cross_compiling" = yes; then
@@ -46457,7 +46072,7 @@ echo "configure:46451: checking if using GNU libiconv" >&5
       
 else
   cat > conftest.$ac_ext <<EOF
-#line 46461 "configure"
+#line 46076 "configure"
 #include "confdefs.h"
 
 #include <$PHP_ICONV_H_PATH>
@@ -46467,7 +46082,7 @@ int main() {
 }
       
 EOF
-if { (eval echo configure:46471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:46086: \"$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
@@ -46489,16 +46104,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:46493: checking if iconv is Konstantin Chuguev's" >&5
+echo "configure:46108: checking if iconv is Konstantin Chuguev's" >&5
       cat > conftest.$ac_ext <<EOF
-#line 46495 "configure"
+#line 46110 "configure"
 #include "confdefs.h"
 #include <iconv.h>
 int main() {
 iconv_ccs_init(NULL, NULL);
 ; return 0; }
 EOF
-if { (eval echo configure:46502: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:46117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
         echo "$ac_t""yes" 1>&6
@@ -46517,18 +46132,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:46521: checking if using IBM iconv" >&5
+echo "configure:46136: checking if using IBM iconv" >&5
       php_iconv_old_ld="$LDFLAGS"
       LDFLAGS="-liconv $LDFLAGS"
       cat > conftest.$ac_ext <<EOF
-#line 46525 "configure"
+#line 46140 "configure"
 #include "confdefs.h"
 #include <iconv.h>
 int main() {
 cstoccsid("");
 ; return 0; }
 EOF
-if { (eval echo configure:46532: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:46147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
         echo "$ac_t""yes" 1>&6
@@ -46714,7 +46329,7 @@ EOF
     esac
 
     echo $ac_n "checking if iconv supports errno""... $ac_c" 1>&6
-echo "configure:46718: checking if iconv supports errno" >&5
+echo "configure:46333: checking if iconv supports errno" >&5
     if test "$cross_compiling" = yes; then
   
       echo "$ac_t""no" 1>&6
@@ -46728,7 +46343,7 @@ EOF
     
 else
   cat > conftest.$ac_ext <<EOF
-#line 46732 "configure"
+#line 46347 "configure"
 #include "confdefs.h"
 
 #include <$PHP_ICONV_H_PATH>
@@ -46749,7 +46364,7 @@ int main() {
 }
     
 EOF
-if { (eval echo configure:46753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:46368: \"$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
@@ -46781,9 +46396,9 @@ fi
 
 
     echo $ac_n "checking if your cpp allows macro usage in include lines""... $ac_c" 1>&6
-echo "configure:46785: checking if your cpp allows macro usage in include lines" >&5
+echo "configure:46400: checking if your cpp allows macro usage in include lines" >&5
     cat > conftest.$ac_ext <<EOF
-#line 46787 "configure"
+#line 46402 "configure"
 #include "confdefs.h"
 
 #define FOO <$PHP_ICONV_H_PATH>
@@ -46793,7 +46408,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:46797: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:46412: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
       echo "$ac_t""yes" 1>&6
@@ -47149,7 +46764,7 @@ fi
 php_with_imap=no
 
 echo $ac_n "checking for IMAP support""... $ac_c" 1>&6
-echo "configure:47153: checking for IMAP support" >&5
+echo "configure:46768: checking for IMAP support" >&5
 # Check whether --with-imap or --without-imap was given.
 if test "${with_imap+set}" = set; then
   withval="$with_imap"
@@ -47196,7 +46811,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:47200: checking for IMAP Kerberos support" >&5
+echo "configure:46815: 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"
@@ -47222,7 +46837,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:47226: checking for IMAP SSL support" >&5
+echo "configure:46841: 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"
@@ -47629,7 +47244,7 @@ EOF
     done
 
         cat > conftest.$ac_ext <<EOF
-#line 47633 "configure"
+#line 47248 "configure"
 #include "confdefs.h"
 #include <$IMAP_INC_DIR/mail.h>
 EOF
@@ -47649,12 +47264,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:47653: checking for utf8_mime2text signature" >&5
+echo "configure:47268: 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 47658 "configure"
+#line 47273 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -47667,7 +47282,7 @@ int main() {
       
 ; return 0; }
 EOF
-if { (eval echo configure:47671: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:47286: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
         ac_cv_utf8_mime2text=old
@@ -47695,13 +47310,13 @@ EOF
 
     old_CFLAGS=$CFLAGS
     CFLAGS="-I$IMAP_INC_DIR"
-    echo $ac_n "checking for U8T_CANONICAL""... $ac_c" 1>&6
-echo "configure:47700: checking for U8T_CANONICAL" >&5
+    echo $ac_n "checking for U8T_DECOMPOSE""... $ac_c" 1>&6
+echo "configure:47315: 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 47705 "configure"
+#line 47320 "configure"
 #include "confdefs.h"
 
 #include <c-client.h>
@@ -47712,17 +47327,17 @@ int main() {
       
 ; return 0; }
 EOF
-if { (eval echo configure:47716: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:47331: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
-         ac_cv_u8t_canonical=yes
+         ac_cv_u8t_decompose=yes
       
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   
-         ac_cv_u8t_canonical=no
+         ac_cv_u8t_decompose=no
       
 fi
 rm -f conftest*
@@ -47732,17 +47347,17 @@ fi
 echo "$ac_t""$ac_cv_u8t_canonical" 1>&6
     CFLAGS=$old_CFLAGS
 
-    if test "$ac_cv_u8t_canonical" = "no" && test "$ac_cv_utf8_mime2text" = "new"; then
+    if test "$ac_cv_u8t_decompose" = "no" && test "$ac_cv_utf8_mime2text" = "new"; then
 		{ echo "configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information." 1>&2; exit 1; }
     fi
-    if test "$ac_cv_u8t_canonical" = "yes" && test "$ac_cv_utf8_mime2text" = "old"; then
+    if test "$ac_cv_u8t_decompose" = "yes" && test "$ac_cv_utf8_mime2text" = "old"; then
 		{ echo "configure: error: utf8_mime2text() has old signature, but U8T_CANONICAL is present. This should not happen. Check config.log for additional information." 1>&2; exit 1; }
     fi
 
         old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=-I$IMAP_INC_DIR
     cat > conftest.$ac_ext <<EOF
-#line 47746 "configure"
+#line 47361 "configure"
 #include "confdefs.h"
 
 #include "imap4r1.h"
@@ -47861,7 +47476,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for pam_start in -lpam""... $ac_c" 1>&6
-echo "configure:47865: checking for pam_start in -lpam" >&5
+echo "configure:47480: 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
@@ -47869,7 +47484,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpam  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 47873 "configure"
+#line 47488 "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
@@ -47880,7 +47495,7 @@ int main() {
 pam_start()
 ; return 0; }
 EOF
-if { (eval echo configure:47884: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:47499: \"$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
@@ -48035,7 +47650,7 @@ fi
   done
 
   echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:48039: checking for crypt in -lcrypt" >&5
+echo "configure:47654: 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
@@ -48043,7 +47658,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 48047 "configure"
+#line 47662 "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
@@ -48054,7 +47669,7 @@ int main() {
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:48058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:47673: \"$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
@@ -48258,7 +47873,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:48262: checking for $ac_word" >&5
+echo "configure:47877: 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
@@ -48627,7 +48242,7 @@ else
 
   else
     cat > conftest.$ac_ext <<EOF
-#line 48631 "configure"
+#line 48246 "configure"
 #include "confdefs.h"
 #include <$IMAP_INC_DIR/linkage.h>
 EOF
@@ -48668,7 +48283,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:48672: checking for $ac_word" >&5
+echo "configure:48287: 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
@@ -48873,9 +48488,9 @@ fi
     old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=-I$OPENSSL_INCDIR
     echo $ac_n "checking for OpenSSL version""... $ac_c" 1>&6
-echo "configure:48877: checking for OpenSSL version" >&5
+echo "configure:48492: checking for OpenSSL version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 48879 "configure"
+#line 48494 "configure"
 #include "confdefs.h"
 
 #include <openssl/opensslv.h>
@@ -49030,7 +48645,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for CRYPTO_free in -lcrypto""... $ac_c" 1>&6
-echo "configure:49034: checking for CRYPTO_free in -lcrypto" >&5
+echo "configure:48649: 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
@@ -49038,7 +48653,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 49042 "configure"
+#line 48657 "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
@@ -49049,7 +48664,7 @@ int main() {
 CRYPTO_free()
 ; return 0; }
 EOF
-if { (eval echo configure:49053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:48668: \"$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
@@ -49206,7 +48821,7 @@ fi
   done
 
   echo $ac_n "checking for SSL_CTX_set_ssl_version in -lssl""... $ac_c" 1>&6
-echo "configure:49210: checking for SSL_CTX_set_ssl_version in -lssl" >&5
+echo "configure:48825: 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
@@ -49214,7 +48829,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 49218 "configure"
+#line 48833 "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
@@ -49225,7 +48840,7 @@ int main() {
 SSL_CTX_set_ssl_version()
 ; return 0; }
 EOF
-if { (eval echo configure:49229: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:48844: \"$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
@@ -49344,7 +48959,7 @@ else
 
   elif test -f "$IMAP_INC_DIR/linkage.c"; then
     cat > conftest.$ac_ext <<EOF
-#line 49348 "configure"
+#line 48963 "configure"
 #include "confdefs.h"
 #include <$IMAP_INC_DIR/linkage.c>
 EOF
@@ -49375,7 +48990,7 @@ rm -f conftest*
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 49379 "configure"
+#line 48994 "configure"
 #include "confdefs.h"
 
     
@@ -49408,7 +49023,7 @@ else
     }
   
 EOF
-if { (eval echo configure:49412: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:49027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -49444,7 +49059,7 @@ fi
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 49448 "configure"
+#line 49063 "configure"
 #include "confdefs.h"
 
     
@@ -49477,7 +49092,7 @@ else
     }
   
 EOF
-if { (eval echo configure:49481: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:49096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -49504,7 +49119,7 @@ fi
 
 
     echo $ac_n "checking whether rfc822_output_address_list function present""... $ac_c" 1>&6
-echo "configure:49508: checking whether rfc822_output_address_list function present" >&5
+echo "configure:49123: checking whether rfc822_output_address_list function present" >&5
     
   old_LIBS=$LIBS
   LIBS="
@@ -49516,7 +49131,7 @@ echo "configure:49508: checking whether rfc822_output_address_list function pres
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 49520 "configure"
+#line 49135 "configure"
 #include "confdefs.h"
 
     
@@ -49552,7 +49167,7 @@ else
     }
   
 EOF
-if { (eval echo configure:49556: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:49171: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -49581,7 +49196,7 @@ fi
 
 
     echo $ac_n "checking whether build with IMAP works""... $ac_c" 1>&6
-echo "configure:49585: checking whether build with IMAP works" >&5
+echo "configure:49200: checking whether build with IMAP works" >&5
     
   
   old_LIBS=$LIBS
@@ -49592,7 +49207,7 @@ echo "configure:49585: checking whether build with IMAP works" >&5
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 49596 "configure"
+#line 49211 "configure"
 #include "confdefs.h"
 
     
@@ -49625,7 +49240,7 @@ else
     }
   
 EOF
-if { (eval echo configure:49629: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:49244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -49657,7 +49272,7 @@ fi
 php_with_interbase=no
 
 echo $ac_n "checking for InterBase support""... $ac_c" 1>&6
-echo "configure:49661: checking for InterBase support" >&5
+echo "configure:49276: checking for InterBase support" >&5
 # Check whether --with-interbase or --without-interbase was given.
 if test "${with_interbase+set}" = set; then
   withval="$with_interbase"
@@ -49807,7 +49422,7 @@ if test "$PHP_INTERBASE" != "no"; then
   done
 
   echo $ac_n "checking for isc_detach_database in -lfbclient""... $ac_c" 1>&6
-echo "configure:49811: checking for isc_detach_database in -lfbclient" >&5
+echo "configure:49426: 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
@@ -49815,7 +49430,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lfbclient  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 49819 "configure"
+#line 49434 "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
@@ -49826,7 +49441,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:49830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:49445: \"$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
@@ -49953,7 +49568,7 @@ else
   done
 
   echo $ac_n "checking for isc_detach_database in -lgds""... $ac_c" 1>&6
-echo "configure:49957: checking for isc_detach_database in -lgds" >&5
+echo "configure:49572: 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
@@ -49961,7 +49576,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgds  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 49965 "configure"
+#line 49580 "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
@@ -49972,7 +49587,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:49976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:49591: \"$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
@@ -50099,7 +49714,7 @@ else
   done
 
   echo $ac_n "checking for isc_detach_database in -lib_util""... $ac_c" 1>&6
-echo "configure:50103: checking for isc_detach_database in -lib_util" >&5
+echo "configure:49718: 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
@@ -50107,7 +49722,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lib_util  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 50111 "configure"
+#line 49726 "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
@@ -50118,7 +49733,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:50122: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:49737: \"$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
@@ -50595,7 +50210,7 @@ fi
 php_enable_intl=no
 
 echo $ac_n "checking whether to enable internationalization support""... $ac_c" 1>&6
-echo "configure:50599: checking whether to enable internationalization support" >&5
+echo "configure:50214: 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"
@@ -50673,7 +50288,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:50677: checking for $ac_word" >&5
+echo "configure:50292: 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
@@ -50711,7 +50326,7 @@ fi
   fi
 
   echo $ac_n "checking for location of ICU headers and libraries""... $ac_c" 1>&6
-echo "configure:50715: checking for location of ICU headers and libraries" >&5
+echo "configure:50330: 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
@@ -50721,7 +50336,7 @@ echo "configure:50715: 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:50725: checking for ICU 3.4 or greater" >&5
+echo "configure:50340: checking for ICU 3.4 or greater" >&5
     icu_version_full=`$ICU_CONFIG --version`
     ac_IFS=$IFS
     IFS="."
@@ -50877,7 +50492,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:50881: checking for $ac_word" >&5
+echo "configure:50496: 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
@@ -50909,7 +50524,7 @@ test -n "$CXX" || CXX="gcc"
 
 
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:50913: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:50528: 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.
@@ -50920,12 +50535,12 @@ cross_compiling=$ac_cv_prog_cxx_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 50924 "configure"
+#line 50539 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:50929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:50544: \"$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
@@ -50951,12 +50566,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:50955: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:50570: 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:50960: checking whether we are using GNU C++" >&5
+echo "configure:50575: 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
@@ -50965,7 +50580,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:50969: \"$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:50584: \"$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
@@ -50984,7 +50599,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:50988: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:50603: 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
@@ -51025,7 +50640,7 @@ for ac_declaration in \
    'void exit (int);'
 do
   cat > conftest.$ac_ext <<EOF
-#line 51029 "configure"
+#line 50644 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 $ac_declaration
@@ -51033,7 +50648,7 @@ int main() {
 exit (42);
 ; return 0; }
 EOF
-if { (eval echo configure:51037: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:50652: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -51043,14 +50658,14 @@ else
 fi
 rm -f conftest*
   cat > conftest.$ac_ext <<EOF
-#line 51047 "configure"
+#line 50662 "configure"
 #include "confdefs.h"
 $ac_declaration
 int main() {
 exit (42);
 ; return 0; }
 EOF
-if { (eval echo configure:51054: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:50669: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   break
 else
@@ -51067,7 +50682,7 @@ fi
 
 
     echo $ac_n "checking how to run the C++ preprocessor""... $ac_c" 1>&6
-echo "configure:51071: checking how to run the C++ preprocessor" >&5
+echo "configure:50686: 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
@@ -51080,12 +50695,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 51084 "configure"
+#line 50699 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:51089: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:50704: \"$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
   :
@@ -51183,6 +50798,9 @@ echo "$ac_t""$CXXCPP" 1>&6
     msgformat/msgformat_parse.c \
     grapheme/grapheme_string.c \
     grapheme/grapheme_util.c \
+    resourcebundle/resourcebundle.c \
+    resourcebundle/resourcebundle_class.c \
+    resourcebundle/resourcebundle_iterator.c \
     idn/idn.c; do
   
       IFS=.
@@ -51274,6 +50892,9 @@ EOF
     msgformat/msgformat_parse.c \
     grapheme/grapheme_string.c \
     grapheme/grapheme_util.c \
+    resourcebundle/resourcebundle.c \
+    resourcebundle/resourcebundle_class.c \
+    resourcebundle/resourcebundle_iterator.c \
     idn/idn.c; do
   
       IFS=.
@@ -51445,6 +51066,9 @@ EOF
     msgformat/msgformat_parse.c \
     grapheme/grapheme_string.c \
     grapheme/grapheme_util.c \
+    resourcebundle/resourcebundle.c \
+    resourcebundle/resourcebundle_class.c \
+    resourcebundle/resourcebundle_iterator.c \
     idn/idn.c; do
   
       IFS=.
@@ -51533,6 +51157,9 @@ EOF
     msgformat/msgformat_parse.c \
     grapheme/grapheme_string.c \
     grapheme/grapheme_util.c \
+    resourcebundle/resourcebundle.c \
+    resourcebundle/resourcebundle_class.c \
+    resourcebundle/resourcebundle_iterator.c \
     idn/idn.c; do
   
       IFS=.
@@ -51616,6 +51243,11 @@ EOF
 
   
   
+    BUILD_DIR="$BUILD_DIR $ext_builddir/resourcebundle"
+  
+
+  
+  
     BUILD_DIR="$BUILD_DIR $ext_builddir/idn"
   
 
@@ -51626,7 +51258,7 @@ fi
 php_enable_json=yes
 
 echo $ac_n "checking whether to enable JavaScript Object Serialization support""... $ac_c" 1>&6
-echo "configure:51630: checking whether to enable JavaScript Object Serialization support" >&5
+echo "configure:51262: 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"
@@ -51675,12 +51307,12 @@ if test "$PHP_JSON" != "no"; then
 EOF
 
   echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:51679: checking for ANSI C header files" >&5
+echo "configure:51311: 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 51684 "configure"
+#line 51316 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -51688,7 +51320,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:51692: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:51324: \"$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*
@@ -51705,7 +51337,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 51709 "configure"
+#line 51341 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -51723,7 +51355,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 51727 "configure"
+#line 51359 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -51744,7 +51376,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 51748 "configure"
+#line 51380 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -51755,7 +51387,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:51759: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:51391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -52105,7 +51737,7 @@ fi
 php_with_ldap=no
 
 echo $ac_n "checking for LDAP support""... $ac_c" 1>&6
-echo "configure:52109: checking for LDAP support" >&5
+echo "configure:51741: checking for LDAP support" >&5
 # Check whether --with-ldap or --without-ldap was given.
 if test "${with_ldap+set}" = set; then
   withval="$with_ldap"
@@ -52152,7 +51784,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:52156: checking for LDAP Cyrus SASL support" >&5
+echo "configure:51788: 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"
@@ -54497,19 +54129,19 @@ EOF
   LIBS="$LIBS $LDAP_SHARED_LIBADD"
 
     echo $ac_n "checking for 3 arg ldap_set_rebind_proc""... $ac_c" 1>&6
-echo "configure:54501: checking for 3 arg ldap_set_rebind_proc" >&5
+echo "configure:54133: 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 54506 "configure"
+#line 54138 "configure"
 #include "confdefs.h"
 #include <ldap.h>
 int main() {
 ldap_set_rebind_proc(0,0,0)
 ; return 0; }
 EOF
-if { (eval echo configure:54513: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:54145: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_3arg_setrebindproc=yes
 else
@@ -54532,12 +54164,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:54536: checking for $ac_func" >&5
+echo "configure:54168: 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 54541 "configure"
+#line 54173 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -54560,7 +54192,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:54564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:54196: \"$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
@@ -54722,7 +54354,7 @@ EOF
   done
 
   echo $ac_n "checking for sasl_version in -lldap""... $ac_c" 1>&6
-echo "configure:54726: checking for sasl_version in -lldap" >&5
+echo "configure:54358: 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
@@ -54730,7 +54362,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lldap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 54734 "configure"
+#line 54366 "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
@@ -54741,7 +54373,7 @@ int main() {
 sasl_version()
 ; return 0; }
 EOF
-if { (eval echo configure:54745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:54377: \"$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
@@ -54910,12 +54542,12 @@ fi
   fi
 
         echo $ac_n "checking for ldap_bind_s""... $ac_c" 1>&6
-echo "configure:54914: checking for ldap_bind_s" >&5
+echo "configure:54546: 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 54919 "configure"
+#line 54551 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char ldap_bind_s(); below.  */
@@ -54938,7 +54570,7 @@ ldap_bind_s();
 
 ; return 0; }
 EOF
-if { (eval echo configure:54942: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:54574: \"$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
@@ -54991,7 +54623,7 @@ fi
 php_enable_mbstring=no
 
 echo $ac_n "checking whether to enable multibyte string support""... $ac_c" 1>&6
-echo "configure:54995: checking whether to enable multibyte string support" >&5
+echo "configure:54627: 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"
@@ -55038,7 +54670,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:55042: checking whether to enable multibyte regex support" >&5
+echo "configure:54674: 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"
@@ -55064,7 +54696,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:55068: checking whether to check multibyte regex backtrack" >&5
+echo "configure:54700: 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"
@@ -55090,7 +54722,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:55094: checking for external libmbfl" >&5
+echo "configure:54726: checking for external libmbfl" >&5
 # Check whether --with-libmbfl or --without-libmbfl was given.
 if test "${with_libmbfl+set}" = set; then
   withval="$with_libmbfl"
@@ -55116,7 +54748,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:55120: checking for external oniguruma" >&5
+echo "configure:54752: checking for external oniguruma" >&5
 # Check whether --with-onig or --without-onig was given.
 if test "${with_onig+set}" = set; then
   withval="$with_onig"
@@ -55160,8 +54792,8 @@ EOF
       fi
 
       echo $ac_n "checking for variable length prototypes and stdarg.h""... $ac_c" 1>&6
-echo "configure:55164: checking for variable length prototypes and stdarg.h" >&5
-if eval "test \"`echo '$''{'cv_php_mbstring_stdarg'+set}'`\" = set"; then
+echo "configure:54796: 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
   
@@ -55169,16 +54801,16 @@ else
   
                     case $host_alias in
           *netware*)
-          cv_php_mbstring_stdarg=yes
+          php_cv_mbstring_stdarg=yes
           ;;
           *)
-          cv_php_mbstring_stdarg=no
+          php_cv_mbstring_stdarg=no
           ;;
           esac
         
 else
   cat > conftest.$ac_ext <<EOF
-#line 55182 "configure"
+#line 54814 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -55193,14 +54825,14 @@ int foo(int x, ...) {
 int main() { return foo(10, "", 3.14); }
         
 EOF
-if { (eval echo configure:55197: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:54829: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
-  cv_php_mbstring_stdarg=yes
+  php_cv_mbstring_stdarg=yes
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -fr conftest*
-  cv_php_mbstring_stdarg=no
+  php_cv_mbstring_stdarg=no
 fi
 rm -fr conftest*
 fi
@@ -55208,23 +54840,23 @@ fi
       
 fi
 
-echo "$ac_t""$cv_php_mbstring_stdarg" 1>&6
+echo "$ac_t""$php_cv_mbstring_stdarg" 1>&6
 
       for ac_hdr in stdlib.h string.h strings.h unistd.h sys/time.h sys/times.h stdarg.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:55218: checking for $ac_hdr" >&5
+echo "configure:54850: 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 55223 "configure"
+#line 54855 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:55228: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:54860: \"$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*
@@ -55251,7 +54883,7 @@ fi
 done
 
       echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:55255: checking size of int" >&5
+echo "configure:54887: 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
@@ -55259,7 +54891,7 @@ else
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 55263 "configure"
+#line 54895 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -55270,7 +54902,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:55274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:54906: \"$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
@@ -55290,7 +54922,7 @@ EOF
 
 
       echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:55294: checking size of short" >&5
+echo "configure:54926: 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
@@ -55298,7 +54930,7 @@ else
   ac_cv_sizeof_short=2
 else
   cat > conftest.$ac_ext <<EOF
-#line 55302 "configure"
+#line 54934 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -55309,7 +54941,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:55313: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:54945: \"$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
@@ -55329,7 +54961,7 @@ EOF
 
 
       echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:55333: checking size of long" >&5
+echo "configure:54965: 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
@@ -55337,7 +54969,7 @@ else
   ac_cv_sizeof_long=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 55341 "configure"
+#line 54973 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -55348,7 +54980,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:55352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:54984: \"$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
@@ -55368,12 +55000,12 @@ EOF
 
 
       echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:55372: checking for working const" >&5
+echo "configure:55004: 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 55377 "configure"
+#line 55009 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -55422,7 +55054,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:55426: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:55058: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -55443,12 +55075,12 @@ EOF
 fi
 
       echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:55447: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:55079: 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 55452 "configure"
+#line 55084 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -55457,7 +55089,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:55461: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:55093: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -55480,19 +55112,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:55484: checking for working alloca.h" >&5
+echo "configure:55116: 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 55489 "configure"
+#line 55121 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:55496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:55128: \"$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
@@ -55513,12 +55145,12 @@ EOF
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:55517: checking for alloca" >&5
+echo "configure:55149: 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 55522 "configure"
+#line 55154 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -55546,7 +55178,7 @@ int main() {
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:55550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:55182: \"$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
@@ -55578,12 +55210,12 @@ EOF
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:55582: checking whether alloca needs Cray hooks" >&5
+echo "configure:55214: 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 55587 "configure"
+#line 55219 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -55608,12 +55240,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:55612: checking for $ac_func" >&5
+echo "configure:55244: 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 55617 "configure"
+#line 55249 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -55636,7 +55268,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:55640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:55272: \"$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
@@ -55663,7 +55295,7 @@ done
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:55667: checking stack direction for C alloca" >&5
+echo "configure:55299: 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
@@ -55671,7 +55303,7 @@ else
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 55675 "configure"
+#line 55307 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -55690,7 +55322,7 @@ main ()
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:55694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:55326: \"$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
@@ -55712,7 +55344,7 @@ EOF
 fi
 
       echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:55716: checking for 8-bit clean memcmp" >&5
+echo "configure:55348: 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
@@ -55720,7 +55352,7 @@ else
   ac_cv_func_memcmp_clean=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 55724 "configure"
+#line 55356 "configure"
 #include "confdefs.h"
 
 main()
@@ -55730,7 +55362,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:55734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:55366: \"$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
@@ -55749,17 +55381,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:55753: checking for stdarg.h" >&5
+echo "configure:55385: 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 55758 "configure"
+#line 55390 "configure"
 #include "confdefs.h"
 #include <stdarg.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:55763: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:55395: \"$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*
@@ -55989,7 +55621,7 @@ EOF
   done
 
   echo $ac_n "checking for onig_init in -lonig""... $ac_c" 1>&6
-echo "configure:55993: checking for onig_init in -lonig" >&5
+echo "configure:55625: 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
@@ -55997,7 +55629,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lonig  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 56001 "configure"
+#line 55633 "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
@@ -56008,7 +55640,7 @@ int main() {
 onig_init()
 ; return 0; }
 EOF
-if { (eval echo configure:56012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:55644: \"$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
@@ -56234,9 +55866,9 @@ fi
   done
 
       echo $ac_n "checking if oniguruma has an invalid entry for KOI8 encoding""... $ac_c" 1>&6
-echo "configure:56238: checking if oniguruma has an invalid entry for KOI8 encoding" >&5
+echo "configure:55870: checking if oniguruma has an invalid entry for KOI8 encoding" >&5
       cat > conftest.$ac_ext <<EOF
-#line 56240 "configure"
+#line 55872 "configure"
 #include "confdefs.h"
 
 #include <oniguruma.h>
@@ -56247,7 +55879,7 @@ return (int)(ONIG_ENCODING_KOI8 + 1);
       
 ; return 0; }
 EOF
-if { (eval echo configure:56251: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:55883: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
         echo "$ac_t""no" 1>&6
@@ -56542,7 +56174,7 @@ EOF
   done
 
   echo $ac_n "checking for mbfl_buffer_converter_new in -lmbfl""... $ac_c" 1>&6
-echo "configure:56546: checking for mbfl_buffer_converter_new in -lmbfl" >&5
+echo "configure:56178: 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
@@ -56550,7 +56182,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lmbfl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 56554 "configure"
+#line 56186 "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
@@ -56561,7 +56193,7 @@ int main() {
 mbfl_buffer_converter_new()
 ; return 0; }
 EOF
-if { (eval echo configure:56565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:56197: \"$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
@@ -57198,7 +56830,7 @@ fi
 php_with_mcrypt=no
 
 echo $ac_n "checking for mcrypt support""... $ac_c" 1>&6
-echo "configure:57202: checking for mcrypt support" >&5
+echo "configure:56834: checking for mcrypt support" >&5
 # Check whether --with-mcrypt or --without-mcrypt was given.
 if test "${with_mcrypt+set}" = set; then
   withval="$with_mcrypt"
@@ -57254,9 +56886,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:57258: checking for libmcrypt version" >&5
+echo "configure:56890: checking for libmcrypt version" >&5
   cat > conftest.$ac_ext <<EOF
-#line 57260 "configure"
+#line 56892 "configure"
 #include "confdefs.h"
 
 #include <mcrypt.h>
@@ -57380,7 +57012,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for mcrypt_module_open in -lmcrypt""... $ac_c" 1>&6
-echo "configure:57384: checking for mcrypt_module_open in -lmcrypt" >&5
+echo "configure:57016: 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
@@ -57388,7 +57020,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lmcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 57392 "configure"
+#line 57024 "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
@@ -57399,7 +57031,7 @@ int main() {
 mcrypt_module_open()
 ; return 0; }
 EOF
-if { (eval echo configure:57403: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:57035: \"$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
@@ -57552,7 +57184,7 @@ else
   done
 
   echo $ac_n "checking for mcrypt_module_open in -lmcrypt""... $ac_c" 1>&6
-echo "configure:57556: checking for mcrypt_module_open in -lmcrypt" >&5
+echo "configure:57188: 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
@@ -57560,7 +57192,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lmcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 57564 "configure"
+#line 57196 "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
@@ -57571,7 +57203,7 @@ int main() {
 mcrypt_module_open()
 ; return 0; }
 EOF
-if { (eval echo configure:57575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:57207: \"$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
@@ -58044,7 +57676,7 @@ fi
 php_with_mssql=no
 
 echo $ac_n "checking for MSSQL support via FreeTDS""... $ac_c" 1>&6
-echo "configure:58048: checking for MSSQL support via FreeTDS" >&5
+echo "configure:57680: 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"
@@ -58545,7 +58177,7 @@ EOF
   fi
 
   echo $ac_n "checking for dnet_addr in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:58549: checking for dnet_addr in -ldnet_stub" >&5
+echo "configure:58181: 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
@@ -58553,7 +58185,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 58557 "configure"
+#line 58189 "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
@@ -58564,7 +58196,7 @@ int main() {
 dnet_addr()
 ; return 0; }
 EOF
-if { (eval echo configure:58568: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:58200: \"$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
@@ -58708,7 +58340,7 @@ fi
 php_with_mysql=no
 
 echo $ac_n "checking for MySQL support""... $ac_c" 1>&6
-echo "configure:58712: checking for MySQL support" >&5
+echo "configure:58344: checking for MySQL support" >&5
 # Check whether --with-mysql or --without-mysql was given.
 if test "${with_mysql+set}" = set; then
   withval="$with_mysql"
@@ -58755,7 +58387,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:58759: checking for specified location of the MySQL UNIX socket" >&5
+echo "configure:58391: 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"
@@ -58782,7 +58414,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:58786: checking for the location of libz" >&5
+echo "configure:58418: 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"
@@ -58809,49 +58441,6 @@ if test "$PHP_MYSQL" = "mysqlnd"; then
     PHP_MYSQLND_ENABLED=yes
 
 elif test "$PHP_MYSQL" != "no"; then
-
-  echo $ac_n "checking for MySQL UNIX socket location""... $ac_c" 1>&6
-echo "configure:58815: 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
-#define PHP_MYSQL_UNIX_SOCK_ADDR "$MYSQL_SOCK"
-EOF
-
-    echo "$ac_t""$MYSQL_SOCK" 1>&6
-  elif test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL_SOCK" = "yes"; then
-    
-  for i in  \
-    /var/run/mysqld/mysqld.sock \
-    /var/tmp/mysql.sock \
-    /var/run/mysql/mysql.sock \
-    /var/lib/mysql/mysql.sock \
-    /var/mysql/mysql.sock \
-    /usr/local/mysql/var/mysql.sock \
-    /Private/tmp/mysql.sock \
-    /private/tmp/mysql.sock \
-    /tmp/mysql.sock \
-  ; do
-    if test -r $i; then
-      MYSQL_SOCK=$i
-      break 2
-    fi
-  done
-
-  if test -n "$MYSQL_SOCK"; then
-    cat >> confdefs.h <<EOF
-#define PHP_MYSQL_UNIX_SOCK_ADDR "$MYSQL_SOCK"
-EOF
-
-    echo "$ac_t""$MYSQL_SOCK" 1>&6
-  else
-    echo "$ac_t""no" 1>&6
-  fi
-
-  else
-    echo "$ac_t""no" 1>&6
-  fi
-
   MYSQL_DIR=
   MYSQL_INC_DIR=
 
@@ -59002,7 +58591,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:59006: checking for mysql_close in -l$MYSQL_LIBNAME" >&5
+echo "configure:58595: 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
@@ -59010,7 +58599,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 59014 "configure"
+#line 58603 "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
@@ -59021,7 +58610,7 @@ int main() {
 mysql_close()
 ; return 0; }
 EOF
-if { (eval echo configure:59025: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:58614: \"$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
@@ -59244,7 +58833,7 @@ else
   done
 
   echo $ac_n "checking for mysql_error in -l$MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:59248: checking for mysql_error in -l$MYSQL_LIBNAME" >&5
+echo "configure:58837: 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
@@ -59252,7 +58841,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 59256 "configure"
+#line 58845 "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
@@ -59263,7 +58852,7 @@ int main() {
 mysql_error()
 ; return 0; }
 EOF
-if { (eval echo configure:59267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:58856: \"$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
@@ -59418,7 +59007,7 @@ fi
   done
 
   echo $ac_n "checking for mysql_errno in -l$MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:59422: checking for mysql_errno in -l$MYSQL_LIBNAME" >&5
+echo "configure:59011: 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
@@ -59426,7 +59015,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 59430 "configure"
+#line 59019 "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
@@ -59437,7 +59026,7 @@ int main() {
 mysql_errno()
 ; return 0; }
 EOF
-if { (eval echo configure:59441: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:59030: \"$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
@@ -59630,6 +59219,48 @@ fi
 fi
 
 if test "$PHP_MYSQL" != "no"; then
+  echo $ac_n "checking for MySQL UNIX socket location""... $ac_c" 1>&6
+echo "configure:59224: 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
+#define PHP_MYSQL_UNIX_SOCK_ADDR "$MYSQL_SOCK"
+EOF
+
+    echo "$ac_t""$MYSQL_SOCK" 1>&6
+  elif test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL_SOCK" = "yes"; then
+    
+  for i in  \
+    /var/run/mysqld/mysqld.sock \
+    /var/tmp/mysql.sock \
+    /var/run/mysql/mysql.sock \
+    /var/lib/mysql/mysql.sock \
+    /var/mysql/mysql.sock \
+    /usr/local/mysql/var/mysql.sock \
+    /Private/tmp/mysql.sock \
+    /private/tmp/mysql.sock \
+    /tmp/mysql.sock \
+  ; do
+    if test -r $i; then
+      MYSQL_SOCK=$i
+      break 2
+    fi
+  done
+
+  if test -n "$MYSQL_SOCK"; then
+    cat >> confdefs.h <<EOF
+#define PHP_MYSQL_UNIX_SOCK_ADDR "$MYSQL_SOCK"
+EOF
+
+    echo "$ac_t""$MYSQL_SOCK" 1>&6
+  else
+    echo "$ac_t""no" 1>&6
+  fi
+
+  else
+    echo "$ac_t""no" 1>&6
+  fi
+
   cat >> confdefs.h <<\EOF
 #define HAVE_MYSQL 1
 EOF
@@ -59962,7 +59593,7 @@ fi
 php_with_mysqli=no
 
 echo $ac_n "checking for MySQLi support""... $ac_c" 1>&6
-echo "configure:59966: checking for MySQLi support" >&5
+echo "configure:59597: checking for MySQLi support" >&5
 # Check whether --with-mysqli or --without-mysqli was given.
 if test "${with_mysqli+set}" = set; then
   withval="$with_mysqli"
@@ -60009,7 +59640,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:60013: checking whether to enable embedded MySQLi support" >&5
+echo "configure:59644: 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"
@@ -60163,7 +59794,7 @@ EOF
   done
 
   echo $ac_n "checking for mysql_set_server_option in -l$MYSQL_LIB_NAME""... $ac_c" 1>&6
-echo "configure:60167: checking for mysql_set_server_option in -l$MYSQL_LIB_NAME" >&5
+echo "configure:59798: 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
@@ -60171,7 +59802,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIB_NAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 60175 "configure"
+#line 59806 "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
@@ -60182,7 +59813,7 @@ int main() {
 mysql_set_server_option()
 ; return 0; }
 EOF
-if { (eval echo configure:60186: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:59817: \"$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
@@ -60430,7 +60061,7 @@ EOF
   done
 
   echo $ac_n "checking for mysql_set_character_set in -l$MYSQL_LIB_NAME""... $ac_c" 1>&6
-echo "configure:60434: checking for mysql_set_character_set in -l$MYSQL_LIB_NAME" >&5
+echo "configure:60065: 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
@@ -60438,7 +60069,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIB_NAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 60442 "configure"
+#line 60073 "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
@@ -60449,7 +60080,7 @@ int main() {
 mysql_set_character_set()
 ; return 0; }
 EOF
-if { (eval echo configure:60453: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:60084: \"$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
@@ -60593,7 +60224,7 @@ fi
   done
 
   echo $ac_n "checking for mysql_stmt_next_result in -l$MYSQL_LIB_NAME""... $ac_c" 1>&6
-echo "configure:60597: checking for mysql_stmt_next_result in -l$MYSQL_LIB_NAME" >&5
+echo "configure:60228: 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
@@ -60601,7 +60232,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIB_NAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 60605 "configure"
+#line 60236 "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
@@ -60612,7 +60243,7 @@ int main() {
 mysql_stmt_next_result()
 ; return 0; }
 EOF
-if { (eval echo configure:60616: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:60247: \"$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
@@ -60998,7 +60629,7 @@ fi
 php_with_oci8=no
 
 echo $ac_n "checking for Oracle (OCI8) support""... $ac_c" 1>&6
-echo "configure:61002: checking for Oracle (OCI8) support" >&5
+echo "configure:60633: 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"
@@ -61049,7 +60680,7 @@ if test "$PHP_OCI8" != "no"; then
 
   
   echo $ac_n "checking PHP version""... $ac_c" 1>&6
-echo "configure:61053: checking PHP version" >&5
+echo "configure:60684: checking PHP version" >&5
 
   tmp_version=$PHP_VERSION
   if test -z "$tmp_version"; then
@@ -61081,7 +60712,7 @@ echo "configure:61053: checking PHP version" >&5
 
   
   echo $ac_n "checking size of long int""... $ac_c" 1>&6
-echo "configure:61085: checking size of long int" >&5
+echo "configure:60716: 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
@@ -61089,7 +60720,7 @@ else
   ac_cv_sizeof_long_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 61093 "configure"
+#line 60724 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -61100,7 +60731,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:61104: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:60735: \"$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
@@ -61120,7 +60751,7 @@ EOF
 
 
   echo $ac_n "checking checking if we're on a 64-bit platform""... $ac_c" 1>&6
-echo "configure:61124: checking checking if we're on a 64-bit platform" >&5
+echo "configure:60755: 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 
@@ -61164,7 +60795,7 @@ echo "configure:61124: 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:61168: checking Oracle ORACLE_HOME install directory" >&5
+echo "configure:60799: checking Oracle ORACLE_HOME install directory" >&5
 
     if test "$PHP_OCI8" = "yes"; then
       OCI8_DIR=$ORACLE_HOME
@@ -61175,7 +60806,7 @@ echo "configure:61168: checking Oracle ORACLE_HOME install directory" >&5
 
     
   echo $ac_n "checking ORACLE_HOME library validity""... $ac_c" 1>&6
-echo "configure:61179: checking ORACLE_HOME library validity" >&5
+echo "configure:60810: 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
@@ -61516,7 +61147,7 @@ echo "configure:61179: checking ORACLE_HOME library validity" >&5
 
     
   echo $ac_n "checking Oracle version""... $ac_c" 1>&6
-echo "configure:61520: checking Oracle version" >&5
+echo "configure:61151: 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
@@ -61646,7 +61277,7 @@ echo "configure:61520: checking Oracle version" >&5
   done
 
   echo $ac_n "checking for OCIEnvNlsCreate in -lclntsh""... $ac_c" 1>&6
-echo "configure:61650: checking for OCIEnvNlsCreate in -lclntsh" >&5
+echo "configure:61281: 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
@@ -61654,7 +61285,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 61658 "configure"
+#line 61289 "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
@@ -61665,7 +61296,7 @@ int main() {
 OCIEnvNlsCreate()
 ; return 0; }
 EOF
-if { (eval echo configure:61669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:61300: \"$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
@@ -62102,7 +61733,7 @@ EOF
   else
             
     echo $ac_n "checking Oracle Instant Client directory""... $ac_c" 1>&6
-echo "configure:62106: checking Oracle Instant Client directory" >&5
+echo "configure:61737: 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[^/]*##'`
@@ -62115,7 +61746,7 @@ echo "configure:62106: 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:62119: checking Oracle Instant Client SDK header directory" >&5
+echo "configure:61750: 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!'`
 
@@ -62324,7 +61955,7 @@ echo "configure:62119: checking Oracle Instant Client SDK header directory" >&5
 
     
   echo $ac_n "checking Oracle Instant Client version""... $ac_c" 1>&6
-echo "configure:62328: checking Oracle Instant Client version" >&5
+echo "configure:61959: 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
@@ -62806,7 +62437,7 @@ esac
 
   if test "$PHP_ADABAS" != "no"; then
     echo $ac_n "checking for Adabas support""... $ac_c" 1>&6
-echo "configure:62810: checking for Adabas support" >&5
+echo "configure:62441: checking for Adabas support" >&5
     if test "$PHP_ADABAS" = "yes"; then
       PHP_ADABAS=/usr/local
     fi
@@ -63012,7 +62643,7 @@ esac
 
   if test "$PHP_SAPDB" != "no"; then
     echo $ac_n "checking for SAP DB support""... $ac_c" 1>&6
-echo "configure:63016: checking for SAP DB support" >&5
+echo "configure:62647: checking for SAP DB support" >&5
     if test "$PHP_SAPDB" = "yes"; then
       PHP_SAPDB=/usr/local
     fi
@@ -63148,7 +62779,7 @@ esac
 
   if test "$PHP_SOLID" != "no"; then
     echo $ac_n "checking for Solid support""... $ac_c" 1>&6
-echo "configure:63152: checking for Solid support" >&5
+echo "configure:62783: checking for Solid support" >&5
     if test "$PHP_SOLID" = "yes"; then
       PHP_SOLID=/usr/local/solid
     fi
@@ -63175,7 +62806,7 @@ EOF
     echo "$ac_t""$ext_output" 1>&6
     
   echo $ac_n "checking Solid library file""... $ac_c" 1>&6
-echo "configure:63179: checking Solid library file" >&5  
+echo "configure:62810: 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
@@ -63299,7 +62930,7 @@ esac
 
   if test "$PHP_IBM_DB2" != "no"; then
     echo $ac_n "checking for IBM DB2 support""... $ac_c" 1>&6
-echo "configure:63303: checking for IBM DB2 support" >&5
+echo "configure:62934: 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
@@ -63330,7 +62961,7 @@ fi
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 63334 "configure"
+#line 62965 "configure"
 #include "confdefs.h"
 
     
@@ -63341,7 +62972,7 @@ else
     }
   
 EOF
-if { (eval echo configure:63345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:62976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -63425,7 +63056,7 @@ esac
 
   if test "$PHP_ODBCROUTER" != "no"; then
     echo $ac_n "checking for ODBCRouter.com support""... $ac_c" 1>&6
-echo "configure:63429: checking for ODBCRouter.com support" >&5
+echo "configure:63060: checking for ODBCRouter.com support" >&5
     if test "$PHP_ODBCROUTER" = "yes"; then
       PHP_ODBCROUTER=/usr
     fi
@@ -63492,7 +63123,7 @@ esac
 
   if test "$PHP_EMPRESS" != "no"; then
     echo $ac_n "checking for Empress support""... $ac_c" 1>&6
-echo "configure:63496: checking for Empress support" >&5
+echo "configure:63127: checking for Empress support" >&5
     if test "$PHP_EMPRESS" = "yes"; then
       ODBC_INCDIR=$EMPRESSPATH/include/odbc
       ODBC_LIBDIR=$EMPRESSPATH/shlib
@@ -63510,7 +63141,7 @@ EOF
     echo "$ac_t""$ext_output" 1>&6
     
   echo $ac_n "checking Empress library file""... $ac_c" 1>&6
-echo "configure:63514: checking Empress library file" >&5
+echo "configure:63145: 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`
@@ -63569,7 +63200,7 @@ esac
 
   if test "$PHP_EMPRESS_BCS" != "no"; then
     echo $ac_n "checking for Empress local access support""... $ac_c" 1>&6
-echo "configure:63573: checking for Empress local access support" >&5
+echo "configure:63204: checking for Empress local access support" >&5
     if test "$PHP_EMPRESS_BCS" = "yes"; then
       ODBC_INCDIR=$EMPRESSPATH/include/odbc
       ODBC_LIBDIR=$EMPRESSPATH/shlib
@@ -63603,7 +63234,7 @@ EOF
     echo "$ac_t""$ext_output" 1>&6
     
   echo $ac_n "checking Empress local access library file""... $ac_c" 1>&6
-echo "configure:63607: checking Empress local access library file" >&5
+echo "configure:63238: 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`
@@ -63662,7 +63293,7 @@ esac
   
   if test "$PHP_BIRDSTEP" != "no"; then
     echo $ac_n "checking for Birdstep support""... $ac_c" 1>&6
-echo "configure:63666: checking for Birdstep support" >&5
+echo "configure:63297: checking for Birdstep support" >&5
     if test "$PHP_BIRDSTEP" = "yes"; then
         ODBC_INCDIR=/usr/local/birdstep/include
         ODBC_LIBDIR=/usr/local/birdstep/lib
@@ -63777,7 +63408,7 @@ esac
 
   if test "$PHP_CUSTOM_ODBC" != "no"; then
     echo $ac_n "checking for a custom ODBC support""... $ac_c" 1>&6
-echo "configure:63781: checking for a custom ODBC support" >&5
+echo "configure:63412: checking for a custom ODBC support" >&5
     if test "$PHP_CUSTOM_ODBC" = "yes"; then
       PHP_CUSTOM_ODBC=/usr/local
     fi
@@ -63844,7 +63475,7 @@ esac
 
   if test "$PHP_IODBC" != "no"; then
     echo $ac_n "checking for iODBC support""... $ac_c" 1>&6
-echo "configure:63848: checking for iODBC support" >&5
+echo "configure:63479: checking for iODBC support" >&5
     if test "$PHP_IODBC" = "yes"; then
       PHP_IODBC=/usr/local
     fi
@@ -63993,7 +63624,7 @@ esac
 
   if test "$PHP_ESOOB" != "no"; then
     echo $ac_n "checking for Easysoft ODBC-ODBC Bridge support""... $ac_c" 1>&6
-echo "configure:63997: checking for Easysoft ODBC-ODBC Bridge support" >&5
+echo "configure:63628: checking for Easysoft ODBC-ODBC Bridge support" >&5
     if test "$PHP_ESOOB" = "yes"; then
       PHP_ESOOB=/usr/local/easysoft/oob/client
     fi
@@ -64060,7 +63691,7 @@ esac
 
   if test "$PHP_UNIXODBC" != "no"; then
     echo $ac_n "checking for unixODBC support""... $ac_c" 1>&6
-echo "configure:64064: checking for unixODBC support" >&5
+echo "configure:63695: checking for unixODBC support" >&5
     if test "$PHP_UNIXODBC" = "yes"; then
       PHP_UNIXODBC=/usr/local
     fi
@@ -64132,7 +63763,7 @@ esac
 
   if test "$PHP_DBMAKER" != "no"; then
     echo $ac_n "checking for DBMaker support""... $ac_c" 1>&6
-echo "configure:64136: checking for DBMaker support" >&5
+echo "configure:63767: 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}'`
@@ -64694,7 +64325,7 @@ fi
 php_enable_pcntl=no
 
 echo $ac_n "checking whether to enable pcntl support""... $ac_c" 1>&6
-echo "configure:64698: checking whether to enable pcntl support" >&5
+echo "configure:64329: 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"
@@ -64741,12 +64372,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:64745: checking for $ac_func" >&5
+echo "configure:64376: 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 64750 "configure"
+#line 64381 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -64769,7 +64400,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:64773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:64404: \"$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
@@ -64800,12 +64431,12 @@ done
   for ac_func in waitpid
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:64804: checking for $ac_func" >&5
+echo "configure:64435: 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 64809 "configure"
+#line 64440 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -64828,7 +64459,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:64832: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:64463: \"$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
@@ -64859,12 +64490,12 @@ done
   for ac_func in sigaction
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:64863: checking for $ac_func" >&5
+echo "configure:64494: 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 64868 "configure"
+#line 64499 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -64887,7 +64518,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:64891: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:64522: \"$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
@@ -64918,12 +64549,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:64922: checking for $ac_func" >&5
+echo "configure:64553: 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 64927 "configure"
+#line 64558 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -64946,7 +64577,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:64950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:64581: \"$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
@@ -65271,7 +64902,7 @@ fi
 php_enable_pdo=yes
 
 echo $ac_n "checking whether to enable PDO support""... $ac_c" 1>&6
-echo "configure:65275: checking whether to enable PDO support" >&5
+echo "configure:64906: 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"
@@ -65708,7 +65339,7 @@ fi
 php_with_pdo_dblib=no
 
 echo $ac_n "checking for PDO_DBLIB support via FreeTDS""... $ac_c" 1>&6
-echo "configure:65712: checking for PDO_DBLIB support via FreeTDS" >&5
+echo "configure:65343: 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"
@@ -65928,13 +65559,13 @@ if test "$PHP_PDO_DBLIB" != "no"; then
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:65932: checking for PDO includes" >&5
+echo "configure:65563: 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:65938: checking for PDO includes" >&5
+echo "configure:65569: 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
@@ -66248,7 +65879,7 @@ EOF
   fi
 
   echo $ac_n "checking for dnet_addr in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:66252: checking for dnet_addr in -ldnet_stub" >&5
+echo "configure:65883: 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
@@ -66256,7 +65887,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 66260 "configure"
+#line 65891 "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
@@ -66267,7 +65898,7 @@ int main() {
 dnet_addr()
 ; return 0; }
 EOF
-if { (eval echo configure:66271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:65902: \"$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
@@ -66428,7 +66059,7 @@ fi
 php_with_pdo_firebird=no
 
 echo $ac_n "checking for Firebird support for PDO""... $ac_c" 1>&6
-echo "configure:66432: checking for Firebird support for PDO" >&5
+echo "configure:66063: 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"
@@ -66585,7 +66216,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:66589: checking for isc_detach_database in -lfbclient" >&5
+echo "configure:66220: 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
@@ -66593,7 +66224,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lfbclient  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 66597 "configure"
+#line 66228 "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
@@ -66604,7 +66235,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:66608: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:66239: \"$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
@@ -66731,7 +66362,7 @@ else
   done
 
   echo $ac_n "checking for isc_detach_database in -lgds""... $ac_c" 1>&6
-echo "configure:66735: checking for isc_detach_database in -lgds" >&5
+echo "configure:66366: 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
@@ -66739,7 +66370,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgds  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 66743 "configure"
+#line 66374 "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
@@ -66750,7 +66381,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:66754: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:66385: \"$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
@@ -66877,7 +66508,7 @@ else
   done
 
   echo $ac_n "checking for isc_detach_database in -lib_util""... $ac_c" 1>&6
-echo "configure:66881: checking for isc_detach_database in -lib_util" >&5
+echo "configure:66512: 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
@@ -66885,7 +66516,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lib_util  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 66889 "configure"
+#line 66520 "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
@@ -66896,7 +66527,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:66900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:66531: \"$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
@@ -66941,13 +66572,13 @@ fi
  
   
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:66945: checking for PDO includes" >&5
+echo "configure:66576: 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:66951: checking for PDO includes" >&5
+echo "configure:66582: 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
@@ -67419,7 +67050,7 @@ fi
 php_with_pdo_mysql=no
 
 echo $ac_n "checking for MySQL support for PDO""... $ac_c" 1>&6
-echo "configure:67423: checking for MySQL support for PDO" >&5
+echo "configure:67054: 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"
@@ -67467,7 +67098,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:67471: checking for the location of libz" >&5
+echo "configure:67102: 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"
@@ -67498,6 +67129,29 @@ if test "$PHP_PDO_MYSQL" != "no"; then
 
   
 
+  if test -f $PHP_PDO_MYSQL && test -x $PHP_PDO_MYSQL ; then
+    PDO_MYSQL_CONFIG=$PHP_PDO_MYSQL
+  elif test "$PHP_PDO_MYSQL" != "yes"; then
+    if test -d "$PHP_PDO_MYSQL" ; then
+      if test -x "$PHP_PDO_MYSQL/bin/mysql_config" ; then
+        PDO_MYSQL_CONFIG="$PHP_PDO_MYSQL/bin/mysql_config"
+      else
+        PDO_MYSQL_DIR="$PHP_PDO_MYSQL"
+      fi
+    fi
+  else
+    for i in /usr/local /usr ; do
+      if test -x "$i/bin/mysql_config" ; then
+        PDO_MYSQL_CONFIG="$i/bin/mysql_config"
+        break;
+      fi
+      if test -r $i/include/mysql/mysql.h || test -r $i/include/mysql.h ; then
+        PDO_MYSQL_DIR="$i"
+        break;
+      fi
+    done
+  fi
+
   if test "$PHP_PDO_MYSQL" = "mysqlnd"; then
         PHP_MYSQLND_ENABLED=yes
     cat >> confdefs.h <<\EOF
@@ -67509,42 +67163,16 @@ EOF
 #define HAVE_MYSQL 1
 EOF
 
-    echo $ac_n "checking for mysql_config""... $ac_c" 1>&6
-echo "configure:67514: checking for mysql_config" >&5
-
-    if test -f $PHP_PDO_MYSQL && test -x $PHP_PDO_MYSQL ; then
-      PDO_MYSQL_CONFIG=$PHP_PDO_MYSQL
-    elif test "$PHP_PDO_MYSQL" != "yes"; then
-      if test -d "$PHP_PDO_MYSQL" ; then
-        if test -x "$PHP_PDO_MYSQL/bin/mysql_config" ; then
-          PDO_MYSQL_CONFIG="$PHP_PDO_MYSQL/bin/mysql_config"
-        else
-          PDO_MYSQL_DIR="$PHP_PDO_MYSQL"
-        fi
-      else
-        echo "$ac_t""$PHP_PDO_MYSQL is not a directory" 1>&6
-        { echo "configure: error: can not find mysql under the "$PHP_PDO_MYSQL" that you specified" 1>&2; exit 1; }
-      fi
-    else
-      for i in /usr/local /usr ; do
-        if test -x "$i/bin/mysql_config" ; then
-          PDO_MYSQL_CONFIG="$i/bin/mysql_config"
-          break;
-        fi
-        if test -r $i/include/mysql/mysql.h || test -r $i/include/mysql.h ; then
-          PDO_MYSQL_DIR="$i"
-          break;
-        fi
-      done
-    fi
 
-    if test -n "$PDO_MYSQL_CONFIG" && test -x "$PDO_MYSQL_CONFIG" ; then
+    echo $ac_n "checking for mysql_config""... $ac_c" 1>&6
+echo "configure:67169: 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:67548: checking for $ac_word" >&5
+echo "configure:67176: 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
@@ -67577,7 +67205,6 @@ else
 fi
 
       fi
-
       if test "$enable_maintainer_zts" = "yes"; then
         PDO_MYSQL_LIBNAME=mysqlclient_r
         PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs_r | $SED -e "s/'//g"`
@@ -67586,14 +67213,10 @@ fi
         PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g"`
       fi
       PDO_MYSQL_INCLUDE=`$PDO_MYSQL_CONFIG --cflags | $SED -e "s/'//g"`
-      PDO_MYSQL_SOCKET=`$PDO_MYSQL_CONFIG --socket` 
-    elif test -z "$PDO_MYSQL_DIR"; then
-      echo "$ac_t""not found" 1>&6
-      { echo "configure: error: Cannot find MySQL header files under $PDO_MYSQL_DIR" 1>&2; exit 1; }
-    else
+    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:67597: checking for mysql install under $PDO_MYSQL_DIR" >&5
+echo "configure:67220: 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
@@ -67644,13 +67267,11 @@ echo "configure:67597: checking for mysql install under $PDO_MYSQL_DIR" >&5
   fi
 
       PDO_MYSQL_INCLUDE=-I$PDO_MYSQL_INC_DIR
+    else
+      echo "$ac_t""not found" 1>&6
+      { echo "configure: error: Unable to find your mysql installation" 1>&2; exit 1; }
     fi
 
-    cat >> confdefs.h <<EOF
-#define PDO_MYSQL_UNIX_ADDR "$PDO_MYSQL_SOCKET"
-EOF
-
-
     
   save_old_LDFLAGS=$LDFLAGS
   ac_stuff="
@@ -67749,7 +67370,7 @@ EOF
   done
 
   echo $ac_n "checking for mysql_query in -l$PDO_MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:67753: checking for mysql_query in -l$PDO_MYSQL_LIBNAME" >&5
+echo "configure:67374: 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
@@ -67757,7 +67378,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$PDO_MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 67761 "configure"
+#line 67382 "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
@@ -67768,7 +67389,7 @@ int main() {
 mysql_query()
 ; return 0; }
 EOF
-if { (eval echo configure:67772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:67393: \"$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
@@ -68121,7 +67742,7 @@ else
   done
 
   echo $ac_n "checking for mysql_query in -l$PDO_MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:68125: checking for mysql_query in -l$PDO_MYSQL_LIBNAME" >&5
+echo "configure:67746: 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
@@ -68129,7 +67750,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$PDO_MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 68133 "configure"
+#line 67754 "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
@@ -68140,7 +67761,7 @@ int main() {
 mysql_query()
 ; return 0; }
 EOF
-if { (eval echo configure:68144: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:67765: \"$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
@@ -68295,7 +67916,7 @@ fi
   done
 
   echo $ac_n "checking for mysql_query in -l$PDO_MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:68299: checking for mysql_query in -l$PDO_MYSQL_LIBNAME" >&5
+echo "configure:67920: 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
@@ -68303,7 +67924,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$PDO_MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 68307 "configure"
+#line 67928 "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
@@ -68314,7 +67935,7 @@ int main() {
 mysql_query()
 ; return 0; }
 EOF
-if { (eval echo configure:68318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:67939: \"$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
@@ -68488,12 +68109,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:68492: checking for $ac_func" >&5
+echo "configure:68113: 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 68497 "configure"
+#line 68118 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -68516,7 +68137,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:68520: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:68141: \"$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
@@ -68546,13 +68167,13 @@ done
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:68550: checking for PDO includes" >&5
+echo "configure:68171: 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:68556: checking for PDO includes" >&5
+echo "configure:68177: 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
@@ -68572,6 +68193,13 @@ echo "$ac_t""$pdo_inc_path" 1>&6
 
   
 
+  if test -n "$PDO_MYSQL_CONFIG"; then
+    PDO_MYSQL_SOCKET=`$PDO_MYSQL_CONFIG --socket`
+    cat >> confdefs.h <<EOF
+#define PDO_MYSQL_UNIX_ADDR "$PDO_MYSQL_SOCKET"
+EOF
+
+  fi
 
     
   ext_builddir=ext/pdo_mysql
@@ -68930,7 +68558,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:68934: checking Oracle OCI support for PDO" >&5
+echo "configure:68562: 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"
@@ -68980,7 +68608,7 @@ if test "$PHP_PDO_OCI" != "no"; then
   fi
 
   echo $ac_n "checking Oracle Install-Dir""... $ac_c" 1>&6
-echo "configure:68984: checking Oracle Install-Dir" >&5
+echo "configure:68612: checking Oracle Install-Dir" >&5
   if test "$PHP_PDO_OCI" = "yes" || test -z "$PHP_PDO_OCI"; then
     PDO_OCI_DIR=$ORACLE_HOME
   else
@@ -68989,7 +68617,7 @@ echo "configure:68984: 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:68993: checking if that is sane" >&5
+echo "configure:68621: 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.
@@ -69002,7 +68630,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:69006: checking for oci.h" >&5
+echo "configure:68634: 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
@@ -69151,7 +68779,7 @@ echo "configure:69006: checking for oci.h" >&5
   else
     
   echo $ac_n "checking size of long int""... $ac_c" 1>&6
-echo "configure:69155: checking size of long int" >&5
+echo "configure:68783: 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
@@ -69159,7 +68787,7 @@ else
   ac_cv_sizeof_long_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 69163 "configure"
+#line 68791 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -69170,7 +68798,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:69174: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:68802: \"$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
@@ -69190,7 +68818,7 @@ EOF
 
 
   echo $ac_n "checking if we're on a 64-bit platform""... $ac_c" 1>&6
-echo "configure:69194: checking if we're on a 64-bit platform" >&5
+echo "configure:68822: 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"
@@ -69200,7 +68828,7 @@ echo "configure:69194: checking if we're on a 64-bit platform" >&5
   fi
 
   echo $ac_n "checking OCI8 libraries dir""... $ac_c" 1>&6
-echo "configure:69204: checking OCI8 libraries dir" >&5
+echo "configure:68832: 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
@@ -69567,7 +69195,7 @@ echo "configure:69204: checking OCI8 libraries dir" >&5
     fi
     
   echo $ac_n "checking Oracle version""... $ac_c" 1>&6
-echo "configure:69571: checking Oracle version" >&5
+echo "configure:69199: 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"
@@ -69581,7 +69209,7 @@ echo "configure:69571: checking Oracle version" >&5
   fi
 
   case $PDO_OCI_VERSION in
-    9.0|10.1|10.2|11.1)
+    9.0|10.1|10.2|11.1|11.2)
       
   
   case clntsh in
@@ -69749,7 +69377,7 @@ echo "configure:69571: checking Oracle version" >&5
   done
 
   echo $ac_n "checking for OCIEnvCreate in -lclntsh""... $ac_c" 1>&6
-echo "configure:69753: checking for OCIEnvCreate in -lclntsh" >&5
+echo "configure:69381: 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
@@ -69757,7 +69385,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 69761 "configure"
+#line 69389 "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
@@ -69768,7 +69396,7 @@ int main() {
 OCIEnvCreate()
 ; return 0; }
 EOF
-if { (eval echo configure:69772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:69400: \"$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
@@ -69902,7 +69530,7 @@ fi
   done
 
   echo $ac_n "checking for OCIEnvNlsCreate in -lclntsh""... $ac_c" 1>&6
-echo "configure:69906: checking for OCIEnvNlsCreate in -lclntsh" >&5
+echo "configure:69534: 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
@@ -69910,7 +69538,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 69914 "configure"
+#line 69542 "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
@@ -69921,7 +69549,7 @@ int main() {
 OCIEnvNlsCreate()
 ; return 0; }
 EOF
-if { (eval echo configure:69925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:69553: \"$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
@@ -70055,7 +69683,7 @@ fi
   done
 
   echo $ac_n "checking for OCILobIsTemporary in -lclntsh""... $ac_c" 1>&6
-echo "configure:70059: checking for OCILobIsTemporary in -lclntsh" >&5
+echo "configure:69687: 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
@@ -70063,7 +69691,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 70067 "configure"
+#line 69695 "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
@@ -70074,7 +69702,7 @@ int main() {
 OCILobIsTemporary()
 ; return 0; }
 EOF
-if { (eval echo configure:70078: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:69706: \"$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
@@ -70204,7 +69832,7 @@ else
   done
 
   echo $ac_n "checking for OCILobIsTemporary in -locijdbc8""... $ac_c" 1>&6
-echo "configure:70208: checking for OCILobIsTemporary in -locijdbc8" >&5
+echo "configure:69836: 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
@@ -70212,7 +69840,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-locijdbc8  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 70216 "configure"
+#line 69844 "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
@@ -70223,7 +69851,7 @@ int main() {
 OCILobIsTemporary()
 ; return 0; }
 EOF
-if { (eval echo configure:70227: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:69855: \"$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
@@ -70384,7 +70012,7 @@ fi
   done
 
   echo $ac_n "checking for OCICollAssign in -lclntsh""... $ac_c" 1>&6
-echo "configure:70388: checking for OCICollAssign in -lclntsh" >&5
+echo "configure:70016: 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
@@ -70392,7 +70020,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 70396 "configure"
+#line 70024 "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
@@ -70403,7 +70031,7 @@ int main() {
 OCICollAssign()
 ; return 0; }
 EOF
-if { (eval echo configure:70407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:70035: \"$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
@@ -70537,7 +70165,7 @@ fi
   done
 
   echo $ac_n "checking for OCIStmtFetch2 in -lclntsh""... $ac_c" 1>&6
-echo "configure:70541: checking for OCIStmtFetch2 in -lclntsh" >&5
+echo "configure:70169: 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
@@ -70545,7 +70173,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 70549 "configure"
+#line 70177 "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
@@ -70556,7 +70184,7 @@ int main() {
 OCIStmtFetch2()
 ; return 0; }
 EOF
-if { (eval echo configure:70560: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:70188: \"$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
@@ -70595,13 +70223,13 @@ fi
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:70599: checking for PDO includes" >&5
+echo "configure:70227: 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:70605: checking for PDO includes" >&5
+echo "configure:70233: 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
@@ -70969,7 +70597,7 @@ fi
 php_with_pdo_odbc=no
 
 echo $ac_n "checking for ODBC v3 support for PDO""... $ac_c" 1>&6
-echo "configure:70973: checking for ODBC v3 support for PDO" >&5
+echo "configure:70601: 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"
@@ -71024,13 +70652,13 @@ if test "$PHP_PDO_ODBC" != "no"; then
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:71028: checking for PDO includes" >&5
+echo "configure:70656: 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:71034: checking for PDO includes" >&5
+echo "configure:70662: 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
@@ -71051,7 +70679,7 @@ echo "$ac_t""$pdo_inc_path" 1>&6
   
 
   echo $ac_n "checking for selected PDO ODBC flavour""... $ac_c" 1>&6
-echo "configure:71055: checking for selected PDO ODBC flavour" >&5
+echo "configure:70683: 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`"
@@ -71130,7 +70758,7 @@ echo "configure:71055: checking for selected PDO ODBC flavour" >&5
 
   
   echo $ac_n "checking for odbc.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71134: checking for odbc.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70762: 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
@@ -71144,7 +70772,7 @@ EOF
 
   
   echo $ac_n "checking for odbcsdk.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71148: checking for odbcsdk.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70776: 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
@@ -71158,7 +70786,7 @@ EOF
 
   
   echo $ac_n "checking for iodbc.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71162: checking for iodbc.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70790: 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
@@ -71172,7 +70800,7 @@ EOF
 
   
   echo $ac_n "checking for sqlunix.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71176: checking for sqlunix.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70804: 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
@@ -71186,7 +70814,7 @@ EOF
 
   
   echo $ac_n "checking for sqltypes.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71190: checking for sqltypes.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70818: 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
@@ -71200,7 +70828,7 @@ EOF
 
   
   echo $ac_n "checking for sqlucode.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71204: checking for sqlucode.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70832: 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
@@ -71214,7 +70842,7 @@ EOF
 
   
   echo $ac_n "checking for sql.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71218: checking for sql.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70846: 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
@@ -71228,7 +70856,7 @@ EOF
 
   
   echo $ac_n "checking for isql.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71232: checking for isql.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70860: 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
@@ -71242,7 +70870,7 @@ EOF
 
   
   echo $ac_n "checking for sqlext.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71246: checking for sqlext.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70874: 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
@@ -71256,7 +70884,7 @@ EOF
 
   
   echo $ac_n "checking for isqlext.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71260: checking for isqlext.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70888: 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
@@ -71270,7 +70898,7 @@ EOF
 
   
   echo $ac_n "checking for udbcext.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71274: checking for udbcext.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70902: 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
@@ -71284,7 +70912,7 @@ EOF
 
   
   echo $ac_n "checking for sqlcli1.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71288: checking for sqlcli1.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70916: 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
@@ -71298,7 +70926,7 @@ EOF
 
   
   echo $ac_n "checking for LibraryManager.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71302: checking for LibraryManager.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70930: 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
@@ -71312,7 +70940,7 @@ EOF
 
   
   echo $ac_n "checking for cli0core.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71316: checking for cli0core.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70944: 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
@@ -71326,7 +70954,7 @@ EOF
 
   
   echo $ac_n "checking for cli0ext.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71330: checking for cli0ext.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70958: 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
@@ -71340,7 +70968,7 @@ EOF
 
   
   echo $ac_n "checking for cli0cli.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71344: checking for cli0cli.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70972: 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
@@ -71354,7 +70982,7 @@ EOF
 
   
   echo $ac_n "checking for cli0defs.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71358: checking for cli0defs.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:70986: 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
@@ -71368,7 +70996,7 @@ EOF
 
   
   echo $ac_n "checking for cli0env.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:71372: checking for cli0env.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:71000: 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
@@ -71574,7 +71202,7 @@ EOF
   done
 
   echo $ac_n "checking for SQLBindCol in -l$pdo_odbc_def_lib""... $ac_c" 1>&6
-echo "configure:71578: checking for SQLBindCol in -l$pdo_odbc_def_lib" >&5
+echo "configure:71206: 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
@@ -71582,7 +71210,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$pdo_odbc_def_lib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 71586 "configure"
+#line 71214 "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
@@ -71593,7 +71221,7 @@ int main() {
 SQLBindCol()
 ; return 0; }
 EOF
-if { (eval echo configure:71597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:71225: \"$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
@@ -71708,7 +71336,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:71712: checking for SQLAllocHandle in -l$pdo_odbc_def_lib" >&5
+echo "configure:71340: 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
@@ -71716,7 +71344,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$pdo_odbc_def_lib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 71720 "configure"
+#line 71348 "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
@@ -71727,7 +71355,7 @@ int main() {
 SQLAllocHandle()
 ; return 0; }
 EOF
-if { (eval echo configure:71731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:71359: \"$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
@@ -72101,7 +71729,7 @@ fi
 php_with_pdo_pgsql=no
 
 echo $ac_n "checking for PostgreSQL support for PDO""... $ac_c" 1>&6
-echo "configure:72105: checking for PostgreSQL support for PDO" >&5
+echo "configure:71733: 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"
@@ -72163,7 +71791,7 @@ if test "$PHP_PDO_PGSQL" != "no"; then
 
 
   echo $ac_n "checking for pg_config""... $ac_c" 1>&6
-echo "configure:72167: checking for pg_config" >&5
+echo "configure:71795: 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"
@@ -72227,13 +71855,13 @@ EOF
 
 
   echo $ac_n "checking for openssl dependencies""... $ac_c" 1>&6
-echo "configure:72231: checking for openssl dependencies" >&5
+echo "configure:71859: 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:72237: checking for $ac_word" >&5
+echo "configure:71865: 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
@@ -72277,7 +71905,7 @@ fi
   old_LDFLAGS=$LDFLAGS
   LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
   echo $ac_n "checking for PQparameterStatus in -lpq""... $ac_c" 1>&6
-echo "configure:72281: checking for PQparameterStatus in -lpq" >&5
+echo "configure:71909: 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
@@ -72285,7 +71913,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 72289 "configure"
+#line 71917 "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
@@ -72296,7 +71924,7 @@ int main() {
 PQparameterStatus()
 ; return 0; }
 EOF
-if { (eval echo configure:72300: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:71928: \"$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
@@ -72325,7 +71953,7 @@ fi
 
 
   echo $ac_n "checking for PQprepare in -lpq""... $ac_c" 1>&6
-echo "configure:72329: checking for PQprepare in -lpq" >&5
+echo "configure:71957: 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
@@ -72333,7 +71961,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 72337 "configure"
+#line 71965 "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
@@ -72344,7 +71972,7 @@ int main() {
 PQprepare()
 ; return 0; }
 EOF
-if { (eval echo configure:72348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:71976: \"$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
@@ -72368,7 +71996,7 @@ else
 fi
 
   echo $ac_n "checking for PQescapeStringConn in -lpq""... $ac_c" 1>&6
-echo "configure:72372: checking for PQescapeStringConn in -lpq" >&5
+echo "configure:72000: 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
@@ -72376,7 +72004,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 72380 "configure"
+#line 72008 "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
@@ -72387,7 +72015,7 @@ int main() {
 PQescapeStringConn()
 ; return 0; }
 EOF
-if { (eval echo configure:72391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:72019: \"$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
@@ -72411,7 +72039,7 @@ else
 fi
 
   echo $ac_n "checking for PQescapeByteaConn in -lpq""... $ac_c" 1>&6
-echo "configure:72415: checking for PQescapeByteaConn in -lpq" >&5
+echo "configure:72043: 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
@@ -72419,7 +72047,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 72423 "configure"
+#line 72051 "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
@@ -72430,7 +72058,7 @@ int main() {
 PQescapeByteaConn()
 ; return 0; }
 EOF
-if { (eval echo configure:72434: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:72062: \"$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
@@ -72455,7 +72083,7 @@ fi
 
 
   echo $ac_n "checking for pg_encoding_to_char in -lpq""... $ac_c" 1>&6
-echo "configure:72459: checking for pg_encoding_to_char in -lpq" >&5
+echo "configure:72087: 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
@@ -72463,7 +72091,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 72467 "configure"
+#line 72095 "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
@@ -72474,7 +72102,7 @@ int main() {
 pg_encoding_to_char()
 ; return 0; }
 EOF
-if { (eval echo configure:72478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:72106: \"$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
@@ -72638,13 +72266,13 @@ fi
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:72642: checking for PDO includes" >&5
+echo "configure:72270: 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:72648: checking for PDO includes" >&5
+echo "configure:72276: 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
@@ -72984,7 +72612,7 @@ fi
 php_with_pdo_sqlite=$PHP_PDO
 
 echo $ac_n "checking for sqlite 3 support for PDO""... $ac_c" 1>&6
-echo "configure:72988: checking for sqlite 3 support for PDO" >&5
+echo "configure:72616: 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"
@@ -73036,13 +72664,13 @@ if test "$PHP_PDO_SQLITE" != "no"; then
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:73040: checking for PDO includes" >&5
+echo "configure:72668: 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:73046: checking for PDO includes" >&5
+echo "configure:72674: 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
@@ -73071,7 +72699,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:73075: checking for sqlite3 files in default path" >&5
+echo "configure:72703: 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
@@ -73217,7 +72845,7 @@ echo "configure:73075: checking for sqlite3 files in default path" >&5
   done
 
   echo $ac_n "checking for $LIBSYMBOL in -l$LIBNAME""... $ac_c" 1>&6
-echo "configure:73221: checking for $LIBSYMBOL in -l$LIBNAME" >&5
+echo "configure:72849: 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
@@ -73225,7 +72853,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 73229 "configure"
+#line 72857 "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
@@ -73236,7 +72864,7 @@ int main() {
 $LIBSYMBOL()
 ; return 0; }
 EOF
-if { (eval echo configure:73240: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:72868: \"$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 +73094,7 @@ fi
   done
 
   echo $ac_n "checking for sqlite3_key in -lsqlite3""... $ac_c" 1>&6
-echo "configure:73470: checking for sqlite3_key in -lsqlite3" >&5
+echo "configure:73098: 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
@@ -73474,7 +73102,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsqlite3  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 73478 "configure"
+#line 73106 "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
@@ -73485,7 +73113,7 @@ int main() {
 sqlite3_key()
 ; return 0; }
 EOF
-if { (eval echo configure:73489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:73117: \"$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
@@ -74226,12 +73854,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:74230: checking for $ac_func" >&5
+echo "configure:73858: 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 74235 "configure"
+#line 73863 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -74254,7 +73882,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:74258: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:73886: \"$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
@@ -74282,17 +73910,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:74286: checking for $ac_hdr" >&5
+echo "configure:73914: 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 74291 "configure"
+#line 73919 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:74296: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:73924: \"$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*
@@ -74416,7 +74044,7 @@ done
   done
 
   echo $ac_n "checking for fdatasync in -lrt""... $ac_c" 1>&6
-echo "configure:74420: checking for fdatasync in -lrt" >&5
+echo "configure:74048: 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
@@ -74424,7 +74052,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lrt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74428 "configure"
+#line 74056 "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
@@ -74435,7 +74063,7 @@ int main() {
 fdatasync()
 ; return 0; }
 EOF
-if { (eval echo configure:74439: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74067: \"$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
@@ -74516,7 +74144,7 @@ fi
 php_with_pgsql=no
 
 echo $ac_n "checking for PostgreSQL support""... $ac_c" 1>&6
-echo "configure:74520: checking for PostgreSQL support" >&5
+echo "configure:74148: checking for PostgreSQL support" >&5
 # Check whether --with-pgsql or --without-pgsql was given.
 if test "${with_pgsql+set}" = set; then
   withval="$with_pgsql"
@@ -74573,7 +74201,7 @@ if test "$PHP_PGSQL" != "no"; then
 
 
   echo $ac_n "checking for pg_config""... $ac_c" 1>&6
-echo "configure:74577: checking for pg_config" >&5
+echo "configure:74205: 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"
@@ -74641,7 +74269,7 @@ EOF
   old_LDFLAGS=$LDFLAGS
   LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
   echo $ac_n "checking for PQescapeString in -lpq""... $ac_c" 1>&6
-echo "configure:74645: checking for PQescapeString in -lpq" >&5
+echo "configure:74273: 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
@@ -74649,7 +74277,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74653 "configure"
+#line 74281 "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
@@ -74660,7 +74288,7 @@ int main() {
 PQescapeString()
 ; return 0; }
 EOF
-if { (eval echo configure:74664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74292: \"$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
@@ -74684,7 +74312,7 @@ else
 fi
 
   echo $ac_n "checking for PQunescapeBytea in -lpq""... $ac_c" 1>&6
-echo "configure:74688: checking for PQunescapeBytea in -lpq" >&5
+echo "configure:74316: 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
@@ -74692,7 +74320,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74696 "configure"
+#line 74324 "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
@@ -74703,7 +74331,7 @@ int main() {
 PQunescapeBytea()
 ; return 0; }
 EOF
-if { (eval echo configure:74707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74335: \"$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
@@ -74727,7 +74355,7 @@ else
 fi
 
   echo $ac_n "checking for PQsetnonblocking in -lpq""... $ac_c" 1>&6
-echo "configure:74731: checking for PQsetnonblocking in -lpq" >&5
+echo "configure:74359: 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
@@ -74735,7 +74363,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74739 "configure"
+#line 74367 "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
@@ -74746,7 +74374,7 @@ int main() {
 PQsetnonblocking()
 ; return 0; }
 EOF
-if { (eval echo configure:74750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74378: \"$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
@@ -74770,7 +74398,7 @@ else
 fi
 
   echo $ac_n "checking for PQcmdTuples in -lpq""... $ac_c" 1>&6
-echo "configure:74774: checking for PQcmdTuples in -lpq" >&5
+echo "configure:74402: 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
@@ -74778,7 +74406,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74782 "configure"
+#line 74410 "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
@@ -74789,7 +74417,7 @@ int main() {
 PQcmdTuples()
 ; return 0; }
 EOF
-if { (eval echo configure:74793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74421: \"$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
@@ -74813,7 +74441,7 @@ else
 fi
 
   echo $ac_n "checking for PQoidValue in -lpq""... $ac_c" 1>&6
-echo "configure:74817: checking for PQoidValue in -lpq" >&5
+echo "configure:74445: 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
@@ -74821,7 +74449,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74825 "configure"
+#line 74453 "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
@@ -74832,7 +74460,7 @@ int main() {
 PQoidValue()
 ; return 0; }
 EOF
-if { (eval echo configure:74836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74464: \"$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
@@ -74856,7 +74484,7 @@ else
 fi
 
   echo $ac_n "checking for PQclientEncoding in -lpq""... $ac_c" 1>&6
-echo "configure:74860: checking for PQclientEncoding in -lpq" >&5
+echo "configure:74488: 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
@@ -74864,7 +74492,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74868 "configure"
+#line 74496 "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
@@ -74875,7 +74503,7 @@ int main() {
 PQclientEncoding()
 ; return 0; }
 EOF
-if { (eval echo configure:74879: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74507: \"$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
@@ -74899,7 +74527,7 @@ else
 fi
 
   echo $ac_n "checking for PQparameterStatus in -lpq""... $ac_c" 1>&6
-echo "configure:74903: checking for PQparameterStatus in -lpq" >&5
+echo "configure:74531: 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
@@ -74907,7 +74535,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74911 "configure"
+#line 74539 "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
@@ -74918,7 +74546,7 @@ int main() {
 PQparameterStatus()
 ; return 0; }
 EOF
-if { (eval echo configure:74922: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74550: \"$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
@@ -74942,7 +74570,7 @@ else
 fi
 
   echo $ac_n "checking for PQprotocolVersion in -lpq""... $ac_c" 1>&6
-echo "configure:74946: checking for PQprotocolVersion in -lpq" >&5
+echo "configure:74574: 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
@@ -74950,7 +74578,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74954 "configure"
+#line 74582 "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
@@ -74961,7 +74589,7 @@ int main() {
 PQprotocolVersion()
 ; return 0; }
 EOF
-if { (eval echo configure:74965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74593: \"$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
@@ -74985,7 +74613,7 @@ else
 fi
 
   echo $ac_n "checking for PQtransactionStatus in -lpq""... $ac_c" 1>&6
-echo "configure:74989: checking for PQtransactionStatus in -lpq" >&5
+echo "configure:74617: 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
@@ -74993,7 +74621,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74997 "configure"
+#line 74625 "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
@@ -75004,7 +74632,7 @@ int main() {
 PQtransactionStatus()
 ; return 0; }
 EOF
-if { (eval echo configure:75008: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74636: \"$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
@@ -75028,7 +74656,7 @@ else
 fi
 
   echo $ac_n "checking for PQexecParams in -lpq""... $ac_c" 1>&6
-echo "configure:75032: checking for PQexecParams in -lpq" >&5
+echo "configure:74660: 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
@@ -75036,7 +74664,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75040 "configure"
+#line 74668 "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
@@ -75047,7 +74675,7 @@ int main() {
 PQexecParams()
 ; return 0; }
 EOF
-if { (eval echo configure:75051: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74679: \"$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
@@ -75071,7 +74699,7 @@ else
 fi
 
   echo $ac_n "checking for PQprepare in -lpq""... $ac_c" 1>&6
-echo "configure:75075: checking for PQprepare in -lpq" >&5
+echo "configure:74703: 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
@@ -75079,7 +74707,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75083 "configure"
+#line 74711 "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
@@ -75090,7 +74718,7 @@ int main() {
 PQprepare()
 ; return 0; }
 EOF
-if { (eval echo configure:75094: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74722: \"$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
@@ -75114,7 +74742,7 @@ else
 fi
 
   echo $ac_n "checking for PQexecPrepared in -lpq""... $ac_c" 1>&6
-echo "configure:75118: checking for PQexecPrepared in -lpq" >&5
+echo "configure:74746: 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
@@ -75122,7 +74750,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75126 "configure"
+#line 74754 "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
@@ -75133,7 +74761,7 @@ int main() {
 PQexecPrepared()
 ; return 0; }
 EOF
-if { (eval echo configure:75137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74765: \"$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
@@ -75157,7 +74785,7 @@ else
 fi
 
   echo $ac_n "checking for PQresultErrorField in -lpq""... $ac_c" 1>&6
-echo "configure:75161: checking for PQresultErrorField in -lpq" >&5
+echo "configure:74789: 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
@@ -75165,7 +74793,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75169 "configure"
+#line 74797 "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
@@ -75176,7 +74804,7 @@ int main() {
 PQresultErrorField()
 ; return 0; }
 EOF
-if { (eval echo configure:75180: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74808: \"$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
@@ -75200,7 +74828,7 @@ else
 fi
 
   echo $ac_n "checking for PQsendQueryParams in -lpq""... $ac_c" 1>&6
-echo "configure:75204: checking for PQsendQueryParams in -lpq" >&5
+echo "configure:74832: 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
@@ -75208,7 +74836,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75212 "configure"
+#line 74840 "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
@@ -75219,7 +74847,7 @@ int main() {
 PQsendQueryParams()
 ; return 0; }
 EOF
-if { (eval echo configure:75223: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74851: \"$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
@@ -75243,7 +74871,7 @@ else
 fi
 
   echo $ac_n "checking for PQsendPrepare in -lpq""... $ac_c" 1>&6
-echo "configure:75247: checking for PQsendPrepare in -lpq" >&5
+echo "configure:74875: 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
@@ -75251,7 +74879,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75255 "configure"
+#line 74883 "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
@@ -75262,7 +74890,7 @@ int main() {
 PQsendPrepare()
 ; return 0; }
 EOF
-if { (eval echo configure:75266: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74894: \"$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
@@ -75286,7 +74914,7 @@ else
 fi
 
   echo $ac_n "checking for PQsendQueryPrepared in -lpq""... $ac_c" 1>&6
-echo "configure:75290: checking for PQsendQueryPrepared in -lpq" >&5
+echo "configure:74918: 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
@@ -75294,7 +74922,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75298 "configure"
+#line 74926 "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
@@ -75305,7 +74933,7 @@ int main() {
 PQsendQueryPrepared()
 ; return 0; }
 EOF
-if { (eval echo configure:75309: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74937: \"$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
@@ -75329,7 +74957,7 @@ else
 fi
 
   echo $ac_n "checking for PQputCopyData in -lpq""... $ac_c" 1>&6
-echo "configure:75333: checking for PQputCopyData in -lpq" >&5
+echo "configure:74961: 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
@@ -75337,7 +74965,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75341 "configure"
+#line 74969 "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
@@ -75348,7 +74976,7 @@ int main() {
 PQputCopyData()
 ; return 0; }
 EOF
-if { (eval echo configure:75352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74980: \"$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
@@ -75372,7 +75000,7 @@ else
 fi
 
   echo $ac_n "checking for PQputCopyEnd in -lpq""... $ac_c" 1>&6
-echo "configure:75376: checking for PQputCopyEnd in -lpq" >&5
+echo "configure:75004: 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
@@ -75380,7 +75008,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75384 "configure"
+#line 75012 "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
@@ -75391,7 +75019,7 @@ int main() {
 PQputCopyEnd()
 ; return 0; }
 EOF
-if { (eval echo configure:75395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75023: \"$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
@@ -75415,7 +75043,7 @@ else
 fi
 
   echo $ac_n "checking for PQgetCopyData in -lpq""... $ac_c" 1>&6
-echo "configure:75419: checking for PQgetCopyData in -lpq" >&5
+echo "configure:75047: 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
@@ -75423,7 +75051,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75427 "configure"
+#line 75055 "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
@@ -75434,7 +75062,7 @@ int main() {
 PQgetCopyData()
 ; return 0; }
 EOF
-if { (eval echo configure:75438: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75066: \"$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
@@ -75458,7 +75086,7 @@ else
 fi
 
   echo $ac_n "checking for PQfreemem in -lpq""... $ac_c" 1>&6
-echo "configure:75462: checking for PQfreemem in -lpq" >&5
+echo "configure:75090: 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
@@ -75466,7 +75094,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75470 "configure"
+#line 75098 "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
@@ -75477,7 +75105,7 @@ int main() {
 PQfreemem()
 ; return 0; }
 EOF
-if { (eval echo configure:75481: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75109: \"$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
@@ -75501,7 +75129,7 @@ else
 fi
 
   echo $ac_n "checking for PQsetErrorVerbosity in -lpq""... $ac_c" 1>&6
-echo "configure:75505: checking for PQsetErrorVerbosity in -lpq" >&5
+echo "configure:75133: 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
@@ -75509,7 +75137,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75513 "configure"
+#line 75141 "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
@@ -75520,7 +75148,7 @@ int main() {
 PQsetErrorVerbosity()
 ; return 0; }
 EOF
-if { (eval echo configure:75524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75152: \"$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
@@ -75544,7 +75172,7 @@ else
 fi
 
   echo $ac_n "checking for PQftable in -lpq""... $ac_c" 1>&6
-echo "configure:75548: checking for PQftable in -lpq" >&5
+echo "configure:75176: 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
@@ -75552,7 +75180,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75556 "configure"
+#line 75184 "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
@@ -75563,7 +75191,7 @@ int main() {
 PQftable()
 ; return 0; }
 EOF
-if { (eval echo configure:75567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75195: \"$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
@@ -75587,7 +75215,7 @@ else
 fi
 
   echo $ac_n "checking for PQescapeStringConn in -lpq""... $ac_c" 1>&6
-echo "configure:75591: checking for PQescapeStringConn in -lpq" >&5
+echo "configure:75219: 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
@@ -75595,7 +75223,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75599 "configure"
+#line 75227 "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
@@ -75606,7 +75234,7 @@ int main() {
 PQescapeStringConn()
 ; return 0; }
 EOF
-if { (eval echo configure:75610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75238: \"$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
@@ -75630,7 +75258,7 @@ else
 fi
 
   echo $ac_n "checking for PQescapeByteaConn in -lpq""... $ac_c" 1>&6
-echo "configure:75634: checking for PQescapeByteaConn in -lpq" >&5
+echo "configure:75262: 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
@@ -75638,7 +75266,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75642 "configure"
+#line 75270 "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
@@ -75649,7 +75277,7 @@ int main() {
 PQescapeByteaConn()
 ; return 0; }
 EOF
-if { (eval echo configure:75653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75281: \"$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
@@ -75673,7 +75301,7 @@ else
 fi
 
   echo $ac_n "checking for pg_encoding_to_char in -lpq""... $ac_c" 1>&6
-echo "configure:75677: checking for pg_encoding_to_char in -lpq" >&5
+echo "configure:75305: 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
@@ -75681,7 +75309,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75685 "configure"
+#line 75313 "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
@@ -75692,7 +75320,7 @@ int main() {
 pg_encoding_to_char()
 ; return 0; }
 EOF
-if { (eval echo configure:75696: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75324: \"$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
@@ -75716,7 +75344,7 @@ else
 fi
 
   echo $ac_n "checking for lo_create in -lpq""... $ac_c" 1>&6
-echo "configure:75720: checking for lo_create in -lpq" >&5
+echo "configure:75348: 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
@@ -75724,7 +75352,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75728 "configure"
+#line 75356 "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
@@ -75735,7 +75363,7 @@ int main() {
 lo_create()
 ; return 0; }
 EOF
-if { (eval echo configure:75739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75367: \"$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
@@ -75759,7 +75387,7 @@ else
 fi
 
   echo $ac_n "checking for lo_import_with_oid in -lpq""... $ac_c" 1>&6
-echo "configure:75763: checking for lo_import_with_oid in -lpq" >&5
+echo "configure:75391: 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
@@ -75767,7 +75395,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75771 "configure"
+#line 75399 "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
@@ -75778,7 +75406,7 @@ int main() {
 lo_import_with_oid()
 ; return 0; }
 EOF
-if { (eval echo configure:75782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75410: \"$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
@@ -76238,7 +75866,7 @@ fi
 php_enable_phar=yes
 
 echo $ac_n "checking for phar archive support""... $ac_c" 1>&6
-echo "configure:76242: checking for phar archive support" >&5
+echo "configure:75870: 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"
@@ -76575,7 +76203,7 @@ EOF
   fi
 
   echo $ac_n "checking for phar openssl support""... $ac_c" 1>&6
-echo "configure:76579: checking for phar openssl support" >&5
+echo "configure:76207: checking for phar openssl support" >&5
   if test "$PHP_HASH_SHARED" != "yes"; then
     if test "$PHP_HASH" != "no"; then
       cat >> confdefs.h <<\EOF
@@ -76650,7 +76278,7 @@ fi
 php_enable_posix=yes
 
 echo $ac_n "checking whether to enable POSIX-like functions""... $ac_c" 1>&6
-echo "configure:76654: checking whether to enable POSIX-like functions" >&5
+echo "configure:76282: 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"
@@ -76995,17 +76623,17 @@ EOF
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:76999: checking for $ac_hdr" >&5
+echo "configure:76627: 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 77004 "configure"
+#line 76632 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:77009: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:76637: \"$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*
@@ -77035,12 +76663,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:77039: checking for $ac_func" >&5
+echo "configure:76667: 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 77044 "configure"
+#line 76672 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -77063,7 +76691,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:77067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76695: \"$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
@@ -77089,14 +76717,14 @@ done
 
 
   echo $ac_n "checking for working ttyname_r() implementation""... $ac_c" 1>&6
-echo "configure:77093: checking for working ttyname_r() implementation" >&5
+echo "configure:76721: 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 77100 "configure"
+#line 76728 "configure"
 #include "confdefs.h"
 
 #include <unistd.h>
@@ -77109,7 +76737,7 @@ int main(int argc, char *argv[])
 }
   
 EOF
-if { (eval echo configure:77113: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:76741: \"$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
@@ -77131,13 +76759,13 @@ fi
 
 
   echo $ac_n "checking for utsname.domainname""... $ac_c" 1>&6
-echo "configure:77135: checking for utsname.domainname" >&5
+echo "configure:76763: 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 77141 "configure"
+#line 76769 "configure"
 #include "confdefs.h"
 
       #define _GNU_SOURCE
@@ -77149,7 +76777,7 @@ int main() {
     
 ; return 0; }
 EOF
-if { (eval echo configure:77153: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:76781: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
       ac_cv_have_utsname_domainname=yes
@@ -77180,7 +76808,7 @@ fi
 php_with_pspell=no
 
 echo $ac_n "checking for PSPELL support""... $ac_c" 1>&6
-echo "configure:77184: checking for PSPELL support" >&5
+echo "configure:76812: checking for PSPELL support" >&5
 # Check whether --with-pspell or --without-pspell was given.
 if test "${with_pspell+set}" = set; then
   withval="$with_pspell"
@@ -77733,7 +77361,7 @@ EOF
   done
 
   echo $ac_n "checking for new_aspell_config in -laspell""... $ac_c" 1>&6
-echo "configure:77737: checking for new_aspell_config in -laspell" >&5
+echo "configure:77365: 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
@@ -77741,7 +77369,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-laspell  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 77745 "configure"
+#line 77373 "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
@@ -77752,7 +77380,7 @@ int main() {
 new_aspell_config()
 ; return 0; }
 EOF
-if { (eval echo configure:77756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:77384: \"$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
@@ -77926,7 +77554,7 @@ fi
 php_with_libedit=no
 
 echo $ac_n "checking for libedit readline replacement""... $ac_c" 1>&6
-echo "configure:77930: checking for libedit readline replacement" >&5
+echo "configure:77558: 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"
@@ -77974,7 +77602,7 @@ if test "$PHP_LIBEDIT" = "no"; then
 php_with_readline=no
 
 echo $ac_n "checking for readline support""... $ac_c" 1>&6
-echo "configure:77978: checking for readline support" >&5
+echo "configure:77606: checking for readline support" >&5
 # Check whether --with-readline or --without-readline was given.
 if test "${with_readline+set}" = set; then
   withval="$with_readline"
@@ -78063,7 +77691,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:78067: checking for tgetent in -lncurses" >&5
+echo "configure:77695: 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
@@ -78071,7 +77699,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lncurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 78075 "configure"
+#line 77703 "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
@@ -78082,7 +77710,7 @@ int main() {
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:78086: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:77714: \"$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
@@ -78127,7 +77755,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:78131: checking for tgetent in -ltermcap" >&5
+echo "configure:77759: 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
@@ -78135,7 +77763,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltermcap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 78139 "configure"
+#line 77767 "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
@@ -78146,7 +77774,7 @@ int main() {
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:78150: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:77778: \"$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
@@ -78293,7 +77921,7 @@ fi
   done
 
   echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6
-echo "configure:78297: checking for readline in -lreadline" >&5
+echo "configure:77925: 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
@@ -78301,7 +77929,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lreadline  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 78305 "configure"
+#line 77933 "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
@@ -78312,7 +77940,7 @@ int main() {
 readline()
 ; return 0; }
 EOF
-if { (eval echo configure:78316: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:77944: \"$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
@@ -78541,7 +78169,7 @@ fi
   done
 
   echo $ac_n "checking for rl_pending_input in -lreadline""... $ac_c" 1>&6
-echo "configure:78545: checking for rl_pending_input in -lreadline" >&5
+echo "configure:78173: 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
@@ -78549,7 +78177,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lreadline  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 78553 "configure"
+#line 78181 "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
@@ -78560,7 +78188,7 @@ int main() {
 rl_pending_input()
 ; return 0; }
 EOF
-if { (eval echo configure:78564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:78192: \"$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
@@ -78691,7 +78319,7 @@ fi
   done
 
   echo $ac_n "checking for rl_callback_read_char in -lreadline""... $ac_c" 1>&6
-echo "configure:78695: checking for rl_callback_read_char in -lreadline" >&5
+echo "configure:78323: 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
@@ -78699,7 +78327,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lreadline  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 78703 "configure"
+#line 78331 "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
@@ -78710,7 +78338,7 @@ int main() {
 rl_callback_read_char()
 ; return 0; }
 EOF
-if { (eval echo configure:78714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:78342: \"$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
@@ -78754,7 +78382,7 @@ EOF
 elif test "$PHP_LIBEDIT" != "no"; then
 
   for i in $PHP_LIBEDIT /usr/local /usr; do
-    test -f $i/include/readline/readline.h && LIBEDIT_DIR=$i && break
+    test -f $i/include/editline/readline.h && LIBEDIT_DIR=$i && break
   done
 
   if test -z "$LIBEDIT_DIR"; then
@@ -78794,7 +78422,7 @@ elif test "$PHP_LIBEDIT" != "no"; then
 
 
   echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:78798: checking for tgetent in -lncurses" >&5
+echo "configure:78426: 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
@@ -78802,7 +78430,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lncurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 78806 "configure"
+#line 78434 "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
@@ -78813,7 +78441,7 @@ int main() {
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:78817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:78445: \"$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
@@ -78857,7 +78485,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:78861: checking for tgetent in -ltermcap" >&5
+echo "configure:78489: 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
@@ -78865,7 +78493,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltermcap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 78869 "configure"
+#line 78497 "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
@@ -78876,7 +78504,7 @@ int main() {
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:78880: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:78508: \"$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
@@ -79022,7 +78650,7 @@ fi
   done
 
   echo $ac_n "checking for readline in -ledit""... $ac_c" 1>&6
-echo "configure:79026: checking for readline in -ledit" >&5
+echo "configure:78654: 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
@@ -79030,7 +78658,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ledit  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 79034 "configure"
+#line 78662 "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
@@ -79041,7 +78669,7 @@ int main() {
 readline()
 ; return 0; }
 EOF
-if { (eval echo configure:79045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:78673: \"$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
@@ -79182,12 +78810,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:79186: checking for $ac_func" >&5
+echo "configure:78814: 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 79191 "configure"
+#line 78819 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -79210,7 +78838,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:79214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:78842: \"$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
@@ -79536,7 +79164,7 @@ fi
 php_with_recode=no
 
 echo $ac_n "checking for recode support""... $ac_c" 1>&6
-echo "configure:79540: checking for recode support" >&5
+echo "configure:79168: checking for recode support" >&5
 # Check whether --with-recode or --without-recode was given.
 if test "${with_recode+set}" = set; then
   withval="$with_recode"
@@ -79703,7 +79331,7 @@ if test "$PHP_RECODE" != "no"; then
   done
 
   echo $ac_n "checking for recode_format_table in -lrecode""... $ac_c" 1>&6
-echo "configure:79707: checking for recode_format_table in -lrecode" >&5
+echo "configure:79335: 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
@@ -79711,7 +79339,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lrecode  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 79715 "configure"
+#line 79343 "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
@@ -79722,7 +79350,7 @@ int main() {
 recode_format_table()
 ; return 0; }
 EOF
-if { (eval echo configure:79726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:79354: \"$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
@@ -79852,7 +79480,7 @@ else
     LDFLAGS="$LDFLAGS -L$RECODE_DIR/$RECODE_LIB"
     LIBS="$LIBS -lrecode"
     cat > conftest.$ac_ext <<EOF
-#line 79856 "configure"
+#line 79484 "configure"
 #include "confdefs.h"
 
 char *program_name;
@@ -79863,7 +79491,7 @@ recode_format_table();
     
 ; return 0; }
 EOF
-if { (eval echo configure:79867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:79495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
       
@@ -80026,17 +79654,17 @@ EOF
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:80030: checking for $ac_hdr" >&5
+echo "configure:79658: 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 80035 "configure"
+#line 79663 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:80040: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:79668: \"$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*
@@ -80659,7 +80287,7 @@ EOF
 php_enable_session=yes
 
 echo $ac_n "checking whether to enable PHP sessions""... $ac_c" 1>&6
-echo "configure:80663: checking whether to enable PHP sessions" >&5
+echo "configure:80291: 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"
@@ -80706,7 +80334,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:80710: checking for mm support" >&5
+echo "configure:80338: checking for mm support" >&5
 # Check whether --with-mm or --without-mm was given.
 if test "${with_mm+set}" = set; then
   withval="$with_mm"
@@ -80731,7 +80359,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:80735: checking whether pwrite works" >&5
+echo "configure:80363: checking whether pwrite works" >&5
 if eval "test \"`echo '$''{'ac_cv_pwrite'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -80743,7 +80371,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 80747 "configure"
+#line 80375 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -80764,7 +80392,7 @@ else
 
   
 EOF
-if { (eval echo configure:80768: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:80396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_cv_pwrite=yes
@@ -80789,7 +80417,7 @@ fi
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 80793 "configure"
+#line 80421 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -80810,7 +80438,7 @@ ssize_t pwrite(int, void *, size_t, off64_t);
 
   
 EOF
-if { (eval echo configure:80814: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:80442: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_cv_pwrite=yes
@@ -80851,7 +80479,7 @@ EOF
 
   
   echo $ac_n "checking whether pread works""... $ac_c" 1>&6
-echo "configure:80855: checking whether pread works" >&5
+echo "configure:80483: checking whether pread works" >&5
 if eval "test \"`echo '$''{'ac_cv_pread'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -80864,7 +80492,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 80868 "configure"
+#line 80496 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -80884,7 +80512,7 @@ else
     }
   
 EOF
-if { (eval echo configure:80888: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:80516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_cv_pread=yes
@@ -80911,7 +80539,7 @@ fi
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 80915 "configure"
+#line 80543 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -80931,7 +80559,7 @@ ssize_t pread(int, void *, size_t, off64_t);
     }
   
 EOF
-if { (eval echo configure:80935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:80563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_cv_pread=yes
@@ -81476,7 +81104,7 @@ fi
 php_enable_shmop=no
 
 echo $ac_n "checking whether to enable shmop support""... $ac_c" 1>&6
-echo "configure:81480: checking whether to enable shmop support" >&5
+echo "configure:81108: 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"
@@ -81823,7 +81451,7 @@ fi
 php_enable_simplexml=yes
 
 echo $ac_n "checking whether to enable SimpleXML support""... $ac_c" 1>&6
-echo "configure:81827: checking whether to enable SimpleXML support" >&5
+echo "configure:81455: 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"
@@ -81871,7 +81499,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:81875: checking libxml2 install dir" >&5
+echo "configure:81503: 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"
@@ -81902,7 +81530,7 @@ if test "$PHP_SIMPLEXML" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:81906: checking for xml2-config path" >&5
+echo "configure:81534: 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
@@ -82060,7 +81688,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:82064: checking whether libxml build works" >&5
+echo "configure:81692: 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
@@ -82076,7 +81704,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 82080 "configure"
+#line 81708 "configure"
 #include "confdefs.h"
 
     
@@ -82087,7 +81715,7 @@ else
     }
   
 EOF
-if { (eval echo configure:82091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:81719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -82475,7 +82103,7 @@ fi
 php_with_snmp=no
 
 echo $ac_n "checking for SNMP support""... $ac_c" 1>&6
-echo "configure:82479: checking for SNMP support" >&5
+echo "configure:82107: checking for SNMP support" >&5
 # Check whether --with-snmp or --without-snmp was given.
 if test "${with_snmp+set}" = set; then
   withval="$with_snmp"
@@ -82522,7 +82150,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:82526: checking OpenSSL dir for SNMP" >&5
+echo "configure:82154: 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"
@@ -82548,7 +82176,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:82552: checking whether to enable UCD SNMP hack" >&5
+echo "configure:82180: 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"
@@ -82576,7 +82204,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:82580: checking for $ac_word" >&5
+echo "configure:82208: 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
@@ -82777,17 +82405,17 @@ EOF
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:82781: checking for $ac_hdr" >&5
+echo "configure:82409: 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 82786 "configure"
+#line 82414 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:82791: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:82419: \"$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*
@@ -82815,9 +82443,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:82819: checking for OpenSSL support in SNMP libraries" >&5
+echo "configure:82447: checking for OpenSSL support in SNMP libraries" >&5
       cat > conftest.$ac_ext <<EOF
-#line 82821 "configure"
+#line 82449 "configure"
 #include "confdefs.h"
 
 #include <ucd-snmp-config.h>
@@ -82872,7 +82500,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:82876: checking for $ac_word" >&5
+echo "configure:82504: 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
@@ -83077,9 +82705,9 @@ fi
     old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=-I$OPENSSL_INCDIR
     echo $ac_n "checking for OpenSSL version""... $ac_c" 1>&6
-echo "configure:83081: checking for OpenSSL version" >&5
+echo "configure:82709: checking for OpenSSL version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 83083 "configure"
+#line 82711 "configure"
 #include "confdefs.h"
 
 #include <openssl/opensslv.h>
@@ -83234,7 +82862,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for CRYPTO_free in -lcrypto""... $ac_c" 1>&6
-echo "configure:83238: checking for CRYPTO_free in -lcrypto" >&5
+echo "configure:82866: 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
@@ -83242,7 +82870,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 83246 "configure"
+#line 82874 "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
@@ -83253,7 +82881,7 @@ int main() {
 CRYPTO_free()
 ; return 0; }
 EOF
-if { (eval echo configure:83257: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:82885: \"$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
@@ -83410,7 +83038,7 @@ fi
   done
 
   echo $ac_n "checking for SSL_CTX_set_ssl_version in -lssl""... $ac_c" 1>&6
-echo "configure:83414: checking for SSL_CTX_set_ssl_version in -lssl" >&5
+echo "configure:83042: 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
@@ -83418,7 +83046,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 83422 "configure"
+#line 83050 "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
@@ -83429,7 +83057,7 @@ int main() {
 SSL_CTX_set_ssl_version()
 ; return 0; }
 EOF
-if { (eval echo configure:83433: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:83061: \"$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
@@ -83542,7 +83170,7 @@ else
     fi
 
     echo $ac_n "checking for kstat_read in -lkstat""... $ac_c" 1>&6
-echo "configure:83546: checking for kstat_read in -lkstat" >&5
+echo "configure:83174: 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
@@ -83550,7 +83178,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lkstat  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 83554 "configure"
+#line 83182 "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
@@ -83561,7 +83189,7 @@ int main() {
 kstat_read()
 ; return 0; }
 EOF
-if { (eval echo configure:83565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:83193: \"$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
@@ -83832,7 +83460,7 @@ fi
   done
 
   echo $ac_n "checking for snmp_parse_oid in -l$SNMP_LIBNAME""... $ac_c" 1>&6
-echo "configure:83836: checking for snmp_parse_oid in -l$SNMP_LIBNAME" >&5
+echo "configure:83464: 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
@@ -83840,7 +83468,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$SNMP_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 83844 "configure"
+#line 83472 "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
@@ -83851,7 +83479,7 @@ int main() {
 snmp_parse_oid()
 ; return 0; }
 EOF
-if { (eval echo configure:83855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:83483: \"$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
@@ -83985,7 +83613,7 @@ fi
   done
 
   echo $ac_n "checking for init_snmp in -l$SNMP_LIBNAME""... $ac_c" 1>&6
-echo "configure:83989: checking for init_snmp in -l$SNMP_LIBNAME" >&5
+echo "configure:83617: 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
@@ -83993,7 +83621,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$SNMP_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 83997 "configure"
+#line 83625 "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
@@ -84004,7 +83632,7 @@ int main() {
 init_snmp()
 ; return 0; }
 EOF
-if { (eval echo configure:84008: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:83636: \"$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
@@ -84351,7 +83979,7 @@ fi
 php_enable_soap=no
 
 echo $ac_n "checking whether to enable SOAP support""... $ac_c" 1>&6
-echo "configure:84355: checking whether to enable SOAP support" >&5
+echo "configure:83983: 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"
@@ -84399,7 +84027,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:84403: checking libxml2 install dir" >&5
+echo "configure:84031: 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"
@@ -84430,7 +84058,7 @@ if test "$PHP_SOAP" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:84434: checking for xml2-config path" >&5
+echo "configure:84062: 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
@@ -84588,7 +84216,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:84592: checking whether libxml build works" >&5
+echo "configure:84220: 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
@@ -84604,7 +84232,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 84608 "configure"
+#line 84236 "configure"
 #include "confdefs.h"
 
     
@@ -84615,7 +84243,7 @@ else
     }
   
 EOF
-if { (eval echo configure:84619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:84247: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -84965,7 +84593,7 @@ fi
 php_enable_sockets=no
 
 echo $ac_n "checking whether to enable sockets support""... $ac_c" 1>&6
-echo "configure:84969: checking whether to enable sockets support" >&5
+echo "configure:84597: 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"
@@ -85010,13 +84638,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:85014: checking for struct cmsghdr" >&5
+echo "configure:84642: 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 85020 "configure"
+#line 84648 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -85025,7 +84653,7 @@ int main() {
 struct cmsghdr s; s
 ; return 0; }
 EOF
-if { (eval echo configure:85029: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:84657: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_cmsghdr=yes
 else
@@ -85050,12 +84678,12 @@ EOF
   for ac_func in hstrerror socketpair
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:85054: checking for $ac_func" >&5
+echo "configure:84682: 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 85059 "configure"
+#line 84687 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -85078,7 +84706,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:85082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:84710: \"$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
@@ -85106,17 +84734,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:85110: checking for $ac_hdr" >&5
+echo "configure:84738: 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 85115 "configure"
+#line 84743 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:85120: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:84748: \"$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*
@@ -85143,7 +84771,7 @@ fi
 done
 
   cat > conftest.$ac_ext <<EOF
-#line 85147 "configure"
+#line 84775 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -85153,7 +84781,7 @@ int main() {
 static struct msghdr tp; int n = (int) tp.msg_flags; return n
 ; return 0; }
 EOF
-if { (eval echo configure:85157: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:84785: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -85463,11 +85091,31 @@ EOF
 
   fi
 
+  
+  
+    header_path=ext/sockets/
+    for header_file in php_sockets.h; do
+      hp_hf="$header_path/$header_file"
+      
+  
+  unique=`echo $hp_hf|$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 $hp_hf"
+      
+  fi
+
+    done 
+  
+
 fi
 
 
   echo $ac_n "checking whether zend_object_value is packed""... $ac_c" 1>&6
-echo "configure:85471: checking whether zend_object_value is packed" >&5
+echo "configure:85119: checking whether zend_object_value is packed" >&5
   old_CPPFLAGS=$CPPFLAGS
   CPPFLAGS="$INCLUDES -I$abs_srcdir $CPPFLAGS"
   if test "$cross_compiling" = yes; then
@@ -85477,7 +85125,7 @@ echo "configure:85471: checking whether zend_object_value is packed" >&5
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 85481 "configure"
+#line 85129 "configure"
 #include "confdefs.h"
 
 #include "Zend/zend_types.h"
@@ -85486,7 +85134,7 @@ int main(int argc, char **argv) {
 }
   
 EOF
-if { (eval echo configure:85490: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:85138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_result=1
@@ -85850,7 +85498,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:85854: checking for sqlite support" >&5
+echo "configure:85502: checking for sqlite support" >&5
 # Check whether --with-sqlite or --without-sqlite was given.
 if test "${with_sqlite+set}" = set; then
   withval="$with_sqlite"
@@ -85897,7 +85545,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:85901: checking whether to enable UTF-8 support in sqlite (default: ISO-8859-1)" >&5
+echo "configure:85549: 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"
@@ -85928,13 +85576,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:85932: checking for PDO includes" >&5
+echo "configure:85580: 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:85938: checking for PDO includes" >&5
+echo "configure:85586: 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
@@ -85968,7 +85616,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:85972: checking for sqlite files in default path" >&5
+echo "configure:85620: checking for sqlite files in default path" >&5
       for i in $SEARCH_PATH ; do
         if test -r $i/$SEARCH_FOR; then
           SQLITE_DIR=$i
@@ -86080,7 +85728,7 @@ echo "configure:85972: checking for sqlite files in default path" >&5
   done
 
   echo $ac_n "checking for sqlite_open in -lsqlite""... $ac_c" 1>&6
-echo "configure:86084: checking for sqlite_open in -lsqlite" >&5
+echo "configure:85732: 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
@@ -86088,7 +85736,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsqlite  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 86092 "configure"
+#line 85740 "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
@@ -86099,7 +85747,7 @@ int main() {
 sqlite_open()
 ; return 0; }
 EOF
-if { (eval echo configure:86103: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:85751: \"$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
@@ -86272,7 +85920,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:86276: checking for $ac_word" >&5
+echo "configure:85924: 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
@@ -86300,7 +85948,7 @@ fi
 
   if test "$LEMON"; then
     echo $ac_n "checking for lemon version""... $ac_c" 1>&6
-echo "configure:86304: checking for lemon version" >&5
+echo "configure:85952: 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
@@ -86713,7 +86361,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:86717: checking size of char *" >&5
+echo "configure:86365: 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
@@ -86721,7 +86369,7 @@ else
   ac_cv_sizeof_char_p=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 86725 "configure"
+#line 86373 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -86732,7 +86380,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:86736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:86384: \"$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
@@ -86794,12 +86442,12 @@ EOF
   for ac_func in usleep nanosleep
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:86798: checking for $ac_func" >&5
+echo "configure:86446: 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 86803 "configure"
+#line 86451 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -86822,7 +86470,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:86826: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:86474: \"$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
@@ -86850,17 +86498,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:86854: checking for $ac_hdr" >&5
+echo "configure:86502: 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 86859 "configure"
+#line 86507 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:86864: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:86512: \"$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*
@@ -86891,7 +86539,7 @@ fi
 
 
 echo $ac_n "checking whether flush should be called explicitly after a buffered io""... $ac_c" 1>&6
-echo "configure:86895: checking whether flush should be called explicitly after a buffered io" >&5
+echo "configure:86543: 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
@@ -86902,7 +86550,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 86906 "configure"
+#line 86554 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -86940,7 +86588,7 @@ int main(int argc, char **argv)
 }
 
 EOF
-if { (eval echo configure:86944: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:86592: \"$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
@@ -86968,7 +86616,7 @@ fi
 
 if test "$ac_cv_func_crypt" = "no"; then
   echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:86972: checking for crypt in -lcrypt" >&5
+echo "configure:86620: 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
@@ -86976,7 +86624,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 86980 "configure"
+#line 86628 "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
@@ -86987,7 +86635,7 @@ int main() {
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:86991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:86639: \"$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
@@ -87016,7 +86664,7 @@ fi
 fi
   
 echo $ac_n "checking for standard DES crypt""... $ac_c" 1>&6
-echo "configure:87020: checking for standard DES crypt" >&5
+echo "configure:86668: 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
@@ -87027,7 +86675,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 87031 "configure"
+#line 86679 "configure"
 #include "confdefs.h"
 
 #if HAVE_UNISTD_H
@@ -87046,7 +86694,7 @@ main() {
 #endif
 }
 EOF
-if { (eval echo configure:87050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:86698: \"$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
@@ -87067,7 +86715,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:87071: checking for extended DES crypt" >&5
+echo "configure:86719: 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
@@ -87078,7 +86726,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 87082 "configure"
+#line 86730 "configure"
 #include "confdefs.h"
 
 #if HAVE_UNISTD_H
@@ -87097,7 +86745,7 @@ main() {
 #endif
 }
 EOF
-if { (eval echo configure:87101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:86749: \"$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
@@ -87118,7 +86766,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:87122: checking for MD5 crypt" >&5
+echo "configure:86770: 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
@@ -87129,7 +86777,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 87133 "configure"
+#line 86781 "configure"
 #include "confdefs.h"
 
 #if HAVE_UNISTD_H
@@ -87157,7 +86805,7 @@ main() {
 #endif
 }
 EOF
-if { (eval echo configure:87161: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:86809: \"$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
@@ -87178,7 +86826,7 @@ fi
 echo "$ac_t""$ac_cv_crypt_md5" 1>&6
 
 echo $ac_n "checking for Blowfish crypt""... $ac_c" 1>&6
-echo "configure:87182: checking for Blowfish crypt" >&5
+echo "configure:86830: 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
@@ -87189,7 +86837,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 87193 "configure"
+#line 86841 "configure"
 #include "confdefs.h"
 
 #if HAVE_UNISTD_H
@@ -87214,7 +86862,7 @@ main() {
 #endif
 }
 EOF
-if { (eval echo configure:87218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:86866: \"$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
@@ -87234,7 +86882,204 @@ fi
 
 echo "$ac_t""$ac_cv_crypt_blowfish" 1>&6
 
+echo $ac_n "checking for SHA512 crypt""... $ac_c" 1>&6
+echo "configure:86887: 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
+  
+if test "$cross_compiling" = yes; then
+  
+  ac_cv_crypt_SHA512=no
+
+else
+  cat > conftest.$ac_ext <<EOF
+#line 86898 "configure"
+#include "confdefs.h"
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
+main() {
+#if HAVE_CRYPT
+    char salt[30], answer[80];
+    
+    salt[0]='$'; salt[1]='6'; salt[2]='$'; salt[3]='$'; salt[4]='b'; salt[5]='a'; salt[6]='r'; salt[7]='\0';
+    strcpy(answer, salt);
+    strcpy(&answer[29],"$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.");
+    exit (strcmp((char *)crypt("foo",salt),answer));
+#else
+	exit(0);
+#endif
+}
+EOF
+if { (eval echo configure:86922: \"$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
+
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  
+  ac_cv_crypt_SHA512=no
+
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_crypt_SHA512" 1>&6
+
+echo $ac_n "checking for SHA256 crypt""... $ac_c" 1>&6
+echo "configure:86943: 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
+  
+if test "$cross_compiling" = yes; then
+  
+  ac_cv_crypt_SHA256=no
+
+else
+  cat > conftest.$ac_ext <<EOF
+#line 86954 "configure"
+#include "confdefs.h"
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
+main() {
+#if HAVE_CRYPT
+    char salt[30], answer[80];
+    salt[0]='$'; salt[1]='5'; salt[2]='$'; salt[3]='$'; salt[4]='s'; salt[5]='a'; salt[6]='l'; salt[7]='t';  salt[8]='s'; salt[9]='t'; salt[10]='r'; salt[11]='i'; salt[12]='n'; salt[13]='g'; salt[14]='\0';    
+    strcat(salt,"");
+    strcpy(answer, salt);
+    strcpy(&answer[29], "$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5");
+    exit (strcmp((char *)crypt("foo",salt),answer));
+#else
+	exit(0);
+#endif
+}
+EOF
+if { (eval echo configure:86978: \"$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
+
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  
+  ac_cv_crypt_SHA256=no
+
+fi
+rm -fr conftest*
+fi
+
+fi
+
+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:87002: 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 87008 "configure"
+#include "confdefs.h"
+
+  
+int main() {
+
+    int align = __alignof__(int);
+  
+; return 0; }
+EOF
+if { (eval echo configure:87018: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  
+    ac_cv_alignof_exists=yes
+  
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  
+    ac_cv_alignof_exists=no
+  
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_alignof_exists" 1>&6
+  if test "$ac_cv_alignof_exists" = "yes"; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_ALIGNOF 1
+EOF
+
+  fi
+
+        echo $ac_n "checking whether the compiler supports aligned attribute""... $ac_c" 1>&6
+echo "configure:87043: 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 87049 "configure"
+#include "confdefs.h"
+
+  
+int main() {
+
+    unsigned char test[32] __attribute__ ((__aligned__ (__alignof__ (int))));
+  
+; return 0; }
+EOF
+if { (eval echo configure:87059: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  
+    ac_cv_attribute_aligned=yes
+  
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  
+    ac_cv_attribute_aligned=no
+  
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_attribute_aligned" 1>&6
+  if test "$ac_cv_attribute_aligned" = "yes"; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_ATTRIBUTE_ALIGNED 1
+EOF
+
+  fi
+    
+
   cat >> confdefs.h <<EOF
 #define PHP_USE_PHP_CRYPT_R 1
 EOF
@@ -87255,6 +87100,14 @@ EOF
 #define PHP_MD5_CRYPT 1
 EOF
 
+  cat >> confdefs.h <<EOF
+#define PHP_SHA512_CRYPT 1
+EOF
+
+  cat >> confdefs.h <<EOF
+#define PHP_SHA256_CRYPT 1
+EOF
+
 
   
   
@@ -87276,7 +87129,7 @@ EOF
 
 
   old_IFS=$IFS
-  for ac_src in crypt_freesec.c crypt_blowfish.c php_crypt_r.c; do
+  for ac_src in crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c; do
   
       IFS=.
       set $ac_src
@@ -87336,21 +87189,45 @@ EOF
 EOF
 
 
+  if test "$ac_cv_crypt_sha512" = "yes"; then
+    ac_result=1
+    ac_crypt_sha512=1
+  else
+    ac_result=0
+    ac_crypt_sha512=0
+  fi
+  cat >> confdefs.h <<EOF
+#define PHP_EXT_SHA512_CRYPT $ac_result
+EOF
+
+
+  if test "$ac_cv_crypt_sha256" = "yes"; then
+    ac_result=1
+    ac_crypt_sha256=1
+  else
+    ac_result=0
+    ac_crypt_sha256=0
+  fi
+  cat >> confdefs.h <<EOF
+#define PHP_EXT_SHA256_CRYPT $ac_result
+EOF
+
+
   cat >> confdefs.h <<EOF
 #define PHP_USE_PHP_CRYPT_R 0
 EOF
 
 fi
 
-for ac_func in getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan
+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:87349: checking for $ac_func" >&5
+echo "configure:87226: 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 87354 "configure"
+#line 87231 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -87373,7 +87250,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:87377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87254: \"$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
@@ -87398,7 +87275,7 @@ fi
 done
 
 echo $ac_n "checking for working fnmatch""... $ac_c" 1>&6
-echo "configure:87402: checking for working fnmatch" >&5
+echo "configure:87279: 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
@@ -87409,11 +87286,11 @@ if test "$cross_compiling" = yes; then
   ac_cv_func_fnmatch_works=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 87413 "configure"
+#line 87290 "configure"
 #include "confdefs.h"
 main() { exit (fnmatch ("a*", "abc", 0) != 0); }
 EOF
-if { (eval echo configure:87417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:87294: \"$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
@@ -87437,19 +87314,15 @@ fi
 	
 
 
-if eval "test \"`echo '$''{'php_can_support_proc_open'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  
 for ac_func in fork CreateProcess
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:87448: checking for $ac_func" >&5
+echo "configure:87321: 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 87453 "configure"
+#line 87326 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -87472,7 +87345,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:87476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87349: \"$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
@@ -87501,10 +87374,8 @@ php_can_support_proc_open=no
 fi
 done
 
-fi
-
 echo $ac_n "checking if your OS can spawn processes with inherited handles""... $ac_c" 1>&6
-echo "configure:87508: checking if your OS can spawn processes with inherited handles" >&5
+echo "configure:87379: 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
@@ -87528,12 +87399,12 @@ fi
   unset found
   
   echo $ac_n "checking for res_nsearch""... $ac_c" 1>&6
-echo "configure:87532: checking for res_nsearch" >&5
+echo "configure:87403: 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 87537 "configure"
+#line 87408 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char res_nsearch(); below.  */
@@ -87556,7 +87427,7 @@ res_nsearch();
 
 ; return 0; }
 EOF
-if { (eval echo configure:87560: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87431: \"$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
@@ -87574,12 +87445,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:87578: checking for __res_nsearch" >&5
+echo "configure:87449: 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 87583 "configure"
+#line 87454 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __res_nsearch(); below.  */
@@ -87602,7 +87473,7 @@ __res_nsearch();
 
 ; return 0; }
 EOF
-if { (eval echo configure:87606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87477: \"$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
@@ -87640,7 +87511,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:87644: checking for res_nsearch in -lresolv" >&5
+echo "configure:87515: 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
@@ -87648,7 +87519,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 87652 "configure"
+#line 87523 "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
@@ -87659,7 +87530,7 @@ int main() {
 res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:87663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87534: \"$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
@@ -87679,7 +87550,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_nsearch in -lresolv""... $ac_c" 1>&6
-echo "configure:87683: checking for __res_nsearch in -lresolv" >&5
+echo "configure:87554: 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
@@ -87687,7 +87558,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 87691 "configure"
+#line 87562 "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
@@ -87698,7 +87569,7 @@ int main() {
 __res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:87702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87573: \"$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
@@ -87730,11 +87601,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 87734 "configure"
+#line 87605 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:87738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:87609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -87776,7 +87647,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:87780: checking for res_nsearch in -lbind" >&5
+echo "configure:87651: 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
@@ -87784,7 +87655,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 87788 "configure"
+#line 87659 "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
@@ -87795,7 +87666,7 @@ int main() {
 res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:87799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87670: \"$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
@@ -87815,7 +87686,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_nsearch in -lbind""... $ac_c" 1>&6
-echo "configure:87819: checking for __res_nsearch in -lbind" >&5
+echo "configure:87690: 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
@@ -87823,7 +87694,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 87827 "configure"
+#line 87698 "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
@@ -87834,7 +87705,7 @@ int main() {
 __res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:87838: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87709: \"$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
@@ -87866,11 +87737,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 87870 "configure"
+#line 87741 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:87874: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:87745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -87912,7 +87783,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:87916: checking for res_nsearch in -lsocket" >&5
+echo "configure:87787: 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
@@ -87920,7 +87791,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 87924 "configure"
+#line 87795 "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
@@ -87931,7 +87802,7 @@ int main() {
 res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:87935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87806: \"$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
@@ -87951,7 +87822,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_nsearch in -lsocket""... $ac_c" 1>&6
-echo "configure:87955: checking for __res_nsearch in -lsocket" >&5
+echo "configure:87826: 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
@@ -87959,7 +87830,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 87963 "configure"
+#line 87834 "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
@@ -87970,7 +87841,7 @@ int main() {
 __res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:87974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87845: \"$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
@@ -88002,11 +87873,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 88006 "configure"
+#line 87877 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:88010: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:87881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -88063,12 +87934,12 @@ EOF
   unset found
   
   echo $ac_n "checking for dns_search""... $ac_c" 1>&6
-echo "configure:88067: checking for dns_search" >&5
+echo "configure:87938: 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 88072 "configure"
+#line 87943 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dns_search(); below.  */
@@ -88091,7 +87962,7 @@ dns_search();
 
 ; return 0; }
 EOF
-if { (eval echo configure:88095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87966: \"$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
@@ -88109,12 +87980,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:88113: checking for __dns_search" >&5
+echo "configure:87984: 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 88118 "configure"
+#line 87989 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __dns_search(); below.  */
@@ -88137,7 +88008,7 @@ __dns_search();
 
 ; return 0; }
 EOF
-if { (eval echo configure:88141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88012: \"$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
@@ -88175,7 +88046,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:88179: checking for dns_search in -lresolv" >&5
+echo "configure:88050: 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
@@ -88183,7 +88054,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88187 "configure"
+#line 88058 "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
@@ -88194,7 +88065,7 @@ int main() {
 dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:88198: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88069: \"$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
@@ -88214,7 +88085,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dns_search in -lresolv""... $ac_c" 1>&6
-echo "configure:88218: checking for __dns_search in -lresolv" >&5
+echo "configure:88089: 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
@@ -88222,7 +88093,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88226 "configure"
+#line 88097 "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
@@ -88233,7 +88104,7 @@ int main() {
 __dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:88237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88108: \"$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
@@ -88265,11 +88136,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 88269 "configure"
+#line 88140 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:88273: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88144: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -88311,7 +88182,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:88315: checking for dns_search in -lbind" >&5
+echo "configure:88186: 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
@@ -88319,7 +88190,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88323 "configure"
+#line 88194 "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
@@ -88330,7 +88201,7 @@ int main() {
 dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:88334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88205: \"$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
@@ -88350,7 +88221,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dns_search in -lbind""... $ac_c" 1>&6
-echo "configure:88354: checking for __dns_search in -lbind" >&5
+echo "configure:88225: 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
@@ -88358,7 +88229,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88362 "configure"
+#line 88233 "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
@@ -88369,7 +88240,7 @@ int main() {
 __dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:88373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88244: \"$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,11 +88272,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 88405 "configure"
+#line 88276 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:88409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -88447,7 +88318,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:88451: checking for dns_search in -lsocket" >&5
+echo "configure:88322: 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
@@ -88455,7 +88326,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88459 "configure"
+#line 88330 "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
@@ -88466,7 +88337,7 @@ int main() {
 dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:88470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88341: \"$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
@@ -88486,7 +88357,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dns_search in -lsocket""... $ac_c" 1>&6
-echo "configure:88490: checking for __dns_search in -lsocket" >&5
+echo "configure:88361: 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
@@ -88494,7 +88365,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88498 "configure"
+#line 88369 "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
@@ -88505,7 +88376,7 @@ int main() {
 __dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:88509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88380: \"$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
@@ -88537,11 +88408,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 88541 "configure"
+#line 88412 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:88545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88416: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -88598,12 +88469,12 @@ EOF
   unset found
   
   echo $ac_n "checking for dn_expand""... $ac_c" 1>&6
-echo "configure:88602: checking for dn_expand" >&5
+echo "configure:88473: 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 88607 "configure"
+#line 88478 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dn_expand(); below.  */
@@ -88626,7 +88497,7 @@ dn_expand();
 
 ; return 0; }
 EOF
-if { (eval echo configure:88630: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88501: \"$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
@@ -88644,12 +88515,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:88648: checking for __dn_expand" >&5
+echo "configure:88519: 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 88653 "configure"
+#line 88524 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __dn_expand(); below.  */
@@ -88672,7 +88543,7 @@ __dn_expand();
 
 ; return 0; }
 EOF
-if { (eval echo configure:88676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88547: \"$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
@@ -88710,7 +88581,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:88714: checking for dn_expand in -lresolv" >&5
+echo "configure:88585: 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
@@ -88718,7 +88589,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88722 "configure"
+#line 88593 "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
@@ -88729,7 +88600,7 @@ int main() {
 dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:88733: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88604: \"$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
@@ -88749,7 +88620,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_expand in -lresolv""... $ac_c" 1>&6
-echo "configure:88753: checking for __dn_expand in -lresolv" >&5
+echo "configure:88624: 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
@@ -88757,7 +88628,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88761 "configure"
+#line 88632 "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
@@ -88768,7 +88639,7 @@ int main() {
 __dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:88772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88643: \"$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
@@ -88800,11 +88671,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 88804 "configure"
+#line 88675 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:88808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -88846,7 +88717,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:88850: checking for dn_expand in -lbind" >&5
+echo "configure:88721: 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
@@ -88854,7 +88725,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88858 "configure"
+#line 88729 "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
@@ -88865,7 +88736,7 @@ int main() {
 dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:88869: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88740: \"$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
@@ -88885,7 +88756,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_expand in -lbind""... $ac_c" 1>&6
-echo "configure:88889: checking for __dn_expand in -lbind" >&5
+echo "configure:88760: 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
@@ -88893,7 +88764,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88897 "configure"
+#line 88768 "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
@@ -88904,7 +88775,7 @@ int main() {
 __dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:88908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88779: \"$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
@@ -88936,11 +88807,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 88940 "configure"
+#line 88811 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:88944: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88815: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -88982,7 +88853,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:88986: checking for dn_expand in -lsocket" >&5
+echo "configure:88857: 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
@@ -88990,7 +88861,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88994 "configure"
+#line 88865 "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
@@ -89001,7 +88872,7 @@ int main() {
 dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:89005: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88876: \"$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
@@ -89021,7 +88892,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_expand in -lsocket""... $ac_c" 1>&6
-echo "configure:89025: checking for __dn_expand in -lsocket" >&5
+echo "configure:88896: 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
@@ -89029,7 +88900,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89033 "configure"
+#line 88904 "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
@@ -89040,7 +88911,7 @@ int main() {
 __dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:89044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88915: \"$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
@@ -89072,11 +88943,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 89076 "configure"
+#line 88947 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:89080: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88951: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -89133,12 +89004,12 @@ EOF
   unset found
   
   echo $ac_n "checking for dn_skipname""... $ac_c" 1>&6
-echo "configure:89137: checking for dn_skipname" >&5
+echo "configure:89008: 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 89142 "configure"
+#line 89013 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dn_skipname(); below.  */
@@ -89161,7 +89032,7 @@ dn_skipname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:89165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89036: \"$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
@@ -89179,12 +89050,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:89183: checking for __dn_skipname" >&5
+echo "configure:89054: 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 89188 "configure"
+#line 89059 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __dn_skipname(); below.  */
@@ -89207,7 +89078,7 @@ __dn_skipname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:89211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89082: \"$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
@@ -89245,7 +89116,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:89249: checking for dn_skipname in -lresolv" >&5
+echo "configure:89120: 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
@@ -89253,7 +89124,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89257 "configure"
+#line 89128 "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
@@ -89264,7 +89135,7 @@ int main() {
 dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:89268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89139: \"$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
@@ -89284,7 +89155,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_skipname in -lresolv""... $ac_c" 1>&6
-echo "configure:89288: checking for __dn_skipname in -lresolv" >&5
+echo "configure:89159: 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
@@ -89292,7 +89163,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89296 "configure"
+#line 89167 "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
@@ -89303,7 +89174,7 @@ int main() {
 __dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:89307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89178: \"$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
@@ -89335,11 +89206,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 89339 "configure"
+#line 89210 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:89343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:89214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -89381,7 +89252,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:89385: checking for dn_skipname in -lbind" >&5
+echo "configure:89256: 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
@@ -89389,7 +89260,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89393 "configure"
+#line 89264 "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
@@ -89400,7 +89271,7 @@ int main() {
 dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:89404: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89275: \"$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
@@ -89420,7 +89291,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_skipname in -lbind""... $ac_c" 1>&6
-echo "configure:89424: checking for __dn_skipname in -lbind" >&5
+echo "configure:89295: 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
@@ -89428,7 +89299,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89432 "configure"
+#line 89303 "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
@@ -89439,7 +89310,7 @@ int main() {
 __dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:89443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89314: \"$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
@@ -89471,11 +89342,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 89475 "configure"
+#line 89346 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:89479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:89350: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -89517,7 +89388,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:89521: checking for dn_skipname in -lsocket" >&5
+echo "configure:89392: 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
@@ -89525,7 +89396,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89529 "configure"
+#line 89400 "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
@@ -89536,7 +89407,7 @@ int main() {
 dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:89540: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89411: \"$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
@@ -89556,7 +89427,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_skipname in -lsocket""... $ac_c" 1>&6
-echo "configure:89560: checking for __dn_skipname in -lsocket" >&5
+echo "configure:89431: 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
@@ -89564,7 +89435,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89568 "configure"
+#line 89439 "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
@@ -89575,7 +89446,7 @@ int main() {
 __dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:89579: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89450: \"$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
@@ -89607,11 +89478,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 89611 "configure"
+#line 89482 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:89615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:89486: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -89670,12 +89541,12 @@ EOF
   unset found
   
   echo $ac_n "checking for res_search""... $ac_c" 1>&6
-echo "configure:89674: checking for res_search" >&5
+echo "configure:89545: 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 89679 "configure"
+#line 89550 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char res_search(); below.  */
@@ -89698,7 +89569,7 @@ res_search();
 
 ; return 0; }
 EOF
-if { (eval echo configure:89702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89573: \"$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
@@ -89716,12 +89587,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:89720: checking for __res_search" >&5
+echo "configure:89591: 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 89725 "configure"
+#line 89596 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __res_search(); below.  */
@@ -89744,7 +89615,7 @@ __res_search();
 
 ; return 0; }
 EOF
-if { (eval echo configure:89748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89619: \"$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
@@ -89782,7 +89653,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:89786: checking for res_search in -lresolv" >&5
+echo "configure:89657: 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
@@ -89790,7 +89661,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89794 "configure"
+#line 89665 "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
@@ -89801,7 +89672,7 @@ int main() {
 res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:89805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89676: \"$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
@@ -89821,7 +89692,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_search in -lresolv""... $ac_c" 1>&6
-echo "configure:89825: checking for __res_search in -lresolv" >&5
+echo "configure:89696: 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
@@ -89829,7 +89700,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89833 "configure"
+#line 89704 "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
@@ -89840,7 +89711,7 @@ int main() {
 __res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:89844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89715: \"$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
@@ -89872,11 +89743,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 89876 "configure"
+#line 89747 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:89880: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:89751: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -89918,7 +89789,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:89922: checking for res_search in -lbind" >&5
+echo "configure:89793: 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
@@ -89926,7 +89797,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89930 "configure"
+#line 89801 "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
@@ -89937,7 +89808,7 @@ int main() {
 res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:89941: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89812: \"$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
@@ -89957,7 +89828,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_search in -lbind""... $ac_c" 1>&6
-echo "configure:89961: checking for __res_search in -lbind" >&5
+echo "configure:89832: 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
@@ -89965,7 +89836,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89969 "configure"
+#line 89840 "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
@@ -89976,7 +89847,7 @@ int main() {
 __res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:89980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89851: \"$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
@@ -90008,11 +89879,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 90012 "configure"
+#line 89883 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:90016: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:89887: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -90054,7 +89925,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:90058: checking for res_search in -lsocket" >&5
+echo "configure:89929: 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
@@ -90062,7 +89933,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90066 "configure"
+#line 89937 "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
@@ -90073,7 +89944,7 @@ int main() {
 res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:90077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89948: \"$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
@@ -90093,7 +89964,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_search in -lsocket""... $ac_c" 1>&6
-echo "configure:90097: checking for __res_search in -lsocket" >&5
+echo "configure:89968: 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
@@ -90101,7 +89972,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90105 "configure"
+#line 89976 "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
@@ -90112,7 +89983,7 @@ int main() {
 __res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:90116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89987: \"$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
@@ -90144,11 +90015,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 90148 "configure"
+#line 90019 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:90152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90023: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -90201,7 +90072,7 @@ EOF
 
 
 echo $ac_n "checking whether atof() accepts NAN""... $ac_c" 1>&6
-echo "configure:90205: checking whether atof() accepts NAN" >&5
+echo "configure:90076: 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
@@ -90212,7 +90083,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 90216 "configure"
+#line 90087 "configure"
 #include "confdefs.h"
 
 #include <math.h>
@@ -90232,7 +90103,7 @@ int main(int argc, char** argv)
 }
 
 EOF
-if { (eval echo configure:90236: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90107: \"$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
@@ -90259,7 +90130,7 @@ EOF
 fi
 
 echo $ac_n "checking whether atof() accepts INF""... $ac_c" 1>&6
-echo "configure:90263: checking whether atof() accepts INF" >&5
+echo "configure:90134: 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
@@ -90270,7 +90141,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 90274 "configure"
+#line 90145 "configure"
 #include "confdefs.h"
 
 #include <math.h>
@@ -90293,7 +90164,7 @@ int main(int argc, char** argv)
 }
 
 EOF
-if { (eval echo configure:90297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90168: \"$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
@@ -90320,7 +90191,7 @@ EOF
 fi
 
 echo $ac_n "checking whether HUGE_VAL == INF""... $ac_c" 1>&6
-echo "configure:90324: checking whether HUGE_VAL == INF" >&5
+echo "configure:90195: 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
@@ -90331,7 +90202,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 90335 "configure"
+#line 90206 "configure"
 #include "confdefs.h"
 
 #include <math.h>
@@ -90354,7 +90225,7 @@ int main(int argc, char** argv)
 }
 
 EOF
-if { (eval echo configure:90358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90229: \"$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
@@ -90381,7 +90252,7 @@ EOF
 fi
 
 echo $ac_n "checking whether HUGE_VAL + -HUGEVAL == NAN""... $ac_c" 1>&6
-echo "configure:90385: checking whether HUGE_VAL + -HUGEVAL == NAN" >&5
+echo "configure:90256: 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
@@ -90392,7 +90263,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 90396 "configure"
+#line 90267 "configure"
 #include "confdefs.h"
 
 #include <math.h>
@@ -90417,7 +90288,7 @@ int main(int argc, char** argv)
 }
 
 EOF
-if { (eval echo configure:90421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90292: \"$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
@@ -90444,13 +90315,13 @@ EOF
 fi
 
 echo $ac_n "checking whether strptime() declaration fails""... $ac_c" 1>&6
-echo "configure:90448: checking whether strptime() declaration fails" >&5
+echo "configure:90319: 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 90454 "configure"
+#line 90325 "configure"
 #include "confdefs.h"
 
 #include <time.h>
@@ -90466,7 +90337,7 @@ int strptime(const char *s, const char *format, struct tm *tm);
 
 ; return 0; }
 EOF
-if { (eval echo configure:90470: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:90341: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   ac_cv_strptime_decl_fails=no
@@ -90494,17 +90365,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:90498: checking for $ac_hdr" >&5
+echo "configure:90369: 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 90503 "configure"
+#line 90374 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:90508: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:90379: \"$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*
@@ -90533,12 +90404,12 @@ done
 for ac_func in mblen
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:90537: checking for $ac_func" >&5
+echo "configure:90408: 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 90542 "configure"
+#line 90413 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -90561,7 +90432,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:90565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90436: \"$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
@@ -90588,12 +90459,12 @@ done
 for ac_func in mbrlen mbsinit
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:90592: checking for $ac_func" >&5
+echo "configure:90463: 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 90597 "configure"
+#line 90468 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -90616,7 +90487,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:90620: \"$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_func_$ac_func=yes"
 else
@@ -90641,13 +90512,13 @@ fi
 done
 
 echo $ac_n "checking for mbstate_t""... $ac_c" 1>&6
-echo "configure:90645: checking for mbstate_t" >&5
+echo "configure:90516: 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 90651 "configure"
+#line 90522 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_WCHAR_H
@@ -90660,7 +90531,7 @@ int __tmp__() { mbstate_t a; }
 
 ; return 0; }
 EOF
-if { (eval echo configure:90664: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:90535: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   ac_cv_type_mbstate_t=yes
@@ -91047,7 +90918,7 @@ EOF
 php_with_sybase_ct=no
 
 echo $ac_n "checking for Sybase-CT support""... $ac_c" 1>&6
-echo "configure:91051: checking for Sybase-CT support" >&5
+echo "configure:90922: 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"
@@ -91697,7 +91568,7 @@ EOF
   done
 
   echo $ac_n "checking for netg_errstr in -ltcl""... $ac_c" 1>&6
-echo "configure:91701: checking for netg_errstr in -ltcl" >&5
+echo "configure:91572: 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
@@ -91705,7 +91576,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltcl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91709 "configure"
+#line 91580 "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
@@ -91716,7 +91587,7 @@ int main() {
 netg_errstr()
 ; return 0; }
 EOF
-if { (eval echo configure:91720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:91591: \"$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
@@ -91891,7 +91762,7 @@ fi
   done
 
   echo $ac_n "checking for insck__getVdate in -linsck""... $ac_c" 1>&6
-echo "configure:91895: checking for insck__getVdate in -linsck" >&5
+echo "configure:91766: 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
@@ -91899,7 +91770,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-linsck  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91903 "configure"
+#line 91774 "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
@@ -91910,7 +91781,7 @@ int main() {
 insck__getVdate()
 ; return 0; }
 EOF
-if { (eval echo configure:91914: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:91785: \"$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
@@ -92058,7 +91929,7 @@ fi
   done
 
   echo $ac_n "checking for bsd_tcp in -linsck""... $ac_c" 1>&6
-echo "configure:92062: checking for bsd_tcp in -linsck" >&5
+echo "configure:91933: 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
@@ -92066,7 +91937,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-linsck  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 92070 "configure"
+#line 91941 "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
@@ -92077,7 +91948,7 @@ int main() {
 bsd_tcp()
 ; return 0; }
 EOF
-if { (eval echo configure:92081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:91952: \"$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
@@ -92137,7 +92008,7 @@ fi
 php_enable_sysvmsg=no
 
 echo $ac_n "checking whether to enable System V IPC support""... $ac_c" 1>&6
-echo "configure:92141: checking whether to enable System V IPC support" >&5
+echo "configure:92012: 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"
@@ -92183,17 +92054,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:92187: checking for sys/msg.h" >&5
+echo "configure:92058: 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 92192 "configure"
+#line 92063 "configure"
 #include "confdefs.h"
 #include <sys/msg.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:92197: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:92068: \"$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*
@@ -92520,7 +92391,7 @@ fi
 php_enable_sysvsem=no
 
 echo $ac_n "checking whether to enable System V semaphore support""... $ac_c" 1>&6
-echo "configure:92524: checking whether to enable System V semaphore support" >&5
+echo "configure:92395: 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"
@@ -92861,12 +92732,12 @@ EOF
 EOF
 
  echo $ac_n "checking for union semun""... $ac_c" 1>&6
-echo "configure:92865: checking for union semun" >&5
+echo "configure:92736: 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 92870 "configure"
+#line 92741 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -92877,7 +92748,7 @@ int main() {
 union semun x;
 ; return 0; }
 EOF
-if { (eval echo configure:92881: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:92752: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
      php_cv_semun=yes
@@ -92913,7 +92784,7 @@ fi
 php_enable_sysvshm=no
 
 echo $ac_n "checking whether to enable System V shared memory support""... $ac_c" 1>&6
-echo "configure:92917: checking whether to enable System V shared memory support" >&5
+echo "configure:92788: 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"
@@ -93260,7 +93131,7 @@ fi
 php_with_tidy=no
 
 echo $ac_n "checking for TIDY support""... $ac_c" 1>&6
-echo "configure:93264: checking for TIDY support" >&5
+echo "configure:93135: checking for TIDY support" >&5
 # Check whether --with-tidy or --without-tidy was given.
 if test "${with_tidy+set}" = set; then
   withval="$with_tidy"
@@ -93552,7 +93423,7 @@ if test "$PHP_TIDY" != "no"; then
   done
 
   echo $ac_n "checking for tidyOptGetDoc in -ltidy""... $ac_c" 1>&6
-echo "configure:93556: checking for tidyOptGetDoc in -ltidy" >&5
+echo "configure:93427: 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
@@ -93560,7 +93431,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltidy  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 93564 "configure"
+#line 93435 "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
@@ -93571,7 +93442,7 @@ int main() {
 tidyOptGetDoc()
 ; return 0; }
 EOF
-if { (eval echo configure:93575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:93446: \"$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
@@ -93915,7 +93786,7 @@ fi
 php_enable_tokenizer=yes
 
 echo $ac_n "checking whether to enable tokenizer support""... $ac_c" 1>&6
-echo "configure:93919: checking whether to enable tokenizer support" >&5
+echo "configure:93790: 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"
@@ -94264,7 +94135,7 @@ fi
 php_enable_wddx=no
 
 echo $ac_n "checking whether to enable WDDX support""... $ac_c" 1>&6
-echo "configure:94268: checking whether to enable WDDX support" >&5
+echo "configure:94139: 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"
@@ -94312,7 +94183,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:94316: checking libxml2 install dir" >&5
+echo "configure:94187: 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"
@@ -94339,7 +94210,7 @@ fi
 php_with_libexpat_dir=no
 
 echo $ac_n "checking libexpat dir for WDDX""... $ac_c" 1>&6
-echo "configure:94343: checking libexpat dir for WDDX" >&5
+echo "configure:94214: 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"
@@ -94370,7 +94241,7 @@ if test "$PHP_WDDX" != "no"; then
 
     
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:94374: checking for xml2-config path" >&5
+echo "configure:94245: 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
@@ -94528,7 +94399,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:94532: checking whether libxml build works" >&5
+echo "configure:94403: 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
@@ -94544,7 +94415,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 94548 "configure"
+#line 94419 "configure"
 #include "confdefs.h"
 
     
@@ -94555,7 +94426,7 @@ else
     }
   
 EOF
-if { (eval echo configure:94559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:94430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -95122,7 +94993,7 @@ fi
 php_enable_xml=yes
 
 echo $ac_n "checking whether to enable XML support""... $ac_c" 1>&6
-echo "configure:95126: checking whether to enable XML support" >&5
+echo "configure:94997: 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"
@@ -95170,7 +95041,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:95174: checking libxml2 install dir" >&5
+echo "configure:95045: 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"
@@ -95197,7 +95068,7 @@ fi
 php_with_libexpat_dir=no
 
 echo $ac_n "checking libexpat install dir""... $ac_c" 1>&6
-echo "configure:95201: checking libexpat install dir" >&5
+echo "configure:95072: 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"
@@ -95229,7 +95100,7 @@ if test "$PHP_XML" != "no"; then
 
     
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:95233: checking for xml2-config path" >&5
+echo "configure:95104: 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
@@ -95387,7 +95258,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:95391: checking whether libxml build works" >&5
+echo "configure:95262: 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
@@ -95403,7 +95274,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 95407 "configure"
+#line 95278 "configure"
 #include "confdefs.h"
 
     
@@ -95414,7 +95285,7 @@ else
     }
   
 EOF
-if { (eval echo configure:95418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:95289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -95950,7 +95821,7 @@ fi
 php_enable_xmlreader=yes
 
 echo $ac_n "checking whether to enable XMLReader support""... $ac_c" 1>&6
-echo "configure:95954: checking whether to enable XMLReader support" >&5
+echo "configure:95825: 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"
@@ -95998,7 +95869,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:96002: checking libxml2 install dir" >&5
+echo "configure:95873: 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"
@@ -96029,7 +95900,7 @@ if test "$PHP_XMLREADER" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:96033: checking for xml2-config path" >&5
+echo "configure:95904: 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
@@ -96187,7 +96058,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:96191: checking whether libxml build works" >&5
+echo "configure:96062: 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
@@ -96203,7 +96074,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 96207 "configure"
+#line 96078 "configure"
 #include "confdefs.h"
 
     
@@ -96214,7 +96085,7 @@ else
     }
   
 EOF
-if { (eval echo configure:96218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:96089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -96596,7 +96467,7 @@ fi
 php_with_xmlrpc=no
 
 echo $ac_n "checking for XMLRPC-EPI support""... $ac_c" 1>&6
-echo "configure:96600: checking for XMLRPC-EPI support" >&5
+echo "configure:96471: 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"
@@ -96644,7 +96515,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:96648: checking libxml2 install dir" >&5
+echo "configure:96519: 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"
@@ -96671,7 +96542,7 @@ fi
 php_with_libexpat_dir=no
 
 echo $ac_n "checking libexpat dir for XMLRPC-EPI""... $ac_c" 1>&6
-echo "configure:96675: checking libexpat dir for XMLRPC-EPI" >&5
+echo "configure:96546: 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"
@@ -96697,7 +96568,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:96701: checking iconv dir for XMLRPC-EPI" >&5
+echo "configure:96572: 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"
@@ -96756,7 +96627,7 @@ EOF
 
     
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:96760: checking for xml2-config path" >&5
+echo "configure:96631: 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
@@ -96914,7 +96785,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:96918: checking whether libxml build works" >&5
+echo "configure:96789: 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
@@ -96930,7 +96801,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 96934 "configure"
+#line 96805 "configure"
 #include "confdefs.h"
 
     
@@ -96941,7 +96812,7 @@ else
     }
   
 EOF
-if { (eval echo configure:96945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:96816: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -97209,12 +97080,12 @@ EOF
 
         if test "$PHP_ICONV" = "yes"; then
     echo $ac_n "checking for iconv""... $ac_c" 1>&6
-echo "configure:97213: checking for iconv" >&5
+echo "configure:97084: 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 97218 "configure"
+#line 97089 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char iconv(); below.  */
@@ -97237,7 +97108,7 @@ iconv();
 
 ; return 0; }
 EOF
-if { (eval echo configure:97241: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:97112: \"$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
@@ -97258,12 +97129,12 @@ else
   echo "$ac_t""no" 1>&6
 
       echo $ac_n "checking for libiconv""... $ac_c" 1>&6
-echo "configure:97262: checking for libiconv" >&5
+echo "configure:97133: 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 97267 "configure"
+#line 97138 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char libiconv(); below.  */
@@ -97286,7 +97157,7 @@ libiconv();
 
 ; return 0; }
 EOF
-if { (eval echo configure:97290: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:97161: \"$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
@@ -97442,7 +97313,7 @@ EOF
   done
 
   echo $ac_n "checking for libiconv in -l$iconv_lib_name""... $ac_c" 1>&6
-echo "configure:97446: checking for libiconv in -l$iconv_lib_name" >&5
+echo "configure:97317: 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
@@ -97450,7 +97321,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$iconv_lib_name  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 97454 "configure"
+#line 97325 "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
@@ -97461,7 +97332,7 @@ int main() {
 libiconv()
 ; return 0; }
 EOF
-if { (eval echo configure:97465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:97336: \"$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
@@ -97595,7 +97466,7 @@ else
   done
 
   echo $ac_n "checking for iconv in -l$iconv_lib_name""... $ac_c" 1>&6
-echo "configure:97599: checking for iconv in -l$iconv_lib_name" >&5
+echo "configure:97470: 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
@@ -97603,7 +97474,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$iconv_lib_name  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 97607 "configure"
+#line 97478 "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
@@ -97614,7 +97485,7 @@ int main() {
 iconv()
 ; return 0; }
 EOF
-if { (eval echo configure:97618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:97489: \"$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
@@ -97804,7 +97675,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:97808: checking for $ac_word" >&5
+echo "configure:97679: 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
@@ -97832,21 +97703,21 @@ else
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:97836: checking for inline" >&5
+echo "configure:97707: 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 97843 "configure"
+#line 97714 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:97850: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:97721: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -97884,12 +97755,12 @@ EOF
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:97888: checking for ANSI C header files" >&5
+echo "configure:97759: 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 97893 "configure"
+#line 97764 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -97897,7 +97768,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:97901: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:97772: \"$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*
@@ -97914,7 +97785,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 97918 "configure"
+#line 97789 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -97932,7 +97803,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 97936 "configure"
+#line 97807 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -97953,7 +97824,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 97957 "configure"
+#line 97828 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -97964,7 +97835,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:97968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:97839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -97991,17 +97862,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:97995: checking for $ac_hdr" >&5
+echo "configure:97866: 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 98000 "configure"
+#line 97871 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:98005: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:97876: \"$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*
@@ -98033,7 +97904,7 @@ done
 
 
 echo $ac_n "checking size of char""... $ac_c" 1>&6
-echo "configure:98037: checking size of char" >&5
+echo "configure:97908: 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
@@ -98041,7 +97912,7 @@ else
   ac_cv_sizeof_char=1
 else
   cat > conftest.$ac_ext <<EOF
-#line 98045 "configure"
+#line 97916 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -98052,7 +97923,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:98056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:97927: \"$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
@@ -98073,7 +97944,7 @@ EOF
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:98077: checking size of int" >&5
+echo "configure:97948: 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
@@ -98081,7 +97952,7 @@ else
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 98085 "configure"
+#line 97956 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -98092,7 +97963,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:98096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:97967: \"$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
@@ -98112,7 +97983,7 @@ EOF
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:98116: checking size of long" >&5
+echo "configure:97987: 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
@@ -98120,7 +97991,7 @@ else
   ac_cv_sizeof_long=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 98124 "configure"
+#line 97995 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -98131,7 +98002,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:98135: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:98006: \"$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
@@ -98151,7 +98022,7 @@ EOF
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:98155: checking size of long long" >&5
+echo "configure:98026: 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
@@ -98159,7 +98030,7 @@ else
   ac_cv_sizeof_long_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 98163 "configure"
+#line 98034 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -98170,7 +98041,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:98174: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:98045: \"$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
@@ -98190,12 +98061,12 @@ EOF
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:98194: checking for size_t" >&5
+echo "configure:98065: 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 98199 "configure"
+#line 98070 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -98223,12 +98094,12 @@ EOF
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:98227: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:98098: 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 98232 "configure"
+#line 98103 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -98237,7 +98108,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:98241: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:98112: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -98258,12 +98129,12 @@ EOF
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:98262: checking for uid_t in sys/types.h" >&5
+echo "configure:98133: 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 98267 "configure"
+#line 98138 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -98303,12 +98174,12 @@ for ac_func in \
  memcpy memmove
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:98307: checking for $ac_func" >&5
+echo "configure:98178: 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 98312 "configure"
+#line 98183 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -98331,7 +98202,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:98335: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:98206: \"$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
@@ -98685,7 +98556,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:98689: checking for XMLRPC-EPI in default path" >&5
+echo "configure:98560: 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
@@ -99128,7 +98999,7 @@ fi
 php_enable_xmlwriter=yes
 
 echo $ac_n "checking whether to enable XMLWriter support""... $ac_c" 1>&6
-echo "configure:99132: checking whether to enable XMLWriter support" >&5
+echo "configure:99003: 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"
@@ -99176,7 +99047,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:99180: checking libxml2 install dir" >&5
+echo "configure:99051: 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"
@@ -99207,7 +99078,7 @@ if test "$PHP_XMLWRITER" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:99211: checking for xml2-config path" >&5
+echo "configure:99082: 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
@@ -99365,7 +99236,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:99369: checking whether libxml build works" >&5
+echo "configure:99240: 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
@@ -99381,7 +99252,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 99385 "configure"
+#line 99256 "configure"
 #include "confdefs.h"
 
     
@@ -99392,7 +99263,7 @@ else
     }
   
 EOF
-if { (eval echo configure:99396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:99267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -99742,7 +99613,7 @@ fi
 php_with_xsl=no
 
 echo $ac_n "checking for XSL support""... $ac_c" 1>&6
-echo "configure:99746: checking for XSL support" >&5
+echo "configure:99617: checking for XSL support" >&5
 # Check whether --with-xsl or --without-xsl was given.
 if test "${with_xsl+set}" = set; then
   withval="$with_xsl"
@@ -99945,7 +99816,7 @@ if test "$PHP_XSL" != "no"; then
 
       
       echo $ac_n "checking for EXSLT support""... $ac_c" 1>&6
-echo "configure:99949: checking for EXSLT support" >&5
+echo "configure:99820: 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
@@ -100421,7 +100292,7 @@ fi
 php_enable_zip=no
 
 echo $ac_n "checking for zip archive read/writesupport""... $ac_c" 1>&6
-echo "configure:100425: checking for zip archive read/writesupport" >&5
+echo "configure:100296: 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"
@@ -100469,7 +100340,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:100473: checking for the location of libz" >&5
+echo "configure:100344: 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"
@@ -100496,7 +100367,7 @@ fi
 php_with_pcre_dir=no
 
 echo $ac_n "checking pcre install prefix""... $ac_c" 1>&6
-echo "configure:100500: checking pcre install prefix" >&5
+echo "configure:100371: 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"
@@ -100543,7 +100414,7 @@ if test "$PHP_ZIP" != "no"; then
   fi
 
     echo $ac_n "checking for the location of zlib""... $ac_c" 1>&6
-echo "configure:100547: checking for the location of zlib" >&5
+echo "configure:100418: 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
@@ -100681,7 +100552,7 @@ echo "configure:100547: checking for the location of zlib" >&5
     old_CPPFLAGS=$CPPFLAGS
   CPPFLAGS=$INCLUDES
   cat > conftest.$ac_ext <<EOF
-#line 100685 "configure"
+#line 100556 "configure"
 #include "confdefs.h"
 
 #include <main/php_config.h>
@@ -100700,7 +100571,7 @@ else
   rm -rf conftest*
   
     cat > conftest.$ac_ext <<EOF
-#line 100704 "configure"
+#line 100575 "configure"
 #include "confdefs.h"
 
 #include <main/php_config.h>
@@ -101064,35 +100935,85 @@ fi
 
 
 
-php_enable_mysqlnd_threading=no
 
-echo $ac_n "checking whether to enable threaded fetch in mysqlnd""... $ac_c" 1>&6
-echo "configure:101071: checking whether to enable threaded fetch in mysqlnd" >&5
-# Check whether --enable-mysqlnd_threading or --disable-mysqlnd_threading was given.
-if test "${enable_mysqlnd_threading+set}" = set; then
-  enableval="$enable_mysqlnd_threading"
-  PHP_MYSQLND_THREADING=$enableval
+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:100943: 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"
+  PHP_DISABLE_MYSQLND_COMPRESSION_SUPPORT=$enableval
+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
+
+fi
+
+
+
+ext_output="yes, shared"
+ext_shared=yes
+case $PHP_DISABLE_MYSQLND_COMPRESSION_SUPPORT in
+shared,*)
+  PHP_DISABLE_MYSQLND_COMPRESSION_SUPPORT=`echo "$PHP_DISABLE_MYSQLND_COMPRESSION_SUPPORT"|$SED 's/^shared,//'`
+  ;;
+shared)
+  PHP_DISABLE_MYSQLND_COMPRESSION_SUPPORT=yes
+  ;;
+no)
+  ext_output=no
+  ext_shared=no
+  ;;
+*)
+  ext_output=yes
+  ext_shared=no
+  ;;
+esac
+
+
+
+echo "$ac_t""$ext_output" 1>&6
+
+
+
+
+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:100991: 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"
+  PHP_ZLIB_DIR=$withval
 else
   
-  PHP_MYSQLND_THREADING=no
+  PHP_ZLIB_DIR=no
 
   if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_MYSQLND_THREADING=$PHP_ENABLE_ALL
+    PHP_ZLIB_DIR=$PHP_ENABLE_ALL
   fi
 
 fi
 
 
-ext_output=$PHP_MYSQLND_THREADING
+ext_output=$PHP_ZLIB_DIR
 echo "$ac_t""$ext_output" 1>&6
 
 
 
+fi
 
 if test "$PHP_MYSQLND_ENABLED" = "yes"; then
   mysqlnd_sources="mysqlnd.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
-                   mysqlnd_ps.c mysqlnd_loaddata.c mysqlnd_palloc.c \
-                   mysqlnd_ps_codec.c mysqlnd_statistics.c mysqlnd_qcache.c\
+                   mysqlnd_ps.c mysqlnd_loaddata.c mysqlnd_net.c \
+                   mysqlnd_ps_codec.c mysqlnd_statistics.c \
 				   mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\
 				   mysqlnd_block_alloc.c php_mysqlnd.c"
 
@@ -101393,18 +101314,156 @@ EOF
     $php_shtool mkdir -p ext/mysqlnd
   
 
-
-    if test "$PHP_MYSQLND_THREADING" = "yes"; then
+  
+  
+    for header_file in ext/mysqlnd/; 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"
     
-  enable_maintainer_zts=yes
-  if test "$pthreads_working" != "yes"; then
-    { echo "configure: error: ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads." 1>&2; exit 1; }
+        INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
+      
   fi
 
+    done 
+  
+
+
+  
+  if test "$PHP_MYSQLND_COMPRESSION_SUPPORT" != "no"; then
     cat >> confdefs.h <<\EOF
-#define MYSQLND_THREADED 1
+#define MYSQLND_COMPRESSION_ENABLED 1
 EOF
 
+    if test "$PHP_ZLIB_DIR" != "no"; then
+      
+
+  if test "$ext_shared" = "yes"; then
+    MYSQLND_SHARED_LIBADD="-lz $MYSQLND_SHARED_LIBADD"
+    if test -n "$PHP_ZLIB_DIR"; then
+      
+  if test "$PHP_ZLIB_DIR" != "/usr/$PHP_LIBDIR" && test "$PHP_ZLIB_DIR" != "/usr/lib"; then
+    
+  if test -z "$PHP_ZLIB_DIR" || echo "$PHP_ZLIB_DIR" | grep '^/' >/dev/null ; then
+    ai_p=$PHP_ZLIB_DIR
+  else
+    
+    ep_dir="`echo $PHP_ZLIB_DIR|$SED 's%/*[^/][^/]*/*$%%'`"
+    
+    ep_realdir="`(cd \"$ep_dir\" && pwd)`"
+    ai_p="$ep_realdir/`basename \"$PHP_ZLIB_DIR\"`"
+  fi
+
+    
+      if test "$ext_shared" = "yes"; then
+        MYSQLND_SHARED_LIBADD="-L$ai_p $MYSQLND_SHARED_LIBADD"
+        test -n "$ld_runpath_switch" && MYSQLND_SHARED_LIBADD="$ld_runpath_switch$ai_p $MYSQLND_SHARED_LIBADD"
+      else
+        
+  
+  
+  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
+
+    fi
+  else
+    
+
+  if test -n "$PHP_ZLIB_DIR"; then
+    
+  if test "$PHP_ZLIB_DIR" != "/usr/$PHP_LIBDIR" && test "$PHP_ZLIB_DIR" != "/usr/lib"; then
+    
+  if test -z "$PHP_ZLIB_DIR" || echo "$PHP_ZLIB_DIR" | grep '^/' >/dev/null ; then
+    ai_p=$PHP_ZLIB_DIR
+  else
+    
+    ep_dir="`echo $PHP_ZLIB_DIR|$SED 's%/*[^/][^/]*/*$%%'`"
+    
+    ep_realdir="`(cd \"$ep_dir\" && pwd)`"
+    ai_p="$ep_realdir/`basename \"$PHP_ZLIB_DIR\"`"
+  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 z in
+  c|c_r|pthread*) ;;
+  *) 
+      LIBS="-lz $LIBS" 
+   ;;
+  esac
+
+
+
+
+  fi
+
+
+      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
 fi
 
@@ -101418,7 +101477,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:101422: checking whether $php_typename exists" >&5
+echo "configure:101481: 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
@@ -101435,7 +101494,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 101439 "configure"
+#line 101498 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #if STDC_HEADERS
@@ -101465,7 +101524,7 @@ int main()
 }
   
 EOF
-if { (eval echo configure:101469: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:101528: \"$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`
@@ -101605,7 +101664,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:101609: checking for hash_insert in -l$MYSQL_LIBNAME" >&5
+echo "configure:101668: 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
@@ -101613,7 +101672,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 101617 "configure"
+#line 101676 "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
@@ -101624,7 +101683,7 @@ int main() {
 hash_insert()
 ; return 0; }
 EOF
-if { (eval echo configure:101628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:101687: \"$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
@@ -101726,7 +101785,7 @@ fi
 php_with_pear=DEFAULT
 
 echo $ac_n "checking whether to install PEAR""... $ac_c" 1>&6
-echo "configure:101730: checking whether to install PEAR" >&5
+echo "configure:101789: 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"
@@ -101831,7 +101890,7 @@ fi
   bison_version=none
   if test "$YACC"; then
     echo $ac_n "checking for bison version""... $ac_c" 1>&6
-echo "configure:101835: checking for bison version" >&5
+echo "configure:101894: 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
@@ -101887,17 +101946,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:101891: checking for $ac_hdr" >&5
+echo "configure:101950: 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 101896 "configure"
+#line 101955 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:101901: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:101960: \"$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*
@@ -101925,12 +101984,12 @@ done
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:101929: checking for size_t" >&5
+echo "configure:101988: 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 101934 "configure"
+#line 101993 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -101958,12 +102017,12 @@ EOF
 fi
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:101962: checking return type of signal handlers" >&5
+echo "configure:102021: 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 101967 "configure"
+#line 102026 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -101980,7 +102039,7 @@ int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:101984: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:102043: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -102004,12 +102063,12 @@ EOF
 
 
 echo $ac_n "checking for uint""... $ac_c" 1>&6
-echo "configure:102008: checking for uint" >&5
+echo "configure:102067: 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 102013 "configure"
+#line 102072 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -102037,12 +102096,12 @@ EOF
 fi
 
 echo $ac_n "checking for ulong""... $ac_c" 1>&6
-echo "configure:102041: checking for ulong" >&5
+echo "configure:102100: 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 102046 "configure"
+#line 102105 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -102072,9 +102131,9 @@ fi
 
 
 echo $ac_n "checking for int32_t""... $ac_c" 1>&6
-echo "configure:102076: checking for int32_t" >&5
+echo "configure:102135: checking for int32_t" >&5
 cat > conftest.$ac_ext <<EOF
-#line 102078 "configure"
+#line 102137 "configure"
 #include "confdefs.h"
 
 #if HAVE_SYS_TYPES_H  
@@ -102093,7 +102152,7 @@ if (sizeof (int32_t))
 
 ; return 0; }
 EOF
-if { (eval echo configure:102097: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:102156: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   cat >> confdefs.h <<EOF
@@ -102112,9 +102171,9 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking for uint32_t""... $ac_c" 1>&6
-echo "configure:102116: checking for uint32_t" >&5
+echo "configure:102175: checking for uint32_t" >&5
 cat > conftest.$ac_ext <<EOF
-#line 102118 "configure"
+#line 102177 "configure"
 #include "confdefs.h"
 
 #if HAVE_SYS_TYPES_H  
@@ -102133,7 +102192,7 @@ if (sizeof (uint32_t))
 
 ; return 0; }
 EOF
-if { (eval echo configure:102137: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:102196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   cat >> confdefs.h <<EOF
@@ -102152,12 +102211,12 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:102156: checking for vprintf" >&5
+echo "configure:102215: 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 102161 "configure"
+#line 102220 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char vprintf(); below.  */
@@ -102180,7 +102239,7 @@ vprintf();
 
 ; return 0; }
 EOF
-if { (eval echo configure:102184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102243: \"$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
@@ -102204,12 +102263,12 @@ fi
 
 if test "$ac_cv_func_vprintf" != yes; then
 echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:102208: checking for _doprnt" >&5
+echo "configure:102267: 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 102213 "configure"
+#line 102272 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char _doprnt(); below.  */
@@ -102232,7 +102291,7 @@ _doprnt();
 
 ; return 0; }
 EOF
-if { (eval echo configure:102236: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102295: \"$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
@@ -102257,7 +102316,7 @@ fi
 fi
 
 echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:102261: checking for 8-bit clean memcmp" >&5
+echo "configure:102320: 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
@@ -102265,7 +102324,7 @@ else
   ac_cv_func_memcmp_clean=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 102269 "configure"
+#line 102328 "configure"
 #include "confdefs.h"
 
 main()
@@ -102275,7 +102334,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:102279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:102338: \"$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
@@ -102295,19 +102354,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:102299: checking for working alloca.h" >&5
+echo "configure:102358: 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 102304 "configure"
+#line 102363 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:102311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102370: \"$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
@@ -102328,12 +102387,12 @@ EOF
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:102332: checking for alloca" >&5
+echo "configure:102391: 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 102337 "configure"
+#line 102396 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -102361,7 +102420,7 @@ int main() {
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:102365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102424: \"$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
@@ -102393,12 +102452,12 @@ EOF
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:102397: checking whether alloca needs Cray hooks" >&5
+echo "configure:102456: 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 102402 "configure"
+#line 102461 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -102423,12 +102482,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:102427: checking for $ac_func" >&5
+echo "configure:102486: 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 102432 "configure"
+#line 102491 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -102451,7 +102510,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:102455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102514: \"$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
@@ -102478,7 +102537,7 @@ done
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:102482: checking stack direction for C alloca" >&5
+echo "configure:102541: 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
@@ -102486,7 +102545,7 @@ else
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 102490 "configure"
+#line 102549 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -102505,7 +102564,7 @@ main ()
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:102509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:102568: \"$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
@@ -102529,12 +102588,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:102533: checking for $ac_func" >&5
+echo "configure:102592: 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 102538 "configure"
+#line 102597 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -102557,7 +102616,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:102561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102620: \"$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
@@ -102583,7 +102642,7 @@ done
 
 
   echo $ac_n "checking whether sprintf is broken""... $ac_c" 1>&6
-echo "configure:102587: checking whether sprintf is broken" >&5
+echo "configure:102646: 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
@@ -102594,11 +102653,11 @@ else
     
 else
   cat > conftest.$ac_ext <<EOF
-#line 102598 "configure"
+#line 102657 "configure"
 #include "confdefs.h"
 main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }
 EOF
-if { (eval echo configure:102602: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:102661: \"$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
@@ -102632,12 +102691,12 @@ EOF
 for ac_func in finite isfinite isinf isnan
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:102636: checking for $ac_func" >&5
+echo "configure:102695: 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 102641 "configure"
+#line 102700 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -102660,7 +102719,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:102664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102723: \"$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
@@ -102687,13 +102746,13 @@ done
 
 
   echo $ac_n "checking whether fp_except is defined""... $ac_c" 1>&6
-echo "configure:102691: checking whether fp_except is defined" >&5
+echo "configure:102750: 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 102697 "configure"
+#line 102756 "configure"
 #include "confdefs.h"
 
 #include <floatingpoint.h>
@@ -102704,7 +102763,7 @@ fp_except x = (fp_except) 0;
 
 ; return 0; }
 EOF
-if { (eval echo configure:102708: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:102767: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
      ac_cv_type_fp_except=yes
@@ -102731,9 +102790,9 @@ EOF
 
 
   echo $ac_n "checking for usable _FPU_SETCW""... $ac_c" 1>&6
-echo "configure:102735: checking for usable _FPU_SETCW" >&5
+echo "configure:102794: checking for usable _FPU_SETCW" >&5
   cat > conftest.$ac_ext <<EOF
-#line 102737 "configure"
+#line 102796 "configure"
 #include "confdefs.h"
 
     #include <fpu_control.h>
@@ -102753,7 +102812,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:102757: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102816: \"$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
@@ -102774,9 +102833,9 @@ EOF
   fi
   
   echo $ac_n "checking for usable fpsetprec""... $ac_c" 1>&6
-echo "configure:102778: checking for usable fpsetprec" >&5
+echo "configure:102837: checking for usable fpsetprec" >&5
   cat > conftest.$ac_ext <<EOF
-#line 102780 "configure"
+#line 102839 "configure"
 #include "confdefs.h"
 
     #include <machine/ieeefp.h>
@@ -102795,7 +102854,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:102799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cfp_have_fpsetprec=yes
 else
@@ -102816,9 +102875,9 @@ EOF
   fi
 
   echo $ac_n "checking for usable _controlfp""... $ac_c" 1>&6
-echo "configure:102820: checking for usable _controlfp" >&5
+echo "configure:102879: checking for usable _controlfp" >&5
   cat > conftest.$ac_ext <<EOF
-#line 102822 "configure"
+#line 102881 "configure"
 #include "confdefs.h"
 
     #include <float.h>
@@ -102837,7 +102896,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:102841: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cfp_have__controlfp=yes
 else
@@ -102858,9 +102917,9 @@ EOF
   fi
 
   echo $ac_n "checking for usable _controlfp_s""... $ac_c" 1>&6
-echo "configure:102862: checking for usable _controlfp_s" >&5
+echo "configure:102921: checking for usable _controlfp_s" >&5
   cat > conftest.$ac_ext <<EOF
-#line 102864 "configure"
+#line 102923 "configure"
 #include "confdefs.h"
 
    #include <float.h>
@@ -102880,7 +102939,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:102884: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102943: \"$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
@@ -102901,9 +102960,9 @@ EOF
   fi
 
   echo $ac_n "checking whether FPU control word can be manipulated by inline assembler""... $ac_c" 1>&6
-echo "configure:102905: checking whether FPU control word can be manipulated by inline assembler" >&5
+echo "configure:102964: checking whether FPU control word can be manipulated by inline assembler" >&5
   cat > conftest.$ac_ext <<EOF
-#line 102907 "configure"
+#line 102966 "configure"
 #include "confdefs.h"
 
     /* nothing */
@@ -102925,7 +102984,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:102929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:102988: \"$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
@@ -102947,7 +103006,7 @@ EOF
 
 
 echo $ac_n "checking whether double cast to long preserves least significant bits""... $ac_c" 1>&6
-echo "configure:102951: checking whether double cast to long preserves least significant bits" >&5
+echo "configure:103010: checking whether double cast to long preserves least significant bits" >&5
 
 if test "$cross_compiling" = yes; then
   
@@ -102955,7 +103014,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 102959 "configure"
+#line 103018 "configure"
 #include "confdefs.h"
 
 #include <limits.h>
@@ -102979,7 +103038,7 @@ int main()
 }
 
 EOF
-if { (eval echo configure:102983: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:103042: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   cat >> confdefs.h <<\EOF
@@ -103005,17 +103064,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:103009: checking for $ac_hdr" >&5
+echo "configure:103068: 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 103014 "configure"
+#line 103073 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:103019: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:103078: \"$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*
@@ -103043,14 +103102,14 @@ done
 
 
 echo $ac_n "checking whether dlsym() requires a leading underscore in symbol names""... $ac_c" 1>&6
-echo "configure:103047: checking whether dlsym() requires a leading underscore in symbol names" >&5
+echo "configure:103106: 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 103054 "configure"
+#line 103113 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -103107,11 +103166,13 @@ int main ()
       else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
       /* dlclose (self); */
     }
+  else
+    puts (dlerror ());
 
     exit (status);
 }
 EOF
-  if { (eval echo configure:103115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  if { (eval echo configure:103176: \"$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
@@ -103125,7 +103186,7 @@ EOF
 EOF
 
  ;;
-      x$lt_unknown|x*) 
+      x$lt_dlunknown|x*) 
   echo "$ac_t""no" 1>&6
  ;;
     esac
@@ -103194,23 +103255,23 @@ fi
 
 
 echo $ac_n "checking virtual machine dispatch method""... $ac_c" 1>&6
-echo "configure:103198: checking virtual machine dispatch method" >&5
+echo "configure:103259: 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:103202: checking whether to enable thread-safety" >&5
+echo "configure:103263: 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:103206: checking whether to enable inline optimization for GCC" >&5
+echo "configure:103267: 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:103210: checking whether to enable Zend debugging" >&5
+echo "configure:103271: 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:103214: checking whether to enable Zend multibyte" >&5
+echo "configure:103275: checking whether to enable Zend multibyte" >&5
 echo "$ac_t""$ZEND_MULTIBYTE" 1>&6
 
 case $PHP_ZEND_VM in
@@ -103283,21 +103344,21 @@ fi
 
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:103287: checking for inline" >&5
+echo "configure:103348: 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 103294 "configure"
+#line 103355 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:103301: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:103362: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -103326,7 +103387,7 @@ esac
 
 
 echo $ac_n "checking target system is Darwin""... $ac_c" 1>&6
-echo "configure:103330: checking target system is Darwin" >&5
+echo "configure:103391: checking target system is Darwin" >&5
 if echo "$target" | grep "darwin" > /dev/null; then
   cat >> confdefs.h <<\EOF
 #define DARWIN 1
@@ -103338,7 +103399,7 @@ else
 fi
 
 echo $ac_n "checking for MM alignment and log values""... $ac_c" 1>&6
-echo "configure:103342: checking for MM alignment and log values" >&5
+echo "configure:103403: checking for MM alignment and log values" >&5
 
 if test "$cross_compiling" = yes; then
   
@@ -103346,7 +103407,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 103350 "configure"
+#line 103411 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -103382,7 +103443,7 @@ int main()
 }
 
 EOF
-if { (eval echo configure:103386: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:103447: \"$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`
@@ -103407,7 +103468,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:103411: checking for memory allocation using mmap(MAP_ANON)" >&5
+echo "configure:103472: checking for memory allocation using mmap(MAP_ANON)" >&5
 
 if test "$cross_compiling" = yes; then
   
@@ -103415,7 +103476,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 103419 "configure"
+#line 103480 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -103451,7 +103512,7 @@ int main()
 }
 
 EOF
-if { (eval echo configure:103455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:103516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   cat >> confdefs.h <<\EOF
@@ -103473,7 +103534,7 @@ fi
 
 
 echo $ac_n "checking for memory allocation using mmap("/dev/zero")""... $ac_c" 1>&6
-echo "configure:103477: checking for memory allocation using mmap("/dev/zero")" >&5
+echo "configure:103538: checking for memory allocation using mmap("/dev/zero")" >&5
 
 if test "$cross_compiling" = yes; then
   
@@ -103481,7 +103542,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 103485 "configure"
+#line 103546 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -103527,7 +103588,7 @@ int main()
 }
 
 EOF
-if { (eval echo configure:103531: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:103592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   cat >> confdefs.h <<\EOF
@@ -103551,12 +103612,12 @@ fi
 for ac_func in mremap
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:103555: checking for $ac_func" >&5
+echo "configure:103616: 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 103560 "configure"
+#line 103621 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -103579,7 +103640,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:103583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:103644: \"$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
@@ -103646,17 +103707,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:103650: checking for $ac_hdr" >&5
+echo "configure:103711: 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 103655 "configure"
+#line 103716 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:103660: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:103721: \"$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*
@@ -103733,7 +103794,7 @@ if test "$TSRM_PTH" != "no"; then
   
 
 echo $ac_n "checking for GNU Pth""... $ac_c" 1>&6
-echo "configure:103737: checking for GNU Pth" >&5
+echo "configure:103798: 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
@@ -103763,17 +103824,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:103767: checking for $ac_hdr" >&5
+echo "configure:103828: 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 103772 "configure"
+#line 103833 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:103777: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:103838: \"$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*
@@ -103803,7 +103864,7 @@ done
 
   LIBS="$LIBS -lst"
   echo $ac_n "checking for SGI's State Threads""... $ac_c" 1>&6
-echo "configure:103807: checking for SGI's State Threads" >&5
+echo "configure:103868: checking for SGI's State Threads" >&5
   echo "$ac_t""yes" 1>&6
   cat >> confdefs.h <<\EOF
 #define TSRM_ST 1
@@ -103842,7 +103903,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 103846 "configure"
+#line 103907 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -103860,7 +103921,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:103864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:103925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -103880,7 +103941,7 @@ fi
   CFLAGS=$save_CFLAGS
 
   echo $ac_n "checking for pthreads_cflags""... $ac_c" 1>&6
-echo "configure:103884: checking for pthreads_cflags" >&5
+echo "configure:103945: 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
@@ -103902,7 +103963,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 103906 "configure"
+#line 103967 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -103920,7 +103981,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:103924: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:103985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -103950,7 +104011,7 @@ fi
 echo "$ac_t""$ac_cv_pthreads_cflags" 1>&6
 
 echo $ac_n "checking for pthreads_lib""... $ac_c" 1>&6
-echo "configure:103954: checking for pthreads_lib" >&5
+echo "configure:104015: 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
@@ -103972,7 +104033,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 103976 "configure"
+#line 104037 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -103990,7 +104051,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:103994: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:104055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -104041,7 +104102,7 @@ EOF
 
 
   echo $ac_n "checking for POSIX threads""... $ac_c" 1>&6
-echo "configure:104045: checking for POSIX threads" >&5
+echo "configure:104106: checking for POSIX threads" >&5
   echo "$ac_t""yes" 1>&6
 fi
 
@@ -104125,6 +104186,7 @@ EXPANDED_PEAR_INSTALLDIR=`eval echo $PEAR_INSTALLDIR`
 EXPANDED_EXTENSION_DIR=`eval echo $EXTENSION_DIR`
 EXPANDED_LOCALSTATEDIR=`eval echo $localstatedir`
 EXPANDED_BINDIR=`eval echo $bindir`
+EXPANDED_SBINDIR=`eval echo $sbindir`
 EXPANDED_LIBDIR=$libdir
 EXPANDED_SYSCONFDIR=`eval echo $sysconfdir`
 EXPANDED_DATADIR=$datadir
@@ -104147,6 +104209,7 @@ datadir=$old_datadir
 
 
 
+
 if test -n "$php_ldflags_add_usr_lib"; then
   PHP_RPATHS="$PHP_RPATHS /usr/lib"
 fi
@@ -104273,6 +104336,7 @@ EOF
 
 
   PHP_INSTALLED_SAPIS="cli $PHP_SAPI"
+  PHP_EXECUTABLE="\$(top_builddir)/\$(SAPI_CLI_PATH)"
 else
   PHP_INSTALLED_SAPIS="$PHP_SAPI"
 fi
@@ -104285,6 +104349,9 @@ fi
 
 
 
+  PHP_VAR_SUBST="$PHP_VAR_SUBST PHP_EXECUTABLE"
+
+
   PHP_VAR_SUBST="$PHP_VAR_SUBST PHP_CLI_TARGET"
 
 
@@ -104337,6 +104404,9 @@ fi
   PHP_VAR_SUBST="$PHP_VAR_SUBST bindir"
 
 
+  PHP_VAR_SUBST="$PHP_VAR_SUBST sbindir"
+
+
   PHP_VAR_SUBST="$PHP_VAR_SUBST exec_prefix"
 
 
@@ -104583,6 +104653,12 @@ fi
 
 LDFLAGS="$LDFLAGS $PHP_AIX_LDFLAGS"
 
+case $host_alias in
+*darwin9*|*darwin10*)
+	ac_cv_exeext=
+	;;
+esac
+
 
 # Check whether --enable-shared or --disable-shared was given.
 if test "${enable_shared+set}" = set; then
@@ -104660,7 +104736,7 @@ fi
 
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:104664: checking build system type" >&5
+echo "configure:104740: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -104689,7 +104765,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:104693: checking for ld used by $CC" >&5
+echo "configure:104769: checking for ld used by $CC" >&5
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return which upsets mingw
@@ -104719,10 +104795,10 @@ echo "configure:104693: 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:104723: checking for GNU ld" >&5
+echo "configure:104799: checking for GNU ld" >&5
 else
   echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-echo "configure:104726: checking for non-GNU ld" >&5
+echo "configure:104802: 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
@@ -104761,7 +104837,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:104765: checking if the linker ($LD) is GNU ld" >&5
+echo "configure:104841: 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
@@ -104781,7 +104857,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:104785: checking for $LD option to reload object files" >&5
+echo "configure:104861: 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
@@ -104798,7 +104874,7 @@ reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   darwin*)
     if test "$GCC" = yes; then
-      reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs'
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -104806,7 +104882,7 @@ case $host_os in
 esac
 
 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
-echo "configure:104810: checking for BSD-compatible nm" >&5
+echo "configure:104886: 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
@@ -104814,36 +104890,43 @@ else
   # Let the user override the test.
   lt_cv_path_NM="$NM"
 else
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    tmp_nm="$ac_dir/${ac_tool_prefix}nm"
-    if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-      # Check to see if the nm accepts a BSD-compat flag.
-      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
-      #   nm: unknown option "B" ignored
-      # Tru64's nm complains that /dev/null is an invalid object file
-      case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-      */dev/null* | *'Invalid file or object type'*)
-	lt_cv_path_NM="$tmp_nm -B"
-	break
-        ;;
-      *)
-	case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	*/dev/null*)
-	  lt_cv_path_NM="$tmp_nm -p"
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
 	  break
 	  ;;
 	*)
-	  lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	  continue # so that we can try to find one that supports BSD flags
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
 	  ;;
 	esac
-      esac
-    fi
+      fi
+    done
+    IFS="$lt_save_ifs"
   done
-  IFS="$lt_save_ifs"
   test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
 fi
 fi
@@ -104851,8 +104934,8 @@ fi
 echo "$ac_t""$lt_cv_path_NM" 1>&6
 NM="$lt_cv_path_NM"
 
-echo $ac_n "checking how to recognise dependent libraries""... $ac_c" 1>&6
-echo "configure:104856: checking how to recognise dependent libraries" >&5
+echo $ac_n "checking how to recognize dependent libraries""... $ac_c" 1>&6
+echo "configure:104939: 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
@@ -104871,7 +104954,7 @@ lt_cv_deplibs_check_method='unknown'
 # whether `pass_all' will *always* work, you probably want this one.
 
 case $host_os in
-aix4* | aix5*)
+aix[4-9]*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -104893,16 +104976,22 @@ cygwin*)
 
 mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
-  # func_win32_libid shell function, so use a weaker test based on 'objdump'.
-  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
-  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
   ;;
 
 darwin* | rhapsody*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | kfreebsd*-gnu | dragonfly*)
+freebsd* | dragonfly*)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
@@ -104940,6 +105029,11 @@ hpux10.20* | hpux11*)
   esac
   ;;
 
+interix[3-9]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+  ;;
+
 irix5* | irix6* | nonstopux*)
   case $LD in
   *-32|*"-32 ") libmagic=32-bit;;
@@ -104951,7 +105045,7 @@ irix5* | irix6* | nonstopux*)
   ;;
 
 # This must be Linux ELF.
-linux*)
+linux* | k*bsd*-gnu)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -104985,7 +105079,7 @@ osf3* | osf4* | osf5*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-sco3.2v5*)
+rdos*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -104993,7 +105087,7 @@ solaris*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+sysv4 | sysv4.3*)
   case $host_vendor in
   motorola)
     lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
@@ -105014,10 +105108,13 @@ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
   siemens)
     lt_cv_deplibs_check_method=pass_all
     ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
   esac
   ;;
 
-sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7* | sysv4*uw2*)
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 esac
@@ -105030,13 +105127,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:105034: checking for object suffix" >&5
+echo "configure:105131: 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:105040: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:105137: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   for ac_file in conftest.*; do
     case $ac_file in
     *.c) ;;
@@ -105056,7 +105153,7 @@ ac_objext=$ac_cv_objext
 
 
 echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
-echo "configure:105060: checking for executable suffix" >&5
+echo "configure:105157: checking for executable suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -105066,7 +105163,7 @@ else
   rm -f conftest*
   echo 'int main () { return 0; }' > conftest.$ac_ext
   ac_cv_exeext=
-  if { (eval echo configure:105070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+  if { (eval echo configure:105167: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
     for file in conftest.*; do
       case $file in
       *.c | *.o | *.obj) ;;
@@ -105090,6 +105187,9 @@ ac_exeext=$EXEEXT
 # If no C compiler was specified, use CC.
 LTCC=${LTCC-"$CC"}
 
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
 # Allow CC to be a program name with arguments.
 compiler=$CC
 
@@ -105109,7 +105209,7 @@ case $host in
 ia64-*-hpux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
-  if { (eval echo configure:105113: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  if { (eval echo configure:105213: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case `/usr/bin/file conftest.$ac_objext` in
     *ELF-32*)
       HPUX_IA64_MODE="32"
@@ -105123,8 +105223,8 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 105127 "configure"' > conftest.$ac_ext
-  if { (eval echo configure:105128: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  echo '#line 105227 "configure"' > conftest.$ac_ext
+  if { (eval echo configure:105228: \"$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*)
@@ -105154,13 +105254,17 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+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:105161: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  if { (eval echo configure:105262: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case `/usr/bin/file conftest.o` in
     *32-bit*)
       case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_i386_fbsd"
+          ;;
         x86_64-*linux*)
           LD="${LD-ld} -m elf_i386"
           ;;
@@ -105177,6 +105281,9 @@ x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
       ;;
     *64-bit*)
       case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_x86_64_fbsd"
+          ;;
         x86_64-*linux*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
@@ -105201,7 +105308,7 @@ x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|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:105205: checking whether the C compiler needs -belf" >&5
+echo "configure:105312: 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
@@ -105214,14 +105321,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 105218 "configure"
+#line 105325 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:105225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:105332: \"$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
@@ -105246,6 +105353,26 @@ echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6
     CFLAGS="$SAVE_CFLAGS"
   fi
   ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { (eval echo configure:105360: \"$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
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+        if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
 
 esac
 
@@ -105258,7 +105385,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:105262: checking how to run the C++ preprocessor" >&5
+echo "configure:105389: 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
@@ -105271,12 +105398,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 105275 "configure"
+#line 105402 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:105280: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:105407: \"$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
   :
@@ -105304,10 +105431,9 @@ 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:105311: checking the maximum length of command line arguments" >&5
+echo "configure:105437: 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
@@ -105354,44 +105480,64 @@ else
     elif test -x /usr/sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
     else
-      lt_cv_sys_max_cmd_len=65536     # usable default for all BSDs
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
     fi
     # And add a safety zone
     lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
     lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
   osf*)
     # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
     # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
     # nice to cause kernel panics so lets avoid the loop below.
     # First set a reasonable default.
     lt_cv_sys_max_cmd_len=16384
-    # 
+    #
     if test -x /sbin/sysconfig; then
       case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
         *1*) lt_cv_sys_max_cmd_len=-1 ;;
       esac
     fi
     ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ 	]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
   *)
-    # If test is not a shell built-in, we'll probably end up computing a
-    # maximum length that is only half of the actual maximum length, but
-    # we can't tell.
-    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-    while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
 	       = "XX$teststring") >/dev/null 2>&1 &&
-	    new_result=`expr "X$teststring" : ".*" 2>&1` &&
-	    lt_cv_sys_max_cmd_len=$new_result &&
-	    test $i != 17 # 1/2 MB should be enough
-    do
-      i=`expr $i + 1`
-      teststring=$teststring$teststring
-    done
-    teststring=
-    # Add a significant safety factor because C++ compilers can tack on massive
-    # amounts of additional arguments before passing them to the linker.
-    # It appears as though 1/2 is a usable value.
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+	      new_result=`expr "X$teststring" : ".*" 2>&1` &&
+	      lt_cv_sys_max_cmd_len=$new_result &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on massive
+      # amounts of additional arguments before passing them to the linker.
+      # It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
     ;;
   esac
 
@@ -105406,9 +105552,10 @@ 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:105412: checking command to parse $NM output from $compiler object" >&5
+echo "configure:105559: 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
@@ -105443,7 +105590,7 @@ hpux*) # Its linker distinguishes data from code symbols
   lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
   lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
   ;;
-linux*)
+linux* | k*bsd*-gnu)
   if test "$host_cpu" = ia64; then
     symcode='[ABCDGIRSTW]'
     lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
@@ -105456,9 +105603,18 @@ irix* | nonstopux*)
 osf*)
   symcode='[BCDEGQRST]'
   ;;
-solaris* | sysv5*)
+solaris*)
   symcode='[BDRT]'
   ;;
+sco3.2v5*)
+  symcode='[DT]'
+  ;;
+sysv4.2uw2*)
+  symcode='[DT]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[ABDT]'
+  ;;
 sysv4)
   symcode='[DFNSTU]'
   ;;
@@ -105503,10 +105659,10 @@ void nm_test_func(){}
 int main(){nm_test_var='a';nm_test_func();return(0);}
 EOF
 
-  if { (eval echo configure:105507: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  if { (eval echo configure:105663: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     # Now try to grab the symbols.
     nlist=conftest.nm
-    if { (eval echo configure:105510: \"$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:105666: \"$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"
@@ -105557,7 +105713,7 @@ EOF
 	  lt_save_CFLAGS="$CFLAGS"
 	  LIBS="conftstm.$ac_objext"
 	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
-	  if { (eval echo configure:105561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+	  if { (eval echo configure:105717: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 	    pipe_works=yes
 	  fi
 	  LIBS="$lt_save_LIBS"
@@ -105575,7 +105731,7 @@ EOF
     echo "$progname: failed program was:" >&5
     cat conftest.$ac_ext >&5
   fi
-  rm -f conftest* conftst*
+  rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
   if test "$pipe_works" = yes; then
@@ -105597,7 +105753,7 @@ else
 fi
 
 echo $ac_n "checking for objdir""... $ac_c" 1>&6
-echo "configure:105601: checking for objdir" >&5
+echo "configure:105757: checking for objdir" >&5
 if eval "test \"`echo '$''{'lt_cv_objdir'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -105663,7 +105819,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:105667: checking for $ac_word" >&5
+echo "configure:105823: 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
@@ -105695,7 +105851,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:105699: checking for $ac_word" >&5
+echo "configure:105855: 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
@@ -105730,7 +105886,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:105734: checking for $ac_word" >&5
+echo "configure:105890: 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
@@ -105762,7 +105918,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:105766: checking for $ac_word" >&5
+echo "configure:105922: 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
@@ -105797,7 +105953,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:105801: checking for $ac_word" >&5
+echo "configure:105957: 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
@@ -105829,7 +105985,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:105833: checking for $ac_word" >&5
+echo "configure:105989: 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
@@ -105871,6 +106027,7 @@ test -z "$AR_FLAGS" && AR_FLAGS=cru
 test -z "$AS" && AS=as
 test -z "$CC" && CC=cc
 test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 test -z "$DLLTOOL" && DLLTOOL=dlltool
 test -z "$LD" && LD=ld
 test -z "$LN_S" && LN_S="ln -s"
@@ -105883,17 +106040,17 @@ test -z "$STRIP" && STRIP=:
 test -z "$ac_objext" && ac_objext=o
 
 # Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
 old_postinstall_cmds='chmod 644 $oldlib'
 old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
   openbsd*)
-    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
     ;;
   *)
-    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
     ;;
   esac
   old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
@@ -105915,7 +106072,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:105919: checking for ${ac_tool_prefix}file" >&5
+echo "configure:106076: 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
@@ -105975,7 +106132,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:105979: checking for file" >&5
+echo "configure:106136: 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
@@ -106041,6 +106198,234 @@ fi
   ;;
 esac
 
+
+  case $host_os in
+    rhapsody* | darwin*)
+    # 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:106208: 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
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+if test -n "$DSYMUTIL"; then
+  echo "$ac_t""$DSYMUTIL" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+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:106240: 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
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_DSYMUTIL="dsymutil"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_prog_DSYMUTIL" && ac_cv_prog_DSYMUTIL=":"
+fi
+fi
+DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+if test -n "$DSYMUTIL"; then
+  echo "$ac_t""$DSYMUTIL" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+else
+  DSYMUTIL=":"
+fi
+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:106275: 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
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+NMEDIT="$ac_cv_prog_NMEDIT"
+if test -n "$NMEDIT"; then
+  echo "$ac_t""$NMEDIT" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
+if test -z "$ac_cv_prog_NMEDIT"; then
+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:106307: 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
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_NMEDIT="nmedit"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_prog_NMEDIT" && ac_cv_prog_NMEDIT=":"
+fi
+fi
+NMEDIT="$ac_cv_prog_NMEDIT"
+if test -n "$NMEDIT"; then
+  echo "$ac_t""$NMEDIT" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+else
+  NMEDIT=":"
+fi
+fi
+
+
+    echo $ac_n "checking for -single_module linker flag""... $ac_c" 1>&6
+echo "configure:106341: 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
+  lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+   # By default we will add the -single_module flag. You can override
+   # by either setting the environment variable LT_MULTI_MODULE
+   # non-empty at configure time, or by adding -multi_module to the
+   # link flags.
+   echo "int foo(void){return 1;}" > conftest.c
+   $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+     -dynamiclib ${wl}-single_module conftest.c
+   if test -f libconftest.dylib; then
+     lt_cv_apple_cc_single_mod=yes
+     rm -rf libconftest.dylib*
+   fi
+   rm conftest.c
+      fi
+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:106364: 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
+  lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      
+cat > conftest.$ac_ext <<EOF
+#line 106374 "configure"
+#include "confdefs.h"
+int main() {
+; return 0; }
+EOF
+if { (eval echo configure:106379: \"$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
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&6
+lt_cv_ld_exported_symbols_list=no
+  rm -rf conftest*
+fi
+rm -f conftest*
+   LDFLAGS="$save_LDFLAGS"
+    
+fi
+
+echo "$ac_t""$lt_cv_ld_exported_symbols_list" 1>&6
+    case $host_os in
+    rhapsody* | darwin1.[0123])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*)
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+   10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+   10.[012]*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+   10.*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}"
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil="~$DSYMUTIL \$lib || :"
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+
+
 enable_dlopen=no
 enable_win32_dll=no
 
@@ -106082,94 +106467,34 @@ objext=o
 objext=$objext
 
 # Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
+lt_simple_compile_test_code="int some_variable = 0;"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
+lt_simple_link_test_code='int main(){return(0);}'
 
 
 # If no C compiler was specified, use CC.
 LTCC=${LTCC-"$CC"}
 
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
 # Allow CC to be a program name with arguments.
 compiler=$CC
 
 
 # save warnings/boilerplate of simple test code
 ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_compiler_boilerplate=`cat conftest.err`
 $rm conftest*
 
 ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-#
-# Check for any special shared library compilation flags.
-#
-lt_prog_cc_shlib=
-if test "$GCC" = no; then
-  case $host_os in
-  sco3.2v5*)
-    lt_prog_cc_shlib='-belf'
-    ;;
-  esac
-fi
-if test -n "$lt_prog_cc_shlib"; then
-  echo "configure: warning: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" 1>&2
-  if echo "$old_CC $old_CFLAGS " | grep "[ 	]$lt_prog_cc_shlib[ 	]" >/dev/null; then :
-  else
-    echo "configure: warning: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" 1>&2
-    lt_cv_prog_cc_can_build_shared=no
-  fi
-fi
-
-
-#
-# Check to make sure the static flag actually works.
-#
-echo $ac_n "checking if $compiler static flag $lt_prog_compiler_static works""... $ac_c" 1>&6
-echo "configure:106138: checking if $compiler static flag $lt_prog_compiler_static works" >&5
-if eval "test \"`echo '$''{'lt_prog_compiler_static_works'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  lt_prog_compiler_static_works=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_prog_compiler_static"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
-       $SED '/^$/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works=yes
-       fi
-     else
-       lt_prog_compiler_static_works=yes
-     fi
-   fi
-   $rm conftest*
-   LDFLAGS="$save_LDFLAGS"
-
-fi
-
-echo "$ac_t""$lt_prog_compiler_static_works" 1>&6
-
-if test x"$lt_prog_compiler_static_works" = xyes; then
-    :
-else
-    lt_prog_compiler_static=
-fi
-
+$rm -r conftest*
 
 
 ## CAVEAT EMPTOR:
@@ -106184,13 +106509,13 @@ if test "$GCC" = yes; then
 
   
 echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions""... $ac_c" 1>&6
-echo "configure:106188: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+echo "configure:106513: 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
   lt_cv_prog_compiler_rtti_exceptions=no
   ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
    lt_compiler_flag="-fno-rtti -fno-exceptions"
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
@@ -106201,17 +106526,17 @@ 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:106205: $lt_compile\"" >&5)
+   (eval echo "\"configure:106530: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "configure:106209: \$? = $ac_status" >&5
+   echo "configure:106534: \$? = $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.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
        lt_cv_prog_compiler_rtti_exceptions=yes
      fi
    fi
@@ -106234,7 +106559,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:106238: checking for $compiler option to produce PIC" >&5
+echo "configure:106563: checking for $compiler option to produce PIC" >&5
  
   if test "$GCC" = yes; then
     lt_prog_compiler_wl='-Wl,'
@@ -106256,14 +106581,16 @@ echo "configure:106238: checking for $compiler option to produce PIC" >&5
       lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
       ;;
 
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
       # PIC is the default for these OSes.
       ;;
 
-    mingw* | pw32* | os2*)
+    mingw* | cygwin* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic='-DDLL_EXPORT'
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+	  lt_prog_compiler_pic='-DDLL_EXPORT'
       ;;
 
     darwin* | rhapsody*)
@@ -106272,6 +106599,11 @@ echo "configure:106238: checking for $compiler option to produce PIC" >&5
       lt_prog_compiler_pic='-fno-common'
       ;;
 
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
     msdosdjgpp*)
       # Just because we use GCC doesn't mean we suddenly get shared libraries
       # on systems that don't support them.
@@ -106325,10 +106657,10 @@ echo "configure:106238: checking for $compiler option to produce PIC" >&5
        esac
        ;;
 
-    mingw* | pw32* | os2*)
+    mingw* | cygwin* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic='-DDLL_EXPORT'
+	  lt_prog_compiler_pic='-DDLL_EXPORT'
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -106358,7 +106690,7 @@ echo "configure:106238: checking for $compiler option to produce PIC" >&5
       lt_prog_compiler_static='-Bstatic'
       ;;
 
-    linux*)
+    linux* | k*bsd*-gnu)
       case $cc_basename in
       # old Intel for x86_64 which still supported -KPIC.
       ecc*)
@@ -106385,6 +106717,22 @@ echo "configure:106238: checking for $compiler option to produce PIC" >&5
         # All Alpha code is PIC.
         lt_prog_compiler_static='-non_shared'
         ;;
+      *)
+        case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl=''
+	  ;;
+	esac
+	;;
       esac
       ;;
 
@@ -106394,9 +106742,8 @@ echo "configure:106238: checking for $compiler option to produce PIC" >&5
       lt_prog_compiler_static='-non_shared'
       ;;
 
-    sco3.2v5*)
-      lt_prog_compiler_pic='-Kpic'
-      lt_prog_compiler_static='-dn'
+    rdos*)
+      lt_prog_compiler_static='-non_shared'
       ;;
 
     solaris*)
@@ -106416,7 +106763,7 @@ echo "configure:106238: checking for $compiler option to produce PIC" >&5
       lt_prog_compiler_static='-Bstatic'
       ;;
 
-    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+    sysv4 | sysv4.2uw2* | sysv4.3*)
       lt_prog_compiler_wl='-Wl,'
       lt_prog_compiler_pic='-KPIC'
       lt_prog_compiler_static='-Bstatic'
@@ -106429,6 +106776,12 @@ echo "configure:106238: checking for $compiler option to produce PIC" >&5
       fi
       ;;
 
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
     unicos*)
       lt_prog_compiler_wl='-Wl,'
       lt_prog_compiler_can_build_shared=no
@@ -106453,13 +106806,13 @@ 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:106457: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
-if eval "test \"`echo '$''{'lt_prog_compiler_pic_works'+set}'`\" = set"; then
+echo "configure:106810: 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
-  lt_prog_compiler_pic_works=no
+  lt_cv_prog_compiler_pic_works=no
   ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
    lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
@@ -106470,27 +106823,27 @@ 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:106474: $lt_compile\"" >&5)
+   (eval echo "\"configure:106827: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "configure:106478: \$? = $ac_status" >&5
+   echo "configure:106831: \$? = $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.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works=yes
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works=yes
      fi
    fi
    $rm conftest*
 
 fi
 
-echo "$ac_t""$lt_prog_compiler_pic_works" 1>&6
+echo "$ac_t""$lt_cv_prog_compiler_pic_works" 1>&6
 
-if test x"$lt_prog_compiler_pic_works" = xyes; then
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
     case $lt_prog_compiler_pic in
      "" | " "*) ;;
      *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
@@ -106511,8 +106864,50 @@ case $host_os in
     ;;
 esac
 
+#
+# Check to make sure the static flag actually works.
+#
+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:106873: 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
+  lt_cv_prog_compiler_static_works=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works=yes
+     fi
+   fi
+   $rm -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+
+echo "$ac_t""$lt_cv_prog_compiler_static_works" 1>&6
+
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+    :
+else
+    lt_prog_compiler_static=
+fi
+
+
 echo $ac_n "checking if $compiler supports -c -o file.$ac_objext""... $ac_c" 1>&6
-echo "configure:106516: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo "configure:106911: 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
@@ -106521,7 +106916,7 @@ else
    mkdir conftest
    cd conftest
    mkdir out
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
    lt_compiler_flag="-o out/conftest2.$ac_objext"
    # Insert the option either (1) after the last *FLAGS variable, or
@@ -106532,18 +106927,18 @@ 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:106536: $lt_compile\"" >&5)
+   (eval echo "\"configure:106931: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "configure:106540: \$? = $ac_status" >&5
+   echo "configure:106935: \$? = $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
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
        lt_cv_prog_compiler_c_o=yes
      fi
    fi
@@ -106566,7 +106961,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:106570: checking if we can lock with hard links" >&5
+echo "configure:106965: 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
@@ -106583,7 +106978,7 @@ else
 fi
 
 echo $ac_n "checking whether the $compiler linker ($LD) supports shared libraries""... $ac_c" 1>&6
-echo "configure:106587: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo "configure:106982: checking whether the $compiler linker ($LD) supports shared libraries" >&5
 
   runpath_var=
   allow_undefined_flag=
@@ -106614,12 +107009,13 @@ echo "configure:106587: checking whether the $compiler linker ($LD) supports sha
   # it will be wrapped by ` (' and `)$', so one must not match beginning or
   # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
   # as well as any symbol that contains `d'.
-  exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
   # the symbol is explicitly referenced.  Since portable code cannot
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
   extract_expsyms_cmds=
   # Just being paranoid about ensuring that cc_basename is set.
   for cc_temp in $compiler""; do
@@ -106641,6 +107037,10 @@ cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
       with_gnu_ld=no
     fi
     ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
   openbsd*)
     with_gnu_ld=no
     ;;
@@ -106650,7 +107050,7 @@ cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
   if test "$with_gnu_ld" = yes; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
-    
+
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
@@ -106671,10 +107071,10 @@ cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
       *\ 2.11.*) ;; # other 2.11 versions
       *) supports_anon_versioning=yes ;;
     esac
-    
+
     # See if GNU ld supports shared libraries.
     case $host_os in
-    aix3* | aix4* | aix5*)
+    aix[3-9]*)
       # On AIX/PPC, the GNU linker is very broken
       if test "$host_cpu" != ia64; then
 	ld_shlibs=no
@@ -106722,10 +107122,10 @@ EOF
       allow_undefined_flag=unsupported
       always_export_symbols=no
       enable_shared_with_static_runtimes=yes
-      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	# If the export-symbols file already is a .def file (1st line
 	# is EXPORTS), use it as is; otherwise, prepend...
 	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
@@ -106734,13 +107134,28 @@ EOF
 	  echo EXPORTS > $output_objdir/$soname.def;
 	  cat $export_symbols >> $output_objdir/$soname.def;
 	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	ld_shlibs=no
       fi
       ;;
 
-    linux*)
+    interix[3-9]*)
+      hardcode_direct=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | k*bsd*-gnu)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	tmp_addflag=
 	case $cc_basename,$host_cpu in
@@ -106748,7 +107163,7 @@ EOF
 	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
-	pgf77* | pgf90* | pgf95*)			# Portland Group f77 and f90 compilers
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
 	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
@@ -106758,13 +107173,22 @@ EOF
 	ifc* | ifort*)			# Intel Fortran compiler
 	  tmp_addflag=' -nofor_main' ;;
 	esac
-	archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	*)
+	  tmp_sharedflag='-shared' ;;
+	esac
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 
 	if test $supports_anon_versioning = yes; then
 	  archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
   cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
   $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	  $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
 	fi
       else
 	ld_shlibs=no
@@ -106781,7 +107205,7 @@ EOF
       fi
       ;;
 
-    solaris* | sysv5*)
+    solaris*)
       if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
 	ld_shlibs=no
 	cat <<EOF 1>&2
@@ -106802,6 +107226,33 @@ EOF
       fi
       ;;
 
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+	  else
+	    ld_shlibs=no
+	  fi
+	;;
+      esac
+      ;;
+
     sunos4*)
       archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
       wlarc=
@@ -106835,14 +107286,14 @@ EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       hardcode_minus_L=yes
-      if test "$GCC" = yes && test -z "$link_static_flag"; then
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	hardcode_direct=unsupported
       fi
       ;;
 
-    aix4* | aix5*)
+    aix[4-9]*)
       if test "$host_cpu" = ia64; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
@@ -106862,13 +107313,14 @@ EOF
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
 	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	  for ld_flag in $LDFLAGS; do
   	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
   	    aix_use_runtimelinking=yes
   	    break
   	  fi
 	  done
+	  ;;
 	esac
 
 	exp_sym_flag='-bexport'
@@ -106895,7 +107347,7 @@ EOF
   	   strings "$collect2name" | grep resolve_lib_name >/dev/null
 	  then
   	  # We have reworked collect2
-  	  hardcode_direct=yes
+  	  :
 	  else
   	  # We have old collect2
   	  hardcode_direct=unsupported
@@ -106906,6 +107358,7 @@ EOF
   	  hardcode_libdir_flag_spec='-L$libdir'
   	  hardcode_libdir_separator=
 	  fi
+	  ;;
 	esac
 	shared_flag='-shared'
 	if test "$aix_use_runtimelinking" = yes; then
@@ -106918,11 +107371,11 @@ EOF
   	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-  	if test "$aix_use_runtimelinking" = yes; then
+	  if test "$aix_use_runtimelinking" = yes; then
 	    shared_flag='${wl}-G'
 	  else
 	    shared_flag='${wl}-bM:SRE'
-  	fi
+	  fi
 	fi
       fi
 
@@ -106936,18 +107389,25 @@ EOF
        # Determine the default libpath from the value encoded in an empty executable.
        
 cat > conftest.$ac_ext <<EOF
-#line 106940 "configure"
+#line 107393 "configure"
 #include "confdefs.h"
 int main() {
 ; return 0; }
 EOF
-if { (eval echo configure:106945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
+if { (eval echo configure:107398: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ 
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
 # Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
   rm -rf conftest*
 else
   echo "configure: failed program was:" >&5
@@ -106957,28 +107417,35 @@ rm -f conftest*
 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 
        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-	archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+	archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
        else
 	if test "$host_cpu" = ia64; then
 	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
 	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an empty executable.
 	 
 cat > conftest.$ac_ext <<EOF
-#line 106971 "configure"
+#line 107431 "configure"
 #include "confdefs.h"
 int main() {
 ; return 0; }
 EOF
-if { (eval echo configure:106976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
+if { (eval echo configure:107436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ 
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
 # Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
   rm -rf conftest*
 else
   echo "configure: failed program was:" >&5
@@ -106992,13 +107459,11 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	  # -berok will link without error, but may produce a broken library.
 	  no_undefined_flag=' ${wl}-bernotok'
 	  allow_undefined_flag=' ${wl}-berok'
-	  # -bexpall does not export symbols beginning with underscore (_)
-	  always_export_symbols=yes
 	  # Exported symbols can be pulled into shared objects from archives
-	  whole_archive_flag_spec=' '
+	  whole_archive_flag_spec='$convenience'
 	  archive_cmds_need_lc=yes
 	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
       ;;
@@ -107031,7 +107496,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       # The linker will automatically build a .lib file if we build a DLL.
       old_archive_From_new_cmds='true'
       # FIXME: Should let the user specify the lib program.
-      old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
       fix_srcfile_path='`cygpath -w "$srcfile"`'
       enable_shared_with_static_runtimes=yes
       ;;
@@ -107064,19 +107529,18 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       link_all_deplibs=yes
     if test "$GCC" = yes ; then
     	output_verbose_link_cmd='echo'
-        archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
     else
       case $cc_basename in
         xlc*)
          output_verbose_link_cmd='echo'
-         archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+         archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
          module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
           # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+         archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
        *)
@@ -107116,7 +107580,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | dragonfly*)
       archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec='-R$libdir'
       hardcode_direct=yes
@@ -107139,47 +107603,62 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       export_dynamic_flag_spec='${wl}-E'
       ;;
 
-    hpux10* | hpux11*)
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator=:
+
+	hardcode_direct=yes
+	export_dynamic_flag_spec='${wl}-E'
+
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L=yes
+      fi
+      ;;
+
+    hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
 	case $host_cpu in
-	hppa*64*|ia64*)
+	hppa*64*)
 	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
+	ia64*)
+	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
 	*)
 	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
-	hppa*64*|ia64*)
-	  archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hppa*64*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       fi
       if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator=:
+
 	case $host_cpu in
-	hppa*64*)
-	  hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hppa*64*|ia64*)
 	  hardcode_libdir_flag_spec_ld='+b $libdir'
-	  hardcode_libdir_separator=:
-	  hardcode_direct=no
-	  hardcode_shlibpath_var=no
-	  ;;
-	ia64*)
-	  hardcode_libdir_flag_spec='-L$libdir'
 	  hardcode_direct=no
 	  hardcode_shlibpath_var=no
-
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L=yes
 	  ;;
 	*)
-	  hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-	  hardcode_libdir_separator=:
 	  hardcode_direct=yes
 	  export_dynamic_flag_spec='${wl}-E'
 
@@ -107223,24 +107702,28 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       ;;
 
     openbsd*)
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec='${wl}-E'
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct=yes
+	hardcode_shlibpath_var=no
+	if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+	  export_dynamic_flag_spec='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     hardcode_libdir_flag_spec='-R$libdir'
+	     ;;
+	   *)
+	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+        fi
       else
-       case $host_os in
-	 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	   archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	   hardcode_libdir_flag_spec='-R$libdir'
-	   ;;
-	 *)
-	   archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	   hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	   ;;
-       esac
+	ld_shlibs=no
       fi
       ;;
 
@@ -107281,14 +107764,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       hardcode_libdir_separator=:
       ;;
 
-    sco3.2v5*)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var=no
-      export_dynamic_flag_spec='${wl}-Bexport'
-      runpath_var=LD_RUN_PATH
-      hardcode_runpath_var=yes
-      ;;
-
     solaris*)
       no_undefined_flag=' -z text'
       if test "$GCC" = yes; then
@@ -107307,17 +107782,16 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       case $host_os in
       solaris2.[0-5] | solaris2.[0-5].*) ;;
       *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
  	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+	fi
+	;;
       esac
       link_all_deplibs=yes
       ;;
@@ -107374,36 +107848,45 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       fi
       ;;
 
-    sysv4.2uw2*)
-      archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct=yes
-      hardcode_minus_L=no
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag='${wl}-z,text'
+      archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
-      hardcode_runpath_var=yes
-      runpath_var=LD_RUN_PATH
-      ;;
+      runpath_var='LD_RUN_PATH'
 
-   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[78]* | unixware7*)
-      no_undefined_flag='${wl}-z ${wl}text'
       if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var=no
       ;;
 
-    sysv5*)
-      no_undefined_flag=' -z text'
-      # $CC -shared without GNU ld will not create a library from C++
-      # object files and a static libstdc++, better avoid it by now
-      archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-  		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
-      hardcode_libdir_flag_spec=
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag='${wl}-z,text'
+      allow_undefined_flag='${wl}-z,nodefs'
+      archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      export_dynamic_flag_spec='${wl}-Bexport'
       runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
       ;;
 
     uts4*)
@@ -107421,11 +107904,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 echo "$ac_t""$ld_shlibs" 1>&6
 test "$ld_shlibs" = no && can_build_shared=no
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
 #
 # Do we need to explicitly link libc?
 #
@@ -107444,16 +107922,17 @@ 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:107448: checking whether -lc should be explicitly linked in" >&5
+echo "configure:107926: checking whether -lc should be explicitly linked in" >&5
       $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-      if { (eval echo configure:107452: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } 2>conftest.err; then
+      if { (eval echo configure:107930: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } 2>conftest.err; then
         soname=conftest
         lib=conftest
         libobjs=conftest.$ac_objext
         deplibs=
         wl=$lt_prog_compiler_wl
+	pic_flag=$lt_prog_compiler_pic
         compiler_flags=-v
         linker_flags=-v
         verstring=
@@ -107461,7 +107940,7 @@ echo "configure:107448: 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:107465: \"$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:107944: \"$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
@@ -107480,7 +107959,7 @@ echo "configure:107448: checking whether -lc should be explicitly linked in" >&5
 esac
 
 echo $ac_n "checking dynamic linker characteristics""... $ac_c" 1>&6
-echo "configure:107484: checking dynamic linker characteristics" >&5
+echo "configure:107963: checking dynamic linker characteristics" >&5
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
@@ -107494,17 +107973,55 @@ shlibpath_overrides_runpath=unknown
 version_type=none
 dynamic_linker="$host_os ld.so"
 sys_lib_dlsearch_path_spec="/lib /usr/lib"
+
 if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$lt_search_path_spec" | grep ';' >/dev/null ; then
     # if the path contains ";" then we assume it to be the separator
     # otherwise default to the standard path separator (i.e. ":") - it is
     # assumed that no part of a normal pathname contains ";" but that should
     # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e 's/;/ /g'`
   else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
   fi
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`echo $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[lt_foo]++; }
+  if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+  sys_lib_search_path_spec=`echo $lt_search_path_spec`
 else
   sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
 fi
@@ -107525,7 +108042,7 @@ aix3*)
   soname_spec='${libname}${release}${shared_ext}$major'
   ;;
 
-aix4* | aix5*)
+aix[4-9]*)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -107664,12 +108181,8 @@ darwin* | rhapsody*)
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
+  
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" 
   sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
   ;;
 
@@ -107686,18 +108199,6 @@ freebsd1*)
   dynamic_linker=no
   ;;
 
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
@@ -107730,10 +108231,15 @@ freebsd* | dragonfly*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
-  *) # from 3.2 on
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
     shlibpath_overrides_runpath=no
     hardcode_into_libs=yes
     ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
   esac
   ;;
 
@@ -107793,6 +108299,18 @@ hpux9* | hpux10* | hpux11*)
   postinstall_cmds='chmod 555 $lib'
   ;;
 
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
 irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
@@ -107836,7 +108354,7 @@ linux*oldld* | linux*aout* | linux*coff*)
   ;;
 
 # This must be Linux ELF.
-linux*)
+linux* | k*bsd*-gnu)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -107850,27 +108368,10 @@ linux*)
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # find out which ABI we are using
-  libsuff=
-  case $host_cpu in
-  x86_64*|s390x*|powerpc64*)
-    echo '#line 107858 "configure"' > conftest.$ac_ext
-    if { (eval echo configure:107859: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-      case `/usr/bin/file conftest.$ac_objext` in
-      *64-bit*)
-        libsuff=64
-        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
-        ;;
-      esac
-    fi
-    rm -rf conftest*
-    ;;
-  esac
-
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ 	]*hwcap[ 	]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -107882,18 +108383,6 @@ linux*)
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -107931,6 +108420,7 @@ nto-qnx*)
 
 openbsd*)
   version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
   need_lib_prefix=no
   # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
   case $host_os in
@@ -107974,11 +108464,8 @@ osf3* | osf4* | osf5*)
   sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
   ;;
 
-sco3.2v5*)
-  version_type=osf
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
+rdos*)
+  dynamic_linker=no
   ;;
 
 solaris*)
@@ -108006,7 +108493,7 @@ sunos4*)
   need_version=yes
   ;;
 
-sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+sysv4 | sysv4.3*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
@@ -108039,6 +108526,29 @@ sysv4*MP*)
   fi
   ;;
 
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+    shlibpath_overrides_runpath=no
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    shlibpath_overrides_runpath=yes
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
 uts4*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -108053,8 +108563,28 @@ esac
 echo "$ac_t""$dynamic_linker" 1>&6
 test "$dynamic_linker" = no && can_build_shared=no
 
+if eval "test \"`echo '$''{'lt_cv_sys_lib_search_path_spec'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"
+fi
+
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if eval "test \"`echo '$''{'lt_cv_sys_lib_dlsearch_path_spec'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"
+fi
+
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
 echo $ac_n "checking how to hardcode library paths into programs""... $ac_c" 1>&6
-echo "configure:108058: checking how to hardcode library paths into programs" >&5
+echo "configure:108588: checking how to hardcode library paths into programs" >&5
 hardcode_action=
 if test -n "$hardcode_libdir_flag_spec" || \
    test -n "$runpath_var" || \
@@ -108092,7 +108622,7 @@ fi
 striplib=
 old_striplib=
 echo $ac_n "checking whether stripping libraries is possible""... $ac_c" 1>&6
-echo "configure:108096: checking whether stripping libraries is possible" >&5
+echo "configure:108626: 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"
@@ -108103,6 +108633,7 @@ else
    darwin*)
        if test -n "$STRIP" ; then
          striplib="$STRIP -x"
+         old_striplib="$STRIP -S"
          echo "$ac_t""yes" 1>&6
        else
   echo "$ac_t""no" 1>&6
@@ -108142,7 +108673,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:108146: checking for dlopen in -ldl" >&5
+echo "configure:108677: 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
@@ -108150,7 +108681,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 108154 "configure"
+#line 108685 "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
@@ -108161,7 +108692,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:108165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:108696: \"$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
@@ -108190,12 +108721,12 @@ fi
 
   *)
     echo $ac_n "checking for shl_load""... $ac_c" 1>&6
-echo "configure:108194: checking for shl_load" >&5
+echo "configure:108725: 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 108199 "configure"
+#line 108730 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shl_load(); below.  */
@@ -108218,7 +108749,7 @@ shl_load();
 
 ; return 0; }
 EOF
-if { (eval echo configure:108222: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:108753: \"$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
@@ -108236,7 +108767,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:108240: checking for shl_load in -ldld" >&5
+echo "configure:108771: 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
@@ -108244,7 +108775,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldld  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 108248 "configure"
+#line 108779 "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
@@ -108255,7 +108786,7 @@ int main() {
 shl_load()
 ; return 0; }
 EOF
-if { (eval echo configure:108259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:108790: \"$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
@@ -108270,16 +108801,16 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:108278: checking for dlopen" >&5
+echo "configure:108809: 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 108283 "configure"
+#line 108814 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dlopen(); below.  */
@@ -108302,7 +108833,7 @@ dlopen();
 
 ; return 0; }
 EOF
-if { (eval echo configure:108306: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:108837: \"$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
@@ -108320,7 +108851,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:108324: checking for dlopen in -ldl" >&5
+echo "configure:108855: 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
@@ -108328,7 +108859,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 108332 "configure"
+#line 108863 "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
@@ -108339,7 +108870,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:108343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:108874: \"$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
@@ -108358,7 +108889,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:108362: checking for dlopen in -lsvld" >&5
+echo "configure:108893: 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
@@ -108366,7 +108897,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsvld  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 108370 "configure"
+#line 108901 "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
@@ -108377,7 +108908,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:108381: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:108912: \"$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
@@ -108396,7 +108927,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:108400: checking for dld_link in -ldld" >&5
+echo "configure:108931: 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
@@ -108404,7 +108935,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldld  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 108408 "configure"
+#line 108939 "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
@@ -108415,7 +108946,7 @@ int main() {
 dld_link()
 ; return 0; }
 EOF
-if { (eval echo configure:108419: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:108950: \"$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
@@ -108430,7 +108961,7 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
 else
   echo "$ac_t""no" 1>&6
 fi
@@ -108465,13 +108996,13 @@ fi
     test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
     save_LDFLAGS="$LDFLAGS"
-    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
     save_LIBS="$LIBS"
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6
-echo "configure:108475: checking whether a program can dlopen itself" >&5
+echo "configure:109006: 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
@@ -108481,7 +109012,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 108485 "configure"
+#line 109016 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -108538,17 +109069,19 @@ int main ()
       else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
       /* dlclose (self); */
     }
+  else
+    puts (dlerror ());
 
     exit (status);
 }
 EOF
-  if { (eval echo configure:108546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  if { (eval echo configure:109079: \"$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
       x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
       x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
     esac
   else :
     # compilation failed
@@ -108563,9 +109096,9 @@ fi
 echo "$ac_t""$lt_cv_dlopen_self" 1>&6
 
     if test "x$lt_cv_dlopen_self" = xyes; then
-      LDFLAGS="$LDFLAGS $link_static_flag"
+      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:108569: checking whether a statically linked program can dlopen itself" >&5
+echo "configure:109102: 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
@@ -108575,7 +109108,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 108579 "configure"
+#line 109112 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -108632,17 +109165,19 @@ int main ()
       else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
       /* dlclose (self); */
     }
+  else
+    puts (dlerror ());
 
     exit (status);
 }
 EOF
-  if { (eval echo configure:108640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  if { (eval echo configure:109175: \"$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
       x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
       x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
     esac
   else :
     # compilation failed
@@ -108675,13 +109210,13 @@ echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6
 fi
 
 
-# Report which librarie types wil actually be built
+# Report which library types will actually be built
 echo $ac_n "checking if libtool supports shared libraries""... $ac_c" 1>&6
-echo "configure:108681: checking if libtool supports shared libraries" >&5
+echo "configure:109216: 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:108685: checking whether to build shared libraries" >&5
+echo "configure:109220: 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
@@ -108695,7 +109230,7 @@ aix3*)
   fi
   ;;
 
-aix4* | aix5*)
+aix[4-9]*)
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
@@ -108704,7 +109239,7 @@ esac
 echo "$ac_t""$enable_shared" 1>&6
 
 echo $ac_n "checking whether to build static libraries""... $ac_c" 1>&6
-echo "configure:108708: checking whether to build static libraries" >&5
+echo "configure:109243: 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
@@ -108722,7 +109257,7 @@ if test -f "$ltmain"; then
   # Now quote all the things that may contain metacharacters while being
   # careful not to overquote the AC_SUBSTed values.  We take copies of the
   # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
     SED SHELL STRIP \
     libname_spec library_names_spec soname_spec extract_expsyms_cmds \
     old_striplib striplib file_magic_cmd finish_cmds finish_eval \
@@ -108749,6 +109284,7 @@ if test -f "$ltmain"; then
     predeps \
     postdeps \
     compiler_lib_search_path \
+    compiler_lib_search_dirs \
     archive_cmds \
     archive_expsym_cmds \
     postinstall_cmds \
@@ -108764,6 +109300,7 @@ if test -f "$ltmain"; then
     module_cmds \
     module_expsym_cmds \
     lt_cv_prog_compiler_c_o \
+    fix_srcfile_path \
     exclude_expsyms \
     include_expsyms; do
 
@@ -108808,7 +109345,7 @@ creating $ofile" 1>&6
 # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 #
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 # Free Software Foundation, Inc.
 #
 # This file is part of GNU Libtool:
@@ -108888,6 +109425,9 @@ AR_FLAGS=$lt_AR_FLAGS
 # A C compiler.
 LTCC=$lt_LTCC
 
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
 # A language-specific compiler.
 CC=$lt_compiler
 
@@ -109041,6 +109581,10 @@ predeps=$lt_predeps
 # shared library.
 postdeps=$lt_postdeps
 
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
 # The library search path used internally by the compiler when linking
 # a shared library.
 compiler_lib_search_path=$lt_compiler_lib_search_path
@@ -109129,7 +109673,7 @@ sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
 
 # Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path"
+fix_srcfile_path=$lt_fix_srcfile_path
 
 # Set to yes if exported symbols are required.
 always_export_symbols=$always_export_symbols
@@ -109216,6 +109760,9 @@ if test -f "$ltmain" && test -n "$tagnames"; then
       echo "configure: warning: using \`LTCC=$LTCC', extracted from \`$ofile'" 1>&2
     fi
   fi
+  if test -z "$LTCFLAGS"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
+  fi
 
   # Extract list of available tagged configurations in $ofile.
   # Note that this assumes the entire list is on one line.
@@ -109266,6 +109813,7 @@ hardcode_libdir_flag_spec_CXX=
 hardcode_libdir_flag_spec_ld_CXX=
 hardcode_libdir_separator_CXX=
 hardcode_minus_L_CXX=no
+hardcode_shlibpath_var_CXX=unsupported
 hardcode_automatic_CXX=no
 module_cmds_CXX=
 module_expsym_cmds_CXX=
@@ -109281,6 +109829,7 @@ postdep_objects_CXX=
 predeps_CXX=
 postdeps_CXX=
 compiler_lib_search_path_CXX=
+compiler_lib_search_dirs_CXX=
 
 # Source file extension for C++ test sources.
 ac_ext=cpp
@@ -109290,32 +109839,35 @@ objext=o
 objext_CXX=$objext
 
 # Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
+lt_simple_compile_test_code="int some_variable = 0;"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *) { return(0); }\n'
+lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
 # If no C compiler was specified, use CC.
 LTCC=${LTCC-"$CC"}
 
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
 # Allow CC to be a program name with arguments.
 compiler=$CC
 
 
 # save warnings/boilerplate of simple test code
 ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_compiler_boilerplate=`cat conftest.err`
 $rm conftest*
 
 ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+$rm -r conftest*
 
 
 # Allow CC to be a program name with arguments.
@@ -109373,7 +109925,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:109377: checking for ld used by $CC" >&5
+echo "configure:109929: checking for ld used by $CC" >&5
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return which upsets mingw
@@ -109403,10 +109955,10 @@ echo "configure:109377: 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:109407: checking for GNU ld" >&5
+echo "configure:109959: checking for GNU ld" >&5
 else
   echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-echo "configure:109410: checking for non-GNU ld" >&5
+echo "configure:109962: 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
@@ -109445,7 +109997,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:109449: checking if the linker ($LD) is GNU ld" >&5
+echo "configure:110001: 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
@@ -109511,14 +110063,14 @@ 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:109515: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo "configure:110067: checking whether the $compiler linker ($LD) supports shared libraries" >&5
 ld_shlibs_CXX=yes
 case $host_os in
   aix3*)
     # FIXME: insert proper C++ library support
     ld_shlibs_CXX=no
     ;;
-  aix4* | aix5*)
+  aix[4-9]*)
     if test "$host_cpu" = ia64; then
       # On IA64, the linker does run time linking by default, so we don't
       # have to do anything special.
@@ -109531,7 +110083,7 @@ case $host_os in
       # Test if we are trying to use run time linking or normal
       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
       # need to do runtime linking.
-      case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+      case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	for ld_flag in $LDFLAGS; do
 	  case $ld_flag in
 	  *-brtl*)
@@ -109540,6 +110092,7 @@ case $host_os in
 	    ;;
 	  esac
 	done
+	;;
       esac
 
       exp_sym_flag='-bexport'
@@ -109566,7 +110119,7 @@ case $host_os in
 	   strings "$collect2name" | grep resolve_lib_name >/dev/null
 	then
 	  # We have reworked collect2
-	  hardcode_direct_CXX=yes
+	  :
 	else
 	  # We have old collect2
 	  hardcode_direct_CXX=unsupported
@@ -109577,6 +110130,7 @@ case $host_os in
 	  hardcode_libdir_flag_spec_CXX='-L$libdir'
 	  hardcode_libdir_separator_CXX=
 	fi
+	;;
       esac
       shared_flag='-shared'
       if test "$aix_use_runtimelinking" = yes; then
@@ -109607,18 +110161,25 @@ case $host_os in
       # Determine the default libpath from the value encoded in an empty executable.
       
 cat > conftest.$ac_ext <<EOF
-#line 109611 "configure"
+#line 110165 "configure"
 #include "confdefs.h"
 int main() {
 ; return 0; }
 EOF
-if { (eval echo configure:109616: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
+if { (eval echo configure:110170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ 
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
 # Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
   rm -rf conftest*
 else
   echo "configure: failed program was:" >&5
@@ -109629,28 +110190,35 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 
       hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
 
-      archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
      else
       if test "$host_cpu" = ia64; then
 	hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
 	allow_undefined_flag_CXX="-z nodefs"
-	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
       else
 	# Determine the default libpath from the value encoded in an empty executable.
 	
 cat > conftest.$ac_ext <<EOF
-#line 109643 "configure"
+#line 110204 "configure"
 #include "confdefs.h"
 int main() {
 ; return 0; }
 EOF
-if { (eval echo configure:109648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
+if { (eval echo configure:110209: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ 
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
 # Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
   rm -rf conftest*
 else
   echo "configure: failed program was:" >&5
@@ -109664,16 +110232,26 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	# -berok will link without error, but may produce a broken library.
 	no_undefined_flag_CXX=' ${wl}-bernotok'
 	allow_undefined_flag_CXX=' ${wl}-berok'
-	# -bexpall does not export symbols beginning with underscore (_)
-	always_export_symbols_CXX=yes
 	# Exported symbols can be pulled into shared objects from archives
-	whole_archive_flag_spec_CXX=' '
+	whole_archive_flag_spec_CXX='$convenience'
 	archive_cmds_need_lc_CXX=yes
 	# This is similar to how AIX traditionally builds its shared libraries.
-	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
       fi
     fi
     ;;
+
+  beos*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+      allow_undefined_flag_CXX=unsupported
+      # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+      # support --undefined.  This deserves some investigation.  FIXME
+      archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    else
+      ld_shlibs_CXX=no
+    fi
+    ;;
+
   chorus*)
     case $cc_basename in
       *)
@@ -109683,7 +110261,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
     esac
     ;;
 
-
   cygwin* | mingw* | pw32*)
     # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
     # as there is no search path for DLLs.
@@ -109693,7 +110270,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
     enable_shared_with_static_runtimes_CXX=yes
 
     if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-      archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+      archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       # If the export-symbols file already is a .def file (1st line
       # is EXPORTS), use it as is; otherwise, prepend...
       archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
@@ -109702,65 +110279,37 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	echo EXPORTS > $output_objdir/$soname.def;
 	cat $export_symbols >> $output_objdir/$soname.def;
       fi~
-      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
     else
       ld_shlibs_CXX=no
     fi
   ;;
       darwin* | rhapsody*)
-        case $host_os in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
       archive_cmds_need_lc_CXX=no
       hardcode_direct_CXX=no
       hardcode_automatic_CXX=yes
       hardcode_shlibpath_var_CXX=unsupported
       whole_archive_flag_spec_CXX=''
       link_all_deplibs_CXX=yes
-
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
+      allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+      if test "$GXX" = yes ; then
       output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+      if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+        archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
       fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      else
-          archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       else
       case $cc_basename in
         xlc*)
          output_verbose_link_cmd='echo'
-          archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+          archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
           module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
           # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
        *)
@@ -109794,7 +110343,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
   freebsd-elf*)
     archive_cmds_need_lc_CXX=no
     ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
+  freebsd* | dragonfly*)
     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
     # conventions
     ld_shlibs_CXX=yes
@@ -109839,34 +110388,21 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
     ;;
   hpux10*|hpux11*)
     if test $with_gnu_ld = no; then
+      hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_CXX=:
+
       case $host_cpu in
-      hppa*64*)
-	hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
-	hardcode_libdir_flag_spec_ld_CXX='+b $libdir'
-	hardcode_libdir_separator_CXX=:
-        ;;
-      ia64*)
-	hardcode_libdir_flag_spec_CXX='-L$libdir'
-        ;;
+      hppa*64*|ia64*) ;;
       *)
-	hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_CXX=:
 	export_dynamic_flag_spec_CXX='${wl}-E'
         ;;
       esac
     fi
     case $host_cpu in
-    hppa*64*)
+    hppa*64*|ia64*)
       hardcode_direct_CXX=no
       hardcode_shlibpath_var_CXX=no
       ;;
-    ia64*)
-      hardcode_direct_CXX=no
-      hardcode_shlibpath_var_CXX=no
-      hardcode_minus_L_CXX=yes # Not in the search PATH,
-					      # but as the default
-					      # location of the library.
-      ;;
     *)
       hardcode_direct_CXX=yes
       hardcode_minus_L_CXX=yes # Not in the search PATH,
@@ -109882,8 +110418,11 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	;;
       aCC*)
 	case $host_cpu in
-	hppa*64*|ia64*)
-	  archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+	hppa*64*)
+	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	  ;;
 	*)
 	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -109903,8 +110442,11 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	if test "$GXX" = yes; then
 	  if test $with_gnu_ld = no; then
 	    case $host_cpu in
-	    ia64*|hppa*64*)
-	      archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+	    hppa*64*)
+	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    ia64*)
+	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	      ;;
 	    *)
 	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -109918,6 +110460,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	;;
     esac
     ;;
+  interix[3-9]*)
+    hardcode_direct_CXX=no
+    hardcode_shlibpath_var_CXX=no
+    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+    export_dynamic_flag_spec_CXX='${wl}-E'
+    # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+    # Instead, shared libraries are loaded at an image base (0x10000000 by
+    # default) and relocated if they conflict, which is a slow very memory
+    # consuming and fragmenting process.  To avoid this, we pick a random,
+    # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+    # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+    archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    ;;
   irix5* | irix6*)
     case $cc_basename in
       CC*)
@@ -109944,7 +110500,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
     hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
     hardcode_libdir_separator_CXX=:
     ;;
-  linux*)
+  linux* | k*bsd*-gnu)
     case $cc_basename in
       KCC*)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
@@ -109996,7 +110552,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
 	whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
+      pgCC* | pgcpp*)
         # Portland Group C++ compiler
 	archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
   	archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
@@ -110024,6 +110580,29 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	# dependencies.
 	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
 	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C++ 5.9
+	  no_undefined_flag_CXX=' -zdefs'
+	  archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	  hardcode_libdir_flag_spec_CXX='-R$libdir'
+	  whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+
+	  # Not sure whether something based on
+	  # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	  # would be better.
+	  output_verbose_link_cmd='echo'
+
+	  # Archives containing C++ object files must be created using
+	  # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	  # necessary to make sure instantiated templates are included
+	  # in the archive.
+	  old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+	  ;;
+	esac
+	;;
     esac
     ;;
   lynxos*)
@@ -110062,16 +110641,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
     ld_shlibs_CXX=no
     ;;
   openbsd*)
-    hardcode_direct_CXX=yes
-    hardcode_shlibpath_var_CXX=no
-    archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-      export_dynamic_flag_spec_CXX='${wl}-E'
-      whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    if test -f /usr/libexec/ld.so; then
+      hardcode_direct_CXX=yes
+      hardcode_shlibpath_var_CXX=no
+      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	export_dynamic_flag_spec_CXX='${wl}-E'
+	whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      fi
+      output_verbose_link_cmd='echo'
+    else
+      ld_shlibs_CXX=no
     fi
-    output_verbose_link_cmd='echo'
     ;;
   osf3*)
     case $cc_basename in
@@ -110200,19 +110783,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
     # FIXME: insert proper C++ library support
     ld_shlibs_CXX=no
     ;;
-  sco*)
-    archive_cmds_need_lc_CXX=no
-    case $cc_basename in
-      CC*)
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-      *)
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-    esac
-    ;;
   sunos4*)
     case $cc_basename in
       CC*)
@@ -110235,26 +110805,21 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
     case $cc_basename in
       CC*)
 	# Sun C++ 4.2, 5.x and Centerline C++
-     archive_cmds_need_lc_CXX=yes
+        archive_cmds_need_lc_CXX=yes
 	no_undefined_flag_CXX=' -zdefs'
-	archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	$CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
 
 	hardcode_libdir_flag_spec_CXX='-R$libdir'
 	hardcode_shlibpath_var_CXX=no
 	case $host_os in
 	  solaris2.[0-5] | solaris2.[0-5].*) ;;
 	  *)
-	    # The C++ compiler is used as linker so we must use $wl
-	    # flag to pass the commands to the underlying system
-	    # linker. We must also pass each convience library through
-	    # to the system linker between allextract/defaultextract.
-	    # The C++ compiler will combine linker options so we
-	    # cannot just pass the convience library names through
-	    # without $wl.
+	    # The compiler driver will combine and reorder linker options,
+	    # but understands `-z linker_flag'.
 	    # Supported since Solaris 2.6 (maybe 2.5.1?)
-	    whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+	    whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
 	    ;;
 	esac
 	link_all_deplibs_CXX=yes
@@ -110301,12 +110866,69 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	  fi
 
 	  hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+	  case $host_os in
+	  solaris2.[0-5] | solaris2.[0-5].*) ;;
+	  *)
+	    whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	    ;;
+	  esac
 	fi
 	;;
     esac
     ;;
-  sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
+  sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+    no_undefined_flag_CXX='${wl}-z,text'
+    archive_cmds_need_lc_CXX=no
+    hardcode_shlibpath_var_CXX=no
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
+    ;;
+  sysv5* | sco3.2v5* | sco5v6*)
+    # Note: We can NOT use -z defs as we might desire, because we do not
+    # link with -lc, and that would cause any symbols used from libc to
+    # always be unresolved, which means just about no library would
+    # ever link correctly.  If we're not using GNU ld we use -z text
+    # though, which does catch some bad symbols but isn't as heavy-handed
+    # as -z defs.
+    # For security reasons, it is highly recommended that you always
+    # use absolute paths for naming shared libraries, and exclude the
+    # DT_RUNPATH tag from executables and libraries.  But doing so
+    # requires that you compile everything twice, which is a pain.
+    # So that behaviour is only enabled if SCOABSPATH is set to a
+    # non-empty value in the environment.  Most likely only useful for
+    # creating official distributions of packages.
+    # This is a hack until libtool officially supports absolute path
+    # names for shared libraries.
+    no_undefined_flag_CXX='${wl}-z,text'
+    allow_undefined_flag_CXX='${wl}-z,nodefs'
     archive_cmds_need_lc_CXX=no
+    hardcode_shlibpath_var_CXX=no
+    hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+    hardcode_libdir_separator_CXX=':'
+    link_all_deplibs_CXX=yes
+    export_dynamic_flag_spec_CXX='${wl}-Bexport'
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
     ;;
   tandem*)
     case $cc_basename in
@@ -110340,7 +110962,6 @@ LD_CXX="$LD"
 ## There is no encapsulation within the following macros, do not change
 ## the running order or otherwise move them around unless you know exactly
 ## what you are doing...
-
 cat > conftest.$ac_ext <<EOF
 class Foo
 {
@@ -110351,7 +110972,7 @@ private:
 };
 EOF
 
-if { (eval echo configure:110355: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:110976: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   # Parse the compiler output and extract the necessary
   # objects, libraries and library flags.
 
@@ -110438,20 +111059,66 @@ fi
 
 $rm -f confest.$objext
 
+compiler_lib_search_dirs_CXX=
+if test -n "$compiler_lib_search_path_CXX"; then
+  compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
 # PORTME: override above test on systems where it is broken
 case $host_os in
+interix[3-9]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  predep_objects_CXX=
+  postdep_objects_CXX=
+  postdeps_CXX=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+    #
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
 solaris*)
   case $cc_basename in
   CC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
     # Adding this requires a known-good setup of shared libraries for
     # Sun compiler versions before 5.6, else PIC objects from an old
     # archive will be linked into the output, leading to subtle bugs.
-    postdeps_CXX='-lCstd -lCrun'
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
     ;;
   esac
+  ;;
 esac
 
-
 case " $postdeps_CXX " in
 *" -lc "*) archive_cmds_need_lc_CXX=no ;;
 esac
@@ -110461,7 +111128,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:110465: checking for $compiler option to produce PIC" >&5
+echo "configure:111132: checking for $compiler option to produce PIC" >&5
  
   # C++ specific cases for pic, static, wl, etc.
   if test "$GXX" = yes; then
@@ -110482,13 +111149,15 @@ echo "configure:110465: checking for $compiler option to produce PIC" >&5
       # like `-m68040'.
       lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
       ;;
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
       # PIC is the default for these OSes.
       ;;
-    mingw* | os2* | pw32*)
+    mingw* | cygwin* | os2* | pw32*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+	  lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -110499,6 +111168,10 @@ echo "configure:110465: checking for $compiler option to produce PIC" >&5
       # DJGPP does not support shared libraries at all
       lt_prog_compiler_pic_CXX=
       ;;
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
     sysv4*MP*)
       if test -d /usr/nec; then
 	lt_prog_compiler_pic_CXX=-Kconform_pic
@@ -110521,7 +111194,7 @@ echo "configure:110465: checking for $compiler option to produce PIC" >&5
     esac
   else
     case $host_os in
-      aix4* | aix5*)
+      aix[4-9]*)
 	# All AIX code is PIC.
 	if test "$host_cpu" = ia64; then
 	  # AIX 5 now supports IA64 processor
@@ -110561,21 +111234,21 @@ echo "configure:110465: checking for $compiler option to produce PIC" >&5
 	    ;;
 	esac
 	;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
+      freebsd* | dragonfly*)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
 	case $cc_basename in
 	  CC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
 	    if test "$host_cpu" != ia64; then
 	      lt_prog_compiler_pic_CXX='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -110589,6 +111262,10 @@ echo "configure:110465: checking for $compiler option to produce PIC" >&5
 	    ;;
 	esac
 	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
       irix5* | irix6* | nonstopux*)
 	case $cc_basename in
 	  CC*)
@@ -110600,7 +111277,7 @@ echo "configure:110465: checking for $compiler option to produce PIC" >&5
 	    ;;
 	esac
 	;;
-      linux*)
+      linux* | k*bsd*-gnu)
 	case $cc_basename in
 	  KCC*)
 	    # KAI C++ Compiler
@@ -110619,7 +111296,7 @@ echo "configure:110465: checking for $compiler option to produce PIC" >&5
         lt_prog_compiler_pic_CXX='-fPIC'
         lt_prog_compiler_static_CXX='-static'
         ;;
-	  pgCC*)
+	  pgCC* | pgcpp*)
 	    # Portland Group C++ compiler.
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_pic_CXX='-fpic'
@@ -110633,6 +111310,14 @@ echo "configure:110465: checking for $compiler option to produce PIC" >&5
 	    lt_prog_compiler_static_CXX='-non_shared'
 	    ;;
 	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      lt_prog_compiler_pic_CXX='-KPIC'
+	      lt_prog_compiler_static_CXX='-Bstatic'
+	      lt_prog_compiler_wl_CXX='-Qoption ld '
+	      ;;
+	    esac
 	    ;;
 	esac
 	;;
@@ -110674,15 +111359,6 @@ echo "configure:110465: checking for $compiler option to produce PIC" >&5
 	;;
       psos*)
 	;;
-      sco*)
-	case $cc_basename in
-	  CC*)
-	    lt_prog_compiler_pic_CXX='-fPIC'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
       solaris*)
 	case $cc_basename in
 	  CC*)
@@ -110724,7 +111400,14 @@ echo "configure:110465: checking for $compiler option to produce PIC" >&5
 	    ;;
 	esac
 	;;
-      unixware*)
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	esac
 	;;
       vxworks*)
 	;;
@@ -110742,13 +111425,13 @@ 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:110746: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
-if eval "test \"`echo '$''{'lt_prog_compiler_pic_works_CXX'+set}'`\" = set"; then
+echo "configure:111429: 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
-  lt_prog_compiler_pic_works_CXX=no
+  lt_cv_prog_compiler_pic_works_CXX=no
   ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
    lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
@@ -110759,27 +111442,27 @@ 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:110763: $lt_compile\"" >&5)
+   (eval echo "\"configure:111446: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "configure:110767: \$? = $ac_status" >&5
+   echo "configure:111450: \$? = $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.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works_CXX=yes
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_CXX=yes
      fi
    fi
    $rm conftest*
 
 fi
 
-echo "$ac_t""$lt_prog_compiler_pic_works_CXX" 1>&6
+echo "$ac_t""$lt_cv_prog_compiler_pic_works_CXX" 1>&6
 
-if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then
+if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
     case $lt_prog_compiler_pic_CXX in
      "" | " "*) ;;
      *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
@@ -110800,8 +111483,50 @@ case $host_os in
     ;;
 esac
 
+#
+# Check to make sure the static flag actually works.
+#
+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:111492: 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
+  lt_cv_prog_compiler_static_works_CXX=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_CXX=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_CXX=yes
+     fi
+   fi
+   $rm -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+
+echo "$ac_t""$lt_cv_prog_compiler_static_works_CXX" 1>&6
+
+if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+    :
+else
+    lt_prog_compiler_static_CXX=
+fi
+
+
 echo $ac_n "checking if $compiler supports -c -o file.$ac_objext""... $ac_c" 1>&6
-echo "configure:110805: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo "configure:111530: 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
@@ -110810,7 +111535,7 @@ else
    mkdir conftest
    cd conftest
    mkdir out
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
    lt_compiler_flag="-o out/conftest2.$ac_objext"
    # Insert the option either (1) after the last *FLAGS variable, or
@@ -110821,18 +111546,18 @@ 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:110825: $lt_compile\"" >&5)
+   (eval echo "\"configure:111550: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "configure:110829: \$? = $ac_status" >&5
+   echo "configure:111554: \$? = $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
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
        lt_cv_prog_compiler_c_o_CXX=yes
      fi
    fi
@@ -110855,7 +111580,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:110859: checking if we can lock with hard links" >&5
+echo "configure:111584: 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
@@ -110872,11 +111597,11 @@ else
 fi
 
 echo $ac_n "checking whether the $compiler linker ($LD) supports shared libraries""... $ac_c" 1>&6
-echo "configure:110876: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo "configure:111601: 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
-  aix4* | aix5*)
+  aix[4-9]*)
     # If we're using GNU nm, then we don't want the "-C" option.
     # -C means demangle to AIX nm, but means don't demangle with GNU nm
     if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
@@ -110889,21 +111614,17 @@ echo "configure:110876: checking whether the $compiler linker ($LD) supports sha
     export_symbols_cmds_CXX="$ltdll_cmds"
   ;;
   cygwin* | mingw*)
-    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
   ;;
   *)
     export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   esac
+  exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
 
 echo "$ac_t""$ld_shlibs_CXX" 1>&6
 test "$ld_shlibs_CXX" = no && can_build_shared=no
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
 #
 # Do we need to explicitly link libc?
 #
@@ -110922,16 +111643,17 @@ 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:110926: checking whether -lc should be explicitly linked in" >&5
+echo "configure:111647: checking whether -lc should be explicitly linked in" >&5
       $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-      if { (eval echo configure:110930: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } 2>conftest.err; then
+      if { (eval echo configure:111651: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } 2>conftest.err; then
         soname=conftest
         lib=conftest
         libobjs=conftest.$ac_objext
         deplibs=
         wl=$lt_prog_compiler_wl_CXX
+	pic_flag=$lt_prog_compiler_pic_CXX
         compiler_flags=-v
         linker_flags=-v
         verstring=
@@ -110939,7 +111661,7 @@ echo "configure:110926: 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:110943: \"$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:111665: \"$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
@@ -110958,7 +111680,7 @@ echo "configure:110926: checking whether -lc should be explicitly linked in" >&5
 esac
 
 echo $ac_n "checking dynamic linker characteristics""... $ac_c" 1>&6
-echo "configure:110962: checking dynamic linker characteristics" >&5
+echo "configure:111684: checking dynamic linker characteristics" >&5
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
@@ -110972,20 +111694,7 @@ shlibpath_overrides_runpath=unknown
 version_type=none
 dynamic_linker="$host_os ld.so"
 sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-  else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-  fi
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
+
 need_lib_prefix=unknown
 hardcode_into_libs=no
 
@@ -111003,7 +111712,7 @@ aix3*)
   soname_spec='${libname}${release}${shared_ext}$major'
   ;;
 
-aix4* | aix5*)
+aix[4-9]*)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -111142,12 +111851,7 @@ darwin* | rhapsody*)
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
+   
   sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
   ;;
 
@@ -111164,18 +111868,6 @@ freebsd1*)
   dynamic_linker=no
   ;;
 
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
@@ -111208,10 +111900,15 @@ freebsd* | dragonfly*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
-  *) # from 3.2 on
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
     shlibpath_overrides_runpath=no
     hardcode_into_libs=yes
     ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
   esac
   ;;
 
@@ -111271,6 +111968,18 @@ hpux9* | hpux10* | hpux11*)
   postinstall_cmds='chmod 555 $lib'
   ;;
 
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
 irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
@@ -111314,7 +112023,7 @@ linux*oldld* | linux*aout* | linux*coff*)
   ;;
 
 # This must be Linux ELF.
-linux*)
+linux* | k*bsd*-gnu)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -111328,27 +112037,10 @@ linux*)
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # find out which ABI we are using
-  libsuff=
-  case $host_cpu in
-  x86_64*|s390x*|powerpc64*)
-    echo '#line 111336 "configure"' > conftest.$ac_ext
-    if { (eval echo configure:111337: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-      case `/usr/bin/file conftest.$ac_objext` in
-      *64-bit*)
-        libsuff=64
-        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
-        ;;
-      esac
-    fi
-    rm -rf conftest*
-    ;;
-  esac
-
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ 	]*hwcap[ 	]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -111360,18 +112052,6 @@ linux*)
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -111409,6 +112089,7 @@ nto-qnx*)
 
 openbsd*)
   version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
   need_lib_prefix=no
   # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
   case $host_os in
@@ -111452,11 +112133,8 @@ osf3* | osf4* | osf5*)
   sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
   ;;
 
-sco3.2v5*)
-  version_type=osf
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
+rdos*)
+  dynamic_linker=no
   ;;
 
 solaris*)
@@ -111484,7 +112162,7 @@ sunos4*)
   need_version=yes
   ;;
 
-sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+sysv4 | sysv4.3*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
@@ -111517,6 +112195,29 @@ sysv4*MP*)
   fi
   ;;
 
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+    shlibpath_overrides_runpath=no
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    shlibpath_overrides_runpath=yes
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
 uts4*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -111531,8 +112232,28 @@ esac
 echo "$ac_t""$dynamic_linker" 1>&6
 test "$dynamic_linker" = no && can_build_shared=no
 
+if eval "test \"`echo '$''{'lt_cv_sys_lib_search_path_spec'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"
+fi
+
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if eval "test \"`echo '$''{'lt_cv_sys_lib_dlsearch_path_spec'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"
+fi
+
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
 echo $ac_n "checking how to hardcode library paths into programs""... $ac_c" 1>&6
-echo "configure:111536: checking how to hardcode library paths into programs" >&5
+echo "configure:112257: 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" || \
@@ -111567,612 +112288,6 @@ elif test "$shlibpath_overrides_runpath" = yes ||
   enable_fast_install=needless
 fi
 
-striplib=
-old_striplib=
-echo $ac_n "checking whether stripping libraries is possible""... $ac_c" 1>&6
-echo "configure:111574: 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"
-  echo "$ac_t""yes" 1>&6
-else
-# FIXME - insert some real tests, host_os isn't really good enough
-  case $host_os in
-   darwin*)
-       if test -n "$STRIP" ; then
-         striplib="$STRIP -x"
-         echo "$ac_t""yes" 1>&6
-       else
-  echo "$ac_t""no" 1>&6
-fi
-       ;;
-   *)
-  echo "$ac_t""no" 1>&6
-    ;;
-  esac
-fi
-
-if test "x$enable_dlopen" != xyes; then
-  enable_dlopen=unknown
-  enable_dlopen_self=unknown
-  enable_dlopen_self_static=unknown
-else
-  lt_cv_dlopen=no
-  lt_cv_dlopen_libs=
-
-  case $host_os in
-  beos*)
-    lt_cv_dlopen="load_add_on"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-    ;;
-
-  mingw* | pw32*)
-    lt_cv_dlopen="LoadLibrary"
-    lt_cv_dlopen_libs=
-   ;;
-
-  cygwin*)
-    lt_cv_dlopen="dlopen"
-    lt_cv_dlopen_libs=
-   ;;
-
-  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:111624: 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
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-ldl  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 111632 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char dlopen();
-
-int main() {
-dlopen()
-; return 0; }
-EOF
-if { (eval echo configure:111646: \"$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
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
-  echo "$ac_t""no" 1>&6
-
-    lt_cv_dlopen="dyld"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-    
-fi
-
-   ;;
-
-  *)
-    echo $ac_n "checking for shl_load""... $ac_c" 1>&6
-echo "configure:111675: 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 111680 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char shl_load(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char shl_load();
-
-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_shl_load) || defined (__stub___shl_load)
-choke me
-#else
-shl_load();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:111706: \"$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
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func_shl_load=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="shl_load"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
-echo "configure:111724: 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
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-ldld  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 111732 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char shl_load();
-
-int main() {
-shl_load()
-; return 0; }
-EOF
-if { (eval echo configure:111746: \"$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
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:111765: 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 111770 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char dlopen(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char dlopen();
-
-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_dlopen) || defined (__stub___dlopen)
-choke me
-#else
-dlopen();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:111796: \"$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
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func_dlopen=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="dlopen"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:111814: 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
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-ldl  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 111822 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char dlopen();
-
-int main() {
-dlopen()
-; return 0; }
-EOF
-if { (eval echo configure:111836: \"$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
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for dlopen in -lsvld""... $ac_c" 1>&6
-echo "configure:111855: 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
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-lsvld  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 111863 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char dlopen();
-
-int main() {
-dlopen()
-; return 0; }
-EOF
-if { (eval echo configure:111877: \"$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
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6
-echo "configure:111896: 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
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-ldld  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 111904 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char dld_link();
-
-int main() {
-dld_link()
-; return 0; }
-EOF
-if { (eval echo configure:111918: \"$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
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-	      
-fi
-
-	    
-fi
-
-	  
-fi
-
-	
-fi
-
-      
-fi
-
-    ;;
-  esac
-
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
-    enable_dlopen=no
-  fi
-
-  case $lt_cv_dlopen in
-  dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
-    save_LDFLAGS="$LDFLAGS"
-    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
-    save_LIBS="$LIBS"
-    LIBS="$lt_cv_dlopen_libs $LIBS"
-
-    echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6
-echo "configure:111974: 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
-  	  if test "$cross_compiling" = yes; then :
-  lt_cv_dlopen_self=cross
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<EOF
-#line 111984 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
-
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
-      /* dlclose (self); */
-    }
-
-    exit (status);
-}
-EOF
-  if { (eval echo configure:112045: \"$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
-      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
-    esac
-  else :
-    # compilation failed
-    lt_cv_dlopen_self=no
-  fi
-fi
-rm -fr conftest*
-
-    
-fi
-
-echo "$ac_t""$lt_cv_dlopen_self" 1>&6
-
-    if test "x$lt_cv_dlopen_self" = xyes; then
-      LDFLAGS="$LDFLAGS $link_static_flag"
-      echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6
-echo "configure:112068: 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
-  	  if test "$cross_compiling" = yes; then :
-  lt_cv_dlopen_self_static=cross
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<EOF
-#line 112078 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
-
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
-      /* dlclose (self); */
-    }
-
-    exit (status);
-}
-EOF
-  if { (eval echo configure:112139: \"$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
-      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
-    esac
-  else :
-    # compilation failed
-    lt_cv_dlopen_self_static=no
-  fi
-fi
-rm -fr conftest*
-
-      
-fi
-
-echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6
-    fi
-
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
-    ;;
-  esac
-
-  case $lt_cv_dlopen_self in
-  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
-  *) enable_dlopen_self=unknown ;;
-  esac
-
-  case $lt_cv_dlopen_self_static in
-  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
-  *) enable_dlopen_self_static=unknown ;;
-  esac
-fi
-
 
 # The else clause should only fire when bootstrapping the
 # libtool distribution, otherwise you forgot to ship ltmain.sh
@@ -112187,7 +112302,7 @@ if test -f "$ltmain"; then
   # Now quote all the things that may contain metacharacters while being
   # careful not to overquote the AC_SUBSTed values.  We take copies of the
   # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
     SED SHELL STRIP \
     libname_spec library_names_spec soname_spec extract_expsyms_cmds \
     old_striplib striplib file_magic_cmd finish_cmds finish_eval \
@@ -112214,6 +112329,7 @@ if test -f "$ltmain"; then
     predeps_CXX \
     postdeps_CXX \
     compiler_lib_search_path_CXX \
+    compiler_lib_search_dirs_CXX \
     archive_cmds_CXX \
     archive_expsym_cmds_CXX \
     postinstall_cmds_CXX \
@@ -112229,6 +112345,7 @@ if test -f "$ltmain"; then
     module_cmds_CXX \
     module_expsym_cmds_CXX \
     lt_cv_prog_compiler_c_o_CXX \
+    fix_srcfile_path_CXX \
     exclude_expsyms_CXX \
     include_expsyms_CXX; do
 
@@ -112305,6 +112422,9 @@ AR_FLAGS=$lt_AR_FLAGS
 # A C compiler.
 LTCC=$lt_LTCC
 
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
 # A language-specific compiler.
 CC=$lt_compiler_CXX
 
@@ -112458,6 +112578,10 @@ predeps=$lt_predeps_CXX
 # shared library.
 postdeps=$lt_postdeps_CXX
 
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
+
 # The library search path used internally by the compiler when linking
 # a shared library.
 compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
@@ -112546,7 +112670,7 @@ sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
 
 # Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_CXX"
+fix_srcfile_path=$lt_fix_srcfile_path
 
 # Set to yes if exported symbols are required.
 always_export_symbols=$always_export_symbols_CXX
@@ -112602,26 +112726,6 @@ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
 	fi
 	;;
 
-#      F77)
-#	if test -n "$F77" && test "X$F77" != "Xno"; then
-#	  AC_LIBTOOL_LANG_F77_CONFIG
-#	else
-#	  tagname=""
-#	fi
-#	;;
-#
-#      GCJ)
-#	if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
-#	  AC_LIBTOOL_LANG_GCJ_CONFIG
-#	else
-#	  tagname=""
-#	fi
-#	;;
-#
-#      RC)
-#	AC_LIBTOOL_LANG_RC_CONFIG
-#	;;
-
       *)
 	{ echo "configure: error: Unsupported tag name: $tagname" 1>&2; exit 1; }
 	;;
@@ -112665,8 +112769,6 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool'
 
 
 
-
-
 if test "$enable_debug" != "yes"; then
   
   if test -z "$LIBTOOL"; then
@@ -112691,14 +112793,6 @@ SHARED_LIBTOOL='$(LIBTOOL)'
 
 CC=$old_CC
 
-if test "$php_did_darwin9_cheat" -eq 1; then
-  if test "$PHP_DEBUG" = "1"; then
-    CFLAGS=`echo "$CFLAGS" | $SED -e 's/-gstabs/-g/g'`
-  else
-    CFLAGS=`echo "-O2 $CFLAGS" | $SED -e 's/-gstabs//g'`
-  fi
-fi
-
 
   echo "$ac_t""" 1>&6
   echo "$ac_t""${T_MD}Generating files${T_ME}" 1>&6
@@ -113457,6 +113551,7 @@ s%@INCLUDE_PATH@%$INCLUDE_PATH%g
 s%@EXPANDED_PEAR_INSTALLDIR@%$EXPANDED_PEAR_INSTALLDIR%g
 s%@EXPANDED_EXTENSION_DIR@%$EXPANDED_EXTENSION_DIR%g
 s%@EXPANDED_BINDIR@%$EXPANDED_BINDIR%g
+s%@EXPANDED_SBINDIR@%$EXPANDED_SBINDIR%g
 s%@EXPANDED_LIBDIR@%$EXPANDED_LIBDIR%g
 s%@EXPANDED_DATADIR@%$EXPANDED_DATADIR%g
 s%@EXPANDED_SYSCONFDIR@%$EXPANDED_SYSCONFDIR%g
@@ -113495,6 +113590,8 @@ s%@EXEEXT@%$EXEEXT%g
 s%@ECHO@%$ECHO%g
 s%@AR@%$AR%g
 s%@STRIP@%$STRIP%g
+s%@DSYMUTIL@%$DSYMUTIL%g
+s%@NMEDIT@%$NMEDIT%g
 s%@LIBTOOL@%$LIBTOOL%g
 
 CEOF
diff --git a/configure.in b/configure.in
index 388d3af..ff29b83 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-## $Id: configure.in 290928 2009-11-18 19:43:33Z johannes $ -*- autoconf -*-
+## $Id: configure.in 295792 2010-03-03 16:36:07Z 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=1
+PHP_RELEASE_VERSION=2
 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`
@@ -122,21 +122,6 @@ dnl or the contents of libs.
 $php_shtool mkdir -p libs
 rm -f libs/*
 
-dnl Darwin 9 hack
-dnl Because the default debugging format used by Apple's GCC on Mac OS 10.5
-dnl causes errors in all current and past versions of Autoconf, we do a little
-dnl messing with the CFLAGS here to trick it.
-php_did_darwin9_cheat=0
-case $host_alias in
-*darwin9*)
-  hasg=`echo $CFLAGS | grep -E '(^-g)|([[:space:]]-g)'`
-  if test x"$hasg" = "x"; then
-    php_did_darwin9_cheat=1
-    CFLAGS="$CFLAGS -gstabs"
-  fi
-  ;;
-esac
-
 dnl Checks for programs.
 dnl -------------------------------------------------------------------------
 
@@ -402,9 +387,6 @@ dnl Check for inet_aton
 dnl in -lc, -lbind and -lresolv
 PHP_CHECK_FUNC(inet_aton, resolv, bind)
 
-dnl Some systems (like OpenSolaris) do not have nanosleep in libc
-PHP_CHECK_FUNC(nanosleep, rt)
-
 dnl Then headers.
 dnl -------------------------------------------------------------------------
 
@@ -424,7 +406,6 @@ sys/time.h \
 netinet/in.h \
 alloca.h \
 arpa/inet.h \
-arpa/nameser_compat.h \
 arpa/nameser.h \
 assert.h \
 crypt.h \
@@ -629,6 +610,9 @@ vasprintf \
 asprintf \
 )
 
+dnl Some systems (like OpenSolaris) do not have nanosleep in libc
+AC_CACHE_CHECK([for nanosleep], ac_cv_func_nanosleep, [PHP_CHECK_FUNC_LIB(nanosleep, rt)])
+
 dnl Check for getaddrinfo, should be a better way, but...
 dnl Also check for working getaddrinfo
 AC_CACHE_CHECK([for getaddrinfo], ac_cv_func_getaddrinfo,
@@ -1171,6 +1155,7 @@ EXPANDED_PEAR_INSTALLDIR=`eval echo $PEAR_INSTALLDIR`
 EXPANDED_EXTENSION_DIR=`eval echo $EXTENSION_DIR`
 EXPANDED_LOCALSTATEDIR=`eval echo $localstatedir`
 EXPANDED_BINDIR=`eval echo $bindir`
+EXPANDED_SBINDIR=`eval echo $sbindir`
 EXPANDED_LIBDIR=$libdir
 EXPANDED_SYSCONFDIR=`eval echo $sysconfdir`
 EXPANDED_DATADIR=$datadir
@@ -1186,6 +1171,7 @@ AC_SUBST(INCLUDE_PATH)
 AC_SUBST(EXPANDED_PEAR_INSTALLDIR)
 AC_SUBST(EXPANDED_EXTENSION_DIR)
 AC_SUBST(EXPANDED_BINDIR)
+AC_SUBST(EXPANDED_SBINDIR)
 AC_SUBST(EXPANDED_LIBDIR)
 AC_SUBST(EXPANDED_DATADIR)
 AC_SUBST(EXPANDED_SYSCONFDIR)
@@ -1230,12 +1216,14 @@ if test "$PHP_CLI" != "no"; then
   PHP_INSTALL_CLI_TARGET="install-cli"
   PHP_ADD_SOURCES(sapi/cli, php_cli.c php_cli_readline.c,, cli)
   PHP_INSTALLED_SAPIS="cli $PHP_SAPI"
+  PHP_EXECUTABLE="\$(top_builddir)/\$(SAPI_CLI_PATH)"
 else
   PHP_INSTALLED_SAPIS="$PHP_SAPI"
 fi
 
 PHP_SUBST_OLD(PHP_INSTALLED_SAPIS)
 
+PHP_SUBST(PHP_EXECUTABLE)
 PHP_SUBST(PHP_CLI_TARGET)
 PHP_SUBST(PHP_SAPI_OBJS)
 PHP_SUBST(PHP_CLI_OBJS)
@@ -1252,6 +1240,7 @@ PHP_SUBST_OLD(php_abs_top_builddir)
 PHP_SUBST_OLD(php_abs_top_srcdir)
 
 PHP_SUBST(bindir)
+PHP_SUBST(sbindir)
 PHP_SUBST(exec_prefix)
 PHP_SUBST_OLD(program_prefix)
 PHP_SUBST_OLD(program_suffix)
@@ -1336,6 +1325,14 @@ PHP_CONFIGURE_PART(Configuring libtool)
 
 LDFLAGS="$LDFLAGS $PHP_AIX_LDFLAGS"
 
+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=
+	;;
+esac
+
 dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by PHP_REQUIRE_CXX).
 dnl Otherwise AC_PROG_LIBTOOL fails if there is no working C++ compiler.
 AC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [
@@ -1359,15 +1356,6 @@ SHARED_LIBTOOL='$(LIBTOOL)'
 
 CC=$old_CC
 
-dnl Finish the Darwin hack
-if test "$php_did_darwin9_cheat" -eq 1; then
-  if test "$PHP_DEBUG" = "1"; then
-    CFLAGS=`echo "$CFLAGS" | $SED -e 's/-gstabs/-g/g'`
-  else
-    CFLAGS=`echo "-O2 $CFLAGS" | $SED -e 's/-gstabs//g'`
-  fi
-fi
-
 PHP_CONFIGURE_PART(Generating files)
 
 CXXFLAGS_CLEAN=$CXXFLAGS
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c
index 66485ce..85440d6 100644
--- a/ext/bcmath/bcmath.c
+++ b/ext/bcmath/bcmath.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: bcmath.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: bcmath.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/bcmath/php_bcmath.h b/ext/bcmath/php_bcmath.h
index 49cdc1a..888bb15 100644
--- a/ext/bcmath/php_bcmath.h
+++ b/ext/bcmath/php_bcmath.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_bcmath.h 287499 2009-08-20 11:19:20Z jani $ */
+/* $Id: php_bcmath.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_BCMATH_H
 #define PHP_BCMATH_H
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c
index 70eefc8..9ecaf29 100644
--- a/ext/bz2/bz2.c
+++ b/ext/bz2/bz2.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
  
-/* $Id: bz2.c 280600 2009-05-15 17:28:08Z kalle $ */
+/* $Id: bz2.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/bz2/bz2_filter.c b/ext/bz2/bz2_filter.c
index 1522895..9daf498 100644
--- a/ext/bz2/bz2_filter.c
+++ b/ext/bz2/bz2_filter.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: bz2_filter.c 275246 2009-02-05 21:45:43Z sixd $ */
+/* $Id: bz2_filter.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/bz2/php_bz2.h b/ext/bz2/php_bz2.h
index 4c90856..c97a8e9 100644
--- a/ext/bz2/php_bz2.h
+++ b/ext/bz2/php_bz2.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_bz2.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_bz2.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_BZ2_H
 #define PHP_BZ2_H
diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c
index 117156d..1a81f9d 100644
--- a/ext/calendar/cal_unix.c
+++ b/ext/calendar/cal_unix.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c
index 5efc739..6884d17 100644
--- a/ext/calendar/calendar.c
+++ b/ext/calendar/calendar.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    |          Wez Furlong               <wez at thebrainroom.com>            |
    +----------------------------------------------------------------------+
  */
-/* $Id: calendar.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: calendar.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/calendar/easter.c b/ext/calendar/easter.c
index 9650978..dd3c63f 100644
--- a/ext/calendar/easter.c
+++ b/ext/calendar/easter.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c
index 7395ed2..9d36133 100644
--- a/ext/com_dotnet/com_com.c
+++ b/ext/com_dotnet/com_com.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_com.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: com_com.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/com_dotnet/com_dotnet.c b/ext/com_dotnet/com_dotnet.c
index 5d77d9e..9625e04 100644
--- a/ext/com_dotnet/com_dotnet.c
+++ b/ext/com_dotnet/com_dotnet.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_dotnet.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: com_dotnet.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c
index 1b64d41..9606cc9 100644
--- a/ext/com_dotnet/com_extension.c
+++ b/ext/com_dotnet/com_extension.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_extension.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: com_extension.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c
index 5256b85..e252734 100644
--- a/ext/com_dotnet/com_handlers.c
+++ b/ext/com_dotnet/com_handlers.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_handlers.c 280806 2009-05-19 17:38:29Z kalle $ */
+/* $Id: com_handlers.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/com_dotnet/com_iterator.c b/ext/com_dotnet/com_iterator.c
index 8353203..4423da2 100644
--- a/ext/com_dotnet/com_iterator.c
+++ b/ext/com_dotnet/com_iterator.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_iterator.c 280806 2009-05-19 17:38:29Z kalle $ */
+/* $Id: com_iterator.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c
index 525dfa4..3cea970 100644
--- a/ext/com_dotnet/com_misc.c
+++ b/ext/com_dotnet/com_misc.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_misc.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: com_misc.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/com_dotnet/com_olechar.c b/ext/com_dotnet/com_olechar.c
index 209446c..8692517 100644
--- a/ext/com_dotnet/com_olechar.c
+++ b/ext/com_dotnet/com_olechar.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_olechar.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: com_olechar.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c
index c19b5a4..7bfc341 100755
--- a/ext/com_dotnet/com_persist.c
+++ b/ext/com_dotnet/com_persist.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_persist.c 280806 2009-05-19 17:38:29Z kalle $ */
+/* $Id: com_persist.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Infrastructure for working with persistent COM objects.
  * Implements: IStream* wrapper for PHP streams.
diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c
index 4c9e61f..10fe37e 100644
--- a/ext/com_dotnet/com_saproxy.c
+++ b/ext/com_dotnet/com_saproxy.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_saproxy.c 280806 2009-05-19 17:38:29Z kalle $ */
+/* $Id: com_saproxy.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* This module implements a SafeArray proxy which is used internally
  * by the engine when resolving multi-dimensional array accesses on
diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c
index a26175d..3c03231 100644
--- a/ext/com_dotnet/com_typeinfo.c
+++ b/ext/com_dotnet/com_typeinfo.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_typeinfo.c 289996 2009-10-27 19:16:55Z pajoye $ */
+/* $Id: com_typeinfo.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c
index 44e5daa..85e1774 100644
--- a/ext/com_dotnet/com_variant.c
+++ b/ext/com_dotnet/com_variant.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_variant.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: com_variant.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c
index 0b2cd14..76d1473 100644
--- a/ext/com_dotnet/com_wrapper.c
+++ b/ext/com_dotnet/com_wrapper.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_wrapper.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: com_wrapper.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* This module exports a PHP object as a COM object by wrapping it
  * using IDispatchEx */
diff --git a/ext/com_dotnet/php_com_dotnet.h b/ext/com_dotnet/php_com_dotnet.h
index 092a826..5660c6e 100644
--- a/ext/com_dotnet/php_com_dotnet.h
+++ b/ext/com_dotnet/php_com_dotnet.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_com_dotnet.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_com_dotnet.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_COM_DOTNET_H
 #define PHP_COM_DOTNET_H
diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h
index 54963b9..f8715ff 100644
--- a/ext/com_dotnet/php_com_dotnet_internal.h
+++ b/ext/com_dotnet/php_com_dotnet_internal.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_com_dotnet_internal.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_com_dotnet_internal.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_COM_DOTNET_INTERNAL_H
 #define PHP_COM_DOTNET_INTERNAL_H
diff --git a/ext/ctype/ctype.c b/ext/ctype/ctype.c
index 2297d8e..1e02621 100644
--- a/ext/ctype/ctype.c
+++ b/ext/ctype/ctype.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/ctype/php_ctype.h b/ext/ctype/php_ctype.h
index 62c8d60..ea4f338 100644
--- a/ext/ctype/php_ctype.h
+++ b/ext/ctype/php_ctype.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 98883e9..1f6f6a9 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: interface.c 289495 2009-10-10 09:24:59Z pajoye $ */
+/* $Id: interface.c 294464 2010-02-03 20:53:31Z pajoye $ */
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
@@ -629,6 +629,9 @@ PHP_MINIT_FUNCTION(curl)
 	REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_COUNT);
 	REGISTER_CURL_CONSTANT(CURLINFO_HEADER_OUT);
 	REGISTER_CURL_CONSTANT(CURLINFO_PRIVATE);
+#if LIBCURL_VERSION_NUM >  0x071301
+	REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO);
+#endif
 
 	/* cURL protocol constants (curl_version) */
 	REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6);
@@ -745,6 +748,11 @@ PHP_MINIT_FUNCTION(curl)
 	REGISTER_CURL_CONSTANT(CURLFTPSSL_ALL);
 #endif
 
+#if LIBCURL_VERSION_NUM > 0x071301
+	REGISTER_CURL_CONSTANT(CURLOPT_CERTINFO);
+	REGISTER_CURL_CONSTANT(CURLOPT_POSTREDIR);
+#endif
+
 /* SSH support works in 7.19.0+ using libssh2 */
 #if LIBCURL_VERSION_NUM >= 0x071300
 	REGISTER_CURL_CONSTANT(CURLSSH_AUTH_NONE);
@@ -781,6 +789,7 @@ PHP_MINIT_FUNCTION(curl)
 
 #if LIBCURL_VERSION_NUM >= 0x070f01
 	REGISTER_CURL_CONSTANT(CURLOPT_FTP_FILEMETHOD);
+	REGISTER_CURL_CONSTANT(CURLOPT_FTP_SKIP_PASV_IP);
 #endif
 
 #if LIBCURL_VERSION_NUM >= 0x071001
@@ -1336,6 +1345,83 @@ static void alloc_curl_handle(php_curl **ch)
 }
 /* }}} */
 
+#if LIBCURL_VERSION_NUM > 0x071301
+/* {{{ split_certinfo
+ */
+static void split_certinfo(char *string, zval *hash)
+{
+	char *org = estrdup(string);
+	char *s = org;
+	char *split;
+
+	if(org) {
+        do {
+			char *key;
+			char *val;
+			char *tmp;
+
+            split = strstr(s, "; ");
+            if(split)
+                *split = '\0';
+			
+			key = s;
+			tmp = memchr(key, '=', 64);
+			if(tmp) {
+				*tmp = '\0';
+				val = tmp+1;
+				add_assoc_string(hash, key, val, 1);
+			}
+			s = split+2;
+		} while(split);
+		efree(org);
+	}
+}
+
+/* {{{ create_certinfo
+ */
+static void create_certinfo(struct curl_certinfo *ci, zval *listcode TSRMLS_DC)
+{
+	int i;
+			
+	if(ci) {
+		zval *certhash = NULL;
+		
+		for(i=0; i<ci->num_of_certs; i++) {
+			struct curl_slist *slist;
+			
+			MAKE_STD_ZVAL(certhash);
+			array_init(certhash);
+			for(slist = ci->certinfo[i]; slist; slist = slist->next) {
+				int len;
+				char s[64];
+				char *tmp;
+				strncpy(s, slist->data, 64);
+				tmp = memchr(s, ':', 64);
+				if(tmp) {
+					*tmp = '\0';
+					len = strlen(s);
+					if(!strcmp(s, "Subject") || !strcmp(s, "Issuer")) {
+						zval *hash;
+
+						MAKE_STD_ZVAL(hash);
+						array_init(hash);
+						
+						split_certinfo(&slist->data[len+1], hash);
+						add_assoc_zval(certhash, s, hash);
+					} else {
+						add_assoc_string(certhash, s, &slist->data[len+1], 1);
+					}
+				} else {
+					php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not extract hash key from certificate info"); 
+				}
+			}
+			add_next_index_zval(listcode, certhash);
+		}
+	}
+}
+/* }}} */
+#endif
+
 /* {{{ proto resource curl_init([string url])
    Initialize a cURL session */
 PHP_FUNCTION(curl_init)
@@ -1572,6 +1658,10 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
 #endif
 #if LIBCURL_VERSION_NUM >= 0x070f01
 		case CURLOPT_FTP_FILEMETHOD:
+		case CURLOPT_FTP_SKIP_PASV_IP:
+#endif
+#if LIBCURL_VERSION_NUM >  0x071301
+		case CURLOPT_CERTINFO:
 #endif
 			convert_to_long_ex(zvalue);
 #if LIBCURL_VERSION_NUM >= 0x71304
@@ -1595,6 +1685,12 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
 			}
 			error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue));
 			break;
+#if LIBCURL_VERSION_NUM > 0x071301
+		case CURLOPT_POSTREDIR:
+			convert_to_long_ex(zvalue);
+			error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, Z_LVAL_PP(zvalue) & CURL_REDIR_POST_ALL);
+			break;
+#endif
 		case CURLOPT_PRIVATE:
 		case CURLOPT_URL:
 		case CURLOPT_PROXY:
@@ -1852,7 +1948,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
 						error = curl_formadd(&first, &last,
 										CURLFORM_COPYNAME, string_key,
 										CURLFORM_NAMELENGTH, (long)string_key_len - 1,
-										CURLFORM_FILENAME, filename ? filename : postval,
+										CURLFORM_FILENAME, filename ? filename + sizeof(";filename=") - 1 : postval,
 										CURLFORM_CONTENTTYPE, type ? type + sizeof(";type=") - 1 : "application/octet-stream",
 										CURLFORM_FILE, postval,
 										CURLFORM_END);
@@ -2121,6 +2217,10 @@ PHP_FUNCTION(curl_getinfo)
 		char   *s_code;
 		long    l_code;
 		double  d_code;
+#if LIBCURL_VERSION_NUM >  0x071301
+		struct curl_certinfo *ci = NULL;
+		zval *listcode;
+#endif
 
 		array_init(return_value);
 
@@ -2191,6 +2291,14 @@ PHP_FUNCTION(curl_getinfo)
 		if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code) == CURLE_OK) {
 			CAAD("redirect_time", d_code);
 		}
+#if LIBCURL_VERSION_NUM > 0x071301
+		if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
+			MAKE_STD_ZVAL(listcode);
+			array_init(listcode);
+			create_certinfo(ci, listcode TSRMLS_CC);
+			CAAZ("certinfo", listcode);
+		}
+#endif
 		if (ch->header.str_len > 0) {
 			CAAS("request_header", ch->header.str);
 		}
@@ -2250,6 +2358,20 @@ PHP_FUNCTION(curl_getinfo)
 				} else {
 					RETURN_FALSE;
 				}
+#if LIBCURL_VERSION_NUM > 0x071301
+			case CURLINFO_CERTINFO: {
+				struct curl_certinfo *ci = NULL;
+
+				array_init(return_value);
+				
+				if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
+					create_certinfo(ci, return_value TSRMLS_CC);
+				} else {
+					RETURN_FALSE;
+				}
+				break;
+			}
+#endif
 		}
 	}
 }
diff --git a/ext/curl/multi.c b/ext/curl/multi.c
index 91312e4..0fdad1a 100644
--- a/ext/curl/multi.c
+++ b/ext/curl/multi.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: multi.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: multi.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h
index 657a0cd..21e3ec1 100644
--- a/ext/curl/php_curl.h
+++ b/ext/curl/php_curl.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_curl.h 289496 2009-10-10 09:29:34Z pajoye $ */
+/* $Id: php_curl.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef _PHP_CURL_H
 #define _PHP_CURL_H
diff --git a/ext/curl/streams.c b/ext/curl/streams.c
index 26786ad..39d78f7 100644
--- a/ext/curl/streams.c
+++ b/ext/curl/streams.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: streams.c 284747 2009-07-25 13:00:25Z jani $ */
+/* $Id: streams.c 294462 2010-02-03 20:49:03Z pajoye $ */
 
 /* This file implements cURL based wrappers.
  * NOTE: If you are implementing your own streams that are intended to
@@ -280,7 +280,7 @@ php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename,
 	 * have a FILE* associated with it.
 	 * Otherwise, use the "smart" memory stream that will turn itself into a file
 	 * when it gets large */
-#if !HAVE_FOPENCOOKIE
+#ifndef HAVE_FOPENCOOKIE
 	if (options & STREAM_WILL_CAST) {
 		curlstream->readbuffer.buf = php_stream_fopen_tmpfile();
 	} else
@@ -445,7 +445,7 @@ php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename,
 	php_stream_to_zval(curlstream->readbuffer.buf, tmp);
 	add_assoc_zval(stream->wrapperdata, "readbuf", tmp);
 
-#if !HAVE_FOPENCOOKIE
+#ifndef HAVE_FOPENCOOKIE
 	if (options & STREAM_WILL_CAST) {
 		/* we will need to download the whole resource now,
 		 * since we cannot get the actual FD for the download,
diff --git a/ext/curl/tests/curl_basic_016.phpt b/ext/curl/tests/curl_basic_016.phpt
index 5c947eb..b5890c0 100644
--- a/ext/curl/tests/curl_basic_016.phpt
+++ b/ext/curl/tests/curl_basic_016.phpt
@@ -3,7 +3,13 @@ Test curl_getinfo() function with basic functionality
 --CREDITS--
 Jean-Marc Fontaine <jmf at durcommefaire.net>
 --SKIPIF--
-<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
+<?php 
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+$curl_version = curl_version();
+if ($curl_version['version_number'] > 0x071201) {
+    exit("skip: tests works only on older versions of curl");
+}
+?>
 --FILE--
 <?php
   $ch   = curl_init();
@@ -12,7 +18,7 @@ Jean-Marc Fontaine <jmf at durcommefaire.net>
 ?>
 ===DONE===
 --EXPECTF--
-array(20) {
+array(2%d) {
   [%u|b%"url"]=>
   string(0) ""
   ["content_type"]=>
diff --git a/ext/curl/tests/curl_ftp_pasv.phpt b/ext/curl/tests/curl_ftp_pasv.phpt
new file mode 100644
index 0000000..6cd7429
--- /dev/null
+++ b/ext/curl/tests/curl_ftp_pasv.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Test curl_exec() function with basic functionality 
+--CREDITS--
+--SKIPIF--
+<?php 
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+if (false === getenv('PHP_CURL_FTP_REMOTE_SERVER'))  exit("skip PHP_CURL_FTP_REMOTE_SERVER env variable is not defined");
+if (false === getenv('PHP_CURL_FTP_REMOTE_USER'))  exit("skip PHP_CURL_FTP_REMOTE_USER env variable is not defined");
+if (false === getenv('PHP_CURL_FTP_REMOTE_PASSWD'))  exit("skip PHP_CURL_FTP_REMOTE_PASSWD env variable is not defined");
+?>
+--FILE--
+<?php
+  $host = getenv('PHP_CURL_FTP_REMOTE_SERVER');
+  $username = getenv('PHP_CURL_FTP_REMOTE_USER');
+  $password = getenv('PHP_CURL_FTP_REMOTE_PASSWD');
+
+  // FTP this script to a server 
+  $fp  =  fopen ( __FILE__ ,  "r" );
+  $url  =  "ftp://$username:$password@$host/test.phpt" ;
+
+  $ch  =  curl_init ();
+
+  // enable below to get the output in verbose mode.
+  // curl_setopt ( $ch , CURLOPT_VERBOSE, 1 );
+
+  /* Without enabling SKIP_PASV_IP flag, the following output will be seen..
+	< 227 Entering Passive Mode (10,5,80,146,100,199)
+	*   Trying 10.5.80.146... * connected
+	* Connecting to 10.5.80.146 (10.5.80.146) port 25799
+   */
+
+  /* After enabling SKIP_PASV_IP flag, the following output will be seen..
+	< 227 Entering Passive Mode (10,5,80,146,50,229)
+	* Skips 10.5.80.146 for data connection, uses 10.5.80.146 instead
+	*   Trying 10.5.80.146... * connected
+   */
+
+  curl_setopt ( $ch , CURLOPT_URL, $url );
+  curl_setopt ( $ch , CURLOPT_TRANSFERTEXT, 1 );
+
+  //force passive connection
+  curl_setopt ( $ch , CURLOPT_FTP_USE_EPSV, 0 );
+  curl_setopt ( $ch , CURLOPT_FTP_SKIP_PASV_IP, 1 );
+
+  // mark the file for upload..
+  curl_setopt ( $ch , CURLOPT_INFILE, $fp );
+  curl_setopt ( $ch , CURLOPT_INFILESIZE,  filesize(__FILE__) );
+  curl_setopt ( $ch , CURLOPT_PUT, 1 );
+  curl_setopt ( $ch , CURLOPT_UPLOAD, 1 );
+
+  $result  =  curl_exec ( $ch );
+  var_dump ( $result );
+  curl_close ( $ch );
+
+?>
+===DONE===
+--EXPECTF--
+bool(true)
+===DONE===
diff --git a/ext/curl/tests/curl_setopt_basic001.phpt b/ext/curl/tests/curl_setopt_basic001.phpt
index 4167c05..99cb538 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--
-PHP Warning:  Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 in safe_mode or an open_basedir is set in %s on line %d
diff --git a/ext/date/config0.m4 b/ext/date/config0.m4
index c26f50b..1d5ed74 100644
--- a/ext/date/config0.m4
+++ b/ext/date/config0.m4
@@ -1,4 +1,4 @@
-dnl $Id: config0.m4 280468 2009-05-13 18:48:20Z jani $
+dnl $Id: config0.m4 294880 2010-02-11 11:11:47Z pajoye $
 dnl config.m4 for date extension
 
 sinclude(ext/date/lib/timelib.m4)
diff --git a/ext/date/lib/astro.c b/ext/date/lib/astro.c
index a9fd43d..e176aeb 100644
--- a/ext/date/lib/astro.c
+++ b/ext/date/lib/astro.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: astro.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: astro.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdio.h>
 #include <math.h>
diff --git a/ext/date/lib/dow.c b/ext/date/lib/dow.c
index eb4b329..857ded2 100644
--- a/ext/date/lib/dow.c
+++ b/ext/date/lib/dow.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dow.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dow.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "timelib.h"
 
diff --git a/ext/date/lib/interval.c b/ext/date/lib/interval.c
index 07be026..42bb13b 100644
--- a/ext/date/lib/interval.c
+++ b/ext/date/lib/interval.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: interval.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: interval.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "timelib.h"
 
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
index 4938127..1f08a95 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 Wed Jul 29 16:20:12 2009 */
+/* Generated by re2c 0.13.5 on Wed Feb 10 15:19:23 2010 */
 /*
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_date.c 286515 2009-07-29 15:34:59Z derick $ */
+/* $Id: parse_date.c 294880 2010-02-11 11:11:47Z pajoye $ */
 
 #include "timelib.h"
 
@@ -237,6 +237,7 @@ static timelib_lookup_table const timelib_reltext_lookup[] = {
 	{ "sixth",    0,  6 },
 	{ "seventh",  0,  7 },
 	{ "eight",    0,  8 },
+	{ "eighth",   0,  8 },
 	{ "ninth",    0,  9 },
 	{ "tenth",    0, 10 },
 	{ "eleventh", 0, 11 },
@@ -967,14 +968,14 @@ yy2:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy140;
-			goto yy1521;
+			goto yy1523;
 		}
 	} else {
 		if (yych <= 'd') {
 			if (yych <= 'Z') goto yy140;
 			if (yych >= 'a') goto yy145;
 		} else {
-			if (yych <= 'e') goto yy1530;
+			if (yych <= 'e') goto yy1532;
 			if (yych <= 'z') goto yy145;
 		}
 	}
@@ -1002,7 +1003,7 @@ yy4:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy140;
-			goto yy1521;
+			goto yy1523;
 		}
 	} else {
 		if (yych <= 'd') {
@@ -1010,7 +1011,7 @@ yy4:
 			if (yych <= '`') goto yy3;
 			goto yy140;
 		} else {
-			if (yych <= 'e') goto yy1521;
+			if (yych <= 'e') goto yy1523;
 			if (yych <= 'z') goto yy140;
 			goto yy3;
 		}
@@ -1025,12 +1026,12 @@ yy5:
 			goto yy140;
 		} else {
 			if (yych <= 'H') {
-				if (yych <= 'E') goto yy1492;
+				if (yych <= 'E') goto yy1494;
 				goto yy140;
 			} else {
-				if (yych <= 'I') goto yy1493;
+				if (yych <= 'I') goto yy1495;
 				if (yych <= 'N') goto yy140;
-				goto yy1491;
+				goto yy1493;
 			}
 		}
 	} else {
@@ -1039,15 +1040,15 @@ yy5:
 				if (yych <= 'Z') goto yy140;
 				goto yy3;
 			} else {
-				if (yych == 'e') goto yy1508;
+				if (yych == 'e') goto yy1510;
 				goto yy145;
 			}
 		} else {
 			if (yych <= 'n') {
-				if (yych <= 'i') goto yy1509;
+				if (yych <= 'i') goto yy1511;
 				goto yy145;
 			} else {
-				if (yych <= 'o') goto yy1507;
+				if (yych <= 'o') goto yy1509;
 				if (yych <= 'z') goto yy145;
 				goto yy3;
 			}
@@ -1063,12 +1064,12 @@ yy6:
 			goto yy140;
 		} else {
 			if (yych <= 'H') {
-				if (yych <= 'E') goto yy1492;
+				if (yych <= 'E') goto yy1494;
 				goto yy140;
 			} else {
-				if (yych <= 'I') goto yy1493;
+				if (yych <= 'I') goto yy1495;
 				if (yych <= 'N') goto yy140;
-				goto yy1491;
+				goto yy1493;
 			}
 		}
 	} else {
@@ -1077,15 +1078,15 @@ yy6:
 				if (yych <= 'Z') goto yy140;
 				goto yy3;
 			} else {
-				if (yych == 'e') goto yy1492;
+				if (yych == 'e') goto yy1494;
 				goto yy140;
 			}
 		} else {
 			if (yych <= 'n') {
-				if (yych <= 'i') goto yy1493;
+				if (yych <= 'i') goto yy1495;
 				goto yy140;
 			} else {
-				if (yych <= 'o') goto yy1491;
+				if (yych <= 'o') goto yy1493;
 				if (yych <= 'z') goto yy140;
 				goto yy3;
 			}
@@ -1098,24 +1099,24 @@ yy7:
 		if (yych <= 'A') {
 			if (yych == ')') goto yy139;
 			if (yych <= '@') goto yy3;
-			goto yy1461;
+			goto yy1463;
 		} else {
-			if (yych == 'I') goto yy1462;
+			if (yych == 'I') goto yy1464;
 			if (yych <= 'N') goto yy140;
-			goto yy1463;
+			goto yy1465;
 		}
 	} else {
 		if (yych <= 'h') {
 			if (yych <= 'Z') goto yy140;
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1476;
+			if (yych <= 'a') goto yy1478;
 			goto yy145;
 		} else {
 			if (yych <= 'n') {
-				if (yych <= 'i') goto yy1477;
+				if (yych <= 'i') goto yy1479;
 				goto yy145;
 			} else {
-				if (yych <= 'o') goto yy1478;
+				if (yych <= 'o') goto yy1480;
 				if (yych <= 'z') goto yy145;
 				goto yy3;
 			}
@@ -1128,24 +1129,24 @@ yy8:
 		if (yych <= 'A') {
 			if (yych == ')') goto yy139;
 			if (yych <= '@') goto yy3;
-			goto yy1461;
+			goto yy1463;
 		} else {
-			if (yych == 'I') goto yy1462;
+			if (yych == 'I') goto yy1464;
 			if (yych <= 'N') goto yy140;
-			goto yy1463;
+			goto yy1465;
 		}
 	} else {
 		if (yych <= 'h') {
 			if (yych <= 'Z') goto yy140;
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1461;
+			if (yych <= 'a') goto yy1463;
 			goto yy140;
 		} else {
 			if (yych <= 'n') {
-				if (yych <= 'i') goto yy1462;
+				if (yych <= 'i') goto yy1464;
 				goto yy140;
 			} else {
-				if (yych <= 'o') goto yy1463;
+				if (yych <= 'o') goto yy1465;
 				if (yych <= 'z') goto yy140;
 				goto yy3;
 			}
@@ -1159,15 +1160,15 @@ yy9:
 	switch (yych) {
 	case ')':	goto yy139;
 	case '0':
-	case '1':	goto yy1391;
-	case '2':	goto yy1392;
+	case '1':	goto yy1393;
+	case '2':	goto yy1394;
 	case '3':
 	case '4':
 	case '5':
 	case '6':
 	case '7':
 	case '8':
-	case '9':	goto yy1393;
+	case '9':	goto yy1395;
 	case 'A':
 	case 'B':
 	case 'C':
@@ -1189,11 +1190,11 @@ yy9:
 	case 'X':
 	case 'Y':
 	case 'Z':	goto yy140;
-	case 'E':	goto yy1386;
-	case 'H':	goto yy1387;
-	case 'O':	goto yy1388;
-	case 'U':	goto yy1389;
-	case 'W':	goto yy1390;
+	case 'E':	goto yy1388;
+	case 'H':	goto yy1389;
+	case 'O':	goto yy1390;
+	case 'U':	goto yy1391;
+	case 'W':	goto yy1392;
 	case 'a':
 	case 'b':
 	case 'c':
@@ -1215,11 +1216,11 @@ yy9:
 	case 'x':
 	case 'y':
 	case 'z':	goto yy145;
-	case 'e':	goto yy1429;
-	case 'h':	goto yy1430;
-	case 'o':	goto yy1431;
-	case 'u':	goto yy1432;
-	case 'w':	goto yy1433;
+	case 'e':	goto yy1431;
+	case 'h':	goto yy1432;
+	case 'o':	goto yy1433;
+	case 'u':	goto yy1434;
+	case 'w':	goto yy1435;
 	default:	goto yy3;
 	}
 yy10:
@@ -1230,15 +1231,15 @@ yy10:
 	switch (yych) {
 	case ')':	goto yy139;
 	case '0':
-	case '1':	goto yy1391;
-	case '2':	goto yy1392;
+	case '1':	goto yy1393;
+	case '2':	goto yy1394;
 	case '3':
 	case '4':
 	case '5':
 	case '6':
 	case '7':
 	case '8':
-	case '9':	goto yy1393;
+	case '9':	goto yy1395;
 	case 'A':
 	case 'B':
 	case 'C':
@@ -1282,24 +1283,24 @@ yy10:
 	case 'y':
 	case 'z':	goto yy140;
 	case 'E':
-	case 'e':	goto yy1386;
+	case 'e':	goto yy1388;
 	case 'H':
-	case 'h':	goto yy1387;
+	case 'h':	goto yy1389;
 	case 'O':
-	case 'o':	goto yy1388;
+	case 'o':	goto yy1390;
 	case 'U':
-	case 'u':	goto yy1389;
+	case 'u':	goto yy1391;
 	case 'W':
-	case 'w':	goto yy1390;
+	case 'w':	goto yy1392;
 	default:	goto yy3;
 	}
 yy11:
 	YYDEBUG(11, *YYCURSOR);
 	yyaccept = 1;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych == '-') goto yy1382;
+	if (yych == '-') goto yy1384;
 	if (yych <= '/') goto yy12;
-	if (yych <= '9') goto yy1383;
+	if (yych <= '9') goto yy1385;
 yy12:
 	YYDEBUG(12, *YYCURSOR);
 	{
@@ -1317,16 +1318,16 @@ yy13:
 			} else {
 				if (yych <= '@') goto yy3;
 				if (yych <= 'D') goto yy140;
-				goto yy1318;
+				goto yy1320;
 			}
 		} else {
 			if (yych <= 'N') {
-				if (yych == 'I') goto yy1319;
+				if (yych == 'I') goto yy1321;
 				goto yy140;
 			} else {
-				if (yych <= 'O') goto yy1320;
+				if (yych <= 'O') goto yy1322;
 				if (yych <= 'Q') goto yy140;
-				goto yy1321;
+				goto yy1323;
 			}
 		}
 	} else {
@@ -1336,16 +1337,16 @@ yy13:
 				if (yych <= '`') goto yy3;
 				goto yy145;
 			} else {
-				if (yych <= 'e') goto yy1359;
+				if (yych <= 'e') goto yy1361;
 				if (yych <= 'h') goto yy145;
-				goto yy1360;
+				goto yy1362;
 			}
 		} else {
 			if (yych <= 'q') {
-				if (yych == 'o') goto yy1361;
+				if (yych == 'o') goto yy1363;
 				goto yy145;
 			} else {
-				if (yych <= 'r') goto yy1362;
+				if (yych <= 'r') goto yy1364;
 				if (yych <= 'z') goto yy145;
 				goto yy3;
 			}
@@ -1362,16 +1363,16 @@ yy14:
 			} else {
 				if (yych <= '@') goto yy3;
 				if (yych <= 'D') goto yy140;
-				goto yy1318;
+				goto yy1320;
 			}
 		} else {
 			if (yych <= 'N') {
-				if (yych == 'I') goto yy1319;
+				if (yych == 'I') goto yy1321;
 				goto yy140;
 			} else {
-				if (yych <= 'O') goto yy1320;
+				if (yych <= 'O') goto yy1322;
 				if (yych <= 'Q') goto yy140;
-				goto yy1321;
+				goto yy1323;
 			}
 		}
 	} else {
@@ -1381,16 +1382,16 @@ yy14:
 				if (yych <= '`') goto yy3;
 				goto yy140;
 			} else {
-				if (yych <= 'e') goto yy1318;
+				if (yych <= 'e') goto yy1320;
 				if (yych <= 'h') goto yy140;
-				goto yy1319;
+				goto yy1321;
 			}
 		} else {
 			if (yych <= 'q') {
-				if (yych == 'o') goto yy1320;
+				if (yych == 'o') goto yy1322;
 				goto yy140;
 			} else {
-				if (yych <= 'r') goto yy1321;
+				if (yych <= 'r') goto yy1323;
 				if (yych <= 'z') goto yy140;
 				goto yy3;
 			}
@@ -1402,13 +1403,13 @@ yy15:
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		if (yych <= '@') goto yy3;
-		goto yy1304;
+		goto yy1306;
 	} else {
 		if (yych <= '`') {
 			if (yych <= 'Z') goto yy140;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1315;
+			if (yych <= 'a') goto yy1317;
 			if (yych <= 'z') goto yy145;
 			goto yy3;
 		}
@@ -1419,13 +1420,13 @@ yy16:
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		if (yych <= '@') goto yy3;
-		goto yy1304;
+		goto yy1306;
 	} else {
 		if (yych <= '`') {
 			if (yych <= 'Z') goto yy140;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1304;
+			if (yych <= 'a') goto yy1306;
 			if (yych <= 'z') goto yy140;
 			goto yy3;
 		}
@@ -1436,13 +1437,13 @@ yy17:
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		if (yych <= '@') goto yy3;
-		goto yy1284;
+		goto yy1286;
 	} else {
 		if (yych <= '`') {
 			if (yych <= 'Z') goto yy140;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1301;
+			if (yych <= 'a') goto yy1303;
 			if (yych <= 'z') goto yy145;
 			goto yy3;
 		}
@@ -1453,13 +1454,13 @@ yy18:
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		if (yych <= '@') goto yy3;
-		goto yy1284;
+		goto yy1286;
 	} else {
 		if (yych <= '`') {
 			if (yych <= 'Z') goto yy140;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1284;
+			if (yych <= 'a') goto yy1286;
 			if (yych <= 'z') goto yy140;
 			goto yy3;
 		}
@@ -1474,17 +1475,17 @@ yy19:
 				goto yy139;
 			} else {
 				if (yych <= '@') goto yy3;
-				if (yych <= 'A') goto yy1227;
+				if (yych <= 'A') goto yy1229;
 				goto yy140;
 			}
 		} else {
 			if (yych <= 'H') {
-				if (yych <= 'E') goto yy1226;
+				if (yych <= 'E') goto yy1228;
 				goto yy140;
 			} else {
-				if (yych <= 'I') goto yy1228;
+				if (yych <= 'I') goto yy1230;
 				if (yych <= 'T') goto yy140;
-				goto yy1229;
+				goto yy1231;
 			}
 		}
 	} else {
@@ -1493,16 +1494,16 @@ yy19:
 				if (yych <= 'Z') goto yy140;
 				goto yy3;
 			} else {
-				if (yych <= 'a') goto yy1256;
+				if (yych <= 'a') goto yy1258;
 				if (yych <= 'd') goto yy145;
-				goto yy1255;
+				goto yy1257;
 			}
 		} else {
 			if (yych <= 't') {
-				if (yych == 'i') goto yy1257;
+				if (yych == 'i') goto yy1259;
 				goto yy145;
 			} else {
-				if (yych <= 'u') goto yy1258;
+				if (yych <= 'u') goto yy1260;
 				if (yych <= 'z') goto yy145;
 				goto yy3;
 			}
@@ -1518,17 +1519,17 @@ yy20:
 				goto yy139;
 			} else {
 				if (yych <= '@') goto yy3;
-				if (yych <= 'A') goto yy1227;
+				if (yych <= 'A') goto yy1229;
 				goto yy140;
 			}
 		} else {
 			if (yych <= 'H') {
-				if (yych <= 'E') goto yy1226;
+				if (yych <= 'E') goto yy1228;
 				goto yy140;
 			} else {
-				if (yych <= 'I') goto yy1228;
+				if (yych <= 'I') goto yy1230;
 				if (yych <= 'T') goto yy140;
-				goto yy1229;
+				goto yy1231;
 			}
 		}
 	} else {
@@ -1537,16 +1538,16 @@ yy20:
 				if (yych <= 'Z') goto yy140;
 				goto yy3;
 			} else {
-				if (yych <= 'a') goto yy1227;
+				if (yych <= 'a') goto yy1229;
 				if (yych <= 'd') goto yy140;
-				goto yy1226;
+				goto yy1228;
 			}
 		} else {
 			if (yych <= 't') {
-				if (yych == 'i') goto yy1228;
+				if (yych == 'i') goto yy1230;
 				goto yy140;
 			} else {
-				if (yych <= 'u') goto yy1229;
+				if (yych <= 'u') goto yy1231;
 				if (yych <= 'z') goto yy140;
 				goto yy3;
 			}
@@ -1569,9 +1570,9 @@ yy21:
 			if (yych <= 'Z') goto yy140;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'h') goto yy145;
-			goto yy1215;
+			goto yy1216;
 		} else {
-			if (yych == 'l') goto yy1216;
+			if (yych == 'l') goto yy1217;
 			if (yych <= 'z') goto yy145;
 			goto yy3;
 		}
@@ -2553,27 +2554,27 @@ yy56:
 					if (yyaccept <= 27) {
 						goto yy1141;
 					} else {
-						goto yy1292;
+						goto yy1294;
 					}
 				} else {
 					if (yyaccept <= 29) {
-						goto yy1311;
+						goto yy1313;
 					} else {
-						goto yy1415;
+						goto yy1417;
 					}
 				}
 			} else {
 				if (yyaccept <= 32) {
 					if (yyaccept <= 31) {
-						goto yy1418;
+						goto yy1420;
 					} else {
-						goto yy1498;
+						goto yy1500;
 					}
 				} else {
 					if (yyaccept <= 33) {
-						goto yy1506;
+						goto yy1508;
 					} else {
-						goto yy1529;
+						goto yy1531;
 					}
 				}
 			}
@@ -17389,21 +17390,22 @@ yy1214:
 	YYDEBUG(1214, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '(') {
-		if (yych <= '\t') {
-			if (yych <= 0x08) goto yy3;
-			goto yy1206;
+	if (yych <= '@') {
+		if (yych <= 0x1F) {
+			if (yych == '\t') goto yy1206;
+			goto yy3;
 		} else {
-			if (yych == ' ') goto yy1206;
+			if (yych <= ' ') goto yy1206;
+			if (yych == ')') goto yy139;
 			goto yy3;
 		}
 	} else {
-		if (yych <= 'Z') {
-			if (yych <= ')') goto yy139;
-			if (yych <= '@') goto yy3;
-			goto yy144;
+		if (yych <= '`') {
+			if (yych == 'H') goto yy1215;
+			if (yych <= 'Z') goto yy144;
+			goto yy3;
 		} else {
-			if (yych <= '`') goto yy3;
+			if (yych == 'h') goto yy1215;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
@@ -17412,6 +17414,18 @@ yy1215:
 	YYDEBUG(1215, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
+	if (yych <= 0x1F) {
+		if (yych == '\t') goto yy1206;
+		goto yy3;
+	} else {
+		if (yych <= ' ') goto yy1206;
+		if (yych == ')') goto yy139;
+		goto yy3;
+	}
+yy1216:
+	YYDEBUG(1216, *YYCURSOR);
+	yyaccept = 0;
+	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'G') {
 		if (yych <= '.') {
 			if (yych == ')') goto yy139;
@@ -17428,13 +17442,13 @@ yy1215:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'g') goto yy1223;
+			if (yych == 'g') goto yy1224;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1216:
-	YYDEBUG(1216, *YYCURSOR);
+yy1217:
+	YYDEBUG(1217, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -17453,13 +17467,13 @@ yy1216:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1217;
+			if (yych == 'e') goto yy1218;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1217:
-	YYDEBUG(1217, *YYCURSOR);
+yy1218:
+	YYDEBUG(1218, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'V') {
@@ -17478,13 +17492,13 @@ yy1217:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'v') goto yy1218;
+			if (yych == 'v') goto yy1219;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1218:
-	YYDEBUG(1218, *YYCURSOR);
+yy1219:
+	YYDEBUG(1219, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -17503,13 +17517,13 @@ yy1218:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1219;
+			if (yych == 'e') goto yy1220;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1219:
-	YYDEBUG(1219, *YYCURSOR);
+yy1220:
+	YYDEBUG(1220, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -17528,13 +17542,13 @@ yy1219:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1220;
+			if (yych == 'n') goto yy1221;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1220:
-	YYDEBUG(1220, *YYCURSOR);
+yy1221:
+	YYDEBUG(1221, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -17551,18 +17565,18 @@ yy1220:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1221;
+			if (yych == 't') goto yy1222;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1221:
-	YYDEBUG(1221, *YYCURSOR);
+yy1222:
+	YYDEBUG(1222, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'H') goto yy1205;
 	if (yych != 'h') goto yy155;
-yy1222:
-	YYDEBUG(1222, *YYCURSOR);
+yy1223:
+	YYDEBUG(1223, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '.') {
 		if (yych <= '\t') {
@@ -17583,8 +17597,8 @@ yy1222:
 			goto yy56;
 		}
 	}
-yy1223:
-	YYDEBUG(1223, *YYCURSOR);
+yy1224:
+	YYDEBUG(1224, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -17603,13 +17617,13 @@ yy1223:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1224;
+			if (yych == 'h') goto yy1225;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1224:
-	YYDEBUG(1224, *YYCURSOR);
+yy1225:
+	YYDEBUG(1225, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -17628,39 +17642,76 @@ yy1224:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1225;
+			if (yych == 't') goto yy1226;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1225:
-	YYDEBUG(1225, *YYCURSOR);
+yy1226:
+	YYDEBUG(1226, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '.') {
+	if (yych <= '@') {
+		if (yych <= ' ') {
+			if (yych == '\t') goto yy1206;
+			if (yych <= 0x1F) goto yy3;
+			goto yy1206;
+		} else {
+			if (yych <= ')') {
+				if (yych <= '(') goto yy3;
+				goto yy139;
+			} else {
+				if (yych == '/') goto yy147;
+				goto yy3;
+			}
+		}
+	} else {
+		if (yych <= '_') {
+			if (yych <= 'H') {
+				if (yych <= 'G') goto yy144;
+				goto yy1215;
+			} else {
+				if (yych <= 'Z') goto yy144;
+				if (yych <= '^') goto yy3;
+				goto yy147;
+			}
+		} else {
+			if (yych <= 'g') {
+				if (yych <= '`') goto yy3;
+				goto yy153;
+			} else {
+				if (yych <= 'h') goto yy1227;
+				if (yych <= 'z') goto yy153;
+				goto yy3;
+			}
+		}
+	}
+yy1227:
+	YYDEBUG(1227, *YYCURSOR);
+	yyaccept = 0;
+	yych = *(YYMARKER = ++YYCURSOR);
+	if (yych <= ')') {
 		if (yych <= 0x1F) {
 			if (yych == '\t') goto yy1206;
 			goto yy3;
 		} else {
 			if (yych <= ' ') goto yy1206;
-			if (yych == ')') goto yy139;
-			goto yy3;
+			if (yych <= '(') goto yy3;
+			goto yy139;
 		}
 	} else {
 		if (yych <= '^') {
-			if (yych <= '/') goto yy147;
-			if (yych <= '@') goto yy3;
-			if (yych <= 'Z') goto yy144;
+			if (yych == '/') goto yy147;
 			goto yy3;
 		} else {
 			if (yych <= '_') goto yy147;
 			if (yych <= '`') goto yy3;
-			if (yych <= 'z') goto yy153;
+			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1226:
-	YYDEBUG(1226, *YYCURSOR);
+yy1228:
+	YYDEBUG(1228, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'V') {
 		if (yych <= 'B') {
@@ -17669,12 +17720,12 @@ yy1226:
 			goto yy141;
 		} else {
 			if (yych <= 'O') {
-				if (yych <= 'C') goto yy1241;
+				if (yych <= 'C') goto yy1244;
 				goto yy141;
 			} else {
-				if (yych <= 'P') goto yy1243;
+				if (yych <= 'P') goto yy1246;
 				if (yych <= 'U') goto yy141;
-				goto yy1242;
+				goto yy1245;
 			}
 		}
 	} else {
@@ -17683,22 +17734,22 @@ yy1226:
 				if (yych <= 'Z') goto yy141;
 				goto yy3;
 			} else {
-				if (yych == 'c') goto yy1241;
+				if (yych == 'c') goto yy1244;
 				goto yy141;
 			}
 		} else {
 			if (yych <= 'u') {
-				if (yych <= 'p') goto yy1243;
+				if (yych <= 'p') goto yy1246;
 				goto yy141;
 			} else {
-				if (yych <= 'v') goto yy1242;
+				if (yych <= 'v') goto yy1245;
 				if (yych <= 'z') goto yy141;
 				goto yy3;
 			}
 		}
 	}
-yy1227:
-	YYDEBUG(1227, *YYCURSOR);
+yy1229:
+	YYDEBUG(1229, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -17707,7 +17758,7 @@ yy1227:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy141;
-			goto yy1236;
+			goto yy1239;
 		}
 	} else {
 		if (yych <= 's') {
@@ -17715,13 +17766,13 @@ yy1227:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 't') goto yy1236;
+			if (yych <= 't') goto yy1239;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1228:
-	YYDEBUG(1228, *YYCURSOR);
+yy1230:
+	YYDEBUG(1230, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'X') {
 		if (yych <= ')') {
@@ -17730,7 +17781,7 @@ yy1228:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'W') goto yy141;
-			goto yy1234;
+			goto yy1236;
 		}
 	} else {
 		if (yych <= 'w') {
@@ -17738,13 +17789,13 @@ yy1228:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'x') goto yy1234;
+			if (yych <= 'x') goto yy1236;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1229:
-	YYDEBUG(1229, *YYCURSOR);
+yy1231:
+	YYDEBUG(1231, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -17760,13 +17811,13 @@ yy1229:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'n') goto yy1230;
+			if (yych <= 'n') goto yy1232;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1230:
-	YYDEBUG(1230, *YYCURSOR);
+yy1232:
+	YYDEBUG(1232, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -17782,13 +17833,13 @@ yy1230:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 'd') goto yy1231;
+			if (yych <= 'd') goto yy1233;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1231:
-	YYDEBUG(1231, *YYCURSOR);
+yy1233:
+	YYDEBUG(1233, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
@@ -17798,13 +17849,13 @@ yy1231:
 			if (yych <= 'Z') goto yy143;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1232;
+			if (yych <= 'a') goto yy1234;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1232:
-	YYDEBUG(1232, *YYCURSOR);
+yy1234:
+	YYDEBUG(1234, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'Y') {
 		if (yych <= ')') {
@@ -17820,18 +17871,18 @@ yy1232:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'y') goto yy1233;
+			if (yych <= 'y') goto yy1235;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1233:
-	YYDEBUG(1233, *YYCURSOR);
+yy1235:
+	YYDEBUG(1235, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == ')') goto yy139;
 	goto yy167;
-yy1234:
-	YYDEBUG(1234, *YYCURSOR);
+yy1236:
+	YYDEBUG(1236, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -17847,13 +17898,13 @@ yy1234:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1235;
+			if (yych <= 't') goto yy1237;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1235:
-	YYDEBUG(1235, *YYCURSOR);
+yy1237:
+	YYDEBUG(1237, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -17862,7 +17913,6 @@ yy1235:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
 		}
 	} else {
 		if (yych <= 'g') {
@@ -17870,13 +17920,36 @@ yy1235:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'h') goto yy1214;
+			if (yych <= 'h') goto yy1238;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1236:
-	YYDEBUG(1236, *YYCURSOR);
+yy1238:
+	YYDEBUG(1238, *YYCURSOR);
+	yyaccept = 0;
+	yych = *(YYMARKER = ++YYCURSOR);
+	if (yych <= '(') {
+		if (yych <= '\t') {
+			if (yych <= 0x08) goto yy3;
+			goto yy1206;
+		} else {
+			if (yych == ' ') goto yy1206;
+			goto yy3;
+		}
+	} else {
+		if (yych <= 'Z') {
+			if (yych <= ')') goto yy139;
+			if (yych <= '@') goto yy3;
+			goto yy144;
+		} else {
+			if (yych <= '`') goto yy3;
+			if (yych <= 'z') goto yy144;
+			goto yy3;
+		}
+	}
+yy1239:
+	YYDEBUG(1239, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'U') {
 		if (yych <= ')') {
@@ -17892,13 +17965,13 @@ yy1236:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 'u') goto yy1237;
+			if (yych <= 'u') goto yy1240;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1237:
-	YYDEBUG(1237, *YYCURSOR);
+yy1240:
+	YYDEBUG(1240, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -17914,13 +17987,13 @@ yy1237:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'r') goto yy1238;
+			if (yych <= 'r') goto yy1241;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1238:
-	YYDEBUG(1238, *YYCURSOR);
+yy1241:
+	YYDEBUG(1241, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -17936,30 +18009,30 @@ yy1238:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'd') goto yy1239;
+			if (yych <= 'd') goto yy1242;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1239:
-	YYDEBUG(1239, *YYCURSOR);
+yy1242:
+	YYDEBUG(1242, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '@') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'A') goto yy1240;
+		if (yych <= 'A') goto yy1243;
 		if (yych != 'a') goto yy3;
 	}
-yy1240:
-	YYDEBUG(1240, *YYCURSOR);
+yy1243:
+	YYDEBUG(1243, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy173;
 	if (yych == 'y') goto yy173;
 	goto yy56;
-yy1241:
-	YYDEBUG(1241, *YYCURSOR);
+yy1244:
+	YYDEBUG(1244, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'O') {
 		if (yych <= ')') {
@@ -17968,7 +18041,7 @@ yy1241:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'N') goto yy142;
-			goto yy1252;
+			goto yy1255;
 		}
 	} else {
 		if (yych <= 'n') {
@@ -17976,13 +18049,13 @@ yy1241:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'o') goto yy1252;
+			if (yych <= 'o') goto yy1255;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1242:
-	YYDEBUG(1242, *YYCURSOR);
+yy1245:
+	YYDEBUG(1245, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'E') {
 		if (yych <= ')') {
@@ -17991,7 +18064,7 @@ yy1242:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy142;
-			goto yy1249;
+			goto yy1252;
 		}
 	} else {
 		if (yych <= 'd') {
@@ -17999,13 +18072,13 @@ yy1242:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'e') goto yy1249;
+			if (yych <= 'e') goto yy1252;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1243:
-	YYDEBUG(1243, *YYCURSOR);
+yy1246:
+	YYDEBUG(1246, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -18040,14 +18113,14 @@ yy1243:
 				if (yych <= '`') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 't') goto yy1244;
+				if (yych <= 't') goto yy1247;
 				if (yych <= 'z') goto yy142;
 				goto yy194;
 			}
 		}
 	}
-yy1244:
-	YYDEBUG(1244, *YYCURSOR);
+yy1247:
+	YYDEBUG(1247, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -18082,14 +18155,14 @@ yy1244:
 				if (yych <= '`') goto yy194;
 				goto yy143;
 			} else {
-				if (yych <= 'e') goto yy1245;
+				if (yych <= 'e') goto yy1248;
 				if (yych <= 'z') goto yy143;
 				goto yy194;
 			}
 		}
 	}
-yy1245:
-	YYDEBUG(1245, *YYCURSOR);
+yy1248:
+	YYDEBUG(1248, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'M') {
 		if (yych <= ')') {
@@ -18105,35 +18178,35 @@ yy1245:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'm') goto yy1246;
+			if (yych <= 'm') goto yy1249;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1246:
-	YYDEBUG(1246, *YYCURSOR);
+yy1249:
+	YYDEBUG(1249, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'B') goto yy1247;
+		if (yych <= 'B') goto yy1250;
 		if (yych != 'b') goto yy3;
 	}
-yy1247:
-	YYDEBUG(1247, *YYCURSOR);
+yy1250:
+	YYDEBUG(1250, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'E') goto yy1248;
+	if (yych == 'E') goto yy1251;
 	if (yych != 'e') goto yy56;
-yy1248:
-	YYDEBUG(1248, *YYCURSOR);
+yy1251:
+	YYDEBUG(1251, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'R') goto yy206;
 	if (yych == 'r') goto yy206;
 	goto yy56;
-yy1249:
-	YYDEBUG(1249, *YYCURSOR);
+yy1252:
+	YYDEBUG(1252, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -18149,13 +18222,13 @@ yy1249:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'n') goto yy1250;
+			if (yych <= 'n') goto yy1253;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1250:
-	YYDEBUG(1250, *YYCURSOR);
+yy1253:
+	YYDEBUG(1253, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -18171,13 +18244,13 @@ yy1250:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 't') goto yy1251;
+			if (yych <= 't') goto yy1254;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1251:
-	YYDEBUG(1251, *YYCURSOR);
+yy1254:
+	YYDEBUG(1254, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'G') {
@@ -18188,8 +18261,8 @@ yy1251:
 		if (yych == 'h') goto yy1205;
 		goto yy3;
 	}
-yy1252:
-	YYDEBUG(1252, *YYCURSOR);
+yy1255:
+	YYDEBUG(1255, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -18205,13 +18278,13 @@ yy1252:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'n') goto yy1253;
+			if (yych <= 'n') goto yy1256;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1253:
-	YYDEBUG(1253, *YYCURSOR);
+yy1256:
+	YYDEBUG(1256, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -18220,6 +18293,7 @@ yy1253:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy144;
+			goto yy1215;
 		}
 	} else {
 		if (yych <= 'c') {
@@ -18227,25 +18301,13 @@ yy1253:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'd') goto yy1254;
+			if (yych <= 'd') goto yy1215;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1254:
-	YYDEBUG(1254, *YYCURSOR);
-	yyaccept = 0;
-	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= 0x1F) {
-		if (yych == '\t') goto yy1206;
-		goto yy3;
-	} else {
-		if (yych <= ' ') goto yy1206;
-		if (yych == ')') goto yy139;
-		goto yy3;
-	}
-yy1255:
-	YYDEBUG(1255, *YYCURSOR);
+yy1257:
+	YYDEBUG(1257, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'V') {
@@ -18259,12 +18321,12 @@ yy1255:
 			}
 		} else {
 			if (yych <= 'O') {
-				if (yych == 'C') goto yy1241;
+				if (yych == 'C') goto yy1244;
 				goto yy141;
 			} else {
-				if (yych <= 'P') goto yy1243;
+				if (yych <= 'P') goto yy1246;
 				if (yych <= 'U') goto yy141;
-				goto yy1242;
+				goto yy1245;
 			}
 		}
 	} else {
@@ -18276,21 +18338,21 @@ yy1255:
 			} else {
 				if (yych <= '`') goto yy3;
 				if (yych <= 'b') goto yy146;
-				goto yy1270;
+				goto yy1273;
 			}
 		} else {
 			if (yych <= 'u') {
-				if (yych == 'p') goto yy1272;
+				if (yych == 'p') goto yy1275;
 				goto yy146;
 			} else {
-				if (yych <= 'v') goto yy1271;
+				if (yych <= 'v') goto yy1274;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1256:
-	YYDEBUG(1256, *YYCURSOR);
+yy1258:
+	YYDEBUG(1258, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -18301,7 +18363,7 @@ yy1256:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy141;
-			goto yy1236;
+			goto yy1239;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18309,13 +18371,13 @@ yy1256:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1265;
+			if (yych == 't') goto yy1268;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1257:
-	YYDEBUG(1257, *YYCURSOR);
+yy1259:
+	YYDEBUG(1259, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'X') {
@@ -18326,7 +18388,7 @@ yy1257:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'W') goto yy141;
-			goto yy1234;
+			goto yy1236;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18334,13 +18396,13 @@ yy1257:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'x') goto yy1263;
+			if (yych == 'x') goto yy1265;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1258:
-	YYDEBUG(1258, *YYCURSOR);
+yy1260:
+	YYDEBUG(1260, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -18351,7 +18413,7 @@ yy1258:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy141;
-			goto yy1230;
+			goto yy1232;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18359,13 +18421,13 @@ yy1258:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1259;
+			if (yych == 'n') goto yy1261;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1259:
-	YYDEBUG(1259, *YYCURSOR);
+yy1261:
+	YYDEBUG(1261, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -18376,7 +18438,7 @@ yy1259:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'C') goto yy142;
-			goto yy1231;
+			goto yy1233;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18384,13 +18446,13 @@ yy1259:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 'd') goto yy1260;
+			if (yych == 'd') goto yy1262;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1260:
-	YYDEBUG(1260, *YYCURSOR);
+yy1262:
+	YYDEBUG(1262, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -18400,7 +18462,7 @@ yy1260:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1232;
+			goto yy1234;
 		}
 	} else {
 		if (yych <= '_') {
@@ -18409,13 +18471,13 @@ yy1260:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1261;
+			if (yych <= 'a') goto yy1263;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1261:
-	YYDEBUG(1261, *YYCURSOR);
+yy1263:
+	YYDEBUG(1263, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -18426,7 +18488,7 @@ yy1261:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy144;
-			goto yy1233;
+			goto yy1235;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18434,13 +18496,13 @@ yy1261:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'y') goto yy1262;
+			if (yych == 'y') goto yy1264;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1262:
-	YYDEBUG(1262, *YYCURSOR);
+yy1264:
+	YYDEBUG(1264, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -18457,8 +18519,8 @@ yy1262:
 			goto yy167;
 		}
 	}
-yy1263:
-	YYDEBUG(1263, *YYCURSOR);
+yy1265:
+	YYDEBUG(1265, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -18469,7 +18531,7 @@ yy1263:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1235;
+			goto yy1237;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18477,13 +18539,13 @@ yy1263:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1264;
+			if (yych == 't') goto yy1266;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1264:
-	YYDEBUG(1264, *YYCURSOR);
+yy1266:
+	YYDEBUG(1266, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -18494,7 +18556,7 @@ yy1264:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18502,13 +18564,39 @@ yy1264:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1225;
+			if (yych == 'h') goto yy1267;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1265:
-	YYDEBUG(1265, *YYCURSOR);
+yy1267:
+	YYDEBUG(1267, *YYCURSOR);
+	yyaccept = 0;
+	yych = *(YYMARKER = ++YYCURSOR);
+	if (yych <= '.') {
+		if (yych <= 0x1F) {
+			if (yych == '\t') goto yy1206;
+			goto yy3;
+		} else {
+			if (yych <= ' ') goto yy1206;
+			if (yych == ')') goto yy139;
+			goto yy3;
+		}
+	} else {
+		if (yych <= '^') {
+			if (yych <= '/') goto yy147;
+			if (yych <= '@') goto yy3;
+			if (yych <= 'Z') goto yy144;
+			goto yy3;
+		} else {
+			if (yych <= '_') goto yy147;
+			if (yych <= '`') goto yy3;
+			if (yych <= 'z') goto yy153;
+			goto yy3;
+		}
+	}
+yy1268:
+	YYDEBUG(1268, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'U') {
@@ -18519,7 +18607,7 @@ yy1265:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'T') goto yy142;
-			goto yy1237;
+			goto yy1240;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18527,13 +18615,13 @@ yy1265:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 'u') goto yy1266;
+			if (yych == 'u') goto yy1269;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1266:
-	YYDEBUG(1266, *YYCURSOR);
+yy1269:
+	YYDEBUG(1269, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -18544,7 +18632,7 @@ yy1266:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy143;
-			goto yy1238;
+			goto yy1241;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18552,13 +18640,13 @@ yy1266:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1267;
+			if (yych == 'r') goto yy1270;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1267:
-	YYDEBUG(1267, *YYCURSOR);
+yy1270:
+	YYDEBUG(1270, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -18569,7 +18657,7 @@ yy1267:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy144;
-			goto yy1239;
+			goto yy1242;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18577,13 +18665,13 @@ yy1267:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1268;
+			if (yych == 'd') goto yy1271;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1268:
-	YYDEBUG(1268, *YYCURSOR);
+yy1271:
+	YYDEBUG(1271, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -18593,26 +18681,26 @@ yy1268:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1240;
+			goto yy1243;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1269;
+			if (yych <= 'a') goto yy1272;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1269:
-	YYDEBUG(1269, *YYCURSOR);
+yy1272:
+	YYDEBUG(1272, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy173;
 	if (yych == 'y') goto yy186;
 	goto yy155;
-yy1270:
-	YYDEBUG(1270, *YYCURSOR);
+yy1273:
+	YYDEBUG(1273, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'O') {
@@ -18623,7 +18711,7 @@ yy1270:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'N') goto yy142;
-			goto yy1252;
+			goto yy1255;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18631,13 +18719,13 @@ yy1270:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'o') goto yy1281;
+			if (yych == 'o') goto yy1284;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1271:
-	YYDEBUG(1271, *YYCURSOR);
+yy1274:
+	YYDEBUG(1274, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -18648,7 +18736,7 @@ yy1271:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy142;
-			goto yy1249;
+			goto yy1252;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18656,13 +18744,13 @@ yy1271:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1278;
+			if (yych == 'e') goto yy1281;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1272:
-	YYDEBUG(1272, *YYCURSOR);
+yy1275:
+	YYDEBUG(1275, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '9') {
@@ -18690,7 +18778,7 @@ yy1272:
 				if (yych <= '@') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'T') goto yy1244;
+				if (yych <= 'T') goto yy1247;
 				if (yych <= 'Z') goto yy142;
 				goto yy194;
 			}
@@ -18700,14 +18788,14 @@ yy1272:
 				if (yych <= '`') goto yy194;
 				goto yy151;
 			} else {
-				if (yych <= 't') goto yy1273;
+				if (yych <= 't') goto yy1276;
 				if (yych <= 'z') goto yy151;
 				goto yy194;
 			}
 		}
 	}
-yy1273:
-	YYDEBUG(1273, *YYCURSOR);
+yy1276:
+	YYDEBUG(1276, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '9') {
@@ -18735,7 +18823,7 @@ yy1273:
 				if (yych <= '@') goto yy194;
 				goto yy143;
 			} else {
-				if (yych <= 'E') goto yy1245;
+				if (yych <= 'E') goto yy1248;
 				if (yych <= 'Z') goto yy143;
 				goto yy194;
 			}
@@ -18745,14 +18833,14 @@ yy1273:
 				if (yych <= '`') goto yy194;
 				goto yy152;
 			} else {
-				if (yych <= 'e') goto yy1274;
+				if (yych <= 'e') goto yy1277;
 				if (yych <= 'z') goto yy152;
 				goto yy194;
 			}
 		}
 	}
-yy1274:
-	YYDEBUG(1274, *YYCURSOR);
+yy1277:
+	YYDEBUG(1277, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'M') {
@@ -18763,7 +18851,7 @@ yy1274:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'L') goto yy144;
-			goto yy1246;
+			goto yy1249;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18771,13 +18859,13 @@ yy1274:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'm') goto yy1275;
+			if (yych == 'm') goto yy1278;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1275:
-	YYDEBUG(1275, *YYCURSOR);
+yy1278:
+	YYDEBUG(1278, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'B') {
@@ -18787,30 +18875,30 @@ yy1275:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'A') goto yy3;
-			goto yy1247;
+			goto yy1250;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'b') goto yy1276;
+			if (yych == 'b') goto yy1279;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1276:
-	YYDEBUG(1276, *YYCURSOR);
+yy1279:
+	YYDEBUG(1279, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'E') goto yy1248;
+	if (yych == 'E') goto yy1251;
 	if (yych != 'e') goto yy155;
-	YYDEBUG(1277, *YYCURSOR);
+	YYDEBUG(1280, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'R') goto yy206;
 	if (yych == 'r') goto yy377;
 	goto yy155;
-yy1278:
-	YYDEBUG(1278, *YYCURSOR);
+yy1281:
+	YYDEBUG(1281, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -18821,7 +18909,7 @@ yy1278:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy143;
-			goto yy1250;
+			goto yy1253;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18829,13 +18917,13 @@ yy1278:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1279;
+			if (yych == 'n') goto yy1282;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1279:
-	YYDEBUG(1279, *YYCURSOR);
+yy1282:
+	YYDEBUG(1282, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -18846,7 +18934,7 @@ yy1279:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy144;
-			goto yy1251;
+			goto yy1254;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18854,13 +18942,13 @@ yy1279:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1280;
+			if (yych == 't') goto yy1283;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1280:
-	YYDEBUG(1280, *YYCURSOR);
+yy1283:
+	YYDEBUG(1283, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -18877,13 +18965,13 @@ yy1280:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1222;
+			if (yych == 'h') goto yy1223;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1281:
-	YYDEBUG(1281, *YYCURSOR);
+yy1284:
+	YYDEBUG(1284, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -18894,7 +18982,7 @@ yy1281:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy143;
-			goto yy1253;
+			goto yy1256;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18902,13 +18990,13 @@ yy1281:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1282;
+			if (yych == 'n') goto yy1285;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1282:
-	YYDEBUG(1282, *YYCURSOR);
+yy1285:
+	YYDEBUG(1285, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -18919,7 +19007,7 @@ yy1282:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy144;
-			goto yy1254;
+			goto yy1215;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18927,37 +19015,13 @@ yy1282:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1283;
+			if (yych == 'd') goto yy1227;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1283:
-	YYDEBUG(1283, *YYCURSOR);
-	yyaccept = 0;
-	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= ')') {
-		if (yych <= 0x1F) {
-			if (yych == '\t') goto yy1206;
-			goto yy3;
-		} else {
-			if (yych <= ' ') goto yy1206;
-			if (yych <= '(') goto yy3;
-			goto yy139;
-		}
-	} else {
-		if (yych <= '^') {
-			if (yych == '/') goto yy147;
-			goto yy3;
-		} else {
-			if (yych <= '_') goto yy147;
-			if (yych <= '`') goto yy3;
-			if (yych <= 'z') goto yy154;
-			goto yy3;
-		}
-	}
-yy1284:
-	YYDEBUG(1284, *YYCURSOR);
+yy1286:
+	YYDEBUG(1286, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'C') {
 		if (yych <= ')') {
@@ -18973,13 +19037,13 @@ yy1284:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'c') goto yy1285;
+			if (yych <= 'c') goto yy1287;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1285:
-	YYDEBUG(1285, *YYCURSOR);
+yy1287:
+	YYDEBUG(1287, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'K') {
 		if (yych <= ')') {
@@ -18995,17 +19059,17 @@ yy1285:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'k') goto yy1286;
+			if (yych <= 'k') goto yy1288;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1286:
-	YYDEBUG(1286, *YYCURSOR);
+yy1288:
+	YYDEBUG(1288, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= ')') {
-		if (yych == ' ') goto yy1287;
+		if (yych == ' ') goto yy1289;
 		if (yych <= '(') goto yy3;
 		goto yy139;
 	} else {
@@ -19018,36 +19082,36 @@ yy1286:
 			goto yy3;
 		}
 	}
-yy1287:
-	YYDEBUG(1287, *YYCURSOR);
+yy1289:
+	YYDEBUG(1289, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'O') goto yy1288;
+	if (yych == 'O') goto yy1290;
 	if (yych != 'o') goto yy56;
-yy1288:
-	YYDEBUG(1288, *YYCURSOR);
+yy1290:
+	YYDEBUG(1290, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'F') goto yy1289;
+	if (yych == 'F') goto yy1291;
 	if (yych != 'f') goto yy56;
-yy1289:
-	YYDEBUG(1289, *YYCURSOR);
+yy1291:
+	YYDEBUG(1291, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych != ' ') goto yy56;
-	YYDEBUG(1290, *YYCURSOR);
+	YYDEBUG(1292, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') goto yy56;
-	if (yych <= '1') goto yy1291;
-	if (yych <= '2') goto yy1293;
-	if (yych <= '9') goto yy1294;
+	if (yych <= '1') goto yy1293;
+	if (yych <= '2') goto yy1295;
+	if (yych <= '9') goto yy1296;
 	goto yy56;
-yy1291:
-	YYDEBUG(1291, *YYCURSOR);
+yy1293:
+	YYDEBUG(1293, *YYCURSOR);
 	yyaccept = 28;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '/') goto yy1295;
-	if (yych <= '9') goto yy1294;
-	goto yy1295;
-yy1292:
-	YYDEBUG(1292, *YYCURSOR);
+	if (yych <= '/') goto yy1297;
+	if (yych <= '9') goto yy1296;
+	goto yy1297;
+yy1294:
+	YYDEBUG(1294, *YYCURSOR);
 	{
 		DEBUG_OUTPUT("backof | frontof");
 		TIMELIB_INIT;
@@ -19069,75 +19133,75 @@ yy1292:
 		TIMELIB_DEINIT;
 		return TIMELIB_LF_DAY_OF_MONTH;
 	}
-yy1293:
-	YYDEBUG(1293, *YYCURSOR);
+yy1295:
+	YYDEBUG(1295, *YYCURSOR);
 	yyaccept = 28;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '/') goto yy1295;
-	if (yych >= '5') goto yy1295;
-yy1294:
-	YYDEBUG(1294, *YYCURSOR);
+	if (yych <= '/') goto yy1297;
+	if (yych >= '5') goto yy1297;
+yy1296:
+	YYDEBUG(1296, *YYCURSOR);
 	yyaccept = 28;
 	YYMARKER = ++YYCURSOR;
 	if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5);
 	yych = *YYCURSOR;
-yy1295:
-	YYDEBUG(1295, *YYCURSOR);
+yy1297:
+	YYDEBUG(1297, *YYCURSOR);
 	if (yych <= 'A') {
 		if (yych <= 0x1F) {
-			if (yych == '\t') goto yy1294;
-			goto yy1292;
+			if (yych == '\t') goto yy1296;
+			goto yy1294;
 		} else {
-			if (yych <= ' ') goto yy1294;
-			if (yych <= '@') goto yy1292;
+			if (yych <= ' ') goto yy1296;
+			if (yych <= '@') goto yy1294;
 		}
 	} else {
 		if (yych <= '`') {
-			if (yych != 'P') goto yy1292;
+			if (yych != 'P') goto yy1294;
 		} else {
-			if (yych <= 'a') goto yy1296;
-			if (yych != 'p') goto yy1292;
+			if (yych <= 'a') goto yy1298;
+			if (yych != 'p') goto yy1294;
 		}
 	}
-yy1296:
-	YYDEBUG(1296, *YYCURSOR);
+yy1298:
+	YYDEBUG(1298, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'L') {
 		if (yych != '.') goto yy56;
 	} else {
-		if (yych <= 'M') goto yy1298;
-		if (yych == 'm') goto yy1298;
+		if (yych <= 'M') goto yy1300;
+		if (yych == 'm') goto yy1300;
 		goto yy56;
 	}
-	YYDEBUG(1297, *YYCURSOR);
+	YYDEBUG(1299, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'M') goto yy1298;
+	if (yych == 'M') goto yy1300;
 	if (yych != 'm') goto yy56;
-yy1298:
-	YYDEBUG(1298, *YYCURSOR);
+yy1300:
+	YYDEBUG(1300, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 0x1F) {
-		if (yych <= 0x00) goto yy1300;
-		if (yych == '\t') goto yy1300;
+		if (yych <= 0x00) goto yy1302;
+		if (yych == '\t') goto yy1302;
 		goto yy56;
 	} else {
-		if (yych <= ' ') goto yy1300;
+		if (yych <= ' ') goto yy1302;
 		if (yych != '.') goto yy56;
 	}
-	YYDEBUG(1299, *YYCURSOR);
+	YYDEBUG(1301, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '\t') {
-		if (yych <= 0x00) goto yy1300;
+		if (yych <= 0x00) goto yy1302;
 		if (yych <= 0x08) goto yy56;
 	} else {
 		if (yych != ' ') goto yy56;
 	}
-yy1300:
-	YYDEBUG(1300, *YYCURSOR);
+yy1302:
+	YYDEBUG(1302, *YYCURSOR);
 	yych = *++YYCURSOR;
-	goto yy1292;
-yy1301:
-	YYDEBUG(1301, *YYCURSOR);
+	goto yy1294;
+yy1303:
+	YYDEBUG(1303, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'C') {
@@ -19148,7 +19212,7 @@ yy1301:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'B') goto yy141;
-			goto yy1285;
+			goto yy1287;
 		}
 	} else {
 		if (yych <= '`') {
@@ -19156,13 +19220,13 @@ yy1301:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'c') goto yy1302;
+			if (yych == 'c') goto yy1304;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1302:
-	YYDEBUG(1302, *YYCURSOR);
+yy1304:
+	YYDEBUG(1304, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'K') {
@@ -19173,7 +19237,7 @@ yy1302:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'J') goto yy142;
-			goto yy1286;
+			goto yy1288;
 		}
 	} else {
 		if (yych <= '`') {
@@ -19181,18 +19245,18 @@ yy1302:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'k') goto yy1303;
+			if (yych == 'k') goto yy1305;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1303:
-	YYDEBUG(1303, *YYCURSOR);
+yy1305:
+	YYDEBUG(1305, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
 		if (yych <= '(') {
-			if (yych == ' ') goto yy1287;
+			if (yych == ' ') goto yy1289;
 			goto yy3;
 		} else {
 			if (yych <= ')') goto yy139;
@@ -19211,8 +19275,8 @@ yy1303:
 			goto yy3;
 		}
 	}
-yy1304:
-	YYDEBUG(1304, *YYCURSOR);
+yy1306:
+	YYDEBUG(1306, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= ')') {
@@ -19228,13 +19292,13 @@ yy1304:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 's') goto yy1305;
+			if (yych <= 's') goto yy1307;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1305:
-	YYDEBUG(1305, *YYCURSOR);
+yy1307:
+	YYDEBUG(1307, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -19250,13 +19314,13 @@ yy1305:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1306;
+			if (yych <= 't') goto yy1308;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1306:
-	YYDEBUG(1306, *YYCURSOR);
+yy1308:
+	YYDEBUG(1308, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '(') {
@@ -19277,33 +19341,33 @@ yy1306:
 			goto yy3;
 		}
 	}
-yy1307:
-	YYDEBUG(1307, *YYCURSOR);
+yy1309:
+	YYDEBUG(1309, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'D') goto yy1308;
+	if (yych == 'D') goto yy1310;
 	if (yych != 'd') goto yy1105;
-yy1308:
-	YYDEBUG(1308, *YYCURSOR);
+yy1310:
+	YYDEBUG(1310, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'A') goto yy1309;
+	if (yych == 'A') goto yy1311;
 	if (yych != 'a') goto yy56;
-yy1309:
-	YYDEBUG(1309, *YYCURSOR);
+yy1311:
+	YYDEBUG(1311, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'Y') goto yy1310;
+	if (yych == 'Y') goto yy1312;
 	if (yych != 'y') goto yy56;
-yy1310:
-	YYDEBUG(1310, *YYCURSOR);
+yy1312:
+	YYDEBUG(1312, *YYCURSOR);
 	yyaccept = 29;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
-		if (yych == ' ') goto yy1312;
+		if (yych == ' ') goto yy1314;
 	} else {
 		if (yych <= 'S') goto yy1142;
 		if (yych == 's') goto yy1142;
 	}
-yy1311:
-	YYDEBUG(1311, *YYCURSOR);
+yy1313:
+	YYDEBUG(1313, *YYCURSOR);
 	{
 		DEBUG_OUTPUT("firstdayof | lastdayof");
 		TIMELIB_INIT;
@@ -19319,22 +19383,22 @@ yy1311:
 		TIMELIB_DEINIT;
 		return TIMELIB_LF_DAY_OF_MONTH;
 	}
-yy1312:
-	YYDEBUG(1312, *YYCURSOR);
-	yych = *++YYCURSOR;
-	if (yych == 'O') goto yy1313;
-	if (yych != 'o') goto yy56;
-yy1313:
-	YYDEBUG(1313, *YYCURSOR);
-	yych = *++YYCURSOR;
-	if (yych == 'F') goto yy1314;
-	if (yych != 'f') goto yy56;
 yy1314:
 	YYDEBUG(1314, *YYCURSOR);
 	yych = *++YYCURSOR;
-	goto yy1311;
+	if (yych == 'O') goto yy1315;
+	if (yych != 'o') goto yy56;
 yy1315:
 	YYDEBUG(1315, *YYCURSOR);
+	yych = *++YYCURSOR;
+	if (yych == 'F') goto yy1316;
+	if (yych != 'f') goto yy56;
+yy1316:
+	YYDEBUG(1316, *YYCURSOR);
+	yych = *++YYCURSOR;
+	goto yy1313;
+yy1317:
+	YYDEBUG(1317, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -19345,7 +19409,7 @@ yy1315:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'R') goto yy141;
-			goto yy1305;
+			goto yy1307;
 		}
 	} else {
 		if (yych <= '`') {
@@ -19353,13 +19417,13 @@ yy1315:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 's') goto yy1316;
+			if (yych == 's') goto yy1318;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1316:
-	YYDEBUG(1316, *YYCURSOR);
+yy1318:
+	YYDEBUG(1318, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -19370,7 +19434,7 @@ yy1316:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1306;
+			goto yy1308;
 		}
 	} else {
 		if (yych <= '`') {
@@ -19378,13 +19442,13 @@ yy1316:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1317;
+			if (yych == 't') goto yy1319;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1317:
-	YYDEBUG(1317, *YYCURSOR);
+yy1319:
+	YYDEBUG(1319, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '.') {
@@ -19392,7 +19456,7 @@ yy1317:
 			if (yych == '\t') goto yy1104;
 			goto yy3;
 		} else {
-			if (yych <= ' ') goto yy1307;
+			if (yych <= ' ') goto yy1309;
 			if (yych == ')') goto yy139;
 			goto yy3;
 		}
@@ -19409,8 +19473,8 @@ yy1317:
 			goto yy3;
 		}
 	}
-yy1318:
-	YYDEBUG(1318, *YYCURSOR);
+yy1320:
+	YYDEBUG(1320, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'B') {
 		if (yych <= ')') {
@@ -19419,7 +19483,7 @@ yy1318:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'A') goto yy141;
-			goto yy1354;
+			goto yy1356;
 		}
 	} else {
 		if (yych <= 'a') {
@@ -19427,37 +19491,37 @@ yy1318:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'b') goto yy1354;
+			if (yych <= 'b') goto yy1356;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1319:
-	YYDEBUG(1319, *YYCURSOR);
+yy1321:
+	YYDEBUG(1321, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= '@') {
 			if (yych == ')') goto yy139;
 			goto yy3;
 		} else {
-			if (yych == 'F') goto yy1344;
+			if (yych == 'F') goto yy1346;
 			if (yych <= 'Q') goto yy141;
-			goto yy1343;
+			goto yy1345;
 		}
 	} else {
 		if (yych <= 'f') {
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'e') goto yy141;
-			goto yy1344;
+			goto yy1346;
 		} else {
-			if (yych == 'r') goto yy1343;
+			if (yych == 'r') goto yy1345;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1320:
-	YYDEBUG(1320, *YYCURSOR);
+yy1322:
+	YYDEBUG(1322, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'U') {
 		if (yych <= ')') {
@@ -19466,7 +19530,7 @@ yy1320:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'T') goto yy141;
-			goto yy1340;
+			goto yy1342;
 		}
 	} else {
 		if (yych <= 't') {
@@ -19474,20 +19538,20 @@ yy1320:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'u') goto yy1340;
+			if (yych <= 'u') goto yy1342;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1321:
-	YYDEBUG(1321, *YYCURSOR);
+yy1323:
+	YYDEBUG(1323, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'O') {
 		if (yych <= '@') {
 			if (yych == ')') goto yy139;
 			goto yy3;
 		} else {
-			if (yych == 'I') goto yy1323;
+			if (yych == 'I') goto yy1325;
 			if (yych <= 'N') goto yy141;
 		}
 	} else {
@@ -19495,15 +19559,15 @@ yy1321:
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'h') goto yy141;
-			goto yy1323;
+			goto yy1325;
 		} else {
-			if (yych == 'o') goto yy1322;
+			if (yych == 'o') goto yy1324;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1322:
-	YYDEBUG(1322, *YYCURSOR);
+yy1324:
+	YYDEBUG(1324, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -19512,7 +19576,7 @@ yy1322:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy142;
-			goto yy1326;
+			goto yy1328;
 		}
 	} else {
 		if (yych <= 'm') {
@@ -19520,13 +19584,13 @@ yy1322:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'n') goto yy1326;
+			if (yych <= 'n') goto yy1328;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1323:
-	YYDEBUG(1323, *YYCURSOR);
+yy1325:
+	YYDEBUG(1325, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -19542,13 +19606,13 @@ yy1323:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 'd') goto yy1324;
+			if (yych <= 'd') goto yy1326;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1324:
-	YYDEBUG(1324, *YYCURSOR);
+yy1326:
+	YYDEBUG(1326, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
@@ -19558,13 +19622,13 @@ yy1324:
 			if (yych <= 'Z') goto yy143;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1325;
+			if (yych <= 'a') goto yy1327;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1325:
-	YYDEBUG(1325, *YYCURSOR);
+yy1327:
+	YYDEBUG(1327, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'Y') {
 		if (yych <= ')') {
@@ -19573,7 +19637,7 @@ yy1325:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy144;
-			goto yy1233;
+			goto yy1235;
 		}
 	} else {
 		if (yych <= 'x') {
@@ -19581,13 +19645,13 @@ yy1325:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'y') goto yy1233;
+			if (yych <= 'y') goto yy1235;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1326:
-	YYDEBUG(1326, *YYCURSOR);
+yy1328:
+	YYDEBUG(1328, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -19603,17 +19667,17 @@ yy1326:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 't') goto yy1327;
+			if (yych <= 't') goto yy1329;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1327:
-	YYDEBUG(1327, *YYCURSOR);
+yy1329:
+	YYDEBUG(1329, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= ')') {
-		if (yych == ' ') goto yy1328;
+		if (yych == ' ') goto yy1330;
 		if (yych <= '(') goto yy3;
 		goto yy139;
 	} else {
@@ -19626,101 +19690,101 @@ yy1327:
 			goto yy3;
 		}
 	}
-yy1328:
-	YYDEBUG(1328, *YYCURSOR);
+yy1330:
+	YYDEBUG(1330, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'O') goto yy1329;
+	if (yych == 'O') goto yy1331;
 	if (yych != 'o') goto yy56;
-yy1329:
-	YYDEBUG(1329, *YYCURSOR);
+yy1331:
+	YYDEBUG(1331, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'F') goto yy1330;
+	if (yych == 'F') goto yy1332;
 	if (yych != 'f') goto yy56;
-yy1330:
-	YYDEBUG(1330, *YYCURSOR);
+yy1332:
+	YYDEBUG(1332, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych != ' ') goto yy56;
-	YYDEBUG(1331, *YYCURSOR);
+	YYDEBUG(1333, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') goto yy56;
-	if (yych <= '1') goto yy1332;
-	if (yych <= '2') goto yy1333;
-	if (yych <= '9') goto yy1334;
+	if (yych <= '1') goto yy1334;
+	if (yych <= '2') goto yy1335;
+	if (yych <= '9') goto yy1336;
 	goto yy56;
-yy1332:
-	YYDEBUG(1332, *YYCURSOR);
+yy1334:
+	YYDEBUG(1334, *YYCURSOR);
 	yyaccept = 28;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '/') goto yy1335;
-	if (yych <= '9') goto yy1334;
-	goto yy1335;
-yy1333:
-	YYDEBUG(1333, *YYCURSOR);
+	if (yych <= '/') goto yy1337;
+	if (yych <= '9') goto yy1336;
+	goto yy1337;
+yy1335:
+	YYDEBUG(1335, *YYCURSOR);
 	yyaccept = 28;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '/') goto yy1335;
-	if (yych >= '5') goto yy1335;
-yy1334:
-	YYDEBUG(1334, *YYCURSOR);
+	if (yych <= '/') goto yy1337;
+	if (yych >= '5') goto yy1337;
+yy1336:
+	YYDEBUG(1336, *YYCURSOR);
 	yyaccept = 28;
 	YYMARKER = ++YYCURSOR;
 	if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5);
 	yych = *YYCURSOR;
-yy1335:
-	YYDEBUG(1335, *YYCURSOR);
+yy1337:
+	YYDEBUG(1337, *YYCURSOR);
 	if (yych <= 'A') {
 		if (yych <= 0x1F) {
-			if (yych == '\t') goto yy1334;
-			goto yy1292;
+			if (yych == '\t') goto yy1336;
+			goto yy1294;
 		} else {
-			if (yych <= ' ') goto yy1334;
-			if (yych <= '@') goto yy1292;
+			if (yych <= ' ') goto yy1336;
+			if (yych <= '@') goto yy1294;
 		}
 	} else {
 		if (yych <= '`') {
-			if (yych != 'P') goto yy1292;
+			if (yych != 'P') goto yy1294;
 		} else {
-			if (yych <= 'a') goto yy1336;
-			if (yych != 'p') goto yy1292;
+			if (yych <= 'a') goto yy1338;
+			if (yych != 'p') goto yy1294;
 		}
 	}
-yy1336:
-	YYDEBUG(1336, *YYCURSOR);
+yy1338:
+	YYDEBUG(1338, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'L') {
 		if (yych != '.') goto yy56;
 	} else {
-		if (yych <= 'M') goto yy1338;
-		if (yych == 'm') goto yy1338;
+		if (yych <= 'M') goto yy1340;
+		if (yych == 'm') goto yy1340;
 		goto yy56;
 	}
-	YYDEBUG(1337, *YYCURSOR);
+	YYDEBUG(1339, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'M') goto yy1338;
+	if (yych == 'M') goto yy1340;
 	if (yych != 'm') goto yy56;
-yy1338:
-	YYDEBUG(1338, *YYCURSOR);
+yy1340:
+	YYDEBUG(1340, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 0x1F) {
-		if (yych <= 0x00) goto yy1300;
-		if (yych == '\t') goto yy1300;
+		if (yych <= 0x00) goto yy1302;
+		if (yych == '\t') goto yy1302;
 		goto yy56;
 	} else {
-		if (yych <= ' ') goto yy1300;
+		if (yych <= ' ') goto yy1302;
 		if (yych != '.') goto yy56;
 	}
-	YYDEBUG(1339, *YYCURSOR);
+	YYDEBUG(1341, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '\t') {
-		if (yych <= 0x00) goto yy1300;
+		if (yych <= 0x00) goto yy1302;
 		if (yych <= 0x08) goto yy56;
-		goto yy1300;
+		goto yy1302;
 	} else {
-		if (yych == ' ') goto yy1300;
+		if (yych == ' ') goto yy1302;
 		goto yy56;
 	}
-yy1340:
-	YYDEBUG(1340, *YYCURSOR);
+yy1342:
+	YYDEBUG(1342, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -19736,13 +19800,13 @@ yy1340:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'r') goto yy1341;
+			if (yych <= 'r') goto yy1343;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1341:
-	YYDEBUG(1341, *YYCURSOR);
+yy1343:
+	YYDEBUG(1343, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -19758,13 +19822,13 @@ yy1341:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 't') goto yy1342;
+			if (yych <= 't') goto yy1344;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1342:
-	YYDEBUG(1342, *YYCURSOR);
+yy1344:
+	YYDEBUG(1344, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -19773,7 +19837,7 @@ yy1342:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy144;
-			goto yy1254;
+			goto yy1215;
 		}
 	} else {
 		if (yych <= 'g') {
@@ -19781,13 +19845,13 @@ yy1342:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'h') goto yy1254;
+			if (yych <= 'h') goto yy1215;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1343:
-	YYDEBUG(1343, *YYCURSOR);
+yy1345:
+	YYDEBUG(1345, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= ')') {
@@ -19796,7 +19860,7 @@ yy1343:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'R') goto yy142;
-			goto yy1346;
+			goto yy1348;
 		}
 	} else {
 		if (yych <= 'r') {
@@ -19804,13 +19868,13 @@ yy1343:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 's') goto yy1346;
+			if (yych <= 's') goto yy1348;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1344:
-	YYDEBUG(1344, *YYCURSOR);
+yy1346:
+	YYDEBUG(1346, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -19826,13 +19890,13 @@ yy1344:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1345;
+			if (yych <= 't') goto yy1347;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1345:
-	YYDEBUG(1345, *YYCURSOR);
+yy1347:
+	YYDEBUG(1347, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -19841,7 +19905,7 @@ yy1345:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= 'g') {
@@ -19849,13 +19913,13 @@ yy1345:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'h') goto yy1214;
+			if (yych <= 'h') goto yy1238;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1346:
-	YYDEBUG(1346, *YYCURSOR);
+yy1348:
+	YYDEBUG(1348, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -19871,13 +19935,13 @@ yy1346:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 't') goto yy1347;
+			if (yych <= 't') goto yy1349;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1347:
-	YYDEBUG(1347, *YYCURSOR);
+yy1349:
+	YYDEBUG(1349, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '(') {
@@ -19898,44 +19962,44 @@ yy1347:
 			goto yy3;
 		}
 	}
-yy1348:
-	YYDEBUG(1348, *YYCURSOR);
+yy1350:
+	YYDEBUG(1350, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'D') goto yy1349;
+	if (yych == 'D') goto yy1351;
 	if (yych != 'd') goto yy1207;
-yy1349:
-	YYDEBUG(1349, *YYCURSOR);
+yy1351:
+	YYDEBUG(1351, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'A') goto yy1350;
+	if (yych == 'A') goto yy1352;
 	if (yych != 'a') goto yy56;
-yy1350:
-	YYDEBUG(1350, *YYCURSOR);
+yy1352:
+	YYDEBUG(1352, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'Y') goto yy1351;
+	if (yych == 'Y') goto yy1353;
 	if (yych != 'y') goto yy56;
-yy1351:
-	YYDEBUG(1351, *YYCURSOR);
+yy1353:
+	YYDEBUG(1353, *YYCURSOR);
 	yyaccept = 29;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
-		if (yych != ' ') goto yy1311;
+		if (yych != ' ') goto yy1313;
 	} else {
 		if (yych <= 'S') goto yy1142;
 		if (yych == 's') goto yy1142;
-		goto yy1311;
+		goto yy1313;
 	}
-	YYDEBUG(1352, *YYCURSOR);
+	YYDEBUG(1354, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'O') goto yy1353;
+	if (yych == 'O') goto yy1355;
 	if (yych != 'o') goto yy56;
-yy1353:
-	YYDEBUG(1353, *YYCURSOR);
+yy1355:
+	YYDEBUG(1355, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'F') goto yy1314;
-	if (yych == 'f') goto yy1314;
+	if (yych == 'F') goto yy1316;
+	if (yych == 'f') goto yy1316;
 	goto yy56;
-yy1354:
-	YYDEBUG(1354, *YYCURSOR);
+yy1356:
+	YYDEBUG(1356, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -19970,14 +20034,14 @@ yy1354:
 				if (yych <= '`') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'r') goto yy1355;
+				if (yych <= 'r') goto yy1357;
 				if (yych <= 'z') goto yy142;
 				goto yy194;
 			}
 		}
 	}
-yy1355:
-	YYDEBUG(1355, *YYCURSOR);
+yy1357:
+	YYDEBUG(1357, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'U') {
 		if (yych <= ')') {
@@ -19993,13 +20057,13 @@ yy1355:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'u') goto yy1356;
+			if (yych <= 'u') goto yy1358;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1356:
-	YYDEBUG(1356, *YYCURSOR);
+yy1358:
+	YYDEBUG(1358, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
@@ -20009,30 +20073,30 @@ yy1356:
 			if (yych <= 'Z') goto yy144;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1357;
+			if (yych <= 'a') goto yy1359;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1357:
-	YYDEBUG(1357, *YYCURSOR);
+yy1359:
+	YYDEBUG(1359, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Q') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'R') goto yy1358;
+		if (yych <= 'R') goto yy1360;
 		if (yych != 'r') goto yy3;
 	}
-yy1358:
-	YYDEBUG(1358, *YYCURSOR);
+yy1360:
+	YYDEBUG(1360, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy206;
 	if (yych == 'y') goto yy206;
 	goto yy56;
-yy1359:
-	YYDEBUG(1359, *YYCURSOR);
+yy1361:
+	YYDEBUG(1361, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'B') {
@@ -20043,7 +20107,7 @@ yy1359:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'A') goto yy141;
-			goto yy1354;
+			goto yy1356;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20051,13 +20115,13 @@ yy1359:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'b') goto yy1377;
+			if (yych == 'b') goto yy1379;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1360:
-	YYDEBUG(1360, *YYCURSOR);
+yy1362:
+	YYDEBUG(1362, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -20070,9 +20134,9 @@ yy1360:
 				if (yych <= '@') goto yy3;
 				goto yy141;
 			} else {
-				if (yych <= 'F') goto yy1344;
+				if (yych <= 'F') goto yy1346;
 				if (yych <= 'Q') goto yy141;
-				goto yy1343;
+				goto yy1345;
 			}
 		}
 	} else {
@@ -20087,17 +20151,17 @@ yy1360:
 			}
 		} else {
 			if (yych <= 'q') {
-				if (yych <= 'f') goto yy1373;
+				if (yych <= 'f') goto yy1375;
 				goto yy146;
 			} else {
-				if (yych <= 'r') goto yy1372;
+				if (yych <= 'r') goto yy1374;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1361:
-	YYDEBUG(1361, *YYCURSOR);
+yy1363:
+	YYDEBUG(1363, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'U') {
@@ -20108,7 +20172,7 @@ yy1361:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'T') goto yy141;
-			goto yy1340;
+			goto yy1342;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20116,13 +20180,13 @@ yy1361:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'u') goto yy1369;
+			if (yych == 'u') goto yy1371;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1362:
-	YYDEBUG(1362, *YYCURSOR);
+yy1364:
+	YYDEBUG(1364, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'O') {
@@ -20135,9 +20199,9 @@ yy1362:
 				if (yych <= '@') goto yy3;
 				goto yy141;
 			} else {
-				if (yych <= 'I') goto yy1323;
+				if (yych <= 'I') goto yy1325;
 				if (yych <= 'N') goto yy141;
-				goto yy1322;
+				goto yy1324;
 			}
 		}
 	} else {
@@ -20152,17 +20216,17 @@ yy1362:
 			}
 		} else {
 			if (yych <= 'n') {
-				if (yych <= 'i') goto yy1364;
+				if (yych <= 'i') goto yy1366;
 				goto yy146;
 			} else {
-				if (yych <= 'o') goto yy1363;
+				if (yych <= 'o') goto yy1365;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1363:
-	YYDEBUG(1363, *YYCURSOR);
+yy1365:
+	YYDEBUG(1365, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -20173,7 +20237,7 @@ yy1363:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy142;
-			goto yy1326;
+			goto yy1328;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20181,13 +20245,13 @@ yy1363:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1367;
+			if (yych == 'n') goto yy1369;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1364:
-	YYDEBUG(1364, *YYCURSOR);
+yy1366:
+	YYDEBUG(1366, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -20198,7 +20262,7 @@ yy1364:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'C') goto yy142;
-			goto yy1324;
+			goto yy1326;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20206,13 +20270,13 @@ yy1364:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 'd') goto yy1365;
+			if (yych == 'd') goto yy1367;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1365:
-	YYDEBUG(1365, *YYCURSOR);
+yy1367:
+	YYDEBUG(1367, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -20222,7 +20286,7 @@ yy1365:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1325;
+			goto yy1327;
 		}
 	} else {
 		if (yych <= '_') {
@@ -20231,13 +20295,13 @@ yy1365:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1366;
+			if (yych <= 'a') goto yy1368;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1366:
-	YYDEBUG(1366, *YYCURSOR);
+yy1368:
+	YYDEBUG(1368, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -20248,7 +20312,7 @@ yy1366:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy144;
-			goto yy1233;
+			goto yy1235;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20256,13 +20320,13 @@ yy1366:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'y') goto yy1262;
+			if (yych == 'y') goto yy1264;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1367:
-	YYDEBUG(1367, *YYCURSOR);
+yy1369:
+	YYDEBUG(1369, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -20273,7 +20337,7 @@ yy1367:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy143;
-			goto yy1327;
+			goto yy1329;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20281,18 +20345,18 @@ yy1367:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1368;
+			if (yych == 't') goto yy1370;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1368:
-	YYDEBUG(1368, *YYCURSOR);
+yy1370:
+	YYDEBUG(1370, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
 		if (yych <= '(') {
-			if (yych == ' ') goto yy1328;
+			if (yych == ' ') goto yy1330;
 			goto yy3;
 		} else {
 			if (yych <= ')') goto yy139;
@@ -20311,8 +20375,8 @@ yy1368:
 			goto yy3;
 		}
 	}
-yy1369:
-	YYDEBUG(1369, *YYCURSOR);
+yy1371:
+	YYDEBUG(1371, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -20323,7 +20387,7 @@ yy1369:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy142;
-			goto yy1341;
+			goto yy1343;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20331,13 +20395,13 @@ yy1369:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1370;
+			if (yych == 'r') goto yy1372;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1370:
-	YYDEBUG(1370, *YYCURSOR);
+yy1372:
+	YYDEBUG(1372, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -20348,7 +20412,7 @@ yy1370:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy143;
-			goto yy1342;
+			goto yy1344;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20356,13 +20420,13 @@ yy1370:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1371;
+			if (yych == 't') goto yy1373;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1371:
-	YYDEBUG(1371, *YYCURSOR);
+yy1373:
+	YYDEBUG(1373, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -20373,7 +20437,7 @@ yy1371:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy144;
-			goto yy1254;
+			goto yy1215;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20381,13 +20445,13 @@ yy1371:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1283;
+			if (yych == 'h') goto yy1227;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1372:
-	YYDEBUG(1372, *YYCURSOR);
+yy1374:
+	YYDEBUG(1374, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -20398,7 +20462,7 @@ yy1372:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'R') goto yy142;
-			goto yy1346;
+			goto yy1348;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20406,13 +20470,13 @@ yy1372:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 's') goto yy1375;
+			if (yych == 's') goto yy1377;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1373:
-	YYDEBUG(1373, *YYCURSOR);
+yy1375:
+	YYDEBUG(1375, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -20423,7 +20487,7 @@ yy1373:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1345;
+			goto yy1347;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20431,13 +20495,13 @@ yy1373:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1374;
+			if (yych == 't') goto yy1376;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1374:
-	YYDEBUG(1374, *YYCURSOR);
+yy1376:
+	YYDEBUG(1376, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -20448,7 +20512,7 @@ yy1374:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20456,13 +20520,13 @@ yy1374:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1225;
+			if (yych == 'h') goto yy1267;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1375:
-	YYDEBUG(1375, *YYCURSOR);
+yy1377:
+	YYDEBUG(1377, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -20473,7 +20537,7 @@ yy1375:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy143;
-			goto yy1347;
+			goto yy1349;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20481,13 +20545,13 @@ yy1375:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1376;
+			if (yych == 't') goto yy1378;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1376:
-	YYDEBUG(1376, *YYCURSOR);
+yy1378:
+	YYDEBUG(1378, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '.') {
@@ -20495,7 +20559,7 @@ yy1376:
 			if (yych == '\t') goto yy1206;
 			goto yy3;
 		} else {
-			if (yych <= ' ') goto yy1348;
+			if (yych <= ' ') goto yy1350;
 			if (yych == ')') goto yy139;
 			goto yy3;
 		}
@@ -20512,8 +20576,8 @@ yy1376:
 			goto yy3;
 		}
 	}
-yy1377:
-	YYDEBUG(1377, *YYCURSOR);
+yy1379:
+	YYDEBUG(1379, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '9') {
@@ -20541,7 +20605,7 @@ yy1377:
 				if (yych <= '@') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'R') goto yy1355;
+				if (yych <= 'R') goto yy1357;
 				if (yych <= 'Z') goto yy142;
 				goto yy194;
 			}
@@ -20551,14 +20615,14 @@ yy1377:
 				if (yych <= '`') goto yy194;
 				goto yy151;
 			} else {
-				if (yych <= 'r') goto yy1378;
+				if (yych <= 'r') goto yy1380;
 				if (yych <= 'z') goto yy151;
 				goto yy194;
 			}
 		}
 	}
-yy1378:
-	YYDEBUG(1378, *YYCURSOR);
+yy1380:
+	YYDEBUG(1380, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'U') {
@@ -20569,7 +20633,7 @@ yy1378:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'T') goto yy143;
-			goto yy1356;
+			goto yy1358;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20577,13 +20641,13 @@ yy1378:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'u') goto yy1379;
+			if (yych == 'u') goto yy1381;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1379:
-	YYDEBUG(1379, *YYCURSOR);
+yy1381:
+	YYDEBUG(1381, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -20593,7 +20657,7 @@ yy1379:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1357;
+			goto yy1359;
 		}
 	} else {
 		if (yych <= '_') {
@@ -20602,13 +20666,13 @@ yy1379:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1380;
+			if (yych <= 'a') goto yy1382;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1380:
-	YYDEBUG(1380, *YYCURSOR);
+yy1382:
+	YYDEBUG(1382, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -20618,39 +20682,39 @@ yy1380:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'Q') goto yy3;
-			goto yy1358;
+			goto yy1360;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1381;
+			if (yych == 'r') goto yy1383;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1381:
-	YYDEBUG(1381, *YYCURSOR);
+yy1383:
+	YYDEBUG(1383, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy206;
 	if (yych == 'y') goto yy377;
 	goto yy155;
-yy1382:
-	YYDEBUG(1382, *YYCURSOR);
+yy1384:
+	YYDEBUG(1384, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') goto yy56;
 	if (yych >= ':') goto yy56;
-yy1383:
-	YYDEBUG(1383, *YYCURSOR);
+yy1385:
+	YYDEBUG(1385, *YYCURSOR);
 	++YYCURSOR;
 	if (YYLIMIT <= YYCURSOR) YYFILL(1);
 	yych = *YYCURSOR;
-	YYDEBUG(1384, *YYCURSOR);
-	if (yych <= '/') goto yy1385;
-	if (yych <= '9') goto yy1383;
-yy1385:
-	YYDEBUG(1385, *YYCURSOR);
+	YYDEBUG(1386, *YYCURSOR);
+	if (yych <= '/') goto yy1387;
+	if (yych <= '9') goto yy1385;
+yy1387:
+	YYDEBUG(1387, *YYCURSOR);
 	{
 		timelib_ull i;
 
@@ -20674,8 +20738,8 @@ yy1385:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-yy1386:
-	YYDEBUG(1386, *YYCURSOR);
+yy1388:
+	YYDEBUG(1388, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -20684,7 +20748,7 @@ yy1386:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy141;
-			goto yy1427;
+			goto yy1429;
 		}
 	} else {
 		if (yych <= 'm') {
@@ -20692,61 +20756,61 @@ yy1386:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'n') goto yy1427;
+			if (yych <= 'n') goto yy1429;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1387:
-	YYDEBUG(1387, *YYCURSOR);
+yy1389:
+	YYDEBUG(1389, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'U') {
 		if (yych <= '@') {
 			if (yych == ')') goto yy139;
 			goto yy3;
 		} else {
-			if (yych == 'I') goto yy1419;
+			if (yych == 'I') goto yy1421;
 			if (yych <= 'T') goto yy141;
-			goto yy1420;
+			goto yy1422;
 		}
 	} else {
 		if (yych <= 'i') {
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'h') goto yy141;
-			goto yy1419;
+			goto yy1421;
 		} else {
-			if (yych == 'u') goto yy1420;
+			if (yych == 'u') goto yy1422;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1388:
-	YYDEBUG(1388, *YYCURSOR);
+yy1390:
+	YYDEBUG(1390, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'M') {
 		if (yych <= '@') {
 			if (yych == ')') goto yy139;
 			goto yy3;
 		} else {
-			if (yych == 'D') goto yy1408;
+			if (yych == 'D') goto yy1410;
 			if (yych <= 'L') goto yy141;
-			goto yy1409;
+			goto yy1411;
 		}
 	} else {
 		if (yych <= 'd') {
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'c') goto yy141;
-			goto yy1408;
+			goto yy1410;
 		} else {
-			if (yych == 'm') goto yy1409;
+			if (yych == 'm') goto yy1411;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1389:
-	YYDEBUG(1389, *YYCURSOR);
+yy1391:
+	YYDEBUG(1391, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'E') {
 		if (yych <= ')') {
@@ -20755,7 +20819,7 @@ yy1389:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy141;
-			goto yy1404;
+			goto yy1406;
 		}
 	} else {
 		if (yych <= 'd') {
@@ -20763,13 +20827,13 @@ yy1389:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'e') goto yy1404;
+			if (yych <= 'e') goto yy1406;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1390:
-	YYDEBUG(1390, *YYCURSOR);
+yy1392:
+	YYDEBUG(1392, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'E') {
 		if (yych <= ')') {
@@ -20778,7 +20842,7 @@ yy1390:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy141;
-			goto yy1400;
+			goto yy1402;
 		}
 	} else {
 		if (yych <= 'd') {
@@ -20786,78 +20850,78 @@ yy1390:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'e') goto yy1400;
+			if (yych <= 'e') goto yy1402;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1391:
-	YYDEBUG(1391, *YYCURSOR);
+yy1393:
+	YYDEBUG(1393, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') {
 		if (yych == '.') goto yy1064;
 		goto yy56;
 	} else {
-		if (yych <= '9') goto yy1394;
+		if (yych <= '9') goto yy1396;
 		if (yych <= ':') goto yy1064;
 		goto yy56;
 	}
-yy1392:
-	YYDEBUG(1392, *YYCURSOR);
+yy1394:
+	YYDEBUG(1394, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') {
 		if (yych == '.') goto yy1064;
 		goto yy56;
 	} else {
-		if (yych <= '4') goto yy1394;
+		if (yych <= '4') goto yy1396;
 		if (yych == ':') goto yy1064;
 		goto yy56;
 	}
-yy1393:
-	YYDEBUG(1393, *YYCURSOR);
+yy1395:
+	YYDEBUG(1395, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == '.') goto yy1064;
 	if (yych == ':') goto yy1064;
 	goto yy56;
-yy1394:
-	YYDEBUG(1394, *YYCURSOR);
+yy1396:
+	YYDEBUG(1396, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') {
 		if (yych == '.') goto yy1064;
 		goto yy56;
 	} else {
-		if (yych <= '5') goto yy1395;
+		if (yych <= '5') goto yy1397;
 		if (yych == ':') goto yy1064;
 		goto yy56;
 	}
-yy1395:
-	YYDEBUG(1395, *YYCURSOR);
+yy1397:
+	YYDEBUG(1397, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') goto yy56;
 	if (yych >= ':') goto yy56;
-	YYDEBUG(1396, *YYCURSOR);
+	YYDEBUG(1398, *YYCURSOR);
 	yyaccept = 24;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') goto yy1067;
-	if (yych <= '5') goto yy1397;
-	if (yych <= '6') goto yy1398;
+	if (yych <= '5') goto yy1399;
+	if (yych <= '6') goto yy1400;
 	goto yy1067;
-yy1397:
-	YYDEBUG(1397, *YYCURSOR);
+yy1399:
+	YYDEBUG(1399, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') goto yy56;
-	if (yych <= '9') goto yy1399;
+	if (yych <= '9') goto yy1401;
 	goto yy56;
-yy1398:
-	YYDEBUG(1398, *YYCURSOR);
+yy1400:
+	YYDEBUG(1400, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych != '0') goto yy56;
-yy1399:
-	YYDEBUG(1399, *YYCURSOR);
+yy1401:
+	YYDEBUG(1401, *YYCURSOR);
 	yych = *++YYCURSOR;
 	goto yy1075;
-yy1400:
-	YYDEBUG(1400, *YYCURSOR);
+yy1402:
+	YYDEBUG(1402, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'L') {
 		if (yych <= ')') {
@@ -20873,13 +20937,13 @@ yy1400:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'l') goto yy1401;
+			if (yych <= 'l') goto yy1403;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1401:
-	YYDEBUG(1401, *YYCURSOR);
+yy1403:
+	YYDEBUG(1403, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'F') {
 		if (yych <= ')') {
@@ -20895,13 +20959,13 @@ yy1401:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'f') goto yy1402;
+			if (yych <= 'f') goto yy1404;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1402:
-	YYDEBUG(1402, *YYCURSOR);
+yy1404:
+	YYDEBUG(1404, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -20917,13 +20981,13 @@ yy1402:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 't') goto yy1403;
+			if (yych <= 't') goto yy1405;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1403:
-	YYDEBUG(1403, *YYCURSOR);
+yy1405:
+	YYDEBUG(1405, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'G') {
@@ -20934,8 +20998,8 @@ yy1403:
 		if (yych == 'h') goto yy1205;
 		goto yy3;
 	}
-yy1404:
-	YYDEBUG(1404, *YYCURSOR);
+yy1406:
+	YYDEBUG(1406, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= ')') {
@@ -20951,13 +21015,13 @@ yy1404:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 's') goto yy1405;
+			if (yych <= 's') goto yy1407;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1405:
-	YYDEBUG(1405, *YYCURSOR);
+yy1407:
+	YYDEBUG(1407, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -20973,13 +21037,13 @@ yy1405:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'd') goto yy1406;
+			if (yych <= 'd') goto yy1408;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1406:
-	YYDEBUG(1406, *YYCURSOR);
+yy1408:
+	YYDEBUG(1408, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
@@ -20989,13 +21053,13 @@ yy1406:
 			if (yych <= 'Z') goto yy144;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1407;
+			if (yych <= 'a') goto yy1409;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1407:
-	YYDEBUG(1407, *YYCURSOR);
+yy1409:
+	YYDEBUG(1409, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'X') {
 		if (yych == ')') goto yy139;
@@ -21005,25 +21069,25 @@ yy1407:
 		if (yych == 'y') goto yy173;
 		goto yy3;
 	}
-yy1408:
-	YYDEBUG(1408, *YYCURSOR);
+yy1410:
+	YYDEBUG(1410, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		if (yych <= '@') goto yy3;
-		goto yy1416;
+		goto yy1418;
 	} else {
 		if (yych <= '`') {
 			if (yych <= 'Z') goto yy142;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1416;
+			if (yych <= 'a') goto yy1418;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1409:
-	YYDEBUG(1409, *YYCURSOR);
+yy1411:
+	YYDEBUG(1411, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'O') {
 		if (yych <= ')') {
@@ -21039,13 +21103,13 @@ yy1409:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'o') goto yy1410;
+			if (yych <= 'o') goto yy1412;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1410:
-	YYDEBUG(1410, *YYCURSOR);
+yy1412:
+	YYDEBUG(1412, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -21061,13 +21125,13 @@ yy1410:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'r') goto yy1411;
+			if (yych <= 'r') goto yy1413;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1411:
-	YYDEBUG(1411, *YYCURSOR);
+yy1413:
+	YYDEBUG(1413, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -21083,32 +21147,32 @@ yy1411:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'r') goto yy1412;
+			if (yych <= 'r') goto yy1414;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1412:
-	YYDEBUG(1412, *YYCURSOR);
+yy1414:
+	YYDEBUG(1414, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'O') goto yy1413;
+		if (yych <= 'O') goto yy1415;
 		if (yych != 'o') goto yy3;
 	}
-yy1413:
-	YYDEBUG(1413, *YYCURSOR);
+yy1415:
+	YYDEBUG(1415, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'W') goto yy1414;
+	if (yych == 'W') goto yy1416;
 	if (yych != 'w') goto yy56;
-yy1414:
-	YYDEBUG(1414, *YYCURSOR);
+yy1416:
+	YYDEBUG(1416, *YYCURSOR);
 	++YYCURSOR;
-yy1415:
-	YYDEBUG(1415, *YYCURSOR);
+yy1417:
+	YYDEBUG(1417, *YYCURSOR);
 	{
 		DEBUG_OUTPUT("tomorrow");
 		TIMELIB_INIT;
@@ -21119,8 +21183,8 @@ yy1415:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-yy1416:
-	YYDEBUG(1416, *YYCURSOR);
+yy1418:
+	YYDEBUG(1418, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'Y') {
 		if (yych <= ')') {
@@ -21136,23 +21200,23 @@ yy1416:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'y') goto yy1417;
+			if (yych <= 'y') goto yy1419;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1417:
-	YYDEBUG(1417, *YYCURSOR);
+yy1419:
+	YYDEBUG(1419, *YYCURSOR);
 	++YYCURSOR;
 	if ((yych = *YYCURSOR) <= '@') {
 		if (yych == ')') goto yy139;
 	} else {
 		if (yych <= 'Z') goto yy144;
-		if (yych <= '`') goto yy1418;
+		if (yych <= '`') goto yy1420;
 		if (yych <= 'z') goto yy144;
 	}
-yy1418:
-	YYDEBUG(1418, *YYCURSOR);
+yy1420:
+	YYDEBUG(1420, *YYCURSOR);
 	{
 		DEBUG_OUTPUT("midnight | today");
 		TIMELIB_INIT;
@@ -21161,8 +21225,8 @@ yy1418:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-yy1419:
-	YYDEBUG(1419, *YYCURSOR);
+yy1421:
+	YYDEBUG(1421, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= '@') {
@@ -21170,8 +21234,8 @@ yy1419:
 			goto yy3;
 		} else {
 			if (yych <= 'Q') goto yy142;
-			if (yych <= 'R') goto yy1425;
-			goto yy1426;
+			if (yych <= 'R') goto yy1427;
+			goto yy1428;
 		}
 	} else {
 		if (yych <= 'q') {
@@ -21179,14 +21243,14 @@ yy1419:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'r') goto yy1425;
-			if (yych <= 's') goto yy1426;
+			if (yych <= 'r') goto yy1427;
+			if (yych <= 's') goto yy1428;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1420:
-	YYDEBUG(1420, *YYCURSOR);
+yy1422:
+	YYDEBUG(1422, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -21202,13 +21266,13 @@ yy1420:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 'r') goto yy1421;
+			if (yych <= 'r') goto yy1423;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1421:
-	YYDEBUG(1421, *YYCURSOR);
+yy1423:
+	YYDEBUG(1423, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= ')') {
@@ -21224,13 +21288,13 @@ yy1421:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 's') goto yy1422;
+			if (yych <= 's') goto yy1424;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1422:
-	YYDEBUG(1422, *YYCURSOR);
+yy1424:
+	YYDEBUG(1424, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -21246,30 +21310,30 @@ yy1422:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'd') goto yy1423;
+			if (yych <= 'd') goto yy1425;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1423:
-	YYDEBUG(1423, *YYCURSOR);
+yy1425:
+	YYDEBUG(1425, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '@') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'A') goto yy1424;
+		if (yych <= 'A') goto yy1426;
 		if (yych != 'a') goto yy3;
 	}
-yy1424:
-	YYDEBUG(1424, *YYCURSOR);
+yy1426:
+	YYDEBUG(1426, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy173;
 	if (yych == 'y') goto yy173;
 	goto yy56;
-yy1425:
-	YYDEBUG(1425, *YYCURSOR);
+yy1427:
+	YYDEBUG(1427, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -21278,7 +21342,7 @@ yy1425:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= 'c') {
@@ -21286,13 +21350,13 @@ yy1425:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'd') goto yy1214;
+			if (yych <= 'd') goto yy1238;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1426:
-	YYDEBUG(1426, *YYCURSOR);
+yy1428:
+	YYDEBUG(1428, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '(') {
@@ -21314,8 +21378,8 @@ yy1426:
 			goto yy3;
 		}
 	}
-yy1427:
-	YYDEBUG(1427, *YYCURSOR);
+yy1429:
+	YYDEBUG(1429, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -21331,13 +21395,13 @@ yy1427:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1428;
+			if (yych <= 't') goto yy1430;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1428:
-	YYDEBUG(1428, *YYCURSOR);
+yy1430:
+	YYDEBUG(1430, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -21346,7 +21410,7 @@ yy1428:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= 'g') {
@@ -21354,13 +21418,13 @@ yy1428:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'h') goto yy1214;
+			if (yych <= 'h') goto yy1238;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1429:
-	YYDEBUG(1429, *YYCURSOR);
+yy1431:
+	YYDEBUG(1431, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -21371,7 +21435,7 @@ yy1429:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy141;
-			goto yy1427;
+			goto yy1429;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21379,13 +21443,13 @@ yy1429:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1459;
+			if (yych == 'n') goto yy1461;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1430:
-	YYDEBUG(1430, *YYCURSOR);
+yy1432:
+	YYDEBUG(1432, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'U') {
@@ -21398,9 +21462,9 @@ yy1430:
 				if (yych <= '@') goto yy3;
 				goto yy141;
 			} else {
-				if (yych <= 'I') goto yy1419;
+				if (yych <= 'I') goto yy1421;
 				if (yych <= 'T') goto yy141;
-				goto yy1420;
+				goto yy1422;
 			}
 		}
 	} else {
@@ -21415,17 +21479,17 @@ yy1430:
 			}
 		} else {
 			if (yych <= 't') {
-				if (yych <= 'i') goto yy1451;
+				if (yych <= 'i') goto yy1453;
 				goto yy146;
 			} else {
-				if (yych <= 'u') goto yy1452;
+				if (yych <= 'u') goto yy1454;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1431:
-	YYDEBUG(1431, *YYCURSOR);
+yy1433:
+	YYDEBUG(1433, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'M') {
@@ -21438,9 +21502,9 @@ yy1431:
 				if (yych <= '@') goto yy3;
 				goto yy141;
 			} else {
-				if (yych <= 'D') goto yy1408;
+				if (yych <= 'D') goto yy1410;
 				if (yych <= 'L') goto yy141;
-				goto yy1409;
+				goto yy1411;
 			}
 		}
 	} else {
@@ -21455,17 +21519,17 @@ yy1431:
 			}
 		} else {
 			if (yych <= 'l') {
-				if (yych <= 'd') goto yy1442;
+				if (yych <= 'd') goto yy1444;
 				goto yy146;
 			} else {
-				if (yych <= 'm') goto yy1443;
+				if (yych <= 'm') goto yy1445;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1432:
-	YYDEBUG(1432, *YYCURSOR);
+yy1434:
+	YYDEBUG(1434, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -21476,7 +21540,7 @@ yy1432:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy141;
-			goto yy1404;
+			goto yy1406;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21484,13 +21548,13 @@ yy1432:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1438;
+			if (yych == 'e') goto yy1440;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1433:
-	YYDEBUG(1433, *YYCURSOR);
+yy1435:
+	YYDEBUG(1435, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -21501,7 +21565,7 @@ yy1433:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy141;
-			goto yy1400;
+			goto yy1402;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21509,13 +21573,13 @@ yy1433:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1434;
+			if (yych == 'e') goto yy1436;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1434:
-	YYDEBUG(1434, *YYCURSOR);
+yy1436:
+	YYDEBUG(1436, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'L') {
@@ -21526,7 +21590,7 @@ yy1434:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'K') goto yy142;
-			goto yy1401;
+			goto yy1403;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21534,13 +21598,13 @@ yy1434:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'l') goto yy1435;
+			if (yych == 'l') goto yy1437;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1435:
-	YYDEBUG(1435, *YYCURSOR);
+yy1437:
+	YYDEBUG(1437, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'F') {
@@ -21551,7 +21615,7 @@ yy1435:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'E') goto yy143;
-			goto yy1402;
+			goto yy1404;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21559,13 +21623,13 @@ yy1435:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'f') goto yy1436;
+			if (yych == 'f') goto yy1438;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1436:
-	YYDEBUG(1436, *YYCURSOR);
+yy1438:
+	YYDEBUG(1438, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -21576,7 +21640,7 @@ yy1436:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy144;
-			goto yy1403;
+			goto yy1405;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21584,13 +21648,13 @@ yy1436:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1437;
+			if (yych == 't') goto yy1439;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1437:
-	YYDEBUG(1437, *YYCURSOR);
+yy1439:
+	YYDEBUG(1439, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -21607,13 +21671,13 @@ yy1437:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1222;
+			if (yych == 'h') goto yy1223;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1438:
-	YYDEBUG(1438, *YYCURSOR);
+yy1440:
+	YYDEBUG(1440, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -21624,7 +21688,7 @@ yy1438:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'R') goto yy142;
-			goto yy1405;
+			goto yy1407;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21632,13 +21696,13 @@ yy1438:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 's') goto yy1439;
+			if (yych == 's') goto yy1441;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1439:
-	YYDEBUG(1439, *YYCURSOR);
+yy1441:
+	YYDEBUG(1441, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -21649,7 +21713,7 @@ yy1439:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy143;
-			goto yy1406;
+			goto yy1408;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21657,13 +21721,13 @@ yy1439:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1440;
+			if (yych == 'd') goto yy1442;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1440:
-	YYDEBUG(1440, *YYCURSOR);
+yy1442:
+	YYDEBUG(1442, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -21673,7 +21737,7 @@ yy1440:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1407;
+			goto yy1409;
 		}
 	} else {
 		if (yych <= '_') {
@@ -21682,13 +21746,13 @@ yy1440:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1441;
+			if (yych <= 'a') goto yy1443;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1441:
-	YYDEBUG(1441, *YYCURSOR);
+yy1443:
+	YYDEBUG(1443, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -21710,8 +21774,8 @@ yy1441:
 			goto yy3;
 		}
 	}
-yy1442:
-	YYDEBUG(1442, *YYCURSOR);
+yy1444:
+	YYDEBUG(1444, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -21721,7 +21785,7 @@ yy1442:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1416;
+			goto yy1418;
 		}
 	} else {
 		if (yych <= '_') {
@@ -21730,13 +21794,13 @@ yy1442:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1449;
+			if (yych <= 'a') goto yy1451;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1443:
-	YYDEBUG(1443, *YYCURSOR);
+yy1445:
+	YYDEBUG(1445, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'O') {
@@ -21747,7 +21811,7 @@ yy1443:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'N') goto yy142;
-			goto yy1410;
+			goto yy1412;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21755,13 +21819,13 @@ yy1443:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'o') goto yy1444;
+			if (yych == 'o') goto yy1446;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1444:
-	YYDEBUG(1444, *YYCURSOR);
+yy1446:
+	YYDEBUG(1446, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -21772,7 +21836,7 @@ yy1444:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy143;
-			goto yy1411;
+			goto yy1413;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21780,13 +21844,13 @@ yy1444:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1445;
+			if (yych == 'r') goto yy1447;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1445:
-	YYDEBUG(1445, *YYCURSOR);
+yy1447:
+	YYDEBUG(1447, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -21797,7 +21861,7 @@ yy1445:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy144;
-			goto yy1412;
+			goto yy1414;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21805,13 +21869,13 @@ yy1445:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1446;
+			if (yych == 'r') goto yy1448;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1446:
-	YYDEBUG(1446, *YYCURSOR);
+yy1448:
+	YYDEBUG(1448, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'O') {
@@ -21821,37 +21885,37 @@ yy1446:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'N') goto yy3;
-			goto yy1413;
+			goto yy1415;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'o') goto yy1447;
+			if (yych == 'o') goto yy1449;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1447:
-	YYDEBUG(1447, *YYCURSOR);
+yy1449:
+	YYDEBUG(1449, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'W') goto yy1414;
+	if (yych == 'W') goto yy1416;
 	if (yych != 'w') goto yy155;
-	YYDEBUG(1448, *YYCURSOR);
+	YYDEBUG(1450, *YYCURSOR);
 	yyaccept = 30;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '^') {
 		if (yych == '/') goto yy147;
-		goto yy1415;
+		goto yy1417;
 	} else {
 		if (yych <= '_') goto yy147;
-		if (yych <= '`') goto yy1415;
+		if (yych <= '`') goto yy1417;
 		if (yych <= 'z') goto yy154;
-		goto yy1415;
+		goto yy1417;
 	}
-yy1449:
-	YYDEBUG(1449, *YYCURSOR);
+yy1451:
+	YYDEBUG(1451, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -21862,7 +21926,7 @@ yy1449:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy143;
-			goto yy1417;
+			goto yy1419;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21870,36 +21934,36 @@ yy1449:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'y') goto yy1450;
+			if (yych == 'y') goto yy1452;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1450:
-	YYDEBUG(1450, *YYCURSOR);
+yy1452:
+	YYDEBUG(1452, *YYCURSOR);
 	yyaccept = 31;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '@') {
 		if (yych <= ')') {
-			if (yych <= '(') goto yy1418;
+			if (yych <= '(') goto yy1420;
 			goto yy139;
 		} else {
 			if (yych == '/') goto yy147;
-			goto yy1418;
+			goto yy1420;
 		}
 	} else {
 		if (yych <= '_') {
 			if (yych <= 'Z') goto yy144;
-			if (yych <= '^') goto yy1418;
+			if (yych <= '^') goto yy1420;
 			goto yy147;
 		} else {
-			if (yych <= '`') goto yy1418;
+			if (yych <= '`') goto yy1420;
 			if (yych <= 'z') goto yy153;
-			goto yy1418;
+			goto yy1420;
 		}
 	}
-yy1451:
-	YYDEBUG(1451, *YYCURSOR);
+yy1453:
+	YYDEBUG(1453, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -21910,8 +21974,8 @@ yy1451:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy142;
-			if (yych <= 'R') goto yy1425;
-			goto yy1426;
+			if (yych <= 'R') goto yy1427;
+			goto yy1428;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21921,16 +21985,16 @@ yy1451:
 		} else {
 			if (yych <= 'r') {
 				if (yych <= 'q') goto yy151;
-				goto yy1457;
+				goto yy1459;
 			} else {
-				if (yych <= 's') goto yy1458;
+				if (yych <= 's') goto yy1460;
 				if (yych <= 'z') goto yy151;
 				goto yy3;
 			}
 		}
 	}
-yy1452:
-	YYDEBUG(1452, *YYCURSOR);
+yy1454:
+	YYDEBUG(1454, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -21941,7 +22005,7 @@ yy1452:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'Q') goto yy142;
-			goto yy1421;
+			goto yy1423;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21949,13 +22013,13 @@ yy1452:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 'r') goto yy1453;
+			if (yych == 'r') goto yy1455;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1453:
-	YYDEBUG(1453, *YYCURSOR);
+yy1455:
+	YYDEBUG(1455, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -21966,7 +22030,7 @@ yy1453:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'R') goto yy143;
-			goto yy1422;
+			goto yy1424;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21974,13 +22038,13 @@ yy1453:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 's') goto yy1454;
+			if (yych == 's') goto yy1456;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1454:
-	YYDEBUG(1454, *YYCURSOR);
+yy1456:
+	YYDEBUG(1456, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -21991,7 +22055,7 @@ yy1454:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy144;
-			goto yy1423;
+			goto yy1425;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21999,13 +22063,13 @@ yy1454:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1455;
+			if (yych == 'd') goto yy1457;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1455:
-	YYDEBUG(1455, *YYCURSOR);
+yy1457:
+	YYDEBUG(1457, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -22015,26 +22079,26 @@ yy1455:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1424;
+			goto yy1426;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1456;
+			if (yych <= 'a') goto yy1458;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1456:
-	YYDEBUG(1456, *YYCURSOR);
+yy1458:
+	YYDEBUG(1458, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy173;
 	if (yych == 'y') goto yy186;
 	goto yy155;
-yy1457:
-	YYDEBUG(1457, *YYCURSOR);
+yy1459:
+	YYDEBUG(1459, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -22045,7 +22109,7 @@ yy1457:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22053,13 +22117,13 @@ yy1457:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1225;
+			if (yych == 'd') goto yy1267;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1458:
-	YYDEBUG(1458, *YYCURSOR);
+yy1460:
+	YYDEBUG(1460, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '.') {
@@ -22084,8 +22148,8 @@ yy1458:
 			goto yy3;
 		}
 	}
-yy1459:
-	YYDEBUG(1459, *YYCURSOR);
+yy1461:
+	YYDEBUG(1461, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -22096,7 +22160,7 @@ yy1459:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1428;
+			goto yy1430;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22104,13 +22168,13 @@ yy1459:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1460;
+			if (yych == 't') goto yy1462;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1460:
-	YYDEBUG(1460, *YYCURSOR);
+yy1462:
+	YYDEBUG(1462, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -22121,7 +22185,7 @@ yy1460:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22129,37 +22193,37 @@ yy1460:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1225;
+			if (yych == 'h') goto yy1267;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1461:
-	YYDEBUG(1461, *YYCURSOR);
+yy1463:
+	YYDEBUG(1463, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'Y') {
 		if (yych <= '@') {
 			if (yych == ')') goto yy139;
 			goto yy3;
 		} else {
-			if (yych == 'R') goto yy1473;
+			if (yych == 'R') goto yy1475;
 			if (yych <= 'X') goto yy141;
-			goto yy1474;
+			goto yy1476;
 		}
 	} else {
 		if (yych <= 'r') {
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'q') goto yy141;
-			goto yy1473;
+			goto yy1475;
 		} else {
-			if (yych == 'y') goto yy1474;
+			if (yych == 'y') goto yy1476;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1462:
-	YYDEBUG(1462, *YYCURSOR);
+yy1464:
+	YYDEBUG(1464, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -22168,7 +22232,7 @@ yy1462:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy141;
-			goto yy1467;
+			goto yy1469;
 		}
 	} else {
 		if (yych <= 'c') {
@@ -22176,13 +22240,13 @@ yy1462:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'd') goto yy1467;
+			if (yych <= 'd') goto yy1469;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1463:
-	YYDEBUG(1463, *YYCURSOR);
+yy1465:
+	YYDEBUG(1465, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -22198,13 +22262,13 @@ yy1463:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'n') goto yy1464;
+			if (yych <= 'n') goto yy1466;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1464:
-	YYDEBUG(1464, *YYCURSOR);
+yy1466:
+	YYDEBUG(1466, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -22220,13 +22284,13 @@ yy1464:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 'd') goto yy1465;
+			if (yych <= 'd') goto yy1467;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1465:
-	YYDEBUG(1465, *YYCURSOR);
+yy1467:
+	YYDEBUG(1467, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
@@ -22236,13 +22300,13 @@ yy1465:
 			if (yych <= 'Z') goto yy143;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1466;
+			if (yych <= 'a') goto yy1468;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1466:
-	YYDEBUG(1466, *YYCURSOR);
+yy1468:
+	YYDEBUG(1468, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'Y') {
 		if (yych <= ')') {
@@ -22251,7 +22315,7 @@ yy1466:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy144;
-			goto yy1233;
+			goto yy1235;
 		}
 	} else {
 		if (yych <= 'x') {
@@ -22259,13 +22323,13 @@ yy1466:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'y') goto yy1233;
+			if (yych <= 'y') goto yy1235;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1467:
-	YYDEBUG(1467, *YYCURSOR);
+yy1469:
+	YYDEBUG(1469, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -22281,13 +22345,13 @@ yy1467:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'n') goto yy1468;
+			if (yych <= 'n') goto yy1470;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1468:
-	YYDEBUG(1468, *YYCURSOR);
+yy1470:
+	YYDEBUG(1470, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'I') {
 		if (yych <= ')') {
@@ -22303,13 +22367,13 @@ yy1468:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'i') goto yy1469;
+			if (yych <= 'i') goto yy1471;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1469:
-	YYDEBUG(1469, *YYCURSOR);
+yy1471:
+	YYDEBUG(1471, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'G') {
 		if (yych <= ')') {
@@ -22325,33 +22389,33 @@ yy1469:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'g') goto yy1470;
+			if (yych <= 'g') goto yy1472;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1470:
-	YYDEBUG(1470, *YYCURSOR);
+yy1472:
+	YYDEBUG(1472, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'G') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'H') goto yy1471;
+		if (yych <= 'H') goto yy1473;
 		if (yych != 'h') goto yy3;
 	}
-yy1471:
-	YYDEBUG(1471, *YYCURSOR);
+yy1473:
+	YYDEBUG(1473, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'T') goto yy1472;
+	if (yych == 'T') goto yy1474;
 	if (yych != 't') goto yy56;
-yy1472:
-	YYDEBUG(1472, *YYCURSOR);
+yy1474:
+	YYDEBUG(1474, *YYCURSOR);
 	yych = *++YYCURSOR;
-	goto yy1418;
-yy1473:
-	YYDEBUG(1473, *YYCURSOR);
+	goto yy1420;
+yy1475:
+	YYDEBUG(1475, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -22379,7 +22443,7 @@ yy1473:
 				if (yych <= '9') goto yy196;
 				goto yy194;
 			} else {
-				if (yych == 'C') goto yy1475;
+				if (yych == 'C') goto yy1477;
 				goto yy142;
 			}
 		} else {
@@ -22387,14 +22451,14 @@ yy1473:
 				if (yych <= '`') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'c') goto yy1475;
+				if (yych <= 'c') goto yy1477;
 				if (yych <= 'z') goto yy142;
 				goto yy194;
 			}
 		}
 	}
-yy1474:
-	YYDEBUG(1474, *YYCURSOR);
+yy1476:
+	YYDEBUG(1476, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '-') {
@@ -22419,8 +22483,8 @@ yy1474:
 			goto yy194;
 		}
 	}
-yy1475:
-	YYDEBUG(1475, *YYCURSOR);
+yy1477:
+	YYDEBUG(1477, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -22442,8 +22506,8 @@ yy1475:
 			goto yy3;
 		}
 	}
-yy1476:
-	YYDEBUG(1476, *YYCURSOR);
+yy1478:
+	YYDEBUG(1478, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -22456,9 +22520,9 @@ yy1476:
 				if (yych <= '@') goto yy3;
 				goto yy141;
 			} else {
-				if (yych <= 'R') goto yy1473;
+				if (yych <= 'R') goto yy1475;
 				if (yych <= 'X') goto yy141;
-				goto yy1474;
+				goto yy1476;
 			}
 		}
 	} else {
@@ -22473,17 +22537,17 @@ yy1476:
 			}
 		} else {
 			if (yych <= 'x') {
-				if (yych <= 'r') goto yy1488;
+				if (yych <= 'r') goto yy1490;
 				goto yy146;
 			} else {
-				if (yych <= 'y') goto yy1489;
+				if (yych <= 'y') goto yy1491;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1477:
-	YYDEBUG(1477, *YYCURSOR);
+yy1479:
+	YYDEBUG(1479, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -22494,7 +22558,7 @@ yy1477:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy141;
-			goto yy1467;
+			goto yy1469;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22502,13 +22566,13 @@ yy1477:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1482;
+			if (yych == 'd') goto yy1484;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1478:
-	YYDEBUG(1478, *YYCURSOR);
+yy1480:
+	YYDEBUG(1480, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -22519,7 +22583,7 @@ yy1478:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy141;
-			goto yy1464;
+			goto yy1466;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22527,13 +22591,13 @@ yy1478:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1479;
+			if (yych == 'n') goto yy1481;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1479:
-	YYDEBUG(1479, *YYCURSOR);
+yy1481:
+	YYDEBUG(1481, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -22544,7 +22608,7 @@ yy1479:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'C') goto yy142;
-			goto yy1465;
+			goto yy1467;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22552,13 +22616,13 @@ yy1479:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 'd') goto yy1480;
+			if (yych == 'd') goto yy1482;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1480:
-	YYDEBUG(1480, *YYCURSOR);
+yy1482:
+	YYDEBUG(1482, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -22568,7 +22632,7 @@ yy1480:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1466;
+			goto yy1468;
 		}
 	} else {
 		if (yych <= '_') {
@@ -22577,13 +22641,13 @@ yy1480:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1481;
+			if (yych <= 'a') goto yy1483;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1481:
-	YYDEBUG(1481, *YYCURSOR);
+yy1483:
+	YYDEBUG(1483, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -22594,7 +22658,7 @@ yy1481:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy144;
-			goto yy1233;
+			goto yy1235;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22602,13 +22666,13 @@ yy1481:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'y') goto yy1262;
+			if (yych == 'y') goto yy1264;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1482:
-	YYDEBUG(1482, *YYCURSOR);
+yy1484:
+	YYDEBUG(1484, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -22619,7 +22683,7 @@ yy1482:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy142;
-			goto yy1468;
+			goto yy1470;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22627,13 +22691,13 @@ yy1482:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1483;
+			if (yych == 'n') goto yy1485;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1483:
-	YYDEBUG(1483, *YYCURSOR);
+yy1485:
+	YYDEBUG(1485, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'I') {
@@ -22644,7 +22708,7 @@ yy1483:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'H') goto yy143;
-			goto yy1469;
+			goto yy1471;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22652,13 +22716,13 @@ yy1483:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'i') goto yy1484;
+			if (yych == 'i') goto yy1486;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1484:
-	YYDEBUG(1484, *YYCURSOR);
+yy1486:
+	YYDEBUG(1486, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'G') {
@@ -22669,7 +22733,7 @@ yy1484:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'F') goto yy144;
-			goto yy1470;
+			goto yy1472;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22677,13 +22741,13 @@ yy1484:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'g') goto yy1485;
+			if (yych == 'g') goto yy1487;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1485:
-	YYDEBUG(1485, *YYCURSOR);
+yy1487:
+	YYDEBUG(1487, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -22693,37 +22757,37 @@ yy1485:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'G') goto yy3;
-			goto yy1471;
+			goto yy1473;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1486;
+			if (yych == 'h') goto yy1488;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1486:
-	YYDEBUG(1486, *YYCURSOR);
+yy1488:
+	YYDEBUG(1488, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'T') goto yy1472;
+	if (yych == 'T') goto yy1474;
 	if (yych != 't') goto yy155;
-	YYDEBUG(1487, *YYCURSOR);
+	YYDEBUG(1489, *YYCURSOR);
 	yyaccept = 31;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '^') {
 		if (yych == '/') goto yy147;
-		goto yy1418;
+		goto yy1420;
 	} else {
 		if (yych <= '_') goto yy147;
-		if (yych <= '`') goto yy1418;
+		if (yych <= '`') goto yy1420;
 		if (yych <= 'z') goto yy154;
-		goto yy1418;
+		goto yy1420;
 	}
-yy1488:
-	YYDEBUG(1488, *YYCURSOR);
+yy1490:
+	YYDEBUG(1490, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '9') {
@@ -22751,7 +22815,7 @@ yy1488:
 				if (yych <= '@') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'C') goto yy1475;
+				if (yych <= 'C') goto yy1477;
 				if (yych <= 'Z') goto yy142;
 				goto yy194;
 			}
@@ -22761,14 +22825,14 @@ yy1488:
 				if (yych <= '`') goto yy194;
 				goto yy151;
 			} else {
-				if (yych <= 'c') goto yy1490;
+				if (yych <= 'c') goto yy1492;
 				if (yych <= 'z') goto yy151;
 				goto yy194;
 			}
 		}
 	}
-yy1489:
-	YYDEBUG(1489, *YYCURSOR);
+yy1491:
+	YYDEBUG(1491, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '.') {
@@ -22803,8 +22867,8 @@ yy1489:
 			}
 		}
 	}
-yy1490:
-	YYDEBUG(1490, *YYCURSOR);
+yy1492:
+	YYDEBUG(1492, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -22828,8 +22892,8 @@ yy1490:
 			goto yy3;
 		}
 	}
-yy1491:
-	YYDEBUG(1491, *YYCURSOR);
+yy1493:
+	YYDEBUG(1493, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'W') {
 		if (yych <= 'N') {
@@ -22837,30 +22901,30 @@ yy1491:
 			if (yych <= '@') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'O') goto yy1499;
+			if (yych <= 'O') goto yy1501;
 			if (yych <= 'U') goto yy141;
-			if (yych <= 'V') goto yy1500;
-			goto yy1497;
+			if (yych <= 'V') goto yy1502;
+			goto yy1499;
 		}
 	} else {
 		if (yych <= 'o') {
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'n') goto yy141;
-			goto yy1499;
+			goto yy1501;
 		} else {
 			if (yych <= 'v') {
 				if (yych <= 'u') goto yy141;
-				goto yy1500;
+				goto yy1502;
 			} else {
-				if (yych <= 'w') goto yy1497;
+				if (yych <= 'w') goto yy1499;
 				if (yych <= 'z') goto yy141;
 				goto yy3;
 			}
 		}
 	}
-yy1492:
-	YYDEBUG(1492, *YYCURSOR);
+yy1494:
+	YYDEBUG(1494, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'X') {
 		if (yych <= ')') {
@@ -22869,7 +22933,7 @@ yy1492:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'W') goto yy141;
-			goto yy1496;
+			goto yy1498;
 		}
 	} else {
 		if (yych <= 'w') {
@@ -22877,13 +22941,13 @@ yy1492:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'x') goto yy1496;
+			if (yych <= 'x') goto yy1498;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1493:
-	YYDEBUG(1493, *YYCURSOR);
+yy1495:
+	YYDEBUG(1495, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -22899,13 +22963,13 @@ yy1493:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'n') goto yy1494;
+			if (yych <= 'n') goto yy1496;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1494:
-	YYDEBUG(1494, *YYCURSOR);
+yy1496:
+	YYDEBUG(1496, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -22921,13 +22985,13 @@ yy1494:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1495;
+			if (yych <= 't') goto yy1497;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1495:
-	YYDEBUG(1495, *YYCURSOR);
+yy1497:
+	YYDEBUG(1497, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -22936,7 +23000,7 @@ yy1495:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= 'g') {
@@ -22944,13 +23008,13 @@ yy1495:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'h') goto yy1214;
+			if (yych <= 'h') goto yy1238;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1496:
-	YYDEBUG(1496, *YYCURSOR);
+yy1498:
+	YYDEBUG(1498, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -22959,7 +23023,7 @@ yy1496:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1426;
+			goto yy1428;
 		}
 	} else {
 		if (yych <= 's') {
@@ -22967,23 +23031,23 @@ yy1496:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1426;
+			if (yych <= 't') goto yy1428;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1497:
-	YYDEBUG(1497, *YYCURSOR);
+yy1499:
+	YYDEBUG(1499, *YYCURSOR);
 	++YYCURSOR;
 	if ((yych = *YYCURSOR) <= '@') {
 		if (yych == ')') goto yy139;
 	} else {
 		if (yych <= 'Z') goto yy142;
-		if (yych <= '`') goto yy1498;
+		if (yych <= '`') goto yy1500;
 		if (yych <= 'z') goto yy142;
 	}
-yy1498:
-	YYDEBUG(1498, *YYCURSOR);
+yy1500:
+	YYDEBUG(1500, *YYCURSOR);
 	{
 		DEBUG_OUTPUT("now");
 		TIMELIB_INIT;
@@ -22991,8 +23055,8 @@ yy1498:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-yy1499:
-	YYDEBUG(1499, *YYCURSOR);
+yy1501:
+	YYDEBUG(1501, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -23001,7 +23065,7 @@ yy1499:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy142;
-			goto yy1505;
+			goto yy1507;
 		}
 	} else {
 		if (yych <= 'm') {
@@ -23009,13 +23073,13 @@ yy1499:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'n') goto yy1505;
+			if (yych <= 'n') goto yy1507;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1500:
-	YYDEBUG(1500, *YYCURSOR);
+yy1502:
+	YYDEBUG(1502, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -23050,14 +23114,14 @@ yy1500:
 				if (yych <= '`') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'e') goto yy1501;
+				if (yych <= 'e') goto yy1503;
 				if (yych <= 'z') goto yy142;
 				goto yy194;
 			}
 		}
 	}
-yy1501:
-	YYDEBUG(1501, *YYCURSOR);
+yy1503:
+	YYDEBUG(1503, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'M') {
 		if (yych <= ')') {
@@ -23073,13 +23137,13 @@ yy1501:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'm') goto yy1502;
+			if (yych <= 'm') goto yy1504;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1502:
-	YYDEBUG(1502, *YYCURSOR);
+yy1504:
+	YYDEBUG(1504, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'B') {
 		if (yych <= ')') {
@@ -23095,40 +23159,40 @@ yy1502:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'b') goto yy1503;
+			if (yych <= 'b') goto yy1505;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1503:
-	YYDEBUG(1503, *YYCURSOR);
+yy1505:
+	YYDEBUG(1505, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'E') goto yy1504;
+		if (yych <= 'E') goto yy1506;
 		if (yych != 'e') goto yy3;
 	}
-yy1504:
-	YYDEBUG(1504, *YYCURSOR);
+yy1506:
+	YYDEBUG(1506, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'R') goto yy206;
 	if (yych == 'r') goto yy206;
 	goto yy56;
-yy1505:
-	YYDEBUG(1505, *YYCURSOR);
+yy1507:
+	YYDEBUG(1507, *YYCURSOR);
 	++YYCURSOR;
 	if ((yych = *YYCURSOR) <= '@') {
 		if (yych == ')') goto yy139;
 	} else {
 		if (yych <= 'Z') goto yy143;
-		if (yych <= '`') goto yy1506;
+		if (yych <= '`') goto yy1508;
 		if (yych <= 'z') goto yy143;
 	}
-yy1506:
-	YYDEBUG(1506, *YYCURSOR);
+yy1508:
+	YYDEBUG(1508, *YYCURSOR);
 	{
 		DEBUG_OUTPUT("noon");
 		TIMELIB_INIT;
@@ -23139,8 +23203,8 @@ yy1506:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-yy1507:
-	YYDEBUG(1507, *YYCURSOR);
+yy1509:
+	YYDEBUG(1509, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'W') {
@@ -23155,11 +23219,11 @@ yy1507:
 		} else {
 			if (yych <= 'O') {
 				if (yych <= 'N') goto yy141;
-				goto yy1499;
+				goto yy1501;
 			} else {
 				if (yych <= 'U') goto yy141;
-				if (yych <= 'V') goto yy1500;
-				goto yy1497;
+				if (yych <= 'V') goto yy1502;
+				goto yy1499;
 			}
 		}
 	} else {
@@ -23174,18 +23238,18 @@ yy1507:
 			}
 		} else {
 			if (yych <= 'v') {
-				if (yych <= 'o') goto yy1514;
+				if (yych <= 'o') goto yy1516;
 				if (yych <= 'u') goto yy146;
-				goto yy1515;
+				goto yy1517;
 			} else {
-				if (yych <= 'w') goto yy1513;
+				if (yych <= 'w') goto yy1515;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1508:
-	YYDEBUG(1508, *YYCURSOR);
+yy1510:
+	YYDEBUG(1510, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'X') {
@@ -23196,7 +23260,7 @@ yy1508:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'W') goto yy141;
-			goto yy1496;
+			goto yy1498;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23204,13 +23268,13 @@ yy1508:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'x') goto yy1512;
+			if (yych == 'x') goto yy1514;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1509:
-	YYDEBUG(1509, *YYCURSOR);
+yy1511:
+	YYDEBUG(1511, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -23221,7 +23285,7 @@ yy1509:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy141;
-			goto yy1494;
+			goto yy1496;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23229,13 +23293,13 @@ yy1509:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1510;
+			if (yych == 'n') goto yy1512;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1510:
-	YYDEBUG(1510, *YYCURSOR);
+yy1512:
+	YYDEBUG(1512, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -23246,7 +23310,7 @@ yy1510:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1495;
+			goto yy1497;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23254,13 +23318,13 @@ yy1510:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1511;
+			if (yych == 't') goto yy1513;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1511:
-	YYDEBUG(1511, *YYCURSOR);
+yy1513:
+	YYDEBUG(1513, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -23271,7 +23335,7 @@ yy1511:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23279,13 +23343,13 @@ yy1511:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1225;
+			if (yych == 'h') goto yy1267;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1512:
-	YYDEBUG(1512, *YYCURSOR);
+yy1514:
+	YYDEBUG(1514, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -23296,7 +23360,7 @@ yy1512:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1426;
+			goto yy1428;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23304,36 +23368,36 @@ yy1512:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1458;
+			if (yych == 't') goto yy1460;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1513:
-	YYDEBUG(1513, *YYCURSOR);
+yy1515:
+	YYDEBUG(1515, *YYCURSOR);
 	yyaccept = 32;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '@') {
 		if (yych <= ')') {
-			if (yych <= '(') goto yy1498;
+			if (yych <= '(') goto yy1500;
 			goto yy139;
 		} else {
 			if (yych == '/') goto yy147;
-			goto yy1498;
+			goto yy1500;
 		}
 	} else {
 		if (yych <= '_') {
 			if (yych <= 'Z') goto yy142;
-			if (yych <= '^') goto yy1498;
+			if (yych <= '^') goto yy1500;
 			goto yy147;
 		} else {
-			if (yych <= '`') goto yy1498;
+			if (yych <= '`') goto yy1500;
 			if (yych <= 'z') goto yy151;
-			goto yy1498;
+			goto yy1500;
 		}
 	}
-yy1514:
-	YYDEBUG(1514, *YYCURSOR);
+yy1516:
+	YYDEBUG(1516, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -23344,7 +23408,7 @@ yy1514:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy142;
-			goto yy1505;
+			goto yy1507;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23352,13 +23416,13 @@ yy1514:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1520;
+			if (yych == 'n') goto yy1522;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1515:
-	YYDEBUG(1515, *YYCURSOR);
+yy1517:
+	YYDEBUG(1517, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '9') {
@@ -23386,7 +23450,7 @@ yy1515:
 				if (yych <= '@') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'E') goto yy1501;
+				if (yych <= 'E') goto yy1503;
 				if (yych <= 'Z') goto yy142;
 				goto yy194;
 			}
@@ -23396,14 +23460,14 @@ yy1515:
 				if (yych <= '`') goto yy194;
 				goto yy151;
 			} else {
-				if (yych <= 'e') goto yy1516;
+				if (yych <= 'e') goto yy1518;
 				if (yych <= 'z') goto yy151;
 				goto yy194;
 			}
 		}
 	}
-yy1516:
-	YYDEBUG(1516, *YYCURSOR);
+yy1518:
+	YYDEBUG(1518, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'M') {
@@ -23414,7 +23478,7 @@ yy1516:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'L') goto yy143;
-			goto yy1502;
+			goto yy1504;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23422,13 +23486,13 @@ yy1516:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'm') goto yy1517;
+			if (yych == 'm') goto yy1519;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1517:
-	YYDEBUG(1517, *YYCURSOR);
+yy1519:
+	YYDEBUG(1519, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'B') {
@@ -23439,7 +23503,7 @@ yy1517:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'A') goto yy144;
-			goto yy1503;
+			goto yy1505;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23447,13 +23511,13 @@ yy1517:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'b') goto yy1518;
+			if (yych == 'b') goto yy1520;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1518:
-	YYDEBUG(1518, *YYCURSOR);
+yy1520:
+	YYDEBUG(1520, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -23463,49 +23527,49 @@ yy1518:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'D') goto yy3;
-			goto yy1504;
+			goto yy1506;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1519;
+			if (yych == 'e') goto yy1521;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1519:
-	YYDEBUG(1519, *YYCURSOR);
+yy1521:
+	YYDEBUG(1521, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'R') goto yy206;
 	if (yych == 'r') goto yy377;
 	goto yy155;
-yy1520:
-	YYDEBUG(1520, *YYCURSOR);
+yy1522:
+	YYDEBUG(1522, *YYCURSOR);
 	yyaccept = 33;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '@') {
 		if (yych <= ')') {
-			if (yych <= '(') goto yy1506;
+			if (yych <= '(') goto yy1508;
 			goto yy139;
 		} else {
 			if (yych == '/') goto yy147;
-			goto yy1506;
+			goto yy1508;
 		}
 	} else {
 		if (yych <= '_') {
 			if (yych <= 'Z') goto yy143;
-			if (yych <= '^') goto yy1506;
+			if (yych <= '^') goto yy1508;
 			goto yy147;
 		} else {
-			if (yych <= '`') goto yy1506;
+			if (yych <= '`') goto yy1508;
 			if (yych <= 'z') goto yy152;
-			goto yy1506;
+			goto yy1508;
 		}
 	}
-yy1521:
-	YYDEBUG(1521, *YYCURSOR);
+yy1523:
+	YYDEBUG(1523, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= ')') {
@@ -23521,13 +23585,13 @@ yy1521:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 's') goto yy1522;
+			if (yych <= 's') goto yy1524;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1522:
-	YYDEBUG(1522, *YYCURSOR);
+yy1524:
+	YYDEBUG(1524, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -23543,13 +23607,13 @@ yy1522:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1523;
+			if (yych <= 't') goto yy1525;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1523:
-	YYDEBUG(1523, *YYCURSOR);
+yy1525:
+	YYDEBUG(1525, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'E') {
 		if (yych <= ')') {
@@ -23565,13 +23629,13 @@ yy1523:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'e') goto yy1524;
+			if (yych <= 'e') goto yy1526;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1524:
-	YYDEBUG(1524, *YYCURSOR);
+yy1526:
+	YYDEBUG(1526, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -23587,37 +23651,37 @@ yy1524:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'r') goto yy1525;
+			if (yych <= 'r') goto yy1527;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1525:
-	YYDEBUG(1525, *YYCURSOR);
+yy1527:
+	YYDEBUG(1527, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'C') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'D') goto yy1526;
+		if (yych <= 'D') goto yy1528;
 		if (yych != 'd') goto yy3;
 	}
-yy1526:
-	YYDEBUG(1526, *YYCURSOR);
+yy1528:
+	YYDEBUG(1528, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'A') goto yy1527;
+	if (yych == 'A') goto yy1529;
 	if (yych != 'a') goto yy56;
-yy1527:
-	YYDEBUG(1527, *YYCURSOR);
+yy1529:
+	YYDEBUG(1529, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'Y') goto yy1528;
+	if (yych == 'Y') goto yy1530;
 	if (yych != 'y') goto yy56;
-yy1528:
-	YYDEBUG(1528, *YYCURSOR);
+yy1530:
+	YYDEBUG(1530, *YYCURSOR);
 	++YYCURSOR;
-yy1529:
-	YYDEBUG(1529, *YYCURSOR);
+yy1531:
+	YYDEBUG(1531, *YYCURSOR);
 	{
 		DEBUG_OUTPUT("yesterday");
 		TIMELIB_INIT;
@@ -23628,8 +23692,8 @@ yy1529:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-yy1530:
-	YYDEBUG(1530, *YYCURSOR);
+yy1532:
+	YYDEBUG(1532, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -23640,7 +23704,7 @@ yy1530:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'R') goto yy141;
-			goto yy1522;
+			goto yy1524;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23648,13 +23712,13 @@ yy1530:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 's') goto yy1531;
+			if (yych == 's') goto yy1533;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1531:
-	YYDEBUG(1531, *YYCURSOR);
+yy1533:
+	YYDEBUG(1533, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -23665,7 +23729,7 @@ yy1531:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1523;
+			goto yy1525;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23673,13 +23737,13 @@ yy1531:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1532;
+			if (yych == 't') goto yy1534;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1532:
-	YYDEBUG(1532, *YYCURSOR);
+yy1534:
+	YYDEBUG(1534, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -23690,7 +23754,7 @@ yy1532:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy143;
-			goto yy1524;
+			goto yy1526;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23698,13 +23762,13 @@ yy1532:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1533;
+			if (yych == 'e') goto yy1535;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1533:
-	YYDEBUG(1533, *YYCURSOR);
+yy1535:
+	YYDEBUG(1535, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -23715,7 +23779,7 @@ yy1533:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy144;
-			goto yy1525;
+			goto yy1527;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23723,13 +23787,13 @@ yy1533:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1534;
+			if (yych == 'r') goto yy1536;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1534:
-	YYDEBUG(1534, *YYCURSOR);
+yy1536:
+	YYDEBUG(1536, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -23739,38 +23803,38 @@ yy1534:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'C') goto yy3;
-			goto yy1526;
+			goto yy1528;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1535;
+			if (yych == 'd') goto yy1537;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1535:
-	YYDEBUG(1535, *YYCURSOR);
+yy1537:
+	YYDEBUG(1537, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'A') goto yy1527;
+	if (yych == 'A') goto yy1529;
 	if (yych != 'a') goto yy155;
-	YYDEBUG(1536, *YYCURSOR);
+	YYDEBUG(1538, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'Y') goto yy1528;
+	if (yych == 'Y') goto yy1530;
 	if (yych != 'y') goto yy155;
-	YYDEBUG(1537, *YYCURSOR);
+	YYDEBUG(1539, *YYCURSOR);
 	yyaccept = 34;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '^') {
 		if (yych == '/') goto yy147;
-		goto yy1529;
+		goto yy1531;
 	} else {
 		if (yych <= '_') goto yy147;
-		if (yych <= '`') goto yy1529;
+		if (yych <= '`') goto yy1531;
 		if (yych <= 'z') goto yy154;
-		goto yy1529;
+		goto yy1531;
 	}
 }
 
@@ -23988,7 +24052,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 					add_pbf_error(s, "A two digit second could not be found", string, begin);
 				}
 				break;
-			case 'u': /* six digit millisecond */
+			case 'u': /* up to six digit millisecond */
 				{
 					double f;
 					char *tptr;
diff --git a/ext/date/lib/parse_date.c.orig b/ext/date/lib/parse_date.c.orig
index f1aa470..04dd383 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 Wed Jul 29 16:20:12 2009 */
+/* Generated by re2c 0.13.5 on Wed Feb 10 15:19:23 2010 */
 #line 1 "ext/date/lib/parse_date.re"
 /*
    +----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_date.c 286515 2009-07-29 15:34:59Z derick $ */
+/* $Id: parse_date.c 294880 2010-02-11 11:11:47Z pajoye $ */
 
 #include "timelib.h"
 
@@ -238,6 +238,7 @@ static timelib_lookup_table const timelib_reltext_lookup[] = {
 	{ "sixth",    0,  6 },
 	{ "seventh",  0,  7 },
 	{ "eight",    0,  8 },
+	{ "eighth",   0,  8 },
 	{ "ninth",    0,  9 },
 	{ "tenth",    0, 10 },
 	{ "eleventh", 0, 11 },
@@ -839,11 +840,11 @@ static int scan(Scanner *s)
 std:
 	s->tok = cursor;
 	s->len = 0;
-#line 965 "ext/date/lib/parse_date.re"
+#line 966 "ext/date/lib/parse_date.re"
 
 
 
-#line 847 "ext/date/lib/parse_date.c"
+#line 848 "ext/date/lib/parse_date.c"
 {
 	YYCTYPE yych;
 	unsigned int yyaccept = 0;
@@ -970,20 +971,20 @@ yy2:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy140;
-			goto yy1521;
+			goto yy1523;
 		}
 	} else {
 		if (yych <= 'd') {
 			if (yych <= 'Z') goto yy140;
 			if (yych >= 'a') goto yy145;
 		} else {
-			if (yych <= 'e') goto yy1530;
+			if (yych <= 'e') goto yy1532;
 			if (yych <= 'z') goto yy145;
 		}
 	}
 yy3:
 	YYDEBUG(3, *YYCURSOR);
-#line 1632 "ext/date/lib/parse_date.re"
+#line 1633 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("tzcorrection | tz");
@@ -996,7 +997,7 @@ yy3:
 		TIMELIB_DEINIT;
 		return TIMELIB_TIMEZONE;
 	}
-#line 1000 "ext/date/lib/parse_date.c"
+#line 1001 "ext/date/lib/parse_date.c"
 yy4:
 	YYDEBUG(4, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -1007,7 +1008,7 @@ yy4:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy140;
-			goto yy1521;
+			goto yy1523;
 		}
 	} else {
 		if (yych <= 'd') {
@@ -1015,7 +1016,7 @@ yy4:
 			if (yych <= '`') goto yy3;
 			goto yy140;
 		} else {
-			if (yych <= 'e') goto yy1521;
+			if (yych <= 'e') goto yy1523;
 			if (yych <= 'z') goto yy140;
 			goto yy3;
 		}
@@ -1030,12 +1031,12 @@ yy5:
 			goto yy140;
 		} else {
 			if (yych <= 'H') {
-				if (yych <= 'E') goto yy1492;
+				if (yych <= 'E') goto yy1494;
 				goto yy140;
 			} else {
-				if (yych <= 'I') goto yy1493;
+				if (yych <= 'I') goto yy1495;
 				if (yych <= 'N') goto yy140;
-				goto yy1491;
+				goto yy1493;
 			}
 		}
 	} else {
@@ -1044,15 +1045,15 @@ yy5:
 				if (yych <= 'Z') goto yy140;
 				goto yy3;
 			} else {
-				if (yych == 'e') goto yy1508;
+				if (yych == 'e') goto yy1510;
 				goto yy145;
 			}
 		} else {
 			if (yych <= 'n') {
-				if (yych <= 'i') goto yy1509;
+				if (yych <= 'i') goto yy1511;
 				goto yy145;
 			} else {
-				if (yych <= 'o') goto yy1507;
+				if (yych <= 'o') goto yy1509;
 				if (yych <= 'z') goto yy145;
 				goto yy3;
 			}
@@ -1068,12 +1069,12 @@ yy6:
 			goto yy140;
 		} else {
 			if (yych <= 'H') {
-				if (yych <= 'E') goto yy1492;
+				if (yych <= 'E') goto yy1494;
 				goto yy140;
 			} else {
-				if (yych <= 'I') goto yy1493;
+				if (yych <= 'I') goto yy1495;
 				if (yych <= 'N') goto yy140;
-				goto yy1491;
+				goto yy1493;
 			}
 		}
 	} else {
@@ -1082,15 +1083,15 @@ yy6:
 				if (yych <= 'Z') goto yy140;
 				goto yy3;
 			} else {
-				if (yych == 'e') goto yy1492;
+				if (yych == 'e') goto yy1494;
 				goto yy140;
 			}
 		} else {
 			if (yych <= 'n') {
-				if (yych <= 'i') goto yy1493;
+				if (yych <= 'i') goto yy1495;
 				goto yy140;
 			} else {
-				if (yych <= 'o') goto yy1491;
+				if (yych <= 'o') goto yy1493;
 				if (yych <= 'z') goto yy140;
 				goto yy3;
 			}
@@ -1103,24 +1104,24 @@ yy7:
 		if (yych <= 'A') {
 			if (yych == ')') goto yy139;
 			if (yych <= '@') goto yy3;
-			goto yy1461;
+			goto yy1463;
 		} else {
-			if (yych == 'I') goto yy1462;
+			if (yych == 'I') goto yy1464;
 			if (yych <= 'N') goto yy140;
-			goto yy1463;
+			goto yy1465;
 		}
 	} else {
 		if (yych <= 'h') {
 			if (yych <= 'Z') goto yy140;
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1476;
+			if (yych <= 'a') goto yy1478;
 			goto yy145;
 		} else {
 			if (yych <= 'n') {
-				if (yych <= 'i') goto yy1477;
+				if (yych <= 'i') goto yy1479;
 				goto yy145;
 			} else {
-				if (yych <= 'o') goto yy1478;
+				if (yych <= 'o') goto yy1480;
 				if (yych <= 'z') goto yy145;
 				goto yy3;
 			}
@@ -1133,24 +1134,24 @@ yy8:
 		if (yych <= 'A') {
 			if (yych == ')') goto yy139;
 			if (yych <= '@') goto yy3;
-			goto yy1461;
+			goto yy1463;
 		} else {
-			if (yych == 'I') goto yy1462;
+			if (yych == 'I') goto yy1464;
 			if (yych <= 'N') goto yy140;
-			goto yy1463;
+			goto yy1465;
 		}
 	} else {
 		if (yych <= 'h') {
 			if (yych <= 'Z') goto yy140;
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1461;
+			if (yych <= 'a') goto yy1463;
 			goto yy140;
 		} else {
 			if (yych <= 'n') {
-				if (yych <= 'i') goto yy1462;
+				if (yych <= 'i') goto yy1464;
 				goto yy140;
 			} else {
-				if (yych <= 'o') goto yy1463;
+				if (yych <= 'o') goto yy1465;
 				if (yych <= 'z') goto yy140;
 				goto yy3;
 			}
@@ -1164,15 +1165,15 @@ yy9:
 	switch (yych) {
 	case ')':	goto yy139;
 	case '0':
-	case '1':	goto yy1391;
-	case '2':	goto yy1392;
+	case '1':	goto yy1393;
+	case '2':	goto yy1394;
 	case '3':
 	case '4':
 	case '5':
 	case '6':
 	case '7':
 	case '8':
-	case '9':	goto yy1393;
+	case '9':	goto yy1395;
 	case 'A':
 	case 'B':
 	case 'C':
@@ -1194,11 +1195,11 @@ yy9:
 	case 'X':
 	case 'Y':
 	case 'Z':	goto yy140;
-	case 'E':	goto yy1386;
-	case 'H':	goto yy1387;
-	case 'O':	goto yy1388;
-	case 'U':	goto yy1389;
-	case 'W':	goto yy1390;
+	case 'E':	goto yy1388;
+	case 'H':	goto yy1389;
+	case 'O':	goto yy1390;
+	case 'U':	goto yy1391;
+	case 'W':	goto yy1392;
 	case 'a':
 	case 'b':
 	case 'c':
@@ -1220,11 +1221,11 @@ yy9:
 	case 'x':
 	case 'y':
 	case 'z':	goto yy145;
-	case 'e':	goto yy1429;
-	case 'h':	goto yy1430;
-	case 'o':	goto yy1431;
-	case 'u':	goto yy1432;
-	case 'w':	goto yy1433;
+	case 'e':	goto yy1431;
+	case 'h':	goto yy1432;
+	case 'o':	goto yy1433;
+	case 'u':	goto yy1434;
+	case 'w':	goto yy1435;
 	default:	goto yy3;
 	}
 yy10:
@@ -1235,15 +1236,15 @@ yy10:
 	switch (yych) {
 	case ')':	goto yy139;
 	case '0':
-	case '1':	goto yy1391;
-	case '2':	goto yy1392;
+	case '1':	goto yy1393;
+	case '2':	goto yy1394;
 	case '3':
 	case '4':
 	case '5':
 	case '6':
 	case '7':
 	case '8':
-	case '9':	goto yy1393;
+	case '9':	goto yy1395;
 	case 'A':
 	case 'B':
 	case 'C':
@@ -1287,32 +1288,32 @@ yy10:
 	case 'y':
 	case 'z':	goto yy140;
 	case 'E':
-	case 'e':	goto yy1386;
+	case 'e':	goto yy1388;
 	case 'H':
-	case 'h':	goto yy1387;
+	case 'h':	goto yy1389;
 	case 'O':
-	case 'o':	goto yy1388;
+	case 'o':	goto yy1390;
 	case 'U':
-	case 'u':	goto yy1389;
+	case 'u':	goto yy1391;
 	case 'W':
-	case 'w':	goto yy1390;
+	case 'w':	goto yy1392;
 	default:	goto yy3;
 	}
 yy11:
 	YYDEBUG(11, *YYCURSOR);
 	yyaccept = 1;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych == '-') goto yy1382;
+	if (yych == '-') goto yy1384;
 	if (yych <= '/') goto yy12;
-	if (yych <= '9') goto yy1383;
+	if (yych <= '9') goto yy1385;
 yy12:
 	YYDEBUG(12, *YYCURSOR);
-#line 1727 "ext/date/lib/parse_date.re"
+#line 1728 "ext/date/lib/parse_date.re"
 	{
 		add_error(s, "Unexpected character");
 		goto std;
 	}
-#line 1316 "ext/date/lib/parse_date.c"
+#line 1317 "ext/date/lib/parse_date.c"
 yy13:
 	YYDEBUG(13, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -1324,16 +1325,16 @@ yy13:
 			} else {
 				if (yych <= '@') goto yy3;
 				if (yych <= 'D') goto yy140;
-				goto yy1318;
+				goto yy1320;
 			}
 		} else {
 			if (yych <= 'N') {
-				if (yych == 'I') goto yy1319;
+				if (yych == 'I') goto yy1321;
 				goto yy140;
 			} else {
-				if (yych <= 'O') goto yy1320;
+				if (yych <= 'O') goto yy1322;
 				if (yych <= 'Q') goto yy140;
-				goto yy1321;
+				goto yy1323;
 			}
 		}
 	} else {
@@ -1343,16 +1344,16 @@ yy13:
 				if (yych <= '`') goto yy3;
 				goto yy145;
 			} else {
-				if (yych <= 'e') goto yy1359;
+				if (yych <= 'e') goto yy1361;
 				if (yych <= 'h') goto yy145;
-				goto yy1360;
+				goto yy1362;
 			}
 		} else {
 			if (yych <= 'q') {
-				if (yych == 'o') goto yy1361;
+				if (yych == 'o') goto yy1363;
 				goto yy145;
 			} else {
-				if (yych <= 'r') goto yy1362;
+				if (yych <= 'r') goto yy1364;
 				if (yych <= 'z') goto yy145;
 				goto yy3;
 			}
@@ -1369,16 +1370,16 @@ yy14:
 			} else {
 				if (yych <= '@') goto yy3;
 				if (yych <= 'D') goto yy140;
-				goto yy1318;
+				goto yy1320;
 			}
 		} else {
 			if (yych <= 'N') {
-				if (yych == 'I') goto yy1319;
+				if (yych == 'I') goto yy1321;
 				goto yy140;
 			} else {
-				if (yych <= 'O') goto yy1320;
+				if (yych <= 'O') goto yy1322;
 				if (yych <= 'Q') goto yy140;
-				goto yy1321;
+				goto yy1323;
 			}
 		}
 	} else {
@@ -1388,16 +1389,16 @@ yy14:
 				if (yych <= '`') goto yy3;
 				goto yy140;
 			} else {
-				if (yych <= 'e') goto yy1318;
+				if (yych <= 'e') goto yy1320;
 				if (yych <= 'h') goto yy140;
-				goto yy1319;
+				goto yy1321;
 			}
 		} else {
 			if (yych <= 'q') {
-				if (yych == 'o') goto yy1320;
+				if (yych == 'o') goto yy1322;
 				goto yy140;
 			} else {
-				if (yych <= 'r') goto yy1321;
+				if (yych <= 'r') goto yy1323;
 				if (yych <= 'z') goto yy140;
 				goto yy3;
 			}
@@ -1409,13 +1410,13 @@ yy15:
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		if (yych <= '@') goto yy3;
-		goto yy1304;
+		goto yy1306;
 	} else {
 		if (yych <= '`') {
 			if (yych <= 'Z') goto yy140;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1315;
+			if (yych <= 'a') goto yy1317;
 			if (yych <= 'z') goto yy145;
 			goto yy3;
 		}
@@ -1426,13 +1427,13 @@ yy16:
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		if (yych <= '@') goto yy3;
-		goto yy1304;
+		goto yy1306;
 	} else {
 		if (yych <= '`') {
 			if (yych <= 'Z') goto yy140;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1304;
+			if (yych <= 'a') goto yy1306;
 			if (yych <= 'z') goto yy140;
 			goto yy3;
 		}
@@ -1443,13 +1444,13 @@ yy17:
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		if (yych <= '@') goto yy3;
-		goto yy1284;
+		goto yy1286;
 	} else {
 		if (yych <= '`') {
 			if (yych <= 'Z') goto yy140;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1301;
+			if (yych <= 'a') goto yy1303;
 			if (yych <= 'z') goto yy145;
 			goto yy3;
 		}
@@ -1460,13 +1461,13 @@ yy18:
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		if (yych <= '@') goto yy3;
-		goto yy1284;
+		goto yy1286;
 	} else {
 		if (yych <= '`') {
 			if (yych <= 'Z') goto yy140;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1284;
+			if (yych <= 'a') goto yy1286;
 			if (yych <= 'z') goto yy140;
 			goto yy3;
 		}
@@ -1481,17 +1482,17 @@ yy19:
 				goto yy139;
 			} else {
 				if (yych <= '@') goto yy3;
-				if (yych <= 'A') goto yy1227;
+				if (yych <= 'A') goto yy1229;
 				goto yy140;
 			}
 		} else {
 			if (yych <= 'H') {
-				if (yych <= 'E') goto yy1226;
+				if (yych <= 'E') goto yy1228;
 				goto yy140;
 			} else {
-				if (yych <= 'I') goto yy1228;
+				if (yych <= 'I') goto yy1230;
 				if (yych <= 'T') goto yy140;
-				goto yy1229;
+				goto yy1231;
 			}
 		}
 	} else {
@@ -1500,16 +1501,16 @@ yy19:
 				if (yych <= 'Z') goto yy140;
 				goto yy3;
 			} else {
-				if (yych <= 'a') goto yy1256;
+				if (yych <= 'a') goto yy1258;
 				if (yych <= 'd') goto yy145;
-				goto yy1255;
+				goto yy1257;
 			}
 		} else {
 			if (yych <= 't') {
-				if (yych == 'i') goto yy1257;
+				if (yych == 'i') goto yy1259;
 				goto yy145;
 			} else {
-				if (yych <= 'u') goto yy1258;
+				if (yych <= 'u') goto yy1260;
 				if (yych <= 'z') goto yy145;
 				goto yy3;
 			}
@@ -1525,17 +1526,17 @@ yy20:
 				goto yy139;
 			} else {
 				if (yych <= '@') goto yy3;
-				if (yych <= 'A') goto yy1227;
+				if (yych <= 'A') goto yy1229;
 				goto yy140;
 			}
 		} else {
 			if (yych <= 'H') {
-				if (yych <= 'E') goto yy1226;
+				if (yych <= 'E') goto yy1228;
 				goto yy140;
 			} else {
-				if (yych <= 'I') goto yy1228;
+				if (yych <= 'I') goto yy1230;
 				if (yych <= 'T') goto yy140;
-				goto yy1229;
+				goto yy1231;
 			}
 		}
 	} else {
@@ -1544,16 +1545,16 @@ yy20:
 				if (yych <= 'Z') goto yy140;
 				goto yy3;
 			} else {
-				if (yych <= 'a') goto yy1227;
+				if (yych <= 'a') goto yy1229;
 				if (yych <= 'd') goto yy140;
-				goto yy1226;
+				goto yy1228;
 			}
 		} else {
 			if (yych <= 't') {
-				if (yych == 'i') goto yy1228;
+				if (yych == 'i') goto yy1230;
 				goto yy140;
 			} else {
-				if (yych <= 'u') goto yy1229;
+				if (yych <= 'u') goto yy1231;
 				if (yych <= 'z') goto yy140;
 				goto yy3;
 			}
@@ -1576,9 +1577,9 @@ yy21:
 			if (yych <= 'Z') goto yy140;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'h') goto yy145;
-			goto yy1215;
+			goto yy1216;
 		} else {
-			if (yych == 'l') goto yy1216;
+			if (yych == 'l') goto yy1217;
 			if (yych <= 'z') goto yy145;
 			goto yy3;
 		}
@@ -2369,11 +2370,11 @@ yy48:
 	if (yych <= '9') goto yy54;
 yy49:
 	YYDEBUG(49, *YYCURSOR);
-#line 1716 "ext/date/lib/parse_date.re"
+#line 1717 "ext/date/lib/parse_date.re"
 	{
 		goto std;
 	}
-#line 2377 "ext/date/lib/parse_date.c"
+#line 2378 "ext/date/lib/parse_date.c"
 yy50:
 	YYDEBUG(50, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -2382,12 +2383,12 @@ yy51:
 	YYDEBUG(51, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(52, *YYCURSOR);
-#line 1721 "ext/date/lib/parse_date.re"
+#line 1722 "ext/date/lib/parse_date.re"
 	{
 		s->pos = cursor; s->line++;
 		goto std;
 	}
-#line 2391 "ext/date/lib/parse_date.c"
+#line 2392 "ext/date/lib/parse_date.c"
 yy53:
 	YYDEBUG(53, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -2564,27 +2565,27 @@ yy56:
 					if (yyaccept <= 27) {
 						goto yy1141;
 					} else {
-						goto yy1292;
+						goto yy1294;
 					}
 				} else {
 					if (yyaccept <= 29) {
-						goto yy1311;
+						goto yy1313;
 					} else {
-						goto yy1415;
+						goto yy1417;
 					}
 				}
 			} else {
 				if (yyaccept <= 32) {
 					if (yyaccept <= 31) {
-						goto yy1418;
+						goto yy1420;
 					} else {
-						goto yy1498;
+						goto yy1500;
 					}
 				} else {
 					if (yyaccept <= 33) {
-						goto yy1506;
+						goto yy1508;
 					} else {
-						goto yy1529;
+						goto yy1531;
 					}
 				}
 			}
@@ -2778,7 +2779,7 @@ yy71:
 	if (yych == 's') goto yy73;
 yy72:
 	YYDEBUG(72, *YYCURSOR);
-#line 1700 "ext/date/lib/parse_date.re"
+#line 1701 "ext/date/lib/parse_date.re"
 	{
 		timelib_ull i;
 		DEBUG_OUTPUT("relative");
@@ -2793,7 +2794,7 @@ yy72:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 2797 "ext/date/lib/parse_date.c"
+#line 2798 "ext/date/lib/parse_date.c"
 yy73:
 	YYDEBUG(73, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -3546,7 +3547,7 @@ yy166:
 	}
 yy167:
 	YYDEBUG(167, *YYCURSOR);
-#line 1563 "ext/date/lib/parse_date.re"
+#line 1564 "ext/date/lib/parse_date.re"
 	{
 		const timelib_relunit* relunit;
 		DEBUG_OUTPUT("daytext");
@@ -3563,7 +3564,7 @@ yy167:
 		TIMELIB_DEINIT;
 		return TIMELIB_WEEKDAY;
 	}
-#line 3567 "ext/date/lib/parse_date.c"
+#line 3568 "ext/date/lib/parse_date.c"
 yy168:
 	YYDEBUG(168, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -4040,7 +4041,7 @@ yy193:
 	}
 yy194:
 	YYDEBUG(194, *YYCURSOR);
-#line 1622 "ext/date/lib/parse_date.re"
+#line 1623 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("monthtext");
 		TIMELIB_INIT;
@@ -4049,7 +4050,7 @@ yy194:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_TEXT;
 	}
-#line 4053 "ext/date/lib/parse_date.c"
+#line 4054 "ext/date/lib/parse_date.c"
 yy195:
 	YYDEBUG(195, *YYCURSOR);
 	++YYCURSOR;
@@ -4100,7 +4101,7 @@ yy198:
 	}
 yy199:
 	YYDEBUG(199, *YYCURSOR);
-#line 1372 "ext/date/lib/parse_date.re"
+#line 1373 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datetextual | datenoyear");
 		TIMELIB_INIT;
@@ -4112,7 +4113,7 @@ yy199:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_TEXT;
 	}
-#line 4116 "ext/date/lib/parse_date.c"
+#line 4117 "ext/date/lib/parse_date.c"
 yy200:
 	YYDEBUG(200, *YYCURSOR);
 	yyaccept = 6;
@@ -4381,7 +4382,7 @@ yy222:
 	}
 yy223:
 	YYDEBUG(223, *YYCURSOR);
-#line 1670 "ext/date/lib/parse_date.re"
+#line 1671 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz");
@@ -4410,7 +4411,7 @@ yy223:
 		TIMELIB_DEINIT;
 		return TIMELIB_SHORTDATE_WITH_TIME;
 	}
-#line 4414 "ext/date/lib/parse_date.c"
+#line 4415 "ext/date/lib/parse_date.c"
 yy224:
 	YYDEBUG(224, *YYCURSOR);
 	yyaccept = 7;
@@ -5087,7 +5088,7 @@ yy279:
 	YYDEBUG(279, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(280, *YYCURSOR);
-#line 1646 "ext/date/lib/parse_date.re"
+#line 1647 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("dateshortwithtimeshort12 | dateshortwithtimelong12");
 		TIMELIB_INIT;
@@ -5110,7 +5111,7 @@ yy279:
 		TIMELIB_DEINIT;
 		return TIMELIB_SHORTDATE_WITH_TIME;
 	}
-#line 5114 "ext/date/lib/parse_date.c"
+#line 5115 "ext/date/lib/parse_date.c"
 yy281:
 	YYDEBUG(281, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -5283,7 +5284,7 @@ yy295:
 	++YYCURSOR;
 yy296:
 	YYDEBUG(296, *YYCURSOR);
-#line 1346 "ext/date/lib/parse_date.re"
+#line 1347 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datenoday");
 		TIMELIB_INIT;
@@ -5295,7 +5296,7 @@ yy296:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_NO_DAY;
 	}
-#line 5299 "ext/date/lib/parse_date.c"
+#line 5300 "ext/date/lib/parse_date.c"
 yy297:
 	YYDEBUG(297, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -6505,7 +6506,7 @@ yy363:
 	if (yych <= '9') goto yy366;
 yy365:
 	YYDEBUG(365, *YYCURSOR);
-#line 1486 "ext/date/lib/parse_date.re"
+#line 1487 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("pgtextshort");
 		TIMELIB_INIT;
@@ -6517,7 +6518,7 @@ yy365:
 		TIMELIB_DEINIT;
 		return TIMELIB_PG_TEXT;
 	}
-#line 6521 "ext/date/lib/parse_date.c"
+#line 6522 "ext/date/lib/parse_date.c"
 yy366:
 	YYDEBUG(366, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -7101,7 +7102,7 @@ yy391:
 	}
 yy392:
 	YYDEBUG(392, *YYCURSOR);
-#line 1542 "ext/date/lib/parse_date.re"
+#line 1543 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("ago");
 		TIMELIB_INIT;
@@ -7121,7 +7122,7 @@ yy392:
 		TIMELIB_DEINIT;
 		return TIMELIB_AGO;
 	}
-#line 7125 "ext/date/lib/parse_date.c"
+#line 7126 "ext/date/lib/parse_date.c"
 yy393:
 	YYDEBUG(393, *YYCURSOR);
 	yyaccept = 5;
@@ -8806,7 +8807,7 @@ yy453:
 	++YYCURSOR;
 yy454:
 	YYDEBUG(454, *YYCURSOR);
-#line 1256 "ext/date/lib/parse_date.re"
+#line 1257 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("iso8601date4 | iso8601date2 | iso8601dateslash | dateslash");
 		TIMELIB_INIT;
@@ -8817,7 +8818,7 @@ yy454:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_DATE;
 	}
-#line 8821 "ext/date/lib/parse_date.c"
+#line 8822 "ext/date/lib/parse_date.c"
 yy455:
 	YYDEBUG(455, *YYCURSOR);
 	yyaccept = 0;
@@ -9377,7 +9378,7 @@ yy474:
 	}
 yy475:
 	YYDEBUG(475, *YYCURSOR);
-#line 1385 "ext/date/lib/parse_date.re"
+#line 1386 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datenoyearrev");
 		TIMELIB_INIT;
@@ -9388,7 +9389,7 @@ yy475:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_TEXT;
 	}
-#line 9392 "ext/date/lib/parse_date.c"
+#line 9393 "ext/date/lib/parse_date.c"
 yy476:
 	YYDEBUG(476, *YYCURSOR);
 	yyaccept = 10;
@@ -9529,7 +9530,7 @@ yy487:
 	YYDEBUG(487, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(488, *YYCURSOR);
-#line 1112 "ext/date/lib/parse_date.re"
+#line 1113 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12");
 		TIMELIB_INIT;
@@ -9545,7 +9546,7 @@ yy487:
 		TIMELIB_DEINIT;
 		return TIMELIB_TIME12;
 	}
-#line 9549 "ext/date/lib/parse_date.c"
+#line 9550 "ext/date/lib/parse_date.c"
 yy489:
 	YYDEBUG(489, *YYCURSOR);
 	yyaccept = 11;
@@ -9558,7 +9559,7 @@ yy489:
 	}
 yy490:
 	YYDEBUG(490, *YYCURSOR);
-#line 1149 "ext/date/lib/parse_date.re"
+#line 1150 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long");
@@ -9583,7 +9584,7 @@ yy490:
 		TIMELIB_DEINIT;
 		return TIMELIB_TIME24_WITH_ZONE;
 	}
-#line 9587 "ext/date/lib/parse_date.c"
+#line 9588 "ext/date/lib/parse_date.c"
 yy491:
 	YYDEBUG(491, *YYCURSOR);
 	yyaccept = 11;
@@ -9893,7 +9894,7 @@ yy522:
 	YYDEBUG(522, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(523, *YYCURSOR);
-#line 1129 "ext/date/lib/parse_date.re"
+#line 1130 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("mssqltime");
 		TIMELIB_INIT;
@@ -9912,7 +9913,7 @@ yy522:
 		TIMELIB_DEINIT;
 		return TIMELIB_TIME24_WITH_ZONE;
 	}
-#line 9916 "ext/date/lib/parse_date.c"
+#line 9917 "ext/date/lib/parse_date.c"
 yy524:
 	YYDEBUG(524, *YYCURSOR);
 	yyaccept = 11;
@@ -10018,7 +10019,7 @@ yy533:
 	if (yych <= '9') goto yy540;
 yy534:
 	YYDEBUG(534, *YYCURSOR);
-#line 1307 "ext/date/lib/parse_date.re"
+#line 1308 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datefull");
 		TIMELIB_INIT;
@@ -10031,7 +10032,7 @@ yy534:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_FULL;
 	}
-#line 10035 "ext/date/lib/parse_date.c"
+#line 10036 "ext/date/lib/parse_date.c"
 yy535:
 	YYDEBUG(535, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -10768,7 +10769,7 @@ yy604:
 	YYDEBUG(605, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(606, *YYCURSOR);
-#line 1321 "ext/date/lib/parse_date.re"
+#line 1322 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("pointed date YYYY");
 		TIMELIB_INIT;
@@ -10779,7 +10780,7 @@ yy604:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_FULL_POINTED;
 	}
-#line 10783 "ext/date/lib/parse_date.c"
+#line 10784 "ext/date/lib/parse_date.c"
 yy607:
 	YYDEBUG(607, *YYCURSOR);
 	yyaccept = 11;
@@ -10815,7 +10816,7 @@ yy610:
 	if (yych <= '9') goto yy604;
 yy611:
 	YYDEBUG(611, *YYCURSOR);
-#line 1333 "ext/date/lib/parse_date.re"
+#line 1334 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("pointed date YY");
 		TIMELIB_INIT;
@@ -10827,7 +10828,7 @@ yy611:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_FULL_POINTED;
 	}
-#line 10831 "ext/date/lib/parse_date.c"
+#line 10832 "ext/date/lib/parse_date.c"
 yy612:
 	YYDEBUG(612, *YYCURSOR);
 	yyaccept = 11;
@@ -11468,7 +11469,7 @@ yy655:
 	}
 yy656:
 	YYDEBUG(656, *YYCURSOR);
-#line 1294 "ext/date/lib/parse_date.re"
+#line 1295 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("gnudateshort");
 		TIMELIB_INIT;
@@ -11480,7 +11481,7 @@ yy656:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_DATE;
 	}
-#line 11484 "ext/date/lib/parse_date.c"
+#line 11485 "ext/date/lib/parse_date.c"
 yy657:
 	YYDEBUG(657, *YYCURSOR);
 	yyaccept = 13;
@@ -11586,7 +11587,7 @@ yy665:
 	}
 yy666:
 	YYDEBUG(666, *YYCURSOR);
-#line 1241 "ext/date/lib/parse_date.re"
+#line 1242 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("americanshort | american");
 		TIMELIB_INIT;
@@ -11600,7 +11601,7 @@ yy666:
 		TIMELIB_DEINIT;
 		return TIMELIB_AMERICAN;
 	}
-#line 11604 "ext/date/lib/parse_date.c"
+#line 11605 "ext/date/lib/parse_date.c"
 yy667:
 	YYDEBUG(667, *YYCURSOR);
 	yyaccept = 14;
@@ -11833,7 +11834,7 @@ yy699:
 	if (yych <= ':') goto yy703;
 yy700:
 	YYDEBUG(700, *YYCURSOR);
-#line 1512 "ext/date/lib/parse_date.re"
+#line 1513 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("clf");
@@ -11853,7 +11854,7 @@ yy700:
 		TIMELIB_DEINIT;
 		return TIMELIB_CLF;
 	}
-#line 11857 "ext/date/lib/parse_date.c"
+#line 11858 "ext/date/lib/parse_date.c"
 yy701:
 	YYDEBUG(701, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -12405,7 +12406,7 @@ yy762:
 	}
 yy763:
 	YYDEBUG(763, *YYCURSOR);
-#line 1268 "ext/date/lib/parse_date.re"
+#line 1269 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("iso8601date2");
 		TIMELIB_INIT;
@@ -12417,7 +12418,7 @@ yy763:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_DATE;
 	}
-#line 12421 "ext/date/lib/parse_date.c"
+#line 12422 "ext/date/lib/parse_date.c"
 yy764:
 	YYDEBUG(764, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -12456,7 +12457,7 @@ yy770:
 	YYDEBUG(770, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(771, *YYCURSOR);
-#line 1499 "ext/date/lib/parse_date.re"
+#line 1500 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("pgtextreverse");
 		TIMELIB_INIT;
@@ -12468,7 +12469,7 @@ yy770:
 		TIMELIB_DEINIT;
 		return TIMELIB_PG_TEXT;
 	}
-#line 12472 "ext/date/lib/parse_date.c"
+#line 12473 "ext/date/lib/parse_date.c"
 yy772:
 	YYDEBUG(772, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -12606,7 +12607,7 @@ yy782:
 	}
 yy783:
 	YYDEBUG(783, *YYCURSOR);
-#line 1533 "ext/date/lib/parse_date.re"
+#line 1534 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("year4");
 		TIMELIB_INIT;
@@ -12614,7 +12615,7 @@ yy783:
 		TIMELIB_DEINIT;
 		return TIMELIB_CLF;
 	}
-#line 12618 "ext/date/lib/parse_date.c"
+#line 12619 "ext/date/lib/parse_date.c"
 yy784:
 	YYDEBUG(784, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -12765,7 +12766,7 @@ yy792:
 	}
 yy793:
 	YYDEBUG(793, *YYCURSOR);
-#line 1359 "ext/date/lib/parse_date.re"
+#line 1360 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datenodayrev");
 		TIMELIB_INIT;
@@ -12777,7 +12778,7 @@ yy793:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_NO_DAY;
 	}
-#line 12781 "ext/date/lib/parse_date.c"
+#line 12782 "ext/date/lib/parse_date.c"
 yy794:
 	YYDEBUG(794, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -12992,7 +12993,7 @@ yy813:
 	if (yych <= '7') goto yy816;
 yy814:
 	YYDEBUG(814, *YYCURSOR);
-#line 1467 "ext/date/lib/parse_date.re"
+#line 1468 "ext/date/lib/parse_date.re"
 	{
 		timelib_sll w, d;
 		DEBUG_OUTPUT("isoweek");
@@ -13010,7 +13011,7 @@ yy814:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_WEEK;
 	}
-#line 13014 "ext/date/lib/parse_date.c"
+#line 13015 "ext/date/lib/parse_date.c"
 yy815:
 	YYDEBUG(815, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -13020,7 +13021,7 @@ yy816:
 	YYDEBUG(816, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(817, *YYCURSOR);
-#line 1448 "ext/date/lib/parse_date.re"
+#line 1449 "ext/date/lib/parse_date.re"
 	{
 		timelib_sll w, d;
 		DEBUG_OUTPUT("isoweekday");
@@ -13038,7 +13039,7 @@ yy816:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_WEEK;
 	}
-#line 13042 "ext/date/lib/parse_date.c"
+#line 13043 "ext/date/lib/parse_date.c"
 yy818:
 	YYDEBUG(818, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -13102,7 +13103,7 @@ yy820:
 	}
 yy821:
 	YYDEBUG(821, *YYCURSOR);
-#line 1435 "ext/date/lib/parse_date.re"
+#line 1436 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("pgydotd");
 		TIMELIB_INIT;
@@ -13114,7 +13115,7 @@ yy821:
 		TIMELIB_DEINIT;
 		return TIMELIB_PG_YEARDAY;
 	}
-#line 13118 "ext/date/lib/parse_date.c"
+#line 13119 "ext/date/lib/parse_date.c"
 yy822:
 	YYDEBUG(822, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -13217,7 +13218,7 @@ yy841:
 	++YYCURSOR;
 yy842:
 	YYDEBUG(842, *YYCURSOR);
-#line 1409 "ext/date/lib/parse_date.re"
+#line 1410 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx | exif");
@@ -13242,7 +13243,7 @@ yy842:
 		TIMELIB_DEINIT;
 		return TIMELIB_XMLRPC_SOAP;
 	}
-#line 13246 "ext/date/lib/parse_date.c"
+#line 13247 "ext/date/lib/parse_date.c"
 yy843:
 	YYDEBUG(843, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -13504,7 +13505,7 @@ yy847:
 	}
 yy848:
 	YYDEBUG(848, *YYCURSOR);
-#line 1397 "ext/date/lib/parse_date.re"
+#line 1398 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datenocolon");
 		TIMELIB_INIT;
@@ -13515,7 +13516,7 @@ yy848:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_NOCOLON;
 	}
-#line 13519 "ext/date/lib/parse_date.c"
+#line 13520 "ext/date/lib/parse_date.c"
 yy849:
 	YYDEBUG(849, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -14435,7 +14436,7 @@ yy972:
 	if (yych <= '9') goto yy995;
 yy973:
 	YYDEBUG(973, *YYCURSOR);
-#line 1281 "ext/date/lib/parse_date.re"
+#line 1282 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("gnudateshorter");
 		TIMELIB_INIT;
@@ -14447,7 +14448,7 @@ yy973:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_DATE;
 	}
-#line 14451 "ext/date/lib/parse_date.c"
+#line 14452 "ext/date/lib/parse_date.c"
 yy974:
 	YYDEBUG(974, *YYCURSOR);
 	yyaccept = 22;
@@ -15456,7 +15457,7 @@ yy1065:
 	}
 yy1067:
 	YYDEBUG(1067, *YYCURSOR);
-#line 1175 "ext/date/lib/parse_date.re"
+#line 1176 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("gnunocolon");
 		TIMELIB_INIT;
@@ -15478,7 +15479,7 @@ yy1067:
 		TIMELIB_DEINIT;
 		return TIMELIB_GNU_NOCOLON;
 	}
-#line 15482 "ext/date/lib/parse_date.c"
+#line 15483 "ext/date/lib/parse_date.c"
 yy1068:
 	YYDEBUG(1068, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -15570,7 +15571,7 @@ yy1074:
 	}
 yy1075:
 	YYDEBUG(1075, *YYCURSOR);
-#line 1221 "ext/date/lib/parse_date.re"
+#line 1222 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("iso8601nocolon");
@@ -15589,7 +15590,7 @@ yy1075:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_NOCOLON;
 	}
-#line 15593 "ext/date/lib/parse_date.c"
+#line 15594 "ext/date/lib/parse_date.c"
 yy1076:
 	YYDEBUG(1076, *YYCURSOR);
 	yyaccept = 25;
@@ -16487,7 +16488,7 @@ yy1116:
 	}
 yy1117:
 	YYDEBUG(1117, *YYCURSOR);
-#line 1605 "ext/date/lib/parse_date.re"
+#line 1606 "ext/date/lib/parse_date.re"
 	{
 		timelib_sll i;
 		int         behavior = 0;
@@ -16503,7 +16504,7 @@ yy1117:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 16507 "ext/date/lib/parse_date.c"
+#line 16508 "ext/date/lib/parse_date.c"
 yy1118:
 	YYDEBUG(1118, *YYCURSOR);
 	++YYCURSOR;
@@ -16554,7 +16555,7 @@ yy1125:
 	YYDEBUG(1125, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(1126, *YYCURSOR);
-#line 1090 "ext/date/lib/parse_date.re"
+#line 1091 "ext/date/lib/parse_date.re"
 	{
 		timelib_sll i;
 		int         behavior = 0;
@@ -16575,7 +16576,7 @@ yy1125:
 		TIMELIB_DEINIT;
 		return TIMELIB_WEEK_DAY_OF_MONTH;
 	}
-#line 16579 "ext/date/lib/parse_date.c"
+#line 16580 "ext/date/lib/parse_date.c"
 yy1127:
 	YYDEBUG(1127, *YYCURSOR);
 	yyaccept = 26;
@@ -16683,7 +16684,7 @@ yy1140:
 	}
 yy1141:
 	YYDEBUG(1141, *YYCURSOR);
-#line 1581 "ext/date/lib/parse_date.re"
+#line 1582 "ext/date/lib/parse_date.re"
 	{
 		timelib_sll i;
 		int         behavior = 0;
@@ -16706,7 +16707,7 @@ yy1141:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 16710 "ext/date/lib/parse_date.c"
+#line 16711 "ext/date/lib/parse_date.c"
 yy1142:
 	YYDEBUG(1142, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -17470,21 +17471,22 @@ yy1214:
 	YYDEBUG(1214, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '(') {
-		if (yych <= '\t') {
-			if (yych <= 0x08) goto yy3;
-			goto yy1206;
+	if (yych <= '@') {
+		if (yych <= 0x1F) {
+			if (yych == '\t') goto yy1206;
+			goto yy3;
 		} else {
-			if (yych == ' ') goto yy1206;
+			if (yych <= ' ') goto yy1206;
+			if (yych == ')') goto yy139;
 			goto yy3;
 		}
 	} else {
-		if (yych <= 'Z') {
-			if (yych <= ')') goto yy139;
-			if (yych <= '@') goto yy3;
-			goto yy144;
+		if (yych <= '`') {
+			if (yych == 'H') goto yy1215;
+			if (yych <= 'Z') goto yy144;
+			goto yy3;
 		} else {
-			if (yych <= '`') goto yy3;
+			if (yych == 'h') goto yy1215;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
@@ -17493,6 +17495,18 @@ yy1215:
 	YYDEBUG(1215, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
+	if (yych <= 0x1F) {
+		if (yych == '\t') goto yy1206;
+		goto yy3;
+	} else {
+		if (yych <= ' ') goto yy1206;
+		if (yych == ')') goto yy139;
+		goto yy3;
+	}
+yy1216:
+	YYDEBUG(1216, *YYCURSOR);
+	yyaccept = 0;
+	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'G') {
 		if (yych <= '.') {
 			if (yych == ')') goto yy139;
@@ -17509,13 +17523,13 @@ yy1215:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'g') goto yy1223;
+			if (yych == 'g') goto yy1224;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1216:
-	YYDEBUG(1216, *YYCURSOR);
+yy1217:
+	YYDEBUG(1217, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -17534,13 +17548,13 @@ yy1216:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1217;
+			if (yych == 'e') goto yy1218;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1217:
-	YYDEBUG(1217, *YYCURSOR);
+yy1218:
+	YYDEBUG(1218, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'V') {
@@ -17559,13 +17573,13 @@ yy1217:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'v') goto yy1218;
+			if (yych == 'v') goto yy1219;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1218:
-	YYDEBUG(1218, *YYCURSOR);
+yy1219:
+	YYDEBUG(1219, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -17584,13 +17598,13 @@ yy1218:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1219;
+			if (yych == 'e') goto yy1220;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1219:
-	YYDEBUG(1219, *YYCURSOR);
+yy1220:
+	YYDEBUG(1220, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -17609,13 +17623,13 @@ yy1219:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1220;
+			if (yych == 'n') goto yy1221;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1220:
-	YYDEBUG(1220, *YYCURSOR);
+yy1221:
+	YYDEBUG(1221, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -17632,18 +17646,18 @@ yy1220:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1221;
+			if (yych == 't') goto yy1222;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1221:
-	YYDEBUG(1221, *YYCURSOR);
+yy1222:
+	YYDEBUG(1222, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'H') goto yy1205;
 	if (yych != 'h') goto yy155;
-yy1222:
-	YYDEBUG(1222, *YYCURSOR);
+yy1223:
+	YYDEBUG(1223, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '.') {
 		if (yych <= '\t') {
@@ -17664,8 +17678,8 @@ yy1222:
 			goto yy56;
 		}
 	}
-yy1223:
-	YYDEBUG(1223, *YYCURSOR);
+yy1224:
+	YYDEBUG(1224, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -17684,13 +17698,13 @@ yy1223:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1224;
+			if (yych == 'h') goto yy1225;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1224:
-	YYDEBUG(1224, *YYCURSOR);
+yy1225:
+	YYDEBUG(1225, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -17709,39 +17723,76 @@ yy1224:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1225;
+			if (yych == 't') goto yy1226;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1225:
-	YYDEBUG(1225, *YYCURSOR);
+yy1226:
+	YYDEBUG(1226, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '.') {
+	if (yych <= '@') {
+		if (yych <= ' ') {
+			if (yych == '\t') goto yy1206;
+			if (yych <= 0x1F) goto yy3;
+			goto yy1206;
+		} else {
+			if (yych <= ')') {
+				if (yych <= '(') goto yy3;
+				goto yy139;
+			} else {
+				if (yych == '/') goto yy147;
+				goto yy3;
+			}
+		}
+	} else {
+		if (yych <= '_') {
+			if (yych <= 'H') {
+				if (yych <= 'G') goto yy144;
+				goto yy1215;
+			} else {
+				if (yych <= 'Z') goto yy144;
+				if (yych <= '^') goto yy3;
+				goto yy147;
+			}
+		} else {
+			if (yych <= 'g') {
+				if (yych <= '`') goto yy3;
+				goto yy153;
+			} else {
+				if (yych <= 'h') goto yy1227;
+				if (yych <= 'z') goto yy153;
+				goto yy3;
+			}
+		}
+	}
+yy1227:
+	YYDEBUG(1227, *YYCURSOR);
+	yyaccept = 0;
+	yych = *(YYMARKER = ++YYCURSOR);
+	if (yych <= ')') {
 		if (yych <= 0x1F) {
 			if (yych == '\t') goto yy1206;
 			goto yy3;
 		} else {
 			if (yych <= ' ') goto yy1206;
-			if (yych == ')') goto yy139;
-			goto yy3;
+			if (yych <= '(') goto yy3;
+			goto yy139;
 		}
 	} else {
 		if (yych <= '^') {
-			if (yych <= '/') goto yy147;
-			if (yych <= '@') goto yy3;
-			if (yych <= 'Z') goto yy144;
+			if (yych == '/') goto yy147;
 			goto yy3;
 		} else {
 			if (yych <= '_') goto yy147;
 			if (yych <= '`') goto yy3;
-			if (yych <= 'z') goto yy153;
+			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1226:
-	YYDEBUG(1226, *YYCURSOR);
+yy1228:
+	YYDEBUG(1228, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'V') {
 		if (yych <= 'B') {
@@ -17750,12 +17801,12 @@ yy1226:
 			goto yy141;
 		} else {
 			if (yych <= 'O') {
-				if (yych <= 'C') goto yy1241;
+				if (yych <= 'C') goto yy1244;
 				goto yy141;
 			} else {
-				if (yych <= 'P') goto yy1243;
+				if (yych <= 'P') goto yy1246;
 				if (yych <= 'U') goto yy141;
-				goto yy1242;
+				goto yy1245;
 			}
 		}
 	} else {
@@ -17764,22 +17815,22 @@ yy1226:
 				if (yych <= 'Z') goto yy141;
 				goto yy3;
 			} else {
-				if (yych == 'c') goto yy1241;
+				if (yych == 'c') goto yy1244;
 				goto yy141;
 			}
 		} else {
 			if (yych <= 'u') {
-				if (yych <= 'p') goto yy1243;
+				if (yych <= 'p') goto yy1246;
 				goto yy141;
 			} else {
-				if (yych <= 'v') goto yy1242;
+				if (yych <= 'v') goto yy1245;
 				if (yych <= 'z') goto yy141;
 				goto yy3;
 			}
 		}
 	}
-yy1227:
-	YYDEBUG(1227, *YYCURSOR);
+yy1229:
+	YYDEBUG(1229, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -17788,7 +17839,7 @@ yy1227:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy141;
-			goto yy1236;
+			goto yy1239;
 		}
 	} else {
 		if (yych <= 's') {
@@ -17796,13 +17847,13 @@ yy1227:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 't') goto yy1236;
+			if (yych <= 't') goto yy1239;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1228:
-	YYDEBUG(1228, *YYCURSOR);
+yy1230:
+	YYDEBUG(1230, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'X') {
 		if (yych <= ')') {
@@ -17811,7 +17862,7 @@ yy1228:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'W') goto yy141;
-			goto yy1234;
+			goto yy1236;
 		}
 	} else {
 		if (yych <= 'w') {
@@ -17819,13 +17870,13 @@ yy1228:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'x') goto yy1234;
+			if (yych <= 'x') goto yy1236;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1229:
-	YYDEBUG(1229, *YYCURSOR);
+yy1231:
+	YYDEBUG(1231, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -17841,13 +17892,13 @@ yy1229:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'n') goto yy1230;
+			if (yych <= 'n') goto yy1232;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1230:
-	YYDEBUG(1230, *YYCURSOR);
+yy1232:
+	YYDEBUG(1232, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -17863,13 +17914,13 @@ yy1230:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 'd') goto yy1231;
+			if (yych <= 'd') goto yy1233;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1231:
-	YYDEBUG(1231, *YYCURSOR);
+yy1233:
+	YYDEBUG(1233, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
@@ -17879,13 +17930,13 @@ yy1231:
 			if (yych <= 'Z') goto yy143;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1232;
+			if (yych <= 'a') goto yy1234;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1232:
-	YYDEBUG(1232, *YYCURSOR);
+yy1234:
+	YYDEBUG(1234, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'Y') {
 		if (yych <= ')') {
@@ -17901,18 +17952,18 @@ yy1232:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'y') goto yy1233;
+			if (yych <= 'y') goto yy1235;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1233:
-	YYDEBUG(1233, *YYCURSOR);
+yy1235:
+	YYDEBUG(1235, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == ')') goto yy139;
 	goto yy167;
-yy1234:
-	YYDEBUG(1234, *YYCURSOR);
+yy1236:
+	YYDEBUG(1236, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -17928,13 +17979,13 @@ yy1234:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1235;
+			if (yych <= 't') goto yy1237;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1235:
-	YYDEBUG(1235, *YYCURSOR);
+yy1237:
+	YYDEBUG(1237, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -17943,7 +17994,6 @@ yy1235:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
 		}
 	} else {
 		if (yych <= 'g') {
@@ -17951,13 +18001,36 @@ yy1235:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'h') goto yy1214;
+			if (yych <= 'h') goto yy1238;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1236:
-	YYDEBUG(1236, *YYCURSOR);
+yy1238:
+	YYDEBUG(1238, *YYCURSOR);
+	yyaccept = 0;
+	yych = *(YYMARKER = ++YYCURSOR);
+	if (yych <= '(') {
+		if (yych <= '\t') {
+			if (yych <= 0x08) goto yy3;
+			goto yy1206;
+		} else {
+			if (yych == ' ') goto yy1206;
+			goto yy3;
+		}
+	} else {
+		if (yych <= 'Z') {
+			if (yych <= ')') goto yy139;
+			if (yych <= '@') goto yy3;
+			goto yy144;
+		} else {
+			if (yych <= '`') goto yy3;
+			if (yych <= 'z') goto yy144;
+			goto yy3;
+		}
+	}
+yy1239:
+	YYDEBUG(1239, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'U') {
 		if (yych <= ')') {
@@ -17973,13 +18046,13 @@ yy1236:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 'u') goto yy1237;
+			if (yych <= 'u') goto yy1240;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1237:
-	YYDEBUG(1237, *YYCURSOR);
+yy1240:
+	YYDEBUG(1240, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -17995,13 +18068,13 @@ yy1237:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'r') goto yy1238;
+			if (yych <= 'r') goto yy1241;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1238:
-	YYDEBUG(1238, *YYCURSOR);
+yy1241:
+	YYDEBUG(1241, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -18017,30 +18090,30 @@ yy1238:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'd') goto yy1239;
+			if (yych <= 'd') goto yy1242;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1239:
-	YYDEBUG(1239, *YYCURSOR);
+yy1242:
+	YYDEBUG(1242, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '@') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'A') goto yy1240;
+		if (yych <= 'A') goto yy1243;
 		if (yych != 'a') goto yy3;
 	}
-yy1240:
-	YYDEBUG(1240, *YYCURSOR);
+yy1243:
+	YYDEBUG(1243, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy173;
 	if (yych == 'y') goto yy173;
 	goto yy56;
-yy1241:
-	YYDEBUG(1241, *YYCURSOR);
+yy1244:
+	YYDEBUG(1244, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'O') {
 		if (yych <= ')') {
@@ -18049,7 +18122,7 @@ yy1241:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'N') goto yy142;
-			goto yy1252;
+			goto yy1255;
 		}
 	} else {
 		if (yych <= 'n') {
@@ -18057,13 +18130,13 @@ yy1241:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'o') goto yy1252;
+			if (yych <= 'o') goto yy1255;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1242:
-	YYDEBUG(1242, *YYCURSOR);
+yy1245:
+	YYDEBUG(1245, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'E') {
 		if (yych <= ')') {
@@ -18072,7 +18145,7 @@ yy1242:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy142;
-			goto yy1249;
+			goto yy1252;
 		}
 	} else {
 		if (yych <= 'd') {
@@ -18080,13 +18153,13 @@ yy1242:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'e') goto yy1249;
+			if (yych <= 'e') goto yy1252;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1243:
-	YYDEBUG(1243, *YYCURSOR);
+yy1246:
+	YYDEBUG(1246, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -18121,14 +18194,14 @@ yy1243:
 				if (yych <= '`') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 't') goto yy1244;
+				if (yych <= 't') goto yy1247;
 				if (yych <= 'z') goto yy142;
 				goto yy194;
 			}
 		}
 	}
-yy1244:
-	YYDEBUG(1244, *YYCURSOR);
+yy1247:
+	YYDEBUG(1247, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -18163,14 +18236,14 @@ yy1244:
 				if (yych <= '`') goto yy194;
 				goto yy143;
 			} else {
-				if (yych <= 'e') goto yy1245;
+				if (yych <= 'e') goto yy1248;
 				if (yych <= 'z') goto yy143;
 				goto yy194;
 			}
 		}
 	}
-yy1245:
-	YYDEBUG(1245, *YYCURSOR);
+yy1248:
+	YYDEBUG(1248, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'M') {
 		if (yych <= ')') {
@@ -18186,35 +18259,35 @@ yy1245:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'm') goto yy1246;
+			if (yych <= 'm') goto yy1249;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1246:
-	YYDEBUG(1246, *YYCURSOR);
+yy1249:
+	YYDEBUG(1249, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'B') goto yy1247;
+		if (yych <= 'B') goto yy1250;
 		if (yych != 'b') goto yy3;
 	}
-yy1247:
-	YYDEBUG(1247, *YYCURSOR);
+yy1250:
+	YYDEBUG(1250, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'E') goto yy1248;
+	if (yych == 'E') goto yy1251;
 	if (yych != 'e') goto yy56;
-yy1248:
-	YYDEBUG(1248, *YYCURSOR);
+yy1251:
+	YYDEBUG(1251, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'R') goto yy206;
 	if (yych == 'r') goto yy206;
 	goto yy56;
-yy1249:
-	YYDEBUG(1249, *YYCURSOR);
+yy1252:
+	YYDEBUG(1252, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -18230,13 +18303,13 @@ yy1249:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'n') goto yy1250;
+			if (yych <= 'n') goto yy1253;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1250:
-	YYDEBUG(1250, *YYCURSOR);
+yy1253:
+	YYDEBUG(1253, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -18252,13 +18325,13 @@ yy1250:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 't') goto yy1251;
+			if (yych <= 't') goto yy1254;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1251:
-	YYDEBUG(1251, *YYCURSOR);
+yy1254:
+	YYDEBUG(1254, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'G') {
@@ -18269,8 +18342,8 @@ yy1251:
 		if (yych == 'h') goto yy1205;
 		goto yy3;
 	}
-yy1252:
-	YYDEBUG(1252, *YYCURSOR);
+yy1255:
+	YYDEBUG(1255, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -18286,13 +18359,13 @@ yy1252:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'n') goto yy1253;
+			if (yych <= 'n') goto yy1256;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1253:
-	YYDEBUG(1253, *YYCURSOR);
+yy1256:
+	YYDEBUG(1256, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -18301,6 +18374,7 @@ yy1253:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy144;
+			goto yy1215;
 		}
 	} else {
 		if (yych <= 'c') {
@@ -18308,25 +18382,13 @@ yy1253:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'd') goto yy1254;
+			if (yych <= 'd') goto yy1215;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1254:
-	YYDEBUG(1254, *YYCURSOR);
-	yyaccept = 0;
-	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= 0x1F) {
-		if (yych == '\t') goto yy1206;
-		goto yy3;
-	} else {
-		if (yych <= ' ') goto yy1206;
-		if (yych == ')') goto yy139;
-		goto yy3;
-	}
-yy1255:
-	YYDEBUG(1255, *YYCURSOR);
+yy1257:
+	YYDEBUG(1257, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'V') {
@@ -18340,12 +18402,12 @@ yy1255:
 			}
 		} else {
 			if (yych <= 'O') {
-				if (yych == 'C') goto yy1241;
+				if (yych == 'C') goto yy1244;
 				goto yy141;
 			} else {
-				if (yych <= 'P') goto yy1243;
+				if (yych <= 'P') goto yy1246;
 				if (yych <= 'U') goto yy141;
-				goto yy1242;
+				goto yy1245;
 			}
 		}
 	} else {
@@ -18357,21 +18419,21 @@ yy1255:
 			} else {
 				if (yych <= '`') goto yy3;
 				if (yych <= 'b') goto yy146;
-				goto yy1270;
+				goto yy1273;
 			}
 		} else {
 			if (yych <= 'u') {
-				if (yych == 'p') goto yy1272;
+				if (yych == 'p') goto yy1275;
 				goto yy146;
 			} else {
-				if (yych <= 'v') goto yy1271;
+				if (yych <= 'v') goto yy1274;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1256:
-	YYDEBUG(1256, *YYCURSOR);
+yy1258:
+	YYDEBUG(1258, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -18382,7 +18444,7 @@ yy1256:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy141;
-			goto yy1236;
+			goto yy1239;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18390,13 +18452,13 @@ yy1256:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1265;
+			if (yych == 't') goto yy1268;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1257:
-	YYDEBUG(1257, *YYCURSOR);
+yy1259:
+	YYDEBUG(1259, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'X') {
@@ -18407,7 +18469,7 @@ yy1257:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'W') goto yy141;
-			goto yy1234;
+			goto yy1236;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18415,13 +18477,13 @@ yy1257:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'x') goto yy1263;
+			if (yych == 'x') goto yy1265;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1258:
-	YYDEBUG(1258, *YYCURSOR);
+yy1260:
+	YYDEBUG(1260, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -18432,7 +18494,7 @@ yy1258:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy141;
-			goto yy1230;
+			goto yy1232;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18440,13 +18502,13 @@ yy1258:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1259;
+			if (yych == 'n') goto yy1261;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1259:
-	YYDEBUG(1259, *YYCURSOR);
+yy1261:
+	YYDEBUG(1261, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -18457,7 +18519,7 @@ yy1259:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'C') goto yy142;
-			goto yy1231;
+			goto yy1233;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18465,13 +18527,13 @@ yy1259:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 'd') goto yy1260;
+			if (yych == 'd') goto yy1262;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1260:
-	YYDEBUG(1260, *YYCURSOR);
+yy1262:
+	YYDEBUG(1262, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -18481,7 +18543,7 @@ yy1260:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1232;
+			goto yy1234;
 		}
 	} else {
 		if (yych <= '_') {
@@ -18490,13 +18552,13 @@ yy1260:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1261;
+			if (yych <= 'a') goto yy1263;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1261:
-	YYDEBUG(1261, *YYCURSOR);
+yy1263:
+	YYDEBUG(1263, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -18507,7 +18569,7 @@ yy1261:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy144;
-			goto yy1233;
+			goto yy1235;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18515,13 +18577,13 @@ yy1261:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'y') goto yy1262;
+			if (yych == 'y') goto yy1264;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1262:
-	YYDEBUG(1262, *YYCURSOR);
+yy1264:
+	YYDEBUG(1264, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -18538,8 +18600,8 @@ yy1262:
 			goto yy167;
 		}
 	}
-yy1263:
-	YYDEBUG(1263, *YYCURSOR);
+yy1265:
+	YYDEBUG(1265, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -18550,7 +18612,7 @@ yy1263:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1235;
+			goto yy1237;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18558,13 +18620,13 @@ yy1263:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1264;
+			if (yych == 't') goto yy1266;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1264:
-	YYDEBUG(1264, *YYCURSOR);
+yy1266:
+	YYDEBUG(1266, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -18575,7 +18637,7 @@ yy1264:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18583,13 +18645,39 @@ yy1264:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1225;
+			if (yych == 'h') goto yy1267;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1265:
-	YYDEBUG(1265, *YYCURSOR);
+yy1267:
+	YYDEBUG(1267, *YYCURSOR);
+	yyaccept = 0;
+	yych = *(YYMARKER = ++YYCURSOR);
+	if (yych <= '.') {
+		if (yych <= 0x1F) {
+			if (yych == '\t') goto yy1206;
+			goto yy3;
+		} else {
+			if (yych <= ' ') goto yy1206;
+			if (yych == ')') goto yy139;
+			goto yy3;
+		}
+	} else {
+		if (yych <= '^') {
+			if (yych <= '/') goto yy147;
+			if (yych <= '@') goto yy3;
+			if (yych <= 'Z') goto yy144;
+			goto yy3;
+		} else {
+			if (yych <= '_') goto yy147;
+			if (yych <= '`') goto yy3;
+			if (yych <= 'z') goto yy153;
+			goto yy3;
+		}
+	}
+yy1268:
+	YYDEBUG(1268, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'U') {
@@ -18600,7 +18688,7 @@ yy1265:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'T') goto yy142;
-			goto yy1237;
+			goto yy1240;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18608,13 +18696,13 @@ yy1265:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 'u') goto yy1266;
+			if (yych == 'u') goto yy1269;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1266:
-	YYDEBUG(1266, *YYCURSOR);
+yy1269:
+	YYDEBUG(1269, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -18625,7 +18713,7 @@ yy1266:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy143;
-			goto yy1238;
+			goto yy1241;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18633,13 +18721,13 @@ yy1266:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1267;
+			if (yych == 'r') goto yy1270;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1267:
-	YYDEBUG(1267, *YYCURSOR);
+yy1270:
+	YYDEBUG(1270, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -18650,7 +18738,7 @@ yy1267:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy144;
-			goto yy1239;
+			goto yy1242;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18658,13 +18746,13 @@ yy1267:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1268;
+			if (yych == 'd') goto yy1271;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1268:
-	YYDEBUG(1268, *YYCURSOR);
+yy1271:
+	YYDEBUG(1271, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -18674,26 +18762,26 @@ yy1268:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1240;
+			goto yy1243;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1269;
+			if (yych <= 'a') goto yy1272;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1269:
-	YYDEBUG(1269, *YYCURSOR);
+yy1272:
+	YYDEBUG(1272, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy173;
 	if (yych == 'y') goto yy186;
 	goto yy155;
-yy1270:
-	YYDEBUG(1270, *YYCURSOR);
+yy1273:
+	YYDEBUG(1273, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'O') {
@@ -18704,7 +18792,7 @@ yy1270:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'N') goto yy142;
-			goto yy1252;
+			goto yy1255;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18712,13 +18800,13 @@ yy1270:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'o') goto yy1281;
+			if (yych == 'o') goto yy1284;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1271:
-	YYDEBUG(1271, *YYCURSOR);
+yy1274:
+	YYDEBUG(1274, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -18729,7 +18817,7 @@ yy1271:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy142;
-			goto yy1249;
+			goto yy1252;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18737,13 +18825,13 @@ yy1271:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1278;
+			if (yych == 'e') goto yy1281;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1272:
-	YYDEBUG(1272, *YYCURSOR);
+yy1275:
+	YYDEBUG(1275, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '9') {
@@ -18771,7 +18859,7 @@ yy1272:
 				if (yych <= '@') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'T') goto yy1244;
+				if (yych <= 'T') goto yy1247;
 				if (yych <= 'Z') goto yy142;
 				goto yy194;
 			}
@@ -18781,14 +18869,14 @@ yy1272:
 				if (yych <= '`') goto yy194;
 				goto yy151;
 			} else {
-				if (yych <= 't') goto yy1273;
+				if (yych <= 't') goto yy1276;
 				if (yych <= 'z') goto yy151;
 				goto yy194;
 			}
 		}
 	}
-yy1273:
-	YYDEBUG(1273, *YYCURSOR);
+yy1276:
+	YYDEBUG(1276, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '9') {
@@ -18816,7 +18904,7 @@ yy1273:
 				if (yych <= '@') goto yy194;
 				goto yy143;
 			} else {
-				if (yych <= 'E') goto yy1245;
+				if (yych <= 'E') goto yy1248;
 				if (yych <= 'Z') goto yy143;
 				goto yy194;
 			}
@@ -18826,14 +18914,14 @@ yy1273:
 				if (yych <= '`') goto yy194;
 				goto yy152;
 			} else {
-				if (yych <= 'e') goto yy1274;
+				if (yych <= 'e') goto yy1277;
 				if (yych <= 'z') goto yy152;
 				goto yy194;
 			}
 		}
 	}
-yy1274:
-	YYDEBUG(1274, *YYCURSOR);
+yy1277:
+	YYDEBUG(1277, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'M') {
@@ -18844,7 +18932,7 @@ yy1274:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'L') goto yy144;
-			goto yy1246;
+			goto yy1249;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18852,13 +18940,13 @@ yy1274:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'm') goto yy1275;
+			if (yych == 'm') goto yy1278;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1275:
-	YYDEBUG(1275, *YYCURSOR);
+yy1278:
+	YYDEBUG(1278, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'B') {
@@ -18868,30 +18956,30 @@ yy1275:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'A') goto yy3;
-			goto yy1247;
+			goto yy1250;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'b') goto yy1276;
+			if (yych == 'b') goto yy1279;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1276:
-	YYDEBUG(1276, *YYCURSOR);
+yy1279:
+	YYDEBUG(1279, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'E') goto yy1248;
+	if (yych == 'E') goto yy1251;
 	if (yych != 'e') goto yy155;
-	YYDEBUG(1277, *YYCURSOR);
+	YYDEBUG(1280, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'R') goto yy206;
 	if (yych == 'r') goto yy377;
 	goto yy155;
-yy1278:
-	YYDEBUG(1278, *YYCURSOR);
+yy1281:
+	YYDEBUG(1281, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -18902,7 +18990,7 @@ yy1278:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy143;
-			goto yy1250;
+			goto yy1253;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18910,13 +18998,13 @@ yy1278:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1279;
+			if (yych == 'n') goto yy1282;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1279:
-	YYDEBUG(1279, *YYCURSOR);
+yy1282:
+	YYDEBUG(1282, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -18927,7 +19015,7 @@ yy1279:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy144;
-			goto yy1251;
+			goto yy1254;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18935,13 +19023,13 @@ yy1279:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1280;
+			if (yych == 't') goto yy1283;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1280:
-	YYDEBUG(1280, *YYCURSOR);
+yy1283:
+	YYDEBUG(1283, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -18958,13 +19046,13 @@ yy1280:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1222;
+			if (yych == 'h') goto yy1223;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1281:
-	YYDEBUG(1281, *YYCURSOR);
+yy1284:
+	YYDEBUG(1284, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -18975,7 +19063,7 @@ yy1281:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy143;
-			goto yy1253;
+			goto yy1256;
 		}
 	} else {
 		if (yych <= '`') {
@@ -18983,13 +19071,13 @@ yy1281:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1282;
+			if (yych == 'n') goto yy1285;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1282:
-	YYDEBUG(1282, *YYCURSOR);
+yy1285:
+	YYDEBUG(1285, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -19000,7 +19088,7 @@ yy1282:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy144;
-			goto yy1254;
+			goto yy1215;
 		}
 	} else {
 		if (yych <= '`') {
@@ -19008,37 +19096,13 @@ yy1282:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1283;
+			if (yych == 'd') goto yy1227;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1283:
-	YYDEBUG(1283, *YYCURSOR);
-	yyaccept = 0;
-	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= ')') {
-		if (yych <= 0x1F) {
-			if (yych == '\t') goto yy1206;
-			goto yy3;
-		} else {
-			if (yych <= ' ') goto yy1206;
-			if (yych <= '(') goto yy3;
-			goto yy139;
-		}
-	} else {
-		if (yych <= '^') {
-			if (yych == '/') goto yy147;
-			goto yy3;
-		} else {
-			if (yych <= '_') goto yy147;
-			if (yych <= '`') goto yy3;
-			if (yych <= 'z') goto yy154;
-			goto yy3;
-		}
-	}
-yy1284:
-	YYDEBUG(1284, *YYCURSOR);
+yy1286:
+	YYDEBUG(1286, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'C') {
 		if (yych <= ')') {
@@ -19054,13 +19118,13 @@ yy1284:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'c') goto yy1285;
+			if (yych <= 'c') goto yy1287;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1285:
-	YYDEBUG(1285, *YYCURSOR);
+yy1287:
+	YYDEBUG(1287, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'K') {
 		if (yych <= ')') {
@@ -19076,17 +19140,17 @@ yy1285:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'k') goto yy1286;
+			if (yych <= 'k') goto yy1288;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1286:
-	YYDEBUG(1286, *YYCURSOR);
+yy1288:
+	YYDEBUG(1288, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= ')') {
-		if (yych == ' ') goto yy1287;
+		if (yych == ' ') goto yy1289;
 		if (yych <= '(') goto yy3;
 		goto yy139;
 	} else {
@@ -19099,37 +19163,37 @@ yy1286:
 			goto yy3;
 		}
 	}
-yy1287:
-	YYDEBUG(1287, *YYCURSOR);
+yy1289:
+	YYDEBUG(1289, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'O') goto yy1288;
+	if (yych == 'O') goto yy1290;
 	if (yych != 'o') goto yy56;
-yy1288:
-	YYDEBUG(1288, *YYCURSOR);
+yy1290:
+	YYDEBUG(1290, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'F') goto yy1289;
+	if (yych == 'F') goto yy1291;
 	if (yych != 'f') goto yy56;
-yy1289:
-	YYDEBUG(1289, *YYCURSOR);
+yy1291:
+	YYDEBUG(1291, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych != ' ') goto yy56;
-	YYDEBUG(1290, *YYCURSOR);
+	YYDEBUG(1292, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') goto yy56;
-	if (yych <= '1') goto yy1291;
-	if (yych <= '2') goto yy1293;
-	if (yych <= '9') goto yy1294;
+	if (yych <= '1') goto yy1293;
+	if (yych <= '2') goto yy1295;
+	if (yych <= '9') goto yy1296;
 	goto yy56;
-yy1291:
-	YYDEBUG(1291, *YYCURSOR);
+yy1293:
+	YYDEBUG(1293, *YYCURSOR);
 	yyaccept = 28;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '/') goto yy1295;
-	if (yych <= '9') goto yy1294;
-	goto yy1295;
-yy1292:
-	YYDEBUG(1292, *YYCURSOR);
-#line 1067 "ext/date/lib/parse_date.re"
+	if (yych <= '/') goto yy1297;
+	if (yych <= '9') goto yy1296;
+	goto yy1297;
+yy1294:
+	YYDEBUG(1294, *YYCURSOR);
+#line 1068 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("backof | frontof");
 		TIMELIB_INIT;
@@ -19151,76 +19215,76 @@ yy1292:
 		TIMELIB_DEINIT;
 		return TIMELIB_LF_DAY_OF_MONTH;
 	}
-#line 19155 "ext/date/lib/parse_date.c"
-yy1293:
-	YYDEBUG(1293, *YYCURSOR);
+#line 19219 "ext/date/lib/parse_date.c"
+yy1295:
+	YYDEBUG(1295, *YYCURSOR);
 	yyaccept = 28;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '/') goto yy1295;
-	if (yych >= '5') goto yy1295;
-yy1294:
-	YYDEBUG(1294, *YYCURSOR);
+	if (yych <= '/') goto yy1297;
+	if (yych >= '5') goto yy1297;
+yy1296:
+	YYDEBUG(1296, *YYCURSOR);
 	yyaccept = 28;
 	YYMARKER = ++YYCURSOR;
 	if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5);
 	yych = *YYCURSOR;
-yy1295:
-	YYDEBUG(1295, *YYCURSOR);
+yy1297:
+	YYDEBUG(1297, *YYCURSOR);
 	if (yych <= 'A') {
 		if (yych <= 0x1F) {
-			if (yych == '\t') goto yy1294;
-			goto yy1292;
+			if (yych == '\t') goto yy1296;
+			goto yy1294;
 		} else {
-			if (yych <= ' ') goto yy1294;
-			if (yych <= '@') goto yy1292;
+			if (yych <= ' ') goto yy1296;
+			if (yych <= '@') goto yy1294;
 		}
 	} else {
 		if (yych <= '`') {
-			if (yych != 'P') goto yy1292;
+			if (yych != 'P') goto yy1294;
 		} else {
-			if (yych <= 'a') goto yy1296;
-			if (yych != 'p') goto yy1292;
+			if (yych <= 'a') goto yy1298;
+			if (yych != 'p') goto yy1294;
 		}
 	}
-yy1296:
-	YYDEBUG(1296, *YYCURSOR);
+yy1298:
+	YYDEBUG(1298, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'L') {
 		if (yych != '.') goto yy56;
 	} else {
-		if (yych <= 'M') goto yy1298;
-		if (yych == 'm') goto yy1298;
+		if (yych <= 'M') goto yy1300;
+		if (yych == 'm') goto yy1300;
 		goto yy56;
 	}
-	YYDEBUG(1297, *YYCURSOR);
+	YYDEBUG(1299, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'M') goto yy1298;
+	if (yych == 'M') goto yy1300;
 	if (yych != 'm') goto yy56;
-yy1298:
-	YYDEBUG(1298, *YYCURSOR);
+yy1300:
+	YYDEBUG(1300, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 0x1F) {
-		if (yych <= 0x00) goto yy1300;
-		if (yych == '\t') goto yy1300;
+		if (yych <= 0x00) goto yy1302;
+		if (yych == '\t') goto yy1302;
 		goto yy56;
 	} else {
-		if (yych <= ' ') goto yy1300;
+		if (yych <= ' ') goto yy1302;
 		if (yych != '.') goto yy56;
 	}
-	YYDEBUG(1299, *YYCURSOR);
+	YYDEBUG(1301, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '\t') {
-		if (yych <= 0x00) goto yy1300;
+		if (yych <= 0x00) goto yy1302;
 		if (yych <= 0x08) goto yy56;
 	} else {
 		if (yych != ' ') goto yy56;
 	}
-yy1300:
-	YYDEBUG(1300, *YYCURSOR);
+yy1302:
+	YYDEBUG(1302, *YYCURSOR);
 	yych = *++YYCURSOR;
-	goto yy1292;
-yy1301:
-	YYDEBUG(1301, *YYCURSOR);
+	goto yy1294;
+yy1303:
+	YYDEBUG(1303, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'C') {
@@ -19231,7 +19295,7 @@ yy1301:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'B') goto yy141;
-			goto yy1285;
+			goto yy1287;
 		}
 	} else {
 		if (yych <= '`') {
@@ -19239,13 +19303,13 @@ yy1301:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'c') goto yy1302;
+			if (yych == 'c') goto yy1304;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1302:
-	YYDEBUG(1302, *YYCURSOR);
+yy1304:
+	YYDEBUG(1304, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'K') {
@@ -19256,7 +19320,7 @@ yy1302:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'J') goto yy142;
-			goto yy1286;
+			goto yy1288;
 		}
 	} else {
 		if (yych <= '`') {
@@ -19264,18 +19328,18 @@ yy1302:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'k') goto yy1303;
+			if (yych == 'k') goto yy1305;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1303:
-	YYDEBUG(1303, *YYCURSOR);
+yy1305:
+	YYDEBUG(1305, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
 		if (yych <= '(') {
-			if (yych == ' ') goto yy1287;
+			if (yych == ' ') goto yy1289;
 			goto yy3;
 		} else {
 			if (yych <= ')') goto yy139;
@@ -19294,8 +19358,8 @@ yy1303:
 			goto yy3;
 		}
 	}
-yy1304:
-	YYDEBUG(1304, *YYCURSOR);
+yy1306:
+	YYDEBUG(1306, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= ')') {
@@ -19311,13 +19375,13 @@ yy1304:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 's') goto yy1305;
+			if (yych <= 's') goto yy1307;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1305:
-	YYDEBUG(1305, *YYCURSOR);
+yy1307:
+	YYDEBUG(1307, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -19333,13 +19397,13 @@ yy1305:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1306;
+			if (yych <= 't') goto yy1308;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1306:
-	YYDEBUG(1306, *YYCURSOR);
+yy1308:
+	YYDEBUG(1308, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '(') {
@@ -19360,34 +19424,34 @@ yy1306:
 			goto yy3;
 		}
 	}
-yy1307:
-	YYDEBUG(1307, *YYCURSOR);
+yy1309:
+	YYDEBUG(1309, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'D') goto yy1308;
+	if (yych == 'D') goto yy1310;
 	if (yych != 'd') goto yy1105;
-yy1308:
-	YYDEBUG(1308, *YYCURSOR);
+yy1310:
+	YYDEBUG(1310, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'A') goto yy1309;
+	if (yych == 'A') goto yy1311;
 	if (yych != 'a') goto yy56;
-yy1309:
-	YYDEBUG(1309, *YYCURSOR);
+yy1311:
+	YYDEBUG(1311, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'Y') goto yy1310;
+	if (yych == 'Y') goto yy1312;
 	if (yych != 'y') goto yy56;
-yy1310:
-	YYDEBUG(1310, *YYCURSOR);
+yy1312:
+	YYDEBUG(1312, *YYCURSOR);
 	yyaccept = 29;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
-		if (yych == ' ') goto yy1312;
+		if (yych == ' ') goto yy1314;
 	} else {
 		if (yych <= 'S') goto yy1142;
 		if (yych == 's') goto yy1142;
 	}
-yy1311:
-	YYDEBUG(1311, *YYCURSOR);
-#line 1050 "ext/date/lib/parse_date.re"
+yy1313:
+	YYDEBUG(1313, *YYCURSOR);
+#line 1051 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("firstdayof | lastdayof");
 		TIMELIB_INIT;
@@ -19403,23 +19467,23 @@ yy1311:
 		TIMELIB_DEINIT;
 		return TIMELIB_LF_DAY_OF_MONTH;
 	}
-#line 19407 "ext/date/lib/parse_date.c"
-yy1312:
-	YYDEBUG(1312, *YYCURSOR);
-	yych = *++YYCURSOR;
-	if (yych == 'O') goto yy1313;
-	if (yych != 'o') goto yy56;
-yy1313:
-	YYDEBUG(1313, *YYCURSOR);
-	yych = *++YYCURSOR;
-	if (yych == 'F') goto yy1314;
-	if (yych != 'f') goto yy56;
+#line 19471 "ext/date/lib/parse_date.c"
 yy1314:
 	YYDEBUG(1314, *YYCURSOR);
 	yych = *++YYCURSOR;
-	goto yy1311;
+	if (yych == 'O') goto yy1315;
+	if (yych != 'o') goto yy56;
 yy1315:
 	YYDEBUG(1315, *YYCURSOR);
+	yych = *++YYCURSOR;
+	if (yych == 'F') goto yy1316;
+	if (yych != 'f') goto yy56;
+yy1316:
+	YYDEBUG(1316, *YYCURSOR);
+	yych = *++YYCURSOR;
+	goto yy1313;
+yy1317:
+	YYDEBUG(1317, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -19430,7 +19494,7 @@ yy1315:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'R') goto yy141;
-			goto yy1305;
+			goto yy1307;
 		}
 	} else {
 		if (yych <= '`') {
@@ -19438,13 +19502,13 @@ yy1315:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 's') goto yy1316;
+			if (yych == 's') goto yy1318;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1316:
-	YYDEBUG(1316, *YYCURSOR);
+yy1318:
+	YYDEBUG(1318, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -19455,7 +19519,7 @@ yy1316:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1306;
+			goto yy1308;
 		}
 	} else {
 		if (yych <= '`') {
@@ -19463,13 +19527,13 @@ yy1316:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1317;
+			if (yych == 't') goto yy1319;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1317:
-	YYDEBUG(1317, *YYCURSOR);
+yy1319:
+	YYDEBUG(1319, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '.') {
@@ -19477,7 +19541,7 @@ yy1317:
 			if (yych == '\t') goto yy1104;
 			goto yy3;
 		} else {
-			if (yych <= ' ') goto yy1307;
+			if (yych <= ' ') goto yy1309;
 			if (yych == ')') goto yy139;
 			goto yy3;
 		}
@@ -19494,8 +19558,8 @@ yy1317:
 			goto yy3;
 		}
 	}
-yy1318:
-	YYDEBUG(1318, *YYCURSOR);
+yy1320:
+	YYDEBUG(1320, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'B') {
 		if (yych <= ')') {
@@ -19504,7 +19568,7 @@ yy1318:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'A') goto yy141;
-			goto yy1354;
+			goto yy1356;
 		}
 	} else {
 		if (yych <= 'a') {
@@ -19512,37 +19576,37 @@ yy1318:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'b') goto yy1354;
+			if (yych <= 'b') goto yy1356;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1319:
-	YYDEBUG(1319, *YYCURSOR);
+yy1321:
+	YYDEBUG(1321, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= '@') {
 			if (yych == ')') goto yy139;
 			goto yy3;
 		} else {
-			if (yych == 'F') goto yy1344;
+			if (yych == 'F') goto yy1346;
 			if (yych <= 'Q') goto yy141;
-			goto yy1343;
+			goto yy1345;
 		}
 	} else {
 		if (yych <= 'f') {
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'e') goto yy141;
-			goto yy1344;
+			goto yy1346;
 		} else {
-			if (yych == 'r') goto yy1343;
+			if (yych == 'r') goto yy1345;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1320:
-	YYDEBUG(1320, *YYCURSOR);
+yy1322:
+	YYDEBUG(1322, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'U') {
 		if (yych <= ')') {
@@ -19551,7 +19615,7 @@ yy1320:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'T') goto yy141;
-			goto yy1340;
+			goto yy1342;
 		}
 	} else {
 		if (yych <= 't') {
@@ -19559,20 +19623,20 @@ yy1320:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'u') goto yy1340;
+			if (yych <= 'u') goto yy1342;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1321:
-	YYDEBUG(1321, *YYCURSOR);
+yy1323:
+	YYDEBUG(1323, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'O') {
 		if (yych <= '@') {
 			if (yych == ')') goto yy139;
 			goto yy3;
 		} else {
-			if (yych == 'I') goto yy1323;
+			if (yych == 'I') goto yy1325;
 			if (yych <= 'N') goto yy141;
 		}
 	} else {
@@ -19580,15 +19644,15 @@ yy1321:
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'h') goto yy141;
-			goto yy1323;
+			goto yy1325;
 		} else {
-			if (yych == 'o') goto yy1322;
+			if (yych == 'o') goto yy1324;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1322:
-	YYDEBUG(1322, *YYCURSOR);
+yy1324:
+	YYDEBUG(1324, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -19597,7 +19661,7 @@ yy1322:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy142;
-			goto yy1326;
+			goto yy1328;
 		}
 	} else {
 		if (yych <= 'm') {
@@ -19605,13 +19669,13 @@ yy1322:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'n') goto yy1326;
+			if (yych <= 'n') goto yy1328;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1323:
-	YYDEBUG(1323, *YYCURSOR);
+yy1325:
+	YYDEBUG(1325, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -19627,13 +19691,13 @@ yy1323:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 'd') goto yy1324;
+			if (yych <= 'd') goto yy1326;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1324:
-	YYDEBUG(1324, *YYCURSOR);
+yy1326:
+	YYDEBUG(1326, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
@@ -19643,13 +19707,13 @@ yy1324:
 			if (yych <= 'Z') goto yy143;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1325;
+			if (yych <= 'a') goto yy1327;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1325:
-	YYDEBUG(1325, *YYCURSOR);
+yy1327:
+	YYDEBUG(1327, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'Y') {
 		if (yych <= ')') {
@@ -19658,7 +19722,7 @@ yy1325:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy144;
-			goto yy1233;
+			goto yy1235;
 		}
 	} else {
 		if (yych <= 'x') {
@@ -19666,13 +19730,13 @@ yy1325:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'y') goto yy1233;
+			if (yych <= 'y') goto yy1235;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1326:
-	YYDEBUG(1326, *YYCURSOR);
+yy1328:
+	YYDEBUG(1328, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -19688,17 +19752,17 @@ yy1326:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 't') goto yy1327;
+			if (yych <= 't') goto yy1329;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1327:
-	YYDEBUG(1327, *YYCURSOR);
+yy1329:
+	YYDEBUG(1329, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= ')') {
-		if (yych == ' ') goto yy1328;
+		if (yych == ' ') goto yy1330;
 		if (yych <= '(') goto yy3;
 		goto yy139;
 	} else {
@@ -19711,101 +19775,101 @@ yy1327:
 			goto yy3;
 		}
 	}
-yy1328:
-	YYDEBUG(1328, *YYCURSOR);
+yy1330:
+	YYDEBUG(1330, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'O') goto yy1329;
+	if (yych == 'O') goto yy1331;
 	if (yych != 'o') goto yy56;
-yy1329:
-	YYDEBUG(1329, *YYCURSOR);
+yy1331:
+	YYDEBUG(1331, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'F') goto yy1330;
+	if (yych == 'F') goto yy1332;
 	if (yych != 'f') goto yy56;
-yy1330:
-	YYDEBUG(1330, *YYCURSOR);
+yy1332:
+	YYDEBUG(1332, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych != ' ') goto yy56;
-	YYDEBUG(1331, *YYCURSOR);
+	YYDEBUG(1333, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') goto yy56;
-	if (yych <= '1') goto yy1332;
-	if (yych <= '2') goto yy1333;
-	if (yych <= '9') goto yy1334;
+	if (yych <= '1') goto yy1334;
+	if (yych <= '2') goto yy1335;
+	if (yych <= '9') goto yy1336;
 	goto yy56;
-yy1332:
-	YYDEBUG(1332, *YYCURSOR);
+yy1334:
+	YYDEBUG(1334, *YYCURSOR);
 	yyaccept = 28;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '/') goto yy1335;
-	if (yych <= '9') goto yy1334;
-	goto yy1335;
-yy1333:
-	YYDEBUG(1333, *YYCURSOR);
+	if (yych <= '/') goto yy1337;
+	if (yych <= '9') goto yy1336;
+	goto yy1337;
+yy1335:
+	YYDEBUG(1335, *YYCURSOR);
 	yyaccept = 28;
 	yych = *(YYMARKER = ++YYCURSOR);
-	if (yych <= '/') goto yy1335;
-	if (yych >= '5') goto yy1335;
-yy1334:
-	YYDEBUG(1334, *YYCURSOR);
+	if (yych <= '/') goto yy1337;
+	if (yych >= '5') goto yy1337;
+yy1336:
+	YYDEBUG(1336, *YYCURSOR);
 	yyaccept = 28;
 	YYMARKER = ++YYCURSOR;
 	if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5);
 	yych = *YYCURSOR;
-yy1335:
-	YYDEBUG(1335, *YYCURSOR);
+yy1337:
+	YYDEBUG(1337, *YYCURSOR);
 	if (yych <= 'A') {
 		if (yych <= 0x1F) {
-			if (yych == '\t') goto yy1334;
-			goto yy1292;
+			if (yych == '\t') goto yy1336;
+			goto yy1294;
 		} else {
-			if (yych <= ' ') goto yy1334;
-			if (yych <= '@') goto yy1292;
+			if (yych <= ' ') goto yy1336;
+			if (yych <= '@') goto yy1294;
 		}
 	} else {
 		if (yych <= '`') {
-			if (yych != 'P') goto yy1292;
+			if (yych != 'P') goto yy1294;
 		} else {
-			if (yych <= 'a') goto yy1336;
-			if (yych != 'p') goto yy1292;
+			if (yych <= 'a') goto yy1338;
+			if (yych != 'p') goto yy1294;
 		}
 	}
-yy1336:
-	YYDEBUG(1336, *YYCURSOR);
+yy1338:
+	YYDEBUG(1338, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'L') {
 		if (yych != '.') goto yy56;
 	} else {
-		if (yych <= 'M') goto yy1338;
-		if (yych == 'm') goto yy1338;
+		if (yych <= 'M') goto yy1340;
+		if (yych == 'm') goto yy1340;
 		goto yy56;
 	}
-	YYDEBUG(1337, *YYCURSOR);
+	YYDEBUG(1339, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'M') goto yy1338;
+	if (yych == 'M') goto yy1340;
 	if (yych != 'm') goto yy56;
-yy1338:
-	YYDEBUG(1338, *YYCURSOR);
+yy1340:
+	YYDEBUG(1340, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 0x1F) {
-		if (yych <= 0x00) goto yy1300;
-		if (yych == '\t') goto yy1300;
+		if (yych <= 0x00) goto yy1302;
+		if (yych == '\t') goto yy1302;
 		goto yy56;
 	} else {
-		if (yych <= ' ') goto yy1300;
+		if (yych <= ' ') goto yy1302;
 		if (yych != '.') goto yy56;
 	}
-	YYDEBUG(1339, *YYCURSOR);
+	YYDEBUG(1341, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '\t') {
-		if (yych <= 0x00) goto yy1300;
+		if (yych <= 0x00) goto yy1302;
 		if (yych <= 0x08) goto yy56;
-		goto yy1300;
+		goto yy1302;
 	} else {
-		if (yych == ' ') goto yy1300;
+		if (yych == ' ') goto yy1302;
 		goto yy56;
 	}
-yy1340:
-	YYDEBUG(1340, *YYCURSOR);
+yy1342:
+	YYDEBUG(1342, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -19821,13 +19885,13 @@ yy1340:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'r') goto yy1341;
+			if (yych <= 'r') goto yy1343;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1341:
-	YYDEBUG(1341, *YYCURSOR);
+yy1343:
+	YYDEBUG(1343, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -19843,13 +19907,13 @@ yy1341:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 't') goto yy1342;
+			if (yych <= 't') goto yy1344;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1342:
-	YYDEBUG(1342, *YYCURSOR);
+yy1344:
+	YYDEBUG(1344, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -19858,7 +19922,7 @@ yy1342:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy144;
-			goto yy1254;
+			goto yy1215;
 		}
 	} else {
 		if (yych <= 'g') {
@@ -19866,13 +19930,13 @@ yy1342:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'h') goto yy1254;
+			if (yych <= 'h') goto yy1215;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1343:
-	YYDEBUG(1343, *YYCURSOR);
+yy1345:
+	YYDEBUG(1345, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= ')') {
@@ -19881,7 +19945,7 @@ yy1343:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'R') goto yy142;
-			goto yy1346;
+			goto yy1348;
 		}
 	} else {
 		if (yych <= 'r') {
@@ -19889,13 +19953,13 @@ yy1343:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 's') goto yy1346;
+			if (yych <= 's') goto yy1348;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1344:
-	YYDEBUG(1344, *YYCURSOR);
+yy1346:
+	YYDEBUG(1346, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -19911,13 +19975,13 @@ yy1344:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1345;
+			if (yych <= 't') goto yy1347;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1345:
-	YYDEBUG(1345, *YYCURSOR);
+yy1347:
+	YYDEBUG(1347, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -19926,7 +19990,7 @@ yy1345:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= 'g') {
@@ -19934,13 +19998,13 @@ yy1345:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'h') goto yy1214;
+			if (yych <= 'h') goto yy1238;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1346:
-	YYDEBUG(1346, *YYCURSOR);
+yy1348:
+	YYDEBUG(1348, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -19956,13 +20020,13 @@ yy1346:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 't') goto yy1347;
+			if (yych <= 't') goto yy1349;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1347:
-	YYDEBUG(1347, *YYCURSOR);
+yy1349:
+	YYDEBUG(1349, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '(') {
@@ -19983,44 +20047,44 @@ yy1347:
 			goto yy3;
 		}
 	}
-yy1348:
-	YYDEBUG(1348, *YYCURSOR);
+yy1350:
+	YYDEBUG(1350, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'D') goto yy1349;
+	if (yych == 'D') goto yy1351;
 	if (yych != 'd') goto yy1207;
-yy1349:
-	YYDEBUG(1349, *YYCURSOR);
+yy1351:
+	YYDEBUG(1351, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'A') goto yy1350;
+	if (yych == 'A') goto yy1352;
 	if (yych != 'a') goto yy56;
-yy1350:
-	YYDEBUG(1350, *YYCURSOR);
+yy1352:
+	YYDEBUG(1352, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'Y') goto yy1351;
+	if (yych == 'Y') goto yy1353;
 	if (yych != 'y') goto yy56;
-yy1351:
-	YYDEBUG(1351, *YYCURSOR);
+yy1353:
+	YYDEBUG(1353, *YYCURSOR);
 	yyaccept = 29;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
-		if (yych != ' ') goto yy1311;
+		if (yych != ' ') goto yy1313;
 	} else {
 		if (yych <= 'S') goto yy1142;
 		if (yych == 's') goto yy1142;
-		goto yy1311;
+		goto yy1313;
 	}
-	YYDEBUG(1352, *YYCURSOR);
+	YYDEBUG(1354, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'O') goto yy1353;
+	if (yych == 'O') goto yy1355;
 	if (yych != 'o') goto yy56;
-yy1353:
-	YYDEBUG(1353, *YYCURSOR);
+yy1355:
+	YYDEBUG(1355, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'F') goto yy1314;
-	if (yych == 'f') goto yy1314;
+	if (yych == 'F') goto yy1316;
+	if (yych == 'f') goto yy1316;
 	goto yy56;
-yy1354:
-	YYDEBUG(1354, *YYCURSOR);
+yy1356:
+	YYDEBUG(1356, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -20055,14 +20119,14 @@ yy1354:
 				if (yych <= '`') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'r') goto yy1355;
+				if (yych <= 'r') goto yy1357;
 				if (yych <= 'z') goto yy142;
 				goto yy194;
 			}
 		}
 	}
-yy1355:
-	YYDEBUG(1355, *YYCURSOR);
+yy1357:
+	YYDEBUG(1357, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'U') {
 		if (yych <= ')') {
@@ -20078,13 +20142,13 @@ yy1355:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'u') goto yy1356;
+			if (yych <= 'u') goto yy1358;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1356:
-	YYDEBUG(1356, *YYCURSOR);
+yy1358:
+	YYDEBUG(1358, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
@@ -20094,30 +20158,30 @@ yy1356:
 			if (yych <= 'Z') goto yy144;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1357;
+			if (yych <= 'a') goto yy1359;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1357:
-	YYDEBUG(1357, *YYCURSOR);
+yy1359:
+	YYDEBUG(1359, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Q') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'R') goto yy1358;
+		if (yych <= 'R') goto yy1360;
 		if (yych != 'r') goto yy3;
 	}
-yy1358:
-	YYDEBUG(1358, *YYCURSOR);
+yy1360:
+	YYDEBUG(1360, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy206;
 	if (yych == 'y') goto yy206;
 	goto yy56;
-yy1359:
-	YYDEBUG(1359, *YYCURSOR);
+yy1361:
+	YYDEBUG(1361, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'B') {
@@ -20128,7 +20192,7 @@ yy1359:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'A') goto yy141;
-			goto yy1354;
+			goto yy1356;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20136,13 +20200,13 @@ yy1359:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'b') goto yy1377;
+			if (yych == 'b') goto yy1379;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1360:
-	YYDEBUG(1360, *YYCURSOR);
+yy1362:
+	YYDEBUG(1362, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -20155,9 +20219,9 @@ yy1360:
 				if (yych <= '@') goto yy3;
 				goto yy141;
 			} else {
-				if (yych <= 'F') goto yy1344;
+				if (yych <= 'F') goto yy1346;
 				if (yych <= 'Q') goto yy141;
-				goto yy1343;
+				goto yy1345;
 			}
 		}
 	} else {
@@ -20172,17 +20236,17 @@ yy1360:
 			}
 		} else {
 			if (yych <= 'q') {
-				if (yych <= 'f') goto yy1373;
+				if (yych <= 'f') goto yy1375;
 				goto yy146;
 			} else {
-				if (yych <= 'r') goto yy1372;
+				if (yych <= 'r') goto yy1374;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1361:
-	YYDEBUG(1361, *YYCURSOR);
+yy1363:
+	YYDEBUG(1363, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'U') {
@@ -20193,7 +20257,7 @@ yy1361:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'T') goto yy141;
-			goto yy1340;
+			goto yy1342;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20201,13 +20265,13 @@ yy1361:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'u') goto yy1369;
+			if (yych == 'u') goto yy1371;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1362:
-	YYDEBUG(1362, *YYCURSOR);
+yy1364:
+	YYDEBUG(1364, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'O') {
@@ -20220,9 +20284,9 @@ yy1362:
 				if (yych <= '@') goto yy3;
 				goto yy141;
 			} else {
-				if (yych <= 'I') goto yy1323;
+				if (yych <= 'I') goto yy1325;
 				if (yych <= 'N') goto yy141;
-				goto yy1322;
+				goto yy1324;
 			}
 		}
 	} else {
@@ -20237,17 +20301,17 @@ yy1362:
 			}
 		} else {
 			if (yych <= 'n') {
-				if (yych <= 'i') goto yy1364;
+				if (yych <= 'i') goto yy1366;
 				goto yy146;
 			} else {
-				if (yych <= 'o') goto yy1363;
+				if (yych <= 'o') goto yy1365;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1363:
-	YYDEBUG(1363, *YYCURSOR);
+yy1365:
+	YYDEBUG(1365, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -20258,7 +20322,7 @@ yy1363:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy142;
-			goto yy1326;
+			goto yy1328;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20266,13 +20330,13 @@ yy1363:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1367;
+			if (yych == 'n') goto yy1369;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1364:
-	YYDEBUG(1364, *YYCURSOR);
+yy1366:
+	YYDEBUG(1366, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -20283,7 +20347,7 @@ yy1364:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'C') goto yy142;
-			goto yy1324;
+			goto yy1326;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20291,13 +20355,13 @@ yy1364:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 'd') goto yy1365;
+			if (yych == 'd') goto yy1367;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1365:
-	YYDEBUG(1365, *YYCURSOR);
+yy1367:
+	YYDEBUG(1367, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -20307,7 +20371,7 @@ yy1365:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1325;
+			goto yy1327;
 		}
 	} else {
 		if (yych <= '_') {
@@ -20316,13 +20380,13 @@ yy1365:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1366;
+			if (yych <= 'a') goto yy1368;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1366:
-	YYDEBUG(1366, *YYCURSOR);
+yy1368:
+	YYDEBUG(1368, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -20333,7 +20397,7 @@ yy1366:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy144;
-			goto yy1233;
+			goto yy1235;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20341,13 +20405,13 @@ yy1366:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'y') goto yy1262;
+			if (yych == 'y') goto yy1264;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1367:
-	YYDEBUG(1367, *YYCURSOR);
+yy1369:
+	YYDEBUG(1369, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -20358,7 +20422,7 @@ yy1367:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy143;
-			goto yy1327;
+			goto yy1329;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20366,18 +20430,18 @@ yy1367:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1368;
+			if (yych == 't') goto yy1370;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1368:
-	YYDEBUG(1368, *YYCURSOR);
+yy1370:
+	YYDEBUG(1370, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
 		if (yych <= '(') {
-			if (yych == ' ') goto yy1328;
+			if (yych == ' ') goto yy1330;
 			goto yy3;
 		} else {
 			if (yych <= ')') goto yy139;
@@ -20396,8 +20460,8 @@ yy1368:
 			goto yy3;
 		}
 	}
-yy1369:
-	YYDEBUG(1369, *YYCURSOR);
+yy1371:
+	YYDEBUG(1371, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -20408,7 +20472,7 @@ yy1369:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy142;
-			goto yy1341;
+			goto yy1343;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20416,13 +20480,13 @@ yy1369:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1370;
+			if (yych == 'r') goto yy1372;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1370:
-	YYDEBUG(1370, *YYCURSOR);
+yy1372:
+	YYDEBUG(1372, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -20433,7 +20497,7 @@ yy1370:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy143;
-			goto yy1342;
+			goto yy1344;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20441,13 +20505,13 @@ yy1370:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1371;
+			if (yych == 't') goto yy1373;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1371:
-	YYDEBUG(1371, *YYCURSOR);
+yy1373:
+	YYDEBUG(1373, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -20458,7 +20522,7 @@ yy1371:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy144;
-			goto yy1254;
+			goto yy1215;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20466,13 +20530,13 @@ yy1371:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1283;
+			if (yych == 'h') goto yy1227;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1372:
-	YYDEBUG(1372, *YYCURSOR);
+yy1374:
+	YYDEBUG(1374, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -20483,7 +20547,7 @@ yy1372:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'R') goto yy142;
-			goto yy1346;
+			goto yy1348;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20491,13 +20555,13 @@ yy1372:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 's') goto yy1375;
+			if (yych == 's') goto yy1377;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1373:
-	YYDEBUG(1373, *YYCURSOR);
+yy1375:
+	YYDEBUG(1375, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -20508,7 +20572,7 @@ yy1373:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1345;
+			goto yy1347;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20516,13 +20580,13 @@ yy1373:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1374;
+			if (yych == 't') goto yy1376;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1374:
-	YYDEBUG(1374, *YYCURSOR);
+yy1376:
+	YYDEBUG(1376, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -20533,7 +20597,7 @@ yy1374:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20541,13 +20605,13 @@ yy1374:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1225;
+			if (yych == 'h') goto yy1267;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1375:
-	YYDEBUG(1375, *YYCURSOR);
+yy1377:
+	YYDEBUG(1377, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -20558,7 +20622,7 @@ yy1375:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy143;
-			goto yy1347;
+			goto yy1349;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20566,13 +20630,13 @@ yy1375:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1376;
+			if (yych == 't') goto yy1378;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1376:
-	YYDEBUG(1376, *YYCURSOR);
+yy1378:
+	YYDEBUG(1378, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '.') {
@@ -20580,7 +20644,7 @@ yy1376:
 			if (yych == '\t') goto yy1206;
 			goto yy3;
 		} else {
-			if (yych <= ' ') goto yy1348;
+			if (yych <= ' ') goto yy1350;
 			if (yych == ')') goto yy139;
 			goto yy3;
 		}
@@ -20597,8 +20661,8 @@ yy1376:
 			goto yy3;
 		}
 	}
-yy1377:
-	YYDEBUG(1377, *YYCURSOR);
+yy1379:
+	YYDEBUG(1379, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '9') {
@@ -20626,7 +20690,7 @@ yy1377:
 				if (yych <= '@') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'R') goto yy1355;
+				if (yych <= 'R') goto yy1357;
 				if (yych <= 'Z') goto yy142;
 				goto yy194;
 			}
@@ -20636,14 +20700,14 @@ yy1377:
 				if (yych <= '`') goto yy194;
 				goto yy151;
 			} else {
-				if (yych <= 'r') goto yy1378;
+				if (yych <= 'r') goto yy1380;
 				if (yych <= 'z') goto yy151;
 				goto yy194;
 			}
 		}
 	}
-yy1378:
-	YYDEBUG(1378, *YYCURSOR);
+yy1380:
+	YYDEBUG(1380, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'U') {
@@ -20654,7 +20718,7 @@ yy1378:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'T') goto yy143;
-			goto yy1356;
+			goto yy1358;
 		}
 	} else {
 		if (yych <= '`') {
@@ -20662,13 +20726,13 @@ yy1378:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'u') goto yy1379;
+			if (yych == 'u') goto yy1381;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1379:
-	YYDEBUG(1379, *YYCURSOR);
+yy1381:
+	YYDEBUG(1381, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -20678,7 +20742,7 @@ yy1379:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1357;
+			goto yy1359;
 		}
 	} else {
 		if (yych <= '_') {
@@ -20687,13 +20751,13 @@ yy1379:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1380;
+			if (yych <= 'a') goto yy1382;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1380:
-	YYDEBUG(1380, *YYCURSOR);
+yy1382:
+	YYDEBUG(1382, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -20703,40 +20767,40 @@ yy1380:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'Q') goto yy3;
-			goto yy1358;
+			goto yy1360;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1381;
+			if (yych == 'r') goto yy1383;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1381:
-	YYDEBUG(1381, *YYCURSOR);
+yy1383:
+	YYDEBUG(1383, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy206;
 	if (yych == 'y') goto yy377;
 	goto yy155;
-yy1382:
-	YYDEBUG(1382, *YYCURSOR);
+yy1384:
+	YYDEBUG(1384, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') goto yy56;
 	if (yych >= ':') goto yy56;
-yy1383:
-	YYDEBUG(1383, *YYCURSOR);
+yy1385:
+	YYDEBUG(1385, *YYCURSOR);
 	++YYCURSOR;
 	if (YYLIMIT <= YYCURSOR) YYFILL(1);
 	yych = *YYCURSOR;
-	YYDEBUG(1384, *YYCURSOR);
-	if (yych <= '/') goto yy1385;
-	if (yych <= '9') goto yy1383;
-yy1385:
-	YYDEBUG(1385, *YYCURSOR);
-#line 1025 "ext/date/lib/parse_date.re"
+	YYDEBUG(1386, *YYCURSOR);
+	if (yych <= '/') goto yy1387;
+	if (yych <= '9') goto yy1385;
+yy1387:
+	YYDEBUG(1387, *YYCURSOR);
+#line 1026 "ext/date/lib/parse_date.re"
 	{
 		timelib_ull i;
 
@@ -20760,9 +20824,9 @@ yy1385:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 20764 "ext/date/lib/parse_date.c"
-yy1386:
-	YYDEBUG(1386, *YYCURSOR);
+#line 20828 "ext/date/lib/parse_date.c"
+yy1388:
+	YYDEBUG(1388, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -20771,7 +20835,7 @@ yy1386:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy141;
-			goto yy1427;
+			goto yy1429;
 		}
 	} else {
 		if (yych <= 'm') {
@@ -20779,61 +20843,61 @@ yy1386:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'n') goto yy1427;
+			if (yych <= 'n') goto yy1429;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1387:
-	YYDEBUG(1387, *YYCURSOR);
+yy1389:
+	YYDEBUG(1389, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'U') {
 		if (yych <= '@') {
 			if (yych == ')') goto yy139;
 			goto yy3;
 		} else {
-			if (yych == 'I') goto yy1419;
+			if (yych == 'I') goto yy1421;
 			if (yych <= 'T') goto yy141;
-			goto yy1420;
+			goto yy1422;
 		}
 	} else {
 		if (yych <= 'i') {
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'h') goto yy141;
-			goto yy1419;
+			goto yy1421;
 		} else {
-			if (yych == 'u') goto yy1420;
+			if (yych == 'u') goto yy1422;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1388:
-	YYDEBUG(1388, *YYCURSOR);
+yy1390:
+	YYDEBUG(1390, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'M') {
 		if (yych <= '@') {
 			if (yych == ')') goto yy139;
 			goto yy3;
 		} else {
-			if (yych == 'D') goto yy1408;
+			if (yych == 'D') goto yy1410;
 			if (yych <= 'L') goto yy141;
-			goto yy1409;
+			goto yy1411;
 		}
 	} else {
 		if (yych <= 'd') {
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'c') goto yy141;
-			goto yy1408;
+			goto yy1410;
 		} else {
-			if (yych == 'm') goto yy1409;
+			if (yych == 'm') goto yy1411;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1389:
-	YYDEBUG(1389, *YYCURSOR);
+yy1391:
+	YYDEBUG(1391, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'E') {
 		if (yych <= ')') {
@@ -20842,7 +20906,7 @@ yy1389:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy141;
-			goto yy1404;
+			goto yy1406;
 		}
 	} else {
 		if (yych <= 'd') {
@@ -20850,13 +20914,13 @@ yy1389:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'e') goto yy1404;
+			if (yych <= 'e') goto yy1406;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1390:
-	YYDEBUG(1390, *YYCURSOR);
+yy1392:
+	YYDEBUG(1392, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'E') {
 		if (yych <= ')') {
@@ -20865,7 +20929,7 @@ yy1390:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy141;
-			goto yy1400;
+			goto yy1402;
 		}
 	} else {
 		if (yych <= 'd') {
@@ -20873,78 +20937,78 @@ yy1390:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'e') goto yy1400;
+			if (yych <= 'e') goto yy1402;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1391:
-	YYDEBUG(1391, *YYCURSOR);
+yy1393:
+	YYDEBUG(1393, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') {
 		if (yych == '.') goto yy1064;
 		goto yy56;
 	} else {
-		if (yych <= '9') goto yy1394;
+		if (yych <= '9') goto yy1396;
 		if (yych <= ':') goto yy1064;
 		goto yy56;
 	}
-yy1392:
-	YYDEBUG(1392, *YYCURSOR);
+yy1394:
+	YYDEBUG(1394, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') {
 		if (yych == '.') goto yy1064;
 		goto yy56;
 	} else {
-		if (yych <= '4') goto yy1394;
+		if (yych <= '4') goto yy1396;
 		if (yych == ':') goto yy1064;
 		goto yy56;
 	}
-yy1393:
-	YYDEBUG(1393, *YYCURSOR);
+yy1395:
+	YYDEBUG(1395, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == '.') goto yy1064;
 	if (yych == ':') goto yy1064;
 	goto yy56;
-yy1394:
-	YYDEBUG(1394, *YYCURSOR);
+yy1396:
+	YYDEBUG(1396, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') {
 		if (yych == '.') goto yy1064;
 		goto yy56;
 	} else {
-		if (yych <= '5') goto yy1395;
+		if (yych <= '5') goto yy1397;
 		if (yych == ':') goto yy1064;
 		goto yy56;
 	}
-yy1395:
-	YYDEBUG(1395, *YYCURSOR);
+yy1397:
+	YYDEBUG(1397, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') goto yy56;
 	if (yych >= ':') goto yy56;
-	YYDEBUG(1396, *YYCURSOR);
+	YYDEBUG(1398, *YYCURSOR);
 	yyaccept = 24;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') goto yy1067;
-	if (yych <= '5') goto yy1397;
-	if (yych <= '6') goto yy1398;
+	if (yych <= '5') goto yy1399;
+	if (yych <= '6') goto yy1400;
 	goto yy1067;
-yy1397:
-	YYDEBUG(1397, *YYCURSOR);
+yy1399:
+	YYDEBUG(1399, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= '/') goto yy56;
-	if (yych <= '9') goto yy1399;
+	if (yych <= '9') goto yy1401;
 	goto yy56;
-yy1398:
-	YYDEBUG(1398, *YYCURSOR);
+yy1400:
+	YYDEBUG(1400, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych != '0') goto yy56;
-yy1399:
-	YYDEBUG(1399, *YYCURSOR);
+yy1401:
+	YYDEBUG(1401, *YYCURSOR);
 	yych = *++YYCURSOR;
 	goto yy1075;
-yy1400:
-	YYDEBUG(1400, *YYCURSOR);
+yy1402:
+	YYDEBUG(1402, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'L') {
 		if (yych <= ')') {
@@ -20960,13 +21024,13 @@ yy1400:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'l') goto yy1401;
+			if (yych <= 'l') goto yy1403;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1401:
-	YYDEBUG(1401, *YYCURSOR);
+yy1403:
+	YYDEBUG(1403, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'F') {
 		if (yych <= ')') {
@@ -20982,13 +21046,13 @@ yy1401:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'f') goto yy1402;
+			if (yych <= 'f') goto yy1404;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1402:
-	YYDEBUG(1402, *YYCURSOR);
+yy1404:
+	YYDEBUG(1404, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -21004,13 +21068,13 @@ yy1402:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 't') goto yy1403;
+			if (yych <= 't') goto yy1405;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1403:
-	YYDEBUG(1403, *YYCURSOR);
+yy1405:
+	YYDEBUG(1405, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'G') {
@@ -21021,8 +21085,8 @@ yy1403:
 		if (yych == 'h') goto yy1205;
 		goto yy3;
 	}
-yy1404:
-	YYDEBUG(1404, *YYCURSOR);
+yy1406:
+	YYDEBUG(1406, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= ')') {
@@ -21038,13 +21102,13 @@ yy1404:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 's') goto yy1405;
+			if (yych <= 's') goto yy1407;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1405:
-	YYDEBUG(1405, *YYCURSOR);
+yy1407:
+	YYDEBUG(1407, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -21060,13 +21124,13 @@ yy1405:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'd') goto yy1406;
+			if (yych <= 'd') goto yy1408;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1406:
-	YYDEBUG(1406, *YYCURSOR);
+yy1408:
+	YYDEBUG(1408, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
@@ -21076,13 +21140,13 @@ yy1406:
 			if (yych <= 'Z') goto yy144;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1407;
+			if (yych <= 'a') goto yy1409;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1407:
-	YYDEBUG(1407, *YYCURSOR);
+yy1409:
+	YYDEBUG(1409, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'X') {
 		if (yych == ')') goto yy139;
@@ -21092,25 +21156,25 @@ yy1407:
 		if (yych == 'y') goto yy173;
 		goto yy3;
 	}
-yy1408:
-	YYDEBUG(1408, *YYCURSOR);
+yy1410:
+	YYDEBUG(1410, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
 		if (yych <= '@') goto yy3;
-		goto yy1416;
+		goto yy1418;
 	} else {
 		if (yych <= '`') {
 			if (yych <= 'Z') goto yy142;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1416;
+			if (yych <= 'a') goto yy1418;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1409:
-	YYDEBUG(1409, *YYCURSOR);
+yy1411:
+	YYDEBUG(1411, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'O') {
 		if (yych <= ')') {
@@ -21126,13 +21190,13 @@ yy1409:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'o') goto yy1410;
+			if (yych <= 'o') goto yy1412;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1410:
-	YYDEBUG(1410, *YYCURSOR);
+yy1412:
+	YYDEBUG(1412, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -21148,13 +21212,13 @@ yy1410:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'r') goto yy1411;
+			if (yych <= 'r') goto yy1413;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1411:
-	YYDEBUG(1411, *YYCURSOR);
+yy1413:
+	YYDEBUG(1413, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -21170,33 +21234,33 @@ yy1411:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'r') goto yy1412;
+			if (yych <= 'r') goto yy1414;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1412:
-	YYDEBUG(1412, *YYCURSOR);
+yy1414:
+	YYDEBUG(1414, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'O') goto yy1413;
+		if (yych <= 'O') goto yy1415;
 		if (yych != 'o') goto yy3;
 	}
-yy1413:
-	YYDEBUG(1413, *YYCURSOR);
+yy1415:
+	YYDEBUG(1415, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'W') goto yy1414;
+	if (yych == 'W') goto yy1416;
 	if (yych != 'w') goto yy56;
-yy1414:
-	YYDEBUG(1414, *YYCURSOR);
+yy1416:
+	YYDEBUG(1416, *YYCURSOR);
 	++YYCURSOR;
-yy1415:
-	YYDEBUG(1415, *YYCURSOR);
-#line 1013 "ext/date/lib/parse_date.re"
+yy1417:
+	YYDEBUG(1417, *YYCURSOR);
+#line 1014 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("tomorrow");
 		TIMELIB_INIT;
@@ -21207,9 +21271,9 @@ yy1415:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 21211 "ext/date/lib/parse_date.c"
-yy1416:
-	YYDEBUG(1416, *YYCURSOR);
+#line 21275 "ext/date/lib/parse_date.c"
+yy1418:
+	YYDEBUG(1418, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'Y') {
 		if (yych <= ')') {
@@ -21225,24 +21289,24 @@ yy1416:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'y') goto yy1417;
+			if (yych <= 'y') goto yy1419;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1417:
-	YYDEBUG(1417, *YYCURSOR);
+yy1419:
+	YYDEBUG(1419, *YYCURSOR);
 	++YYCURSOR;
 	if ((yych = *YYCURSOR) <= '@') {
 		if (yych == ')') goto yy139;
 	} else {
 		if (yych <= 'Z') goto yy144;
-		if (yych <= '`') goto yy1418;
+		if (yych <= '`') goto yy1420;
 		if (yych <= 'z') goto yy144;
 	}
-yy1418:
-	YYDEBUG(1418, *YYCURSOR);
-#line 1003 "ext/date/lib/parse_date.re"
+yy1420:
+	YYDEBUG(1420, *YYCURSOR);
+#line 1004 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("midnight | today");
 		TIMELIB_INIT;
@@ -21251,9 +21315,9 @@ yy1418:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 21255 "ext/date/lib/parse_date.c"
-yy1419:
-	YYDEBUG(1419, *YYCURSOR);
+#line 21319 "ext/date/lib/parse_date.c"
+yy1421:
+	YYDEBUG(1421, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= '@') {
@@ -21261,8 +21325,8 @@ yy1419:
 			goto yy3;
 		} else {
 			if (yych <= 'Q') goto yy142;
-			if (yych <= 'R') goto yy1425;
-			goto yy1426;
+			if (yych <= 'R') goto yy1427;
+			goto yy1428;
 		}
 	} else {
 		if (yych <= 'q') {
@@ -21270,14 +21334,14 @@ yy1419:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'r') goto yy1425;
-			if (yych <= 's') goto yy1426;
+			if (yych <= 'r') goto yy1427;
+			if (yych <= 's') goto yy1428;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1420:
-	YYDEBUG(1420, *YYCURSOR);
+yy1422:
+	YYDEBUG(1422, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -21293,13 +21357,13 @@ yy1420:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 'r') goto yy1421;
+			if (yych <= 'r') goto yy1423;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1421:
-	YYDEBUG(1421, *YYCURSOR);
+yy1423:
+	YYDEBUG(1423, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= ')') {
@@ -21315,13 +21379,13 @@ yy1421:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 's') goto yy1422;
+			if (yych <= 's') goto yy1424;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1422:
-	YYDEBUG(1422, *YYCURSOR);
+yy1424:
+	YYDEBUG(1424, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -21337,30 +21401,30 @@ yy1422:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'd') goto yy1423;
+			if (yych <= 'd') goto yy1425;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1423:
-	YYDEBUG(1423, *YYCURSOR);
+yy1425:
+	YYDEBUG(1425, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '@') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'A') goto yy1424;
+		if (yych <= 'A') goto yy1426;
 		if (yych != 'a') goto yy3;
 	}
-yy1424:
-	YYDEBUG(1424, *YYCURSOR);
+yy1426:
+	YYDEBUG(1426, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy173;
 	if (yych == 'y') goto yy173;
 	goto yy56;
-yy1425:
-	YYDEBUG(1425, *YYCURSOR);
+yy1427:
+	YYDEBUG(1427, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -21369,7 +21433,7 @@ yy1425:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= 'c') {
@@ -21377,13 +21441,13 @@ yy1425:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'd') goto yy1214;
+			if (yych <= 'd') goto yy1238;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1426:
-	YYDEBUG(1426, *YYCURSOR);
+yy1428:
+	YYDEBUG(1428, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '(') {
@@ -21405,8 +21469,8 @@ yy1426:
 			goto yy3;
 		}
 	}
-yy1427:
-	YYDEBUG(1427, *YYCURSOR);
+yy1429:
+	YYDEBUG(1429, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -21422,13 +21486,13 @@ yy1427:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1428;
+			if (yych <= 't') goto yy1430;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1428:
-	YYDEBUG(1428, *YYCURSOR);
+yy1430:
+	YYDEBUG(1430, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -21437,7 +21501,7 @@ yy1428:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= 'g') {
@@ -21445,13 +21509,13 @@ yy1428:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'h') goto yy1214;
+			if (yych <= 'h') goto yy1238;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1429:
-	YYDEBUG(1429, *YYCURSOR);
+yy1431:
+	YYDEBUG(1431, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -21462,7 +21526,7 @@ yy1429:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy141;
-			goto yy1427;
+			goto yy1429;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21470,13 +21534,13 @@ yy1429:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1459;
+			if (yych == 'n') goto yy1461;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1430:
-	YYDEBUG(1430, *YYCURSOR);
+yy1432:
+	YYDEBUG(1432, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'U') {
@@ -21489,9 +21553,9 @@ yy1430:
 				if (yych <= '@') goto yy3;
 				goto yy141;
 			} else {
-				if (yych <= 'I') goto yy1419;
+				if (yych <= 'I') goto yy1421;
 				if (yych <= 'T') goto yy141;
-				goto yy1420;
+				goto yy1422;
 			}
 		}
 	} else {
@@ -21506,17 +21570,17 @@ yy1430:
 			}
 		} else {
 			if (yych <= 't') {
-				if (yych <= 'i') goto yy1451;
+				if (yych <= 'i') goto yy1453;
 				goto yy146;
 			} else {
-				if (yych <= 'u') goto yy1452;
+				if (yych <= 'u') goto yy1454;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1431:
-	YYDEBUG(1431, *YYCURSOR);
+yy1433:
+	YYDEBUG(1433, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'M') {
@@ -21529,9 +21593,9 @@ yy1431:
 				if (yych <= '@') goto yy3;
 				goto yy141;
 			} else {
-				if (yych <= 'D') goto yy1408;
+				if (yych <= 'D') goto yy1410;
 				if (yych <= 'L') goto yy141;
-				goto yy1409;
+				goto yy1411;
 			}
 		}
 	} else {
@@ -21546,17 +21610,17 @@ yy1431:
 			}
 		} else {
 			if (yych <= 'l') {
-				if (yych <= 'd') goto yy1442;
+				if (yych <= 'd') goto yy1444;
 				goto yy146;
 			} else {
-				if (yych <= 'm') goto yy1443;
+				if (yych <= 'm') goto yy1445;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1432:
-	YYDEBUG(1432, *YYCURSOR);
+yy1434:
+	YYDEBUG(1434, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -21567,7 +21631,7 @@ yy1432:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy141;
-			goto yy1404;
+			goto yy1406;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21575,13 +21639,13 @@ yy1432:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1438;
+			if (yych == 'e') goto yy1440;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1433:
-	YYDEBUG(1433, *YYCURSOR);
+yy1435:
+	YYDEBUG(1435, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -21592,7 +21656,7 @@ yy1433:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy141;
-			goto yy1400;
+			goto yy1402;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21600,13 +21664,13 @@ yy1433:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1434;
+			if (yych == 'e') goto yy1436;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1434:
-	YYDEBUG(1434, *YYCURSOR);
+yy1436:
+	YYDEBUG(1436, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'L') {
@@ -21617,7 +21681,7 @@ yy1434:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'K') goto yy142;
-			goto yy1401;
+			goto yy1403;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21625,13 +21689,13 @@ yy1434:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'l') goto yy1435;
+			if (yych == 'l') goto yy1437;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1435:
-	YYDEBUG(1435, *YYCURSOR);
+yy1437:
+	YYDEBUG(1437, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'F') {
@@ -21642,7 +21706,7 @@ yy1435:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'E') goto yy143;
-			goto yy1402;
+			goto yy1404;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21650,13 +21714,13 @@ yy1435:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'f') goto yy1436;
+			if (yych == 'f') goto yy1438;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1436:
-	YYDEBUG(1436, *YYCURSOR);
+yy1438:
+	YYDEBUG(1438, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -21667,7 +21731,7 @@ yy1436:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy144;
-			goto yy1403;
+			goto yy1405;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21675,13 +21739,13 @@ yy1436:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1437;
+			if (yych == 't') goto yy1439;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1437:
-	YYDEBUG(1437, *YYCURSOR);
+yy1439:
+	YYDEBUG(1439, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -21698,13 +21762,13 @@ yy1437:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1222;
+			if (yych == 'h') goto yy1223;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1438:
-	YYDEBUG(1438, *YYCURSOR);
+yy1440:
+	YYDEBUG(1440, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -21715,7 +21779,7 @@ yy1438:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'R') goto yy142;
-			goto yy1405;
+			goto yy1407;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21723,13 +21787,13 @@ yy1438:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 's') goto yy1439;
+			if (yych == 's') goto yy1441;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1439:
-	YYDEBUG(1439, *YYCURSOR);
+yy1441:
+	YYDEBUG(1441, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -21740,7 +21804,7 @@ yy1439:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy143;
-			goto yy1406;
+			goto yy1408;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21748,13 +21812,13 @@ yy1439:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1440;
+			if (yych == 'd') goto yy1442;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1440:
-	YYDEBUG(1440, *YYCURSOR);
+yy1442:
+	YYDEBUG(1442, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -21764,7 +21828,7 @@ yy1440:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1407;
+			goto yy1409;
 		}
 	} else {
 		if (yych <= '_') {
@@ -21773,13 +21837,13 @@ yy1440:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1441;
+			if (yych <= 'a') goto yy1443;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1441:
-	YYDEBUG(1441, *YYCURSOR);
+yy1443:
+	YYDEBUG(1443, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -21801,8 +21865,8 @@ yy1441:
 			goto yy3;
 		}
 	}
-yy1442:
-	YYDEBUG(1442, *YYCURSOR);
+yy1444:
+	YYDEBUG(1444, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -21812,7 +21876,7 @@ yy1442:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1416;
+			goto yy1418;
 		}
 	} else {
 		if (yych <= '_') {
@@ -21821,13 +21885,13 @@ yy1442:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1449;
+			if (yych <= 'a') goto yy1451;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1443:
-	YYDEBUG(1443, *YYCURSOR);
+yy1445:
+	YYDEBUG(1445, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'O') {
@@ -21838,7 +21902,7 @@ yy1443:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'N') goto yy142;
-			goto yy1410;
+			goto yy1412;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21846,13 +21910,13 @@ yy1443:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'o') goto yy1444;
+			if (yych == 'o') goto yy1446;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1444:
-	YYDEBUG(1444, *YYCURSOR);
+yy1446:
+	YYDEBUG(1446, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -21863,7 +21927,7 @@ yy1444:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy143;
-			goto yy1411;
+			goto yy1413;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21871,13 +21935,13 @@ yy1444:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1445;
+			if (yych == 'r') goto yy1447;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1445:
-	YYDEBUG(1445, *YYCURSOR);
+yy1447:
+	YYDEBUG(1447, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -21888,7 +21952,7 @@ yy1445:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy144;
-			goto yy1412;
+			goto yy1414;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21896,13 +21960,13 @@ yy1445:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1446;
+			if (yych == 'r') goto yy1448;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1446:
-	YYDEBUG(1446, *YYCURSOR);
+yy1448:
+	YYDEBUG(1448, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'O') {
@@ -21912,37 +21976,37 @@ yy1446:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'N') goto yy3;
-			goto yy1413;
+			goto yy1415;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'o') goto yy1447;
+			if (yych == 'o') goto yy1449;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1447:
-	YYDEBUG(1447, *YYCURSOR);
+yy1449:
+	YYDEBUG(1449, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'W') goto yy1414;
+	if (yych == 'W') goto yy1416;
 	if (yych != 'w') goto yy155;
-	YYDEBUG(1448, *YYCURSOR);
+	YYDEBUG(1450, *YYCURSOR);
 	yyaccept = 30;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '^') {
 		if (yych == '/') goto yy147;
-		goto yy1415;
+		goto yy1417;
 	} else {
 		if (yych <= '_') goto yy147;
-		if (yych <= '`') goto yy1415;
+		if (yych <= '`') goto yy1417;
 		if (yych <= 'z') goto yy154;
-		goto yy1415;
+		goto yy1417;
 	}
-yy1449:
-	YYDEBUG(1449, *YYCURSOR);
+yy1451:
+	YYDEBUG(1451, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -21953,7 +22017,7 @@ yy1449:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy143;
-			goto yy1417;
+			goto yy1419;
 		}
 	} else {
 		if (yych <= '`') {
@@ -21961,36 +22025,36 @@ yy1449:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'y') goto yy1450;
+			if (yych == 'y') goto yy1452;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1450:
-	YYDEBUG(1450, *YYCURSOR);
+yy1452:
+	YYDEBUG(1452, *YYCURSOR);
 	yyaccept = 31;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '@') {
 		if (yych <= ')') {
-			if (yych <= '(') goto yy1418;
+			if (yych <= '(') goto yy1420;
 			goto yy139;
 		} else {
 			if (yych == '/') goto yy147;
-			goto yy1418;
+			goto yy1420;
 		}
 	} else {
 		if (yych <= '_') {
 			if (yych <= 'Z') goto yy144;
-			if (yych <= '^') goto yy1418;
+			if (yych <= '^') goto yy1420;
 			goto yy147;
 		} else {
-			if (yych <= '`') goto yy1418;
+			if (yych <= '`') goto yy1420;
 			if (yych <= 'z') goto yy153;
-			goto yy1418;
+			goto yy1420;
 		}
 	}
-yy1451:
-	YYDEBUG(1451, *YYCURSOR);
+yy1453:
+	YYDEBUG(1453, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -22001,8 +22065,8 @@ yy1451:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy142;
-			if (yych <= 'R') goto yy1425;
-			goto yy1426;
+			if (yych <= 'R') goto yy1427;
+			goto yy1428;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22012,16 +22076,16 @@ yy1451:
 		} else {
 			if (yych <= 'r') {
 				if (yych <= 'q') goto yy151;
-				goto yy1457;
+				goto yy1459;
 			} else {
-				if (yych <= 's') goto yy1458;
+				if (yych <= 's') goto yy1460;
 				if (yych <= 'z') goto yy151;
 				goto yy3;
 			}
 		}
 	}
-yy1452:
-	YYDEBUG(1452, *YYCURSOR);
+yy1454:
+	YYDEBUG(1454, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -22032,7 +22096,7 @@ yy1452:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'Q') goto yy142;
-			goto yy1421;
+			goto yy1423;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22040,13 +22104,13 @@ yy1452:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 'r') goto yy1453;
+			if (yych == 'r') goto yy1455;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1453:
-	YYDEBUG(1453, *YYCURSOR);
+yy1455:
+	YYDEBUG(1455, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -22057,7 +22121,7 @@ yy1453:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'R') goto yy143;
-			goto yy1422;
+			goto yy1424;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22065,13 +22129,13 @@ yy1453:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 's') goto yy1454;
+			if (yych == 's') goto yy1456;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1454:
-	YYDEBUG(1454, *YYCURSOR);
+yy1456:
+	YYDEBUG(1456, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -22082,7 +22146,7 @@ yy1454:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy144;
-			goto yy1423;
+			goto yy1425;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22090,13 +22154,13 @@ yy1454:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1455;
+			if (yych == 'd') goto yy1457;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1455:
-	YYDEBUG(1455, *YYCURSOR);
+yy1457:
+	YYDEBUG(1457, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -22106,26 +22170,26 @@ yy1455:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1424;
+			goto yy1426;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1456;
+			if (yych <= 'a') goto yy1458;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1456:
-	YYDEBUG(1456, *YYCURSOR);
+yy1458:
+	YYDEBUG(1458, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'Y') goto yy173;
 	if (yych == 'y') goto yy186;
 	goto yy155;
-yy1457:
-	YYDEBUG(1457, *YYCURSOR);
+yy1459:
+	YYDEBUG(1459, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -22136,7 +22200,7 @@ yy1457:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22144,13 +22208,13 @@ yy1457:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1225;
+			if (yych == 'd') goto yy1267;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1458:
-	YYDEBUG(1458, *YYCURSOR);
+yy1460:
+	YYDEBUG(1460, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '.') {
@@ -22175,8 +22239,8 @@ yy1458:
 			goto yy3;
 		}
 	}
-yy1459:
-	YYDEBUG(1459, *YYCURSOR);
+yy1461:
+	YYDEBUG(1461, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -22187,7 +22251,7 @@ yy1459:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1428;
+			goto yy1430;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22195,13 +22259,13 @@ yy1459:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1460;
+			if (yych == 't') goto yy1462;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1460:
-	YYDEBUG(1460, *YYCURSOR);
+yy1462:
+	YYDEBUG(1462, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -22212,7 +22276,7 @@ yy1460:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22220,37 +22284,37 @@ yy1460:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1225;
+			if (yych == 'h') goto yy1267;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1461:
-	YYDEBUG(1461, *YYCURSOR);
+yy1463:
+	YYDEBUG(1463, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'Y') {
 		if (yych <= '@') {
 			if (yych == ')') goto yy139;
 			goto yy3;
 		} else {
-			if (yych == 'R') goto yy1473;
+			if (yych == 'R') goto yy1475;
 			if (yych <= 'X') goto yy141;
-			goto yy1474;
+			goto yy1476;
 		}
 	} else {
 		if (yych <= 'r') {
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'q') goto yy141;
-			goto yy1473;
+			goto yy1475;
 		} else {
-			if (yych == 'y') goto yy1474;
+			if (yych == 'y') goto yy1476;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1462:
-	YYDEBUG(1462, *YYCURSOR);
+yy1464:
+	YYDEBUG(1464, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -22259,7 +22323,7 @@ yy1462:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy141;
-			goto yy1467;
+			goto yy1469;
 		}
 	} else {
 		if (yych <= 'c') {
@@ -22267,13 +22331,13 @@ yy1462:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'd') goto yy1467;
+			if (yych <= 'd') goto yy1469;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1463:
-	YYDEBUG(1463, *YYCURSOR);
+yy1465:
+	YYDEBUG(1465, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -22289,13 +22353,13 @@ yy1463:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'n') goto yy1464;
+			if (yych <= 'n') goto yy1466;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1464:
-	YYDEBUG(1464, *YYCURSOR);
+yy1466:
+	YYDEBUG(1466, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'D') {
 		if (yych <= ')') {
@@ -22311,13 +22375,13 @@ yy1464:
 			if (yych <= '`') goto yy167;
 			goto yy142;
 		} else {
-			if (yych <= 'd') goto yy1465;
+			if (yych <= 'd') goto yy1467;
 			if (yych <= 'z') goto yy142;
 			goto yy167;
 		}
 	}
-yy1465:
-	YYDEBUG(1465, *YYCURSOR);
+yy1467:
+	YYDEBUG(1467, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'A') {
 		if (yych == ')') goto yy139;
@@ -22327,13 +22391,13 @@ yy1465:
 			if (yych <= 'Z') goto yy143;
 			goto yy3;
 		} else {
-			if (yych <= 'a') goto yy1466;
+			if (yych <= 'a') goto yy1468;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1466:
-	YYDEBUG(1466, *YYCURSOR);
+yy1468:
+	YYDEBUG(1468, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'Y') {
 		if (yych <= ')') {
@@ -22342,7 +22406,7 @@ yy1466:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy144;
-			goto yy1233;
+			goto yy1235;
 		}
 	} else {
 		if (yych <= 'x') {
@@ -22350,13 +22414,13 @@ yy1466:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'y') goto yy1233;
+			if (yych <= 'y') goto yy1235;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1467:
-	YYDEBUG(1467, *YYCURSOR);
+yy1469:
+	YYDEBUG(1469, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -22372,13 +22436,13 @@ yy1467:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'n') goto yy1468;
+			if (yych <= 'n') goto yy1470;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1468:
-	YYDEBUG(1468, *YYCURSOR);
+yy1470:
+	YYDEBUG(1470, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'I') {
 		if (yych <= ')') {
@@ -22394,13 +22458,13 @@ yy1468:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'i') goto yy1469;
+			if (yych <= 'i') goto yy1471;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1469:
-	YYDEBUG(1469, *YYCURSOR);
+yy1471:
+	YYDEBUG(1471, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'G') {
 		if (yych <= ')') {
@@ -22416,33 +22480,33 @@ yy1469:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'g') goto yy1470;
+			if (yych <= 'g') goto yy1472;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1470:
-	YYDEBUG(1470, *YYCURSOR);
+yy1472:
+	YYDEBUG(1472, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'G') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'H') goto yy1471;
+		if (yych <= 'H') goto yy1473;
 		if (yych != 'h') goto yy3;
 	}
-yy1471:
-	YYDEBUG(1471, *YYCURSOR);
+yy1473:
+	YYDEBUG(1473, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'T') goto yy1472;
+	if (yych == 'T') goto yy1474;
 	if (yych != 't') goto yy56;
-yy1472:
-	YYDEBUG(1472, *YYCURSOR);
+yy1474:
+	YYDEBUG(1474, *YYCURSOR);
 	yych = *++YYCURSOR;
-	goto yy1418;
-yy1473:
-	YYDEBUG(1473, *YYCURSOR);
+	goto yy1420;
+yy1475:
+	YYDEBUG(1475, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -22470,7 +22534,7 @@ yy1473:
 				if (yych <= '9') goto yy196;
 				goto yy194;
 			} else {
-				if (yych == 'C') goto yy1475;
+				if (yych == 'C') goto yy1477;
 				goto yy142;
 			}
 		} else {
@@ -22478,14 +22542,14 @@ yy1473:
 				if (yych <= '`') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'c') goto yy1475;
+				if (yych <= 'c') goto yy1477;
 				if (yych <= 'z') goto yy142;
 				goto yy194;
 			}
 		}
 	}
-yy1474:
-	YYDEBUG(1474, *YYCURSOR);
+yy1476:
+	YYDEBUG(1476, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '-') {
@@ -22510,8 +22574,8 @@ yy1474:
 			goto yy194;
 		}
 	}
-yy1475:
-	YYDEBUG(1475, *YYCURSOR);
+yy1477:
+	YYDEBUG(1477, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -22533,8 +22597,8 @@ yy1475:
 			goto yy3;
 		}
 	}
-yy1476:
-	YYDEBUG(1476, *YYCURSOR);
+yy1478:
+	YYDEBUG(1478, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -22547,9 +22611,9 @@ yy1476:
 				if (yych <= '@') goto yy3;
 				goto yy141;
 			} else {
-				if (yych <= 'R') goto yy1473;
+				if (yych <= 'R') goto yy1475;
 				if (yych <= 'X') goto yy141;
-				goto yy1474;
+				goto yy1476;
 			}
 		}
 	} else {
@@ -22564,17 +22628,17 @@ yy1476:
 			}
 		} else {
 			if (yych <= 'x') {
-				if (yych <= 'r') goto yy1488;
+				if (yych <= 'r') goto yy1490;
 				goto yy146;
 			} else {
-				if (yych <= 'y') goto yy1489;
+				if (yych <= 'y') goto yy1491;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1477:
-	YYDEBUG(1477, *YYCURSOR);
+yy1479:
+	YYDEBUG(1479, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -22585,7 +22649,7 @@ yy1477:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'C') goto yy141;
-			goto yy1467;
+			goto yy1469;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22593,13 +22657,13 @@ yy1477:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1482;
+			if (yych == 'd') goto yy1484;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1478:
-	YYDEBUG(1478, *YYCURSOR);
+yy1480:
+	YYDEBUG(1480, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -22610,7 +22674,7 @@ yy1478:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy141;
-			goto yy1464;
+			goto yy1466;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22618,13 +22682,13 @@ yy1478:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1479;
+			if (yych == 'n') goto yy1481;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1479:
-	YYDEBUG(1479, *YYCURSOR);
+yy1481:
+	YYDEBUG(1481, *YYCURSOR);
 	yyaccept = 4;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -22635,7 +22699,7 @@ yy1479:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy167;
 			if (yych <= 'C') goto yy142;
-			goto yy1465;
+			goto yy1467;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22643,13 +22707,13 @@ yy1479:
 			if (yych == '_') goto yy147;
 			goto yy167;
 		} else {
-			if (yych == 'd') goto yy1480;
+			if (yych == 'd') goto yy1482;
 			if (yych <= 'z') goto yy151;
 			goto yy167;
 		}
 	}
-yy1480:
-	YYDEBUG(1480, *YYCURSOR);
+yy1482:
+	YYDEBUG(1482, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'A') {
@@ -22659,7 +22723,7 @@ yy1480:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
-			goto yy1466;
+			goto yy1468;
 		}
 	} else {
 		if (yych <= '_') {
@@ -22668,13 +22732,13 @@ yy1480:
 			goto yy147;
 		} else {
 			if (yych <= '`') goto yy3;
-			if (yych <= 'a') goto yy1481;
+			if (yych <= 'a') goto yy1483;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1481:
-	YYDEBUG(1481, *YYCURSOR);
+yy1483:
+	YYDEBUG(1483, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'Y') {
@@ -22685,7 +22749,7 @@ yy1481:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'X') goto yy144;
-			goto yy1233;
+			goto yy1235;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22693,13 +22757,13 @@ yy1481:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'y') goto yy1262;
+			if (yych == 'y') goto yy1264;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1482:
-	YYDEBUG(1482, *YYCURSOR);
+yy1484:
+	YYDEBUG(1484, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -22710,7 +22774,7 @@ yy1482:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy142;
-			goto yy1468;
+			goto yy1470;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22718,13 +22782,13 @@ yy1482:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1483;
+			if (yych == 'n') goto yy1485;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1483:
-	YYDEBUG(1483, *YYCURSOR);
+yy1485:
+	YYDEBUG(1485, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'I') {
@@ -22735,7 +22799,7 @@ yy1483:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'H') goto yy143;
-			goto yy1469;
+			goto yy1471;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22743,13 +22807,13 @@ yy1483:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'i') goto yy1484;
+			if (yych == 'i') goto yy1486;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1484:
-	YYDEBUG(1484, *YYCURSOR);
+yy1486:
+	YYDEBUG(1486, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'G') {
@@ -22760,7 +22824,7 @@ yy1484:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'F') goto yy144;
-			goto yy1470;
+			goto yy1472;
 		}
 	} else {
 		if (yych <= '`') {
@@ -22768,13 +22832,13 @@ yy1484:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'g') goto yy1485;
+			if (yych == 'g') goto yy1487;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1485:
-	YYDEBUG(1485, *YYCURSOR);
+yy1487:
+	YYDEBUG(1487, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -22784,37 +22848,37 @@ yy1485:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'G') goto yy3;
-			goto yy1471;
+			goto yy1473;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1486;
+			if (yych == 'h') goto yy1488;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1486:
-	YYDEBUG(1486, *YYCURSOR);
+yy1488:
+	YYDEBUG(1488, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'T') goto yy1472;
+	if (yych == 'T') goto yy1474;
 	if (yych != 't') goto yy155;
-	YYDEBUG(1487, *YYCURSOR);
+	YYDEBUG(1489, *YYCURSOR);
 	yyaccept = 31;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '^') {
 		if (yych == '/') goto yy147;
-		goto yy1418;
+		goto yy1420;
 	} else {
 		if (yych <= '_') goto yy147;
-		if (yych <= '`') goto yy1418;
+		if (yych <= '`') goto yy1420;
 		if (yych <= 'z') goto yy154;
-		goto yy1418;
+		goto yy1420;
 	}
-yy1488:
-	YYDEBUG(1488, *YYCURSOR);
+yy1490:
+	YYDEBUG(1490, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '9') {
@@ -22842,7 +22906,7 @@ yy1488:
 				if (yych <= '@') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'C') goto yy1475;
+				if (yych <= 'C') goto yy1477;
 				if (yych <= 'Z') goto yy142;
 				goto yy194;
 			}
@@ -22852,14 +22916,14 @@ yy1488:
 				if (yych <= '`') goto yy194;
 				goto yy151;
 			} else {
-				if (yych <= 'c') goto yy1490;
+				if (yych <= 'c') goto yy1492;
 				if (yych <= 'z') goto yy151;
 				goto yy194;
 			}
 		}
 	}
-yy1489:
-	YYDEBUG(1489, *YYCURSOR);
+yy1491:
+	YYDEBUG(1491, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '.') {
@@ -22894,8 +22958,8 @@ yy1489:
 			}
 		}
 	}
-yy1490:
-	YYDEBUG(1490, *YYCURSOR);
+yy1492:
+	YYDEBUG(1492, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -22919,8 +22983,8 @@ yy1490:
 			goto yy3;
 		}
 	}
-yy1491:
-	YYDEBUG(1491, *YYCURSOR);
+yy1493:
+	YYDEBUG(1493, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'W') {
 		if (yych <= 'N') {
@@ -22928,30 +22992,30 @@ yy1491:
 			if (yych <= '@') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'O') goto yy1499;
+			if (yych <= 'O') goto yy1501;
 			if (yych <= 'U') goto yy141;
-			if (yych <= 'V') goto yy1500;
-			goto yy1497;
+			if (yych <= 'V') goto yy1502;
+			goto yy1499;
 		}
 	} else {
 		if (yych <= 'o') {
 			if (yych <= 'Z') goto yy141;
 			if (yych <= '`') goto yy3;
 			if (yych <= 'n') goto yy141;
-			goto yy1499;
+			goto yy1501;
 		} else {
 			if (yych <= 'v') {
 				if (yych <= 'u') goto yy141;
-				goto yy1500;
+				goto yy1502;
 			} else {
-				if (yych <= 'w') goto yy1497;
+				if (yych <= 'w') goto yy1499;
 				if (yych <= 'z') goto yy141;
 				goto yy3;
 			}
 		}
 	}
-yy1492:
-	YYDEBUG(1492, *YYCURSOR);
+yy1494:
+	YYDEBUG(1494, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'X') {
 		if (yych <= ')') {
@@ -22960,7 +23024,7 @@ yy1492:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'W') goto yy141;
-			goto yy1496;
+			goto yy1498;
 		}
 	} else {
 		if (yych <= 'w') {
@@ -22968,13 +23032,13 @@ yy1492:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'x') goto yy1496;
+			if (yych <= 'x') goto yy1498;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1493:
-	YYDEBUG(1493, *YYCURSOR);
+yy1495:
+	YYDEBUG(1495, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -22990,13 +23054,13 @@ yy1493:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 'n') goto yy1494;
+			if (yych <= 'n') goto yy1496;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1494:
-	YYDEBUG(1494, *YYCURSOR);
+yy1496:
+	YYDEBUG(1496, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -23012,13 +23076,13 @@ yy1494:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1495;
+			if (yych <= 't') goto yy1497;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1495:
-	YYDEBUG(1495, *YYCURSOR);
+yy1497:
+	YYDEBUG(1497, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'H') {
 		if (yych <= ')') {
@@ -23027,7 +23091,7 @@ yy1495:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= 'g') {
@@ -23035,13 +23099,13 @@ yy1495:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'h') goto yy1214;
+			if (yych <= 'h') goto yy1238;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1496:
-	YYDEBUG(1496, *YYCURSOR);
+yy1498:
+	YYDEBUG(1498, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -23050,7 +23114,7 @@ yy1496:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1426;
+			goto yy1428;
 		}
 	} else {
 		if (yych <= 's') {
@@ -23058,24 +23122,24 @@ yy1496:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1426;
+			if (yych <= 't') goto yy1428;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1497:
-	YYDEBUG(1497, *YYCURSOR);
+yy1499:
+	YYDEBUG(1499, *YYCURSOR);
 	++YYCURSOR;
 	if ((yych = *YYCURSOR) <= '@') {
 		if (yych == ')') goto yy139;
 	} else {
 		if (yych <= 'Z') goto yy142;
-		if (yych <= '`') goto yy1498;
+		if (yych <= '`') goto yy1500;
 		if (yych <= 'z') goto yy142;
 	}
-yy1498:
-	YYDEBUG(1498, *YYCURSOR);
-#line 982 "ext/date/lib/parse_date.re"
+yy1500:
+	YYDEBUG(1500, *YYCURSOR);
+#line 983 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("now");
 		TIMELIB_INIT;
@@ -23083,9 +23147,9 @@ yy1498:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 23087 "ext/date/lib/parse_date.c"
-yy1499:
-	YYDEBUG(1499, *YYCURSOR);
+#line 23151 "ext/date/lib/parse_date.c"
+yy1501:
+	YYDEBUG(1501, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'N') {
 		if (yych <= ')') {
@@ -23094,7 +23158,7 @@ yy1499:
 		} else {
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy142;
-			goto yy1505;
+			goto yy1507;
 		}
 	} else {
 		if (yych <= 'm') {
@@ -23102,13 +23166,13 @@ yy1499:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 'n') goto yy1505;
+			if (yych <= 'n') goto yy1507;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1500:
-	YYDEBUG(1500, *YYCURSOR);
+yy1502:
+	YYDEBUG(1502, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '/') {
@@ -23143,14 +23207,14 @@ yy1500:
 				if (yych <= '`') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'e') goto yy1501;
+				if (yych <= 'e') goto yy1503;
 				if (yych <= 'z') goto yy142;
 				goto yy194;
 			}
 		}
 	}
-yy1501:
-	YYDEBUG(1501, *YYCURSOR);
+yy1503:
+	YYDEBUG(1503, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'M') {
 		if (yych <= ')') {
@@ -23166,13 +23230,13 @@ yy1501:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'm') goto yy1502;
+			if (yych <= 'm') goto yy1504;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1502:
-	YYDEBUG(1502, *YYCURSOR);
+yy1504:
+	YYDEBUG(1504, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'B') {
 		if (yych <= ')') {
@@ -23188,41 +23252,41 @@ yy1502:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'b') goto yy1503;
+			if (yych <= 'b') goto yy1505;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1503:
-	YYDEBUG(1503, *YYCURSOR);
+yy1505:
+	YYDEBUG(1505, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'E') goto yy1504;
+		if (yych <= 'E') goto yy1506;
 		if (yych != 'e') goto yy3;
 	}
-yy1504:
-	YYDEBUG(1504, *YYCURSOR);
+yy1506:
+	YYDEBUG(1506, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'R') goto yy206;
 	if (yych == 'r') goto yy206;
 	goto yy56;
-yy1505:
-	YYDEBUG(1505, *YYCURSOR);
+yy1507:
+	YYDEBUG(1507, *YYCURSOR);
 	++YYCURSOR;
 	if ((yych = *YYCURSOR) <= '@') {
 		if (yych == ')') goto yy139;
 	} else {
 		if (yych <= 'Z') goto yy143;
-		if (yych <= '`') goto yy1506;
+		if (yych <= '`') goto yy1508;
 		if (yych <= 'z') goto yy143;
 	}
-yy1506:
-	YYDEBUG(1506, *YYCURSOR);
-#line 991 "ext/date/lib/parse_date.re"
+yy1508:
+	YYDEBUG(1508, *YYCURSOR);
+#line 992 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("noon");
 		TIMELIB_INIT;
@@ -23233,9 +23297,9 @@ yy1506:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 23237 "ext/date/lib/parse_date.c"
-yy1507:
-	YYDEBUG(1507, *YYCURSOR);
+#line 23301 "ext/date/lib/parse_date.c"
+yy1509:
+	YYDEBUG(1509, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'W') {
@@ -23250,11 +23314,11 @@ yy1507:
 		} else {
 			if (yych <= 'O') {
 				if (yych <= 'N') goto yy141;
-				goto yy1499;
+				goto yy1501;
 			} else {
 				if (yych <= 'U') goto yy141;
-				if (yych <= 'V') goto yy1500;
-				goto yy1497;
+				if (yych <= 'V') goto yy1502;
+				goto yy1499;
 			}
 		}
 	} else {
@@ -23269,18 +23333,18 @@ yy1507:
 			}
 		} else {
 			if (yych <= 'v') {
-				if (yych <= 'o') goto yy1514;
+				if (yych <= 'o') goto yy1516;
 				if (yych <= 'u') goto yy146;
-				goto yy1515;
+				goto yy1517;
 			} else {
-				if (yych <= 'w') goto yy1513;
+				if (yych <= 'w') goto yy1515;
 				if (yych <= 'z') goto yy146;
 				goto yy3;
 			}
 		}
 	}
-yy1508:
-	YYDEBUG(1508, *YYCURSOR);
+yy1510:
+	YYDEBUG(1510, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'X') {
@@ -23291,7 +23355,7 @@ yy1508:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'W') goto yy141;
-			goto yy1496;
+			goto yy1498;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23299,13 +23363,13 @@ yy1508:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'x') goto yy1512;
+			if (yych == 'x') goto yy1514;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1509:
-	YYDEBUG(1509, *YYCURSOR);
+yy1511:
+	YYDEBUG(1511, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -23316,7 +23380,7 @@ yy1509:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy141;
-			goto yy1494;
+			goto yy1496;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23324,13 +23388,13 @@ yy1509:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1510;
+			if (yych == 'n') goto yy1512;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1510:
-	YYDEBUG(1510, *YYCURSOR);
+yy1512:
+	YYDEBUG(1512, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -23341,7 +23405,7 @@ yy1510:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1495;
+			goto yy1497;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23349,13 +23413,13 @@ yy1510:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1511;
+			if (yych == 't') goto yy1513;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1511:
-	YYDEBUG(1511, *YYCURSOR);
+yy1513:
+	YYDEBUG(1513, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'H') {
@@ -23366,7 +23430,7 @@ yy1511:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'G') goto yy143;
-			goto yy1214;
+			goto yy1238;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23374,13 +23438,13 @@ yy1511:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'h') goto yy1225;
+			if (yych == 'h') goto yy1267;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1512:
-	YYDEBUG(1512, *YYCURSOR);
+yy1514:
+	YYDEBUG(1514, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -23391,7 +23455,7 @@ yy1512:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1426;
+			goto yy1428;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23399,36 +23463,36 @@ yy1512:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1458;
+			if (yych == 't') goto yy1460;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1513:
-	YYDEBUG(1513, *YYCURSOR);
+yy1515:
+	YYDEBUG(1515, *YYCURSOR);
 	yyaccept = 32;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '@') {
 		if (yych <= ')') {
-			if (yych <= '(') goto yy1498;
+			if (yych <= '(') goto yy1500;
 			goto yy139;
 		} else {
 			if (yych == '/') goto yy147;
-			goto yy1498;
+			goto yy1500;
 		}
 	} else {
 		if (yych <= '_') {
 			if (yych <= 'Z') goto yy142;
-			if (yych <= '^') goto yy1498;
+			if (yych <= '^') goto yy1500;
 			goto yy147;
 		} else {
-			if (yych <= '`') goto yy1498;
+			if (yych <= '`') goto yy1500;
 			if (yych <= 'z') goto yy151;
-			goto yy1498;
+			goto yy1500;
 		}
 	}
-yy1514:
-	YYDEBUG(1514, *YYCURSOR);
+yy1516:
+	YYDEBUG(1516, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'N') {
@@ -23439,7 +23503,7 @@ yy1514:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'M') goto yy142;
-			goto yy1505;
+			goto yy1507;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23447,13 +23511,13 @@ yy1514:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'n') goto yy1520;
+			if (yych == 'n') goto yy1522;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1515:
-	YYDEBUG(1515, *YYCURSOR);
+yy1517:
+	YYDEBUG(1517, *YYCURSOR);
 	yyaccept = 5;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '9') {
@@ -23481,7 +23545,7 @@ yy1515:
 				if (yych <= '@') goto yy194;
 				goto yy142;
 			} else {
-				if (yych <= 'E') goto yy1501;
+				if (yych <= 'E') goto yy1503;
 				if (yych <= 'Z') goto yy142;
 				goto yy194;
 			}
@@ -23491,14 +23555,14 @@ yy1515:
 				if (yych <= '`') goto yy194;
 				goto yy151;
 			} else {
-				if (yych <= 'e') goto yy1516;
+				if (yych <= 'e') goto yy1518;
 				if (yych <= 'z') goto yy151;
 				goto yy194;
 			}
 		}
 	}
-yy1516:
-	YYDEBUG(1516, *YYCURSOR);
+yy1518:
+	YYDEBUG(1518, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'M') {
@@ -23509,7 +23573,7 @@ yy1516:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'L') goto yy143;
-			goto yy1502;
+			goto yy1504;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23517,13 +23581,13 @@ yy1516:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'm') goto yy1517;
+			if (yych == 'm') goto yy1519;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1517:
-	YYDEBUG(1517, *YYCURSOR);
+yy1519:
+	YYDEBUG(1519, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'B') {
@@ -23534,7 +23598,7 @@ yy1517:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'A') goto yy144;
-			goto yy1503;
+			goto yy1505;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23542,13 +23606,13 @@ yy1517:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'b') goto yy1518;
+			if (yych == 'b') goto yy1520;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1518:
-	YYDEBUG(1518, *YYCURSOR);
+yy1520:
+	YYDEBUG(1520, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -23558,49 +23622,49 @@ yy1518:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'D') goto yy3;
-			goto yy1504;
+			goto yy1506;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1519;
+			if (yych == 'e') goto yy1521;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1519:
-	YYDEBUG(1519, *YYCURSOR);
+yy1521:
+	YYDEBUG(1521, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych == 'R') goto yy206;
 	if (yych == 'r') goto yy377;
 	goto yy155;
-yy1520:
-	YYDEBUG(1520, *YYCURSOR);
+yy1522:
+	YYDEBUG(1522, *YYCURSOR);
 	yyaccept = 33;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '@') {
 		if (yych <= ')') {
-			if (yych <= '(') goto yy1506;
+			if (yych <= '(') goto yy1508;
 			goto yy139;
 		} else {
 			if (yych == '/') goto yy147;
-			goto yy1506;
+			goto yy1508;
 		}
 	} else {
 		if (yych <= '_') {
 			if (yych <= 'Z') goto yy143;
-			if (yych <= '^') goto yy1506;
+			if (yych <= '^') goto yy1508;
 			goto yy147;
 		} else {
-			if (yych <= '`') goto yy1506;
+			if (yych <= '`') goto yy1508;
 			if (yych <= 'z') goto yy152;
-			goto yy1506;
+			goto yy1508;
 		}
 	}
-yy1521:
-	YYDEBUG(1521, *YYCURSOR);
+yy1523:
+	YYDEBUG(1523, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'S') {
 		if (yych <= ')') {
@@ -23616,13 +23680,13 @@ yy1521:
 			if (yych <= '`') goto yy3;
 			goto yy141;
 		} else {
-			if (yych <= 's') goto yy1522;
+			if (yych <= 's') goto yy1524;
 			if (yych <= 'z') goto yy141;
 			goto yy3;
 		}
 	}
-yy1522:
-	YYDEBUG(1522, *YYCURSOR);
+yy1524:
+	YYDEBUG(1524, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'T') {
 		if (yych <= ')') {
@@ -23638,13 +23702,13 @@ yy1522:
 			if (yych <= '`') goto yy3;
 			goto yy142;
 		} else {
-			if (yych <= 't') goto yy1523;
+			if (yych <= 't') goto yy1525;
 			if (yych <= 'z') goto yy142;
 			goto yy3;
 		}
 	}
-yy1523:
-	YYDEBUG(1523, *YYCURSOR);
+yy1525:
+	YYDEBUG(1525, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'E') {
 		if (yych <= ')') {
@@ -23660,13 +23724,13 @@ yy1523:
 			if (yych <= '`') goto yy3;
 			goto yy143;
 		} else {
-			if (yych <= 'e') goto yy1524;
+			if (yych <= 'e') goto yy1526;
 			if (yych <= 'z') goto yy143;
 			goto yy3;
 		}
 	}
-yy1524:
-	YYDEBUG(1524, *YYCURSOR);
+yy1526:
+	YYDEBUG(1526, *YYCURSOR);
 	yych = *++YYCURSOR;
 	if (yych <= 'R') {
 		if (yych <= ')') {
@@ -23682,38 +23746,38 @@ yy1524:
 			if (yych <= '`') goto yy3;
 			goto yy144;
 		} else {
-			if (yych <= 'r') goto yy1525;
+			if (yych <= 'r') goto yy1527;
 			if (yych <= 'z') goto yy144;
 			goto yy3;
 		}
 	}
-yy1525:
-	YYDEBUG(1525, *YYCURSOR);
+yy1527:
+	YYDEBUG(1527, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'C') {
 		if (yych == ')') goto yy139;
 		goto yy3;
 	} else {
-		if (yych <= 'D') goto yy1526;
+		if (yych <= 'D') goto yy1528;
 		if (yych != 'd') goto yy3;
 	}
-yy1526:
-	YYDEBUG(1526, *YYCURSOR);
+yy1528:
+	YYDEBUG(1528, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'A') goto yy1527;
+	if (yych == 'A') goto yy1529;
 	if (yych != 'a') goto yy56;
-yy1527:
-	YYDEBUG(1527, *YYCURSOR);
+yy1529:
+	YYDEBUG(1529, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'Y') goto yy1528;
+	if (yych == 'Y') goto yy1530;
 	if (yych != 'y') goto yy56;
-yy1528:
-	YYDEBUG(1528, *YYCURSOR);
+yy1530:
+	YYDEBUG(1530, *YYCURSOR);
 	++YYCURSOR;
-yy1529:
-	YYDEBUG(1529, *YYCURSOR);
-#line 970 "ext/date/lib/parse_date.re"
+yy1531:
+	YYDEBUG(1531, *YYCURSOR);
+#line 971 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("yesterday");
 		TIMELIB_INIT;
@@ -23724,9 +23788,9 @@ yy1529:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 23728 "ext/date/lib/parse_date.c"
-yy1530:
-	YYDEBUG(1530, *YYCURSOR);
+#line 23792 "ext/date/lib/parse_date.c"
+yy1532:
+	YYDEBUG(1532, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'S') {
@@ -23737,7 +23801,7 @@ yy1530:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'R') goto yy141;
-			goto yy1522;
+			goto yy1524;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23745,13 +23809,13 @@ yy1530:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 's') goto yy1531;
+			if (yych == 's') goto yy1533;
 			if (yych <= 'z') goto yy146;
 			goto yy3;
 		}
 	}
-yy1531:
-	YYDEBUG(1531, *YYCURSOR);
+yy1533:
+	YYDEBUG(1533, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'T') {
@@ -23762,7 +23826,7 @@ yy1531:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'S') goto yy142;
-			goto yy1523;
+			goto yy1525;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23770,13 +23834,13 @@ yy1531:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 't') goto yy1532;
+			if (yych == 't') goto yy1534;
 			if (yych <= 'z') goto yy151;
 			goto yy3;
 		}
 	}
-yy1532:
-	YYDEBUG(1532, *YYCURSOR);
+yy1534:
+	YYDEBUG(1534, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'E') {
@@ -23787,7 +23851,7 @@ yy1532:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'D') goto yy143;
-			goto yy1524;
+			goto yy1526;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23795,13 +23859,13 @@ yy1532:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'e') goto yy1533;
+			if (yych == 'e') goto yy1535;
 			if (yych <= 'z') goto yy152;
 			goto yy3;
 		}
 	}
-yy1533:
-	YYDEBUG(1533, *YYCURSOR);
+yy1535:
+	YYDEBUG(1535, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'R') {
@@ -23812,7 +23876,7 @@ yy1533:
 			if (yych <= '/') goto yy147;
 			if (yych <= '@') goto yy3;
 			if (yych <= 'Q') goto yy144;
-			goto yy1525;
+			goto yy1527;
 		}
 	} else {
 		if (yych <= '`') {
@@ -23820,13 +23884,13 @@ yy1533:
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'r') goto yy1534;
+			if (yych == 'r') goto yy1536;
 			if (yych <= 'z') goto yy153;
 			goto yy3;
 		}
 	}
-yy1534:
-	YYDEBUG(1534, *YYCURSOR);
+yy1536:
+	YYDEBUG(1536, *YYCURSOR);
 	yyaccept = 0;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= 'D') {
@@ -23836,41 +23900,41 @@ yy1534:
 		} else {
 			if (yych <= '/') goto yy147;
 			if (yych <= 'C') goto yy3;
-			goto yy1526;
+			goto yy1528;
 		}
 	} else {
 		if (yych <= '`') {
 			if (yych == '_') goto yy147;
 			goto yy3;
 		} else {
-			if (yych == 'd') goto yy1535;
+			if (yych == 'd') goto yy1537;
 			if (yych <= 'z') goto yy154;
 			goto yy3;
 		}
 	}
-yy1535:
-	YYDEBUG(1535, *YYCURSOR);
+yy1537:
+	YYDEBUG(1537, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'A') goto yy1527;
+	if (yych == 'A') goto yy1529;
 	if (yych != 'a') goto yy155;
-	YYDEBUG(1536, *YYCURSOR);
+	YYDEBUG(1538, *YYCURSOR);
 	yych = *++YYCURSOR;
-	if (yych == 'Y') goto yy1528;
+	if (yych == 'Y') goto yy1530;
 	if (yych != 'y') goto yy155;
-	YYDEBUG(1537, *YYCURSOR);
+	YYDEBUG(1539, *YYCURSOR);
 	yyaccept = 34;
 	yych = *(YYMARKER = ++YYCURSOR);
 	if (yych <= '^') {
 		if (yych == '/') goto yy147;
-		goto yy1529;
+		goto yy1531;
 	} else {
 		if (yych <= '_') goto yy147;
-		if (yych <= '`') goto yy1529;
+		if (yych <= '`') goto yy1531;
 		if (yych <= 'z') goto yy154;
-		goto yy1529;
+		goto yy1531;
 	}
 }
-#line 1731 "ext/date/lib/parse_date.re"
+#line 1732 "ext/date/lib/parse_date.re"
 
 }
 
@@ -24086,7 +24150,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 					add_pbf_error(s, "A two digit second could not be found", string, begin);
 				}
 				break;
-			case 'u': /* six digit millisecond */
+			case 'u': /* up to six digit millisecond */
 				{
 					double f;
 					char *tptr;
diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re
index 53966d8..dd3ac7b 100644
--- a/ext/date/lib/parse_date.re
+++ b/ext/date/lib/parse_date.re
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_date.re 286515 2009-07-29 15:34:59Z derick $ */
+/* $Id: parse_date.re 294880 2010-02-11 11:11:47Z pajoye $ */
 
 #include "timelib.h"
 
@@ -236,6 +236,7 @@ static timelib_lookup_table const timelib_reltext_lookup[] = {
 	{ "sixth",    0,  6 },
 	{ "seventh",  0,  7 },
 	{ "eight",    0,  8 },
+	{ "eighth",   0,  8 },
 	{ "ninth",    0,  9 },
 	{ "tenth",    0, 10 },
 	{ "eleventh", 0, 11 },
@@ -951,7 +952,7 @@ dateshortwithtimelongtz = datenoyear iso8601normtz;
 /*
  * Relative regexps
  */
-reltextnumber = 'first'|'second'|'third'|'fourth'|'fifth'|'sixth'|'seventh'|'eight'|'ninth'|'tenth'|'eleventh'|'twelfth';
+reltextnumber = 'first'|'second'|'third'|'fourth'|'fifth'|'sixth'|'seventh'|'eight'|'eighth'|'ninth'|'tenth'|'eleventh'|'twelfth';
 reltexttext = 'next'|'last'|'previous'|'this';
 reltextunit = (('sec'|'second'|'min'|'minute'|'hour'|'day'|'fortnight'|'forthnight'|'month'|'year') 's'?) | 'weeks' | daytext;
 
@@ -1943,7 +1944,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 					add_pbf_error(s, "A two digit second could not be found", string, begin);
 				}
 				break;
-			case 'u': /* six digit millisecond */
+			case 'u': /* up to six digit millisecond */
 				{
 					double f;
 					char *tptr;
diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c
index ca7acea..6239f9e 100644
--- a/ext/date/lib/parse_tz.c
+++ b/ext/date/lib/parse_tz.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_tz.c 279320 2009-04-25 16:33:41Z nlopess $ */
+/* $Id: parse_tz.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "timelib.h"
 
diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c
index 3b233dd..84001d3 100644
--- a/ext/date/lib/timelib.c
+++ b/ext/date/lib/timelib.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: timelib.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: timelib.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "timelib.h"
 #include <ctype.h>
diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h
index acf7f70..33eb6eb 100644
--- a/ext/date/lib/timelib.h
+++ b/ext/date/lib/timelib.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: timelib.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: timelib.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef __TIMELIB_H__
 #define __TIMELIB_H__
diff --git a/ext/date/lib/timelib_structs.h b/ext/date/lib/timelib_structs.h
index 733b815..15622e7 100644
--- a/ext/date/lib/timelib_structs.h
+++ b/ext/date/lib/timelib_structs.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: timelib_structs.h 282169 2009-06-15 15:08:12Z pajoye $ */
+/* $Id: timelib_structs.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef __TIMELIB_STRUCTS_H__
 #define __TIMELIB_STRUCTS_H__
diff --git a/ext/date/lib/timezonedb.h b/ext/date/lib/timezonedb.h
index c6c8abf..27f1889 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[561] = {
+const timelib_tzdb_index_entry timezonedb_idx_builtin[564] = {
 	{ "Africa/Abidjan"                    , 0x000000 },
 	{ "Africa/Accra"                      , 0x000055 },
 	{ "Africa/Addis_Ababa"                , 0x0000FD },
@@ -92,477 +92,480 @@ const timelib_tzdb_index_entry timezonedb_idx_builtin[561] = {
 	{ "America/Cayman"                    , 0x005FBE },
 	{ "America/Chicago"                   , 0x006013 },
 	{ "America/Chihuahua"                 , 0x00652A },
-	{ "America/Coral_Harbour"             , 0x006779 },
-	{ "America/Cordoba"                   , 0x00680B },
-	{ "America/Costa_Rica"                , 0x0069B1 },
-	{ "America/Cuiaba"                    , 0x006A3B },
-	{ "America/Curacao"                   , 0x006D19 },
-	{ "America/Danmarkshavn"              , 0x006D7F },
-	{ "America/Dawson"                    , 0x006EC3 },
-	{ "America/Dawson_Creek"              , 0x0071E0 },
-	{ "America/Denver"                    , 0x0073BA },
-	{ "America/Detroit"                   , 0x007740 },
-	{ "America/Dominica"                  , 0x007A9F },
-	{ "America/Edmonton"                  , 0x007AF4 },
-	{ "America/Eirunepe"                  , 0x007EAC },
-	{ "America/El_Salvador"               , 0x007FBF },
-	{ "America/Ensenada"                  , 0x008034 },
-	{ "America/Fort_Wayne"                , 0x0084DB },
-	{ "America/Fortaleza"                 , 0x00839D },
-	{ "America/Glace_Bay"                 , 0x008745 },
-	{ "America/Godthab"                   , 0x008ABC },
-	{ "America/Goose_Bay"                 , 0x008D80 },
-	{ "America/Grand_Turk"                , 0x00923D },
-	{ "America/Grenada"                   , 0x0094EC },
-	{ "America/Guadeloupe"                , 0x009541 },
-	{ "America/Guatemala"                 , 0x009596 },
-	{ "America/Guayaquil"                 , 0x00961F },
-	{ "America/Guyana"                    , 0x00967C },
-	{ "America/Halifax"                   , 0x0096FD },
-	{ "America/Havana"                    , 0x009C13 },
-	{ "America/Hermosillo"                , 0x009F86 },
-	{ "America/Indiana/Indianapolis"      , 0x00A064 },
-	{ "America/Indiana/Knox"              , 0x00A2F5 },
-	{ "America/Indiana/Marengo"           , 0x00A68C },
-	{ "America/Indiana/Petersburg"        , 0x00A932 },
-	{ "America/Indiana/Tell_City"         , 0x00AE7F },
-	{ "America/Indiana/Vevay"             , 0x00B118 },
-	{ "America/Indiana/Vincennes"         , 0x00B353 },
-	{ "America/Indiana/Winamac"           , 0x00B607 },
-	{ "America/Indianapolis"              , 0x00AC15 },
-	{ "America/Inuvik"                    , 0x00B8C0 },
-	{ "America/Iqaluit"                   , 0x00BBB7 },
-	{ "America/Jamaica"                   , 0x00BED9 },
-	{ "America/Jujuy"                     , 0x00BF9E },
-	{ "America/Juneau"                    , 0x00C148 },
-	{ "America/Kentucky/Louisville"       , 0x00C4C6 },
-	{ "America/Kentucky/Monticello"       , 0x00C8E4 },
-	{ "America/Knox_IN"                   , 0x00CC69 },
-	{ "America/La_Paz"                    , 0x00CFDA },
-	{ "America/Lima"                      , 0x00D041 },
-	{ "America/Los_Angeles"               , 0x00D0E9 },
-	{ "America/Louisville"                , 0x00D4FA },
-	{ "America/Maceio"                    , 0x00D8EF },
-	{ "America/Managua"                   , 0x00DA29 },
-	{ "America/Manaus"                    , 0x00DADC },
-	{ "America/Marigot"                   , 0x00DBDE },
-	{ "America/Martinique"                , 0x00DC33 },
-	{ "America/Mazatlan"                  , 0x00DC9F },
-	{ "America/Mendoza"                   , 0x00DF0C },
-	{ "America/Menominee"                 , 0x00E0C0 },
-	{ "America/Merida"                    , 0x00E441 },
-	{ "America/Mexico_City"               , 0x00E67C },
-	{ "America/Miquelon"                  , 0x00E8F7 },
-	{ "America/Moncton"                   , 0x00EB69 },
-	{ "America/Monterrey"                 , 0x00F000 },
-	{ "America/Montevideo"                , 0x00F247 },
-	{ "America/Montreal"                  , 0x00F559 },
-	{ "America/Montserrat"                , 0x00FA6F },
-	{ "America/Nassau"                    , 0x00FAC4 },
-	{ "America/New_York"                  , 0x00FE09 },
-	{ "America/Nipigon"                   , 0x010314 },
-	{ "America/Nome"                      , 0x010665 },
-	{ "America/Noronha"                   , 0x0109E3 },
-	{ "America/North_Dakota/Center"       , 0x010B13 },
-	{ "America/North_Dakota/New_Salem"    , 0x010EA7 },
-	{ "America/Panama"                    , 0x011250 },
-	{ "America/Pangnirtung"               , 0x0112A5 },
-	{ "America/Paramaribo"                , 0x0115DB },
-	{ "America/Phoenix"                   , 0x01166D },
-	{ "America/Port-au-Prince"            , 0x01171B },
-	{ "America/Port_of_Spain"             , 0x011936 },
-	{ "America/Porto_Acre"                , 0x011837 },
-	{ "America/Porto_Velho"               , 0x01198B },
-	{ "America/Puerto_Rico"               , 0x011A81 },
-	{ "America/Rainy_River"               , 0x011AEC },
-	{ "America/Rankin_Inlet"              , 0x011E24 },
-	{ "America/Recife"                    , 0x01210A },
-	{ "America/Regina"                    , 0x012234 },
-	{ "America/Resolute"                  , 0x0123F2 },
-	{ "America/Rio_Branco"                , 0x0126EB },
-	{ "America/Rosario"                   , 0x0127EE },
-	{ "America/Santarem"                  , 0x012994 },
-	{ "America/Santiago"                  , 0x012A99 },
-	{ "America/Santo_Domingo"             , 0x012E42 },
-	{ "America/Sao_Paulo"                 , 0x012F08 },
-	{ "America/Scoresbysund"              , 0x013217 },
-	{ "America/Shiprock"                  , 0x013505 },
-	{ "America/St_Barthelemy"             , 0x013894 },
-	{ "America/St_Johns"                  , 0x0138E9 },
-	{ "America/St_Kitts"                  , 0x013E3C },
-	{ "America/St_Lucia"                  , 0x013E91 },
-	{ "America/St_Thomas"                 , 0x013EE6 },
-	{ "America/St_Vincent"                , 0x013F3B },
-	{ "America/Swift_Current"             , 0x013F90 },
-	{ "America/Tegucigalpa"               , 0x0140B1 },
-	{ "America/Thule"                     , 0x014130 },
-	{ "America/Thunder_Bay"               , 0x014377 },
-	{ "America/Tijuana"                   , 0x0146C0 },
-	{ "America/Toronto"                   , 0x014A35 },
-	{ "America/Tortola"                   , 0x014F4C },
-	{ "America/Vancouver"                 , 0x014FA1 },
-	{ "America/Virgin"                    , 0x0153DE },
-	{ "America/Whitehorse"                , 0x015433 },
-	{ "America/Winnipeg"                  , 0x015750 },
-	{ "America/Yakutat"                   , 0x015B90 },
-	{ "America/Yellowknife"               , 0x015EFB },
-	{ "Antarctica/Casey"                  , 0x01620B },
-	{ "Antarctica/Davis"                  , 0x016291 },
-	{ "Antarctica/DumontDUrville"         , 0x01631B },
-	{ "Antarctica/Mawson"                 , 0x0163AD },
-	{ "Antarctica/McMurdo"                , 0x016429 },
-	{ "Antarctica/Palmer"                 , 0x01672B },
-	{ "Antarctica/Rothera"                , 0x016A47 },
-	{ "Antarctica/South_Pole"             , 0x016ABD },
-	{ "Antarctica/Syowa"                  , 0x016DC5 },
-	{ "Antarctica/Vostok"                 , 0x016E33 },
-	{ "Arctic/Longyearbyen"               , 0x016EA8 },
-	{ "Asia/Aden"                         , 0x0171DA },
-	{ "Asia/Almaty"                       , 0x01722F },
-	{ "Asia/Amman"                        , 0x0173AE },
-	{ "Asia/Anadyr"                       , 0x01766E },
-	{ "Asia/Aqtau"                        , 0x01795C },
-	{ "Asia/Aqtobe"                       , 0x017B5B },
-	{ "Asia/Ashgabat"                     , 0x017D13 },
-	{ "Asia/Ashkhabad"                    , 0x017E30 },
-	{ "Asia/Baghdad"                      , 0x017F4D },
-	{ "Asia/Bahrain"                      , 0x0180C2 },
-	{ "Asia/Baku"                         , 0x018128 },
-	{ "Asia/Bangkok"                      , 0x018410 },
-	{ "Asia/Beirut"                       , 0x018465 },
-	{ "Asia/Bishkek"                      , 0x018772 },
-	{ "Asia/Brunei"                       , 0x01891E },
-	{ "Asia/Calcutta"                     , 0x018980 },
-	{ "Asia/Choibalsan"                   , 0x0189F9 },
-	{ "Asia/Chongqing"                    , 0x018B72 },
-	{ "Asia/Chungking"                    , 0x018C61 },
-	{ "Asia/Colombo"                      , 0x018D10 },
-	{ "Asia/Dacca"                        , 0x018DAC },
-	{ "Asia/Damascus"                     , 0x018E4D },
-	{ "Asia/Dhaka"                        , 0x01919D },
-	{ "Asia/Dili"                         , 0x01923E },
-	{ "Asia/Dubai"                        , 0x0192C7 },
-	{ "Asia/Dushanbe"                     , 0x01931C },
-	{ "Asia/Gaza"                         , 0x01941F },
-	{ "Asia/Harbin"                       , 0x019768 },
-	{ "Asia/Ho_Chi_Minh"                  , 0x01984F },
-	{ "Asia/Hong_Kong"                    , 0x0198C7 },
-	{ "Asia/Hovd"                         , 0x019A93 },
-	{ "Asia/Irkutsk"                      , 0x019C0B },
-	{ "Asia/Istanbul"                     , 0x019EF2 },
-	{ "Asia/Jakarta"                      , 0x01A2DF },
-	{ "Asia/Jayapura"                     , 0x01A389 },
-	{ "Asia/Jerusalem"                    , 0x01A40D },
-	{ "Asia/Kabul"                        , 0x01A73C },
-	{ "Asia/Kamchatka"                    , 0x01A78D },
-	{ "Asia/Karachi"                      , 0x01AA72 },
-	{ "Asia/Kashgar"                      , 0x01AC3F },
-	{ "Asia/Kathmandu"                    , 0x01AD10 },
-	{ "Asia/Katmandu"                     , 0x01AD76 },
-	{ "Asia/Kolkata"                      , 0x01ADDC },
-	{ "Asia/Krasnoyarsk"                  , 0x01AE55 },
-	{ "Asia/Kuala_Lumpur"                 , 0x01B13E },
-	{ "Asia/Kuching"                      , 0x01B1FB },
-	{ "Asia/Kuwait"                       , 0x01B2E9 },
-	{ "Asia/Macao"                        , 0x01B33E },
-	{ "Asia/Macau"                        , 0x01B479 },
-	{ "Asia/Magadan"                      , 0x01B5B4 },
-	{ "Asia/Makassar"                     , 0x01B897 },
-	{ "Asia/Manila"                       , 0x01B950 },
-	{ "Asia/Muscat"                       , 0x01B9D5 },
-	{ "Asia/Nicosia"                      , 0x01BA2A },
-	{ "Asia/Novokuznetsk"                 , 0x01BD12 },
-	{ "Asia/Novosibirsk"                  , 0x01C015 },
-	{ "Asia/Omsk"                         , 0x01C309 },
-	{ "Asia/Oral"                         , 0x01C5F1 },
-	{ "Asia/Phnom_Penh"                   , 0x01C7C1 },
-	{ "Asia/Pontianak"                    , 0x01C839 },
-	{ "Asia/Pyongyang"                    , 0x01C8FA },
-	{ "Asia/Qatar"                        , 0x01C967 },
-	{ "Asia/Qyzylorda"                    , 0x01C9CD },
-	{ "Asia/Rangoon"                      , 0x01CBA3 },
-	{ "Asia/Riyadh"                       , 0x01CC1B },
-	{ "Asia/Saigon"                       , 0x01CC70 },
-	{ "Asia/Sakhalin"                     , 0x01CCE8 },
-	{ "Asia/Samarkand"                    , 0x01CFE8 },
-	{ "Asia/Seoul"                        , 0x01D11E },
-	{ "Asia/Shanghai"                     , 0x01D1C2 },
-	{ "Asia/Singapore"                    , 0x01D2A2 },
-	{ "Asia/Taipei"                       , 0x01D359 },
-	{ "Asia/Tashkent"                     , 0x01D471 },
-	{ "Asia/Tbilisi"                      , 0x01D5A2 },
-	{ "Asia/Tehran"                       , 0x01D75C },
-	{ "Asia/Tel_Aviv"                     , 0x01D9CA },
-	{ "Asia/Thimbu"                       , 0x01DCF9 },
-	{ "Asia/Thimphu"                      , 0x01DD5F },
-	{ "Asia/Tokyo"                        , 0x01DDC5 },
-	{ "Asia/Ujung_Pandang"                , 0x01DE4E },
-	{ "Asia/Ulaanbaatar"                  , 0x01DECA },
-	{ "Asia/Ulan_Bator"                   , 0x01E025 },
-	{ "Asia/Urumqi"                       , 0x01E172 },
-	{ "Asia/Vientiane"                    , 0x01E239 },
-	{ "Asia/Vladivostok"                  , 0x01E2B1 },
-	{ "Asia/Yakutsk"                      , 0x01E59E },
-	{ "Asia/Yekaterinburg"                , 0x01E884 },
-	{ "Asia/Yerevan"                      , 0x01EB90 },
-	{ "Atlantic/Azores"                   , 0x01EE94 },
-	{ "Atlantic/Bermuda"                  , 0x01F397 },
-	{ "Atlantic/Canary"                   , 0x01F678 },
-	{ "Atlantic/Cape_Verde"               , 0x01F94E },
-	{ "Atlantic/Faeroe"                   , 0x01F9C7 },
-	{ "Atlantic/Faroe"                    , 0x01FC6B },
-	{ "Atlantic/Jan_Mayen"                , 0x01FF0F },
-	{ "Atlantic/Madeira"                  , 0x020241 },
-	{ "Atlantic/Reykjavik"                , 0x02074A },
-	{ "Atlantic/South_Georgia"            , 0x020903 },
-	{ "Atlantic/St_Helena"                , 0x020C1B },
-	{ "Atlantic/Stanley"                  , 0x020947 },
-	{ "Australia/ACT"                     , 0x020C70 },
-	{ "Australia/Adelaide"                , 0x020F8D },
-	{ "Australia/Brisbane"                , 0x0212B9 },
-	{ "Australia/Broken_Hill"             , 0x021380 },
-	{ "Australia/Canberra"                , 0x0216BE },
-	{ "Australia/Currie"                  , 0x0219DB },
-	{ "Australia/Darwin"                  , 0x021D0E },
-	{ "Australia/Eucla"                   , 0x021D94 },
-	{ "Australia/Hobart"                  , 0x021E69 },
-	{ "Australia/LHI"                     , 0x0221C7 },
-	{ "Australia/Lindeman"                , 0x022462 },
-	{ "Australia/Lord_Howe"               , 0x022543 },
-	{ "Australia/Melbourne"               , 0x0227EE },
-	{ "Australia/North"                   , 0x022B13 },
-	{ "Australia/NSW"                     , 0x022B87 },
-	{ "Australia/Perth"                   , 0x022EA4 },
-	{ "Australia/Queensland"              , 0x022F7C },
-	{ "Australia/South"                   , 0x023028 },
-	{ "Australia/Sydney"                  , 0x023345 },
-	{ "Australia/Tasmania"                , 0x023682 },
-	{ "Australia/Victoria"                , 0x0239C7 },
-	{ "Australia/West"                    , 0x023CE4 },
-	{ "Australia/Yancowinna"              , 0x023D9A },
-	{ "Brazil/Acre"                       , 0x0240BC },
-	{ "Brazil/DeNoronha"                  , 0x0241BB },
-	{ "Brazil/East"                       , 0x0242DB },
-	{ "Brazil/West"                       , 0x0245B8 },
-	{ "Canada/Atlantic"                   , 0x0246B0 },
-	{ "Canada/Central"                    , 0x024B98 },
-	{ "Canada/East-Saskatchewan"          , 0x0254A2 },
-	{ "Canada/Eastern"                    , 0x024FB2 },
-	{ "Canada/Mountain"                   , 0x02562B },
-	{ "Canada/Newfoundland"               , 0x0259A1 },
-	{ "Canada/Pacific"                    , 0x025ECC },
-	{ "Canada/Saskatchewan"               , 0x0262E5 },
-	{ "Canada/Yukon"                      , 0x02646E },
-	{ "CET"                               , 0x026771 },
-	{ "Chile/Continental"                 , 0x026A7A },
-	{ "Chile/EasterIsland"                , 0x026E15 },
-	{ "CST6CDT"                           , 0x027157 },
-	{ "Cuba"                              , 0x0274A8 },
-	{ "EET"                               , 0x02781B },
-	{ "Egypt"                             , 0x027ACE },
-	{ "Eire"                              , 0x027E95 },
-	{ "EST"                               , 0x0283A6 },
-	{ "EST5EDT"                           , 0x0283EA },
-	{ "Etc/GMT"                           , 0x02873B },
-	{ "Etc/GMT+0"                         , 0x028807 },
-	{ "Etc/GMT+1"                         , 0x028891 },
-	{ "Etc/GMT+10"                        , 0x02891E },
-	{ "Etc/GMT+11"                        , 0x0289AC },
-	{ "Etc/GMT+12"                        , 0x028A3A },
-	{ "Etc/GMT+2"                         , 0x028B55 },
-	{ "Etc/GMT+3"                         , 0x028BE1 },
-	{ "Etc/GMT+4"                         , 0x028C6D },
-	{ "Etc/GMT+5"                         , 0x028CF9 },
-	{ "Etc/GMT+6"                         , 0x028D85 },
-	{ "Etc/GMT+7"                         , 0x028E11 },
-	{ "Etc/GMT+8"                         , 0x028E9D },
-	{ "Etc/GMT+9"                         , 0x028F29 },
-	{ "Etc/GMT-0"                         , 0x0287C3 },
-	{ "Etc/GMT-1"                         , 0x02884B },
-	{ "Etc/GMT-10"                        , 0x0288D7 },
-	{ "Etc/GMT-11"                        , 0x028965 },
-	{ "Etc/GMT-12"                        , 0x0289F3 },
-	{ "Etc/GMT-13"                        , 0x028A81 },
-	{ "Etc/GMT-14"                        , 0x028AC8 },
-	{ "Etc/GMT-2"                         , 0x028B0F },
-	{ "Etc/GMT-3"                         , 0x028B9B },
-	{ "Etc/GMT-4"                         , 0x028C27 },
-	{ "Etc/GMT-5"                         , 0x028CB3 },
-	{ "Etc/GMT-6"                         , 0x028D3F },
-	{ "Etc/GMT-7"                         , 0x028DCB },
-	{ "Etc/GMT-8"                         , 0x028E57 },
-	{ "Etc/GMT-9"                         , 0x028EE3 },
-	{ "Etc/GMT0"                          , 0x02877F },
-	{ "Etc/Greenwich"                     , 0x028F6F },
-	{ "Etc/UCT"                           , 0x028FB3 },
-	{ "Etc/Universal"                     , 0x028FF7 },
-	{ "Etc/UTC"                           , 0x02903B },
-	{ "Etc/Zulu"                          , 0x02907F },
-	{ "Europe/Amsterdam"                  , 0x0290C3 },
-	{ "Europe/Andorra"                    , 0x029501 },
-	{ "Europe/Athens"                     , 0x02977D },
-	{ "Europe/Belfast"                    , 0x029AC0 },
-	{ "Europe/Belgrade"                   , 0x029FF7 },
-	{ "Europe/Berlin"                     , 0x02A2C0 },
-	{ "Europe/Bratislava"                 , 0x02A616 },
-	{ "Europe/Brussels"                   , 0x02A948 },
-	{ "Europe/Bucharest"                  , 0x02AD7F },
-	{ "Europe/Budapest"                   , 0x02B0A9 },
-	{ "Europe/Chisinau"                   , 0x02B41C },
-	{ "Europe/Copenhagen"                 , 0x02B7AA },
-	{ "Europe/Dublin"                     , 0x02BAB4 },
-	{ "Europe/Gibraltar"                  , 0x02BFC5 },
-	{ "Europe/Guernsey"                   , 0x02C41C },
-	{ "Europe/Helsinki"                   , 0x02C953 },
-	{ "Europe/Isle_of_Man"                , 0x02CC09 },
-	{ "Europe/Istanbul"                   , 0x02D140 },
-	{ "Europe/Jersey"                     , 0x02D52D },
-	{ "Europe/Kaliningrad"                , 0x02DA64 },
-	{ "Europe/Kiev"                       , 0x02DDC7 },
-	{ "Europe/Lisbon"                     , 0x02E0DE },
-	{ "Europe/Ljubljana"                  , 0x02E5E2 },
-	{ "Europe/London"                     , 0x02E8AB },
-	{ "Europe/Luxembourg"                 , 0x02EDE2 },
-	{ "Europe/Madrid"                     , 0x02F238 },
-	{ "Europe/Malta"                      , 0x02F5FE },
-	{ "Europe/Mariehamn"                  , 0x02F9B7 },
-	{ "Europe/Minsk"                      , 0x02FC6D },
-	{ "Europe/Monaco"                     , 0x02FF78 },
-	{ "Europe/Moscow"                     , 0x0303B3 },
-	{ "Europe/Nicosia"                    , 0x030705 },
-	{ "Europe/Oslo"                       , 0x0309ED },
-	{ "Europe/Paris"                      , 0x030D1F },
-	{ "Europe/Podgorica"                  , 0x031165 },
-	{ "Europe/Prague"                     , 0x03142E },
-	{ "Europe/Riga"                       , 0x031760 },
-	{ "Europe/Rome"                       , 0x031AA5 },
-	{ "Europe/Samara"                     , 0x031E68 },
-	{ "Europe/San_Marino"                 , 0x032194 },
-	{ "Europe/Sarajevo"                   , 0x032557 },
-	{ "Europe/Simferopol"                 , 0x032820 },
-	{ "Europe/Skopje"                     , 0x032B4B },
-	{ "Europe/Sofia"                      , 0x032E14 },
-	{ "Europe/Stockholm"                  , 0x03311C },
-	{ "Europe/Tallinn"                    , 0x0333CB },
-	{ "Europe/Tirane"                     , 0x033705 },
-	{ "Europe/Tiraspol"                   , 0x033A0B },
-	{ "Europe/Uzhgorod"                   , 0x033D99 },
-	{ "Europe/Vaduz"                      , 0x0340B0 },
-	{ "Europe/Vatican"                    , 0x034343 },
-	{ "Europe/Vienna"                     , 0x034706 },
-	{ "Europe/Vilnius"                    , 0x034A33 },
-	{ "Europe/Volgograd"                  , 0x034D72 },
-	{ "Europe/Warsaw"                     , 0x03507B },
-	{ "Europe/Zagreb"                     , 0x03545C },
-	{ "Europe/Zaporozhye"                 , 0x035725 },
-	{ "Europe/Zurich"                     , 0x035A66 },
-	{ "Factory"                           , 0x035D15 },
-	{ "GB"                                , 0x035D86 },
-	{ "GB-Eire"                           , 0x0362BD },
-	{ "GMT"                               , 0x0367F4 },
-	{ "GMT+0"                             , 0x0368C0 },
-	{ "GMT-0"                             , 0x03687C },
-	{ "GMT0"                              , 0x036838 },
-	{ "Greenwich"                         , 0x036904 },
-	{ "Hongkong"                          , 0x036948 },
-	{ "HST"                               , 0x036B14 },
-	{ "Iceland"                           , 0x036B58 },
-	{ "Indian/Antananarivo"               , 0x036D11 },
-	{ "Indian/Chagos"                     , 0x036D85 },
-	{ "Indian/Christmas"                  , 0x036DE7 },
-	{ "Indian/Cocos"                      , 0x036E2B },
-	{ "Indian/Comoro"                     , 0x036E6F },
-	{ "Indian/Kerguelen"                  , 0x036EC4 },
-	{ "Indian/Mahe"                       , 0x036F19 },
-	{ "Indian/Maldives"                   , 0x036F6E },
-	{ "Indian/Mauritius"                  , 0x036FC3 },
-	{ "Indian/Mayotte"                    , 0x037039 },
-	{ "Indian/Reunion"                    , 0x03708E },
-	{ "Iran"                              , 0x0370E3 },
-	{ "Israel"                            , 0x037351 },
-	{ "Jamaica"                           , 0x037680 },
-	{ "Japan"                             , 0x037745 },
-	{ "Kwajalein"                         , 0x0377CE },
-	{ "Libya"                             , 0x037831 },
-	{ "MET"                               , 0x03792B },
-	{ "Mexico/BajaNorte"                  , 0x037C34 },
-	{ "Mexico/BajaSur"                    , 0x037F9D },
-	{ "Mexico/General"                    , 0x0381E2 },
-	{ "MST"                               , 0x038440 },
-	{ "MST7MDT"                           , 0x038484 },
-	{ "Navajo"                            , 0x0387D5 },
-	{ "NZ"                                , 0x038B4E },
-	{ "NZ-CHAT"                           , 0x038ECC },
-	{ "Pacific/Apia"                      , 0x0391B4 },
-	{ "Pacific/Auckland"                  , 0x039232 },
-	{ "Pacific/Chatham"                   , 0x0395BE },
-	{ "Pacific/Easter"                    , 0x0398B5 },
-	{ "Pacific/Efate"                     , 0x039C13 },
-	{ "Pacific/Enderbury"                 , 0x039CD9 },
-	{ "Pacific/Fakaofo"                   , 0x039D47 },
-	{ "Pacific/Fiji"                      , 0x039D8B },
-	{ "Pacific/Funafuti"                  , 0x039E01 },
-	{ "Pacific/Galapagos"                 , 0x039E45 },
-	{ "Pacific/Gambier"                   , 0x039EBD },
-	{ "Pacific/Guadalcanal"               , 0x039F22 },
-	{ "Pacific/Guam"                      , 0x039F77 },
-	{ "Pacific/Honolulu"                  , 0x039FCD },
-	{ "Pacific/Johnston"                  , 0x03A061 },
-	{ "Pacific/Kiritimati"                , 0x03A0B3 },
-	{ "Pacific/Kosrae"                    , 0x03A11E },
-	{ "Pacific/Kwajalein"                 , 0x03A17B },
-	{ "Pacific/Majuro"                    , 0x03A1E7 },
-	{ "Pacific/Marquesas"                 , 0x03A246 },
-	{ "Pacific/Midway"                    , 0x03A2AD },
-	{ "Pacific/Nauru"                     , 0x03A337 },
-	{ "Pacific/Niue"                      , 0x03A3AF },
-	{ "Pacific/Norfolk"                   , 0x03A40D },
-	{ "Pacific/Noumea"                    , 0x03A462 },
-	{ "Pacific/Pago_Pago"                 , 0x03A4F2 },
-	{ "Pacific/Palau"                     , 0x03A57B },
-	{ "Pacific/Pitcairn"                  , 0x03A5BF },
-	{ "Pacific/Ponape"                    , 0x03A614 },
-	{ "Pacific/Port_Moresby"              , 0x03A669 },
-	{ "Pacific/Rarotonga"                 , 0x03A6AD },
-	{ "Pacific/Saipan"                    , 0x03A789 },
-	{ "Pacific/Samoa"                     , 0x03A7EC },
-	{ "Pacific/Tahiti"                    , 0x03A875 },
-	{ "Pacific/Tarawa"                    , 0x03A8DA },
-	{ "Pacific/Tongatapu"                 , 0x03A92E },
-	{ "Pacific/Truk"                      , 0x03A9BA },
-	{ "Pacific/Wake"                      , 0x03AA13 },
-	{ "Pacific/Wallis"                    , 0x03AA63 },
-	{ "Pacific/Yap"                       , 0x03AAA7 },
-	{ "Poland"                            , 0x03AAEC },
-	{ "Portugal"                          , 0x03AECD },
-	{ "PRC"                               , 0x03B3C9 },
-	{ "PST8PDT"                           , 0x03B47A },
-	{ "ROC"                               , 0x03B7CB },
-	{ "ROK"                               , 0x03B8E3 },
-	{ "Singapore"                         , 0x03B987 },
-	{ "Turkey"                            , 0x03BA3E },
-	{ "UCT"                               , 0x03BE2B },
-	{ "Universal"                         , 0x03BE6F },
-	{ "US/Alaska"                         , 0x03BEB3 },
-	{ "US/Aleutian"                       , 0x03C21C },
-	{ "US/Arizona"                        , 0x03C582 },
-	{ "US/Central"                        , 0x03C610 },
-	{ "US/East-Indiana"                   , 0x03D01A },
-	{ "US/Eastern"                        , 0x03CB1B },
-	{ "US/Hawaii"                         , 0x03D284 },
-	{ "US/Indiana-Starke"                 , 0x03D312 },
-	{ "US/Michigan"                       , 0x03D683 },
-	{ "US/Mountain"                       , 0x03D9BA },
-	{ "US/Pacific"                        , 0x03DD33 },
-	{ "US/Pacific-New"                    , 0x03E138 },
-	{ "US/Samoa"                          , 0x03E53D },
-	{ "UTC"                               , 0x03E5C6 },
-	{ "W-SU"                              , 0x03E8BD },
-	{ "WET"                               , 0x03E60A },
-	{ "Zulu"                              , 0x03EBF8 },
+	{ "America/Coral_Harbour"             , 0x006795 },
+	{ "America/Cordoba"                   , 0x006827 },
+	{ "America/Costa_Rica"                , 0x0069CD },
+	{ "America/Cuiaba"                    , 0x006A57 },
+	{ "America/Curacao"                   , 0x006D35 },
+	{ "America/Danmarkshavn"              , 0x006D9B },
+	{ "America/Dawson"                    , 0x006EDF },
+	{ "America/Dawson_Creek"              , 0x0071FC },
+	{ "America/Denver"                    , 0x0073D6 },
+	{ "America/Detroit"                   , 0x00775C },
+	{ "America/Dominica"                  , 0x007ABB },
+	{ "America/Edmonton"                  , 0x007B10 },
+	{ "America/Eirunepe"                  , 0x007EC8 },
+	{ "America/El_Salvador"               , 0x007FDB },
+	{ "America/Ensenada"                  , 0x008050 },
+	{ "America/Fort_Wayne"                , 0x0084F7 },
+	{ "America/Fortaleza"                 , 0x0083B9 },
+	{ "America/Glace_Bay"                 , 0x008761 },
+	{ "America/Godthab"                   , 0x008AD8 },
+	{ "America/Goose_Bay"                 , 0x008D9C },
+	{ "America/Grand_Turk"                , 0x009259 },
+	{ "America/Grenada"                   , 0x009508 },
+	{ "America/Guadeloupe"                , 0x00955D },
+	{ "America/Guatemala"                 , 0x0095B2 },
+	{ "America/Guayaquil"                 , 0x00963B },
+	{ "America/Guyana"                    , 0x009698 },
+	{ "America/Halifax"                   , 0x009719 },
+	{ "America/Havana"                    , 0x009C2F },
+	{ "America/Hermosillo"                , 0x009FA2 },
+	{ "America/Indiana/Indianapolis"      , 0x00A080 },
+	{ "America/Indiana/Knox"              , 0x00A311 },
+	{ "America/Indiana/Marengo"           , 0x00A6A8 },
+	{ "America/Indiana/Petersburg"        , 0x00A94E },
+	{ "America/Indiana/Tell_City"         , 0x00AE9B },
+	{ "America/Indiana/Vevay"             , 0x00B134 },
+	{ "America/Indiana/Vincennes"         , 0x00B36F },
+	{ "America/Indiana/Winamac"           , 0x00B623 },
+	{ "America/Indianapolis"              , 0x00AC31 },
+	{ "America/Inuvik"                    , 0x00B8DC },
+	{ "America/Iqaluit"                   , 0x00BBD3 },
+	{ "America/Jamaica"                   , 0x00BEF5 },
+	{ "America/Jujuy"                     , 0x00BFBA },
+	{ "America/Juneau"                    , 0x00C164 },
+	{ "America/Kentucky/Louisville"       , 0x00C4E2 },
+	{ "America/Kentucky/Monticello"       , 0x00C900 },
+	{ "America/Knox_IN"                   , 0x00CC85 },
+	{ "America/La_Paz"                    , 0x00CFF6 },
+	{ "America/Lima"                      , 0x00D05D },
+	{ "America/Los_Angeles"               , 0x00D105 },
+	{ "America/Louisville"                , 0x00D516 },
+	{ "America/Maceio"                    , 0x00D90B },
+	{ "America/Managua"                   , 0x00DA45 },
+	{ "America/Manaus"                    , 0x00DAF8 },
+	{ "America/Marigot"                   , 0x00DBFA },
+	{ "America/Martinique"                , 0x00DC4F },
+	{ "America/Matamoros"                 , 0x00DCBB },
+	{ "America/Mazatlan"                  , 0x00DF14 },
+	{ "America/Mendoza"                   , 0x00E181 },
+	{ "America/Menominee"                 , 0x00E335 },
+	{ "America/Merida"                    , 0x00E6B6 },
+	{ "America/Mexico_City"               , 0x00E8F1 },
+	{ "America/Miquelon"                  , 0x00EB6C },
+	{ "America/Moncton"                   , 0x00EDDE },
+	{ "America/Monterrey"                 , 0x00F275 },
+	{ "America/Montevideo"                , 0x00F4D8 },
+	{ "America/Montreal"                  , 0x00F7EA },
+	{ "America/Montserrat"                , 0x00FD00 },
+	{ "America/Nassau"                    , 0x00FD55 },
+	{ "America/New_York"                  , 0x01009A },
+	{ "America/Nipigon"                   , 0x0105A5 },
+	{ "America/Nome"                      , 0x0108F6 },
+	{ "America/Noronha"                   , 0x010C74 },
+	{ "America/North_Dakota/Center"       , 0x010DA4 },
+	{ "America/North_Dakota/New_Salem"    , 0x011138 },
+	{ "America/Ojinaga"                   , 0x0114E1 },
+	{ "America/Panama"                    , 0x011742 },
+	{ "America/Pangnirtung"               , 0x011797 },
+	{ "America/Paramaribo"                , 0x011ACD },
+	{ "America/Phoenix"                   , 0x011B5F },
+	{ "America/Port-au-Prince"            , 0x011C0D },
+	{ "America/Port_of_Spain"             , 0x011E28 },
+	{ "America/Porto_Acre"                , 0x011D29 },
+	{ "America/Porto_Velho"               , 0x011E7D },
+	{ "America/Puerto_Rico"               , 0x011F73 },
+	{ "America/Rainy_River"               , 0x011FDE },
+	{ "America/Rankin_Inlet"              , 0x012316 },
+	{ "America/Recife"                    , 0x0125FC },
+	{ "America/Regina"                    , 0x012726 },
+	{ "America/Resolute"                  , 0x0128E4 },
+	{ "America/Rio_Branco"                , 0x012BDD },
+	{ "America/Rosario"                   , 0x012CE0 },
+	{ "America/Santa_Isabel"              , 0x012E86 },
+	{ "America/Santarem"                  , 0x013229 },
+	{ "America/Santiago"                  , 0x01332E },
+	{ "America/Santo_Domingo"             , 0x0136D7 },
+	{ "America/Sao_Paulo"                 , 0x01379D },
+	{ "America/Scoresbysund"              , 0x013AAC },
+	{ "America/Shiprock"                  , 0x013D9A },
+	{ "America/St_Barthelemy"             , 0x014129 },
+	{ "America/St_Johns"                  , 0x01417E },
+	{ "America/St_Kitts"                  , 0x0146D1 },
+	{ "America/St_Lucia"                  , 0x014726 },
+	{ "America/St_Thomas"                 , 0x01477B },
+	{ "America/St_Vincent"                , 0x0147D0 },
+	{ "America/Swift_Current"             , 0x014825 },
+	{ "America/Tegucigalpa"               , 0x014946 },
+	{ "America/Thule"                     , 0x0149C5 },
+	{ "America/Thunder_Bay"               , 0x014C0C },
+	{ "America/Tijuana"                   , 0x014F55 },
+	{ "America/Toronto"                   , 0x0152EE },
+	{ "America/Tortola"                   , 0x015805 },
+	{ "America/Vancouver"                 , 0x01585A },
+	{ "America/Virgin"                    , 0x015C97 },
+	{ "America/Whitehorse"                , 0x015CEC },
+	{ "America/Winnipeg"                  , 0x016009 },
+	{ "America/Yakutat"                   , 0x016449 },
+	{ "America/Yellowknife"               , 0x0167B4 },
+	{ "Antarctica/Casey"                  , 0x016AC4 },
+	{ "Antarctica/Davis"                  , 0x016B4A },
+	{ "Antarctica/DumontDUrville"         , 0x016BD4 },
+	{ "Antarctica/Mawson"                 , 0x016C66 },
+	{ "Antarctica/McMurdo"                , 0x016CE2 },
+	{ "Antarctica/Palmer"                 , 0x016FE4 },
+	{ "Antarctica/Rothera"                , 0x017300 },
+	{ "Antarctica/South_Pole"             , 0x017376 },
+	{ "Antarctica/Syowa"                  , 0x01767E },
+	{ "Antarctica/Vostok"                 , 0x0176EC },
+	{ "Arctic/Longyearbyen"               , 0x017761 },
+	{ "Asia/Aden"                         , 0x017A93 },
+	{ "Asia/Almaty"                       , 0x017AE8 },
+	{ "Asia/Amman"                        , 0x017C67 },
+	{ "Asia/Anadyr"                       , 0x017F27 },
+	{ "Asia/Aqtau"                        , 0x018215 },
+	{ "Asia/Aqtobe"                       , 0x018414 },
+	{ "Asia/Ashgabat"                     , 0x0185CC },
+	{ "Asia/Ashkhabad"                    , 0x0186E9 },
+	{ "Asia/Baghdad"                      , 0x018806 },
+	{ "Asia/Bahrain"                      , 0x01897B },
+	{ "Asia/Baku"                         , 0x0189E1 },
+	{ "Asia/Bangkok"                      , 0x018CC9 },
+	{ "Asia/Beirut"                       , 0x018D1E },
+	{ "Asia/Bishkek"                      , 0x01902B },
+	{ "Asia/Brunei"                       , 0x0191D7 },
+	{ "Asia/Calcutta"                     , 0x019239 },
+	{ "Asia/Choibalsan"                   , 0x0192B2 },
+	{ "Asia/Chongqing"                    , 0x01942B },
+	{ "Asia/Chungking"                    , 0x01951A },
+	{ "Asia/Colombo"                      , 0x0195C9 },
+	{ "Asia/Dacca"                        , 0x019665 },
+	{ "Asia/Damascus"                     , 0x019823 },
+	{ "Asia/Dhaka"                        , 0x019B73 },
+	{ "Asia/Dili"                         , 0x019D31 },
+	{ "Asia/Dubai"                        , 0x019DBA },
+	{ "Asia/Dushanbe"                     , 0x019E0F },
+	{ "Asia/Gaza"                         , 0x019F12 },
+	{ "Asia/Harbin"                       , 0x01A25B },
+	{ "Asia/Ho_Chi_Minh"                  , 0x01A342 },
+	{ "Asia/Hong_Kong"                    , 0x01A3BA },
+	{ "Asia/Hovd"                         , 0x01A586 },
+	{ "Asia/Irkutsk"                      , 0x01A6FE },
+	{ "Asia/Istanbul"                     , 0x01A9E5 },
+	{ "Asia/Jakarta"                      , 0x01ADD2 },
+	{ "Asia/Jayapura"                     , 0x01AE7C },
+	{ "Asia/Jerusalem"                    , 0x01AF00 },
+	{ "Asia/Kabul"                        , 0x01B22F },
+	{ "Asia/Kamchatka"                    , 0x01B280 },
+	{ "Asia/Karachi"                      , 0x01B565 },
+	{ "Asia/Kashgar"                      , 0x01B732 },
+	{ "Asia/Kathmandu"                    , 0x01B803 },
+	{ "Asia/Katmandu"                     , 0x01B869 },
+	{ "Asia/Kolkata"                      , 0x01B8CF },
+	{ "Asia/Krasnoyarsk"                  , 0x01B948 },
+	{ "Asia/Kuala_Lumpur"                 , 0x01BC31 },
+	{ "Asia/Kuching"                      , 0x01BCEE },
+	{ "Asia/Kuwait"                       , 0x01BDDC },
+	{ "Asia/Macao"                        , 0x01BE31 },
+	{ "Asia/Macau"                        , 0x01BF6C },
+	{ "Asia/Magadan"                      , 0x01C0A7 },
+	{ "Asia/Makassar"                     , 0x01C38A },
+	{ "Asia/Manila"                       , 0x01C443 },
+	{ "Asia/Muscat"                       , 0x01C4C8 },
+	{ "Asia/Nicosia"                      , 0x01C51D },
+	{ "Asia/Novokuznetsk"                 , 0x01C805 },
+	{ "Asia/Novosibirsk"                  , 0x01CB08 },
+	{ "Asia/Omsk"                         , 0x01CDFC },
+	{ "Asia/Oral"                         , 0x01D0E4 },
+	{ "Asia/Phnom_Penh"                   , 0x01D2B4 },
+	{ "Asia/Pontianak"                    , 0x01D32C },
+	{ "Asia/Pyongyang"                    , 0x01D3ED },
+	{ "Asia/Qatar"                        , 0x01D45A },
+	{ "Asia/Qyzylorda"                    , 0x01D4C0 },
+	{ "Asia/Rangoon"                      , 0x01D696 },
+	{ "Asia/Riyadh"                       , 0x01D70E },
+	{ "Asia/Saigon"                       , 0x01D763 },
+	{ "Asia/Sakhalin"                     , 0x01D7DB },
+	{ "Asia/Samarkand"                    , 0x01DADB },
+	{ "Asia/Seoul"                        , 0x01DC11 },
+	{ "Asia/Shanghai"                     , 0x01DCB5 },
+	{ "Asia/Singapore"                    , 0x01DD95 },
+	{ "Asia/Taipei"                       , 0x01DE4C },
+	{ "Asia/Tashkent"                     , 0x01DF64 },
+	{ "Asia/Tbilisi"                      , 0x01E095 },
+	{ "Asia/Tehran"                       , 0x01E24F },
+	{ "Asia/Tel_Aviv"                     , 0x01E4BD },
+	{ "Asia/Thimbu"                       , 0x01E7EC },
+	{ "Asia/Thimphu"                      , 0x01E852 },
+	{ "Asia/Tokyo"                        , 0x01E8B8 },
+	{ "Asia/Ujung_Pandang"                , 0x01E941 },
+	{ "Asia/Ulaanbaatar"                  , 0x01E9BD },
+	{ "Asia/Ulan_Bator"                   , 0x01EB18 },
+	{ "Asia/Urumqi"                       , 0x01EC65 },
+	{ "Asia/Vientiane"                    , 0x01ED2C },
+	{ "Asia/Vladivostok"                  , 0x01EDA4 },
+	{ "Asia/Yakutsk"                      , 0x01F091 },
+	{ "Asia/Yekaterinburg"                , 0x01F377 },
+	{ "Asia/Yerevan"                      , 0x01F683 },
+	{ "Atlantic/Azores"                   , 0x01F987 },
+	{ "Atlantic/Bermuda"                  , 0x01FE8A },
+	{ "Atlantic/Canary"                   , 0x02016B },
+	{ "Atlantic/Cape_Verde"               , 0x020441 },
+	{ "Atlantic/Faeroe"                   , 0x0204BA },
+	{ "Atlantic/Faroe"                    , 0x02075E },
+	{ "Atlantic/Jan_Mayen"                , 0x020A02 },
+	{ "Atlantic/Madeira"                  , 0x020D34 },
+	{ "Atlantic/Reykjavik"                , 0x02123D },
+	{ "Atlantic/South_Georgia"            , 0x0213F6 },
+	{ "Atlantic/St_Helena"                , 0x02170E },
+	{ "Atlantic/Stanley"                  , 0x02143A },
+	{ "Australia/ACT"                     , 0x021763 },
+	{ "Australia/Adelaide"                , 0x021A80 },
+	{ "Australia/Brisbane"                , 0x021DAC },
+	{ "Australia/Broken_Hill"             , 0x021E73 },
+	{ "Australia/Canberra"                , 0x0221B1 },
+	{ "Australia/Currie"                  , 0x0224CE },
+	{ "Australia/Darwin"                  , 0x022801 },
+	{ "Australia/Eucla"                   , 0x022887 },
+	{ "Australia/Hobart"                  , 0x02295C },
+	{ "Australia/LHI"                     , 0x022CBA },
+	{ "Australia/Lindeman"                , 0x022F55 },
+	{ "Australia/Lord_Howe"               , 0x023036 },
+	{ "Australia/Melbourne"               , 0x0232E1 },
+	{ "Australia/North"                   , 0x023606 },
+	{ "Australia/NSW"                     , 0x02367A },
+	{ "Australia/Perth"                   , 0x023997 },
+	{ "Australia/Queensland"              , 0x023A6F },
+	{ "Australia/South"                   , 0x023B1B },
+	{ "Australia/Sydney"                  , 0x023E38 },
+	{ "Australia/Tasmania"                , 0x024175 },
+	{ "Australia/Victoria"                , 0x0244BA },
+	{ "Australia/West"                    , 0x0247D7 },
+	{ "Australia/Yancowinna"              , 0x02488D },
+	{ "Brazil/Acre"                       , 0x024BAF },
+	{ "Brazil/DeNoronha"                  , 0x024CAE },
+	{ "Brazil/East"                       , 0x024DCE },
+	{ "Brazil/West"                       , 0x0250AB },
+	{ "Canada/Atlantic"                   , 0x0251A3 },
+	{ "Canada/Central"                    , 0x02568B },
+	{ "Canada/East-Saskatchewan"          , 0x025F95 },
+	{ "Canada/Eastern"                    , 0x025AA5 },
+	{ "Canada/Mountain"                   , 0x02611E },
+	{ "Canada/Newfoundland"               , 0x026494 },
+	{ "Canada/Pacific"                    , 0x0269BF },
+	{ "Canada/Saskatchewan"               , 0x026DD8 },
+	{ "Canada/Yukon"                      , 0x026F61 },
+	{ "CET"                               , 0x027264 },
+	{ "Chile/Continental"                 , 0x02756D },
+	{ "Chile/EasterIsland"                , 0x027908 },
+	{ "CST6CDT"                           , 0x027C4A },
+	{ "Cuba"                              , 0x027F9B },
+	{ "EET"                               , 0x02830E },
+	{ "Egypt"                             , 0x0285C1 },
+	{ "Eire"                              , 0x028988 },
+	{ "EST"                               , 0x028E99 },
+	{ "EST5EDT"                           , 0x028EDD },
+	{ "Etc/GMT"                           , 0x02922E },
+	{ "Etc/GMT+0"                         , 0x0292FA },
+	{ "Etc/GMT+1"                         , 0x029384 },
+	{ "Etc/GMT+10"                        , 0x029411 },
+	{ "Etc/GMT+11"                        , 0x02949F },
+	{ "Etc/GMT+12"                        , 0x02952D },
+	{ "Etc/GMT+2"                         , 0x029648 },
+	{ "Etc/GMT+3"                         , 0x0296D4 },
+	{ "Etc/GMT+4"                         , 0x029760 },
+	{ "Etc/GMT+5"                         , 0x0297EC },
+	{ "Etc/GMT+6"                         , 0x029878 },
+	{ "Etc/GMT+7"                         , 0x029904 },
+	{ "Etc/GMT+8"                         , 0x029990 },
+	{ "Etc/GMT+9"                         , 0x029A1C },
+	{ "Etc/GMT-0"                         , 0x0292B6 },
+	{ "Etc/GMT-1"                         , 0x02933E },
+	{ "Etc/GMT-10"                        , 0x0293CA },
+	{ "Etc/GMT-11"                        , 0x029458 },
+	{ "Etc/GMT-12"                        , 0x0294E6 },
+	{ "Etc/GMT-13"                        , 0x029574 },
+	{ "Etc/GMT-14"                        , 0x0295BB },
+	{ "Etc/GMT-2"                         , 0x029602 },
+	{ "Etc/GMT-3"                         , 0x02968E },
+	{ "Etc/GMT-4"                         , 0x02971A },
+	{ "Etc/GMT-5"                         , 0x0297A6 },
+	{ "Etc/GMT-6"                         , 0x029832 },
+	{ "Etc/GMT-7"                         , 0x0298BE },
+	{ "Etc/GMT-8"                         , 0x02994A },
+	{ "Etc/GMT-9"                         , 0x0299D6 },
+	{ "Etc/GMT0"                          , 0x029272 },
+	{ "Etc/Greenwich"                     , 0x029A62 },
+	{ "Etc/UCT"                           , 0x029AA6 },
+	{ "Etc/Universal"                     , 0x029AEA },
+	{ "Etc/UTC"                           , 0x029B2E },
+	{ "Etc/Zulu"                          , 0x029B72 },
+	{ "Europe/Amsterdam"                  , 0x029BB6 },
+	{ "Europe/Andorra"                    , 0x029FF4 },
+	{ "Europe/Athens"                     , 0x02A270 },
+	{ "Europe/Belfast"                    , 0x02A5B3 },
+	{ "Europe/Belgrade"                   , 0x02AAEA },
+	{ "Europe/Berlin"                     , 0x02ADB3 },
+	{ "Europe/Bratislava"                 , 0x02B109 },
+	{ "Europe/Brussels"                   , 0x02B43B },
+	{ "Europe/Bucharest"                  , 0x02B872 },
+	{ "Europe/Budapest"                   , 0x02BB9C },
+	{ "Europe/Chisinau"                   , 0x02BF0F },
+	{ "Europe/Copenhagen"                 , 0x02C29D },
+	{ "Europe/Dublin"                     , 0x02C5A7 },
+	{ "Europe/Gibraltar"                  , 0x02CAB8 },
+	{ "Europe/Guernsey"                   , 0x02CF0F },
+	{ "Europe/Helsinki"                   , 0x02D446 },
+	{ "Europe/Isle_of_Man"                , 0x02D6FC },
+	{ "Europe/Istanbul"                   , 0x02DC33 },
+	{ "Europe/Jersey"                     , 0x02E020 },
+	{ "Europe/Kaliningrad"                , 0x02E557 },
+	{ "Europe/Kiev"                       , 0x02E8BA },
+	{ "Europe/Lisbon"                     , 0x02EBD1 },
+	{ "Europe/Ljubljana"                  , 0x02F0D5 },
+	{ "Europe/London"                     , 0x02F39E },
+	{ "Europe/Luxembourg"                 , 0x02F8D5 },
+	{ "Europe/Madrid"                     , 0x02FD2B },
+	{ "Europe/Malta"                      , 0x0300F1 },
+	{ "Europe/Mariehamn"                  , 0x0304AA },
+	{ "Europe/Minsk"                      , 0x030760 },
+	{ "Europe/Monaco"                     , 0x030A6B },
+	{ "Europe/Moscow"                     , 0x030EA6 },
+	{ "Europe/Nicosia"                    , 0x0311F8 },
+	{ "Europe/Oslo"                       , 0x0314E0 },
+	{ "Europe/Paris"                      , 0x031812 },
+	{ "Europe/Podgorica"                  , 0x031C58 },
+	{ "Europe/Prague"                     , 0x031F21 },
+	{ "Europe/Riga"                       , 0x032253 },
+	{ "Europe/Rome"                       , 0x032598 },
+	{ "Europe/Samara"                     , 0x03295B },
+	{ "Europe/San_Marino"                 , 0x032C87 },
+	{ "Europe/Sarajevo"                   , 0x03304A },
+	{ "Europe/Simferopol"                 , 0x033313 },
+	{ "Europe/Skopje"                     , 0x03363E },
+	{ "Europe/Sofia"                      , 0x033907 },
+	{ "Europe/Stockholm"                  , 0x033C0F },
+	{ "Europe/Tallinn"                    , 0x033EBE },
+	{ "Europe/Tirane"                     , 0x0341F8 },
+	{ "Europe/Tiraspol"                   , 0x0344FE },
+	{ "Europe/Uzhgorod"                   , 0x03488C },
+	{ "Europe/Vaduz"                      , 0x034BA3 },
+	{ "Europe/Vatican"                    , 0x034E36 },
+	{ "Europe/Vienna"                     , 0x0351F9 },
+	{ "Europe/Vilnius"                    , 0x035526 },
+	{ "Europe/Volgograd"                  , 0x035865 },
+	{ "Europe/Warsaw"                     , 0x035B6E },
+	{ "Europe/Zagreb"                     , 0x035F4F },
+	{ "Europe/Zaporozhye"                 , 0x036218 },
+	{ "Europe/Zurich"                     , 0x036559 },
+	{ "Factory"                           , 0x036808 },
+	{ "GB"                                , 0x036879 },
+	{ "GB-Eire"                           , 0x036DB0 },
+	{ "GMT"                               , 0x0372E7 },
+	{ "GMT+0"                             , 0x0373B3 },
+	{ "GMT-0"                             , 0x03736F },
+	{ "GMT0"                              , 0x03732B },
+	{ "Greenwich"                         , 0x0373F7 },
+	{ "Hongkong"                          , 0x03743B },
+	{ "HST"                               , 0x037607 },
+	{ "Iceland"                           , 0x03764B },
+	{ "Indian/Antananarivo"               , 0x037804 },
+	{ "Indian/Chagos"                     , 0x037878 },
+	{ "Indian/Christmas"                  , 0x0378DA },
+	{ "Indian/Cocos"                      , 0x03791E },
+	{ "Indian/Comoro"                     , 0x037962 },
+	{ "Indian/Kerguelen"                  , 0x0379B7 },
+	{ "Indian/Mahe"                       , 0x037A0C },
+	{ "Indian/Maldives"                   , 0x037A61 },
+	{ "Indian/Mauritius"                  , 0x037AB6 },
+	{ "Indian/Mayotte"                    , 0x037B2C },
+	{ "Indian/Reunion"                    , 0x037B81 },
+	{ "Iran"                              , 0x037BD6 },
+	{ "Israel"                            , 0x037E44 },
+	{ "Jamaica"                           , 0x038173 },
+	{ "Japan"                             , 0x038238 },
+	{ "Kwajalein"                         , 0x0382C1 },
+	{ "Libya"                             , 0x038324 },
+	{ "MET"                               , 0x03841E },
+	{ "Mexico/BajaNorte"                  , 0x038727 },
+	{ "Mexico/BajaSur"                    , 0x038A90 },
+	{ "Mexico/General"                    , 0x038CD5 },
+	{ "MST"                               , 0x038F33 },
+	{ "MST7MDT"                           , 0x038F77 },
+	{ "Navajo"                            , 0x0392C8 },
+	{ "NZ"                                , 0x039641 },
+	{ "NZ-CHAT"                           , 0x0399BF },
+	{ "Pacific/Apia"                      , 0x039CA7 },
+	{ "Pacific/Auckland"                  , 0x039D25 },
+	{ "Pacific/Chatham"                   , 0x03A0B1 },
+	{ "Pacific/Easter"                    , 0x03A3A8 },
+	{ "Pacific/Efate"                     , 0x03A706 },
+	{ "Pacific/Enderbury"                 , 0x03A7CC },
+	{ "Pacific/Fakaofo"                   , 0x03A83A },
+	{ "Pacific/Fiji"                      , 0x03A87E },
+	{ "Pacific/Funafuti"                  , 0x03A8FE },
+	{ "Pacific/Galapagos"                 , 0x03A942 },
+	{ "Pacific/Gambier"                   , 0x03A9BA },
+	{ "Pacific/Guadalcanal"               , 0x03AA1F },
+	{ "Pacific/Guam"                      , 0x03AA74 },
+	{ "Pacific/Honolulu"                  , 0x03AACA },
+	{ "Pacific/Johnston"                  , 0x03AB5E },
+	{ "Pacific/Kiritimati"                , 0x03ABB0 },
+	{ "Pacific/Kosrae"                    , 0x03AC1B },
+	{ "Pacific/Kwajalein"                 , 0x03AC78 },
+	{ "Pacific/Majuro"                    , 0x03ACE4 },
+	{ "Pacific/Marquesas"                 , 0x03AD43 },
+	{ "Pacific/Midway"                    , 0x03ADAA },
+	{ "Pacific/Nauru"                     , 0x03AE34 },
+	{ "Pacific/Niue"                      , 0x03AEAC },
+	{ "Pacific/Norfolk"                   , 0x03AF0A },
+	{ "Pacific/Noumea"                    , 0x03AF5F },
+	{ "Pacific/Pago_Pago"                 , 0x03AFEF },
+	{ "Pacific/Palau"                     , 0x03B078 },
+	{ "Pacific/Pitcairn"                  , 0x03B0BC },
+	{ "Pacific/Ponape"                    , 0x03B111 },
+	{ "Pacific/Port_Moresby"              , 0x03B166 },
+	{ "Pacific/Rarotonga"                 , 0x03B1AA },
+	{ "Pacific/Saipan"                    , 0x03B286 },
+	{ "Pacific/Samoa"                     , 0x03B2E9 },
+	{ "Pacific/Tahiti"                    , 0x03B372 },
+	{ "Pacific/Tarawa"                    , 0x03B3D7 },
+	{ "Pacific/Tongatapu"                 , 0x03B42B },
+	{ "Pacific/Truk"                      , 0x03B4B7 },
+	{ "Pacific/Wake"                      , 0x03B510 },
+	{ "Pacific/Wallis"                    , 0x03B560 },
+	{ "Pacific/Yap"                       , 0x03B5A4 },
+	{ "Poland"                            , 0x03B5E9 },
+	{ "Portugal"                          , 0x03B9CA },
+	{ "PRC"                               , 0x03BEC6 },
+	{ "PST8PDT"                           , 0x03BF77 },
+	{ "ROC"                               , 0x03C2C8 },
+	{ "ROK"                               , 0x03C3E0 },
+	{ "Singapore"                         , 0x03C484 },
+	{ "Turkey"                            , 0x03C53B },
+	{ "UCT"                               , 0x03C928 },
+	{ "Universal"                         , 0x03C96C },
+	{ "US/Alaska"                         , 0x03C9B0 },
+	{ "US/Aleutian"                       , 0x03CD19 },
+	{ "US/Arizona"                        , 0x03D07F },
+	{ "US/Central"                        , 0x03D10D },
+	{ "US/East-Indiana"                   , 0x03DB17 },
+	{ "US/Eastern"                        , 0x03D618 },
+	{ "US/Hawaii"                         , 0x03DD81 },
+	{ "US/Indiana-Starke"                 , 0x03DE0F },
+	{ "US/Michigan"                       , 0x03E180 },
+	{ "US/Mountain"                       , 0x03E4B7 },
+	{ "US/Pacific"                        , 0x03E830 },
+	{ "US/Pacific-New"                    , 0x03EC35 },
+	{ "US/Samoa"                          , 0x03F03A },
+	{ "UTC"                               , 0x03F0C3 },
+	{ "W-SU"                              , 0x03F3BA },
+	{ "WET"                               , 0x03F107 },
+	{ "Zulu"                              , 0x03F6F5 },
 };
 /* This is a generated file, do not modify */
-const unsigned char timelib_timezone_db_data_builtin[257084] = {
+const unsigned char timelib_timezone_db_data_builtin[259897] = {
 
 
 /* Africa/Abidjan */
@@ -1822,21 +1825,21 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 0x3D, 0x71, 0x90, 0xC0, 0x3E, 0x8F, 0x98, 0x30, 0x3F, 0x5A, 0xAD, 0x40, 0x40, 0x6F, 0x7A, 0x30, 
 0x41, 0x71, 0xEE, 0x40, 0x42, 0x33, 0xAC, 0xB0, 0x43, 0x51, 0xD0, 0x40, 0x44, 0x13, 0x8E, 0xB0, 
 0x45, 0x31, 0xB2, 0x40, 0x45, 0xF3, 0x70, 0xB0, 0x47, 0x1A, 0xCE, 0xC0, 0x47, 0xD3, 0x52, 0xB0, 
-0x48, 0xFA, 0xB0, 0xC0, 0x49, 0xB3, 0x34, 0xB0, 0x4A, 0xDA, 0x92, 0xC0, 0x4B, 0x9C, 0x51, 0x30, 
-0x4C, 0xBA, 0x74, 0xC0, 0x4D, 0x7C, 0x33, 0x30, 0x4E, 0x9A, 0x56, 0xC0, 0x4F, 0x5C, 0x15, 0x30, 
-0x50, 0x83, 0x73, 0x40, 0x51, 0x3B, 0xF7, 0x30, 0x52, 0x63, 0x55, 0x40, 0x53, 0x1B, 0xD9, 0x30, 
-0x54, 0x43, 0x37, 0x40, 0x54, 0xFB, 0xBB, 0x30, 0x56, 0x23, 0x19, 0x40, 0x56, 0xE4, 0xD7, 0xB0, 
-0x58, 0x02, 0xFB, 0x40, 0x58, 0xC4, 0xB9, 0xB0, 0x59, 0xE2, 0xDD, 0x40, 0x5A, 0xA4, 0x9B, 0xB0, 
-0x5B, 0xCB, 0xF9, 0xC0, 0x5C, 0x84, 0x7D, 0xB0, 0x5D, 0xAB, 0xDB, 0xC0, 0x5E, 0x64, 0x5F, 0xB0, 
-0x5F, 0x8B, 0xBD, 0xC0, 0x60, 0x4D, 0x7C, 0x30, 0x61, 0x6B, 0x9F, 0xC0, 0x62, 0x2D, 0x5E, 0x30, 
-0x63, 0x4B, 0x81, 0xC0, 0x64, 0x0D, 0x40, 0x30, 0x65, 0x2B, 0x63, 0xC0, 0x65, 0xED, 0x22, 0x30, 
-0x67, 0x14, 0x80, 0x40, 0x67, 0xCD, 0x04, 0x30, 0x68, 0xF4, 0x62, 0x40, 0x69, 0xAC, 0xE6, 0x30, 
-0x6A, 0xD4, 0x44, 0x40, 0x6B, 0x96, 0x02, 0xB0, 0x6C, 0xB4, 0x26, 0x40, 0x6D, 0x75, 0xE4, 0xB0, 
-0x6E, 0x94, 0x08, 0x40, 0x6F, 0x55, 0xC6, 0xB0, 0x70, 0x7D, 0x24, 0xC0, 0x71, 0x35, 0xA8, 0xB0, 
-0x72, 0x5D, 0x06, 0xC0, 0x73, 0x15, 0x8A, 0xB0, 0x74, 0x3C, 0xE8, 0xC0, 0x74, 0xFE, 0xA7, 0x30, 
-0x76, 0x1C, 0xCA, 0xC0, 0x76, 0xDE, 0x89, 0x30, 0x77, 0xFC, 0xAC, 0xC0, 0x78, 0xBE, 0x6B, 0x30, 
-0x79, 0xDC, 0x8E, 0xC0, 0x7A, 0x9E, 0x4D, 0x30, 0x7B, 0xC5, 0xAB, 0x40, 0x7C, 0x7E, 0x2F, 0x30, 
-0x7D, 0xA5, 0x8D, 0x40, 0x7E, 0x5E, 0x11, 0x30, 0x7F, 0x85, 0x6F, 0x40, 0x01, 0x02, 0x01, 0x03, 
+0x48, 0xFA, 0xB0, 0xC0, 0x49, 0xB3, 0x34, 0xB0, 0x4A, 0xDA, 0x92, 0xC0, 0x4B, 0xC1, 0x3B, 0x30, 
+0x4C, 0xA7, 0xFF, 0xC0, 0x4D, 0xA1, 0x1D, 0x30, 0x4E, 0x87, 0xE1, 0xC0, 0x4F, 0x80, 0xFF, 0x30, 
+0x50, 0x70, 0xFE, 0x40, 0x51, 0x6A, 0x1B, 0xB0, 0x52, 0x50, 0xE0, 0x40, 0x53, 0x49, 0xFD, 0xB0, 
+0x54, 0x30, 0xC2, 0x40, 0x55, 0x29, 0xDF, 0xB0, 0x56, 0x10, 0xA4, 0x40, 0x57, 0x09, 0xC1, 0xB0, 
+0x57, 0xF0, 0x86, 0x40, 0x58, 0xE9, 0xA3, 0xB0, 0x59, 0xD0, 0x68, 0x40, 0x5A, 0xC9, 0x85, 0xB0, 
+0x5B, 0xB9, 0x84, 0xC0, 0x5C, 0xB2, 0xA2, 0x30, 0x5D, 0x99, 0x66, 0xC0, 0x5E, 0x92, 0x84, 0x30, 
+0x5F, 0x79, 0x48, 0xC0, 0x60, 0x72, 0x66, 0x30, 0x61, 0x59, 0x2A, 0xC0, 0x62, 0x52, 0x48, 0x30, 
+0x63, 0x39, 0x0C, 0xC0, 0x64, 0x32, 0x2A, 0x30, 0x65, 0x18, 0xEE, 0xC0, 0x66, 0x1B, 0x46, 0xB0, 
+0x67, 0x02, 0x0B, 0x40, 0x67, 0xFB, 0x28, 0xB0, 0x68, 0xE1, 0xED, 0x40, 0x69, 0xDB, 0x0A, 0xB0, 
+0x6A, 0xC1, 0xCF, 0x40, 0x6B, 0xBA, 0xEC, 0xB0, 0x6C, 0xA1, 0xB1, 0x40, 0x6D, 0x9A, 0xCE, 0xB0, 
+0x6E, 0x81, 0x93, 0x40, 0x6F, 0x7A, 0xB0, 0xB0, 0x70, 0x6A, 0xAF, 0xC0, 0x71, 0x63, 0xCD, 0x30, 
+0x72, 0x4A, 0x91, 0xC0, 0x73, 0x43, 0xAF, 0x30, 0x74, 0x2A, 0x73, 0xC0, 0x75, 0x23, 0x91, 0x30, 
+0x76, 0x0A, 0x55, 0xC0, 0x77, 0x03, 0x73, 0x30, 0x77, 0xEA, 0x37, 0xC0, 0x78, 0xE3, 0x55, 0x30, 
+0x79, 0xCA, 0x19, 0xC0, 0x7A, 0xC3, 0x37, 0x30, 0x7B, 0xB3, 0x36, 0x40, 0x7C, 0xAC, 0x53, 0xB0, 
+0x7D, 0x93, 0x18, 0x40, 0x7E, 0x8C, 0x35, 0xB0, 0x7F, 0x72, 0xFA, 0x40, 0x01, 0x02, 0x01, 0x03, 
 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 
 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 
 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 
@@ -2452,8 +2455,10 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 0xFF, 0xFF, 0xB9, 0xB0, 0x01, 0x0C, 0xFF, 0xFF, 0xAB, 0xA0, 0x01, 0x10, 0x4C, 0x4D, 0x54, 0x00, 
 0x4D, 0x53, 0x54, 0x00, 0x43, 0x53, 0x54, 0x00, 0x43, 0x44, 0x54, 0x00, 0x4D, 0x44, 0x54, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB5, 0x05, 0x25, 0x00, 0x70, 
-0xC9, 0xB2, 0x00, 0x00, 0x00, 0x19, 0x4D, 0x6F, 0x75, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x20, 0x54, 
-0x69, 0x6D, 0x65, 0x20, 0x2D, 0x20, 0x43, 0x68, 0x69, 0x68, 0x75, 0x61, 0x68, 0x75, 0x61, 
+0xC9, 0xB2, 0x00, 0x00, 0x00, 0x35, 0x4D, 0x65, 0x78, 0x69, 0x63, 0x61, 0x6E, 0x20, 0x4D, 0x6F, 
+0x75, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x20, 0x54, 0x69, 0x6D, 0x65, 0x20, 0x2D, 0x20, 0x43, 0x68, 
+0x69, 0x68, 0x75, 0x61, 0x68, 0x75, 0x61, 0x20, 0x61, 0x77, 0x61, 0x79, 0x20, 0x66, 0x72, 0x6F, 
+0x6D, 0x20, 0x55, 0x53, 0x20, 0x62, 0x6F, 0x72, 0x64, 0x65, 0x72, 
 
 /* America/Coral_Harbour */
 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -2913,20 +2918,20 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 0x40, 0x6F, 0xDC, 0xA0, 0x41, 0x84, 0xA9, 0x90, 0x42, 0x4F, 0xBE, 0xA0, 0x43, 0x64, 0x8B, 0x90, 
 0x44, 0x2F, 0xA0, 0xA0, 0x45, 0x44, 0x6D, 0x90, 0x46, 0x0F, 0x82, 0xA0, 0x47, 0x24, 0x4F, 0x90, 
 0x47, 0xF8, 0x9F, 0x20, 0x49, 0x04, 0x31, 0x90, 0x49, 0xD8, 0x81, 0x20, 0x4A, 0xE4, 0x13, 0x90, 
-0x4B, 0xB8, 0x63, 0x20, 0x4C, 0xCD, 0x30, 0x10, 0x4D, 0x98, 0x45, 0x20, 0x4E, 0xAD, 0x12, 0x10, 
-0x4F, 0x78, 0x27, 0x20, 0x50, 0x8C, 0xF4, 0x10, 0x51, 0x61, 0x43, 0xA0, 0x52, 0x6C, 0xD6, 0x10, 
-0x53, 0x41, 0x25, 0xA0, 0x54, 0x4C, 0xB8, 0x10, 0x55, 0x21, 0x07, 0xA0, 0x56, 0x2C, 0x9A, 0x10, 
-0x57, 0x00, 0xE9, 0xA0, 0x58, 0x15, 0xB6, 0x90, 0x58, 0xE0, 0xCB, 0xA0, 0x59, 0xF5, 0x98, 0x90, 
-0x5A, 0xC0, 0xAD, 0xA0, 0x5B, 0xD5, 0x7A, 0x90, 0x5C, 0xA9, 0xCA, 0x20, 0x5D, 0xB5, 0x5C, 0x90, 
-0x5E, 0x89, 0xAC, 0x20, 0x5F, 0x95, 0x3E, 0x90, 0x60, 0x69, 0x8E, 0x20, 0x61, 0x7E, 0x5B, 0x10, 
-0x62, 0x49, 0x70, 0x20, 0x63, 0x5E, 0x3D, 0x10, 0x64, 0x29, 0x52, 0x20, 0x65, 0x3E, 0x1F, 0x10, 
-0x66, 0x12, 0x6E, 0xA0, 0x67, 0x1E, 0x01, 0x10, 0x67, 0xF2, 0x50, 0xA0, 0x68, 0xFD, 0xE3, 0x10, 
-0x69, 0xD2, 0x32, 0xA0, 0x6A, 0xDD, 0xC5, 0x10, 0x6B, 0xB2, 0x14, 0xA0, 0x6C, 0xC6, 0xE1, 0x90, 
-0x6D, 0x91, 0xF6, 0xA0, 0x6E, 0xA6, 0xC3, 0x90, 0x6F, 0x71, 0xD8, 0xA0, 0x70, 0x86, 0xA5, 0x90, 
-0x71, 0x5A, 0xF5, 0x20, 0x72, 0x66, 0x87, 0x90, 0x73, 0x3A, 0xD7, 0x20, 0x74, 0x46, 0x69, 0x90, 
-0x75, 0x1A, 0xB9, 0x20, 0x76, 0x2F, 0x86, 0x10, 0x76, 0xFA, 0x9B, 0x20, 0x78, 0x0F, 0x68, 0x10, 
-0x78, 0xDA, 0x7D, 0x20, 0x79, 0xEF, 0x4A, 0x10, 0x7A, 0xBA, 0x5F, 0x20, 0x7B, 0xCF, 0x2C, 0x10, 
-0x7C, 0xA3, 0x7B, 0xA0, 0x7D, 0xAF, 0x0E, 0x10, 0x7E, 0x83, 0x5D, 0xA0, 0x7F, 0x8E, 0xF0, 0x10, 
+0x4B, 0x9C, 0xB3, 0xA0, 0x4C, 0xD6, 0x6A, 0x90, 0x4D, 0x7C, 0x95, 0xA0, 0x4E, 0xB6, 0x4C, 0x90, 
+0x4F, 0x5C, 0x77, 0xA0, 0x50, 0x96, 0x2E, 0x90, 0x51, 0x3C, 0x59, 0xA0, 0x52, 0x76, 0x10, 0x90, 
+0x53, 0x1C, 0x3B, 0xA0, 0x54, 0x55, 0xF2, 0x90, 0x54, 0xFC, 0x1D, 0xA0, 0x56, 0x35, 0xD4, 0x90, 
+0x56, 0xE5, 0x3A, 0x20, 0x58, 0x1E, 0xF1, 0x10, 0x58, 0xC5, 0x1C, 0x20, 0x59, 0xFE, 0xD3, 0x10, 
+0x5A, 0xA4, 0xFE, 0x20, 0x5B, 0xDE, 0xB5, 0x10, 0x5C, 0x84, 0xE0, 0x20, 0x5D, 0xBE, 0x97, 0x10, 
+0x5E, 0x64, 0xC2, 0x20, 0x5F, 0x9E, 0x79, 0x10, 0x60, 0x4D, 0xDE, 0xA0, 0x61, 0x87, 0x95, 0x90, 
+0x62, 0x2D, 0xC0, 0xA0, 0x63, 0x67, 0x77, 0x90, 0x64, 0x0D, 0xA2, 0xA0, 0x65, 0x47, 0x59, 0x90, 
+0x65, 0xED, 0x84, 0xA0, 0x67, 0x27, 0x3B, 0x90, 0x67, 0xCD, 0x66, 0xA0, 0x69, 0x07, 0x1D, 0x90, 
+0x69, 0xAD, 0x48, 0xA0, 0x6A, 0xE6, 0xFF, 0x90, 0x6B, 0x96, 0x65, 0x20, 0x6C, 0xD0, 0x1C, 0x10, 
+0x6D, 0x76, 0x47, 0x20, 0x6E, 0xAF, 0xFE, 0x10, 0x6F, 0x56, 0x29, 0x20, 0x70, 0x8F, 0xE0, 0x10, 
+0x71, 0x36, 0x0B, 0x20, 0x72, 0x6F, 0xC2, 0x10, 0x73, 0x15, 0xED, 0x20, 0x74, 0x4F, 0xA4, 0x10, 
+0x74, 0xFF, 0x09, 0xA0, 0x76, 0x38, 0xC0, 0x90, 0x76, 0xDE, 0xEB, 0xA0, 0x78, 0x18, 0xA2, 0x90, 
+0x78, 0xBE, 0xCD, 0xA0, 0x79, 0xF8, 0x84, 0x90, 0x7A, 0x9E, 0xAF, 0xA0, 0x7B, 0xD8, 0x66, 0x90, 
+0x7C, 0x7E, 0x91, 0xA0, 0x7D, 0xB8, 0x48, 0x90, 0x7E, 0x5E, 0x73, 0xA0, 0x7F, 0x98, 0x2A, 0x90, 
 0x01, 0x02, 0x01, 0x02, 0x03, 0x02, 0x04, 0x05, 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, 
@@ -4469,6 +4474,46 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 0x54, 0x00, 0x41, 0x53, 0x54, 0x00, 0x41, 0x44, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x9F, 0x9B, 0x60, 0x00, 0xB5, 0x73, 0xD2, 0x00, 0x00, 0x00, 0x00, 
 
+/* America/Matamoros */
+0x50, 0x48, 0x50, 0x31, 0x01, 0x4D, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0C, 0xA5, 0xB6, 0xDA, 0x60, 
+0x22, 0x55, 0xF1, 0x00, 0x23, 0x6A, 0xBD, 0xF0, 0x31, 0x67, 0x76, 0x00, 0x32, 0x73, 0x08, 0x70, 
+0x33, 0x47, 0x58, 0x00, 0x34, 0x52, 0xEA, 0x70, 0x35, 0x27, 0x3A, 0x00, 0x36, 0x32, 0xCC, 0x70, 
+0x37, 0x07, 0x1C, 0x00, 0x38, 0x1B, 0xE8, 0xF0, 0x38, 0xE6, 0xFE, 0x00, 0x39, 0xFB, 0xCA, 0xF0, 
+0x3A, 0xF5, 0x04, 0x80, 0x3B, 0xB6, 0xC2, 0xF0, 0x3C, 0xAF, 0xFC, 0x80, 0x3D, 0xBB, 0x8E, 0xF0, 
+0x3E, 0x8F, 0xDE, 0x80, 0x3F, 0x9B, 0x70, 0xF0, 0x40, 0x6F, 0xC0, 0x80, 0x41, 0x84, 0x8D, 0x70, 
+0x42, 0x4F, 0xA2, 0x80, 0x43, 0x64, 0x6F, 0x70, 0x44, 0x2F, 0x84, 0x80, 0x45, 0x44, 0x51, 0x70, 
+0x46, 0x0F, 0x66, 0x80, 0x47, 0x24, 0x33, 0x70, 0x47, 0xF8, 0x83, 0x00, 0x49, 0x04, 0x15, 0x70, 
+0x49, 0xD8, 0x65, 0x00, 0x4A, 0xE3, 0xF7, 0x70, 0x4B, 0x9C, 0x97, 0x80, 0x4C, 0xD6, 0x4E, 0x70, 
+0x4D, 0x7C, 0x79, 0x80, 0x4E, 0xB6, 0x30, 0x70, 0x4F, 0x5C, 0x5B, 0x80, 0x50, 0x96, 0x12, 0x70, 
+0x51, 0x3C, 0x3D, 0x80, 0x52, 0x75, 0xF4, 0x70, 0x53, 0x1C, 0x1F, 0x80, 0x54, 0x55, 0xD6, 0x70, 
+0x54, 0xFC, 0x01, 0x80, 0x56, 0x35, 0xB8, 0x70, 0x56, 0xE5, 0x1E, 0x00, 0x58, 0x1E, 0xD4, 0xF0, 
+0x58, 0xC5, 0x00, 0x00, 0x59, 0xFE, 0xB6, 0xF0, 0x5A, 0xA4, 0xE2, 0x00, 0x5B, 0xDE, 0x98, 0xF0, 
+0x5C, 0x84, 0xC4, 0x00, 0x5D, 0xBE, 0x7A, 0xF0, 0x5E, 0x64, 0xA6, 0x00, 0x5F, 0x9E, 0x5C, 0xF0, 
+0x60, 0x4D, 0xC2, 0x80, 0x61, 0x87, 0x79, 0x70, 0x62, 0x2D, 0xA4, 0x80, 0x63, 0x67, 0x5B, 0x70, 
+0x64, 0x0D, 0x86, 0x80, 0x65, 0x47, 0x3D, 0x70, 0x65, 0xED, 0x68, 0x80, 0x67, 0x27, 0x1F, 0x70, 
+0x67, 0xCD, 0x4A, 0x80, 0x69, 0x07, 0x01, 0x70, 0x69, 0xAD, 0x2C, 0x80, 0x6A, 0xE6, 0xE3, 0x70, 
+0x6B, 0x96, 0x49, 0x00, 0x6C, 0xCF, 0xFF, 0xF0, 0x6D, 0x76, 0x2B, 0x00, 0x6E, 0xAF, 0xE1, 0xF0, 
+0x6F, 0x56, 0x0D, 0x00, 0x70, 0x8F, 0xC3, 0xF0, 0x71, 0x35, 0xEF, 0x00, 0x72, 0x6F, 0xA5, 0xF0, 
+0x73, 0x15, 0xD1, 0x00, 0x74, 0x4F, 0x87, 0xF0, 0x74, 0xFE, 0xED, 0x80, 0x76, 0x38, 0xA4, 0x70, 
+0x76, 0xDE, 0xCF, 0x80, 0x78, 0x18, 0x86, 0x70, 0x78, 0xBE, 0xB1, 0x80, 0x79, 0xF8, 0x68, 0x70, 
+0x7A, 0x9E, 0x93, 0x80, 0x7B, 0xD8, 0x4A, 0x70, 0x7C, 0x7E, 0x75, 0x80, 0x7D, 0xB8, 0x2C, 0x70, 
+0x7E, 0x5E, 0x57, 0x80, 0x7F, 0x98, 0x0E, 0x70, 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, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0xFF, 
+0xFF, 0xA2, 0x40, 0x00, 0x00, 0xFF, 0xFF, 0xAB, 0xA0, 0x00, 0x04, 0xFF, 0xFF, 0xB9, 0xB0, 0x01, 
+0x08, 0x4C, 0x4D, 0x54, 0x00, 0x43, 0x53, 0x54, 0x00, 0x43, 0x44, 0x54, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0xB0, 0xBF, 0x65, 0x00, 0x7D, 0xE2, 0x90, 0x00, 0x00, 0x00, 0x4A, 0x55, 
+0x53, 0x20, 0x43, 0x65, 0x6E, 0x74, 0x72, 0x61, 0x6C, 0x20, 0x54, 0x69, 0x6D, 0x65, 0x20, 0x2D, 
+0x20, 0x43, 0x6F, 0x61, 0x68, 0x75, 0x69, 0x6C, 0x61, 0x2C, 0x20, 0x44, 0x75, 0x72, 0x61, 0x6E, 
+0x67, 0x6F, 0x2C, 0x20, 0x4E, 0x75, 0x65, 0x76, 0x6F, 0x20, 0x4C, 0x65, 0x6F, 0x6E, 0x2C, 0x20, 
+0x54, 0x61, 0x6D, 0x61, 0x75, 0x6C, 0x69, 0x70, 0x61, 0x73, 0x20, 0x6E, 0x65, 0x61, 0x72, 0x20, 
+0x55, 0x53, 0x20, 0x62, 0x6F, 0x72, 0x64, 0x65, 0x72, 
+
 /* America/Mazatlan */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x4D, 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, 
@@ -4830,11 +4875,13 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0xFF, 
 0xFF, 0xA1, 0xF4, 0x00, 0x00, 0xFF, 0xFF, 0xAB, 0xA0, 0x00, 0x04, 0xFF, 0xFF, 0xB9, 0xB0, 0x01, 
 0x08, 0x4C, 0x4D, 0x54, 0x00, 0x43, 0x53, 0x54, 0x00, 0x43, 0x44, 0x54, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0xB0, 0x7E, 0x4A, 0x00, 0x79, 0x96, 0x4D, 0x00, 0x00, 0x00, 0x38, 0x43, 
-0x65, 0x6E, 0x74, 0x72, 0x61, 0x6C, 0x20, 0x54, 0x69, 0x6D, 0x65, 0x20, 0x2D, 0x20, 0x43, 0x6F, 
-0x61, 0x68, 0x75, 0x69, 0x6C, 0x61, 0x2C, 0x20, 0x44, 0x75, 0x72, 0x61, 0x6E, 0x67, 0x6F, 0x2C, 
-0x20, 0x4E, 0x75, 0x65, 0x76, 0x6F, 0x20, 0x4C, 0x65, 0x6F, 0x6E, 0x2C, 0x20, 0x54, 0x61, 0x6D, 
-0x61, 0x75, 0x6C, 0x69, 0x70, 0x61, 0x73, 
+0x00, 0x00, 0x00, 0x00, 0xB0, 0x7E, 0x4A, 0x00, 0x79, 0x96, 0x4D, 0x00, 0x00, 0x00, 0x54, 0x4D, 
+0x65, 0x78, 0x69, 0x63, 0x61, 0x6E, 0x20, 0x43, 0x65, 0x6E, 0x74, 0x72, 0x61, 0x6C, 0x20, 0x54, 
+0x69, 0x6D, 0x65, 0x20, 0x2D, 0x20, 0x43, 0x6F, 0x61, 0x68, 0x75, 0x69, 0x6C, 0x61, 0x2C, 0x20, 
+0x44, 0x75, 0x72, 0x61, 0x6E, 0x67, 0x6F, 0x2C, 0x20, 0x4E, 0x75, 0x65, 0x76, 0x6F, 0x20, 0x4C, 
+0x65, 0x6F, 0x6E, 0x2C, 0x20, 0x54, 0x61, 0x6D, 0x61, 0x75, 0x6C, 0x69, 0x70, 0x61, 0x73, 0x20, 
+0x61, 0x77, 0x61, 0x79, 0x20, 0x66, 0x72, 0x6F, 0x6D, 0x20, 0x55, 0x53, 0x20, 0x62, 0x6F, 0x72, 
+0x64, 0x65, 0x72, 
 
 /* America/Montevideo */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x55, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -5375,6 +5422,47 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 0x75, 0x6E, 0x74, 0x79, 0x20, 0x28, 0x65, 0x78, 0x63, 0x65, 0x70, 0x74, 0x20, 0x4D, 0x61, 0x6E, 
 0x64, 0x61, 0x6E, 0x20, 0x61, 0x72, 0x65, 0x61, 0x29, 
 
+/* America/Ojinaga */
+0x50, 0x48, 0x50, 0x31, 0x01, 0x4D, 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, 0x5A, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x14, 0xA5, 0xB6, 0xE8, 0x70, 
+0xAF, 0xF2, 0x6E, 0xE0, 0xB6, 0x66, 0x56, 0x60, 0xB7, 0x43, 0xD2, 0x60, 0xB8, 0x0C, 0x36, 0x60, 
+0xB8, 0xFD, 0x86, 0xF0, 0x31, 0x67, 0x76, 0x00, 0x32, 0x73, 0x08, 0x70, 0x33, 0x47, 0x58, 0x00, 
+0x34, 0x52, 0xEA, 0x70, 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, 0x9C, 0xA5, 0x90, 0x4C, 0xD6, 0x5C, 0x80, 0x4D, 0x7C, 0x87, 0x90, 
+0x4E, 0xB6, 0x3E, 0x80, 0x4F, 0x5C, 0x69, 0x90, 0x50, 0x96, 0x20, 0x80, 0x51, 0x3C, 0x4B, 0x90, 
+0x52, 0x76, 0x02, 0x80, 0x53, 0x1C, 0x2D, 0x90, 0x54, 0x55, 0xE4, 0x80, 0x54, 0xFC, 0x0F, 0x90, 
+0x56, 0x35, 0xC6, 0x80, 0x56, 0xE5, 0x2C, 0x10, 0x58, 0x1E, 0xE3, 0x00, 0x58, 0xC5, 0x0E, 0x10, 
+0x59, 0xFE, 0xC5, 0x00, 0x5A, 0xA4, 0xF0, 0x10, 0x5B, 0xDE, 0xA7, 0x00, 0x5C, 0x84, 0xD2, 0x10, 
+0x5D, 0xBE, 0x89, 0x00, 0x5E, 0x64, 0xB4, 0x10, 0x5F, 0x9E, 0x6B, 0x00, 0x60, 0x4D, 0xD0, 0x90, 
+0x61, 0x87, 0x87, 0x80, 0x62, 0x2D, 0xB2, 0x90, 0x63, 0x67, 0x69, 0x80, 0x64, 0x0D, 0x94, 0x90, 
+0x65, 0x47, 0x4B, 0x80, 0x65, 0xED, 0x76, 0x90, 0x67, 0x27, 0x2D, 0x80, 0x67, 0xCD, 0x58, 0x90, 
+0x69, 0x07, 0x0F, 0x80, 0x69, 0xAD, 0x3A, 0x90, 0x6A, 0xE6, 0xF1, 0x80, 0x6B, 0x96, 0x57, 0x10, 
+0x6C, 0xD0, 0x0E, 0x00, 0x6D, 0x76, 0x39, 0x10, 0x6E, 0xAF, 0xF0, 0x00, 0x6F, 0x56, 0x1B, 0x10, 
+0x70, 0x8F, 0xD2, 0x00, 0x71, 0x35, 0xFD, 0x10, 0x72, 0x6F, 0xB4, 0x00, 0x73, 0x15, 0xDF, 0x10, 
+0x74, 0x4F, 0x96, 0x00, 0x74, 0xFE, 0xFB, 0x90, 0x76, 0x38, 0xB2, 0x80, 0x76, 0xDE, 0xDD, 0x90, 
+0x78, 0x18, 0x94, 0x80, 0x78, 0xBE, 0xBF, 0x90, 0x79, 0xF8, 0x76, 0x80, 0x7A, 0x9E, 0xA1, 0x90, 
+0x7B, 0xD8, 0x58, 0x80, 0x7C, 0x7E, 0x83, 0x90, 0x7D, 0xB8, 0x3A, 0x80, 0x7E, 0x5E, 0x65, 0x90, 
+0x7F, 0x98, 0x1C, 0x80, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x03, 0x02, 0x03, 0x02, 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, 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, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 
+0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0xFF, 0xFF, 
+0x9E, 0x1C, 0x00, 0x00, 0xFF, 0xFF, 0x9D, 0x90, 0x00, 0x04, 0xFF, 0xFF, 0xAB, 0xA0, 0x00, 0x08, 
+0xFF, 0xFF, 0xB9, 0xB0, 0x01, 0x0C, 0xFF, 0xFF, 0xAB, 0xA0, 0x01, 0x10, 0x4C, 0x4D, 0x54, 0x00, 
+0x4D, 0x53, 0x54, 0x00, 0x43, 0x53, 0x54, 0x00, 0x43, 0x44, 0x54, 0x00, 0x4D, 0x44, 0x54, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB6, 0x71, 0xBA, 0x00, 0x73, 
+0x54, 0xBD, 0x00, 0x00, 0x00, 0x2B, 0x55, 0x53, 0x20, 0x4D, 0x6F, 0x75, 0x6E, 0x74, 0x61, 0x69, 
+0x6E, 0x20, 0x54, 0x69, 0x6D, 0x65, 0x20, 0x2D, 0x20, 0x43, 0x68, 0x69, 0x68, 0x75, 0x61, 0x68, 
+0x75, 0x61, 0x20, 0x6E, 0x65, 0x61, 0x72, 0x20, 0x55, 0x53, 0x20, 0x62, 0x6F, 0x72, 0x64, 0x65, 
+0x72, 
+
 /* America/Panama */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x50, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 
@@ -5787,6 +5875,67 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 
 0xA8, 0x80, 0x00, 0x00, 0x00, 0x00, 
 
+/* America/Santa_Isabel */
+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, 0x95, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x18, 0xA5, 0xB6, 0xF6, 0x80, 
+0xA9, 0x79, 0x4F, 0x70, 0xAF, 0xF2, 0x7C, 0xF0, 0xB6, 0x66, 0x64, 0x70, 0xB7, 0x1B, 0x10, 0x00, 
+0xB8, 0x0A, 0xF2, 0xF0, 0xCB, 0xEA, 0x8D, 0x80, 0xD2, 0x23, 0xF4, 0x70, 0xD2, 0x99, 0xBA, 0x70, 
+0xD7, 0x1B, 0x59, 0x00, 0xD8, 0x91, 0xB4, 0xF0, 0xE2, 0x7E, 0x59, 0xA0, 0xE3, 0x49, 0x52, 0x90, 
+0xE4, 0x5E, 0x3B, 0xA0, 0xE5, 0x29, 0x34, 0x90, 0xE6, 0x47, 0x58, 0x20, 0xE7, 0x12, 0x51, 0x10, 
+0xE8, 0x27, 0x3A, 0x20, 0xE8, 0xF2, 0x33, 0x10, 0xEA, 0x07, 0x1C, 0x20, 0xEA, 0xD2, 0x15, 0x10, 
+0xEB, 0xE6, 0xFE, 0x20, 0xEC, 0xB1, 0xF7, 0x10, 0xED, 0xC6, 0xE0, 0x20, 0xEE, 0x91, 0xD9, 0x10, 
+0x0B, 0xE0, 0xAF, 0xA0, 0x0C, 0xD9, 0xCD, 0x10, 0x0D, 0xC0, 0x91, 0xA0, 0x0E, 0xB9, 0xAF, 0x10, 
+0x0F, 0xA9, 0xAE, 0x20, 0x10, 0x99, 0x91, 0x10, 0x11, 0x89, 0x90, 0x20, 0x12, 0x79, 0x73, 0x10, 
+0x13, 0x69, 0x72, 0x20, 0x14, 0x59, 0x55, 0x10, 0x15, 0x49, 0x54, 0x20, 0x16, 0x39, 0x37, 0x10, 
+0x17, 0x29, 0x36, 0x20, 0x18, 0x22, 0x53, 0x90, 0x19, 0x09, 0x18, 0x20, 0x1A, 0x02, 0x35, 0x90, 
+0x1A, 0xF2, 0x34, 0xA0, 0x1B, 0xE2, 0x17, 0x90, 0x1C, 0xD2, 0x16, 0xA0, 0x1D, 0xC1, 0xF9, 0x90, 
+0x1E, 0xB1, 0xF8, 0xA0, 0x1F, 0xA1, 0xDB, 0x90, 0x20, 0x76, 0x2B, 0x20, 0x21, 0x81, 0xBD, 0x90, 
+0x22, 0x56, 0x0D, 0x20, 0x23, 0x6A, 0xDA, 0x10, 0x24, 0x35, 0xEF, 0x20, 0x25, 0x4A, 0xBC, 0x10, 
+0x26, 0x15, 0xD1, 0x20, 0x27, 0x2A, 0x9E, 0x10, 0x27, 0xFE, 0xED, 0xA0, 0x29, 0x0A, 0x80, 0x10, 
+0x29, 0xDE, 0xCF, 0xA0, 0x2A, 0xEA, 0x62, 0x10, 0x2B, 0xBE, 0xB1, 0xA0, 0x2C, 0xD3, 0x7E, 0x90, 
+0x2D, 0x9E, 0x93, 0xA0, 0x2E, 0xB3, 0x60, 0x90, 0x2F, 0x7E, 0x75, 0xA0, 0x30, 0x93, 0x42, 0x90, 
+0x31, 0x67, 0x92, 0x20, 0x32, 0x73, 0x24, 0x90, 0x33, 0x47, 0x74, 0x20, 0x34, 0x53, 0x06, 0x90, 
+0x35, 0x27, 0x56, 0x20, 0x36, 0x32, 0xE8, 0x90, 0x37, 0x07, 0x38, 0x20, 0x38, 0x1C, 0x05, 0x10, 
+0x38, 0xE7, 0x1A, 0x20, 0x39, 0xFB, 0xE7, 0x10, 0x3A, 0xC6, 0xFC, 0x20, 0x3B, 0xDB, 0xC9, 0x10, 
+0x3C, 0xB0, 0x18, 0xA0, 0x3D, 0xBB, 0xAB, 0x10, 0x3E, 0x8F, 0xFA, 0xA0, 0x3F, 0x9B, 0x8D, 0x10, 
+0x40, 0x6F, 0xDC, 0xA0, 0x41, 0x84, 0xA9, 0x90, 0x42, 0x4F, 0xBE, 0xA0, 0x43, 0x64, 0x8B, 0x90, 
+0x44, 0x2F, 0xA0, 0xA0, 0x45, 0x44, 0x6D, 0x90, 0x46, 0x0F, 0x82, 0xA0, 0x47, 0x24, 0x4F, 0x90, 
+0x47, 0xF8, 0x9F, 0x20, 0x49, 0x04, 0x31, 0x90, 0x49, 0xD8, 0x81, 0x20, 0x4A, 0xE4, 0x13, 0x90, 
+0x4B, 0xB8, 0x63, 0x20, 0x4C, 0xCD, 0x30, 0x10, 0x4D, 0x98, 0x45, 0x20, 0x4E, 0xAD, 0x12, 0x10, 
+0x4F, 0x78, 0x27, 0x20, 0x50, 0x8C, 0xF4, 0x10, 0x51, 0x61, 0x43, 0xA0, 0x52, 0x6C, 0xD6, 0x10, 
+0x53, 0x41, 0x25, 0xA0, 0x54, 0x4C, 0xB8, 0x10, 0x55, 0x21, 0x07, 0xA0, 0x56, 0x2C, 0x9A, 0x10, 
+0x57, 0x00, 0xE9, 0xA0, 0x58, 0x15, 0xB6, 0x90, 0x58, 0xE0, 0xCB, 0xA0, 0x59, 0xF5, 0x98, 0x90, 
+0x5A, 0xC0, 0xAD, 0xA0, 0x5B, 0xD5, 0x7A, 0x90, 0x5C, 0xA9, 0xCA, 0x20, 0x5D, 0xB5, 0x5C, 0x90, 
+0x5E, 0x89, 0xAC, 0x20, 0x5F, 0x95, 0x3E, 0x90, 0x60, 0x69, 0x8E, 0x20, 0x61, 0x7E, 0x5B, 0x10, 
+0x62, 0x49, 0x70, 0x20, 0x63, 0x5E, 0x3D, 0x10, 0x64, 0x29, 0x52, 0x20, 0x65, 0x3E, 0x1F, 0x10, 
+0x66, 0x12, 0x6E, 0xA0, 0x67, 0x1E, 0x01, 0x10, 0x67, 0xF2, 0x50, 0xA0, 0x68, 0xFD, 0xE3, 0x10, 
+0x69, 0xD2, 0x32, 0xA0, 0x6A, 0xDD, 0xC5, 0x10, 0x6B, 0xB2, 0x14, 0xA0, 0x6C, 0xC6, 0xE1, 0x90, 
+0x6D, 0x91, 0xF6, 0xA0, 0x6E, 0xA6, 0xC3, 0x90, 0x6F, 0x71, 0xD8, 0xA0, 0x70, 0x86, 0xA5, 0x90, 
+0x71, 0x5A, 0xF5, 0x20, 0x72, 0x66, 0x87, 0x90, 0x73, 0x3A, 0xD7, 0x20, 0x74, 0x46, 0x69, 0x90, 
+0x75, 0x1A, 0xB9, 0x20, 0x76, 0x2F, 0x86, 0x10, 0x76, 0xFA, 0x9B, 0x20, 0x78, 0x0F, 0x68, 0x10, 
+0x78, 0xDA, 0x7D, 0x20, 0x79, 0xEF, 0x4A, 0x10, 0x7A, 0xBA, 0x5F, 0x20, 0x7B, 0xCF, 0x2C, 0x10, 
+0x7C, 0xA3, 0x7B, 0xA0, 0x7D, 0xAF, 0x0E, 0x10, 0x7E, 0x83, 0x5D, 0xA0, 0x7F, 0x8E, 0xF0, 0x10, 
+0x01, 0x02, 0x01, 0x02, 0x03, 0x02, 0x04, 0x05, 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, 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, 
+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, 0x02, 0x03, 0x02, 0x03, 
+0x02, 0x03, 0x02, 0x03, 0x02, 0xFF, 0xFF, 0x94, 0x50, 0x00, 0x00, 0xFF, 0xFF, 0x9D, 0x90, 0x00, 
+0x04, 0xFF, 0xFF, 0x8F, 0x80, 0x00, 0x08, 0xFF, 0xFF, 0x9D, 0x90, 0x01, 0x0C, 0xFF, 0xFF, 0x9D, 
+0x90, 0x01, 0x10, 0xFF, 0xFF, 0x9D, 0x90, 0x01, 0x14, 0x4C, 0x4D, 0x54, 0x00, 0x4D, 0x53, 0x54, 
+0x00, 0x50, 0x53, 0x54, 0x00, 0x50, 0x44, 0x54, 0x00, 0x50, 0x57, 0x54, 0x00, 0x50, 0x50, 0x54, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xB7, 0x90, 
+0x30, 0x00, 0x63, 0x62, 0xB5, 0x00, 0x00, 0x00, 0x3A, 0x4D, 0x65, 0x78, 0x69, 0x63, 0x61, 0x6E, 
+0x20, 0x50, 0x61, 0x63, 0x69, 0x66, 0x69, 0x63, 0x20, 0x54, 0x69, 0x6D, 0x65, 0x20, 0x2D, 0x20, 
+0x42, 0x61, 0x6A, 0x61, 0x20, 0x43, 0x61, 0x6C, 0x69, 0x66, 0x6F, 0x72, 0x6E, 0x69, 0x61, 0x20, 
+0x61, 0x77, 0x61, 0x79, 0x20, 0x66, 0x72, 0x6F, 0x6D, 0x20, 0x55, 0x53, 0x20, 0x62, 0x6F, 0x72, 
+0x64, 0x65, 0x72, 
+
 /* America/Santarem */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x42, 0x52, 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, 
@@ -6321,20 +6470,20 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 0x40, 0x6F, 0xDC, 0xA0, 0x41, 0x84, 0xA9, 0x90, 0x42, 0x4F, 0xBE, 0xA0, 0x43, 0x64, 0x8B, 0x90, 
 0x44, 0x2F, 0xA0, 0xA0, 0x45, 0x44, 0x6D, 0x90, 0x46, 0x0F, 0x82, 0xA0, 0x47, 0x24, 0x4F, 0x90, 
 0x47, 0xF8, 0x9F, 0x20, 0x49, 0x04, 0x31, 0x90, 0x49, 0xD8, 0x81, 0x20, 0x4A, 0xE4, 0x13, 0x90, 
-0x4B, 0xB8, 0x63, 0x20, 0x4C, 0xCD, 0x30, 0x10, 0x4D, 0x98, 0x45, 0x20, 0x4E, 0xAD, 0x12, 0x10, 
-0x4F, 0x78, 0x27, 0x20, 0x50, 0x8C, 0xF4, 0x10, 0x51, 0x61, 0x43, 0xA0, 0x52, 0x6C, 0xD6, 0x10, 
-0x53, 0x41, 0x25, 0xA0, 0x54, 0x4C, 0xB8, 0x10, 0x55, 0x21, 0x07, 0xA0, 0x56, 0x2C, 0x9A, 0x10, 
-0x57, 0x00, 0xE9, 0xA0, 0x58, 0x15, 0xB6, 0x90, 0x58, 0xE0, 0xCB, 0xA0, 0x59, 0xF5, 0x98, 0x90, 
-0x5A, 0xC0, 0xAD, 0xA0, 0x5B, 0xD5, 0x7A, 0x90, 0x5C, 0xA9, 0xCA, 0x20, 0x5D, 0xB5, 0x5C, 0x90, 
-0x5E, 0x89, 0xAC, 0x20, 0x5F, 0x95, 0x3E, 0x90, 0x60, 0x69, 0x8E, 0x20, 0x61, 0x7E, 0x5B, 0x10, 
-0x62, 0x49, 0x70, 0x20, 0x63, 0x5E, 0x3D, 0x10, 0x64, 0x29, 0x52, 0x20, 0x65, 0x3E, 0x1F, 0x10, 
-0x66, 0x12, 0x6E, 0xA0, 0x67, 0x1E, 0x01, 0x10, 0x67, 0xF2, 0x50, 0xA0, 0x68, 0xFD, 0xE3, 0x10, 
-0x69, 0xD2, 0x32, 0xA0, 0x6A, 0xDD, 0xC5, 0x10, 0x6B, 0xB2, 0x14, 0xA0, 0x6C, 0xC6, 0xE1, 0x90, 
-0x6D, 0x91, 0xF6, 0xA0, 0x6E, 0xA6, 0xC3, 0x90, 0x6F, 0x71, 0xD8, 0xA0, 0x70, 0x86, 0xA5, 0x90, 
-0x71, 0x5A, 0xF5, 0x20, 0x72, 0x66, 0x87, 0x90, 0x73, 0x3A, 0xD7, 0x20, 0x74, 0x46, 0x69, 0x90, 
-0x75, 0x1A, 0xB9, 0x20, 0x76, 0x2F, 0x86, 0x10, 0x76, 0xFA, 0x9B, 0x20, 0x78, 0x0F, 0x68, 0x10, 
-0x78, 0xDA, 0x7D, 0x20, 0x79, 0xEF, 0x4A, 0x10, 0x7A, 0xBA, 0x5F, 0x20, 0x7B, 0xCF, 0x2C, 0x10, 
-0x7C, 0xA3, 0x7B, 0xA0, 0x7D, 0xAF, 0x0E, 0x10, 0x7E, 0x83, 0x5D, 0xA0, 0x7F, 0x8E, 0xF0, 0x10, 
+0x4B, 0x9C, 0xB3, 0xA0, 0x4C, 0xD6, 0x6A, 0x90, 0x4D, 0x7C, 0x95, 0xA0, 0x4E, 0xB6, 0x4C, 0x90, 
+0x4F, 0x5C, 0x77, 0xA0, 0x50, 0x96, 0x2E, 0x90, 0x51, 0x3C, 0x59, 0xA0, 0x52, 0x76, 0x10, 0x90, 
+0x53, 0x1C, 0x3B, 0xA0, 0x54, 0x55, 0xF2, 0x90, 0x54, 0xFC, 0x1D, 0xA0, 0x56, 0x35, 0xD4, 0x90, 
+0x56, 0xE5, 0x3A, 0x20, 0x58, 0x1E, 0xF1, 0x10, 0x58, 0xC5, 0x1C, 0x20, 0x59, 0xFE, 0xD3, 0x10, 
+0x5A, 0xA4, 0xFE, 0x20, 0x5B, 0xDE, 0xB5, 0x10, 0x5C, 0x84, 0xE0, 0x20, 0x5D, 0xBE, 0x97, 0x10, 
+0x5E, 0x64, 0xC2, 0x20, 0x5F, 0x9E, 0x79, 0x10, 0x60, 0x4D, 0xDE, 0xA0, 0x61, 0x87, 0x95, 0x90, 
+0x62, 0x2D, 0xC0, 0xA0, 0x63, 0x67, 0x77, 0x90, 0x64, 0x0D, 0xA2, 0xA0, 0x65, 0x47, 0x59, 0x90, 
+0x65, 0xED, 0x84, 0xA0, 0x67, 0x27, 0x3B, 0x90, 0x67, 0xCD, 0x66, 0xA0, 0x69, 0x07, 0x1D, 0x90, 
+0x69, 0xAD, 0x48, 0xA0, 0x6A, 0xE6, 0xFF, 0x90, 0x6B, 0x96, 0x65, 0x20, 0x6C, 0xD0, 0x1C, 0x10, 
+0x6D, 0x76, 0x47, 0x20, 0x6E, 0xAF, 0xFE, 0x10, 0x6F, 0x56, 0x29, 0x20, 0x70, 0x8F, 0xE0, 0x10, 
+0x71, 0x36, 0x0B, 0x20, 0x72, 0x6F, 0xC2, 0x10, 0x73, 0x15, 0xED, 0x20, 0x74, 0x4F, 0xA4, 0x10, 
+0x74, 0xFF, 0x09, 0xA0, 0x76, 0x38, 0xC0, 0x90, 0x76, 0xDE, 0xEB, 0xA0, 0x78, 0x18, 0xA2, 0x90, 
+0x78, 0xBE, 0xCD, 0xA0, 0x79, 0xF8, 0x84, 0x90, 0x7A, 0x9E, 0xAF, 0xA0, 0x7B, 0xD8, 0x66, 0x90, 
+0x7C, 0x7E, 0x91, 0xA0, 0x7D, 0xB8, 0x48, 0x90, 0x7E, 0x5E, 0x73, 0xA0, 0x7F, 0x98, 0x2A, 0x90, 
 0x01, 0x02, 0x01, 0x02, 0x03, 0x02, 0x04, 0x05, 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, 
@@ -6349,8 +6498,10 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 0x90, 0x01, 0x10, 0xFF, 0xFF, 0x9D, 0x90, 0x01, 0x14, 0x4C, 0x4D, 0x54, 0x00, 0x4D, 0x53, 0x54, 
 0x00, 0x50, 0x53, 0x54, 0x00, 0x50, 0x44, 0x54, 0x00, 0x50, 0x57, 0x54, 0x00, 0x50, 0x50, 0x54, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xBA, 0xF8, 
-0x95, 0x00, 0x60, 0x1A, 0xDD, 0x00, 0x00, 0x00, 0x0C, 0x50, 0x61, 0x63, 0x69, 0x66, 0x69, 0x63, 
-0x20, 0x54, 0x69, 0x6D, 0x65, 
+0x95, 0x00, 0x60, 0x1A, 0xDD, 0x00, 0x00, 0x00, 0x30, 0x55, 0x53, 0x20, 0x50, 0x61, 0x63, 0x69, 
+0x66, 0x69, 0x63, 0x20, 0x54, 0x69, 0x6D, 0x65, 0x20, 0x2D, 0x20, 0x42, 0x61, 0x6A, 0x61, 0x20, 
+0x43, 0x61, 0x6C, 0x69, 0x66, 0x6F, 0x72, 0x6E, 0x69, 0x61, 0x20, 0x6E, 0x65, 0x61, 0x72, 0x20, 
+0x55, 0x53, 0x20, 0x62, 0x6F, 0x72, 0x64, 0x65, 0x72, 
 
 /* America/Toronto */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x43, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -7531,15 +7682,32 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 /* Asia/Dacca */
 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 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, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1B, 0xCA, 0xDB, 0x86, 0xB0, 
+0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1B, 0xCA, 0xDB, 0x86, 0xB0, 
 0xCC, 0x05, 0x71, 0x18, 0xCC, 0x95, 0x32, 0xA8, 0xDD, 0xA8, 0xD2, 0x98, 0x02, 0x4F, 0x9D, 0x20, 
-0x4A, 0x3B, 0xC4, 0x10, 0x01, 0x02, 0x01, 0x03, 0x04, 0x05, 0x00, 0x00, 0x52, 0xD0, 0x00, 0x00, 
-0x00, 0x00, 0x5B, 0x68, 0x00, 0x04, 0x00, 0x00, 0x4D, 0x58, 0x00, 0x09, 0x00, 0x00, 0x54, 0x60, 
-0x00, 0x0D, 0x00, 0x00, 0x54, 0x60, 0x00, 0x12, 0x00, 0x00, 0x62, 0x70, 0x01, 0x16, 0x48, 0x4D, 
-0x54, 0x00, 0x42, 0x55, 0x52, 0x54, 0x00, 0x49, 0x53, 0x54, 0x00, 0x44, 0x41, 0x43, 0x54, 0x00, 
-0x42, 0x44, 0x54, 0x00, 0x42, 0x44, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 
-0x00, 
+0x4A, 0x3B, 0xC4, 0x10, 0x4B, 0x3C, 0xD8, 0x90, 0x4B, 0xB3, 0x7F, 0x90, 0x4C, 0xCD, 0xA0, 0x90, 
+0x4D, 0x94, 0xB3, 0x10, 0x4E, 0xAE, 0xD4, 0x10, 0x4F, 0x77, 0x38, 0x10, 0x50, 0x91, 0x59, 0x10, 
+0x51, 0x58, 0x6B, 0x90, 0x52, 0x72, 0x8C, 0x90, 0x53, 0x39, 0x9F, 0x10, 0x54, 0x53, 0xC0, 0x10, 
+0x55, 0x1A, 0xD2, 0x90, 0x56, 0x34, 0xF3, 0x90, 0x56, 0xFD, 0x57, 0x90, 0x58, 0x17, 0x78, 0x90, 
+0x58, 0xDE, 0x8B, 0x10, 0x59, 0xF8, 0xAC, 0x10, 0x5A, 0xBF, 0xBE, 0x90, 0x5B, 0xD9, 0xDF, 0x90, 
+0x5C, 0xA0, 0xF2, 0x10, 0x5D, 0xBB, 0x13, 0x10, 0x5E, 0x83, 0x77, 0x10, 0x5F, 0x9D, 0x98, 0x10, 
+0x60, 0x64, 0xAA, 0x90, 0x61, 0x7E, 0xCB, 0x90, 0x62, 0x45, 0xDE, 0x10, 0x63, 0x5F, 0xFF, 0x10, 
+0x64, 0x27, 0x11, 0x90, 0x65, 0x41, 0x32, 0x90, 0x66, 0x09, 0x96, 0x90, 0x67, 0x23, 0xB7, 0x90, 
+0x67, 0xEA, 0xCA, 0x10, 0x69, 0x04, 0xEB, 0x10, 0x69, 0xCB, 0xFD, 0x90, 0x6A, 0xE6, 0x1E, 0x90, 
+0x6B, 0xAD, 0x31, 0x10, 0x6C, 0xC7, 0x52, 0x10, 0x6D, 0x8F, 0xB6, 0x10, 0x6E, 0xA9, 0xD7, 0x10, 
+0x6F, 0x70, 0xE9, 0x90, 0x70, 0x8B, 0x0A, 0x90, 0x71, 0x52, 0x1D, 0x10, 0x72, 0x6C, 0x3E, 0x10, 
+0x73, 0x33, 0x50, 0x90, 0x74, 0x4D, 0x71, 0x90, 0x75, 0x15, 0xD5, 0x90, 0x76, 0x2F, 0xF6, 0x90, 
+0x76, 0xF7, 0x09, 0x10, 0x78, 0x11, 0x2A, 0x10, 0x78, 0xD8, 0x3C, 0x90, 0x79, 0xF2, 0x5D, 0x90, 
+0x7A, 0xB9, 0x70, 0x10, 0x7B, 0xD3, 0x91, 0x10, 0x7C, 0x9B, 0xF5, 0x10, 0x7D, 0xB6, 0x16, 0x10, 
+0x7E, 0x7D, 0x28, 0x90, 0x7F, 0x97, 0x49, 0x90, 0x01, 0x02, 0x01, 0x03, 0x04, 0x05, 0x04, 0x05, 
+0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 
+0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 
+0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 
+0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x00, 0x00, 0x52, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x5B, 
+0x68, 0x00, 0x04, 0x00, 0x00, 0x4D, 0x58, 0x00, 0x09, 0x00, 0x00, 0x54, 0x60, 0x00, 0x0D, 0x00, 
+0x00, 0x54, 0x60, 0x00, 0x12, 0x00, 0x00, 0x62, 0x70, 0x01, 0x16, 0x48, 0x4D, 0x54, 0x00, 0x42, 
+0x55, 0x52, 0x54, 0x00, 0x49, 0x53, 0x54, 0x00, 0x44, 0x41, 0x43, 0x54, 0x00, 0x42, 0x44, 0x54, 
+0x00, 0x42, 0x44, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 0x00, 
 
 /* Asia/Damascus */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x53, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -7600,15 +7768,32 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 /* Asia/Dhaka */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x42, 0x44, 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, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1B, 0xCA, 0xDB, 0x86, 0xB0, 
+0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1B, 0xCA, 0xDB, 0x86, 0xB0, 
 0xCC, 0x05, 0x71, 0x18, 0xCC, 0x95, 0x32, 0xA8, 0xDD, 0xA8, 0xD2, 0x98, 0x02, 0x4F, 0x9D, 0x20, 
-0x4A, 0x3B, 0xC4, 0x10, 0x01, 0x02, 0x01, 0x03, 0x04, 0x05, 0x00, 0x00, 0x52, 0xD0, 0x00, 0x00, 
-0x00, 0x00, 0x5B, 0x68, 0x00, 0x04, 0x00, 0x00, 0x4D, 0x58, 0x00, 0x09, 0x00, 0x00, 0x54, 0x60, 
-0x00, 0x0D, 0x00, 0x00, 0x54, 0x60, 0x00, 0x12, 0x00, 0x00, 0x62, 0x70, 0x01, 0x16, 0x48, 0x4D, 
-0x54, 0x00, 0x42, 0x55, 0x52, 0x54, 0x00, 0x49, 0x53, 0x54, 0x00, 0x44, 0x41, 0x43, 0x54, 0x00, 
-0x42, 0x44, 0x54, 0x00, 0x42, 0x44, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x84, 0x92, 0x01, 0x9C, 0x9F, 0x82, 0x00, 0x00, 0x00, 
-0x00, 
+0x4A, 0x3B, 0xC4, 0x10, 0x4B, 0x3C, 0xD8, 0x90, 0x4B, 0xB3, 0x7F, 0x90, 0x4C, 0xCD, 0xA0, 0x90, 
+0x4D, 0x94, 0xB3, 0x10, 0x4E, 0xAE, 0xD4, 0x10, 0x4F, 0x77, 0x38, 0x10, 0x50, 0x91, 0x59, 0x10, 
+0x51, 0x58, 0x6B, 0x90, 0x52, 0x72, 0x8C, 0x90, 0x53, 0x39, 0x9F, 0x10, 0x54, 0x53, 0xC0, 0x10, 
+0x55, 0x1A, 0xD2, 0x90, 0x56, 0x34, 0xF3, 0x90, 0x56, 0xFD, 0x57, 0x90, 0x58, 0x17, 0x78, 0x90, 
+0x58, 0xDE, 0x8B, 0x10, 0x59, 0xF8, 0xAC, 0x10, 0x5A, 0xBF, 0xBE, 0x90, 0x5B, 0xD9, 0xDF, 0x90, 
+0x5C, 0xA0, 0xF2, 0x10, 0x5D, 0xBB, 0x13, 0x10, 0x5E, 0x83, 0x77, 0x10, 0x5F, 0x9D, 0x98, 0x10, 
+0x60, 0x64, 0xAA, 0x90, 0x61, 0x7E, 0xCB, 0x90, 0x62, 0x45, 0xDE, 0x10, 0x63, 0x5F, 0xFF, 0x10, 
+0x64, 0x27, 0x11, 0x90, 0x65, 0x41, 0x32, 0x90, 0x66, 0x09, 0x96, 0x90, 0x67, 0x23, 0xB7, 0x90, 
+0x67, 0xEA, 0xCA, 0x10, 0x69, 0x04, 0xEB, 0x10, 0x69, 0xCB, 0xFD, 0x90, 0x6A, 0xE6, 0x1E, 0x90, 
+0x6B, 0xAD, 0x31, 0x10, 0x6C, 0xC7, 0x52, 0x10, 0x6D, 0x8F, 0xB6, 0x10, 0x6E, 0xA9, 0xD7, 0x10, 
+0x6F, 0x70, 0xE9, 0x90, 0x70, 0x8B, 0x0A, 0x90, 0x71, 0x52, 0x1D, 0x10, 0x72, 0x6C, 0x3E, 0x10, 
+0x73, 0x33, 0x50, 0x90, 0x74, 0x4D, 0x71, 0x90, 0x75, 0x15, 0xD5, 0x90, 0x76, 0x2F, 0xF6, 0x90, 
+0x76, 0xF7, 0x09, 0x10, 0x78, 0x11, 0x2A, 0x10, 0x78, 0xD8, 0x3C, 0x90, 0x79, 0xF2, 0x5D, 0x90, 
+0x7A, 0xB9, 0x70, 0x10, 0x7B, 0xD3, 0x91, 0x10, 0x7C, 0x9B, 0xF5, 0x10, 0x7D, 0xB6, 0x16, 0x10, 
+0x7E, 0x7D, 0x28, 0x90, 0x7F, 0x97, 0x49, 0x90, 0x01, 0x02, 0x01, 0x03, 0x04, 0x05, 0x04, 0x05, 
+0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 
+0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 
+0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 
+0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x00, 0x00, 0x52, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x5B, 
+0x68, 0x00, 0x04, 0x00, 0x00, 0x4D, 0x58, 0x00, 0x09, 0x00, 0x00, 0x54, 0x60, 0x00, 0x0D, 0x00, 
+0x00, 0x54, 0x60, 0x00, 0x12, 0x00, 0x00, 0x62, 0x70, 0x01, 0x16, 0x48, 0x4D, 0x54, 0x00, 0x42, 
+0x55, 0x52, 0x54, 0x00, 0x49, 0x53, 0x54, 0x00, 0x44, 0x41, 0x43, 0x54, 0x00, 0x42, 0x44, 0x54, 
+0x00, 0x42, 0x44, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0xAD, 0x84, 0x92, 0x01, 0x9C, 0x9F, 0x82, 0x00, 0x00, 0x00, 0x00, 
 
 /* Asia/Dili */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x54, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -16105,20 +16290,20 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 0x40, 0x6F, 0xDC, 0xA0, 0x41, 0x84, 0xA9, 0x90, 0x42, 0x4F, 0xBE, 0xA0, 0x43, 0x64, 0x8B, 0x90, 
 0x44, 0x2F, 0xA0, 0xA0, 0x45, 0x44, 0x6D, 0x90, 0x46, 0x0F, 0x82, 0xA0, 0x47, 0x24, 0x4F, 0x90, 
 0x47, 0xF8, 0x9F, 0x20, 0x49, 0x04, 0x31, 0x90, 0x49, 0xD8, 0x81, 0x20, 0x4A, 0xE4, 0x13, 0x90, 
-0x4B, 0xB8, 0x63, 0x20, 0x4C, 0xCD, 0x30, 0x10, 0x4D, 0x98, 0x45, 0x20, 0x4E, 0xAD, 0x12, 0x10, 
-0x4F, 0x78, 0x27, 0x20, 0x50, 0x8C, 0xF4, 0x10, 0x51, 0x61, 0x43, 0xA0, 0x52, 0x6C, 0xD6, 0x10, 
-0x53, 0x41, 0x25, 0xA0, 0x54, 0x4C, 0xB8, 0x10, 0x55, 0x21, 0x07, 0xA0, 0x56, 0x2C, 0x9A, 0x10, 
-0x57, 0x00, 0xE9, 0xA0, 0x58, 0x15, 0xB6, 0x90, 0x58, 0xE0, 0xCB, 0xA0, 0x59, 0xF5, 0x98, 0x90, 
-0x5A, 0xC0, 0xAD, 0xA0, 0x5B, 0xD5, 0x7A, 0x90, 0x5C, 0xA9, 0xCA, 0x20, 0x5D, 0xB5, 0x5C, 0x90, 
-0x5E, 0x89, 0xAC, 0x20, 0x5F, 0x95, 0x3E, 0x90, 0x60, 0x69, 0x8E, 0x20, 0x61, 0x7E, 0x5B, 0x10, 
-0x62, 0x49, 0x70, 0x20, 0x63, 0x5E, 0x3D, 0x10, 0x64, 0x29, 0x52, 0x20, 0x65, 0x3E, 0x1F, 0x10, 
-0x66, 0x12, 0x6E, 0xA0, 0x67, 0x1E, 0x01, 0x10, 0x67, 0xF2, 0x50, 0xA0, 0x68, 0xFD, 0xE3, 0x10, 
-0x69, 0xD2, 0x32, 0xA0, 0x6A, 0xDD, 0xC5, 0x10, 0x6B, 0xB2, 0x14, 0xA0, 0x6C, 0xC6, 0xE1, 0x90, 
-0x6D, 0x91, 0xF6, 0xA0, 0x6E, 0xA6, 0xC3, 0x90, 0x6F, 0x71, 0xD8, 0xA0, 0x70, 0x86, 0xA5, 0x90, 
-0x71, 0x5A, 0xF5, 0x20, 0x72, 0x66, 0x87, 0x90, 0x73, 0x3A, 0xD7, 0x20, 0x74, 0x46, 0x69, 0x90, 
-0x75, 0x1A, 0xB9, 0x20, 0x76, 0x2F, 0x86, 0x10, 0x76, 0xFA, 0x9B, 0x20, 0x78, 0x0F, 0x68, 0x10, 
-0x78, 0xDA, 0x7D, 0x20, 0x79, 0xEF, 0x4A, 0x10, 0x7A, 0xBA, 0x5F, 0x20, 0x7B, 0xCF, 0x2C, 0x10, 
-0x7C, 0xA3, 0x7B, 0xA0, 0x7D, 0xAF, 0x0E, 0x10, 0x7E, 0x83, 0x5D, 0xA0, 0x7F, 0x8E, 0xF0, 0x10, 
+0x4B, 0x9C, 0xB3, 0xA0, 0x4C, 0xD6, 0x6A, 0x90, 0x4D, 0x7C, 0x95, 0xA0, 0x4E, 0xB6, 0x4C, 0x90, 
+0x4F, 0x5C, 0x77, 0xA0, 0x50, 0x96, 0x2E, 0x90, 0x51, 0x3C, 0x59, 0xA0, 0x52, 0x76, 0x10, 0x90, 
+0x53, 0x1C, 0x3B, 0xA0, 0x54, 0x55, 0xF2, 0x90, 0x54, 0xFC, 0x1D, 0xA0, 0x56, 0x35, 0xD4, 0x90, 
+0x56, 0xE5, 0x3A, 0x20, 0x58, 0x1E, 0xF1, 0x10, 0x58, 0xC5, 0x1C, 0x20, 0x59, 0xFE, 0xD3, 0x10, 
+0x5A, 0xA4, 0xFE, 0x20, 0x5B, 0xDE, 0xB5, 0x10, 0x5C, 0x84, 0xE0, 0x20, 0x5D, 0xBE, 0x97, 0x10, 
+0x5E, 0x64, 0xC2, 0x20, 0x5F, 0x9E, 0x79, 0x10, 0x60, 0x4D, 0xDE, 0xA0, 0x61, 0x87, 0x95, 0x90, 
+0x62, 0x2D, 0xC0, 0xA0, 0x63, 0x67, 0x77, 0x90, 0x64, 0x0D, 0xA2, 0xA0, 0x65, 0x47, 0x59, 0x90, 
+0x65, 0xED, 0x84, 0xA0, 0x67, 0x27, 0x3B, 0x90, 0x67, 0xCD, 0x66, 0xA0, 0x69, 0x07, 0x1D, 0x90, 
+0x69, 0xAD, 0x48, 0xA0, 0x6A, 0xE6, 0xFF, 0x90, 0x6B, 0x96, 0x65, 0x20, 0x6C, 0xD0, 0x1C, 0x10, 
+0x6D, 0x76, 0x47, 0x20, 0x6E, 0xAF, 0xFE, 0x10, 0x6F, 0x56, 0x29, 0x20, 0x70, 0x8F, 0xE0, 0x10, 
+0x71, 0x36, 0x0B, 0x20, 0x72, 0x6F, 0xC2, 0x10, 0x73, 0x15, 0xED, 0x20, 0x74, 0x4F, 0xA4, 0x10, 
+0x74, 0xFF, 0x09, 0xA0, 0x76, 0x38, 0xC0, 0x90, 0x76, 0xDE, 0xEB, 0xA0, 0x78, 0x18, 0xA2, 0x90, 
+0x78, 0xBE, 0xCD, 0xA0, 0x79, 0xF8, 0x84, 0x90, 0x7A, 0x9E, 0xAF, 0xA0, 0x7B, 0xD8, 0x66, 0x90, 
+0x7C, 0x7E, 0x91, 0xA0, 0x7D, 0xB8, 0x48, 0x90, 0x7E, 0x5E, 0x73, 0xA0, 0x7F, 0x98, 0x2A, 0x90, 
 0x01, 0x02, 0x01, 0x02, 0x03, 0x02, 0x04, 0x05, 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, 
@@ -16651,12 +16836,13 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 /* Pacific/Fiji */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x46, 0x4A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0D, 0x9A, 0x13, 0xB2, 0x3C, 
+0x00, 0x00, 0x00, 0x07, 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, 
-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, 0xA8, 0xEA, 0x02, 0x22, 
-0xE6, 0x82, 0x00, 0x00, 0x00, 0x00, 
+0x4B, 0x11, 0x2C, 0xE0, 0x4B, 0xD2, 0xF9, 0x60, 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, 0xA8, 0xEA, 0x02, 0x22, 0xE6, 0x82, 0x00, 0x00, 0x00, 0x00, 
+
 
 /* Pacific/Funafuti */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x54, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -18061,4 +18247,4 @@ const unsigned char timelib_timezone_db_data_builtin[257084] = {
 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 = { "2009.18", 561, timezonedb_idx_builtin, timelib_timezone_db_data_builtin };
+const timelib_tzdb timezonedb_builtin = { "2010.3", 564, timezonedb_idx_builtin, timelib_timezone_db_data_builtin };
diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c
index b013882..e2fa02b 100644
--- a/ext/date/lib/tm2unixtime.c
+++ b/ext/date/lib/tm2unixtime.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: tm2unixtime.c 279799 2009-05-03 18:22:40Z derick $ */
+/* $Id: tm2unixtime.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "timelib.h"
 
diff --git a/ext/date/lib/unixtime2tm.c b/ext/date/lib/unixtime2tm.c
index 465e8bf..416de9b 100644
--- a/ext/date/lib/unixtime2tm.c
+++ b/ext/date/lib/unixtime2tm.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: unixtime2tm.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: unixtime2tm.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "timelib.h"
 
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 5b84dbd..7a5185b 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_date.c 289981 2009-10-27 10:41:45Z pajoye $ */
+/* $Id: php_date.c 294906 2010-02-11 22:37:50Z pajoye $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -32,15 +32,11 @@
 #include <time.h>
 
 #ifdef PHP_WIN32
-# include "win32/php_stdint.h"
-#endif
-
-#if defined(__GNUC__) && __GNUC__ < 3
-static __inline __int64_t llabs( __int64_t i ) { return i >= 0 ? i : -i; }
-#endif
-
-#if defined(NETWARE) && defined(__MWERKS__)
-static __inline long long llabs( long long i ) { return i >= 0 ? i : -i; }
+static __inline __int64 php_date_llabs( __int64 i ) { return i >= 0? i: -i; }
+#elif defined(__GNUC__) && __GNUC__ < 3
+static __inline __int64_t php_date_llabs( __int64_t i ) { return i >= 0 ? i : -i; }
+#else
+static __inline long long php_date_llabs( long long i ) { return i >= 0 ? i : -i; }
 #endif
 
 /* {{{ arginfo */
@@ -1011,7 +1007,7 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca
 {
 	smart_str            string = {0};
 	int                  i, length;
-	char                 buffer[33];
+	char                 buffer[97];
 	timelib_time_offset *offset = NULL;
 	timelib_sll          isoweek, isoyear;
 	int                  rfc_colon;
@@ -1070,7 +1066,7 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca
 			/* year */
 			case 'L': length = slprintf(buffer, 32, "%d", timelib_is_leap((int) t->y)); break;
 			case 'y': length = slprintf(buffer, 32, "%02d", (int) t->y % 100); break;
-			case 'Y': length = slprintf(buffer, 32, "%s%04lld", t->y < 0 ? "-" : "", llabs((timelib_sll) t->y)); break;
+			case 'Y': length = slprintf(buffer, 32, "%s%04lld", t->y < 0 ? "-" : "", php_date_llabs((timelib_sll) t->y)); break;
 
 			/* time */
 			case 'a': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "pm" : "am"); break;
@@ -1126,7 +1122,7 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca
 			case 'Z': length = slprintf(buffer, 32, "%d", localtime ? offset->offset : 0); break;
 
 			/* full date/time */
-			case 'c': length = slprintf(buffer, 32, "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
+			case 'c': length = slprintf(buffer, 96, "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
 							                (int) t->y, (int) t->m, (int) t->d,
 											(int) t->h, (int) t->i, (int) t->s,
 											localtime ? ((offset->offset < 0) ? '-' : '+') : '+',
@@ -1134,7 +1130,7 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca
 											localtime ? abs((offset->offset % 3600) / 60) : 0
 							  );
 					  break;
-			case 'r': length = slprintf(buffer, 32, "%3s, %02d %3s %04d %02d:%02d:%02d %c%02d%02d",
+			case 'r': length = slprintf(buffer, 96, "%3s, %02d %3s %04d %02d:%02d:%02d %c%02d%02d",
 							                php_date_short_day_name(t->y, t->m, t->d),
 											(int) t->d, mon_short_names[t->m - 1],
 											(int) t->y, (int) t->h, (int) t->i, (int) t->s,
@@ -2759,6 +2755,7 @@ PHP_FUNCTION(date_modify)
 	char         *modify;
 	int           modify_len;
 	timelib_time *tmp_time;
+	timelib_error_container *err = NULL;
 
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &modify, &modify_len) == FAILURE) {
 		RETURN_FALSE;
@@ -2766,7 +2763,18 @@ PHP_FUNCTION(date_modify)
 	dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
 	DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
 
-	tmp_time = timelib_strtotime(modify, modify_len, NULL, DATE_TIMEZONEDB);
+	tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB);
+
+	/* update last errors and warnings */
+	update_errors_warnings(err TSRMLS_CC);
+	if (err && err->error_count) {
+		/* spit out the first library error message, at least */
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", modify,
+			err->error_messages[0].position, err->error_messages[0].character, err->error_messages[0].message);
+		timelib_time_dtor(tmp_time);
+		RETURN_FALSE;
+	}
+
 	memcpy(&dateobj->time->relative, &tmp_time->relative, sizeof(struct timelib_rel_time));
 	dateobj->time->have_relative = tmp_time->have_relative;
 	dateobj->time->sse_uptodate = 0;
diff --git a/ext/date/php_date.h b/ext/date/php_date.h
index 37b0af9..e26e96a 100644
--- a/ext/date/php_date.h
+++ b/ext/date/php_date.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_date.h 281478 2009-05-31 21:28:38Z stas $ */
+/* $Id: php_date.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_DATE_H
 #define PHP_DATE_H
diff --git a/ext/date/tests/DateTimeZone_listIdentifiers_basic1.phpt b/ext/date/tests/DateTimeZone_listIdentifiers_basic1.phpt
index c1ab2f9..7eebfa8 100644
--- a/ext/date/tests/DateTimeZone_listIdentifiers_basic1.phpt
+++ b/ext/date/tests/DateTimeZone_listIdentifiers_basic1.phpt
@@ -13,816 +13,24 @@ echo "*** Testing DateTimeZone::listIdentifiers() : basic functionality ***\n";
 //Set the default time zone 
 date_default_timezone_set("GMT");
 
-var_dump( DateTimeZone::listIdentifiers() );
+$zones = DateTimeZone::listIdentifiers();
+echo "Check return tpe is ARRAY\n";
+var_dump(is_array($zones));
+
+echo "Check array contains some common timezones\n";
+var_dump(in_array("Europe/London", $zones));
+var_dump(in_array("America/New_York", $zones));
+var_dump(in_array("UTC", $zones));
 
 ?>
 ===DONE===
 --EXPECT--
 *** Testing DateTimeZone::listIdentifiers() : basic functionality ***
-array(402) {
-  [0]=>
-  string(14) "Africa/Abidjan"
-  [1]=>
-  string(12) "Africa/Accra"
-  [2]=>
-  string(18) "Africa/Addis_Ababa"
-  [3]=>
-  string(14) "Africa/Algiers"
-  [4]=>
-  string(13) "Africa/Asmara"
-  [5]=>
-  string(13) "Africa/Bamako"
-  [6]=>
-  string(13) "Africa/Bangui"
-  [7]=>
-  string(13) "Africa/Banjul"
-  [8]=>
-  string(13) "Africa/Bissau"
-  [9]=>
-  string(15) "Africa/Blantyre"
-  [10]=>
-  string(18) "Africa/Brazzaville"
-  [11]=>
-  string(16) "Africa/Bujumbura"
-  [12]=>
-  string(12) "Africa/Cairo"
-  [13]=>
-  string(17) "Africa/Casablanca"
-  [14]=>
-  string(12) "Africa/Ceuta"
-  [15]=>
-  string(14) "Africa/Conakry"
-  [16]=>
-  string(12) "Africa/Dakar"
-  [17]=>
-  string(20) "Africa/Dar_es_Salaam"
-  [18]=>
-  string(15) "Africa/Djibouti"
-  [19]=>
-  string(13) "Africa/Douala"
-  [20]=>
-  string(15) "Africa/El_Aaiun"
-  [21]=>
-  string(15) "Africa/Freetown"
-  [22]=>
-  string(15) "Africa/Gaborone"
-  [23]=>
-  string(13) "Africa/Harare"
-  [24]=>
-  string(19) "Africa/Johannesburg"
-  [25]=>
-  string(14) "Africa/Kampala"
-  [26]=>
-  string(15) "Africa/Khartoum"
-  [27]=>
-  string(13) "Africa/Kigali"
-  [28]=>
-  string(15) "Africa/Kinshasa"
-  [29]=>
-  string(12) "Africa/Lagos"
-  [30]=>
-  string(17) "Africa/Libreville"
-  [31]=>
-  string(11) "Africa/Lome"
-  [32]=>
-  string(13) "Africa/Luanda"
-  [33]=>
-  string(17) "Africa/Lubumbashi"
-  [34]=>
-  string(13) "Africa/Lusaka"
-  [35]=>
-  string(13) "Africa/Malabo"
-  [36]=>
-  string(13) "Africa/Maputo"
-  [37]=>
-  string(13) "Africa/Maseru"
-  [38]=>
-  string(14) "Africa/Mbabane"
-  [39]=>
-  string(16) "Africa/Mogadishu"
-  [40]=>
-  string(15) "Africa/Monrovia"
-  [41]=>
-  string(14) "Africa/Nairobi"
-  [42]=>
-  string(15) "Africa/Ndjamena"
-  [43]=>
-  string(13) "Africa/Niamey"
-  [44]=>
-  string(17) "Africa/Nouakchott"
-  [45]=>
-  string(18) "Africa/Ouagadougou"
-  [46]=>
-  string(17) "Africa/Porto-Novo"
-  [47]=>
-  string(15) "Africa/Sao_Tome"
-  [48]=>
-  string(14) "Africa/Tripoli"
-  [49]=>
-  string(12) "Africa/Tunis"
-  [50]=>
-  string(15) "Africa/Windhoek"
-  [51]=>
-  string(12) "America/Adak"
-  [52]=>
-  string(17) "America/Anchorage"
-  [53]=>
-  string(16) "America/Anguilla"
-  [54]=>
-  string(15) "America/Antigua"
-  [55]=>
-  string(17) "America/Araguaina"
-  [56]=>
-  string(30) "America/Argentina/Buenos_Aires"
-  [57]=>
-  string(27) "America/Argentina/Catamarca"
-  [58]=>
-  string(25) "America/Argentina/Cordoba"
-  [59]=>
-  string(23) "America/Argentina/Jujuy"
-  [60]=>
-  string(26) "America/Argentina/La_Rioja"
-  [61]=>
-  string(25) "America/Argentina/Mendoza"
-  [62]=>
-  string(30) "America/Argentina/Rio_Gallegos"
-  [63]=>
-  string(23) "America/Argentina/Salta"
-  [64]=>
-  string(26) "America/Argentina/San_Juan"
-  [65]=>
-  string(26) "America/Argentina/San_Luis"
-  [66]=>
-  string(25) "America/Argentina/Tucuman"
-  [67]=>
-  string(25) "America/Argentina/Ushuaia"
-  [68]=>
-  string(13) "America/Aruba"
-  [69]=>
-  string(16) "America/Asuncion"
-  [70]=>
-  string(16) "America/Atikokan"
-  [71]=>
-  string(13) "America/Bahia"
-  [72]=>
-  string(16) "America/Barbados"
-  [73]=>
-  string(13) "America/Belem"
-  [74]=>
-  string(14) "America/Belize"
-  [75]=>
-  string(20) "America/Blanc-Sablon"
-  [76]=>
-  string(17) "America/Boa_Vista"
-  [77]=>
-  string(14) "America/Bogota"
-  [78]=>
-  string(13) "America/Boise"
-  [79]=>
-  string(21) "America/Cambridge_Bay"
-  [80]=>
-  string(20) "America/Campo_Grande"
-  [81]=>
-  string(14) "America/Cancun"
-  [82]=>
-  string(15) "America/Caracas"
-  [83]=>
-  string(15) "America/Cayenne"
-  [84]=>
-  string(14) "America/Cayman"
-  [85]=>
-  string(15) "America/Chicago"
-  [86]=>
-  string(17) "America/Chihuahua"
-  [87]=>
-  string(18) "America/Costa_Rica"
-  [88]=>
-  string(14) "America/Cuiaba"
-  [89]=>
-  string(15) "America/Curacao"
-  [90]=>
-  string(20) "America/Danmarkshavn"
-  [91]=>
-  string(14) "America/Dawson"
-  [92]=>
-  string(20) "America/Dawson_Creek"
-  [93]=>
-  string(14) "America/Denver"
-  [94]=>
-  string(15) "America/Detroit"
-  [95]=>
-  string(16) "America/Dominica"
-  [96]=>
-  string(16) "America/Edmonton"
-  [97]=>
-  string(16) "America/Eirunepe"
-  [98]=>
-  string(19) "America/El_Salvador"
-  [99]=>
-  string(17) "America/Fortaleza"
-  [100]=>
-  string(17) "America/Glace_Bay"
-  [101]=>
-  string(15) "America/Godthab"
-  [102]=>
-  string(17) "America/Goose_Bay"
-  [103]=>
-  string(18) "America/Grand_Turk"
-  [104]=>
-  string(15) "America/Grenada"
-  [105]=>
-  string(18) "America/Guadeloupe"
-  [106]=>
-  string(17) "America/Guatemala"
-  [107]=>
-  string(17) "America/Guayaquil"
-  [108]=>
-  string(14) "America/Guyana"
-  [109]=>
-  string(15) "America/Halifax"
-  [110]=>
-  string(14) "America/Havana"
-  [111]=>
-  string(18) "America/Hermosillo"
-  [112]=>
-  string(28) "America/Indiana/Indianapolis"
-  [113]=>
-  string(20) "America/Indiana/Knox"
-  [114]=>
-  string(23) "America/Indiana/Marengo"
-  [115]=>
-  string(26) "America/Indiana/Petersburg"
-  [116]=>
-  string(25) "America/Indiana/Tell_City"
-  [117]=>
-  string(21) "America/Indiana/Vevay"
-  [118]=>
-  string(25) "America/Indiana/Vincennes"
-  [119]=>
-  string(23) "America/Indiana/Winamac"
-  [120]=>
-  string(14) "America/Inuvik"
-  [121]=>
-  string(15) "America/Iqaluit"
-  [122]=>
-  string(15) "America/Jamaica"
-  [123]=>
-  string(14) "America/Juneau"
-  [124]=>
-  string(27) "America/Kentucky/Louisville"
-  [125]=>
-  string(27) "America/Kentucky/Monticello"
-  [126]=>
-  string(14) "America/La_Paz"
-  [127]=>
-  string(12) "America/Lima"
-  [128]=>
-  string(19) "America/Los_Angeles"
-  [129]=>
-  string(14) "America/Maceio"
-  [130]=>
-  string(15) "America/Managua"
-  [131]=>
-  string(14) "America/Manaus"
-  [132]=>
-  string(15) "America/Marigot"
-  [133]=>
-  string(18) "America/Martinique"
-  [134]=>
-  string(16) "America/Mazatlan"
-  [135]=>
-  string(17) "America/Menominee"
-  [136]=>
-  string(14) "America/Merida"
-  [137]=>
-  string(19) "America/Mexico_City"
-  [138]=>
-  string(16) "America/Miquelon"
-  [139]=>
-  string(15) "America/Moncton"
-  [140]=>
-  string(17) "America/Monterrey"
-  [141]=>
-  string(18) "America/Montevideo"
-  [142]=>
-  string(16) "America/Montreal"
-  [143]=>
-  string(18) "America/Montserrat"
-  [144]=>
-  string(14) "America/Nassau"
-  [145]=>
-  string(16) "America/New_York"
-  [146]=>
-  string(15) "America/Nipigon"
-  [147]=>
-  string(12) "America/Nome"
-  [148]=>
-  string(15) "America/Noronha"
-  [149]=>
-  string(27) "America/North_Dakota/Center"
-  [150]=>
-  string(30) "America/North_Dakota/New_Salem"
-  [151]=>
-  string(14) "America/Panama"
-  [152]=>
-  string(19) "America/Pangnirtung"
-  [153]=>
-  string(18) "America/Paramaribo"
-  [154]=>
-  string(15) "America/Phoenix"
-  [155]=>
-  string(22) "America/Port-au-Prince"
-  [156]=>
-  string(21) "America/Port_of_Spain"
-  [157]=>
-  string(19) "America/Porto_Velho"
-  [158]=>
-  string(19) "America/Puerto_Rico"
-  [159]=>
-  string(19) "America/Rainy_River"
-  [160]=>
-  string(20) "America/Rankin_Inlet"
-  [161]=>
-  string(14) "America/Recife"
-  [162]=>
-  string(14) "America/Regina"
-  [163]=>
-  string(16) "America/Resolute"
-  [164]=>
-  string(18) "America/Rio_Branco"
-  [165]=>
-  string(16) "America/Santarem"
-  [166]=>
-  string(16) "America/Santiago"
-  [167]=>
-  string(21) "America/Santo_Domingo"
-  [168]=>
-  string(17) "America/Sao_Paulo"
-  [169]=>
-  string(20) "America/Scoresbysund"
-  [170]=>
-  string(16) "America/Shiprock"
-  [171]=>
-  string(21) "America/St_Barthelemy"
-  [172]=>
-  string(16) "America/St_Johns"
-  [173]=>
-  string(16) "America/St_Kitts"
-  [174]=>
-  string(16) "America/St_Lucia"
-  [175]=>
-  string(17) "America/St_Thomas"
-  [176]=>
-  string(18) "America/St_Vincent"
-  [177]=>
-  string(21) "America/Swift_Current"
-  [178]=>
-  string(19) "America/Tegucigalpa"
-  [179]=>
-  string(13) "America/Thule"
-  [180]=>
-  string(19) "America/Thunder_Bay"
-  [181]=>
-  string(15) "America/Tijuana"
-  [182]=>
-  string(15) "America/Toronto"
-  [183]=>
-  string(15) "America/Tortola"
-  [184]=>
-  string(17) "America/Vancouver"
-  [185]=>
-  string(18) "America/Whitehorse"
-  [186]=>
-  string(16) "America/Winnipeg"
-  [187]=>
-  string(15) "America/Yakutat"
-  [188]=>
-  string(19) "America/Yellowknife"
-  [189]=>
-  string(16) "Antarctica/Casey"
-  [190]=>
-  string(16) "Antarctica/Davis"
-  [191]=>
-  string(25) "Antarctica/DumontDUrville"
-  [192]=>
-  string(17) "Antarctica/Mawson"
-  [193]=>
-  string(18) "Antarctica/McMurdo"
-  [194]=>
-  string(17) "Antarctica/Palmer"
-  [195]=>
-  string(18) "Antarctica/Rothera"
-  [196]=>
-  string(21) "Antarctica/South_Pole"
-  [197]=>
-  string(16) "Antarctica/Syowa"
-  [198]=>
-  string(17) "Antarctica/Vostok"
-  [199]=>
-  string(19) "Arctic/Longyearbyen"
-  [200]=>
-  string(9) "Asia/Aden"
-  [201]=>
-  string(11) "Asia/Almaty"
-  [202]=>
-  string(10) "Asia/Amman"
-  [203]=>
-  string(11) "Asia/Anadyr"
-  [204]=>
-  string(10) "Asia/Aqtau"
-  [205]=>
-  string(11) "Asia/Aqtobe"
-  [206]=>
-  string(13) "Asia/Ashgabat"
-  [207]=>
-  string(12) "Asia/Baghdad"
-  [208]=>
-  string(12) "Asia/Bahrain"
-  [209]=>
-  string(9) "Asia/Baku"
-  [210]=>
-  string(12) "Asia/Bangkok"
-  [211]=>
-  string(11) "Asia/Beirut"
-  [212]=>
-  string(12) "Asia/Bishkek"
-  [213]=>
-  string(11) "Asia/Brunei"
-  [214]=>
-  string(15) "Asia/Choibalsan"
-  [215]=>
-  string(14) "Asia/Chongqing"
-  [216]=>
-  string(12) "Asia/Colombo"
-  [217]=>
-  string(13) "Asia/Damascus"
-  [218]=>
-  string(10) "Asia/Dhaka"
-  [219]=>
-  string(9) "Asia/Dili"
-  [220]=>
-  string(10) "Asia/Dubai"
-  [221]=>
-  string(13) "Asia/Dushanbe"
-  [222]=>
-  string(9) "Asia/Gaza"
-  [223]=>
-  string(11) "Asia/Harbin"
-  [224]=>
-  string(16) "Asia/Ho_Chi_Minh"
-  [225]=>
-  string(14) "Asia/Hong_Kong"
-  [226]=>
-  string(9) "Asia/Hovd"
-  [227]=>
-  string(12) "Asia/Irkutsk"
-  [228]=>
-  string(12) "Asia/Jakarta"
-  [229]=>
-  string(13) "Asia/Jayapura"
-  [230]=>
-  string(14) "Asia/Jerusalem"
-  [231]=>
-  string(10) "Asia/Kabul"
-  [232]=>
-  string(14) "Asia/Kamchatka"
-  [233]=>
-  string(12) "Asia/Karachi"
-  [234]=>
-  string(12) "Asia/Kashgar"
-  [235]=>
-  string(14) "Asia/Kathmandu"
-  [236]=>
-  string(12) "Asia/Kolkata"
-  [237]=>
-  string(16) "Asia/Krasnoyarsk"
-  [238]=>
-  string(17) "Asia/Kuala_Lumpur"
-  [239]=>
-  string(12) "Asia/Kuching"
-  [240]=>
-  string(11) "Asia/Kuwait"
-  [241]=>
-  string(10) "Asia/Macau"
-  [242]=>
-  string(12) "Asia/Magadan"
-  [243]=>
-  string(13) "Asia/Makassar"
-  [244]=>
-  string(11) "Asia/Manila"
-  [245]=>
-  string(11) "Asia/Muscat"
-  [246]=>
-  string(12) "Asia/Nicosia"
-  [247]=>
-  string(16) "Asia/Novosibirsk"
-  [248]=>
-  string(9) "Asia/Omsk"
-  [249]=>
-  string(9) "Asia/Oral"
-  [250]=>
-  string(15) "Asia/Phnom_Penh"
-  [251]=>
-  string(14) "Asia/Pontianak"
-  [252]=>
-  string(14) "Asia/Pyongyang"
-  [253]=>
-  string(10) "Asia/Qatar"
-  [254]=>
-  string(14) "Asia/Qyzylorda"
-  [255]=>
-  string(12) "Asia/Rangoon"
-  [256]=>
-  string(11) "Asia/Riyadh"
-  [257]=>
-  string(13) "Asia/Sakhalin"
-  [258]=>
-  string(14) "Asia/Samarkand"
-  [259]=>
-  string(10) "Asia/Seoul"
-  [260]=>
-  string(13) "Asia/Shanghai"
-  [261]=>
-  string(14) "Asia/Singapore"
-  [262]=>
-  string(11) "Asia/Taipei"
-  [263]=>
-  string(13) "Asia/Tashkent"
-  [264]=>
-  string(12) "Asia/Tbilisi"
-  [265]=>
-  string(11) "Asia/Tehran"
-  [266]=>
-  string(12) "Asia/Thimphu"
-  [267]=>
-  string(10) "Asia/Tokyo"
-  [268]=>
-  string(16) "Asia/Ulaanbaatar"
-  [269]=>
-  string(11) "Asia/Urumqi"
-  [270]=>
-  string(14) "Asia/Vientiane"
-  [271]=>
-  string(16) "Asia/Vladivostok"
-  [272]=>
-  string(12) "Asia/Yakutsk"
-  [273]=>
-  string(18) "Asia/Yekaterinburg"
-  [274]=>
-  string(12) "Asia/Yerevan"
-  [275]=>
-  string(15) "Atlantic/Azores"
-  [276]=>
-  string(16) "Atlantic/Bermuda"
-  [277]=>
-  string(15) "Atlantic/Canary"
-  [278]=>
-  string(19) "Atlantic/Cape_Verde"
-  [279]=>
-  string(14) "Atlantic/Faroe"
-  [280]=>
-  string(16) "Atlantic/Madeira"
-  [281]=>
-  string(18) "Atlantic/Reykjavik"
-  [282]=>
-  string(22) "Atlantic/South_Georgia"
-  [283]=>
-  string(18) "Atlantic/St_Helena"
-  [284]=>
-  string(16) "Atlantic/Stanley"
-  [285]=>
-  string(18) "Australia/Adelaide"
-  [286]=>
-  string(18) "Australia/Brisbane"
-  [287]=>
-  string(21) "Australia/Broken_Hill"
-  [288]=>
-  string(16) "Australia/Currie"
-  [289]=>
-  string(16) "Australia/Darwin"
-  [290]=>
-  string(15) "Australia/Eucla"
-  [291]=>
-  string(16) "Australia/Hobart"
-  [292]=>
-  string(18) "Australia/Lindeman"
-  [293]=>
-  string(19) "Australia/Lord_Howe"
-  [294]=>
-  string(19) "Australia/Melbourne"
-  [295]=>
-  string(15) "Australia/Perth"
-  [296]=>
-  string(16) "Australia/Sydney"
-  [297]=>
-  string(16) "Europe/Amsterdam"
-  [298]=>
-  string(14) "Europe/Andorra"
-  [299]=>
-  string(13) "Europe/Athens"
-  [300]=>
-  string(15) "Europe/Belgrade"
-  [301]=>
-  string(13) "Europe/Berlin"
-  [302]=>
-  string(17) "Europe/Bratislava"
-  [303]=>
-  string(15) "Europe/Brussels"
-  [304]=>
-  string(16) "Europe/Bucharest"
-  [305]=>
-  string(15) "Europe/Budapest"
-  [306]=>
-  string(15) "Europe/Chisinau"
-  [307]=>
-  string(17) "Europe/Copenhagen"
-  [308]=>
-  string(13) "Europe/Dublin"
-  [309]=>
-  string(16) "Europe/Gibraltar"
-  [310]=>
-  string(15) "Europe/Guernsey"
-  [311]=>
-  string(15) "Europe/Helsinki"
-  [312]=>
-  string(18) "Europe/Isle_of_Man"
-  [313]=>
-  string(15) "Europe/Istanbul"
-  [314]=>
-  string(13) "Europe/Jersey"
-  [315]=>
-  string(18) "Europe/Kaliningrad"
-  [316]=>
-  string(11) "Europe/Kiev"
-  [317]=>
-  string(13) "Europe/Lisbon"
-  [318]=>
-  string(16) "Europe/Ljubljana"
-  [319]=>
-  string(13) "Europe/London"
-  [320]=>
-  string(17) "Europe/Luxembourg"
-  [321]=>
-  string(13) "Europe/Madrid"
-  [322]=>
-  string(12) "Europe/Malta"
-  [323]=>
-  string(16) "Europe/Mariehamn"
-  [324]=>
-  string(12) "Europe/Minsk"
-  [325]=>
-  string(13) "Europe/Monaco"
-  [326]=>
-  string(13) "Europe/Moscow"
-  [327]=>
-  string(11) "Europe/Oslo"
-  [328]=>
-  string(12) "Europe/Paris"
-  [329]=>
-  string(16) "Europe/Podgorica"
-  [330]=>
-  string(13) "Europe/Prague"
-  [331]=>
-  string(11) "Europe/Riga"
-  [332]=>
-  string(11) "Europe/Rome"
-  [333]=>
-  string(13) "Europe/Samara"
-  [334]=>
-  string(17) "Europe/San_Marino"
-  [335]=>
-  string(15) "Europe/Sarajevo"
-  [336]=>
-  string(17) "Europe/Simferopol"
-  [337]=>
-  string(13) "Europe/Skopje"
-  [338]=>
-  string(12) "Europe/Sofia"
-  [339]=>
-  string(16) "Europe/Stockholm"
-  [340]=>
-  string(14) "Europe/Tallinn"
-  [341]=>
-  string(13) "Europe/Tirane"
-  [342]=>
-  string(15) "Europe/Uzhgorod"
-  [343]=>
-  string(12) "Europe/Vaduz"
-  [344]=>
-  string(14) "Europe/Vatican"
-  [345]=>
-  string(13) "Europe/Vienna"
-  [346]=>
-  string(14) "Europe/Vilnius"
-  [347]=>
-  string(16) "Europe/Volgograd"
-  [348]=>
-  string(13) "Europe/Warsaw"
-  [349]=>
-  string(13) "Europe/Zagreb"
-  [350]=>
-  string(17) "Europe/Zaporozhye"
-  [351]=>
-  string(13) "Europe/Zurich"
-  [352]=>
-  string(19) "Indian/Antananarivo"
-  [353]=>
-  string(13) "Indian/Chagos"
-  [354]=>
-  string(16) "Indian/Christmas"
-  [355]=>
-  string(12) "Indian/Cocos"
-  [356]=>
-  string(13) "Indian/Comoro"
-  [357]=>
-  string(16) "Indian/Kerguelen"
-  [358]=>
-  string(11) "Indian/Mahe"
-  [359]=>
-  string(15) "Indian/Maldives"
-  [360]=>
-  string(16) "Indian/Mauritius"
-  [361]=>
-  string(14) "Indian/Mayotte"
-  [362]=>
-  string(14) "Indian/Reunion"
-  [363]=>
-  string(12) "Pacific/Apia"
-  [364]=>
-  string(16) "Pacific/Auckland"
-  [365]=>
-  string(15) "Pacific/Chatham"
-  [366]=>
-  string(14) "Pacific/Easter"
-  [367]=>
-  string(13) "Pacific/Efate"
-  [368]=>
-  string(17) "Pacific/Enderbury"
-  [369]=>
-  string(15) "Pacific/Fakaofo"
-  [370]=>
-  string(12) "Pacific/Fiji"
-  [371]=>
-  string(16) "Pacific/Funafuti"
-  [372]=>
-  string(17) "Pacific/Galapagos"
-  [373]=>
-  string(15) "Pacific/Gambier"
-  [374]=>
-  string(19) "Pacific/Guadalcanal"
-  [375]=>
-  string(12) "Pacific/Guam"
-  [376]=>
-  string(16) "Pacific/Honolulu"
-  [377]=>
-  string(16) "Pacific/Johnston"
-  [378]=>
-  string(18) "Pacific/Kiritimati"
-  [379]=>
-  string(14) "Pacific/Kosrae"
-  [380]=>
-  string(17) "Pacific/Kwajalein"
-  [381]=>
-  string(14) "Pacific/Majuro"
-  [382]=>
-  string(17) "Pacific/Marquesas"
-  [383]=>
-  string(14) "Pacific/Midway"
-  [384]=>
-  string(13) "Pacific/Nauru"
-  [385]=>
-  string(12) "Pacific/Niue"
-  [386]=>
-  string(15) "Pacific/Norfolk"
-  [387]=>
-  string(14) "Pacific/Noumea"
-  [388]=>
-  string(17) "Pacific/Pago_Pago"
-  [389]=>
-  string(13) "Pacific/Palau"
-  [390]=>
-  string(16) "Pacific/Pitcairn"
-  [391]=>
-  string(14) "Pacific/Ponape"
-  [392]=>
-  string(20) "Pacific/Port_Moresby"
-  [393]=>
-  string(17) "Pacific/Rarotonga"
-  [394]=>
-  string(14) "Pacific/Saipan"
-  [395]=>
-  string(14) "Pacific/Tahiti"
-  [396]=>
-  string(14) "Pacific/Tarawa"
-  [397]=>
-  string(17) "Pacific/Tongatapu"
-  [398]=>
-  string(12) "Pacific/Truk"
-  [399]=>
-  string(12) "Pacific/Wake"
-  [400]=>
-  string(14) "Pacific/Wallis"
-  [401]=>
-  string(3) "UTC"
-}
-===DONE===
\ No newline at end of file
+Check return tpe is ARRAY
+bool(true)
+Check array contains some common timezones
+bool(true)
+bool(true)
+bool(true)
+===DONE===
+	
\ No newline at end of file
diff --git a/ext/date/tests/bug45866.phpt b/ext/date/tests/bug45866.phpt
new file mode 100644
index 0000000..a8407a6
--- /dev/null
+++ b/ext/date/tests/bug45866.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #45866 (decimal values fed to DateTime->modify() causes long execution times)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$date = new DateTime( '2009-07-29 16:44:23 Europe/London' );
+$date->modify( "+1.61538461538 day" );
+echo $date->format( 'r' ), "\n";
+
+$date = new DateTime( '2009-07-29 16:44:23 Europe/London' );
+$date->modify( "61538461538 day" );
+echo $date->format( 'r' ), "\n";
+
+$date = new DateTime( '2009-07-29 16:44:23 Europe/London' );
+$date->modify( "£61538461538 day" );
+echo $date->format( 'r' ), "\n";
+?>
+--EXPECTF--
+Thu, 14 Aug 168488594 16:44:23 +0000
+Thu, 14 Aug 168488594 16:44:23 +0000
+
+Warning: DateTime::modify(): Failed to parse time string (£61538461538 day) at position 0 (%s): Unexpected character in %sbug45866.php on line 11
+Wed, 29 Jul 2009 16:44:23 +0100
diff --git a/ext/date/tests/bug46268.phpt b/ext/date/tests/bug46268.phpt
index dd2d4a3..808fd85 100644
--- a/ext/date/tests/bug46268.phpt
+++ b/ext/date/tests/bug46268.phpt
@@ -7,10 +7,10 @@ date_default_timezone_set('Asia/Tokyo');
 $now = new DateTime('2008-10-10 01:02:03');
 echo $now->format("Y-m-d H:i:s") . PHP_EOL;
 
-$now->modify("1 day after");
+$now->modify("1 day");
 echo $now->format("Y-m-d H:i:s") . PHP_EOL;
 
-$now->modify("1 hour after");
+$now->modify("1 hour");
 echo $now->format("Y-m-d H:i:s") . PHP_EOL;
 
 $now->setTime(0, 0, 0);
diff --git a/ext/date/tests/bug49585.phpt b/ext/date/tests/bug49585.phpt
new file mode 100644
index 0000000..2ec1424
--- /dev/null
+++ b/ext/date/tests/bug49585.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #49585 (date_format buffer not long enough for >4 digit years)
+--FILE--
+<?php
+date_default_timezone_set('UTC');
+
+$date = new DateTime('-1500-01-01');
+var_dump($date->format('r'));
+
+$date->setDate(-2147483648, 1, 1);
+var_dump($date->format('r'));
+var_dump($date->format('c'));
+--EXPECT--
+string(32) "Sat, 01 Jan -1500 00:00:00 +0000"
+string(42) "Unknown, 01 Jan -2147483648 00:00:00 +0000"
+string(32) "-2147483648-01-01T00:00:00+00:00"
diff --git a/ext/date/tests/bug50392.phpt b/ext/date/tests/bug50392.phpt
new file mode 100644
index 0000000..8d10923
--- /dev/null
+++ b/ext/date/tests/bug50392.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Bug #50392 date_create_from_format enforces 6 digits for 'u' format character
+--FILE--
+<?php
+date_default_timezone_set('Europe/Bratislava');
+
+$base = '2009-03-01 18:00:00';
+
+for ($i = 0; $i < 8; $i++) {
+	var_dump(date_create_from_format('Y-m-d H:i:s.u', $base . '.' . str_repeat('1', $i)));
+}
+?>
+--EXPECT--
+bool(false)
+object(DateTime)#2 (3) {
+  ["date"]=>
+  string(19) "2009-03-01 18:00:00"
+  ["timezone_type"]=>
+  int(3)
+  ["timezone"]=>
+  string(17) "Europe/Bratislava"
+}
+object(DateTime)#2 (3) {
+  ["date"]=>
+  string(19) "2009-03-01 18:00:00"
+  ["timezone_type"]=>
+  int(3)
+  ["timezone"]=>
+  string(17) "Europe/Bratislava"
+}
+object(DateTime)#2 (3) {
+  ["date"]=>
+  string(19) "2009-03-01 18:00:00"
+  ["timezone_type"]=>
+  int(3)
+  ["timezone"]=>
+  string(17) "Europe/Bratislava"
+}
+object(DateTime)#2 (3) {
+  ["date"]=>
+  string(19) "2009-03-01 18:00:00"
+  ["timezone_type"]=>
+  int(3)
+  ["timezone"]=>
+  string(17) "Europe/Bratislava"
+}
+object(DateTime)#2 (3) {
+  ["date"]=>
+  string(19) "2009-03-01 18:00:00"
+  ["timezone_type"]=>
+  int(3)
+  ["timezone"]=>
+  string(17) "Europe/Bratislava"
+}
+object(DateTime)#2 (3) {
+  ["date"]=>
+  string(19) "2009-03-01 18:00:00"
+  ["timezone_type"]=>
+  int(3)
+  ["timezone"]=>
+  string(17) "Europe/Bratislava"
+}
+bool(false)
diff --git a/ext/date/tests/bug50680.phpt b/ext/date/tests/bug50680.phpt
new file mode 100644
index 0000000..99b1381
--- /dev/null
+++ b/ext/date/tests/bug50680.phpt
@@ -0,0 +1,9 @@
+--TEST--
+Bug #50680 ("eighth" quantifier is not understood)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+var_dump(date("d", strtotime("March 1 eighth day 2009")));
+--EXPECT--
+string(2) "09"
diff --git a/ext/date/tests/oo_002.phpt b/ext/date/tests/oo_002.phpt
index 0dade99..34e6941 100644
--- a/ext/date/tests/oo_002.phpt
+++ b/ext/date/tests/oo_002.phpt
@@ -9,7 +9,7 @@ $d = new _d("1pm Aug 1 GMT 2007");
 var_dump($d->format(DateTime::RFC822));
 $c = clone $d;
 var_dump($c->format(DateTime::RFC822));
-$d->modify("1 hour after");
+$d->modify("1 hour");
 $c->modify("1 second ago");
 var_dump($d->format(DateTime::RFC822));
 var_dump($c->format(DateTime::RFC822));
diff --git a/ext/date/tests/sunfuncts.phpt b/ext/date/tests/sunfuncts.phpt
new file mode 100644
index 0000000..59acb12
--- /dev/null
+++ b/ext/date/tests/sunfuncts.phpt
@@ -0,0 +1,42 @@
+--TEST--
+date_sunrise() and date_sunset() functions
+--INI--
+precision=13
+--FILE--
+<?php
+date_default_timezone_set('Asia/Jerusalem');
+for($a=1;$a<=12;$a++){
+	echo date_sunrise(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_TIMESTAMP,31.76670,35.23330,90.83,2)." ";
+	echo date_sunrise(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_STRING,31.76670,35.23330,90.83,2)." ";
+	echo date_sunrise(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_DOUBLE,31.76670,35.23330,90.83,2)."\n";
+	
+	echo date_sunset(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_TIMESTAMP,31.76670,35.23330,90.83,2)." ";
+	echo date_sunset(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_STRING,31.76670,35.23330,90.83,2)." ";
+	echo date_sunset(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_DOUBLE,31.76670,35.23330,90.83,2)."\n";
+}
+?>
+--EXPECTF--
+1041395864 06:37 6.6290131458%d
+1041432452 16:47 16.792451114%d
+1044073855 06:30 6.5154089279%d
+1044112463 17:14 17.239870289%d
+1046491495 06:04 6.0822145033%d
+1046533075 17:37 17.632011035%d
+1049167581 05:26 5.4394438111%d
+1049212774 17:59 17.993035729%d
+1051757532 04:52 4.8701934126%d
+1051806007 18:20 18.335390508%d
+1054434776 04:32 4.5489827182%d
+1054485647 18:40 18.679812949%d
+1057026949 04:35 4.5971956372%d
+1057078197 18:49 18.832563396%d
+1059706409 04:53 4.8916575089%d
+1059755837 18:37 18.621440704%d
+1062385999 05:13 5.2220951121%d
+1062432291 18:04 18.080957168%d
+1064979098 05:31 5.5273199215%d
+1065021952 17:25 17.431339135%d
+1067658845 05:54 5.9016292870%d
+1067698274 16:51 16.853902453%d
+1070252387 06:19 6.3299242689%d
+1070289382 16:36 16.606312600%d
diff --git a/ext/date/tests/timezone_identifiers_list_basic1.phpt b/ext/date/tests/timezone_identifiers_list_basic1.phpt
index 80bee6d..4476da2 100644
--- a/ext/date/tests/timezone_identifiers_list_basic1.phpt
+++ b/ext/date/tests/timezone_identifiers_list_basic1.phpt
@@ -13,816 +13,24 @@ echo "*** Testing timezone_identifiers_list() : basic functionality ***\n";
 //Set the default time zone 
 date_default_timezone_set("GMT");
 
-var_dump (timezone_identifiers_list() );
+$zones = timezone_identifiers_list();
+echo "Check return tpe is ARRAY\n";
+var_dump(is_array($zones));
+
+echo "Check array contains some common timezones\n";
+var_dump(in_array("Europe/London", $zones));
+var_dump(in_array("America/New_York", $zones));
+var_dump(in_array("UTC", $zones));
 
 ?>
 ===DONE===
 --EXPECTF--
 *** Testing timezone_identifiers_list() : basic functionality ***
-array(402) {
-  [0]=>
-  string(14) "Africa/Abidjan"
-  [1]=>
-  string(12) "Africa/Accra"
-  [2]=>
-  string(18) "Africa/Addis_Ababa"
-  [3]=>
-  string(14) "Africa/Algiers"
-  [4]=>
-  string(13) "Africa/Asmara"
-  [5]=>
-  string(13) "Africa/Bamako"
-  [6]=>
-  string(13) "Africa/Bangui"
-  [7]=>
-  string(13) "Africa/Banjul"
-  [8]=>
-  string(13) "Africa/Bissau"
-  [9]=>
-  string(15) "Africa/Blantyre"
-  [10]=>
-  string(18) "Africa/Brazzaville"
-  [11]=>
-  string(16) "Africa/Bujumbura"
-  [12]=>
-  string(12) "Africa/Cairo"
-  [13]=>
-  string(17) "Africa/Casablanca"
-  [14]=>
-  string(12) "Africa/Ceuta"
-  [15]=>
-  string(14) "Africa/Conakry"
-  [16]=>
-  string(12) "Africa/Dakar"
-  [17]=>
-  string(20) "Africa/Dar_es_Salaam"
-  [18]=>
-  string(15) "Africa/Djibouti"
-  [19]=>
-  string(13) "Africa/Douala"
-  [20]=>
-  string(15) "Africa/El_Aaiun"
-  [21]=>
-  string(15) "Africa/Freetown"
-  [22]=>
-  string(15) "Africa/Gaborone"
-  [23]=>
-  string(13) "Africa/Harare"
-  [24]=>
-  string(19) "Africa/Johannesburg"
-  [25]=>
-  string(14) "Africa/Kampala"
-  [26]=>
-  string(15) "Africa/Khartoum"
-  [27]=>
-  string(13) "Africa/Kigali"
-  [28]=>
-  string(15) "Africa/Kinshasa"
-  [29]=>
-  string(12) "Africa/Lagos"
-  [30]=>
-  string(17) "Africa/Libreville"
-  [31]=>
-  string(11) "Africa/Lome"
-  [32]=>
-  string(13) "Africa/Luanda"
-  [33]=>
-  string(17) "Africa/Lubumbashi"
-  [34]=>
-  string(13) "Africa/Lusaka"
-  [35]=>
-  string(13) "Africa/Malabo"
-  [36]=>
-  string(13) "Africa/Maputo"
-  [37]=>
-  string(13) "Africa/Maseru"
-  [38]=>
-  string(14) "Africa/Mbabane"
-  [39]=>
-  string(16) "Africa/Mogadishu"
-  [40]=>
-  string(15) "Africa/Monrovia"
-  [41]=>
-  string(14) "Africa/Nairobi"
-  [42]=>
-  string(15) "Africa/Ndjamena"
-  [43]=>
-  string(13) "Africa/Niamey"
-  [44]=>
-  string(17) "Africa/Nouakchott"
-  [45]=>
-  string(18) "Africa/Ouagadougou"
-  [46]=>
-  string(17) "Africa/Porto-Novo"
-  [47]=>
-  string(15) "Africa/Sao_Tome"
-  [48]=>
-  string(14) "Africa/Tripoli"
-  [49]=>
-  string(12) "Africa/Tunis"
-  [50]=>
-  string(15) "Africa/Windhoek"
-  [51]=>
-  string(12) "America/Adak"
-  [52]=>
-  string(17) "America/Anchorage"
-  [53]=>
-  string(16) "America/Anguilla"
-  [54]=>
-  string(15) "America/Antigua"
-  [55]=>
-  string(17) "America/Araguaina"
-  [56]=>
-  string(30) "America/Argentina/Buenos_Aires"
-  [57]=>
-  string(27) "America/Argentina/Catamarca"
-  [58]=>
-  string(25) "America/Argentina/Cordoba"
-  [59]=>
-  string(23) "America/Argentina/Jujuy"
-  [60]=>
-  string(26) "America/Argentina/La_Rioja"
-  [61]=>
-  string(25) "America/Argentina/Mendoza"
-  [62]=>
-  string(30) "America/Argentina/Rio_Gallegos"
-  [63]=>
-  string(23) "America/Argentina/Salta"
-  [64]=>
-  string(26) "America/Argentina/San_Juan"
-  [65]=>
-  string(26) "America/Argentina/San_Luis"
-  [66]=>
-  string(25) "America/Argentina/Tucuman"
-  [67]=>
-  string(25) "America/Argentina/Ushuaia"
-  [68]=>
-  string(13) "America/Aruba"
-  [69]=>
-  string(16) "America/Asuncion"
-  [70]=>
-  string(16) "America/Atikokan"
-  [71]=>
-  string(13) "America/Bahia"
-  [72]=>
-  string(16) "America/Barbados"
-  [73]=>
-  string(13) "America/Belem"
-  [74]=>
-  string(14) "America/Belize"
-  [75]=>
-  string(20) "America/Blanc-Sablon"
-  [76]=>
-  string(17) "America/Boa_Vista"
-  [77]=>
-  string(14) "America/Bogota"
-  [78]=>
-  string(13) "America/Boise"
-  [79]=>
-  string(21) "America/Cambridge_Bay"
-  [80]=>
-  string(20) "America/Campo_Grande"
-  [81]=>
-  string(14) "America/Cancun"
-  [82]=>
-  string(15) "America/Caracas"
-  [83]=>
-  string(15) "America/Cayenne"
-  [84]=>
-  string(14) "America/Cayman"
-  [85]=>
-  string(15) "America/Chicago"
-  [86]=>
-  string(17) "America/Chihuahua"
-  [87]=>
-  string(18) "America/Costa_Rica"
-  [88]=>
-  string(14) "America/Cuiaba"
-  [89]=>
-  string(15) "America/Curacao"
-  [90]=>
-  string(20) "America/Danmarkshavn"
-  [91]=>
-  string(14) "America/Dawson"
-  [92]=>
-  string(20) "America/Dawson_Creek"
-  [93]=>
-  string(14) "America/Denver"
-  [94]=>
-  string(15) "America/Detroit"
-  [95]=>
-  string(16) "America/Dominica"
-  [96]=>
-  string(16) "America/Edmonton"
-  [97]=>
-  string(16) "America/Eirunepe"
-  [98]=>
-  string(19) "America/El_Salvador"
-  [99]=>
-  string(17) "America/Fortaleza"
-  [100]=>
-  string(17) "America/Glace_Bay"
-  [101]=>
-  string(15) "America/Godthab"
-  [102]=>
-  string(17) "America/Goose_Bay"
-  [103]=>
-  string(18) "America/Grand_Turk"
-  [104]=>
-  string(15) "America/Grenada"
-  [105]=>
-  string(18) "America/Guadeloupe"
-  [106]=>
-  string(17) "America/Guatemala"
-  [107]=>
-  string(17) "America/Guayaquil"
-  [108]=>
-  string(14) "America/Guyana"
-  [109]=>
-  string(15) "America/Halifax"
-  [110]=>
-  string(14) "America/Havana"
-  [111]=>
-  string(18) "America/Hermosillo"
-  [112]=>
-  string(28) "America/Indiana/Indianapolis"
-  [113]=>
-  string(20) "America/Indiana/Knox"
-  [114]=>
-  string(23) "America/Indiana/Marengo"
-  [115]=>
-  string(26) "America/Indiana/Petersburg"
-  [116]=>
-  string(25) "America/Indiana/Tell_City"
-  [117]=>
-  string(21) "America/Indiana/Vevay"
-  [118]=>
-  string(25) "America/Indiana/Vincennes"
-  [119]=>
-  string(23) "America/Indiana/Winamac"
-  [120]=>
-  string(14) "America/Inuvik"
-  [121]=>
-  string(15) "America/Iqaluit"
-  [122]=>
-  string(15) "America/Jamaica"
-  [123]=>
-  string(14) "America/Juneau"
-  [124]=>
-  string(27) "America/Kentucky/Louisville"
-  [125]=>
-  string(27) "America/Kentucky/Monticello"
-  [126]=>
-  string(14) "America/La_Paz"
-  [127]=>
-  string(12) "America/Lima"
-  [128]=>
-  string(19) "America/Los_Angeles"
-  [129]=>
-  string(14) "America/Maceio"
-  [130]=>
-  string(15) "America/Managua"
-  [131]=>
-  string(14) "America/Manaus"
-  [132]=>
-  string(15) "America/Marigot"
-  [133]=>
-  string(18) "America/Martinique"
-  [134]=>
-  string(16) "America/Mazatlan"
-  [135]=>
-  string(17) "America/Menominee"
-  [136]=>
-  string(14) "America/Merida"
-  [137]=>
-  string(19) "America/Mexico_City"
-  [138]=>
-  string(16) "America/Miquelon"
-  [139]=>
-  string(15) "America/Moncton"
-  [140]=>
-  string(17) "America/Monterrey"
-  [141]=>
-  string(18) "America/Montevideo"
-  [142]=>
-  string(16) "America/Montreal"
-  [143]=>
-  string(18) "America/Montserrat"
-  [144]=>
-  string(14) "America/Nassau"
-  [145]=>
-  string(16) "America/New_York"
-  [146]=>
-  string(15) "America/Nipigon"
-  [147]=>
-  string(12) "America/Nome"
-  [148]=>
-  string(15) "America/Noronha"
-  [149]=>
-  string(27) "America/North_Dakota/Center"
-  [150]=>
-  string(30) "America/North_Dakota/New_Salem"
-  [151]=>
-  string(14) "America/Panama"
-  [152]=>
-  string(19) "America/Pangnirtung"
-  [153]=>
-  string(18) "America/Paramaribo"
-  [154]=>
-  string(15) "America/Phoenix"
-  [155]=>
-  string(22) "America/Port-au-Prince"
-  [156]=>
-  string(21) "America/Port_of_Spain"
-  [157]=>
-  string(19) "America/Porto_Velho"
-  [158]=>
-  string(19) "America/Puerto_Rico"
-  [159]=>
-  string(19) "America/Rainy_River"
-  [160]=>
-  string(20) "America/Rankin_Inlet"
-  [161]=>
-  string(14) "America/Recife"
-  [162]=>
-  string(14) "America/Regina"
-  [163]=>
-  string(16) "America/Resolute"
-  [164]=>
-  string(18) "America/Rio_Branco"
-  [165]=>
-  string(16) "America/Santarem"
-  [166]=>
-  string(16) "America/Santiago"
-  [167]=>
-  string(21) "America/Santo_Domingo"
-  [168]=>
-  string(17) "America/Sao_Paulo"
-  [169]=>
-  string(20) "America/Scoresbysund"
-  [170]=>
-  string(16) "America/Shiprock"
-  [171]=>
-  string(21) "America/St_Barthelemy"
-  [172]=>
-  string(16) "America/St_Johns"
-  [173]=>
-  string(16) "America/St_Kitts"
-  [174]=>
-  string(16) "America/St_Lucia"
-  [175]=>
-  string(17) "America/St_Thomas"
-  [176]=>
-  string(18) "America/St_Vincent"
-  [177]=>
-  string(21) "America/Swift_Current"
-  [178]=>
-  string(19) "America/Tegucigalpa"
-  [179]=>
-  string(13) "America/Thule"
-  [180]=>
-  string(19) "America/Thunder_Bay"
-  [181]=>
-  string(15) "America/Tijuana"
-  [182]=>
-  string(15) "America/Toronto"
-  [183]=>
-  string(15) "America/Tortola"
-  [184]=>
-  string(17) "America/Vancouver"
-  [185]=>
-  string(18) "America/Whitehorse"
-  [186]=>
-  string(16) "America/Winnipeg"
-  [187]=>
-  string(15) "America/Yakutat"
-  [188]=>
-  string(19) "America/Yellowknife"
-  [189]=>
-  string(16) "Antarctica/Casey"
-  [190]=>
-  string(16) "Antarctica/Davis"
-  [191]=>
-  string(25) "Antarctica/DumontDUrville"
-  [192]=>
-  string(17) "Antarctica/Mawson"
-  [193]=>
-  string(18) "Antarctica/McMurdo"
-  [194]=>
-  string(17) "Antarctica/Palmer"
-  [195]=>
-  string(18) "Antarctica/Rothera"
-  [196]=>
-  string(21) "Antarctica/South_Pole"
-  [197]=>
-  string(16) "Antarctica/Syowa"
-  [198]=>
-  string(17) "Antarctica/Vostok"
-  [199]=>
-  string(19) "Arctic/Longyearbyen"
-  [200]=>
-  string(9) "Asia/Aden"
-  [201]=>
-  string(11) "Asia/Almaty"
-  [202]=>
-  string(10) "Asia/Amman"
-  [203]=>
-  string(11) "Asia/Anadyr"
-  [204]=>
-  string(10) "Asia/Aqtau"
-  [205]=>
-  string(11) "Asia/Aqtobe"
-  [206]=>
-  string(13) "Asia/Ashgabat"
-  [207]=>
-  string(12) "Asia/Baghdad"
-  [208]=>
-  string(12) "Asia/Bahrain"
-  [209]=>
-  string(9) "Asia/Baku"
-  [210]=>
-  string(12) "Asia/Bangkok"
-  [211]=>
-  string(11) "Asia/Beirut"
-  [212]=>
-  string(12) "Asia/Bishkek"
-  [213]=>
-  string(11) "Asia/Brunei"
-  [214]=>
-  string(15) "Asia/Choibalsan"
-  [215]=>
-  string(14) "Asia/Chongqing"
-  [216]=>
-  string(12) "Asia/Colombo"
-  [217]=>
-  string(13) "Asia/Damascus"
-  [218]=>
-  string(10) "Asia/Dhaka"
-  [219]=>
-  string(9) "Asia/Dili"
-  [220]=>
-  string(10) "Asia/Dubai"
-  [221]=>
-  string(13) "Asia/Dushanbe"
-  [222]=>
-  string(9) "Asia/Gaza"
-  [223]=>
-  string(11) "Asia/Harbin"
-  [224]=>
-  string(16) "Asia/Ho_Chi_Minh"
-  [225]=>
-  string(14) "Asia/Hong_Kong"
-  [226]=>
-  string(9) "Asia/Hovd"
-  [227]=>
-  string(12) "Asia/Irkutsk"
-  [228]=>
-  string(12) "Asia/Jakarta"
-  [229]=>
-  string(13) "Asia/Jayapura"
-  [230]=>
-  string(14) "Asia/Jerusalem"
-  [231]=>
-  string(10) "Asia/Kabul"
-  [232]=>
-  string(14) "Asia/Kamchatka"
-  [233]=>
-  string(12) "Asia/Karachi"
-  [234]=>
-  string(12) "Asia/Kashgar"
-  [235]=>
-  string(14) "Asia/Kathmandu"
-  [236]=>
-  string(12) "Asia/Kolkata"
-  [237]=>
-  string(16) "Asia/Krasnoyarsk"
-  [238]=>
-  string(17) "Asia/Kuala_Lumpur"
-  [239]=>
-  string(12) "Asia/Kuching"
-  [240]=>
-  string(11) "Asia/Kuwait"
-  [241]=>
-  string(10) "Asia/Macau"
-  [242]=>
-  string(12) "Asia/Magadan"
-  [243]=>
-  string(13) "Asia/Makassar"
-  [244]=>
-  string(11) "Asia/Manila"
-  [245]=>
-  string(11) "Asia/Muscat"
-  [246]=>
-  string(12) "Asia/Nicosia"
-  [247]=>
-  string(16) "Asia/Novosibirsk"
-  [248]=>
-  string(9) "Asia/Omsk"
-  [249]=>
-  string(9) "Asia/Oral"
-  [250]=>
-  string(15) "Asia/Phnom_Penh"
-  [251]=>
-  string(14) "Asia/Pontianak"
-  [252]=>
-  string(14) "Asia/Pyongyang"
-  [253]=>
-  string(10) "Asia/Qatar"
-  [254]=>
-  string(14) "Asia/Qyzylorda"
-  [255]=>
-  string(12) "Asia/Rangoon"
-  [256]=>
-  string(11) "Asia/Riyadh"
-  [257]=>
-  string(13) "Asia/Sakhalin"
-  [258]=>
-  string(14) "Asia/Samarkand"
-  [259]=>
-  string(10) "Asia/Seoul"
-  [260]=>
-  string(13) "Asia/Shanghai"
-  [261]=>
-  string(14) "Asia/Singapore"
-  [262]=>
-  string(11) "Asia/Taipei"
-  [263]=>
-  string(13) "Asia/Tashkent"
-  [264]=>
-  string(12) "Asia/Tbilisi"
-  [265]=>
-  string(11) "Asia/Tehran"
-  [266]=>
-  string(12) "Asia/Thimphu"
-  [267]=>
-  string(10) "Asia/Tokyo"
-  [268]=>
-  string(16) "Asia/Ulaanbaatar"
-  [269]=>
-  string(11) "Asia/Urumqi"
-  [270]=>
-  string(14) "Asia/Vientiane"
-  [271]=>
-  string(16) "Asia/Vladivostok"
-  [272]=>
-  string(12) "Asia/Yakutsk"
-  [273]=>
-  string(18) "Asia/Yekaterinburg"
-  [274]=>
-  string(12) "Asia/Yerevan"
-  [275]=>
-  string(15) "Atlantic/Azores"
-  [276]=>
-  string(16) "Atlantic/Bermuda"
-  [277]=>
-  string(15) "Atlantic/Canary"
-  [278]=>
-  string(19) "Atlantic/Cape_Verde"
-  [279]=>
-  string(14) "Atlantic/Faroe"
-  [280]=>
-  string(16) "Atlantic/Madeira"
-  [281]=>
-  string(18) "Atlantic/Reykjavik"
-  [282]=>
-  string(22) "Atlantic/South_Georgia"
-  [283]=>
-  string(18) "Atlantic/St_Helena"
-  [284]=>
-  string(16) "Atlantic/Stanley"
-  [285]=>
-  string(18) "Australia/Adelaide"
-  [286]=>
-  string(18) "Australia/Brisbane"
-  [287]=>
-  string(21) "Australia/Broken_Hill"
-  [288]=>
-  string(16) "Australia/Currie"
-  [289]=>
-  string(16) "Australia/Darwin"
-  [290]=>
-  string(15) "Australia/Eucla"
-  [291]=>
-  string(16) "Australia/Hobart"
-  [292]=>
-  string(18) "Australia/Lindeman"
-  [293]=>
-  string(19) "Australia/Lord_Howe"
-  [294]=>
-  string(19) "Australia/Melbourne"
-  [295]=>
-  string(15) "Australia/Perth"
-  [296]=>
-  string(16) "Australia/Sydney"
-  [297]=>
-  string(16) "Europe/Amsterdam"
-  [298]=>
-  string(14) "Europe/Andorra"
-  [299]=>
-  string(13) "Europe/Athens"
-  [300]=>
-  string(15) "Europe/Belgrade"
-  [301]=>
-  string(13) "Europe/Berlin"
-  [302]=>
-  string(17) "Europe/Bratislava"
-  [303]=>
-  string(15) "Europe/Brussels"
-  [304]=>
-  string(16) "Europe/Bucharest"
-  [305]=>
-  string(15) "Europe/Budapest"
-  [306]=>
-  string(15) "Europe/Chisinau"
-  [307]=>
-  string(17) "Europe/Copenhagen"
-  [308]=>
-  string(13) "Europe/Dublin"
-  [309]=>
-  string(16) "Europe/Gibraltar"
-  [310]=>
-  string(15) "Europe/Guernsey"
-  [311]=>
-  string(15) "Europe/Helsinki"
-  [312]=>
-  string(18) "Europe/Isle_of_Man"
-  [313]=>
-  string(15) "Europe/Istanbul"
-  [314]=>
-  string(13) "Europe/Jersey"
-  [315]=>
-  string(18) "Europe/Kaliningrad"
-  [316]=>
-  string(11) "Europe/Kiev"
-  [317]=>
-  string(13) "Europe/Lisbon"
-  [318]=>
-  string(16) "Europe/Ljubljana"
-  [319]=>
-  string(13) "Europe/London"
-  [320]=>
-  string(17) "Europe/Luxembourg"
-  [321]=>
-  string(13) "Europe/Madrid"
-  [322]=>
-  string(12) "Europe/Malta"
-  [323]=>
-  string(16) "Europe/Mariehamn"
-  [324]=>
-  string(12) "Europe/Minsk"
-  [325]=>
-  string(13) "Europe/Monaco"
-  [326]=>
-  string(13) "Europe/Moscow"
-  [327]=>
-  string(11) "Europe/Oslo"
-  [328]=>
-  string(12) "Europe/Paris"
-  [329]=>
-  string(16) "Europe/Podgorica"
-  [330]=>
-  string(13) "Europe/Prague"
-  [331]=>
-  string(11) "Europe/Riga"
-  [332]=>
-  string(11) "Europe/Rome"
-  [333]=>
-  string(13) "Europe/Samara"
-  [334]=>
-  string(17) "Europe/San_Marino"
-  [335]=>
-  string(15) "Europe/Sarajevo"
-  [336]=>
-  string(17) "Europe/Simferopol"
-  [337]=>
-  string(13) "Europe/Skopje"
-  [338]=>
-  string(12) "Europe/Sofia"
-  [339]=>
-  string(16) "Europe/Stockholm"
-  [340]=>
-  string(14) "Europe/Tallinn"
-  [341]=>
-  string(13) "Europe/Tirane"
-  [342]=>
-  string(15) "Europe/Uzhgorod"
-  [343]=>
-  string(12) "Europe/Vaduz"
-  [344]=>
-  string(14) "Europe/Vatican"
-  [345]=>
-  string(13) "Europe/Vienna"
-  [346]=>
-  string(14) "Europe/Vilnius"
-  [347]=>
-  string(16) "Europe/Volgograd"
-  [348]=>
-  string(13) "Europe/Warsaw"
-  [349]=>
-  string(13) "Europe/Zagreb"
-  [350]=>
-  string(17) "Europe/Zaporozhye"
-  [351]=>
-  string(13) "Europe/Zurich"
-  [352]=>
-  string(19) "Indian/Antananarivo"
-  [353]=>
-  string(13) "Indian/Chagos"
-  [354]=>
-  string(16) "Indian/Christmas"
-  [355]=>
-  string(12) "Indian/Cocos"
-  [356]=>
-  string(13) "Indian/Comoro"
-  [357]=>
-  string(16) "Indian/Kerguelen"
-  [358]=>
-  string(11) "Indian/Mahe"
-  [359]=>
-  string(15) "Indian/Maldives"
-  [360]=>
-  string(16) "Indian/Mauritius"
-  [361]=>
-  string(14) "Indian/Mayotte"
-  [362]=>
-  string(14) "Indian/Reunion"
-  [363]=>
-  string(12) "Pacific/Apia"
-  [364]=>
-  string(16) "Pacific/Auckland"
-  [365]=>
-  string(15) "Pacific/Chatham"
-  [366]=>
-  string(14) "Pacific/Easter"
-  [367]=>
-  string(13) "Pacific/Efate"
-  [368]=>
-  string(17) "Pacific/Enderbury"
-  [369]=>
-  string(15) "Pacific/Fakaofo"
-  [370]=>
-  string(12) "Pacific/Fiji"
-  [371]=>
-  string(16) "Pacific/Funafuti"
-  [372]=>
-  string(17) "Pacific/Galapagos"
-  [373]=>
-  string(15) "Pacific/Gambier"
-  [374]=>
-  string(19) "Pacific/Guadalcanal"
-  [375]=>
-  string(12) "Pacific/Guam"
-  [376]=>
-  string(16) "Pacific/Honolulu"
-  [377]=>
-  string(16) "Pacific/Johnston"
-  [378]=>
-  string(18) "Pacific/Kiritimati"
-  [379]=>
-  string(14) "Pacific/Kosrae"
-  [380]=>
-  string(17) "Pacific/Kwajalein"
-  [381]=>
-  string(14) "Pacific/Majuro"
-  [382]=>
-  string(17) "Pacific/Marquesas"
-  [383]=>
-  string(14) "Pacific/Midway"
-  [384]=>
-  string(13) "Pacific/Nauru"
-  [385]=>
-  string(12) "Pacific/Niue"
-  [386]=>
-  string(15) "Pacific/Norfolk"
-  [387]=>
-  string(14) "Pacific/Noumea"
-  [388]=>
-  string(17) "Pacific/Pago_Pago"
-  [389]=>
-  string(13) "Pacific/Palau"
-  [390]=>
-  string(16) "Pacific/Pitcairn"
-  [391]=>
-  string(14) "Pacific/Ponape"
-  [392]=>
-  string(20) "Pacific/Port_Moresby"
-  [393]=>
-  string(17) "Pacific/Rarotonga"
-  [394]=>
-  string(14) "Pacific/Saipan"
-  [395]=>
-  string(14) "Pacific/Tahiti"
-  [396]=>
-  string(14) "Pacific/Tarawa"
-  [397]=>
-  string(17) "Pacific/Tongatapu"
-  [398]=>
-  string(12) "Pacific/Truk"
-  [399]=>
-  string(12) "Pacific/Wake"
-  [400]=>
-  string(14) "Pacific/Wallis"
-  [401]=>
-  string(3) "UTC"
-}
+Check return tpe is ARRAY
+bool(true)
+Check array contains some common timezones
+bool(true)
+bool(true)
+bool(true)
 ===DONE===
+	
\ No newline at end of file
diff --git a/ext/dba/dba.c b/ext/dba/dba.c
index d59b1f2..dca6ac6 100644
--- a/ext/dba/dba.c
+++ b/ext/dba/dba.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_cdb.c b/ext/dba/dba_cdb.c
index 61c1df5..525fa4a 100644
--- a/ext/dba/dba_cdb.c
+++ b/ext/dba/dba_cdb.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba_cdb.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba_cdb.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_db1.c b/ext/dba/dba_db1.c
index 202ef69..125dbc1 100755
--- a/ext/dba/dba_db1.c
+++ b/ext/dba/dba_db1.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba_db1.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba_db1.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_db2.c b/ext/dba/dba_db2.c
index 6b31111..9688deb 100644
--- a/ext/dba/dba_db2.c
+++ b/ext/dba/dba_db2.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba_db2.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba_db2.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_db3.c b/ext/dba/dba_db3.c
index 3b090ca..d1986ea 100644
--- a/ext/dba/dba_db3.c
+++ b/ext/dba/dba_db3.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba_db3.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba_db3.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c
index bdf9cdf..7e500e0 100644
--- a/ext/dba/dba_db4.c
+++ b/ext/dba/dba_db4.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba_db4.c 286636 2009-08-01 23:10:11Z felipe $ */
+/* $Id: dba_db4.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_dbm.c b/ext/dba/dba_dbm.c
index 9e32369..7019181 100644
--- a/ext/dba/dba_dbm.c
+++ b/ext/dba/dba_dbm.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba_dbm.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba_dbm.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_flatfile.c b/ext/dba/dba_flatfile.c
index 849ce3a..3bcfd58 100644
--- a/ext/dba/dba_flatfile.c
+++ b/ext/dba/dba_flatfile.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba_flatfile.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba_flatfile.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c
index d7a0c92..0e1d462 100644
--- a/ext/dba/dba_gdbm.c
+++ b/ext/dba/dba_gdbm.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba_gdbm.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba_gdbm.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_inifile.c b/ext/dba/dba_inifile.c
index 0cd2f28..f8e6188 100644
--- a/ext/dba/dba_inifile.c
+++ b/ext/dba/dba_inifile.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba_inifile.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba_inifile.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_ndbm.c b/ext/dba/dba_ndbm.c
index 3860039..a35965c 100644
--- a/ext/dba/dba_ndbm.c
+++ b/ext/dba/dba_ndbm.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba_ndbm.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba_ndbm.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/dba_qdbm.c b/ext/dba/dba_qdbm.c
index b3a9c35..8f67bc3 100755
--- a/ext/dba/dba_qdbm.c
+++ b/ext/dba/dba_qdbm.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: dba_qdbm.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dba_qdbm.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dba/libcdb/cdb.c b/ext/dba/libcdb/cdb.c
index 6d5f3aa..95c4df6 100644
--- a/ext/dba/libcdb/cdb.c
+++ b/ext/dba/libcdb/cdb.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: cdb.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: cdb.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
 
@@ -189,6 +189,6 @@ int cdb_find(struct cdb *c, char *key, unsigned int len TSRMLS_DC)
 /* {{{ cdb_version */
 char *cdb_version() 
 {
-	return "0.75, $Revision: 272370 $";
+	return "0.75, $Revision: 293036 $";
 }
 /* }}} */
diff --git a/ext/dba/libcdb/cdb.h b/ext/dba/libcdb/cdb.h
index 858e9a3..6d12761 100644
--- a/ext/dba/libcdb/cdb.h
+++ b/ext/dba/libcdb/cdb.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: cdb.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: cdb.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
 
diff --git a/ext/dba/libcdb/cdb_make.c b/ext/dba/libcdb/cdb_make.c
index 180d192..29f8b29 100644
--- a/ext/dba/libcdb/cdb_make.c
+++ b/ext/dba/libcdb/cdb_make.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: cdb_make.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: cdb_make.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
 
@@ -240,5 +240,5 @@ int cdb_make_finish(struct cdb_make *c TSRMLS_DC)
 /* {{{ cdb_make_version */
 char *cdb_make_version() 
 {
-	return "0.75, $Revision: 272370 $";
+	return "0.75, $Revision: 293036 $";
 }
diff --git a/ext/dba/libcdb/cdb_make.h b/ext/dba/libcdb/cdb_make.h
index a0fea70..492b098 100644
--- a/ext/dba/libcdb/cdb_make.h
+++ b/ext/dba/libcdb/cdb_make.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: cdb_make.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: cdb_make.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
 
diff --git a/ext/dba/libcdb/uint32.c b/ext/dba/libcdb/uint32.c
index 29df68c..f9e7d38 100644
--- a/ext/dba/libcdb/uint32.c
+++ b/ext/dba/libcdb/uint32.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: uint32.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: uint32.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
 
diff --git a/ext/dba/libcdb/uint32.h b/ext/dba/libcdb/uint32.h
index df31e4c..63bc382 100644
--- a/ext/dba/libcdb/uint32.h
+++ b/ext/dba/libcdb/uint32.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: uint32.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: uint32.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
 
diff --git a/ext/dba/libflatfile/flatfile.c b/ext/dba/libflatfile/flatfile.c
index 16216b4..a01ed63 100644
--- a/ext/dba/libflatfile/flatfile.c
+++ b/ext/dba/libflatfile/flatfile.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: flatfile.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: flatfile.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -307,7 +307,7 @@ datum flatfile_nextkey(flatfile *dba TSRMLS_DC) {
 /* {{{ flatfile_version */
 char *flatfile_version() 
 {
-	return "1.0, $Revision: 272370 $";
+	return "1.0, $Revision: 293036 $";
 }
 /* }}} */ 
 
diff --git a/ext/dba/libflatfile/flatfile.h b/ext/dba/libflatfile/flatfile.h
index 3de3587..4172c7b 100644
--- a/ext/dba/libflatfile/flatfile.h
+++ b/ext/dba/libflatfile/flatfile.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: flatfile.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: flatfile.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_LIB_FLATFILE_H
 #define PHP_LIB_FLATFILE_H
diff --git a/ext/dba/libinifile/inifile.c b/ext/dba/libinifile/inifile.c
index acc4792..5d492c8 100644
--- a/ext/dba/libinifile/inifile.c
+++ b/ext/dba/libinifile/inifile.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: inifile.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: inifile.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -43,7 +43,7 @@
 /* {{{ inifile_version */
 char *inifile_version() 
 {
-	return "1.0, $Revision: 272370 $";
+	return "1.0, $Revision: 293036 $";
 }
 /* }}} */ 
 
diff --git a/ext/dba/libinifile/inifile.h b/ext/dba/libinifile/inifile.h
index 81806f1..801bb27 100644
--- a/ext/dba/libinifile/inifile.h
+++ b/ext/dba/libinifile/inifile.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: inifile.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: inifile.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_LIB_INIFILE_H
 #define PHP_LIB_INIFILE_H
diff --git a/ext/dba/php_dba.h b/ext/dba/php_dba.h
index fccb2ee..4e6dccb 100644
--- a/ext/dba/php_dba.h
+++ b/ext/dba/php_dba.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_dba.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_dba.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_DBA_H
 #define PHP_DBA_H
diff --git a/ext/dba/tests/dba_cdb_make.phpt b/ext/dba/tests/dba_cdb_make.phpt
index b7311f1..6691d0a 100644
--- a/ext/dba/tests/dba_cdb_make.phpt
+++ b/ext/dba/tests/dba_cdb_make.phpt
@@ -33,7 +33,7 @@ magic_quotes_runtime=1
 	}
 ?>
 --EXPECT--
-PHP Warning:  Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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/attr.c b/ext/dom/attr.c
index f6f57af..fbec6dc 100644
--- a/ext/dom/attr.c
+++ b/ext/dom/attr.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: attr.c 277102 2009-03-13 13:43:29Z rrichards $ */
+/* $Id: attr.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/cdatasection.c b/ext/dom/cdatasection.c
index f57e3c4..142b35b 100644
--- a/ext/dom/cdatasection.c
+++ b/ext/dom/cdatasection.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: cdatasection.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: cdatasection.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/characterdata.c b/ext/dom/characterdata.c
index 9af73a1..cc79760 100644
--- a/ext/dom/characterdata.c
+++ b/ext/dom/characterdata.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: characterdata.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: characterdata.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/comment.c b/ext/dom/comment.c
index c3888a8..18badf3 100644
--- a/ext/dom/comment.c
+++ b/ext/dom/comment.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: comment.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: comment.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/document.c b/ext/dom/document.c
index 9fc6290..4728e66 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: document.c 282119 2009-06-14 13:13:35Z iliaa $ */
+/* $Id: document.c 294436 2010-02-03 18:41:27Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1203,7 +1203,18 @@ PHP_FUNCTION(dom_document_import_node)
 		if (!retnodep) {
 			RETURN_FALSE;
 		}
-		
+
+		if ((retnodep->type == XML_ATTRIBUTE_NODE) && (nodep->ns != NULL)) {
+			xmlNsPtr nsptr = NULL;
+			xmlNodePtr root = xmlDocGetRootElement(docp);
+
+			nsptr = xmlSearchNsByHref (nodep->doc, root, nodep->ns->href);
+			if (nsptr == NULL) {
+				int errorcode;
+				nsptr = dom_get_ns(root, nodep->ns->href, &errorcode, nodep->ns->prefix);
+			}
+			xmlSetNs(retnodep, nsptr);
+		}
 	}
 
 	DOM_RET_OBJ(rv, (xmlNodePtr) retnodep, &ret, intern);
@@ -1531,7 +1542,7 @@ char *_dom_get_valid_file_path(char *source, char *resolved_path, int resolved_p
 }
 /* }}} */
 
-static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int options TSRMLS_DC) /* {{{ */
+static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int source_len, int options TSRMLS_DC) /* {{{ */
 {
     xmlDocPtr ret;
     xmlParserCtxtPtr ctxt = NULL;
@@ -1568,7 +1579,7 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int optio
 		}
 		
 	} else {
-		ctxt = xmlCreateDocParserCtxt(source);
+		ctxt = xmlCreateMemoryParserCtxt(source, source_len);
 	}
 
 	if (ctxt == NULL) {
@@ -1671,7 +1682,7 @@ static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) {
 		RETURN_FALSE;
 	}
 
-	newdoc = dom_document_parser(id, mode, source, options TSRMLS_CC);
+	newdoc = dom_document_parser(id, mode, source, source_len, options TSRMLS_CC);
 
 	if (!newdoc)
 		RETURN_FALSE;
diff --git a/ext/dom/documentfragment.c b/ext/dom/documentfragment.c
index c1b3b64..e3769bd 100644
--- a/ext/dom/documentfragment.c
+++ b/ext/dom/documentfragment.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: documentfragment.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: documentfragment.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c
index fcb938f..08be3fc 100644
--- a/ext/dom/documenttype.c
+++ b/ext/dom/documenttype.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: documenttype.c 289439 2009-10-09 18:52:59Z pajoye $ */
+/* $Id: documenttype.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/dom_ce.h b/ext/dom/dom_ce.h
index d14b310..196286b 100644
--- a/ext/dom/dom_ce.h
+++ b/ext/dom/dom_ce.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: dom_ce.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dom_ce.h 293036 2010-01-03 09:23:27Z sebastian $ */
 #ifndef DOM_CE_H
 #define DOM_CE_H
 
diff --git a/ext/dom/dom_fe.h b/ext/dom/dom_fe.h
index 3a052f2..ed87cd0 100644
--- a/ext/dom/dom_fe.h
+++ b/ext/dom/dom_fe.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: dom_fe.h 273468 2009-01-13 18:06:48Z rrichards $ */
+/* $Id: dom_fe.h 293036 2010-01-03 09:23:27Z sebastian $ */
 #ifndef DOM_FE_H
 #define DOM_FE_H
 
diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c
index e76b4ac..b91f2a0 100644
--- a/ext/dom/dom_iterators.c
+++ b/ext/dom/dom_iterators.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: dom_iterators.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dom_iterators.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/dom_properties.h b/ext/dom/dom_properties.h
index 6fd1bcc..4179985 100644
--- a/ext/dom/dom_properties.h
+++ b/ext/dom/dom_properties.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: dom_properties.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: dom_properties.h 293036 2010-01-03 09:23:27Z sebastian $ */
 #ifndef DOM_PROPERTIES_H
 #define DOM_PROPERTIES_H
 
diff --git a/ext/dom/domconfiguration.c b/ext/dom/domconfiguration.c
index 5ae0421..62f353d 100644
--- a/ext/dom/domconfiguration.c
+++ b/ext/dom/domconfiguration.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: domconfiguration.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: domconfiguration.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/domerror.c b/ext/dom/domerror.c
index 330d4af..4c846f0 100644
--- a/ext/dom/domerror.c
+++ b/ext/dom/domerror.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: domerror.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: domerror.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/domerrorhandler.c b/ext/dom/domerrorhandler.c
index a161428..2091776 100644
--- a/ext/dom/domerrorhandler.c
+++ b/ext/dom/domerrorhandler.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: domerrorhandler.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: domerrorhandler.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/domexception.c b/ext/dom/domexception.c
index 9301c11..cfb2a76 100644
--- a/ext/dom/domexception.c
+++ b/ext/dom/domexception.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: domexception.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: domexception.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/domimplementation.c b/ext/dom/domimplementation.c
index 6ec0e65..29a808b 100644
--- a/ext/dom/domimplementation.c
+++ b/ext/dom/domimplementation.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: domimplementation.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: domimplementation.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/domimplementationlist.c b/ext/dom/domimplementationlist.c
index 144e58a..c25b81a 100644
--- a/ext/dom/domimplementationlist.c
+++ b/ext/dom/domimplementationlist.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: domimplementationlist.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: domimplementationlist.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/domimplementationsource.c b/ext/dom/domimplementationsource.c
index 66248e3..5ade26b 100644
--- a/ext/dom/domimplementationsource.c
+++ b/ext/dom/domimplementationsource.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: domimplementationsource.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: domimplementationsource.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/domlocator.c b/ext/dom/domlocator.c
index f40d47d..5629e15 100644
--- a/ext/dom/domlocator.c
+++ b/ext/dom/domlocator.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: domlocator.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: domlocator.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/domstringlist.c b/ext/dom/domstringlist.c
index d2d7879..c618135 100644
--- a/ext/dom/domstringlist.c
+++ b/ext/dom/domstringlist.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: domstringlist.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: domstringlist.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/element.c b/ext/dom/element.c
index 69d780f..d0b7cd4 100644
--- a/ext/dom/element.c
+++ b/ext/dom/element.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: element.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: element.c 294446 2010-02-03 20:04:38Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -777,9 +777,15 @@ PHP_FUNCTION(dom_element_set_attribute_ns)
 				node_list_unlink(nodep->children TSRMLS_CC);
 			}
 
-			if (xmlStrEqual((xmlChar *) prefix, (xmlChar *)"xmlns") && xmlStrEqual((xmlChar *) uri, (xmlChar *)DOM_XMLNS_NAMESPACE)) {
+			if ((xmlStrEqual((xmlChar *) prefix, (xmlChar *)"xmlns") || 
+				(prefix == NULL && xmlStrEqual((xmlChar *) localname, (xmlChar *)"xmlns"))) && 
+				xmlStrEqual((xmlChar *) uri, (xmlChar *)DOM_XMLNS_NAMESPACE)) {
 				is_xmlns = 1;
-				nsptr = dom_get_nsdecl(elemp, (xmlChar *)localname);
+				if (prefix == NULL) {
+					nsptr = dom_get_nsdecl(elemp, NULL);
+				} else {
+					nsptr = dom_get_nsdecl(elemp, (xmlChar *)localname);
+				}
 			} else {
 				nsptr = xmlSearchNsByHref(elemp->doc, elemp, (xmlChar *)uri);
 				if (nsptr && nsptr->prefix == NULL) {
@@ -802,7 +808,12 @@ PHP_FUNCTION(dom_element_set_attribute_ns)
 
 			if (nsptr == NULL) {
 				if (prefix == NULL) {
-					errorcode = NAMESPACE_ERR;
+					if (is_xmlns == 1) {
+						xmlNewNs(elemp, (xmlChar *)value, NULL);
+						xmlReconciliateNs(elemp->doc, elemp);
+					} else {
+						errorcode = NAMESPACE_ERR;
+					}
 				} else {
 					if (is_xmlns == 1) {
 						xmlNewNs(elemp, (xmlChar *)value, (xmlChar *)localname);
diff --git a/ext/dom/entity.c b/ext/dom/entity.c
index 7caaab0..d28e131 100644
--- a/ext/dom/entity.c
+++ b/ext/dom/entity.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: entity.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: entity.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/entityreference.c b/ext/dom/entityreference.c
index 762fc3f..8b0164a 100644
--- a/ext/dom/entityreference.c
+++ b/ext/dom/entityreference.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: entityreference.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: entityreference.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/namednodemap.c b/ext/dom/namednodemap.c
index 2ea88f6..1228062 100644
--- a/ext/dom/namednodemap.c
+++ b/ext/dom/namednodemap.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: namednodemap.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: namednodemap.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/namelist.c b/ext/dom/namelist.c
index 116165e..6ed0f6f 100644
--- a/ext/dom/namelist.c
+++ b/ext/dom/namelist.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: namelist.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: namelist.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/node.c b/ext/dom/node.c
index 923757d..dc6309a 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: node.c 277102 2009-03-13 13:43:29Z rrichards $ */
+/* $Id: node.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1730,7 +1730,7 @@ PHP_FUNCTION(dom_node_get_feature)
 }
 /* }}} end dom_node_get_feature */
 
-/* {{{ proto DomUserData dom_node_set_user_data(string key, DomUserData data, userdatahandler handler);
+/* {{{ proto mixed dom_node_set_user_data(string key, mixed data, userdatahandler handler);
 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-setUserData
 Since: DOM Level 3
 */
@@ -1740,7 +1740,7 @@ PHP_FUNCTION(dom_node_set_user_data)
 }
 /* }}} end dom_node_set_user_data */
 
-/* {{{ proto DomUserData dom_node_get_user_data(string key);
+/* {{{ proto mixed dom_node_get_user_data(string key);
 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-getUserData
 Since: DOM Level 3
 */
diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c
index 923db96..0392d83 100644
--- a/ext/dom/nodelist.c
+++ b/ext/dom/nodelist.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: nodelist.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: nodelist.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/notation.c b/ext/dom/notation.c
index 4817177..75e0310 100644
--- a/ext/dom/notation.c
+++ b/ext/dom/notation.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: notation.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: notation.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 214139c..73c7110 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_dom.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_dom.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h
index 1e43aa0..6724bde 100644
--- a/ext/dom/php_dom.h
+++ b/ext/dom/php_dom.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_dom.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_dom.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_DOM_H
 #define PHP_DOM_H
diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c
index 8e6d676..ac83d8c 100644
--- a/ext/dom/processinginstruction.c
+++ b/ext/dom/processinginstruction.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: processinginstruction.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: processinginstruction.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/string_extend.c b/ext/dom/string_extend.c
index 8b791df..fc09e30 100644
--- a/ext/dom/string_extend.c
+++ b/ext/dom/string_extend.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: string_extend.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: string_extend.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/tests/DOMAttr_value_basic_001.phpt b/ext/dom/tests/DOMAttr_value_basic_001.phpt
index 2a2b521..40e00bc 100755
--- a/ext/dom/tests/DOMAttr_value_basic_001.phpt
+++ b/ext/dom/tests/DOMAttr_value_basic_001.phpt
@@ -3,9 +3,14 @@ Read empty $value.
 --CREDIT--
 Jason Bouffard <jbouffard1 at yahoo.com>
 # TestFest Atlanta 2009-05-14
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
 $attr = new DOMAttr('category');
 print $attr->value."\n";
 ?>
+===DONE===
 --EXPECTF--
+===DONE===
+	
\ No newline at end of file
diff --git a/ext/dom/tests/DOMCharacterData_length_error_001.phpt b/ext/dom/tests/DOMCharacterData_length_error_001.phpt
index 87c9377..0dda492 100755
--- a/ext/dom/tests/DOMCharacterData_length_error_001.phpt
+++ b/ext/dom/tests/DOMCharacterData_length_error_001.phpt
@@ -3,10 +3,15 @@ Invalid State Error when getting length on DOMCharacterData out of content.
 --CREDIT--
 Jason Bouffard <jbouffard1 at yahoo.com>
 # TestFest Atlanta 2009-05-14
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
 $character_data = new DOMCharacterData();
 print $character_data->length;
 ?>
+===DONE===
 --EXPECTF--
-Warning: main(): Invalid State Error in %s
\ No newline at end of file
+Warning: main(): Invalid State Error in %s
+===DONE===
+	
\ No newline at end of file
diff --git a/ext/dom/tests/DOMText_appendData_basic.phpt b/ext/dom/tests/DOMText_appendData_basic.phpt
index 6a28a9a..0eea699 100644
--- a/ext/dom/tests/DOMText_appendData_basic.phpt
+++ b/ext/dom/tests/DOMText_appendData_basic.phpt
@@ -3,6 +3,8 @@ DOMText::appendData basic functionality test
 --CREDITS--
 Mike Sullivan <mike at regexia.com>
 #TestFest 2008 (London)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
 
@@ -26,10 +28,13 @@ echo "Text Content: " . $textnode->data . "\n";
 echo "\n" . $document->saveXML();
 
 ?>
+===DONE===
 --EXPECT--
 Text Length (one append): 4
 Text Length (two appends): 8
 Text Content: data><&"
 
 <?xml version="1.0"?>
-<root><text>data><&"</text></root>
\ No newline at end of file
+<root><text>data><&"</text></root>
+===DONE===
+	
\ No newline at end of file
diff --git a/ext/dom/tests/bug42082.phpt b/ext/dom/tests/bug42082.phpt
index 86f32dd..ab018a7 100644
--- a/ext/dom/tests/bug42082.phpt
+++ b/ext/dom/tests/bug42082.phpt
@@ -1,5 +1,7 @@
 --TEST--
 Bug #42082 (NodeList length zero should be empty)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
 $doc = new DOMDocument();
@@ -14,6 +16,7 @@ $doc->loadXML("<element></element>");
 var_dump($doc->firstChild->nodeValue, empty($doc->firstChild->nodeValue), isset($doc->firstChild->nodeValue));
 var_dump(empty($doc->nodeType), empty($doc->firstChild->nodeType))
 ?>
+===DONE===
 --EXPECTF--
 object(DOMNodeList)#%d (0) {
 }
@@ -24,4 +27,6 @@ string(0) ""
 bool(true)
 bool(true)
 bool(false)
-bool(false) 
\ No newline at end of file
+bool(false)
+===DONE===
+	
\ No newline at end of file
diff --git a/ext/dom/tests/bug47848.phpt b/ext/dom/tests/bug47848.phpt
new file mode 100644
index 0000000..b4453c7
--- /dev/null
+++ b/ext/dom/tests/bug47848.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #47848 (importNode doesn't preserve attribute namespaces)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php 
+
+$aDOM = new DOMDocument();
+$aDOM->appendChild($aDOM->createElementNS('http://friend2friend.net/','f2f:a'));
+
+$fromdom = new DOMDocument();
+$fromdom->loadXML('<data xmlns:ai="http://altruists.org" ai:attr="namespaced" />');
+
+$attr= $fromdom->firstChild->attributes->item(0);
+
+$att = $aDOM->importNode($attr);
+
+$aDOM->documentElement->appendChild($aDOM->importNode($attr, true));
+
+echo $aDOM->saveXML();
+
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<f2f:a xmlns:f2f="http://friend2friend.net/" xmlns:ai="http://altruists.org" ai:attr="namespaced"/>
\ No newline at end of file
diff --git a/ext/dom/tests/bug49463.phpt b/ext/dom/tests/bug49463.phpt
new file mode 100644
index 0000000..4f232e3
--- /dev/null
+++ b/ext/dom/tests/bug49463.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #49463 (setAttributeNS fails setting default namespace).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument('1.0', 'utf-8');
+$root = $doc->createElementNS('http://purl.org/rss/1.0/','rdf:RDF');
+$doc->appendChild($root);
+$root->setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns","http://purl.org/rss/1.0/" );
+
+echo $doc->saveXML()."\n";
+?>
+--EXPECT--
+<?xml version="1.0" encoding="utf-8"?>
+<rdf:RDF xmlns:rdf="http://purl.org/rss/1.0/" xmlns="http://purl.org/rss/1.0/"/>
diff --git a/ext/dom/tests/bug50661.phpt b/ext/dom/tests/bug50661.phpt
new file mode 100644
index 0000000..3760db9
--- /dev/null
+++ b/ext/dom/tests/bug50661.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #50661 (DOMDocument::loadXML does not allow UTF-16).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$data = "\xFE\xFF\x00\x3C\x00\x66\x00\x6F\x00\x6F\x00\x2F\x00\x3E";
+
+$dom = new DOMDocument();
+$dom->loadXML($data);
+echo $dom->saveXML();
+
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<foo/>
diff --git a/ext/dom/tests/domdocument_createcomment_error_001.phpt b/ext/dom/tests/domdocument_createcomment_error_001.phpt
index 5df4e20..24104a1 100644
--- a/ext/dom/tests/domdocument_createcomment_error_001.phpt
+++ b/ext/dom/tests/domdocument_createcomment_error_001.phpt
@@ -2,10 +2,15 @@
 DomDocument::CreateComment() - Incorrect Parameters
 --CREDITS--
 Clint Priest @ PhpTek09
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
 	$x = new DomDocument();
 	$x->createComment();
 ?>
+===DONE===
 --EXPECTF--
-Warning: DOMDocument::createComment() expects exactly 1 parameter, 0 given in %s
\ No newline at end of file
+Warning: DOMDocument::createComment() expects exactly 1 parameter, 0 given in %s
+===DONE===
+	
\ No newline at end of file
diff --git a/ext/dom/tests/domdocument_createentityreference_001.phpt b/ext/dom/tests/domdocument_createentityreference_001.phpt
index 15f7df1..7343e74 100644
--- a/ext/dom/tests/domdocument_createentityreference_001.phpt
+++ b/ext/dom/tests/domdocument_createentityreference_001.phpt
@@ -2,12 +2,17 @@
 DomDocument::CreateEntityReference() - Creates an entity reference with the appropriate name
 --CREDITS--
 Clint Priest @ PhpTek09
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
 	$objDoc = new DomDocument();
 	
 	$objRef = $objDoc->createEntityReference('Test');
-	echo $objRef->nodeName;
+	echo $objRef->nodeName . "\n";
 ?>
+===DONE===
 --EXPECT--
-Test
\ No newline at end of file
+Test
+===DONE===
+	
\ No newline at end of file
diff --git a/ext/dom/tests/domdocument_createentityreference_002.phpt b/ext/dom/tests/domdocument_createentityreference_002.phpt
index 21d79aa..a2416c2 100644
--- a/ext/dom/tests/domdocument_createentityreference_002.phpt
+++ b/ext/dom/tests/domdocument_createentityreference_002.phpt
@@ -2,11 +2,16 @@
 DomDocument::CreateEntityReference() - Empty Arguments
 --CREDITS--
 Clint Priest @ PhpTek09
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
 	$objDoc = new DomDocument();
 	
 	$objRef = $objDoc->createEntityReference();
 ?>
+===DONE===
 --EXPECTF--
-Warning: DOMDocument::createEntityReference() expects exactly 1 parameter, 0 given in %s
\ No newline at end of file
+Warning: DOMDocument::createEntityReference() expects exactly 1 parameter, 0 given in %s
+===DONE===
+	
\ No newline at end of file
diff --git a/ext/dom/text.c b/ext/dom/text.c
index c658e1b..2e5b237 100644
--- a/ext/dom/text.c
+++ b/ext/dom/text.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: text.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: text.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/typeinfo.c b/ext/dom/typeinfo.c
index 7c42f90..95521e8 100644
--- a/ext/dom/typeinfo.c
+++ b/ext/dom/typeinfo.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: typeinfo.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: typeinfo.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/userdatahandler.c b/ext/dom/userdatahandler.c
index 2b761d7..2ee47ea 100644
--- a/ext/dom/userdatahandler.c
+++ b/ext/dom/userdatahandler.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: userdatahandler.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: userdatahandler.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/dom/xml_common.h b/ext/dom/xml_common.h
index 9c3c6fc..16d1928 100644
--- a/ext/dom/xml_common.h
+++ b/ext/dom/xml_common.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: xml_common.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: xml_common.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_XML_COMMON_H
 #define PHP_XML_COMMON_H
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c
index a2fdc13..209b213 100644
--- a/ext/dom/xpath.c
+++ b/ext/dom/xpath.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: xpath.c 281742 2009-06-06 02:40:49Z mattwil $ */
+/* $Id: xpath.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/enchant/config.m4 b/ext/enchant/config.m4
index 8a36ee8..8e2fc5b 100755
--- a/ext/enchant/config.m4
+++ b/ext/enchant/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 289597 2009-10-12 22:35:36Z pajoye $
+dnl $Id: config.m4 289366 2009-10-08 20:28:21Z pajoye $
 dnl
 
 PHP_ARG_WITH(enchant,for ENCHANT support,
diff --git a/ext/enchant/config.w32 b/ext/enchant/config.w32
index f36b7c8..011688d 100644
--- a/ext/enchant/config.w32
+++ b/ext/enchant/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32 289597 2009-10-12 22:35:36Z pajoye $
+// $Id: config.w32 289372 2009-10-08 20:59:50Z pajoye $
 // vim:ft=javascript
 
 ARG_WITH("enchant", "Enchant Support", "no");
diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c
index 1a003aa..87c16e2 100755
--- a/ext/enchant/enchant.c
+++ b/ext/enchant/enchant.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | Copyright (c) 1997-2010 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.0 of the PHP license,       |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
   |         Ilia Alshanetsky <ilia at prohost.org>                          |
   +----------------------------------------------------------------------+
 
-  $Id: enchant.c 289597 2009-10-12 22:35:36Z pajoye $
+  $Id: enchant.c 293036 2010-01-03 09:23:27Z sebastian $
 */
 
 #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: 289597 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 293036 $");
 	php_info_print_table_end();
 
 	php_info_print_table_start();
diff --git a/ext/enchant/php_enchant.h b/ext/enchant/php_enchant.h
index 0f27db9..50cfdc7 100644
--- a/ext/enchant/php_enchant.h
+++ b/ext/enchant/php_enchant.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 4                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | Copyright (c) 1997-2010 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.0 of the PHP license,       |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -15,7 +15,7 @@
   | Author: Pierre-Alain Joye <paj at pearfr.org>                           |
   +----------------------------------------------------------------------+
 
-  $Id: php_enchant.h 289597 2009-10-12 22:35:36Z pajoye $
+  $Id: php_enchant.h 293036 2010-01-03 09:23:27Z sebastian $
 */
 
 #ifndef PHP_ENCHANT_H
diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c
index 7298626..d433ebb 100644
--- a/ext/ereg/ereg.c
+++ b/ext/ereg/ereg.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    |          Jaakko Hyvätti <jaakko at hyvatti.iki.fi>                      | 
    +----------------------------------------------------------------------+
  */
-/* $Id: ereg.c 281350 2009-05-28 21:57:24Z scottmac $ */
+/* $Id: ereg.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdio.h>
 #include <ctype.h>
diff --git a/ext/ereg/php_ereg.h b/ext/ereg/php_ereg.h
index 28fd54d..7c1d1a0 100644
--- a/ext/ereg/php_ereg.h
+++ b/ext/ereg/php_ereg.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
 */
 
 
-/* $Id: php_ereg.h 281350 2009-05-28 21:57:24Z scottmac $ */
+/* $Id: php_ereg.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef EREG_H
 #define EREG_H
diff --git a/ext/ereg/php_regex.h b/ext/ereg/php_regex.h
index 2ff44a5..7689540 100644
--- a/ext/ereg/php_regex.h
+++ b/ext/ereg/php_regex.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_regex.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_regex.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_REGEX_H
 #define PHP_REGEX_H
diff --git a/ext/exif/exif.c b/ext/exif/exif.c
index f03c3c1..85fa1b9 100644
--- a/ext/exif/exif.c
+++ b/ext/exif/exif.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: exif.c 287372 2009-08-16 14:32:32Z iliaa $ */
+/* $Id: exif.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*  ToDos
  *
@@ -138,7 +138,7 @@ const zend_function_entry exif_functions[] = {
 };
 /* }}} */
 
-#define EXIF_VERSION "1.4 $Id: exif.c 287372 2009-08-16 14:32:32Z iliaa $"
+#define EXIF_VERSION "1.4 $Id: exif.c 293036 2010-01-03 09:23:27Z sebastian $"
 
 /* {{{ PHP_MINFO_FUNCTION
  */
@@ -3876,11 +3876,7 @@ static int exif_read_file(image_info_type *ImageInfo, char *FileName, int read_t
 			}
 
 			/* Store file date/time. */
-#ifdef NETWARE
-			ImageInfo->FileDateTime = st.st_mtime.tv_sec;
-#else
 			ImageInfo->FileDateTime = st.st_mtime;
-#endif
 			ImageInfo->FileSize = st.st_size;
 			/*exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Opened stream is file: %d", ImageInfo->FileSize);*/
 		}
diff --git a/ext/exif/php_exif.h b/ext/exif/php_exif.h
index 105490e..2b1b77e 100644
--- a/ext/exif/php_exif.h
+++ b/ext/exif/php_exif.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_exif.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_exif.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #if HAVE_EXIF
 extern zend_module_entry exif_module_entry;
diff --git a/ext/exif/tests/exif006.phpt b/ext/exif/tests/exif006.phpt
index 256a9eb..cbd7191 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--
-PHP Warning:  Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch
index 1427d87..dc8e03f 100644
--- a/ext/fileinfo/libmagic.patch
+++ b/ext/fileinfo/libmagic.patch
@@ -1,127 +1,3030 @@
-Index: libmagic/apprentice.c
-===================================================================
-RCS file: /repository/pecl/fileinfo/libmagic/apprentice.c,v
-retrieving revision 1.1
-diff -u -r1.1 apprentice.c
---- libmagic/apprentice.c	11 Jul 2008 14:13:50 -0000	1.1
-+++ libmagic/apprentice.c	25 Jul 2008 08:18:07 -0000
-@@ -157,6 +157,10 @@
- }
- #endif /* COMPILE_ONLY */
- 
-+#ifdef PHP_BUNDLE
-+#include "../data_file.c"
+diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
+--- libmagic.orig/apprentice.c	2009-03-18 15:19:23.000000000 +0000
++++ libmagic/apprentice.c	2010-01-28 11:02:24.000000000 +0000
+@@ -29,6 +29,8 @@
+  * apprentice - make one pass through /etc/magic, learning its secrets.
+  */
+ 
++#include "php.h"
++
+ #include "file.h"
+ 
+ #ifndef	lint
+@@ -38,17 +40,24 @@
+ #include "magic.h"
+ #include "patchlevel.h"
+ #include <stdlib.h>
+-#ifdef HAVE_UNISTD_H
++
++#ifdef PHP_WIN32
++#include "win32/unistd.h"
++#if _MSC_VER <= 1300
++# include "win32/php_strtoi64.h"
 +#endif
++#define strtoull _strtoui64
++#else
+ #include <unistd.h>
+ #endif
 +
+ #include <string.h>
+ #include <assert.h>
+ #include <ctype.h>
+ #include <fcntl.h>
+-#ifdef QUICK
+-#include <sys/mman.h>
+-#endif
++#ifndef PHP_WIN32
+ #include <dirent.h>
++#endif
+ 
+ #define	EATAB {while (isascii((unsigned char) *l) && \
+ 		      isspace((unsigned char) *l))  ++l;}
+@@ -116,12 +125,10 @@
+ private int parse_strength(struct magic_set *, struct magic_entry *, const char *);
+ private int parse_apple(struct magic_set *, struct magic_entry *, const char *);
+ 
+-
+ private size_t maxmagic = 0;
+ private size_t magicsize = sizeof(struct magic);
+ 
+ private const char usg_hdr[] = "cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
+-
+ private struct {
+ 	const char *name;
+ 	size_t len;
+@@ -135,38 +142,7 @@
+ 	{ NULL, 0, NULL }
+ };
+ 
+-#ifdef COMPILE_ONLY
+-
+-int main(int, char *[]);
+-
+-int
+-main(int argc, char *argv[])
+-{
+-	int ret;
+-	struct magic_set *ms;
+-	char *progname;
+-
+-	if ((progname = strrchr(argv[0], '/')) != NULL)
+-		progname++;
+-	else
+-		progname = argv[0];
+-
+-	if (argc != 2) {
+-		(void)fprintf(stderr, "Usage: %s file\n", progname);
+-		return 1;
+-	}
+-
+-	if ((ms = magic_open(MAGIC_CHECK)) == NULL) {
+-		(void)fprintf(stderr, "%s: %s\n", progname, strerror(errno));
+-		return 1;
+-	}
+-	ret = magic_compile(ms, argv[1]) == -1 ? 1 : 0;
+-	if (ret == 1)
+-		(void)fprintf(stderr, "%s: %s\n", progname, magic_error(ms));
+-	magic_close(ms);
+-	return ret;
+-}
+-#endif /* COMPILE_ONLY */
++#include "../data_file.c"
+ 
  static const struct type_tbl_s {
  	const char name[16];
- 	const size_t len;
-@@ -310,6 +314,11 @@
+@@ -222,6 +198,10 @@
+ # undef XX_NULL
+ };
+ 
++#ifndef S_ISDIR
++#define S_ISDIR(mode) ((mode) & _S_IFDIR)
++#endif
++
+ private int
+ get_type(const char *l, const char **t)
+ {
+@@ -279,15 +259,17 @@
+ 		if (rv != 0)
+ 			return -1;
+ 		rv = apprentice_compile(ms, &magic, &nmagic, fn);
+-		free(magic);
++		efree(magic);
+ 		return rv;
+ 	}
+ 
+-#ifndef COMPILE_ONLY
+ 	if ((rv = apprentice_map(ms, &magic, &nmagic, fn)) == -1) {
+-		if (ms->flags & MAGIC_CHECK)
+-			file_magwarn(ms, "using regular magic file `%s'", fn);
+-		rv = apprentice_load(ms, &magic, &nmagic, fn, action);
++		if (fn) {
++			if (ms->flags & MAGIC_CHECK)
++				file_magwarn(ms, "using regular magic file `%s'", fn);
++			rv = apprentice_load(ms, &magic, &nmagic, fn, action);
++		}
++
+ 		if (rv != 0)
+ 			return -1;
+ 	}
+@@ -299,11 +281,7 @@
+ 		return -1;
+ 	}
+ 
+-	if ((ml = CAST(struct mlist *, malloc(sizeof(*ml)))) == NULL) {
+-		file_delmagic(magic, mapped, nmagic);
+-		file_oomem(ms, sizeof(*ml));
+-		return -1;
+-	}
++	ml = emalloc(sizeof(*ml));
+ 
+ 	ml->magic = magic;
+ 	ml->nmagic = nmagic;
+@@ -315,7 +293,6 @@
+ 	mlist->prev = ml;
+ 
+ 	return 0;
+-#endif /* COMPILE_ONLY */
+ }
+ 
+ protected void
+@@ -324,22 +301,18 @@
  	if (p == NULL)
  		return;
  	switch (type) {
-+#ifdef PHP_BUNDLE
+-	case 2:
+-#ifdef QUICK
+-		p--;
+-		(void)munmap((void *)p, sizeof(*p) * (entries + 1));
 +	case 3:
 +		/* Do nothing, it's part of the code segment */
-+		break;
-+#endif
- #ifdef QUICK
- 	case 2:
+ 		break;
+-#else
+-		(void)&entries;
+-		abort();
+-		/*NOTREACHED*/
+-#endif
++
+ 	case 1:
  		p--;
-@@ -339,8 +348,19 @@
+ 		/*FALLTHROUGH*/
++
+ 	case 0:
+-		free(p);
++		efree(p);
+ 		break;
++
+ 	default:
+ 		abort();
+ 	}
+@@ -357,20 +330,17 @@
  
  	if (fn == NULL)
  		fn = getenv("MAGIC");
 -	if (fn == NULL)
+-		fn = MAGIC;
+-
+-	if ((mfn = strdup(fn)) == NULL) {
+-		file_oomem(ms, strlen(fn));
+-		return NULL;
 +	if (fn == NULL) {
-+#ifdef PHP_BUNDLE
-+		if ((mlist = malloc(sizeof(*mlist))) == NULL) {
-+			file_oomem(ms, sizeof(*mlist));
-+			return NULL;
-+		}
++		mlist = emalloc(sizeof(*mlist));
 +		mlist->next = mlist->prev = mlist;
 +		apprentice_1(ms, fn, action, mlist);
 +		return mlist;
+ 	}
++
++	mfn = estrdup(fn);
+ 	fn = mfn;
+ 
+-	if ((mlist = CAST(struct mlist *, malloc(sizeof(*mlist)))) == NULL) {
+-		free(mfn);
+-		file_oomem(ms, sizeof(*mlist));
+-		return NULL;
+-	}
++	mlist = emalloc(sizeof(*mlist));
+ 	mlist->next = mlist->prev = mlist;
+ 
+ 	while (fn) {
+@@ -384,13 +354,13 @@
+ 		fn = p;
+ 	}
+ 	if (errs == -1) {
+-		free(mfn);
+-		free(mlist);
++		efree(mfn);
++		efree(mlist);
+ 		mlist = NULL;
+ 		file_error(ms, 0, "could not find any magic files!");
+ 		return NULL;
+ 	}
+-	free(mfn);
++	efree(mfn);
+ 	return mlist;
+ }
+ 
+@@ -523,6 +493,7 @@
+ 		abort();
+ 	}
+ 
++
+ 	/*
+ 	 * Magic entries with no description get a bonus because they depend
+ 	 * on subsequent magic entries to print something.
+@@ -538,8 +509,8 @@
+ private int
+ apprentice_sort(const void *a, const void *b)
+ {
+-	const struct magic_entry *ma = CAST(const struct magic_entry *, a);
+-	const struct magic_entry *mb = CAST(const struct magic_entry *, b);
++	const struct magic_entry *ma = a;
++	const struct magic_entry *mb = b;
+ 	size_t sa = apprentice_magic_strength(ma->mp);
+ 	size_t sb = apprentice_magic_strength(mb->mp);
+ 	if (sa == sb)
+@@ -617,34 +588,51 @@
+ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
+    struct magic_entry **marray, uint32_t *marraycount)
+ {
+-	char line[BUFSIZ];
++	char buffer[BUFSIZ + 1];
++	char *line;
++	size_t line_len;
+ 	size_t lineno = 0;
+-	FILE *f = fopen(ms->file = fn, "r");
+-	if (f == NULL) {
++
++	php_stream *stream;
++
++	TSRMLS_FETCH();
++
++#if (PHP_MAJOR_VERSION < 6)
++	stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
 +#else
- 		fn = MAGIC;
++	stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS, NULL);
 +#endif
-+	}
++
++	if (stream == NULL) {
+ 		if (errno != ENOENT)
+ 			file_error(ms, errno, "cannot read magic file `%s'",
+ 				   fn);
+ 		(*errs)++;
+ 	} else {
++
+ 		/* read and parse this file */
+-		for (ms->line = 1; fgets(line, sizeof(line), f) != NULL; ms->line++) {
+-			size_t len;
+-			len = strlen(line);
+-			if (len == 0) /* null line, garbage, etc */
++#if (PHP_MAJOR_VERSION < 6)
++		for (ms->line = 1; (line = php_stream_get_line(stream, buffer , BUFSIZ, &line_len)) != NULL; ms->line++) {
++#else		
++		for (ms->line = 1; (line = php_stream_get_line(stream, ZSTR(buffer), BUFSIZ, &line_len)) != NULL; ms->line++) {
++#endif
++			if (line_len == 0) /* null line, garbage, etc */
+ 				continue;
+-			if (line[len - 1] == '\n') {
++
++			if (line[line_len - 1] == '\n') {
+ 				lineno++;
+-				line[len - 1] = '\0'; /* delete newline */
++				line[line_len - 1] = '\0'; /* delete newline */
+ 			}
+ 			if (line[0] == '\0')	/* empty, do not parse */
+ 				continue;
+ 			if (line[0] == '#')	/* comment, do not parse */
+ 				continue;
++
+ 			if (line[0] == '!' && line[1] == ':') {
+ 				size_t i;
+ 
+ 				for (i = 0; bang[i].name != NULL; i++) {
+-					if (len - 2 > bang[i].len &&
++					if (line_len - 2 > bang[i].len &&
+ 					    memcmp(bang[i].name, line + 2,
+ 					    bang[i].len) == 0)
+ 						break;
+@@ -670,12 +658,11 @@
+ 				}
+ 				continue;
+ 			}
+-			if (parse(ms, marray, marraycount, line, lineno,
+-			    action) != 0)
++			if (parse(ms, marray, marraycount, line, lineno, action) != 0)
+ 				(*errs)++;
+ 		}
  
- 	if ((mfn = strdup(fn)) == NULL) {
- 		file_oomem(ms, strlen(fn));
-@@ -1886,6 +1906,15 @@
+-		(void)fclose(f);
++		php_stream_close(stream);
+ 	}
+ }
+ 
+@@ -690,7 +677,6 @@
+ 	int errs = 0;
+ 	struct magic_entry *marray;
+ 	uint32_t marraycount, i, mentrycount = 0, starttest;
+-	size_t slen;
+ 	char subfn[MAXPATHLEN];
+ 	struct stat st;
+ 	DIR *dir;
+@@ -698,12 +684,8 @@
+ 
+ 	ms->flags |= MAGIC_CHECK;	/* Enable checks for parsed files */
+ 
+-        maxmagic = MAXMAGIS;
+-	if ((marray = CAST(struct magic_entry *, calloc(maxmagic,
+-	    sizeof(*marray)))) == NULL) {
+-		file_oomem(ms, maxmagic * sizeof(*marray));
+-		return -1;
+-	}
++	maxmagic = MAXMAGIS;
++	marray = ecalloc(maxmagic, sizeof(*marray));
+ 	marraycount = 0;
+ 
+ 	/* print silly verbose header for USG compat. */
+@@ -713,14 +695,14 @@
+ 	/* load directory or file */
+         /* FIXME: Read file names and sort them to prevent
+            non-determinism. See Debian bug #488562. */
+-	if (stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {
++	if (php_sys_stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {
+ 		dir = opendir(fn);
+ 		if (dir) {
+ 			while ((d = readdir(dir)) != NULL) {
+ 				snprintf(subfn, sizeof(subfn), "%s/%s",
+ 				    fn, d->d_name);
+ 				if (stat(subfn, &st) == 0 &&
+-				    S_ISREG(st.st_mode)) {
++					S_ISREG(st.st_mode)) {
+ 					load_1(ms, action, subfn, &errs,
+ 					    &marray, &marraycount);
+ 				}
+@@ -790,12 +772,7 @@
+ 	for (i = 0; i < marraycount; i++)
+ 		mentrycount += marray[i].cont_count;
+ 
+-	slen = sizeof(**magicp) * mentrycount;
+-	if ((*magicp = CAST(struct magic *, malloc(slen))) == NULL) {
+-		file_oomem(ms, slen);
+-		errs++;
+-		goto out;
+-	}
++	*magicp = emalloc(sizeof(**magicp) * mentrycount);
+ 
+ 	mentrycount = 0;
+ 	for (i = 0; i < marraycount; i++) {
+@@ -805,8 +782,8 @@
+ 	}
+ out:
+ 	for (i = 0; i < marraycount; i++)
+-		free(marray[i].mp);
+-	free(marray);
++		efree(marray[i].mp);
++	efree(marray);
+ 	if (errs) {
+ 		*magicp = NULL;
+ 		*nmagicp = 0;
+@@ -1081,11 +1058,7 @@
+ 		if (me->cont_count == me->max_count) {
+ 			struct magic *nm;
+ 			size_t cnt = me->max_count + ALLOC_CHUNK;
+-			if ((nm = CAST(struct magic *, realloc(me->mp,
+-			    sizeof(*nm) * cnt))) == NULL) {
+-				file_oomem(ms, sizeof(*nm) * cnt);
+-				return -1;
+-			}
++			nm = erealloc(me->mp, sizeof(*nm) * cnt);
+ 			me->mp = m = nm;
+ 			me->max_count = cnt;
+ 		}
+@@ -1097,23 +1070,13 @@
+ 			struct magic_entry *mp;
+ 
+ 			maxmagic += ALLOC_INCR;
+-			if ((mp = CAST(struct magic_entry *,
+-			    realloc(*mentryp, sizeof(*mp) * maxmagic))) ==
+-			    NULL) {
+-				file_oomem(ms, sizeof(*mp) * maxmagic);
+-				return -1;
+-			}
+-			(void)memset(&mp[*nmentryp], 0, sizeof(*mp) *
+-			    ALLOC_INCR);
++			mp = erealloc(*mentryp, sizeof(*mp) * maxmagic);
++			(void)memset(&mp[*nmentryp], 0, sizeof(*mp) * ALLOC_INCR);
+ 			*mentryp = mp;
+ 		}
+ 		me = &(*mentryp)[*nmentryp];
+ 		if (me->mp == NULL) {
+-			size_t len = sizeof(*m) * ALLOC_CHUNK;
+-			if ((m = CAST(struct magic *, malloc(len))) == NULL) {
+-				file_oomem(ms, len);
+-				return -1;
+-			}
++			m = safe_emalloc(sizeof(*m), ALLOC_CHUNK, 0);
+ 			me->mp = m;
+ 			me->max_count = ALLOC_CHUNK;
+ 		} else
+@@ -1264,7 +1227,7 @@
+ 
+ 	m->mask_op = 0;
+ 	if (*l == '~') {
+-		if (!IS_STRING(m->type))
++		if (!IS_LIBMAGIC_STRING(m->type))
+ 			m->mask_op |= FILE_OPINVERSE;
+ 		else if (ms->flags & MAGIC_CHECK)
+ 			file_magwarn(ms, "'~' invalid for string types");
+@@ -1274,7 +1237,7 @@
+ 	m->str_flags = 0;
+ 	m->num_mask = 0;
+ 	if ((op = get_op(*l)) != -1) {
+-		if (!IS_STRING(m->type)) {
++		if (!IS_LIBMAGIC_STRING(m->type)) {
+ 			uint64_t val;
+ 			++l;
+ 			m->mask_op |= op;
+@@ -1423,11 +1386,6 @@
+ 		if (check_format(ms, m) == -1)
+ 			return -1;
+ 	}
+-#ifndef COMPILE_ONLY
+-	if (action == FILE_CHECK) {
+-		file_mdump(m);
+-	}
+-#endif
+ 	m->mimetype[0] = '\0';		/* initialise MIME type to none */
+ 	if (m->cont_level == 0)
+ 		++(*nmentryp);		/* make room for next */
+@@ -2053,56 +2011,68 @@
+ 
+ /*
+  * handle a compiled file.
++ * return -1 = error
++ * return 1  = memory structure you can free
++ * return 3  = bundled library from PHP
+  */
+ private int
+ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
+     const char *fn)
+ {
+-	int fd;
+-	struct stat st;
+ 	uint32_t *ptr;
+ 	uint32_t version;
  	int needsbyteswap;
  	char *dbname = NULL;
  	void *mm = NULL;
 +	int   ret = 0;
++	php_stream *stream = NULL;
++	php_stream_statbuf st;
++
++
++	TSRMLS_FETCH();
 +
-+#ifdef PHP_BUNDLE
 +	if (fn == NULL) {
-+		mm = &php_magic_database;
++		mm = (void *)&php_magic_database;
 +		ret = 3;
 +		goto internal_loaded;
 +	}
-+#endif
  
- 	mkdbname(fn, &dbname, 0);
+ 	dbname = mkdbname(ms, fn, 0);
  	if (dbname == NULL)
-@@ -1909,7 +1938,7 @@
- 		file_error(ms, errno, "cannot map `%s'", dbname);
+ 		goto error2;
+ 
+-	if ((fd = open(dbname, O_RDONLY|O_BINARY)) == -1)
++#if (PHP_MAJOR_VERSION < 6)
++		stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
++#else
++		stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS, NULL);
++#endif
++
++	if (!stream) {
+ 		goto error2;
++	}
+ 
+-	if (fstat(fd, &st) == -1) {
++	if (php_stream_stat(stream, &st) < 0) {
+ 		file_error(ms, errno, "cannot stat `%s'", dbname);
+ 		goto error1;
+ 	}
+-	if (st.st_size < 8) {
++
++	if (st.sb.st_size < 8) {
+ 		file_error(ms, 0, "file `%s' is too small", dbname);
  		goto error1;
  	}
+ 
+-#ifdef QUICK
+-	if ((mm = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
+-	    MAP_PRIVATE|MAP_FILE, fd, (off_t)0)) == MAP_FAILED) {
+-		file_error(ms, errno, "cannot map `%s'", dbname);
+-		goto error1;
+-	}
 -#define RET	2
-+	ret = 2;
- #else
- 	if ((mm = malloc((size_t)st.st_size)) == NULL) {
- 		file_oomem(ms, (size_t)st.st_size);
-@@ -1919,11 +1948,14 @@
+-#else
+-	if ((mm = CAST(void *, malloc((size_t)st.st_size))) == NULL) {
+-		file_oomem(ms, (size_t)st.st_size);
+-		goto error1;
+-	}
+-	if (read(fd, mm, (size_t)st.st_size) != (ssize_t)st.st_size) {
++	mm = emalloc((size_t)st.sb.st_size);
++	if (php_stream_read(stream, mm, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) {
  		file_badread(ms);
  		goto error1;
  	}
 -#define RET	1
+-#endif
+-	*magicp = CAST(struct magic *, mm);
+-	(void)close(fd);
+-	fd = -1;
 +	ret = 1;
- #endif
--	*magicp = mm;
- 	(void)close(fd);
- 	fd = -1;
-+#ifdef PHP_BUNDLE
++
++	php_stream_close(stream);
++	stream = NULL;
++
 +internal_loaded:
-+#endif
 +	*magicp = mm;
  	ptr = (uint32_t *)(void *)*magicp;
  	if (*ptr != MAGICNO) {
  		if (swap4(*ptr) != MAGICNO) {
-@@ -1943,6 +1975,11 @@
+@@ -2110,42 +2080,65 @@
+ 			goto error1;
+ 		}
+ 		needsbyteswap = 1;
+-	} else
++	} else {
+ 		needsbyteswap = 0;
++	}
++
+ 	if (needsbyteswap)
+ 		version = swap4(ptr[1]);
+ 	else
+ 		version = ptr[1];
++
+ 	if (version != VERSIONNO) {
+ 		file_error(ms, 0, "File %d.%d supports only version %d magic "
+ 		    "files. `%s' is version %d", FILE_VERSION_MAJOR, patchlevel,
  		    VERSIONNO, dbname, version);
  		goto error1;
  	}
-+#ifdef PHP_BUNDLE
-+	if (fn == NULL)
+-	*nmagicp = (uint32_t)(st.st_size / sizeof(struct magic));
+-	if (*nmagicp > 0)
++
++	/* php_magic_database is a const, performing writes will segfault. This is for big-endian
++	machines only, PPC and Sparc specifically. Consider static variable or MINIT in
++	future. */
++	if (needsbyteswap && fn == NULL) {
++		mm = emalloc(sizeof(php_magic_database));
++		mm = memcpy(mm, php_magic_database, sizeof(php_magic_database));
++		*magicp = mm;
++		ret = 1;
++	}
++
++	if (fn == NULL) {
 +		*nmagicp = (sizeof(php_magic_database) / sizeof(struct magic));
-+	else /* the statement after the #endif is used */
-+#endif
- 	*nmagicp = (uint32_t)(st.st_size / sizeof(struct magic));
- 	if (*nmagicp > 0)
++	} else {
++		*nmagicp = (uint32_t)(st.sb.st_size / sizeof(struct magic));
++	}
++	if (*nmagicp > 0) {
  		(*nmagicp)--;
-@@ -1950,7 +1987,7 @@
- 	if (needsbyteswap)
++	}
+ 	(*magicp)++;
+-	if (needsbyteswap)
++	if (needsbyteswap) {
  		byteswap(*magicp, *nmagicp);
- 	free(dbname);
+-	free(dbname);
 -	return RET;
++	}
++
++	if (dbname) {
++		efree(dbname);
++	}
 +	return ret;
  
  error1:
- 	if (fd != -1)
-Index: libmagic/config.h
-===================================================================
-RCS file: /repository/pecl/fileinfo/libmagic/config.h,v
-retrieving revision 1.2
-retrieving revision 1.3
-diff -u -r1.2 -r1.3
---- libmagic/config.h	11 Jul 2008 14:49:45 -0000	1.2
-+++ libmagic/config.h	24 Jul 2008 13:40:21 -0000	1.3
-@@ -2,3 +2,4 @@
- #ifdef HAVE_CONFIG_H
- #include "../config.h"
- #endif
-+#define PHP_BUNDLE
+-	if (fd != -1)
+-		(void)close(fd);
+-	if (mm) {
+-#ifdef QUICK
+-		(void)munmap((void *)mm, (size_t)st.st_size);
+-#else
+-		free(mm);
+-#endif
++	if (stream) {
++		php_stream_close(stream);
++	}
++
++	if (mm && ret == 1) {
++		efree(mm);
+ 	} else {
+ 		*magicp = NULL;
+ 		*nmagicp = 0;
+ 	}
+ error2:
+-	free(dbname);
++	if (dbname) {
++		efree(dbname);
++	}
+ 	return -1;
+ }
+ 
+@@ -2159,41 +2152,50 @@
+ apprentice_compile(struct magic_set *ms, struct magic **magicp,
+     uint32_t *nmagicp, const char *fn)
+ {
+-	int fd;
+ 	char *dbname;
+ 	int rv = -1;
++	php_stream *stream;
+ 
+-	dbname = mkdbname(ms, fn, 1);
++	TSRMLS_FETCH();
+ 
+-	if (dbname == NULL) 
++	dbname = mkdbname(ms, fn, 0);
++
++	if (dbname == NULL) {
+ 		goto out;
++	}
+ 
+-	if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644)) == -1) {
++/* wb+ == O_WRONLY|O_CREAT|O_TRUNC|O_BINARY */
++#if (PHP_MAJOR_VERSION < 6)
++	stream = php_stream_open_wrapper((char *)fn, "wb+", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
++#else
++	stream = php_stream_open_wrapper((char *)fn, "wb+", REPORT_ERRORS, NULL);
++#endif
++
++	if (!stream) {
+ 		file_error(ms, errno, "cannot open `%s'", dbname);
+ 		goto out;
+ 	}
+ 
+-	if (write(fd, ar, sizeof(ar)) != (ssize_t)sizeof(ar)) {
++	if (php_stream_write(stream, (char *)ar, sizeof(ar)) != (ssize_t)sizeof(ar)) {
+ 		file_error(ms, errno, "error writing `%s'", dbname);
+ 		goto out;
+ 	}
+ 
+-	if (lseek(fd, (off_t)sizeof(struct magic), SEEK_SET)
+-	    != sizeof(struct magic)) {
++	if (php_stream_seek(stream,(off_t)sizeof(struct magic), SEEK_SET) != sizeof(struct magic)) {
+ 		file_error(ms, errno, "error seeking `%s'", dbname);
+ 		goto out;
+ 	}
+ 
+-	if (write(fd, *magicp, (sizeof(struct magic) * *nmagicp)) 
+-	    != (ssize_t)(sizeof(struct magic) * *nmagicp)) {
++	if (php_stream_write(stream, (char *)*magicp, (sizeof(struct magic) * *nmagicp) != (ssize_t)(sizeof(struct magic) * *nmagicp))) {
+ 		file_error(ms, errno, "error writing `%s'", dbname);
+ 		goto out;
+ 	}
+ 
+-	(void)close(fd);
++	php_stream_close(stream);
++
+ 	rv = 0;
+ out:
+-	free(dbname);
++	efree(dbname);
+ 	return rv;
+ }
+ 
+@@ -2206,6 +2208,7 @@
+ {
+ 	const char *p, *q;
+ 	char *buf;
++	TSRMLS_FETCH();
+ 
+ 	if (strip) {
+ 		if ((p = strrchr(fn, '/')) != NULL)
+@@ -2227,14 +2230,14 @@
+ 	q++;
+ 	/* Compatibility with old code that looked in .mime */
+ 	if (ms->flags & MAGIC_MIME) {
+-		asprintf(&buf, "%.*s.mime%s", (int)(q - fn), fn, ext);
+-		if (access(buf, R_OK) != -1) {
++		spprintf(&buf, MAXPATHLEN, "%.*s.mime%s", (int)(q - fn), fn, ext);
++		if (VCWD_ACCESS(buf, R_OK) != -1) {
+ 			ms->flags &= MAGIC_MIME_TYPE;
+ 			return buf;
+ 		}
+-		free(buf);
++		efree(buf);
+ 	}
+-	asprintf(&buf, "%.*s%s", (int)(q - fn), fn, ext);
++	spprintf(&buf, MAXPATHLEN, "%.*s%s", (int)(q - fn), fn, ext);
+ 
+ 	/* Compatibility with old code that looked in .mime */
+ 	if (strstr(p, ".mime") != NULL)
+@@ -2324,7 +2327,7 @@
+ 	m->offset = swap4((uint32_t)m->offset);
+ 	m->in_offset = swap4((uint32_t)m->in_offset);
+ 	m->lineno = swap4((uint32_t)m->lineno);
+-	if (IS_STRING(m->type)) {
++	if (IS_LIBMAGIC_STRING(m->type)) {
+ 		m->str_range = swap4(m->str_range);
+ 		m->str_flags = swap4(m->str_flags);
+ 	}
+diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
+--- libmagic.orig/ascmagic.c	2009-03-17 21:52:35.000000000 +0000
++++ libmagic/ascmagic.c	2009-12-23 19:39:50.000000000 +0000
+@@ -144,10 +144,8 @@
+ 	/* malloc size is a conservative overestimate; could be
+ 	   improved, or at least realloced after conversion. */
+ 	mlen = ulen * 6;
+-	if ((utf8_buf = CAST(unsigned char *, malloc(mlen))) == NULL) {
+-		file_oomem(ms, mlen);
+-		goto done;
+-	}
++	utf8_buf = emalloc(mlen);
++
+ 	if ((utf8_end = encode_utf8(utf8_buf, mlen, ubuf, ulen)) == NULL)
+ 		goto done;
+ 	if ((rv = file_softmagic(ms, utf8_buf, (size_t)(utf8_end - utf8_buf),
+@@ -310,7 +308,7 @@
+ 	rv = 1;
+ done:
+ 	if (utf8_buf)
+-		free(utf8_buf);
++		efree(utf8_buf);
+ 
+ 	return rv;
+ }
+diff -u libmagic.orig/cdf.c libmagic/cdf.c
+--- libmagic.orig/cdf.c	2009-05-06 15:29:47.000000000 +0100
++++ libmagic/cdf.c	2009-12-23 19:39:50.000000000 +0000
+@@ -40,7 +40,17 @@
+ #include <err.h>
+ #endif
+ #include <stdlib.h>
++
++#ifdef PHP_WIN32
++#include "win32/unistd.h"
++#else
+ #include <unistd.h>
++#endif
++
++#ifndef UINT32_MAX
++# define UINT32_MAX (0xffffffff)
++#endif
++
+ #include <string.h>
+ #include <time.h>
+ #include <ctype.h>
+@@ -1042,7 +1052,7 @@
+ 	cdf_directory_t *d;
+ 	char name[__arraycount(d->d_name)];
+ 	cdf_stream_t scn;
+-	struct timespec ts;
++	struct timeval ts;
+ 
+ 	static const char *types[] = { "empty", "user storage",
+ 	    "user stream", "lockbytes", "property", "root storage" };
+@@ -1094,13 +1104,13 @@
+ cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
+ {
+ 	cdf_timestamp_t tp;
+-	struct timespec ts;
++	struct timeval ts;
+ 	char buf[64];
+ 	size_t i;
+ 
+ 	for (i = 0; i < count; i++) {
+ 		cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
+-		(void)fprintf(stderr, "%zu) %s: ", i, buf); 
++		(void)fprintf(stderr, "%zu) %s: ", i, buf);
+ 		switch (info[i].pi_type) {
+ 		case CDF_SIGNED16:
+ 			(void)fprintf(stderr, "signed 16 [%hd]\n",
+@@ -1121,13 +1131,17 @@
+ 			break;
+ 		case CDF_FILETIME:
+ 			tp = info[i].pi_tp;
++#if defined(PHP_WIN32 ) && _MSC_VER <= 1500
++		if (tp < 1000000000000000i64) {
++#else
+ 			if (tp < 1000000000000000LL) {
++#endif
+ 				cdf_print_elapsed_time(buf, sizeof(buf), tp);
+ 				(void)fprintf(stderr, "timestamp %s\n", buf);
+ 			} else {
+ 				cdf_timestamp_to_timespec(&ts, tp);
+ 				(void)fprintf(stderr, "timestamp %s",
+-				    ctime(&ts.tv_sec));
++					ctime(&ts.tv_sec));
+ 			}
+ 			break;
+ 		case CDF_CLIPBOARD:
+diff -u libmagic.orig/cdf.h libmagic/cdf.h
+--- libmagic.orig/cdf.h	2009-04-29 20:03:02.000000000 +0100
++++ libmagic/cdf.h	2009-12-23 19:39:50.000000000 +0000
+@@ -42,7 +42,11 @@
+ 
+ typedef struct {
+ 	uint64_t	h_magic;
+-#define CDF_MAGIC	0xE11AB1A1E011CFD0LL
++#if defined(PHP_WIN32 ) && _MSC_VER <= 1500
++# define CDF_MAGIC	0xE11AB1A1E011CFD0i64
++#else
++# define CDF_MAGIC	0xE11AB1A1E011CFD0LL
++#endif
+ 	uint64_t	h_uuid[2];
+ 	uint16_t	h_revision;
+ 	uint16_t	h_version;
+@@ -248,9 +252,9 @@
+ 	size_t i_len;
+ } cdf_info_t;
+ 
+-struct timespec;
+-int cdf_timestamp_to_timespec(struct timespec *, cdf_timestamp_t);
+-int cdf_timespec_to_timestamp(cdf_timestamp_t *, const struct timespec *);
++struct timeval;
++int cdf_timestamp_to_timespec(struct timeval *, cdf_timestamp_t);
++int cdf_timespec_to_timestamp(cdf_timestamp_t *, const struct timeval *);
+ int cdf_read_header(const cdf_info_t *, cdf_header_t *);
+ void cdf_swap_header(cdf_header_t *);
+ void cdf_unpack_header(cdf_header_t *, char *);
+diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
+--- libmagic.orig/cdf_time.c	2009-03-10 11:44:29.000000000 +0000
++++ libmagic/cdf_time.c	2009-12-23 19:39:50.000000000 +0000
+@@ -96,7 +96,7 @@
+ }
+ 
+ int
+-cdf_timestamp_to_timespec(struct timespec *ts, cdf_timestamp_t t)
++cdf_timestamp_to_timespec(struct timeval *ts, cdf_timestamp_t t)
+ {
+ 	struct tm tm;
+ #ifdef HAVE_STRUCT_TM_TM_ZONE
+@@ -104,8 +104,8 @@
+ #endif
+ 	int rdays;
+ 
+-	/* Unit is 100's of nanoseconds */
+-	ts->tv_nsec = (t % CDF_TIME_PREC) * 100;
++	/* Time interval, in microseconds */
++	ts->tv_usec = (t % CDF_TIME_PREC) * CDF_TIME_PREC;
+ 
+ 	t /= CDF_TIME_PREC;
+ 	tm.tm_sec = t % 60;
+@@ -143,7 +143,7 @@
+ }
+ 
+ int
+-cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts)
++cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timeval *ts)
+ {
+ 	(void)&t;
+ 	(void)&ts;
+@@ -153,7 +153,7 @@
+ 		errno = EINVAL;
+ 		return -1;
+ 	}
+-	*t = (ts->ts_nsec / 100) * CDF_TIME_PREC;
++	*t = (ts->ts_usec / CDF_TIME_PREC) * CDF_TIME_PREC;
+ 	*t = tm.tm_sec;
+ 	*t += tm.tm_min * 60;
+ 	*t += tm.tm_hour * 60 * 60;
+@@ -167,7 +167,7 @@
+ int
+ main(int argc, char *argv[])
+ {
+-	struct timespec ts;
++	struct timeval ts;
+ 	static const cdf_timestamp_t tst = 0x01A5E403C2D59C00ULL;
+ 	static const char *ref = "Sat Apr 23 01:30:00 1977";
+ 	char *p, *q;
+diff -u libmagic.orig/compress.c libmagic/compress.c
+--- libmagic.orig/compress.c	2009-03-23 14:21:51.000000000 +0000
++++ libmagic/compress.c	2009-12-23 19:39:50.000000000 +0000
+@@ -32,6 +32,7 @@
+  *	uncompress(method, old, n, newch) - uncompress old into new, 
+  *					    using method, return sizeof new
+  */
++#include "config.h"
+ #include "file.h"
+ 
+ #ifndef lint
+@@ -45,7 +46,10 @@
+ #endif
+ #include <string.h>
+ #include <errno.h>
++#include <sys/types.h>
++#ifndef PHP_WIN32
+ #include <sys/ioctl.h>
++#endif
+ #ifdef HAVE_SYS_WAIT_H
+ #include <sys/wait.h>
+ #endif
+@@ -57,6 +61,9 @@
+ #include <zlib.h>
+ #endif
+ 
++#undef FIONREAD
++
++
+ private const struct {
+ 	const char magic[8];
+ 	size_t maglen;
+@@ -79,12 +86,10 @@
+  	{ "\3757zXZ\0",6,{ "xz", "-cd", NULL }, 1 },		/* XZ Utils */
+ };
+ 
+-private size_t ncompr = sizeof(compr) / sizeof(compr[0]);
+-
+ #define NODATA ((size_t)~0)
+ 
+-
+ private ssize_t swrite(int, const void *, size_t);
++#ifdef PHP_FILEINFO_UNCOMPRESS
+ private size_t uncompressbuf(struct magic_set *, int, size_t,
+     const unsigned char *, unsigned char **, size_t);
+ #ifdef BUILTIN_DECOMPRESS
+@@ -100,10 +105,13 @@
+ 	size_t i, nsz;
+ 	int rv = 0;
+ 	int mime = ms->flags & MAGIC_MIME;
++	size_t ncompr;
+ 
+ 	if ((ms->flags & MAGIC_COMPRESS) == 0)
+ 		return 0;
+ 
++	ncompr = sizeof(compr) / sizeof(compr[0]);
++
+ 	for (i = 0; i < ncompr; i++) {
+ 		if (nbytes < compr[i].maglen)
+ 			continue;
+@@ -133,10 +141,11 @@
+ 	}
+ error:
+ 	if (newbuf)
+-		free(newbuf);
++		efree(newbuf);
+ 	ms->flags |= MAGIC_COMPRESS;
+ 	return rv;
+ }
++#endif
+ 
+ /*
+  * `safe' write for sockets and pipes.
+@@ -169,7 +178,7 @@
+ protected ssize_t
+ sread(int fd, void *buf, size_t n, int canbepipe)
+ {
+-	int rv, cnt;
++	int rv;
+ #ifdef FIONREAD
+ 	int t = 0;
+ #endif
+@@ -181,6 +190,7 @@
+ #ifdef FIONREAD
+ 	if ((canbepipe && (ioctl(fd, FIONREAD, &t) == -1)) || (t == 0)) {
+ #ifdef FD_ZERO
++		int cnt;
+ 		for (cnt = 0;; cnt++) {
+ 			fd_set check;
+ 			struct timeval tout = {0, 100 * 1000};
+@@ -294,6 +304,7 @@
+ 	return fd;
+ }
+ 
++#ifdef PHP_FILEINFO_UNCOMPRESS
+ #ifdef BUILTIN_DECOMPRESS
+ 
+ #define FHCRC		(1 << 1)
+@@ -301,6 +312,7 @@
+ #define FNAME		(1 << 3)
+ #define FCOMMENT	(1 << 4)
+ 
++
+ private size_t
+ uncompressgzipped(struct magic_set *ms, const unsigned char *old,
+     unsigned char **newch, size_t n)
+@@ -330,9 +342,7 @@
+ 
+ 	if (data_start >= n)
+ 		return 0;
+-	if ((*newch = CAST(unsigned char *, malloc(HOWMANY + 1))) == NULL) {
+-		return 0;
+-	}
++	*newch = (unsigned char *)emalloc(HOWMANY + 1));
+ 	
+ 	/* XXX: const castaway, via strchr */
+ 	z.next_in = (Bytef *)strchr((const char *)old + data_start,
+@@ -455,20 +465,14 @@
+ 			fdin[1] = -1;
+ 		}
+ 
+-		if ((*newch = (unsigned char *) malloc(HOWMANY + 1)) == NULL) {
+-#ifdef DEBUG
+-			(void)fprintf(stderr, "Malloc failed (%s)\n",
+-			    strerror(errno));
+-#endif
+-			n = 0;
+-			goto err;
+-		}
++		*newch = (unsigned char *) emalloc(HOWMANY + 1);
++
+ 		if ((r = sread(fdout[0], *newch, HOWMANY, 0)) <= 0) {
+ #ifdef DEBUG
+ 			(void)fprintf(stderr, "Read failed (%s)\n",
+ 			    strerror(errno));
+ #endif
+-			free(*newch);
++			efree(*newch);
+ 			n = 0;
+ 			newch[0] = '\0';
+ 			goto err;
+@@ -492,3 +496,4 @@
+ 		return n;
+ 	}
+ }
++#endif /* if PHP_FILEINFO_UNCOMPRESS */
+diff -u libmagic.orig/file.h libmagic/file.h
+--- libmagic.orig/file.h	2009-03-17 21:52:35.000000000 +0000
++++ libmagic/file.h	2009-12-23 19:39:50.000000000 +0000
+@@ -33,9 +33,7 @@
+ #ifndef __file_h__
+ #define __file_h__
+ 
+-#ifdef HAVE_CONFIG_H
+-#include <config.h>
+-#endif
++#include "config.h"
+ 
+ #include <stdio.h>	/* Include that here, to make sure __P gets defined */
+ #include <errno.h>
+@@ -46,9 +44,20 @@
+ #ifdef HAVE_INTTYPES_H
+ #include <inttypes.h>
+ #endif
+-#include <regex.h>
++#ifdef PHP_WIN32
++#include "win32/php_stdint.h"
++#endif
++
++#include "php.h"
++#include "ext/standard/php_string.h"
++#include "ext/pcre/php_pcre.h"
++
+ #include <sys/types.h>
++#ifdef PHP_WIN32
++#include "win32/param.h"
++#else
+ #include <sys/param.h>
++#endif
+ /* Do this here and now, because struct stat gets re-defined on solaris */
+ #include <sys/stat.h>
+ #include <stdarg.h>
+@@ -59,7 +68,7 @@
+ #define MAGIC "/etc/magic"
+ #endif
+ 
+-#ifdef __EMX__
++#if defined(__EMX__) || defined(PHP_WIN32)
+ #define PATHSEP	';'
+ #else
+ #define PATHSEP	':'
+@@ -81,12 +90,6 @@
+ #endif
+ #endif
+ 
+-#ifndef __GNUC__
+-#ifndef __attribute__
+-#define __attribute__(a)
+-#endif
+-#endif
+-
+ #ifndef MIN
+ #define	MIN(a,b)	(((a) < (b)) ? (a) : (b))
+ #endif
+@@ -189,7 +192,7 @@
+ #define				FILE_INDIRECT	41
+ #define				FILE_NAMES_SIZE	42/* size of array to contain all names */
+ 
+-#define IS_STRING(t) \
++#define IS_LIBMAGIC_STRING(t) \
+ 	((t) == FILE_STRING || \
+ 	 (t) == FILE_PSTRING || \
+ 	 (t) == FILE_BESTRING16 || \
+@@ -211,7 +214,7 @@
+ #ifdef ENABLE_CONDITIONALS
+ 	uint8_t cond;		/* conditional type */
+ #else
+-	uint8_t dummy;
++	uint8_t dummy;	
+ #endif
+ 	uint8_t factor_op;
+ #define		FILE_FACTOR_OP_PLUS	'+'
+@@ -345,20 +348,20 @@
+ 
+ struct stat;
+ protected const char *file_fmttime(uint32_t, int);
+-protected int file_buffer(struct magic_set *, int, const char *, const void *,
++protected int file_buffer(struct magic_set *, php_stream *, const char *, const void *,
+     size_t);
+-protected int file_fsmagic(struct magic_set *, const char *, struct stat *);
++protected int file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *stream);
+ protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
+-protected int file_vprintf(struct magic_set *, const char *, va_list);
+-protected int file_printf(struct magic_set *, const char *, ...)
+-    __attribute__((__format__(__printf__, 2, 3)));
++protected int file_printf(struct magic_set *, const char *, ...);
+ protected int file_reset(struct magic_set *);
+ protected int file_tryelf(struct magic_set *, int, const unsigned char *,
+     size_t);
+ protected int file_trycdf(struct magic_set *, int, const unsigned char *,
+     size_t);
++#ifdef PHP_FILEINFO_UNCOMPRESS 
+ protected int file_zmagic(struct magic_set *, int, const char *,
+     const unsigned char *, size_t);
++#endif
+ protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t);
+ protected int file_ascmagic_with_encoding(struct magic_set *,
+     const unsigned char *, size_t, unichar *, size_t, const char *,
+@@ -375,13 +378,9 @@
+ protected void file_badread(struct magic_set *);
+ protected void file_badseek(struct magic_set *);
+ protected void file_oomem(struct magic_set *, size_t);
+-protected void file_error(struct magic_set *, int, const char *, ...)
+-    __attribute__((__format__(__printf__, 3, 4)));
+-protected void file_magerror(struct magic_set *, const char *, ...)
+-    __attribute__((__format__(__printf__, 2, 3)));
+-protected void file_magwarn(struct magic_set *, const char *, ...)
+-    __attribute__((__format__(__printf__, 2, 3)));
+-protected void file_mdump(struct magic *);
++protected void file_error(struct magic_set *, int, const char *, ...);
++protected void file_magerror(struct magic_set *, const char *, ...);
++protected void file_magwarn(struct magic_set *, const char *, ...);
+ protected void file_showstr(FILE *, const char *, size_t);
+ protected size_t file_mbswidth(const char *);
+ protected const char *file_getbuffer(struct magic_set *);
+@@ -394,11 +393,8 @@
+     size_t);
+ #endif /* __EMX__ */
+ 
+-
+-#ifndef COMPILE_ONLY
+ extern const char *file_names[];
+ extern const size_t file_nnames;
+-#endif
+ 
+ #ifndef HAVE_STRERROR
+ extern int sys_nerr;
+@@ -411,20 +407,14 @@
+ #define strtoul(a, b, c)	strtol(a, b, c)
+ #endif
+ 
+-#ifndef HAVE_VASPRINTF
+-int vasprintf(char **, const char *, va_list);
+-#endif
+-#ifndef HAVE_ASPRINTF
+-int asprintf(char **ptr, const char *format_string, ...);
+-#endif
+-
+-#ifndef HAVE_STRLCPY
++#ifndef strlcpy
+ size_t strlcpy(char *dst, const char *src, size_t siz);
+ #endif
+-#ifndef HAVE_STRLCAT
++#ifndef strlcat
+ size_t strlcat(char *dst, const char *src, size_t siz);
+ #endif
+ 
++
+ #if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK)
+ #define QUICK
+ #endif
+diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
+--- libmagic.orig/fsmagic.c	2009-03-17 21:52:35.000000000 +0000
++++ libmagic/fsmagic.c	2009-12-23 19:39:50.000000000 +0000
+@@ -60,29 +60,19 @@
+ #endif
+ #undef HAVE_MAJOR
+ 
+-private int
+-bad_link(struct magic_set *ms, int err, char *buf)
+-{
+-	const char *errfmt;
+-	int mime = ms->flags & MAGIC_MIME;
+-	if ((mime & MAGIC_MIME_TYPE) &&
+-	    file_printf(ms, "application/x-symlink")
+-	    == -1)
+-		return -1;
+-	else if (!mime) {
+-		if (err == ELOOP)
+-			errfmt = "symbolic link in a loop";
+-		else
+-			errfmt = "broken symbolic link to `%s'";
+-		if (ms->flags & MAGIC_ERROR) {
+-			file_error(ms, err, errfmt, buf);
+-			return -1;
+-		} 
+-		if (file_printf(ms, errfmt, buf) == -1)
+-			return -1;
+-	}
+-	return 1;
+-}
++#ifdef PHP_WIN32
++
++# undef S_IFIFO
++#endif
++
++
++#ifndef S_ISDIR
++#define S_ISDIR(mode) ((mode) & _S_IFDIR)
++#endif
++
++#ifndef S_ISREG
++#define S_ISREG(mode) ((mode) & _S_IFREG)
++#endif
+ 
+ private int
+ handle_mime(struct magic_set *ms, int mime, const char *str)
+@@ -100,41 +90,36 @@
+ }
+ 
+ protected int
+-file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
++file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *stream)
+ {
+-	int ret = 0;
+ 	int mime = ms->flags & MAGIC_MIME;
+-#ifdef	S_IFLNK
+-	char buf[BUFSIZ+4];
+-	int nch;
+-	struct stat tstatbuf;
+-#endif
++	TSRMLS_FETCH();
+ 
+ 	if (ms->flags & MAGIC_APPLE)
+ 		return 0;
+-	if (fn == NULL)
++
++	if (!fn && !stream) {
+ 		return 0;
++	}
+ 
+-	/*
+-	 * Fstat is cheaper but fails for files you don't have read perms on.
+-	 * On 4.2BSD and similar systems, use lstat() to identify symlinks.
+-	 */
+-#ifdef	S_IFLNK
+-	if ((ms->flags & MAGIC_SYMLINK) == 0)
+-		ret = lstat(fn, sb);
+-	else
+-#endif
+-	ret = stat(fn, sb);	/* don't merge into if; see "ret =" above */
+-
+-	if (ret) {
+-		if (ms->flags & MAGIC_ERROR) {
+-			file_error(ms, errno, "cannot stat `%s'", fn);
+-			return -1;
++	if (stream) {
++		php_stream_statbuf ssb;
++		if (php_stream_stat(stream, &ssb) < 0) {
++			if (ms->flags & MAGIC_ERROR) {
++				file_error(ms, errno, "cannot stat `%s'", fn);
++				return -1;
++			}
++			return 1;
++		}
++		memcpy(sb, &ssb.sb, sizeof(struct stat));
++	} else {
++		if (php_sys_stat(fn, sb) != 0) {
++			if (ms->flags & MAGIC_ERROR) {
++				file_error(ms, errno, "cannot stat `%s'", fn);
++				return -1;
++			}
++			return 1;
+ 		}
+-		if (file_printf(ms, "cannot open `%s' (%s)",
+-		    fn, strerror(errno)) == -1)
+-			return -1;
+-		return 1;
+ 	}
+ 
+ 	if (!mime) {
+@@ -154,172 +139,75 @@
+ 				return -1;
+ #endif
+ 	}
+-	
++
+ 	switch (sb->st_mode & S_IFMT) {
+-	case S_IFDIR:
+-		if (mime) {
+-			if (handle_mime(ms, mime, "x-directory") == -1)
+-				return -1;
+-		} else if (file_printf(ms, "directory") == -1)
+-			return -1;
+-		return 1;
+-#ifdef S_IFCHR
+-	case S_IFCHR:
+-		/* 
+-		 * If -s has been specified, treat character special files
+-		 * like ordinary files.  Otherwise, just report that they
+-		 * are block special files and go on to the next file.
+-		 */
+-		if ((ms->flags & MAGIC_DEVICES) != 0)
+-			break;
+-		if (mime) {
+-			if (handle_mime(ms, mime, "x-character-device") == -1)
+-				return -1;
+-		} else {
+-#ifdef HAVE_STAT_ST_RDEV
+-# ifdef dv_unit
+-			if (file_printf(ms, "character special (%d/%d/%d)",
+-			    major(sb->st_rdev), dv_unit(sb->st_rdev),
+-					dv_subunit(sb->st_rdev)) == -1)
+-				return -1;
+-# else
+-			if (file_printf(ms, "character special (%ld/%ld)",
+-			    (long)major(sb->st_rdev), (long)minor(sb->st_rdev))
+-			    == -1)
+-				return -1;
+-# endif
+-#else
+-			if (file_printf(ms, "character special") == -1)
+-				return -1;
+-#endif
+-		}
+-		return 1;
+-#endif
+-#ifdef S_IFBLK
+-	case S_IFBLK:
+-		/* 
+-		 * If -s has been specified, treat block special files
+-		 * like ordinary files.  Otherwise, just report that they
+-		 * are block special files and go on to the next file.
+-		 */
+-		if ((ms->flags & MAGIC_DEVICES) != 0)
+-			break;
+-		if (mime) {
+-			if (handle_mime(ms, mime, "x-block-device") == -1)
+-				return -1;
+-		} else {
+-#ifdef HAVE_STAT_ST_RDEV
+-# ifdef dv_unit
+-			if (file_printf(ms, "block special (%d/%d/%d)",
+-					major(sb->st_rdev), dv_unit(sb->st_rdev),
+-					dv_subunit(sb->st_rdev)) == -1)
+-				return -1;
+-# else
+-			if (file_printf(ms, "block special (%ld/%ld)",
+-					(long)major(sb->st_rdev), (long)minor(sb->st_rdev)) == -1)
+-				return -1;
+-# endif
+-#else
+-			if (file_printf(ms, "block special") == -1)
+-				return -1;
+-#endif
+-		}
+-		return 1;
+-#endif
+-	/* TODO add code to handle V7 MUX and Blit MUX files */
+-#ifdef	S_IFIFO
+-	case S_IFIFO:
+-		if((ms->flags & MAGIC_DEVICES) != 0)
+-			break;
+-		if (mime) {
+-			if (handle_mime(ms, mime, "x-fifo") == -1)
+-				return -1;
+-		} else if (file_printf(ms, "fifo (named pipe)") == -1)
+-			return -1;
+-		return 1;
+-#endif
+-#ifdef	S_IFDOOR
+-	case S_IFDOOR:
+-		if (mime) {
+-			if (handle_mime(ms, mime, "x-door") == -1)
+-				return -1;
+-		} else if (file_printf(ms, "door") == -1)
+-			return -1;
+-		return 1;
+-#endif
+-#ifdef	S_IFLNK
+-	case S_IFLNK:
+-		if ((nch = readlink(fn, buf, BUFSIZ-1)) <= 0) {
+-			if (ms->flags & MAGIC_ERROR) {
+-			    file_error(ms, errno, "unreadable symlink `%s'",
+-				fn);
+-			    return -1;
++#ifndef PHP_WIN32
++# ifdef S_IFCHR
++		case S_IFCHR:
++			/* 
++			 * If -s has been specified, treat character special files
++			 * like ordinary files.  Otherwise, just report that they
++			 * are block special files and go on to the next file.
++			 */
++			if ((ms->flags & MAGIC_DEVICES) != 0) {
++				break;
+ 			}
+ 			if (mime) {
+-				if (handle_mime(ms, mime, "x-symlink") == -1)
++				if (handle_mime(ms, mime, "x-character-device") == -1)
+ 					return -1;
+-			} else if (file_printf(ms,
+-			    "unreadable symlink `%s' (%s)", fn,
+-			    strerror(errno)) == -1)
+-				return -1;
++			} else {
++#  ifdef HAVE_STAT_ST_RDEV
++#   ifdef dv_unit
++				if (file_printf(ms, "character special (%d/%d/%d)",
++				    major(sb->st_rdev), dv_unit(sb->st_rdev),
++						dv_subunit(sb->st_rdev)) == -1)
++					return -1;
++#   else
++				if (file_printf(ms, "character special (%ld/%ld)",
++				    (long)major(sb->st_rdev), (long)minor(sb->st_rdev))
++				    == -1)
++					return -1;
++#   endif
++#  else
++				if (file_printf(ms, "character special") == -1)
++					return -1;
++#  endif
++			}
+ 			return 1;
+-		}
+-		buf[nch] = '\0';	/* readlink(2) does not do this */
+-
+-		/* If broken symlink, say so and quit early. */
+-		if (*buf == '/') {
+-			if (stat(buf, &tstatbuf) < 0)
+-				return bad_link(ms, errno, buf);
+-		} else {
+-			char *tmp;
+-			char buf2[BUFSIZ+BUFSIZ+4];
++# endif
++#endif
+ 
+-			if ((tmp = strrchr(fn,  '/')) == NULL) {
+-				tmp = buf; /* in current directory anyway */
+-			} else {
+-				if (tmp - fn + 1 > BUFSIZ) {
+-					if (ms->flags & MAGIC_ERROR) {
+-						file_error(ms, 0, 
+-						    "path too long: `%s'", buf);
++#ifdef	S_IFIFO
++			case S_IFIFO:
++				if((ms->flags & MAGIC_DEVICES) != 0)
++					break;
++				if (mime) {
++					if (handle_mime(ms, mime, "x-fifo") == -1)
+ 						return -1;
+-					}
++				} else if (file_printf(ms, "fifo (named pipe)") == -1)
++					return -1;
++				return 1;
++#endif
++#ifdef	S_IFDOOR
++				case S_IFDOOR:
+ 					if (mime) {
+-						if (handle_mime(ms, mime,
+-						    "x-path-too-long") == -1)
++						if (handle_mime(ms, mime, "x-door") == -1)
+ 							return -1;
+-					} else if (file_printf(ms,
+-					    "path too long: `%s'", fn) == -1)
++					} else if (file_printf(ms, "door") == -1)
+ 						return -1;
+ 					return 1;
+-				}
+-				/* take dir part */
+-				(void)strlcpy(buf2, fn, sizeof buf2);
+-				buf2[tmp - fn + 1] = '\0';
+-				/* plus (rel) link */
+-				(void)strlcat(buf2, buf, sizeof buf2);
+-				tmp = buf2;
+-			}
+-			if (stat(tmp, &tstatbuf) < 0)
+-				return bad_link(ms, errno, buf);
+-		}
++#endif
+ 
+-		/* Otherwise, handle it. */
+-		if ((ms->flags & MAGIC_SYMLINK) != 0) {
+-			const char *p;
+-			ms->flags &= MAGIC_SYMLINK;
+-			p = magic_file(ms, buf);
+-			ms->flags |= MAGIC_SYMLINK;
+-			return p != NULL ? 1 : -1;
+-		} else { /* just print what it points to */
+-			if (mime) {
+-				if (handle_mime(ms, mime, "x-symlink") == -1)
+-					return -1;
+-			} else if (file_printf(ms, "symbolic link to `%s'",
+-			    buf) == -1)
+-				return -1;
+-		}
+-		return 1;
++#ifdef	S_IFLNK
++	case S_IFLNK:
++		/* stat is used, if it made here then the link is broken */
++			if (ms->flags & MAGIC_ERROR) {
++			    file_error(ms, errno, "unreadable symlink `%s'", fn);
++			    return -1;
++			}
++	return 1;
+ #endif
++
+ #ifdef	S_IFSOCK
+ #ifndef __COHERENT__
+ 	case S_IFSOCK:
+@@ -331,12 +219,14 @@
+ 		return 1;
+ #endif
+ #endif
+-	case S_IFREG:
+-		break;
+-	default:
+-		file_error(ms, 0, "invalid mode 0%o", sb->st_mode);
+-		return -1;
+-		/*NOTREACHED*/
++
++		case S_IFREG:
++			break;
++
++		default:
++			file_error(ms, 0, "invalid mode 0%o", sb->st_mode);
++			return -1;
++			/*NOTREACHED*/
+ 	}
+ 
+ 	/*
+diff -u libmagic.orig/funcs.c libmagic/funcs.c
+--- libmagic.orig/funcs.c	2009-04-07 12:07:00.000000000 +0100
++++ libmagic/funcs.c	2009-12-23 19:39:50.000000000 +0000
+@@ -41,52 +41,36 @@
+ #if defined(HAVE_WCTYPE_H)
+ #include <wctype.h>
+ #endif
+-#if defined(HAVE_LIMITS_H)
+-#include <limits.h>
+-#endif
+ 
+-#ifndef SIZE_MAX
+-#define SIZE_MAX	((size_t)~0)
++#ifndef SIZE_MAX 
++# define SIZE_MAX ((size_t) -1) 
+ #endif
+ 
+ /*
+  * Like printf, only we append to a buffer.
+  */
+ protected int
+-file_vprintf(struct magic_set *ms, const char *fmt, va_list ap)
++file_printf(struct magic_set *ms, const char *fmt, ...)
+ {
++	va_list ap;
+ 	int len;
+-	char *buf, *newstr;
++	char *buf = NULL, *newstr;
+ 
+-	len = vasprintf(&buf, fmt, ap);
+-	if (len < 0)
+-		goto out;
++	va_start(ap, fmt);
++	len = vspprintf(&buf, 0, fmt, ap);
++	va_end(ap);
+ 
+ 	if (ms->o.buf != NULL) {
+-		len = asprintf(&newstr, "%s%s", ms->o.buf, buf);
+-		free(buf);
+-		if (len < 0)
+-			goto out;
+-		free(ms->o.buf);
+-		buf = newstr;
++		len = spprintf(&newstr, 0, "%s%s", ms->o.buf, (buf ? buf : ""));
++		if (buf) {
++			efree(buf);
++		}
++		efree(ms->o.buf);
++		ms->o.buf = newstr;
++	} else {
++		ms->o.buf = buf;
+ 	}
+-	ms->o.buf = buf;
+ 	return 0;
+-out:
+-	file_error(ms, errno, "vasprintf failed");
+-	return -1;
+-}
+-
+-protected int
+-file_printf(struct magic_set *ms, const char *fmt, ...)
+-{
+-	int rv;
+-	va_list ap;
+-
+-	va_start(ap, fmt);
+-	rv = file_vprintf(ms, fmt, ap);
+-	va_end(ap);
+-	return rv;
+ }
+ 
+ /*
+@@ -97,17 +81,32 @@
+ file_error_core(struct magic_set *ms, int error, const char *f, va_list va,
+     uint32_t lineno)
+ {
++	char *buf = NULL;
++	
+ 	/* Only the first error is ok */
+-	if (ms->event_flags & EVENT_HAD_ERR)
++	if (ms->event_flags & EVENT_HAD_ERR) {
+ 		return;
++	}
++	
+ 	if (lineno != 0) {
+-		free(ms->o.buf);
++		efree(ms->o.buf);
+ 		ms->o.buf = NULL;
+ 		file_printf(ms, "line %u: ", lineno);
+ 	}
+-	file_vprintf(ms, f, va);
+-	if (error > 0)
+-		file_printf(ms, " (%s)", strerror(error));
++
++	vspprintf(&buf, 0, f, va);
++	va_end(va);
++	
++	if (error > 0) {
++		file_printf(ms, "%s (%s)", (*buf ? buf : ""), strerror(error));
++	} else if (*buf) {
++		file_printf(ms, "%s", buf);
++	}
++	
++	if (buf) {
++		efree(buf);
++	}
++
+ 	ms->event_flags |= EVENT_HAD_ERR;
+ 	ms->error = error;
+ }
+@@ -153,14 +152,13 @@
+ 	file_error(ms, errno, "error reading");
+ }
+ 
+-#ifndef COMPILE_ONLY
+ protected int
+-file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
++file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const void *buf,
+     size_t nb)
+ {
+ 	int m = 0, rv = 0, looks_text = 0;
+ 	int mime = ms->flags & MAGIC_MIME;
+-	const unsigned char *ubuf = CAST(const unsigned char *, buf);
++	const unsigned char *ubuf = buf;
+ 	unichar *u8buf = NULL;
+ 	size_t ulen;
+ 	const char *code = NULL;
+@@ -188,7 +186,7 @@
+ 		    &code, &code_mime, &type);
+ 	}
+ 
+-#ifdef __EMX__
++#if defined(__EMX__)
+ 	if ((ms->flags & MAGIC_NO_CHECK_APPTYPE) == 0 && inname) {
+ 		switch (file_os2_apptype(ms, inname, buf, nb)) {
+ 		case -1:
+@@ -201,13 +199,14 @@
+ 	}
+ #endif
+ 
+-	/* try compression stuff */
++#if PHP_FILEINFO_UNCOMPRESS
+ 	if ((ms->flags & MAGIC_NO_CHECK_COMPRESS) == 0)
+-		if ((m = file_zmagic(ms, fd, inname, ubuf, nb)) != 0) {
++		if ((m = file_zmagic(ms, stream, inname, ubuf, nb)) != 0) {
+ 			if ((ms->flags & MAGIC_DEBUG) != 0)
+ 				(void)fprintf(stderr, "zmagic %d\n", m);
+ 			goto done;
+-		}
++ 	}
++#endif
+ 
+ 	/* Check if we have a tar file */
+ 	if ((ms->flags & MAGIC_NO_CHECK_TAR) == 0)
+@@ -218,12 +217,17 @@
+ 		}
+ 
+ 	/* Check if we have a CDF file */
+-	if ((ms->flags & MAGIC_NO_CHECK_CDF) == 0)
+-		if ((m = file_trycdf(ms, fd, ubuf, nb)) != 0) {
+-			if ((ms->flags & MAGIC_DEBUG) != 0)
+-				(void)fprintf(stderr, "cdf %d\n", m);
+-			goto done;
++	if ((ms->flags & MAGIC_NO_CHECK_CDF) == 0) {
++		int fd;
++		TSRMLS_FETCH();
++		if (stream && SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)&fd, 0)) {
++			if ((m = file_trycdf(ms, fd, ubuf, nb)) != 0) {
++				if ((ms->flags & MAGIC_DEBUG) != 0)
++					(void)fprintf(stderr, "cdf %d\n", m);
++				goto done;
++			}
+ 		}
++	}
+ 
+ 	/* try soft magic tests */
+ 	if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0)
+@@ -294,7 +298,6 @@
+ 
+ 	return m;
+ }
+-#endif
+ 
+ protected int
+ file_reset(struct magic_set *ms)
+@@ -304,11 +307,11 @@
+ 		return -1;
+ 	}
+ 	if (ms->o.buf) {
+-		free(ms->o.buf);
++		efree(ms->o.buf);
+ 		ms->o.buf = NULL;
+ 	}
+ 	if (ms->o.pbuf) {
+-		free(ms->o.pbuf);
++		efree(ms->o.pbuf);
+ 		ms->o.pbuf = NULL;
+ 	}
+ 	ms->event_flags &= ~EVENT_HAD_ERR;
+@@ -342,14 +345,10 @@
+ 	/* * 4 is for octal representation, + 1 is for NUL */
+ 	len = strlen(ms->o.buf);
+ 	if (len > (SIZE_MAX - 1) / 4) {
+-		file_oomem(ms, len);
+ 		return NULL;
+ 	}
+ 	psize = len * 4 + 1;
+-	if ((pbuf = CAST(char *, realloc(ms->o.pbuf, psize))) == NULL) {
+-		file_oomem(ms, psize);
+-		return NULL;
+-	}
++	pbuf = erealloc(ms->o.pbuf, psize);
+ 	ms->o.pbuf = pbuf;
+ 
+ #if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
+@@ -409,13 +408,7 @@
+ 
+ 	if (level >= ms->c.len) {
+ 		len = (ms->c.len += 20) * sizeof(*ms->c.li);
+-		ms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ?
+-		    malloc(len) :
+-		    realloc(ms->c.li, len));
+-		if (ms->c.li == NULL) {
+-			file_oomem(ms, len);
+-			return -1;
+-		}
++		ms->c.li = (ms->c.li == NULL) ? emalloc(len) : erealloc(ms->c.li, len);
+ 	}
+ 	ms->c.li[level].got_match = 0;
+ #ifdef ENABLE_CONDITIONALS
+diff -u libmagic.orig/magic.c libmagic/magic.c
+--- libmagic.orig/magic.c	2009-03-20 21:25:41.000000000 +0000
++++ libmagic/magic.c	2009-12-23 19:39:50.000000000 +0000
+@@ -34,14 +34,19 @@
+ #include "magic.h"
+ 
+ #include <stdlib.h>
++#ifdef PHP_WIN32
++#include "win32/unistd.h"
++#else
+ #include <unistd.h>
++#endif
+ #include <string.h>
+-#ifdef QUICK
+-#include <sys/mman.h>
++#ifdef PHP_WIN32
++# include "config.w32.h"
++#else
++# include "php_config.h"
+ #endif
+-#ifdef HAVE_LIMITS_H
++
+ #include <limits.h>	/* for PIPE_BUF */
+-#endif
+ 
+ #if defined(HAVE_UTIMES)
+ # include <sys/time.h>
+@@ -57,7 +62,9 @@
+ #include <unistd.h>	/* for read() */
+ #endif
+ 
+-#include <netinet/in.h>		/* for byte swapping */
++#ifndef PHP_WIN32
++# include <netinet/in.h>		/* for byte swapping */
++#endif
+ 
+ #include "patchlevel.h"
+ 
+@@ -70,13 +77,16 @@
+ #endif
+ #endif
+ 
++#ifdef PHP_WIN32
++# undef S_IFLNK
++# undef S_IFIFO
++#endif
++
+ private void free_mlist(struct mlist *);
+ private void close_and_restore(const struct magic_set *, const char *, int,
+     const struct stat *);
+ private int unreadable_info(struct magic_set *, mode_t, const char *);
+-#ifndef COMPILE_ONLY
+-private const char *file_or_fd(struct magic_set *, const char *, int);
+-#endif
++private const char *file_or_stream(struct magic_set *, const char *, php_stream *);
+ 
+ #ifndef	STDIN_FILENO
+ #define	STDIN_FILENO	0
+@@ -86,11 +96,8 @@
+ magic_open(int flags)
+ {
+ 	struct magic_set *ms;
+-	size_t len;
+ 
+-	if ((ms = CAST(magic_set *, calloc((size_t)1,
+-	    sizeof(struct magic_set)))) == NULL)
+-		return NULL;
++	ms = ecalloc((size_t)1, sizeof(struct magic_set));
+ 
+ 	if (magic_setflags(ms, flags) == -1) {
+ 		errno = EINVAL;
+@@ -98,11 +105,9 @@
+ 	}
+ 
+ 	ms->o.buf = ms->o.pbuf = NULL;
+-	len = (ms->c.len = 10) * sizeof(*ms->c.li);
+-
+-	if ((ms->c.li = CAST(struct level_info *, malloc(len))) == NULL)
+-		goto free;
+ 
++	ms->c.li = emalloc((ms->c.len = 10) * sizeof(*ms->c.li));
++	
+ 	ms->event_flags = 0;
+ 	ms->error = -1;
+ 	ms->mlist = NULL;
+@@ -110,7 +115,7 @@
+ 	ms->line = 0;
+ 	return ms;
+ free:
+-	free(ms);
++	efree(ms);
+ 	return NULL;
+ }
+ 
+@@ -126,10 +131,10 @@
+ 		struct mlist *next = ml->next;
+ 		struct magic *mg = ml->magic;
+ 		file_delmagic(mg, ml->mapped, ml->nmagic);
+-		free(ml);
++		efree(ml);
+ 		ml = next;
+ 	}
+-	free(ml);
++	efree(ml);
+ }
+ 
+ private int
+@@ -153,11 +158,19 @@
+ public void
+ magic_close(struct magic_set *ms)
+ {
+-	free_mlist(ms->mlist);
+-	free(ms->o.pbuf);
+-	free(ms->o.buf);
+-	free(ms->c.li);
+-	free(ms);
++	if (ms->mlist) {
++		free_mlist(ms->mlist);
++	}
++	if (ms->o.pbuf) {
++		efree(ms->o.pbuf);
++	}
++	if (ms->o.buf) {
++		efree(ms->o.buf);
++	}
++	if (ms->c.li) {
++		efree(ms->c.li);
++	}
++	efree(ms);
+ }
+ 
+ /*
+@@ -183,21 +196,10 @@
+ 	return ml ? 0 : -1;
+ }
+ 
+-public int
+-magic_check(struct magic_set *ms, const char *magicfile)
+-{
+-	struct mlist *ml = file_apprentice(ms, magicfile, FILE_CHECK);
+-	free_mlist(ml);
+-	return ml ? 0 : -1;
+-}
+-
+ private void
+ close_and_restore(const struct magic_set *ms, const char *name, int fd,
+     const struct stat *sb)
+ {
+-	if (fd == STDIN_FILENO)
+-		return;
+-	(void) close(fd);
+ 
+ 	if ((ms->flags & MAGIC_PRESERVE_ATIME) != 0) {
+ 		/*
+@@ -224,7 +226,6 @@
+ 	}
+ }
+ 
+-#ifndef COMPILE_ONLY
+ 
+ /*
+  * find type of descriptor
+@@ -232,7 +233,7 @@
+ public const char *
+ magic_descriptor(struct magic_set *ms, int fd)
+ {
+-	return file_or_fd(ms, NULL, fd);
++	return file_or_stream(ms, NULL, NULL);
+ }
+ 
+ /*
+@@ -241,103 +242,95 @@
+ public const char *
+ magic_file(struct magic_set *ms, const char *inname)
+ {
+-	return file_or_fd(ms, inname, STDIN_FILENO);
++	return file_or_stream(ms, inname, NULL);
++}
++
++public const char *
++magic_stream(struct magic_set *ms, php_stream *stream)
++{
++	return file_or_stream(ms, NULL, stream);
+ }
+ 
+ private const char *
+-file_or_fd(struct magic_set *ms, const char *inname, int fd)
++file_or_stream(struct magic_set *ms, const char *inname, php_stream *stream)
+ {
+ 	int	rv = -1;
+ 	unsigned char *buf;
+ 	struct stat	sb;
+ 	ssize_t nbytes = 0;	/* number of bytes read from a datafile */
+-	int	ispipe = 0;
++	int no_in_stream = 0;
++	TSRMLS_FETCH();
++
++	if (!inname && !stream) {
++		return NULL;
++	}
+ 
+ 	/*
+ 	 * one extra for terminating '\0', and
+ 	 * some overlapping space for matches near EOF
+ 	 */
+ #define SLOP (1 + sizeof(union VALUETYPE))
+-	if ((buf = CAST(unsigned char *, malloc(HOWMANY + SLOP))) == NULL)
+-		return NULL;
++	buf = emalloc(HOWMANY + SLOP);
+ 
+-	if (file_reset(ms) == -1)
++	if (file_reset(ms) == -1) {
+ 		goto done;
++	}
+ 
+-	switch (file_fsmagic(ms, inname, &sb)) {
+-	case -1:		/* error */
+-		goto done;
+-	case 0:			/* nothing found */
+-		break;
+-	default:		/* matched it and printed type */
++	switch (file_fsmagic(ms, inname, &sb, stream)) {
++		case -1:		/* error */
++			goto done;
++		case 0:			/* nothing found */
++			break;
++		default:		/* matched it and printed type */
++			rv = 0;
++			goto done;
++	}
++
++	errno = 0;
++
++	if (!stream && inname) {
++		no_in_stream = 1;
++#if (PHP_MAJOR_VERSION < 6)
++		stream = php_stream_open_wrapper(inname, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
++#else
++		stream = php_stream_open_wrapper(inname, "rb", REPORT_ERRORS, NULL);
++#endif
++	}
++
++	if (!stream) {
++		if (unreadable_info(ms, sb.st_mode, inname) == -1)
++			goto done;
+ 		rv = 0;
+ 		goto done;
+ 	}
+ 
+-	if (inname == NULL) {
+-		if (fstat(fd, &sb) == 0 && S_ISFIFO(sb.st_mode))
+-			ispipe = 1;
+-	} else {
+-		int flags = O_RDONLY|O_BINARY;
+-
+-		if (stat(inname, &sb) == 0 && S_ISFIFO(sb.st_mode)) {
+-			flags |= O_NONBLOCK;
+-			ispipe = 1;
+-		}
+-
+-		errno = 0;
+-		if ((fd = open(inname, flags)) < 0) {
+-			if (unreadable_info(ms, sb.st_mode, inname) == -1)
+-				goto done;
+-			rv = 0;
+-			goto done;
+-		}
+ #ifdef O_NONBLOCK
+-		if ((flags = fcntl(fd, F_GETFL)) != -1) {
+-			flags &= ~O_NONBLOCK;
+-			(void)fcntl(fd, F_SETFL, flags);
+-		}
++/* we should be already be in non blocking mode for network socket */
+ #endif
+-	}
+ 
+ 	/*
+ 	 * try looking at the first HOWMANY bytes
+ 	 */
+-	if (ispipe) {
+-		ssize_t r = 0;
+-
+-		while ((r = sread(fd, (void *)&buf[nbytes],
+-		    (size_t)(HOWMANY - nbytes), 1)) > 0) {
+-			nbytes += r;
+-			if (r < PIPE_BUF) break;
+-		}
+-
+-		if (nbytes == 0) {
+-			/* We can not read it, but we were able to stat it. */
+-			if (unreadable_info(ms, sb.st_mode, inname) == -1)
+-				goto done;
+-			rv = 0;
+-			goto done;
+-		}
+-
+-	} else {
+-		if ((nbytes = read(fd, (char *)buf, HOWMANY)) == -1) {
+-			file_error(ms, errno, "cannot read `%s'", inname);
+-			goto done;
+-		}
++	if ((nbytes = php_stream_read(stream, (char *)buf, HOWMANY)) < 0) {
++		file_error(ms, errno, "cannot read `%s'", inname);
++		goto done;
+ 	}
+ 
+ 	(void)memset(buf + nbytes, 0, SLOP); /* NUL terminate */
+-	if (file_buffer(ms, fd, inname, buf, (size_t)nbytes) == -1)
++	if (file_buffer(ms, stream, inname, buf, (size_t)nbytes) == -1)
+ 		goto done;
+ 	rv = 0;
+ done:
+-	free(buf);
+-	close_and_restore(ms, inname, fd, &sb);
++	efree(buf);
++
++	if (no_in_stream && stream) {
++		php_stream_close(stream);
++	}
++
++	close_and_restore(ms, inname, 0, &sb);
+ 	return rv == 0 ? file_getbuffer(ms) : NULL;
+ }
+ 
+-
+ public const char *
+ magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
+ {
+@@ -345,14 +338,13 @@
+ 		return NULL;
+ 	/*
+ 	 * The main work is done here!
+-	 * We have the file name and/or the data buffer to be identified.
++	 * We have the file name and/or the data buffer to be identified. 
+ 	 */
+-	if (file_buffer(ms, -1, NULL, buf, nb) == -1) {
++	if (file_buffer(ms, NULL, NULL, buf, nb) == -1) {
+ 		return NULL;
+ 	}
+ 	return file_getbuffer(ms);
+ }
+-#endif
+ 
+ public const char *
+ magic_error(struct magic_set *ms)
+diff -u libmagic.orig/magic.h libmagic/magic.h
+--- libmagic.orig/magic.h	2009-03-17 21:52:35.000000000 +0000
++++ libmagic/magic.h	2009-12-23 19:39:50.000000000 +0000
+@@ -70,6 +70,7 @@
+ void magic_close(magic_t);
+ 
+ const char *magic_file(magic_t, const char *);
++const char *magic_stream(magic_t, php_stream *);
+ const char *magic_descriptor(magic_t, int);
+ const char *magic_buffer(magic_t, const void *, size_t);
+ 
+@@ -78,7 +79,6 @@
+ 
+ int magic_load(magic_t, const char *);
+ int magic_compile(magic_t, const char *);
+-int magic_check(magic_t, const char *);
+ int magic_errno(magic_t);
+ 
+ #ifdef __cplusplus
+diff -u libmagic.orig/patchlevel.h libmagic/patchlevel.h
+--- libmagic.orig/patchlevel.h	2009-05-06 21:32:48.000000000 +0100
++++ libmagic/patchlevel.h	2009-12-23 19:39:50.000000000 +0000
+@@ -3,23 +3,23 @@
+ 
+ /*
+  * Patchlevel file for Ian Darwin's MAGIC command.
+- * $File: patchlevel.h,v 1.74 2009/05/06 20:32:48 christos Exp $
++ * $File: patchlevel.h,v 1.68 2008/03/22 21:39:43 christos Exp $
+  *
+- * $Log: patchlevel.h,v $
+- * Revision 1.74  2009/05/06 20:32:48  christos
+- * welcome to 5.03
++ * $Log$
++ * Revision 1.4  2009/05/04 20:52:43  scottmac
++ * Update libmagic to 5.02
+  *
+- * Revision 1.73  2009/05/04 15:15:13  christos
+- * 5.02...
++ * Revision 1.3  2009/03/15 23:02:35  scottmac
++ * Update fileinfo to libmagic 5.00 and remove dependency on dirent.h on Windows
+  *
+- * Revision 1.72  2009/04/30 21:20:15  christos
+- * 5.01 we are almost here.
++ * Revision 1.2  2008/11/02 16:09:27  scottmac
++ * Update libmagic to 4.26 and add support for v6 of the magic file format.
+  *
+- * Revision 1.71  2009/01/21 19:09:42  christos
+- * file 5.0
++ * Revision 1.1  2008/07/11 14:13:50  derick
++ * - Move lib to libmagic
+  *
+- * Revision 1.70  2008/08/30 10:01:01  christos
+- * file 4.26
++ * Revision 1.1  2008/07/11 14:10:50  derick
++ * - Step one for bundling the libmagic library. Some config.m4 issues left.
+  *
+  * Revision 1.69  2008/07/02 15:27:05  christos
+  * welcome to 4.25
+diff -u libmagic.orig/print.c libmagic/print.c
+--- libmagic.orig/print.c	2009-03-17 21:52:35.000000000 +0000
++++ libmagic/print.c	2009-12-23 19:39:50.000000000 +0000
+@@ -29,6 +29,8 @@
+  * print.c - debugging printout routines
+  */
+ 
++#include "php.h"
++
+ #include "file.h"
+ 
+ #ifndef lint
+@@ -45,157 +47,21 @@
+ 
+ #define SZOF(a)	(sizeof(a) / sizeof(a[0]))
+ 
+-#ifndef COMPILE_ONLY
+-protected void
+-file_mdump(struct magic *m)
+-{
+-	private const char optyp[] = { FILE_OPS };
+-
+-	(void) fprintf(stderr, "[%u", m->lineno);
+-	(void) fprintf(stderr, ">>>>>>>> %u" + 8 - (m->cont_level & 7),
+-		       m->offset);
+-
+-	if (m->flag & INDIR) {
+-		(void) fprintf(stderr, "(%s,",
+-			       /* Note: type is unsigned */
+-			       (m->in_type < file_nnames) ? 
+-					file_names[m->in_type] : "*bad*");
+-		if (m->in_op & FILE_OPINVERSE)
+-			(void) fputc('~', stderr);
+-		(void) fprintf(stderr, "%c%u),",
+-			       ((size_t)(m->in_op & FILE_OPS_MASK) <
+-			       SZOF(optyp)) ? 
+-					optyp[m->in_op & FILE_OPS_MASK] : '?',
+-				m->in_offset);
+-	}
+-	(void) fprintf(stderr, " %s%s", (m->flag & UNSIGNED) ? "u" : "",
+-		       /* Note: type is unsigned */
+-		       (m->type < file_nnames) ? file_names[m->type] : "*bad*");
+-	if (m->mask_op & FILE_OPINVERSE)
+-		(void) fputc('~', stderr);
+-
+-	if (IS_STRING(m->type)) {
+-		if (m->str_flags) {
+-			(void) fputc('/', stderr);
+-			if (m->str_flags & STRING_COMPACT_BLANK) 
+-				(void) fputc(CHAR_COMPACT_BLANK, stderr);
+-			if (m->str_flags & STRING_COMPACT_OPTIONAL_BLANK) 
+-				(void) fputc(CHAR_COMPACT_OPTIONAL_BLANK,
+-				    stderr);
+-			if (m->str_flags & STRING_IGNORE_LOWERCASE) 
+-				(void) fputc(CHAR_IGNORE_LOWERCASE, stderr);
+-			if (m->str_flags & STRING_IGNORE_UPPERCASE) 
+-				(void) fputc(CHAR_IGNORE_UPPERCASE, stderr);
+-			if (m->str_flags & REGEX_OFFSET_START) 
+-				(void) fputc(CHAR_REGEX_OFFSET_START, stderr);
+-		}
+-		if (m->str_range)
+-			(void) fprintf(stderr, "/%u", m->str_range);
+-	}
+-	else {
+-		if ((size_t)(m->mask_op & FILE_OPS_MASK) < SZOF(optyp))
+-			(void) fputc(optyp[m->mask_op & FILE_OPS_MASK], stderr);
+-		else
+-			(void) fputc('?', stderr);
+-			
+-		if (m->num_mask) {
+-			(void) fprintf(stderr, "%.8llx",
+-			    (unsigned long long)m->num_mask);
+-		}
+-	}
+-	(void) fprintf(stderr, ",%c", m->reln);
+-
+-	if (m->reln != 'x') {
+-		switch (m->type) {
+-		case FILE_BYTE:
+-		case FILE_SHORT:
+-		case FILE_LONG:
+-		case FILE_LESHORT:
+-		case FILE_LELONG:
+-		case FILE_MELONG:
+-		case FILE_BESHORT:
+-		case FILE_BELONG:
+-			(void) fprintf(stderr, "%d", m->value.l);
+-			break;
+-		case FILE_BEQUAD:
+-		case FILE_LEQUAD:
+-		case FILE_QUAD:
+-			(void) fprintf(stderr, "%lld",
+-			    (unsigned long long)m->value.q);
+-			break;
+-		case FILE_PSTRING:
+-		case FILE_STRING:
+-		case FILE_REGEX:
+-		case FILE_BESTRING16:
+-		case FILE_LESTRING16:
+-		case FILE_SEARCH:
+-			file_showstr(stderr, m->value.s, (size_t)m->vallen);
+-			break;
+-		case FILE_DATE:
+-		case FILE_LEDATE:
+-		case FILE_BEDATE:
+-		case FILE_MEDATE:
+-			(void)fprintf(stderr, "%s,",
+-			    file_fmttime(m->value.l, 1));
+-			break;
+-		case FILE_LDATE:
+-		case FILE_LELDATE:
+-		case FILE_BELDATE:
+-		case FILE_MELDATE:
+-			(void)fprintf(stderr, "%s,",
+-			    file_fmttime(m->value.l, 0));
+-			break;
+-		case FILE_QDATE:
+-		case FILE_LEQDATE:
+-		case FILE_BEQDATE:
+-			(void)fprintf(stderr, "%s,",
+-			    file_fmttime((uint32_t)m->value.q, 1));
+-			break;
+-		case FILE_QLDATE:
+-		case FILE_LEQLDATE:
+-		case FILE_BEQLDATE:
+-			(void)fprintf(stderr, "%s,",
+-			    file_fmttime((uint32_t)m->value.q, 0));
+-			break;
+-		case FILE_FLOAT:
+-		case FILE_BEFLOAT:
+-		case FILE_LEFLOAT:
+-			(void) fprintf(stderr, "%G", m->value.f);
+-			break;
+-		case FILE_DOUBLE:
+-		case FILE_BEDOUBLE:
+-		case FILE_LEDOUBLE:
+-			(void) fprintf(stderr, "%G", m->value.d);
+-			break;
+-		case FILE_DEFAULT:
+-			/* XXX - do anything here? */
+-			break;
+-		default:
+-			(void) fputs("*bad*", stderr);
+-			break;
+-		}
+-	}
+-	(void) fprintf(stderr, ",\"%s\"]\n", m->desc);
+-}
+-#endif
+-
+ /*VARARGS*/
+ protected void
+ file_magwarn(struct magic_set *ms, const char *f, ...)
+ {
+ 	va_list va;
++	char *expanded_format;
++	TSRMLS_FETCH();
+ 
+-	/* cuz we use stdout for most, stderr here */
+-	(void) fflush(stdout); 
+-
+-	if (ms->file)
+-		(void) fprintf(stderr, "%s, %lu: ", ms->file,
+-		    (unsigned long)ms->line);
+-	(void) fprintf(stderr, "Warning: ");
+ 	va_start(va, f);
+-	(void) vfprintf(stderr, f, va);
++	vasprintf(&expanded_format, f, va);
+ 	va_end(va);
+-	(void) fputc('\n', stderr);
++	
++	php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Warning: %s", expanded_format);
++
++	free(expanded_format);
+ }
+ 
+ protected const char *
+diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
+--- libmagic.orig/readcdf.c	2009-05-06 21:48:22.000000000 +0100
++++ libmagic/readcdf.c	2009-12-23 19:39:50.000000000 +0000
+@@ -30,7 +30,11 @@
+ #endif
+ 
+ #include <stdlib.h>
++#ifdef PHP_WIN32
++#include "win32/unistd.h"
++#else
+ #include <unistd.h>
++#endif
+ #include <string.h>
+ #include <time.h>
+ #include <ctype.h>
+@@ -46,7 +50,7 @@
+ {
+ 	size_t i;
+ 	cdf_timestamp_t tp;
+-	struct timespec ts;
++	struct timeval ts;
+ 	char buf[64];
+ 	const char *str = "vnd.ms-office";
+ 	const char *s;
+@@ -106,7 +110,11 @@
+ 		case CDF_FILETIME:
+ 			tp = info[i].pi_tp;
+ 			if (tp != 0) {
++#if defined(PHP_WIN32 ) && _MSC_VER <= 1500
++				if (tp < 1000000000000000i64) {
++#else
+ 				if (tp < 1000000000000000LL) {
++#endif
+ 					char tbuf[64];
+ 					cdf_print_elapsed_time(tbuf,
+ 					    sizeof(tbuf), tp);
+@@ -115,7 +123,10 @@
+ 						return -1;
+ 				} else {
+ 					char *c, *ec;
+-					cdf_timestamp_to_timespec(&ts, tp);
++
++					if (cdf_timestamp_to_timespec(&ts, tp) == -1) {
++						return -1;
++					}
+ 					c = ctime(&ts.tv_sec);
+ 					if ((ec = strchr(c, '\n')) != NULL)
+ 						*ec = '\0';
+diff -u libmagic.orig/readelf.c libmagic/readelf.c
+--- libmagic.orig/readelf.c	2009-03-17 21:52:35.000000000 +0000
++++ libmagic/readelf.c	2009-12-23 19:39:50.000000000 +0000
+@@ -49,7 +49,7 @@
+     off_t, int *, int);
+ private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, int *,
+     int);
+-private size_t donote(struct magic_set *, void *, size_t, size_t, int,
++private size_t donote(struct magic_set *, unsigned char *, size_t, size_t, int,
+     int, size_t, int *);
+ 
+ #define	ELF_ALIGN(a)	((((a) + align - 1) / align) * align)
+@@ -364,7 +364,7 @@
+ #endif
+ 
+ private size_t
+-donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
++donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
+     int clazz, int swap, size_t align, int *flags)
+ {
+ 	Elf32_Nhdr nh32;
+@@ -374,7 +374,6 @@
+ 	int os_style = -1;
+ #endif
+ 	uint32_t namesz, descsz;
+-	unsigned char *nbuf = CAST(unsigned char *, vbuf);
+ 
+ 	(void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
+ 	offset += xnh_sizeof;
+@@ -855,20 +854,16 @@
+ 				file_badread(ms);
+ 				return -1;
+ 			}
+-			if ((nbuf = malloc((size_t)xsh_size)) == NULL) {
+-				file_error(ms, errno, "Cannot allocate memory"
+-				    " for note");
+-				return -1;
+-			}
++			nbuf = emalloc((size_t)xsh_size);
+ 			if ((noff = lseek(fd, (off_t)xsh_offset, SEEK_SET)) ==
+ 			    (off_t)-1) {
+ 				file_badread(ms);
+-				free(nbuf);
++				efree(nbuf);
+ 				return -1;
+ 			}
+ 			if (read(fd, nbuf, (size_t)xsh_size) !=
+ 			    (ssize_t)xsh_size) {
+-				free(nbuf);
++				efree(nbuf);
+ 				file_badread(ms);
+ 				return -1;
+ 			}
+@@ -884,11 +879,11 @@
+ 					break;
+ 			}
+ 			if ((lseek(fd, off, SEEK_SET)) == (off_t)-1) {
+-				free(nbuf);
++				efree(nbuf);
+ 				file_badread(ms);
+ 				return -1;
+ 			}
+-			free(nbuf);
++			efree(nbuf);
+ 			break;
+ 		case SHT_SUNW_cap:
+ 		    {
+diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
+--- libmagic.orig/softmagic.c	2009-03-27 22:42:49.000000000 +0000
++++ libmagic/softmagic.c	2009-12-23 19:39:50.000000000 +0000
+@@ -41,6 +41,11 @@
+ #include <stdlib.h>
+ #include <time.h>
+ 
++#ifndef PREG_OFFSET_CAPTURE
++# define PREG_OFFSET_CAPTURE                 (1<<8)
++#endif
++
++
+ 
+ private int match(struct magic_set *, struct magic *, uint32_t,
+     const unsigned char *, size_t, int);
+@@ -125,9 +130,9 @@
+ 
+ 		if ((m->flag & BINTEST) != mode) {
+ 			/* Skip sub-tests */
+-			while (magic[magindex + 1].cont_level != 0 &&
+-			       ++magindex < nmagic)
+-				continue;
++			while (magindex < nmagic - 1 && magic[magindex + 1].cont_level != 0) {
++				magindex++;
++			}
+ 			continue; /* Skip to next top-level test*/
+ 		}
+ 
+@@ -162,9 +167,9 @@
+ 			 * main entry didn't match,
+ 			 * flush its continuations
+ 			 */
+-			while (magindex < nmagic - 1 &&
+-			    magic[magindex + 1].cont_level != 0)
++			while (magindex < nmagic - 1 && magic[magindex + 1].cont_level != 0) {
+ 				magindex++;
++			}
+ 			continue;
+ 		}
+ 
+@@ -191,8 +196,8 @@
+ 		if (file_check_mem(ms, ++cont_level) == -1)
+ 			return -1;
+ 
+-		while (magic[magindex+1].cont_level != 0 &&
+-		    ++magindex < nmagic) {
++		while (magindex < nmagic - 1 && magic[magindex + 1].cont_level != 0) {
++			magindex++;
+ 			m = &magic[magindex];
+ 			ms->line = m->lineno; /* for messages */
+ 
+@@ -207,8 +212,7 @@
+ 			}
+ 			ms->offset = m->offset;
+ 			if (m->flag & OFFADD) {
+-				ms->offset +=
+-				    ms->c.li[cont_level - 1].off;
++				ms->offset += ms->c.li[cont_level - 1].off;
+ 			}
+ 
+ #ifdef ENABLE_CONDITIONALS
+@@ -313,44 +317,22 @@
+ private int
+ check_fmt(struct magic_set *ms, struct magic *m)
+ {
+-	regex_t rx;
+-	int rc;
+-
+-	if (strchr(m->desc, '%') == NULL)
++	pcre *pce;
++	int re_options;
++	pcre_extra *re_extra;
++	TSRMLS_FETCH();
++	
++	if (strchr(m->desc, '%') == NULL) {
+ 		return 0;
+-
+-	rc = regcomp(&rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB);
+-	if (rc) {
+-		char errmsg[512];
+-		(void)regerror(rc, &rx, errmsg, sizeof(errmsg));
+-		file_magerror(ms, "regex error %d, (%s)", rc, errmsg);
++	}
++	
++	if ((pce = pcre_get_compiled_regex("~%[-0-9.]*s~", &re_extra, &re_options TSRMLS_CC)) == NULL) {
+ 		return -1;
+ 	} else {
+-		rc = regexec(&rx, m->desc, 0, 0, 0);
+-		regfree(&rx);
+-		return !rc;
++	 	return !pcre_exec(pce, re_extra, m->desc, strlen(m->desc), 0, re_options, NULL, 0);
+ 	}
+ }
+ 
+-#ifndef HAVE_STRNDUP
+-char * strndup(const char *, size_t);
+-
+-char *
+-strndup(const char *str, size_t n)
+-{
+-	size_t len;
+-	char *copy;
+-
+-	for (len = 0; len < n && str[len]; len++)
+-		continue;
+-	if ((copy = malloc(len + 1)) == NULL)
+-		return NULL;
+-	(void)memcpy(copy, str, len);
+-	copy[len] = '\0';
+-	return copy;
+-}
+-#endif /* HAVE_STRNDUP */
+-
+ private int32_t
+ mprint(struct magic_set *ms, struct magic *m)
+ {
+@@ -533,13 +515,10 @@
+ 		char *cp;
+ 		int rval;
+ 
+-		cp = strndup((const char *)ms->search.s, ms->search.rm_len);
+-		if (cp == NULL) {
+-			file_oomem(ms, ms->search.rm_len);
+-			return -1;
+-		}
++		cp = estrndup((const char *)ms->search.s, ms->search.rm_len);
++
+ 		rval = file_printf(ms, m->desc, cp);
+-		free(cp);
++		efree(cp);
+ 
+ 		if (rval == -1)
+ 			return -1;
+@@ -733,16 +712,16 @@
+ 	if (m->num_mask) \
+ 		switch (m->mask_op & FILE_OPS_MASK) { \
+ 		case FILE_OPADD: \
+-			p->fld += cast m->num_mask; \
++			p->fld += cast (int64_t)m->num_mask; \
+ 			break; \
+ 		case FILE_OPMINUS: \
+-			p->fld -= cast m->num_mask; \
++			p->fld -= cast (int64_t)m->num_mask; \
+ 			break; \
+ 		case FILE_OPMULTIPLY: \
+-			p->fld *= cast m->num_mask; \
++			p->fld *= cast (int64_t)m->num_mask; \
+ 			break; \
+ 		case FILE_OPDIVIDE: \
+-			p->fld /= cast m->num_mask; \
++			p->fld /= cast (int64_t)m->num_mask; \
+ 			break; \
+ 		} \
+ 
+@@ -1033,16 +1012,13 @@
+ 
+ 	if ((ms->flags & MAGIC_DEBUG) != 0) {
+ 		mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
+-#ifndef COMPILE_ONLY
+-		file_mdump(m);
+-#endif
+ 	}
+ 
+ 	if (m->flag & INDIR) {
+ 		int off = m->in_offset;
+ 		if (m->in_op & FILE_OPINDIRECT) {
+-			const union VALUETYPE *q = CAST(const union VALUETYPE *,
+-			    ((const void *)(s + offset + off)));
++			const union VALUETYPE *q =
++			    ((const void *)(s + offset + off));
+ 			switch (m->in_type) {
+ 			case FILE_BYTE:
+ 				off = q->b;
+@@ -1522,9 +1498,6 @@
+ 		if ((ms->flags & MAGIC_DEBUG) != 0) {
+ 			mdebug(offset, (char *)(void *)p,
+ 			    sizeof(union VALUETYPE));
+-#ifndef COMPILE_ONLY
+-			file_mdump(m);
+-#endif
+ 		}
+ 	}
+ 
+@@ -1672,6 +1645,66 @@
+ 	return file_strncmp(a, b, len, flags);
+ }
+ 
++private void
++convert_libmagic_pattern(zval *pattern, int options)
++{
++		int i, j=0;
++		char *t;
++
++		t = (char *) safe_emalloc(Z_STRLEN_P(pattern), 2, 5);
++		memset(t, '\0', sizeof(t));
++		
++		t[j++] = '~';
++		
++		for (i=0; i<Z_STRLEN_P(pattern); i++, j++) {
++			switch (Z_STRVAL_P(pattern)[i]) {
++				case '?':
++					t[j] = '.';
++					break;
++				case '*':
++					t[j++] = '.';
++					t[j] = '*';
++					break;
++				case '.':
++					t[j++] = '\\';
++					t[j] = '.';
++					break;
++				case '\\':
++					t[j++] = '\\';
++					t[j] = '\\';
++					break;
++				case '(':
++					t[j++] = '\\';
++					t[j] = '(';
++					break;
++				case ')':
++					t[j++] = '\\';
++					t[j] = ')';
++					break;
++				case '~':
++					t[j++] = '\\';
++					t[j] = '~';
++					break;
++				default:
++					t[j] = Z_STRVAL_P(pattern)[i];
++					break;
++			}
++		}
++		t[j++] = '~';
++	
++		if (options & PCRE_CASELESS) 
++			t[j++] = 'm';
++	
++		if (options & PCRE_MULTILINE)
++			t[j++] = 'i';
++
++		t[j]=0;
++	
++		Z_STRVAL_P(pattern) = t;
++		Z_STRLEN_P(pattern) = j;
++
++}
++
+ private int
+ magiccheck(struct magic_set *ms, struct magic *m)
+ {
+@@ -1828,67 +1861,162 @@
+ 		break;
+ 	}
+ 	case FILE_REGEX: {
+-		int rc;
+-		regex_t rx;
+-		char errmsg[512];
+-
+-		if (ms->search.s == NULL)
+-			return 0;
+-
+-		l = 0;
+-		rc = regcomp(&rx, m->value.s,
+-		    REG_EXTENDED|REG_NEWLINE|
+-		    ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0));
+-		if (rc) {
+-			(void)regerror(rc, &rx, errmsg, sizeof(errmsg));
+-			file_magerror(ms, "regex error %d, (%s)",
+-			    rc, errmsg);
+-			v = (uint64_t)-1;
+-		}
+-		else {
+-			regmatch_t pmatch[1];
+-#ifndef REG_STARTEND
+-#define	REG_STARTEND	0
+-			size_t l = ms->search.s_len - 1;
+-			char c = ms->search.s[l];
+-			((char *)(intptr_t)ms->search.s)[l] = '\0';
++		zval *pattern;
++		int options = 0;
++		pcre_cache_entry *pce;
++		TSRMLS_FETCH();
++		
++		MAKE_STD_ZVAL(pattern);
++		ZVAL_STRINGL(pattern, (char *)m->value.s, m->vallen, 0);
++	
++		options |= PCRE_MULTILINE;
++		
++		if (m->str_flags & STRING_IGNORE_CASE) {
++			options |= PCRE_CASELESS;
++		}
++		
++		convert_libmagic_pattern(pattern, options);
++		
++#if (PHP_MAJOR_VERSION < 6)
++		if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) {
+ #else
+-			pmatch[0].rm_so = 0;
+-			pmatch[0].rm_eo = ms->search.s_len;
++		if ((pce = pcre_get_compiled_regex_cache(IS_STRING, Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) {
+ #endif
+-			rc = regexec(&rx, (const char *)ms->search.s,
+-			    1, pmatch, REG_STARTEND);
+-#if REG_STARTEND == 0
+-			((char *)(intptr_t)ms->search.s)[l] = c;
++			zval_dtor(pattern);
++			FREE_ZVAL(pattern);
++			return -1;
++		} else {
++			/* pce now contains the compiled regex */
++			zval *retval;
++			zval *subpats;
++			char *haystack;
++			
++			MAKE_STD_ZVAL(retval);
++			ALLOC_INIT_ZVAL(subpats);
++			
++			/* Cut the search len from haystack, equals to REG_STARTEND */
++			haystack = estrndup(ms->search.s, ms->search.s_len);
++
++			/* match v = 0, no match v = 1 */
++#if (PHP_MAJOR_VERSION < 6)
++			php_pcre_match_impl(pce, haystack, ms->search.s_len, retval, subpats, 1, 1, PREG_OFFSET_CAPTURE, 0 TSRMLS_CC);
++#else			
++			php_pcre_match_impl(pce, IS_STRING, haystack, ms->search.s_len, retval, subpats, 1, 1, PREG_OFFSET_CAPTURE, 0 TSRMLS_CC);
+ #endif
+-			switch (rc) {
+-			case 0:
+-				ms->search.s += (int)pmatch[0].rm_so;
+-				ms->search.offset += (size_t)pmatch[0].rm_so;
+-				ms->search.rm_len =
+-				    (size_t)(pmatch[0].rm_eo - pmatch[0].rm_so);
+-				v = 0;
+-				break;
++			/* Free haystack */
++			efree(haystack);
++			
++			if (Z_LVAL_P(retval) < 0) {
++				zval_ptr_dtor(&subpats);
++				FREE_ZVAL(retval);
++				zval_dtor(pattern);
++				FREE_ZVAL(pattern);
++				return -1;
++			} else if ((Z_LVAL_P(retval) > 0) && (Z_TYPE_P(subpats) == IS_ARRAY)) {
++				
++				/* Need to fetch global match which equals pmatch[0] */
++				HashTable *ht = Z_ARRVAL_P(subpats);
++				HashPosition outer_pos;
++				zval *pattern_match = NULL, *pattern_offset = NULL;
++				
++				zend_hash_internal_pointer_reset_ex(ht, &outer_pos); 
++				
++				if (zend_hash_has_more_elements_ex(ht, &outer_pos) == SUCCESS &&
++					zend_hash_move_forward_ex(ht, &outer_pos)) {
++					
++					zval **ppzval;
++					
++					/* The first element (should be) is the global match 
++					   Need to move to the inner array to get the global match */
++					
++					if (zend_hash_get_current_data_ex(ht, (void**)&ppzval, &outer_pos) != FAILURE) { 
++						
++						HashTable *inner_ht;
++						HashPosition inner_pos;
++						zval **match, **offset;
++						zval tmpcopy = **ppzval, matchcopy, offsetcopy;
++						
++						zval_copy_ctor(&tmpcopy); 
++						INIT_PZVAL(&tmpcopy);
++						
++						inner_ht = Z_ARRVAL(tmpcopy);
++						
++						/* If everything goes according to the master plan
++						   tmpcopy now contains two elements:
++						   0 = the match
++						   1 = starting position of the match */
++						zend_hash_internal_pointer_reset_ex(inner_ht, &inner_pos); 
++						
++						if (zend_hash_has_more_elements_ex(inner_ht, &inner_pos) == SUCCESS &&
++							zend_hash_move_forward_ex(inner_ht, &inner_pos)) {
++						
++							if (zend_hash_get_current_data_ex(inner_ht, (void**)&match, &inner_pos) != FAILURE) { 
++									
++								matchcopy = **match;
++								zval_copy_ctor(&matchcopy);
++								INIT_PZVAL(&matchcopy);
++								convert_to_string(&matchcopy); 
++								
++								MAKE_STD_ZVAL(pattern_match);
++								Z_STRVAL_P(pattern_match) = (char *)Z_STRVAL(matchcopy);
++								Z_STRLEN_P(pattern_match) = Z_STRLEN(matchcopy);
++								Z_TYPE_P(pattern_match) = IS_STRING; 
++
++								zval_dtor(&matchcopy);
++							}
++						}
++						
++						if (zend_hash_has_more_elements_ex(inner_ht, &inner_pos) == SUCCESS &&
++							zend_hash_move_forward_ex(inner_ht, &inner_pos)) {
++							
++							if (zend_hash_get_current_data_ex(inner_ht, (void**)&offset, &inner_pos) != FAILURE) { 
++								
++								offsetcopy = **offset;
++								zval_copy_ctor(&offsetcopy);
++								INIT_PZVAL(&offsetcopy);
++								convert_to_long(&offsetcopy); 
++								
++								MAKE_STD_ZVAL(pattern_offset);
++								Z_LVAL_P(pattern_offset) = Z_LVAL(offsetcopy);
++								Z_TYPE_P(pattern_offset) = IS_LONG;
++								
++								zval_dtor(&offsetcopy);
++							}
++						}
++						zval_dtor(&tmpcopy); 	
++					}
++					
++					if ((pattern_match != NULL) && (pattern_offset != NULL)) {
++						ms->search.s += (int)Z_LVAL_P(pattern_offset); /* this is where the match starts */
++						ms->search.offset += (size_t)Z_LVAL_P(pattern_offset); /* this is where the match starts as size_t */
++						ms->search.rm_len = Z_STRLEN_P(pattern_match) /* This is the length of the matched pattern */;
++						v = 0;
++						
++						efree(pattern_match);
++						efree(pattern_offset);
++						
++					} else {
++						zval_ptr_dtor(&subpats);
++						FREE_ZVAL(retval);
++						zval_dtor(pattern);
++						FREE_ZVAL(pattern);
++						return -1;
++					}					
++				}
+ 
+-			case REG_NOMATCH:
++				
++			} else {
+ 				v = 1;
+-				break;
+-
+-			default:
+-				(void)regerror(rc, &rx, errmsg, sizeof(errmsg));
+-				file_magerror(ms, "regexec error %d, (%s)",
+-				    rc, errmsg);
+-				v = (uint64_t)-1;
+-				break;
+ 			}
+-			regfree(&rx);
++			zval_ptr_dtor(&subpats);
++			FREE_ZVAL(retval);
+ 		}
+-		if (v == (uint64_t)-1)
+-			return -1;
+-		break;
++		zval_dtor(pattern);
++		FREE_ZVAL(pattern);
++		break;	
+ 	}
+ 	case FILE_INDIRECT:
+-		return 1;
++		return 1;	 
+ 	default:
+ 		file_magerror(ms, "invalid type %d in magiccheck()", m->type);
+ 		return -1;
+@@ -1900,7 +2028,7 @@
+ 	case 'x':
+ 		if ((ms->flags & MAGIC_DEBUG) != 0)
+ 			(void) fprintf(stderr, "%llu == *any* = 1\n",
+-			    (unsigned long long)v);
++			    (uint64_t)v);
+ 		matched = 1;
+ 		break;
+ 
+@@ -1908,7 +2036,7 @@
+ 		matched = v != l;
+ 		if ((ms->flags & MAGIC_DEBUG) != 0)
+ 			(void) fprintf(stderr, "%llu != %llu = %d\n",
+-			    (unsigned long long)v, (unsigned long long)l,
++			    (uint64_t)v, (uint64_t)l,
+ 			    matched);
+ 		break;
+ 
+@@ -1916,7 +2044,7 @@
+ 		matched = v == l;
+ 		if ((ms->flags & MAGIC_DEBUG) != 0)
+ 			(void) fprintf(stderr, "%llu == %llu = %d\n",
+-			    (unsigned long long)v, (unsigned long long)l,
++			    (uint64_t)v, (uint64_t)l,
+ 			    matched);
+ 		break;
+ 
+@@ -1925,14 +2053,14 @@
+ 			matched = v > l;
+ 			if ((ms->flags & MAGIC_DEBUG) != 0)
+ 				(void) fprintf(stderr, "%llu > %llu = %d\n",
+-				    (unsigned long long)v,
+-				    (unsigned long long)l, matched);
++				    (uint64_t)v,
++				    (uint64_t)l, matched);
+ 		}
+ 		else {
+ 			matched = (int64_t) v > (int64_t) l;
+ 			if ((ms->flags & MAGIC_DEBUG) != 0)
+ 				(void) fprintf(stderr, "%lld > %lld = %d\n",
+-				    (long long)v, (long long)l, matched);
++				    (uint64_t)v, (uint64_t)l, matched);
+ 		}
+ 		break;
+ 
+@@ -1941,14 +2069,14 @@
+ 			matched = v < l;
+ 			if ((ms->flags & MAGIC_DEBUG) != 0)
+ 				(void) fprintf(stderr, "%llu < %llu = %d\n",
+-				    (unsigned long long)v,
+-				    (unsigned long long)l, matched);
++				    (uint64_t)v,
++				    (uint64_t)l, matched);
+ 		}
+ 		else {
+ 			matched = (int64_t) v < (int64_t) l;
+ 			if ((ms->flags & MAGIC_DEBUG) != 0)
+ 				(void) fprintf(stderr, "%lld < %lld = %d\n",
+-				       (long long)v, (long long)l, matched);
++				       (int64_t)v, (int64_t)l, matched);
+ 		}
+ 		break;
+ 
+@@ -1956,16 +2084,16 @@
+ 		matched = (v & l) == l;
+ 		if ((ms->flags & MAGIC_DEBUG) != 0)
+ 			(void) fprintf(stderr, "((%llx & %llx) == %llx) = %d\n",
+-			    (unsigned long long)v, (unsigned long long)l,
+-			    (unsigned long long)l, matched);
++			    (uint64_t)v, (uint64_t)l,
++			    (uint64_t)l, matched);
+ 		break;
+ 
+ 	case '^':
+ 		matched = (v & l) != l;
+ 		if ((ms->flags & MAGIC_DEBUG) != 0)
+ 			(void) fprintf(stderr, "((%llx & %llx) != %llx) = %d\n",
+-			    (unsigned long long)v, (unsigned long long)l,
+-			    (unsigned long long)l, matched);
++			    (uint64_t)v, (uint64_t)l,
++			    (uint64_t)l, matched);
+ 		break;
+ 
+ 	default:
diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c
index 86b431f..ffa2cb5 100644
--- a/ext/fileinfo/libmagic/apprentice.c
+++ b/ext/fileinfo/libmagic/apprentice.c
@@ -34,7 +34,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.132 2008/03/28 18:19:30 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.151 2009/03/18 15:19:23 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -44,7 +44,7 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1.132 2008/03/28 18:19:30 christos Exp $")
 #ifdef PHP_WIN32
 #include "win32/unistd.h"
 #if _MSC_VER <= 1300
-#include "win32/php_strtoi64.h"
+# include "win32/php_strtoi64.h"
 #endif
 #define strtoull _strtoui64
 #else
@@ -55,7 +55,9 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1.132 2008/03/28 18:19:30 christos Exp $")
 #include <assert.h>
 #include <ctype.h>
 #include <fcntl.h>
-
+#ifndef PHP_WIN32
+#include <dirent.h>
+#endif
 
 #define	EATAB {while (isascii((unsigned char) *l) && \
 		      isspace((unsigned char) *l))  ++l;}
@@ -609,7 +611,11 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
 	} else {
 
 		/* read and parse this file */
+#if (PHP_MAJOR_VERSION < 6)
 		for (ms->line = 1; (line = php_stream_get_line(stream, buffer , BUFSIZ, &line_len)) != NULL; ms->line++) {
+#else		
+		for (ms->line = 1; (line = php_stream_get_line(stream, ZSTR(buffer), BUFSIZ, &line_len)) != NULL; ms->line++) {
+#endif
 			if (line_len == 0) /* null line, garbage, etc */
 				continue;
 
@@ -851,9 +857,9 @@ file_signextend(struct magic_set *ms, struct magic *m, uint64_t v)
 		case FILE_INDIRECT:
 			break;
 		default:
-			if (ms->flags & MAGIC_CHECK) {
-			    file_magwarn(ms, "cannot happen: m->type=%d\n", m->type);
-			}
+			if (ms->flags & MAGIC_CHECK)
+			    file_magwarn(ms, "cannot happen: m->type=%d\n",
+				    m->type);
 			return ~0U;
 		}
 	}
@@ -1669,7 +1675,7 @@ check_format(struct magic_set *ms, struct magic *m)
 		 */
 		file_magwarn(ms, "Printf format `%c' is not valid for type "
 		    "`%s' in description `%s'", *ptr ? *ptr : '?',
-            file_names[m->type], m->desc);
+		    file_names[m->type], m->desc);
 		return -1;
 	}
 	
@@ -2114,7 +2120,7 @@ internal_loaded:
 	}
 
 	if (dbname) {
-		free(dbname);
+		efree(dbname);
 	}
 	return ret;
 
@@ -2131,7 +2137,7 @@ error1:
 	}
 error2:
 	if (dbname) {
-		free(dbname);
+		efree(dbname);
 	}
 	return -1;
 }
@@ -2189,7 +2195,7 @@ apprentice_compile(struct magic_set *ms, struct magic **magicp,
 
 	rv = 0;
 out:
-	free(dbname);
+	efree(dbname);
 	return rv;
 }
 
@@ -2202,6 +2208,7 @@ mkdbname(struct magic_set *ms, const char *fn, int strip)
 {
 	const char *p, *q;
 	char *buf;
+	TSRMLS_FETCH();
 
 	if (strip) {
 		if ((p = strrchr(fn, '/')) != NULL)
@@ -2223,14 +2230,14 @@ mkdbname(struct magic_set *ms, const char *fn, int strip)
 	q++;
 	/* Compatibility with old code that looked in .mime */
 	if (ms->flags & MAGIC_MIME) {
-		asprintf(&buf, "%.*s.mime%s", (int)(q - fn), fn, ext);
-		if (access(buf, R_OK) != -1) {
+		spprintf(&buf, MAXPATHLEN, "%.*s.mime%s", (int)(q - fn), fn, ext);
+		if (VCWD_ACCESS(buf, R_OK) != -1) {
 			ms->flags &= MAGIC_MIME_TYPE;
 			return buf;
 		}
-		free(buf);
+		efree(buf);
 	}
-	asprintf(&buf, "%.*s%s", (int)(q - fn), fn, ext);
+	spprintf(&buf, MAXPATHLEN, "%.*s%s", (int)(q - fn), fn, ext);
 
 	/* Compatibility with old code that looked in .mime */
 	if (strstr(p, ".mime") != NULL)
diff --git a/ext/fileinfo/libmagic/apptype.c b/ext/fileinfo/libmagic/apptype.c
index 85136ed..31b8095 100644
--- a/ext/fileinfo/libmagic/apptype.c
+++ b/ext/fileinfo/libmagic/apptype.c
@@ -27,10 +27,9 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: apptype.c,v 1.7 2007/01/12 17:38:27 christos Exp $")
+FILE_RCSID("@(#)$File: apptype.c,v 1.11 2009/02/04 18:24:32 christos Exp $")
 #endif /* lint */
 
-
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/ext/fileinfo/libmagic/ascmagic.c b/ext/fileinfo/libmagic/ascmagic.c
index 4fee8a8..e73b26f 100644
--- a/ext/fileinfo/libmagic/ascmagic.c
+++ b/ext/fileinfo/libmagic/ascmagic.c
@@ -2,7 +2,7 @@
  * Copyright (c) Ian F. Darwin 1986-1995.
  * Software written by Ian F. Darwin and others;
  * maintained 1995-present by Christos Zoulas and others.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -12,7 +12,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- *  
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -36,7 +36,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: ascmagic.c,v 1.62 2008/03/01 22:21:48 rrt Exp $")
+FILE_RCSID("@(#)$File: ascmagic.c,v 1.75 2009/02/03 20:27:51 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -66,14 +66,14 @@ trim_nuls(const unsigned char *buf, size_t nbytes)
 {
 	while (nbytes > 1 && buf[nbytes - 1] == '\0')
 		nbytes--;
- 
+
 	return nbytes;
 }
 
 protected int
 file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
 {
-	unichar *ubuf = NULL;	
+	unichar *ubuf = NULL;
 	size_t ulen;
 	int rv = 1;
 
@@ -264,7 +264,7 @@ subtype_identified:
 			if (file_printf(ms, ", with") == -1)
 				goto done;
 
-			if (n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0)			{
+			if (n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0) {
 				if (file_printf(ms, " no") == -1)
 					goto done;
 			} else {
diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c
index eecfa1e..a3b4a11 100644
--- a/ext/fileinfo/libmagic/cdf.c
+++ b/ext/fileinfo/libmagic/cdf.c
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.17 2009/02/03 20:27:51 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.30 2009/05/06 14:29:47 christos Exp $")
 #endif
 
 #include <assert.h>
@@ -237,6 +237,19 @@ cdf_unpack_dir(cdf_directory_t *d, char *buf)
 	CDF_UNPACK(d->d_unused0);
 }
 
+static int
+cdf_check_stream_offset(const cdf_stream_t *sst, const void *p, size_t tail)
+{
+	const char *b = (const char *)sst->sst_tab;
+	const char *e = ((const char *)p) + tail;
+	if (e >= b && (size_t)(e - b) < sst->sst_dirlen * sst->sst_len)
+		return 0;
+	DPRINTF((stderr, "offset begin %p end %p %zu >= %zu\n", b, e,
+	    (size_t)(e - b), sst->sst_dirlen * sst->sst_len));
+	errno = EFTYPE;
+	return -1;
+}
+
 static ssize_t
 cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)
 {
@@ -264,7 +277,6 @@ cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)
 	return (ssize_t)len;
 }
 
-
 int
 cdf_read_header(const cdf_info_t *info, cdf_header_t *h)
 {
@@ -332,15 +344,15 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
 			break;
 
 #define CDF_SEC_LIMIT (UINT32_MAX / (4 * ss))
-	if (h->h_num_sectors_in_master_sat > CDF_SEC_LIMIT ||
-	    i > CDF_SEC_LIMIT / nsatpersec) {
+	if (h->h_num_sectors_in_master_sat > CDF_SEC_LIMIT / nsatpersec ||
+	    i > CDF_SEC_LIMIT) {
 		DPRINTF(("Number of sectors in master SAT too big %u %zu\n",
 		    h->h_num_sectors_in_master_sat, i));
 		errno = EFTYPE;
 		return -1;
 	}
 
-	sat->sat_len = h->h_num_sectors_in_master_sat + i * nsatpersec;
+	sat->sat_len = h->h_num_sectors_in_master_sat * nsatpersec + i;
 	DPRINTF(("sat_len = %zu ss = %zu\n", sat->sat_len, ss));
 	if ((sat->sat_tab = calloc(sat->sat_len, ss)) == NULL)
 		return -1;
@@ -360,6 +372,8 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
 
 	mid = h->h_secid_first_sector_in_master_sat;
 	for (j = 0; j < h->h_num_sectors_in_master_sat; j++) {
+		if (mid < 0)
+			goto out;
 		if (j >= CDF_LOOP_LIMIT) {
 			DPRINTF(("Reading master sector loop limit"));
 			errno = EFTYPE;
@@ -371,10 +385,8 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
 		}
 		for (k = 0; k < nsatpersec; k++, i++) {
 			sec = CDF_TOLE4(msa[k]);
-			if (sec < 0) {
-				sat->sat_len = i;
-				break;
-			}
+			if (sec < 0)
+				goto out;
 			if (i >= sat->sat_len) {
 			    DPRINTF(("Out of bounds reading MSA %u >= %u",
 				i, sat->sat_len));
@@ -390,6 +402,8 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
 		}
 		mid = CDF_TOLE4(msa[nsatpersec]);
 	}
+out:
+	sat->sat_len = i;
 	free(msa);
 	return 0;
 out2:
@@ -478,7 +492,7 @@ cdf_read_short_sector_chain(const cdf_header_t *h,
 	scn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h));
 	scn->sst_dirlen = len;
 
-	if (scn->sst_len == (size_t)-1)
+	if (sst->sst_tab == NULL || scn->sst_len == (size_t)-1)
 		return -1;
 
 	scn->sst_tab = calloc(scn->sst_len, ss);
@@ -629,22 +643,21 @@ cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h,
 			break;
 
 	/* If the it is not there, just fake it; some docs don't have it */
-	if (i == dir->dir_len) {
-		scn->sst_tab = NULL;
-		scn->sst_len = 0;
-		return 0;
-	}
+	if (i == dir->dir_len)
+		goto out;
 	d = &dir->dir_tab[i];
 
 	/* If the it is not there, just fake it; some docs don't have it */
-	if (d->d_stream_first_sector < 0) {
-		scn->sst_tab = NULL;
-		scn->sst_len = 0;
-		return 0;
-	}
+	if (d->d_stream_first_sector < 0)
+		goto out;
 
 	return  cdf_read_long_sector_chain(info, h, sat,
 	    d->d_stream_first_sector, d->d_size, scn);
+out:
+	scn->sst_tab = NULL;
+	scn->sst_len = 0;
+	scn->sst_dirlen = 0;
+	return 0;
 }
 
 static int
@@ -697,15 +710,27 @@ cdf_read_property_info(const cdf_stream_t *sst, uint32_t offs,
 	size_t i, o, nelements, j;
 	cdf_property_info_t *inp;
 
+	if (offs > UINT32_MAX / 4) {
+		errno = EFTYPE;
+		goto out;
+	}
 	shp = (const void *)((const char *)sst->sst_tab + offs);
+	if (cdf_check_stream_offset(sst, shp, sizeof(*shp)) == -1)
+		goto out;
 	sh.sh_len = CDF_TOLE4(shp->sh_len);
+#define CDF_SHLEN_LIMIT (UINT32_MAX / 8)
+	if (sh.sh_len > CDF_SHLEN_LIMIT) {
+		errno = EFTYPE;
+		goto out;
+	}
 	sh.sh_properties = CDF_TOLE4(shp->sh_properties);
-#define CDF_PROP_LIM (UINT32_MAX / (4 * sizeof(*inp)))
-	if (sh.sh_properties > CDF_PROP_LIM)
+#define CDF_PROP_LIMIT (UINT32_MAX / (4 * sizeof(*inp)))
+	if (sh.sh_properties > CDF_PROP_LIMIT)
 		goto out;
-	DPRINTF(("section len: %u properties %u\n", sh.sh_len,	    sh.sh_properties));
+	DPRINTF(("section len: %u properties %u\n", sh.sh_len,
+	    sh.sh_properties));
 	if (*maxcount) {
-		if (*maxcount > CDF_PROP_LIM)
+		if (*maxcount > CDF_PROP_LIMIT)
 			goto out;
 		*maxcount += sh.sh_properties;
 		inp = realloc(*info, *maxcount * sizeof(*inp));
@@ -720,6 +745,8 @@ cdf_read_property_info(const cdf_stream_t *sst, uint32_t offs,
 	*count += sh.sh_properties;
 	p = (const void *)((const char *)sst->sst_tab + offs + sizeof(sh));
 	e = (const void *)(((const char *)shp) + sh.sh_len);
+	if (cdf_check_stream_offset(sst, e, 0) == -1)
+		goto out;
 	for (i = 0; i < sh.sh_properties; i++) {
 		q = (const uint32_t *)((const char *)p +
 		    CDF_TOLE4(p[(i << 1) + 1])) - 2;
@@ -777,8 +804,8 @@ cdf_read_property_info(const cdf_stream_t *sst, uint32_t offs,
 		case CDF_LENGTH32_STRING:
 			if (nelements > 1) {
 				size_t nelem = inp - *info;
-				if (*maxcount > CDF_PROP_LIM
-				    || nelements > CDF_PROP_LIM)
+				if (*maxcount > CDF_PROP_LIMIT
+				    || nelements > CDF_PROP_LIMIT)
 					goto out;
 				*maxcount += nelements;
 				inp = realloc(*info, *maxcount * sizeof(*inp));
@@ -832,6 +859,9 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, cdf_summary_info_header_t *ssi,
 	const cdf_section_declaration_t *sd = (const void *)
 	    ((const char *)sst->sst_tab + CDF_SECTION_DECLARATION_OFFSET);
 
+	if (cdf_check_stream_offset(sst, si, sizeof(*si)) == -1 ||
+	    cdf_check_stream_offset(sst, sd, sizeof(*sd)) == -1)
+		return -1;
 	ssi->si_byte_order = CDF_TOLE2(si->si_byte_order);
 	ssi->si_os_version = CDF_TOLE2(si->si_os_version);
 	ssi->si_os = CDF_TOLE2(si->si_os);
@@ -946,11 +976,13 @@ cdf_dump_header(const cdf_header_t *h)
 	size_t i;
 
 #define DUMP(a, b) (void)fprintf(stderr, "%40.40s = " a "\n", # b, h->h_ ## b)
+#define DUMP2(a, b) (void)fprintf(stderr, "%40.40s = " a " (" a ")\n", # b, \
+    h->h_ ## b, 1 << h->h_ ## b)
 	DUMP("%d", revision);
 	DUMP("%d", version);
 	DUMP("0x%x", byte_order);
-	DUMP("%d", sec_size_p2);
-	DUMP("%d", short_sec_size_p2);
+	DUMP2("%d", sec_size_p2);
+	DUMP2("%d", short_sec_size_p2);
 	DUMP("%d", num_sectors_in_sat);
 	DUMP("%d", secid_first_directory);
 	DUMP("%d", min_size_standard_stream);
@@ -1202,7 +1234,7 @@ main(int argc, char *argv[])
 #endif
 
 
-		if (cdf_read_summary_info(&inf, &h, &sat, &ssat, &sst, &dir,
+		if (cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
 		    &scn) == -1)
 			err(1, "Cannot read summary info");
 #ifdef CDF_DEBUG
diff --git a/ext/fileinfo/libmagic/cdf_time.c b/ext/fileinfo/libmagic/cdf_time.c
index ac416ea..3637296 100644
--- a/ext/fileinfo/libmagic/cdf_time.c
+++ b/ext/fileinfo/libmagic/cdf_time.c
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf_time.c,v 1.5 2009/02/03 20:27:51 christos Exp $")
+FILE_RCSID("@(#)$File: cdf_time.c,v 1.6 2009/03/10 11:44:29 christos Exp $")
 #endif
 
 #include <time.h>
diff --git a/ext/fileinfo/libmagic/compress.c b/ext/fileinfo/libmagic/compress.c
index 0678665..de4de34 100644
--- a/ext/fileinfo/libmagic/compress.c
+++ b/ext/fileinfo/libmagic/compress.c
@@ -32,12 +32,11 @@
  *	uncompress(method, old, n, newch) - uncompress old into new, 
  *					    using method, return sizeof new
  */
-
 #include "config.h"
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.56 2008/02/07 00:58:52 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.63 2009/03/23 14:21:51 christos Exp $")
 #endif
 
 #include "magic.h"
@@ -89,7 +88,6 @@ private const struct {
 
 #define NODATA ((size_t)~0)
 
-
 private ssize_t swrite(int, const void *, size_t);
 #ifdef PHP_FILEINFO_UNCOMPRESS
 private size_t uncompressbuf(struct magic_set *, int, size_t,
@@ -107,10 +105,13 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,
 	size_t i, nsz;
 	int rv = 0;
 	int mime = ms->flags & MAGIC_MIME;
+	size_t ncompr;
 
 	if ((ms->flags & MAGIC_COMPRESS) == 0)
 		return 0;
 
+	ncompr = sizeof(compr) / sizeof(compr[0]);
+
 	for (i = 0; i < ncompr; i++) {
 		if (nbytes < compr[i].maglen)
 			continue;
@@ -189,6 +190,7 @@ sread(int fd, void *buf, size_t n, int canbepipe)
 #ifdef FIONREAD
 	if ((canbepipe && (ioctl(fd, FIONREAD, &t) == -1)) || (t == 0)) {
 #ifdef FD_ZERO
+		int cnt;
 		for (cnt = 0;; cnt++) {
 			fd_set check;
 			struct timeval tout = {0, 100 * 1000};
@@ -310,6 +312,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
 #define FNAME		(1 << 3)
 #define FCOMMENT	(1 << 4)
 
+
 private size_t
 uncompressgzipped(struct magic_set *ms, const unsigned char *old,
     unsigned char **newch, size_t n)
@@ -373,7 +376,6 @@ uncompressgzipped(struct magic_set *ms, const unsigned char *old,
 }
 #endif
 
-
 private size_t
 uncompressbuf(struct magic_set *ms, int fd, size_t method,
     const unsigned char *old, unsigned char **newch, size_t n)
@@ -490,7 +492,7 @@ err:
 		(void)wait(NULL);
 #endif
 		(void) close(fdin[0]);
-		
+	    
 		return n;
 	}
 }
diff --git a/ext/fileinfo/libmagic/file.h b/ext/fileinfo/libmagic/file.h
index 58211f1..915602f 100644
--- a/ext/fileinfo/libmagic/file.h
+++ b/ext/fileinfo/libmagic/file.h
@@ -2,7 +2,7 @@
  * Copyright (c) Ian F. Darwin 1986-1995.
  * Software written by Ian F. Darwin and others;
  * maintained 1995-present by Christos Zoulas and others.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -12,7 +12,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- *  
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -27,7 +27,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.103 2008/03/01 22:21:49 rrt Exp $
+ * @(#)$File: file.h,v 1.119 2009/02/04 18:24:32 christos Exp $
  */
 
 #ifndef __file_h__
@@ -138,7 +138,7 @@ struct magic {
 #define UNSIGNED	0x08	/* comparison is unsigned */
 #define NOSPACE		0x10	/* suppress space character before output */
 #define BINTEST		0x20	/* test is for a binary type (set only
-                                   for top-level tests) */
+				   for top-level tests) */
 #define TEXTTEST	0	/* for passing to file_softmagic */
 
 	uint8_t factor;
@@ -216,7 +216,7 @@ struct magic {
 #else
 	uint8_t dummy;	
 #endif
-	uint8_t factor_op;	
+	uint8_t factor_op;
 #define		FILE_FACTOR_OP_PLUS	'+'
 #define		FILE_FACTOR_OP_MINUS	'-'
 #define		FILE_FACTOR_OP_TIMES	'*'
@@ -264,7 +264,7 @@ struct magic {
 #define str_range _u._s._count
 #define str_flags _u._s._flags
 	/* Words 9-16 */
-	union VALUETYPE value; /* either number of string */
+	union VALUETYPE value;	/* either number or string */
 	/* Words 17-24 */
 	char desc[MAXDESC];	/* description */
 	/* Words 25-32 */
@@ -312,7 +312,6 @@ struct level_info {
 	int last_cond;	/* used for error checking by parse() */
 #endif
 };
-
 struct magic_set {
 	struct mlist *mlist;
 	struct cont {
diff --git a/ext/fileinfo/libmagic/fsmagic.c b/ext/fileinfo/libmagic/fsmagic.c
index dd84db8..ca21713 100644
--- a/ext/fileinfo/libmagic/fsmagic.c
+++ b/ext/fileinfo/libmagic/fsmagic.c
@@ -176,7 +176,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *
 			return 1;
 # endif
 #endif
-			
+
 #ifdef	S_IFIFO
 			case S_IFIFO:
 				if((ms->flags & MAGIC_DEVICES) != 0)
diff --git a/ext/fileinfo/libmagic/funcs.c b/ext/fileinfo/libmagic/funcs.c
index f36f9b2..3ca5408 100644
--- a/ext/fileinfo/libmagic/funcs.c
+++ b/ext/fileinfo/libmagic/funcs.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) Christos Zoulas 2003.
  * All Rights Reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -11,7 +11,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- *  
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.39 2008/03/01 22:21:49 rrt Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.53 2009/04/07 11:07:00 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -392,7 +392,7 @@ file_getbuffer(struct magic_set *ms)
 
 	for (np = ms->o.pbuf, op = ms->o.buf; *op; op++) {
 		if (isprint((unsigned char)*op)) {
-			*np++ = *op;	
+			*np++ = *op;
 		} else {
 			OCTALIFY(np, op);
 		}
diff --git a/ext/fileinfo/libmagic/is_tar.c b/ext/fileinfo/libmagic/is_tar.c
index 9802877..f962edb 100644
--- a/ext/fileinfo/libmagic/is_tar.c
+++ b/ext/fileinfo/libmagic/is_tar.c
@@ -40,7 +40,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: is_tar.c,v 1.31 2008/02/04 20:51:17 christos Exp $")
+FILE_RCSID("@(#)$File: is_tar.c,v 1.36 2009/02/03 20:27:51 christos Exp $")
 #endif
 
 #include "magic.h"
diff --git a/ext/fileinfo/libmagic/magic.c b/ext/fileinfo/libmagic/magic.c
index 9c4b3bf..849896b 100644
--- a/ext/fileinfo/libmagic/magic.c
+++ b/ext/fileinfo/libmagic/magic.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) Christos Zoulas 2003.
  * All Rights Reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -11,7 +11,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- *  
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -28,7 +28,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: magic.c,v 1.50 2008/02/19 00:58:59 rrt Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.62 2009/03/20 21:25:41 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -65,9 +65,10 @@ FILE_RCSID("@(#)$File: magic.c,v 1.50 2008/02/19 00:58:59 rrt Exp $")
 #ifndef PHP_WIN32
 # include <netinet/in.h>		/* for byte swapping */
 #endif
+
 #include "patchlevel.h"
 
-#ifndef PIPE_BUF 
+#ifndef PIPE_BUF
 /* Get the PIPE_BUF from pathconf */
 #ifdef _PC_PIPE_BUF
 #define PIPE_BUF pathconf(".", _PC_PIPE_BUF)
@@ -199,6 +200,7 @@ private void
 close_and_restore(const struct magic_set *ms, const char *name, int fd,
     const struct stat *sb)
 {
+
 	if ((ms->flags & MAGIC_PRESERVE_ATIME) != 0) {
 		/*
 		 * Try to restore access, modification times if read it.
@@ -303,7 +305,7 @@ file_or_stream(struct magic_set *ms, const char *inname, php_stream *stream)
 	}
 
 #ifdef O_NONBLOCK
-		/* we should be already be in non blocking mode for network socket */
+/* we should be already be in non blocking mode for network socket */
 #endif
 
 	/*
diff --git a/ext/fileinfo/libmagic/magic.h b/ext/fileinfo/libmagic/magic.h
index 2e0fdc3..ba03792 100644
--- a/ext/fileinfo/libmagic/magic.h
+++ b/ext/fileinfo/libmagic/magic.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) Christos Zoulas 2003.
  * All Rights Reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -11,7 +11,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- *  
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
diff --git a/ext/fileinfo/libmagic/patchlevel.h b/ext/fileinfo/libmagic/patchlevel.h
index 12e685a..f458f56 100644
--- a/ext/fileinfo/libmagic/patchlevel.h
+++ b/ext/fileinfo/libmagic/patchlevel.h
@@ -6,14 +6,14 @@
  * $File: patchlevel.h,v 1.68 2008/03/22 21:39:43 christos Exp $
  *
  * $Log$
- * Revision 1.1.2.3  2009/05/04 20:54:53  scottmac
- * MFH Update libmagic to 5.02
+ * Revision 1.4  2009/05/04 20:52:43  scottmac
+ * Update libmagic to 5.02
  *
- * Revision 1.1.2.2  2009/03/15 23:04:18  scottmac
- * MFH Update fileinfo to libmagic 5.00 and remove dependency on dirent.h on Windows
+ * Revision 1.3  2009/03/15 23:02:35  scottmac
+ * Update fileinfo to libmagic 5.00 and remove dependency on dirent.h on Windows
  *
- * Revision 1.1.2.1  2008/11/02 16:13:49  scottmac
- * MFH: Sync libmagic with 4.26 and add support for the new v6 magic file format
+ * Revision 1.2  2008/11/02 16:09:27  scottmac
+ * Update libmagic to 4.26 and add support for v6 of the magic file format.
  *
  * Revision 1.1  2008/07/11 14:13:50  derick
  * - Move lib to libmagic
diff --git a/ext/fileinfo/libmagic/print.c b/ext/fileinfo/libmagic/print.c
index acba041..fd10126 100644
--- a/ext/fileinfo/libmagic/print.c
+++ b/ext/fileinfo/libmagic/print.c
@@ -34,7 +34,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: print.c,v 1.63 2008/02/17 19:28:54 rrt Exp $")
+FILE_RCSID("@(#)$File: print.c,v 1.66 2009/02/03 20:27:51 christos Exp $")
 #endif  /* lint */
 
 #include <string.h>
diff --git a/ext/fileinfo/libmagic/readcdf.c b/ext/fileinfo/libmagic/readcdf.c
index a12fa9c..56d6504 100644
--- a/ext/fileinfo/libmagic/readcdf.c
+++ b/ext/fileinfo/libmagic/readcdf.c
@@ -26,17 +26,15 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.11 2009/02/03 20:27:51 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.18 2009/05/06 20:48:22 christos Exp $")
 #endif
 
 #include <stdlib.h>
-
 #ifdef PHP_WIN32
 #include "win32/unistd.h"
 #else
 #include <unistd.h>
 #endif
-
 #include <string.h>
 #include <time.h>
 #include <ctype.h>
@@ -202,7 +200,7 @@ protected int
 file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
     size_t nbytes)
 {
-	cdf_info_t info;	
+	cdf_info_t info;
 	cdf_header_t h;
 	cdf_sat_t sat, ssat;
 	cdf_stream_t sst, scn;
@@ -246,7 +244,6 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
 		expn = "Cannot read short stream";
 		goto out3;
 	}
-
 #ifdef CDF_DEBUG
 	cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir);
 #endif
diff --git a/ext/fileinfo/libmagic/readelf.c b/ext/fileinfo/libmagic/readelf.c
index e78b5ef..5429b50 100644
--- a/ext/fileinfo/libmagic/readelf.c
+++ b/ext/fileinfo/libmagic/readelf.c
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.73 2008/03/27 22:00:28 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.81 2008/11/04 16:38:28 christos Exp $")
 #endif
 
 #ifdef BUILTIN_ELF
@@ -1118,6 +1118,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
 	return 0;
 }
 
+
 protected int
 file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
     size_t nbytes)
@@ -1137,7 +1138,6 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
 
 	if (ms->flags & (MAGIC_MIME|MAGIC_APPLE))
 		return 0;
-
 	/*
 	 * ELF executables have multiple section headers in arbitrary
 	 * file locations and thus file(1) cannot determine it from easily.
diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c
index 5bed6e6..0a06d00 100644
--- a/ext/fileinfo/libmagic/softmagic.c
+++ b/ext/fileinfo/libmagic/softmagic.c
@@ -2,7 +2,7 @@
  * Copyright (c) Ian F. Darwin 1986-1995.
  * Software written by Ian F. Darwin and others;
  * maintained 1995-present by Christos Zoulas and others.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -12,7 +12,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- *  
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.117 2008/03/01 22:21:49 rrt Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.135 2009/03/27 22:42:49 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -149,7 +149,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 		default:
 			if (m->type == FILE_INDIRECT)
 				returnval = 1;
-
+				
 			switch (magiccheck(ms, m)) {
 			case -1:
 				return -1;
@@ -163,7 +163,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 			break;
 		}
 		if (flush) {
-			/* 
+			/*
 			 * main entry didn't match,
 			 * flush its continuations
 			 */
@@ -188,7 +188,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 
 
 		if (print && mprint(ms, m) == -1)
-		 			return -1;
+			return -1;
 
 		ms->c.li[cont_level].off = moffset(ms, m);
 
@@ -227,7 +227,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 				return -1;
 			case 0:
 				if (m->reln != '!')
-				continue;
+					continue;
 				flush = 1;
 				break;
 			default:
@@ -305,11 +305,11 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 		if (printed_something) {
 			firstline = 0;
 			if (print)
-			returnval = 1;
+				returnval = 1;
 		}
 		if ((ms->flags & MAGIC_CONTINUE) == 0 && printed_something) {
 			return returnval; /* don't keep searching */
-		}			
+		}
 	}
 	return returnval;  /* This is hit if -k is set or there is no match */
 }
@@ -377,7 +377,8 @@ mprint(struct magic_set *ms, struct magic *m)
 				return -1;
 			break;
 		default:
-			if (file_printf(ms, m->desc, (unsigned short) v) == -1)
+			if (
+			    file_printf(ms, m->desc, (unsigned short) v) == -1)
 				return -1;
 			break;
 		}
@@ -932,7 +933,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
 			}
 			if (lines)
 				last = (const char *)s + nbytes;
-			
+
 			ms->search.s = buf;
 			ms->search.s_len = last - buf;
 			ms->search.offset = offset;
@@ -945,10 +946,10 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
 			const unsigned char *esrc = s + nbytes;
 			char *dst = p->s;
 			char *edst = &p->s[sizeof(p->s) - 1];
-			
+
 			if (type == FILE_BESTRING16)
 				src++;
-			
+
 			/* check for pointer overflow */
 			if (src < s) {
 				file_magerror(ms, "invalid offset %u in mcopy()",
@@ -1506,14 +1507,14 @@ mget(struct magic_set *ms, const unsigned char *s,
 		if (nbytes < (offset + 1)) /* should alway be true */
 			return 0;
 		break;
-		
+
 	case FILE_SHORT:
 	case FILE_BESHORT:
 	case FILE_LESHORT:
 		if (nbytes < (offset + 2))
 			return 0;
 		break;
-		
+
 	case FILE_LONG:
 	case FILE_BELONG:
 	case FILE_LELONG:
@@ -1532,7 +1533,7 @@ mget(struct magic_set *ms, const unsigned char *s,
 		if (nbytes < (offset + 4))
 			return 0;
 		break;
-		
+
 	case FILE_DOUBLE:
 	case FILE_BEDOUBLE:
 	case FILE_LEDOUBLE:
@@ -1591,7 +1592,7 @@ file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags)
 	if (0L == flags) { /* normal string: do it fast */
 		while (len-- > 0)
 			if ((v = *b++ - *a++) != '\0')
-				break; 
+				break;
 	}
 	else { /* combine the others */
 		while (len-- > 0) {
@@ -1605,8 +1606,8 @@ file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags)
 				if ((v = toupper(*b++) - *a++) != '\0')
 					break;
 			}
-			else if ((flags & STRING_COMPACT_BLANK) && 
-			    isspace(*a)) { 
+			else if ((flags & STRING_COMPACT_BLANK) &&
+			    isspace(*a)) {
 				a++;
 				if (isspace(*b++)) {
 					while (isspace(*b))
@@ -1761,23 +1762,23 @@ magiccheck(struct magic_set *ms, struct magic *m)
 		case 'x':
 			matched = 1;
 			break;
-	
+
 		case '!':
 			matched = fv != fl;
 			break;
-	
+
 		case '=':
 			matched = fv == fl;
 			break;
-	
+
 		case '>':
 			matched = fv > fl;
 			break;
-	
+
 		case '<':
 			matched = fv < fl;
 			break;
-	
+
 		default:
 			matched = 0;
 			file_magerror(ms, "cannot happen with float: invalid relation `%c'",
@@ -1795,23 +1796,23 @@ magiccheck(struct magic_set *ms, struct magic *m)
 		case 'x':
 			matched = 1;
 			break;
-	
+
 		case '!':
 			matched = dv != dl;
 			break;
-	
+
 		case '=':
 			matched = dv == dl;
 			break;
-	
+
 		case '>':
 			matched = dv > dl;
 			break;
-	
+
 		case '<':
 			matched = dv < dl;
 			break;
-	
+
 		default:
 			matched = 0;
 			file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln);
@@ -1859,7 +1860,6 @@ magiccheck(struct magic_set *ms, struct magic *m)
 		}
 		break;
 	}
-			
 	case FILE_REGEX: {
 		zval *pattern;
 		int options = 0;
@@ -1867,9 +1867,7 @@ magiccheck(struct magic_set *ms, struct magic *m)
 		TSRMLS_FETCH();
 		
 		MAKE_STD_ZVAL(pattern);
-		Z_STRVAL_P(pattern) = (char *)m->value.s;
-		Z_STRLEN_P(pattern) = m->vallen;
-		Z_TYPE_P(pattern) = IS_STRING; 
+		ZVAL_STRINGL(pattern, (char *)m->value.s, m->vallen, 0);
 	
 		options |= PCRE_MULTILINE;
 		
@@ -1878,8 +1876,14 @@ magiccheck(struct magic_set *ms, struct magic *m)
 		}
 		
 		convert_libmagic_pattern(pattern, options);
-
+		
+#if (PHP_MAJOR_VERSION < 6)
 		if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) {
+#else
+		if ((pce = pcre_get_compiled_regex_cache(IS_STRING, Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) {
+#endif
+			zval_dtor(pattern);
+			FREE_ZVAL(pattern);
 			return -1;
 		} else {
 			/* pce now contains the compiled regex */
@@ -1894,16 +1898,19 @@ magiccheck(struct magic_set *ms, struct magic *m)
 			haystack = estrndup(ms->search.s, ms->search.s_len);
 
 			/* match v = 0, no match v = 1 */
+#if (PHP_MAJOR_VERSION < 6)
 			php_pcre_match_impl(pce, haystack, ms->search.s_len, retval, subpats, 1, 1, PREG_OFFSET_CAPTURE, 0 TSRMLS_CC);
-			
+#else			
+			php_pcre_match_impl(pce, IS_STRING, haystack, ms->search.s_len, retval, subpats, 1, 1, PREG_OFFSET_CAPTURE, 0 TSRMLS_CC);
+#endif
 			/* Free haystack */
 			efree(haystack);
 			
 			if (Z_LVAL_P(retval) < 0) {
 				zval_ptr_dtor(&subpats);
 				FREE_ZVAL(retval);
-				efree(Z_STRVAL_P(pattern));
-				efree(pattern);
+				zval_dtor(pattern);
+				FREE_ZVAL(pattern);
 				return -1;
 			} else if ((Z_LVAL_P(retval) > 0) && (Z_TYPE_P(subpats) == IS_ARRAY)) {
 				
@@ -1991,8 +1998,8 @@ magiccheck(struct magic_set *ms, struct magic *m)
 					} else {
 						zval_ptr_dtor(&subpats);
 						FREE_ZVAL(retval);
-						efree(Z_STRVAL_P(pattern));
-						efree(pattern);
+						zval_dtor(pattern);
+						FREE_ZVAL(pattern);
 						return -1;
 					}					
 				}
@@ -2004,8 +2011,8 @@ magiccheck(struct magic_set *ms, struct magic *m)
 			zval_ptr_dtor(&subpats);
 			FREE_ZVAL(retval);
 		}
-		efree(Z_STRVAL_P(pattern));
-		efree(pattern);
+		zval_dtor(pattern);
+		FREE_ZVAL(pattern);
 		break;	
 	}
 	case FILE_INDIRECT:
@@ -2123,7 +2130,7 @@ print_sep(struct magic_set *ms, int firstline)
 	if (firstline)
 		return 0;
 	/*
-	 * we found another match 
+	 * we found another match
 	 * put a newline and '-' to do some simple formatting
 	 */
 	return file_printf(ms, "\n- ");
diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c
index 431356e..9a641c8 100644
--- a/ext/filter/callback_filter.c
+++ b/ext/filter/callback_filter.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: callback_filter.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: callback_filter.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_filter.h"
 
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
index 7268d08..087ca2f 100644
--- a/ext/filter/filter.c
+++ b/ext/filter/filter.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -19,7 +19,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: filter.c 289434 2009-10-09 17:32:53Z pajoye $ */
+/* $Id: filter.c 294106 2010-01-27 17:22:54Z johannes $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -251,6 +251,7 @@ PHP_MINIT_FUNCTION(filter)
 
 	REGISTER_LONG_CONSTANT("FILTER_FLAG_STRIP_LOW", FILTER_FLAG_STRIP_LOW, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("FILTER_FLAG_STRIP_HIGH", FILTER_FLAG_STRIP_HIGH, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("FILTER_FLAG_STRIP_BACKTICK", FILTER_FLAG_STRIP_BACKTICK, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_LOW", FILTER_FLAG_ENCODE_LOW, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_HIGH", FILTER_FLAG_ENCODE_HIGH, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_AMP", FILTER_FLAG_ENCODE_AMP, CONST_CS | CONST_PERSISTENT);
@@ -313,7 +314,7 @@ PHP_MINFO_FUNCTION(filter)
 {
 	php_info_print_table_start();
 	php_info_print_table_row( 2, "Input Validation and Filtering", "enabled" );
-	php_info_print_table_row( 2, "Revision", "$Revision: 289434 $");
+	php_info_print_table_row( 2, "Revision", "$Revision: 294106 $");
 	php_info_print_table_end();
 
 	DISPLAY_INI_ENTRIES();
@@ -391,9 +392,7 @@ static void php_zval_filter(zval **value, long filter, long flags, zval *options
 	) {
 		zval **tmp; 
 		if (zend_hash_find(HASH_OF(options), "default", sizeof("default"), (void **)&tmp) == SUCCESS) {
-			**value = **tmp;
-			zval_copy_ctor(*value);
-			INIT_PZVAL(*value);
+			MAKE_COPY_ZVAL(tmp, *value);
 		}
 	}
 }
@@ -678,9 +677,7 @@ static void php_filter_call(zval **filtered, long filter, zval **filter_args, co
 		zval *tmp;
 
 		ALLOC_ZVAL(tmp);
-		*tmp = **filtered;
-		zval_copy_ctor(tmp);
-		INIT_PZVAL(tmp);
+		MAKE_COPY_ZVAL(filtered, tmp);
 
 		zval_dtor(*filtered);
 
@@ -700,15 +697,11 @@ static void php_filter_array_handler(zval *input, zval **op, zval *return_value
 
 	if (!op) {
 		zval_dtor(return_value);
-		*return_value = *input;
-		zval_copy_ctor(return_value);
-		INIT_PZVAL(return_value);
+		MAKE_COPY_ZVAL(&input, return_value);
 		php_filter_call(&return_value, FILTER_DEFAULT, NULL, 0, FILTER_REQUIRE_ARRAY TSRMLS_CC);
 	} else if (Z_TYPE_PP(op) == IS_LONG) {
 		zval_dtor(return_value);
-		*return_value = *input;
-		zval_copy_ctor(return_value);
-		INIT_PZVAL(return_value);
+		MAKE_COPY_ZVAL(&input, return_value);
 		php_filter_call(&return_value, Z_LVAL_PP(op), NULL, 0, FILTER_REQUIRE_ARRAY TSRMLS_CC);
 	} else if (Z_TYPE_PP(op) == IS_ARRAY) {
 		array_init(return_value);
@@ -734,9 +727,7 @@ static void php_filter_array_handler(zval *input, zval **op, zval *return_value
 				zval *nval;
 
 				ALLOC_ZVAL(nval);
-				*nval = **tmp;
-				zval_copy_ctor(nval);
-				INIT_PZVAL(nval);
+				MAKE_COPY_ZVAL(tmp, nval);
 
 				php_filter_call(&nval, -1, arg_elm, 0, FILTER_REQUIRE_SCALAR TSRMLS_CC);
 				add_assoc_zval_ex(return_value, arg_key, arg_key_len, nval);
@@ -777,14 +768,13 @@ PHP_FUNCTION(filter_input)
 				filter_flags = Z_LVAL_PP(filter_args);
 			} else if (Z_TYPE_PP(filter_args) == IS_ARRAY && zend_hash_find(HASH_OF(*filter_args), "flags", sizeof("flags"), (void **)&option) == SUCCESS) {
 				PHP_FILTER_GET_LONG_OPT(option, filter_flags);
-			} else if (Z_TYPE_PP(filter_args) == IS_ARRAY && 
+			}
+			if (Z_TYPE_PP(filter_args) == IS_ARRAY && 
 				zend_hash_find(HASH_OF(*filter_args), "options", sizeof("options"), (void **)&opt) == SUCCESS &&
 				Z_TYPE_PP(opt) == IS_ARRAY &&
 				zend_hash_find(HASH_OF(*opt), "default", sizeof("default"), (void **)&def) == SUCCESS
 			) {
-				*return_value = **def;
-				zval_copy_ctor(return_value);
-				INIT_PZVAL(return_value);
+				MAKE_COPY_ZVAL(def, return_value);
 				return;
 			}
 		}
@@ -795,9 +785,7 @@ PHP_FUNCTION(filter_input)
 		}
 	}
 
-	*return_value = **tmp;
-	zval_copy_ctor(return_value);  /* Watch out for empty strings */
-	INIT_PZVAL(return_value);
+	MAKE_COPY_ZVAL(tmp, return_value);
 
 	php_filter_call(&return_value, filter, filter_args, 1, FILTER_REQUIRE_SCALAR TSRMLS_CC);
 }
@@ -819,9 +807,7 @@ PHP_FUNCTION(filter_var)
 		RETURN_FALSE;
 	}
 
-	*return_value = *data;
-	zval_copy_ctor(data);
-	INIT_PZVAL(return_value);
+	MAKE_COPY_ZVAL(&data, return_value);
 
 	php_filter_call(&return_value, filter, filter_args, 1, FILTER_REQUIRE_SCALAR TSRMLS_CC);
 }
diff --git a/ext/filter/filter_private.h b/ext/filter/filter_private.h
index 9581691..8920877 100644
--- a/ext/filter/filter_private.h
+++ b/ext/filter/filter_private.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: filter_private.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: filter_private.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef FILTER_PRIVATE_H
 #define FILTER_PRIVATE_H
@@ -39,6 +39,7 @@
 #define FILTER_FLAG_ENCODE_AMP              0x0040
 #define FILTER_FLAG_NO_ENCODE_QUOTES        0x0080
 #define FILTER_FLAG_EMPTY_STRING_NULL       0x0100
+#define FILTER_FLAG_STRIP_BACKTICK          0x0200
 
 #define FILTER_FLAG_ALLOW_FRACTION          0x1000
 #define FILTER_FLAG_ALLOW_THOUSAND          0x2000
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index 237ed9d..f8f453e 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: logical_filters.c 284212 2009-07-16 23:29:36Z felipe $ */
+/* $Id: logical_filters.c 293996 2010-01-25 16:14:28Z johannes $ */
 
 #include "php_filter.h"
 #include "filter_private.h"
@@ -456,12 +456,35 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 		RETURN_VALIDATION_FAILED
 	}
 
+	if (url->scheme != NULL && (!strcasecmp(url->scheme, "http") || !strcasecmp(url->scheme, "https"))) {
+		char *e, *s;
+
+		if (url->host == NULL) {
+			goto bad_url;
+		}
+
+		e = url->host + strlen(url->host);
+		s = url->host;
+
+		while (s < e) {
+			if (!isalnum((int)*(unsigned char *)s) && *s != '_' && *s != '.') {
+				goto bad_url;
+			}
+			s++;
+		}
+
+		if (*(e - 1) == '.') {
+			goto bad_url;
+		}
+	}
+
 	if (
 		url->scheme == NULL || 
 		/* some schemas allow the host to be empty */
 		(url->host == NULL && (strcmp(url->scheme, "mailto") && strcmp(url->scheme, "news") && strcmp(url->scheme, "file"))) ||
 		((flags & FILTER_FLAG_PATH_REQUIRED) && url->path == NULL) || ((flags & FILTER_FLAG_QUERY_REQUIRED) && url->query == NULL)
 	) {
+bad_url:
 		php_url_free(url);
 		RETURN_VALIDATION_FAILED
 	}
@@ -472,7 +495,7 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
 	/* From http://cvs.php.net/co.php/pear/HTML_QuickForm/QuickForm/Rule/Email.php?r=1.4 */
-	const char regexp[] = "/^((\\\"[^\\\"\\f\\n\\r\\t\\b]+\\\")|([A-Za-z0-9_][A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*(\\.[A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z0-9\\-]))?)+[A-Za-z]+))$/D";
+	const char regexp[] = "/^((\\\"[^\\\"\\f\\n\\r\\t\\b]+\\\")|([A-Za-z0-9_][A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\=\\?\\^\\`\\|\\{\\}]*(\\.[A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\=\\?\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z0-9\\-]))?)+[A-Za-z]+))$/D";
 
 	pcre       *re = NULL;
 	pcre_extra *pcre_extra = NULL;
diff --git a/ext/filter/php_filter.h b/ext/filter/php_filter.h
index 63416a0..1c5d846 100644
--- a/ext/filter/php_filter.h
+++ b/ext/filter/php_filter.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_filter.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_filter.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_FILTER_H
 #define PHP_FILTER_H
diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c
index fc0475c..c5152db 100644
--- a/ext/filter/sanitizing_filters.c
+++ b/ext/filter/sanitizing_filters.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sanitizing_filters.c 289438 2009-10-09 17:50:17Z pajoye $ */
+/* $Id: sanitizing_filters.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_filter.h"
 #include "filter_private.h"
@@ -123,6 +123,7 @@ static void php_filter_strip(zval *value, long flags)
 	for (i = 0; i < Z_STRLEN_P(value); i++) {
 		if ((str[i] > 127) && (flags & FILTER_FLAG_STRIP_HIGH)) {
 		} else if ((str[i] < 32) && (flags & FILTER_FLAG_STRIP_LOW)) {
+		} else if ((str[i] == '`') && (flags & FILTER_FLAG_STRIP_BACKTICK)) {
 		} else {
 			buf[c] = str[i];
 			++c;
diff --git a/ext/filter/tests/033.phpt b/ext/filter/tests/033.phpt
index f965e35..143d0c1 100644
--- a/ext/filter/tests/033.phpt
+++ b/ext/filter/tests/033.phpt
@@ -21,7 +21,7 @@ stripped            PHP  1  foo at bar.com    http://a.b.c        1.2.3.4   123  12
 encoded             PHP  1  foo%40bar.com  http%3A%2F%2Fa.b.c  1.2.3.4   123  123abc%3C%3E%28%29  O%27Henry      %ED%95%98%ED%8D%BC
 special_chars       PHP  1  foo at bar.com    http://a.b.c        1.2.3.4   123  123abc<>()  O'Henry    하퍼    
 unsafe_raw          PHP  1  foo at bar.com    http://a.b.c        1.2.3.4   123  123abc<>()          O'Henry        하퍼    
-email               PHP  1  foo at bar.com    http//a.b.c         1.2.3.4   123  123abc              O'Henry                  
+email               PHP  1  foo at bar.com    httpa.b.c           1.2.3.4   123  123abc              O'Henry                  
 url                 PHP  1  foo at bar.com    http://a.b.c        1.2.3.4   123  123abc<>()          O'Henry                  
 number_int               1                                     1234      123  123                                          
 number_float             1                                     1234      123  123                                          
diff --git a/ext/filter/tests/bug39763.phpt b/ext/filter/tests/bug39763.phpt
index 429fff6..1422f52 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--	
-PHP Warning:  Directive 'magic_quotes_gpc' 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
 \"probably a bug\"
 \"probably a bug\"
\ No newline at end of file
diff --git a/ext/filter/tests/bug42718-2.phpt b/ext/filter/tests/bug42718-2.phpt
index fd2a91d..13cd990 100644
--- a/ext/filter/tests/bug42718-2.phpt
+++ b/ext/filter/tests/bug42718-2.phpt
@@ -3,6 +3,7 @@ Bug #42718 - 2 (unsafe_raw filter not applied when configured as default filter)
 --SKIPIF--
 <?php if (!extension_loaded("filter")) die("skip"); ?>
 --INI--
+display_errors=0
 magic_quotes_gpc=1
 filter.default=unsafe_raw
 filter.default_flags=
diff --git a/ext/filter/tests/bug50158.phpt b/ext/filter/tests/bug50158.phpt
new file mode 100644
index 0000000..fbe2ca3
--- /dev/null
+++ b/ext/filter/tests/bug50158.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #50158 (FILTER_VALIDATE_EMAIL fails with valid addresses containing = or ?)
+--FILE--
+<?php
+
+$email_address = "test=mail at example.com";    
+var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));    
+                                                                
+$email_address = "test-mail at example.com";    
+var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));    
+    
+$email_address = "test+mail at example.com";    
+var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));   
+
+$email_address = "test?mail at example.com";    
+var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));   
+
+?>
+--EXPECTF--
+%unicode|string%(21) "test=mail at example.com"
+%unicode|string%(21) "test-mail at example.com"
+%unicode|string%(21) "test+mail at example.com"
+%unicode|string%(21) "test?mail at example.com"
diff --git a/ext/filter/tests/bug50632.phpt b/ext/filter/tests/bug50632.phpt
new file mode 100644
index 0000000..2f33b91
--- /dev/null
+++ b/ext/filter/tests/bug50632.phpt
@@ -0,0 +1,11 @@
+--TEST--
+bug 50632, filter_input() does not return default value if the variable does not exist
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+$foo = filter_input(INPUT_GET, 'foo', FILTER_VALIDATE_INT, array('flags' => FILTER_REQUIRE_SCALAR, 'options' => array('default' => 23)));
+var_dump($foo);
+?>
+--EXPECT--	
+int(23)
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index 36c2b07..be6c03f 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ftp.c 289416 2009-10-09 14:20:17Z pajoye $ */
+/* $Id: ftp.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1387,7 +1387,7 @@ ftp_getdata(ftpbuf_t *ftp TSRMLS_DC)
 
 	sa = (struct sockaddr *) &ftp->localaddr;
 	/* bind/listen */
-	if ((fd = socket(sa->sa_family, SOCK_STREAM, 0)) == -1) {
+	if ((fd = socket(sa->sa_family, SOCK_STREAM, 0)) == SOCK_ERR) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "socket() failed: %s (%d)", strerror(errno), errno);
 		goto bail;
 	}
@@ -1420,17 +1420,17 @@ ftp_getdata(ftpbuf_t *ftp TSRMLS_DC)
 	php_any_addr(sa->sa_family, &addr, 0);
 	size = php_sockaddr_size(&addr);
 
-	if (bind(fd, (struct sockaddr*) &addr, size) == -1) {
+	if (bind(fd, (struct sockaddr*) &addr, size) != 0) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "bind() failed: %s (%d)", strerror(errno), errno);
 		goto bail;
 	}
 
-	if (getsockname(fd, (struct sockaddr*) &addr, &size) == -1) {
+	if (getsockname(fd, (struct sockaddr*) &addr, &size) != 0) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "getsockname() failed: %s (%d)", strerror(errno), errno);
 		goto bail;
 	}
 
-	if (listen(fd, 5) == -1) {
+	if (listen(fd, 5) != 0) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "listen() failed: %s (%d)", strerror(errno), errno);
 		goto bail;
 	}
@@ -1699,7 +1699,7 @@ ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t typ
 	char			arg[11];
 
 	if (ftp == NULL) {
-		goto bail;
+		return PHP_FTP_FAILED;
 	}
 
 	if (!ftp_type(ftp, type)) {
diff --git a/ext/ftp/ftp.h b/ext/ftp/ftp.h
index a8575e2..9e48193 100644
--- a/ext/ftp/ftp.h
+++ b/ext/ftp/ftp.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ftp.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: ftp.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef	FTP_H
 #define	FTP_H
diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c
index 57d65ee..f06fe6b 100644
--- a/ext/ftp/php_ftp.c
+++ b/ext/ftp/php_ftp.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_ftp.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_ftp.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/ftp/php_ftp.h b/ext/ftp/php_ftp.h
index cae3f48..1155fd1 100644
--- a/ext/ftp/php_ftp.h
+++ b/ext/ftp/php_ftp.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_ftp.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_ftp.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef	_INCLUDED_FTP_H
 #define	_INCLUDED_FTP_H
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 8853e61..8459ac2 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: gd.c 282455 2009-06-19 22:15:28Z kalle $ */
+/* $Id: gd.c 294458 2010-02-03 20:42:50Z pajoye $ */
 
 /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
    Cold Spring Harbor Labs. */
@@ -3427,7 +3427,10 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must have at least 3 points in your array");
 		RETURN_FALSE;
 	}
-
+	if (npoints <= 0) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must give a positive number of points");
+		RETURN_FALSE;
+	}
 	if (nelem < npoints * 2) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to use %d points in array with only %d points", npoints, nelem/2);
 		RETURN_FALSE;
@@ -3880,7 +3883,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
 	long col = -1, x = -1, y = -1;
 	int str_len, fontname_len, i, brect[8];
 	double ptsize, angle;
-	unsigned char *str = NULL, *fontname = NULL;
+	char *str = NULL, *fontname = NULL;
 	char *error = NULL;
 	int argc = ZEND_NUM_ARGS();
 #if HAVE_GD_STRINGFTEX
@@ -3942,28 +3945,24 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
 	{
 		char tmp_font_path[MAXPATHLEN];
 
-		if (VCWD_REALPATH((char *)fontname, tmp_font_path)) {
-			fontname = (unsigned char *) fontname;
-		} else {
+		if (!VCWD_REALPATH(fontname, tmp_font_path)) {
 			fontname = NULL;
 		}
 	}
-#else
-	fontname = (unsigned char *) fontname;
 #endif
 
-	PHP_GD_CHECK_OPEN_BASEDIR((char *)fontname, "Invalid font filename");
+	PHP_GD_CHECK_OPEN_BASEDIR(fontname, "Invalid font filename");
 	
 #ifdef USE_GD_IMGSTRTTF
 # if HAVE_GD_STRINGFTEX
 	if (extended) {
-		error = gdImageStringFTEx(im, brect, col, (char *)fontname, ptsize, angle, x, y, (char *)str, &strex);
+		error = gdImageStringFTEx(im, brect, col, fontname, ptsize, angle, x, y, str, &strex);
 	}
 	else
 # endif
 
 # if HAVE_GD_STRINGFT
-	error = gdImageStringFT(im, brect, col, (char *)fontname, ptsize, angle, x, y, (char *)str);
+	error = gdImageStringFT(im, brect, col, fontname, ptsize, angle, x, y, str);
 # elif HAVE_GD_STRINGTTF
 	error = gdImageStringTTF(im, brect, col, fontname, ptsize, angle, x, y, str);
 # endif
@@ -4139,7 +4138,7 @@ PHP_FUNCTION(imagepsencodefont)
 	T1_DeleteAllSizes(*f_ind);
 	if (T1_ReencodeFont(*f_ind, enc_vector)) {
 		T1_DeleteEncoding(enc_vector);
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't reencode font");
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't re-encode font");
 		RETURN_FALSE;
 	}
 
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c
index e4961cf..13660e6 100644
--- a/ext/gd/gd_ctx.c
+++ b/ext/gd/gd_ctx.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: gd_ctx.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: gd_ctx.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_gd.h"
 
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index a0ea6f1..e4e2e0f 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -2568,7 +2568,7 @@ void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c)
 	typedef void (*image_line)(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
 	image_line draw_line;
 
-	if (!n) {
+	if (n <= 0) {
 		return;
 	}
 
@@ -2614,14 +2614,14 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
 {
 	int i;
 	int y;
-	int miny, maxy;
+	int miny, maxy, pmaxy;
 	int x1, y1;
 	int x2, y2;
 	int ind1, ind2;
 	int ints;
 	int fill_color;
 
-	if (!n) {
+	if (n <= 0) {
 		return;
 	}
 
@@ -2658,7 +2658,7 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
 			maxy = p[i].y;
 		}
 	}
-
+	pmaxy = maxy;
 	/* 2.0.16: Optimization by Ilia Chipitsine -- don't waste time offscreen */
 	if (miny < 0) {
 		miny = 0;
@@ -2700,13 +2700,13 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
 			 */
 			if (y >= y1 && y < y2) {
 				im->polyInts[ints++] = (float) ((y - y1) * (x2 - x1)) / (float) (y2 - y1) + 0.5 + x1;
-			} else if (y == maxy && y > y1 && y <= y2) {
-				im->polyInts[ints++] = (float) ((y - y1) * (x2 - x1)) / (float) (y2 - y1) + 0.5 + x1;
+			} else if (y == pmaxy && y == y2) {
+				im->polyInts[ints++] = x2;
 			}
 		}
 		qsort(im->polyInts, ints, sizeof(int), gdCompareInt);
 
-		for (i = 0; i < ints; i += 2) {
+		for (i = 0; i < ints - 1; i += 2) {
 			gdImageLine(im, im->polyInts[i], y, im->polyInts[i + 1], y, fill_color);
 		}
 	}
diff --git a/ext/gd/libgd/gd_png.c b/ext/gd/libgd/gd_png.c
index da5a32f..52a087e 100644
--- a/ext/gd/libgd/gd_png.c
+++ b/ext/gd/libgd/gd_png.c
@@ -145,7 +145,7 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
 		return NULL;
 	}
 
-	if (!png_check_sig (sig, 8)) { /* bad signature */
+	if (png_sig_cmp(sig, 0, 8) != 0) { /* bad signature */
 		return NULL;
 	}
 
diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c
index ffac3eb..a3ced0a 100644
--- a/ext/gd/libgd/gdft.c
+++ b/ext/gd/libgd/gdft.c
@@ -1090,6 +1090,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
 
 		if (render) {
 			if (image->format != ft_glyph_format_bitmap && FT_Glyph_To_Bitmap(&image, ft_render_mode_normal, 0, 1)) {
+				FT_Done_Glyph(image);
 				if (tmpstr) {
 					gdFree(tmpstr);
 				}
@@ -1100,7 +1101,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
 
 			/* now, draw to our target surface */
 			bm = (FT_BitmapGlyph) image;
-			gdft_draw_bitmap(tc_cache, im, fg, bm->bitmap, x + x1 + ((pen.x + 31) >> 6) + bm->left, y + y1 + ((pen.y + 31) >> 6) - bm->top);
+			gdft_draw_bitmap(tc_cache, im, fg, bm->bitmap, x + x1 + ((pen.x + 31) >> 6), y + y1 + ((pen.y + 31) >> 6) - bm->top);
 		}
 
 		/* record current glyph index for kerning */
diff --git a/ext/gd/libgd/xbm.c b/ext/gd/libgd/xbm.c
index 983163a..053d223 100644
--- a/ext/gd/libgd/xbm.c
+++ b/ext/gd/libgd/xbm.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: xbm.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: xbm.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdio.h>
 #include <math.h>
diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h
index d2970ce..708b934 100644
--- a/ext/gd/php_gd.h
+++ b/ext/gd/php_gd.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_gd.h 281216 2009-05-27 08:18:24Z pajoye $ */
+/* $Id: php_gd.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_GD_H
 #define PHP_GD_H
diff --git a/ext/gd/tests/bug49600.phpt b/ext/gd/tests/bug49600.phpt
new file mode 100644
index 0000000..068f8f3
--- /dev/null
+++ b/ext/gd/tests/bug49600.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #49600 (imageTTFText text shifted right)
+--SKIPIF--
+<?php
+	if(!extension_loaded('gd')){ die('skip gd extension not available'); }
+	if(!function_exists('imagettftext')) die('skip imagettftext() not available');
+	if(!function_exists('imagettfbbox')) die('skip imagettfbbox() not available');
+?>
+--FILE--
+<?php
+$cwd = dirname(__FILE__);
+$font = "$cwd/Tuffy.ttf";
+$image = imagecreatetruecolor(50, 50);
+$color = imagecolorallocate($image, 255, 255, 255);
+foreach (array("E", "I", "P", "g", "i", "q") as $c)
+{
+    $x = imagettftext($image, 32, 0, 0, 0, $color, $font, $c);
+	$y = imagettfbbox(32, 0, "$cwd/Tuffy.ttf", $c);
+    if ( abs($x[0] - $y[0]) > 1
+      || abs($x[2] - $y[2]) > 1
+      || abs($x[4] - $y[4]) > 1
+      || abs($x[6] - $y[6]) > 1 ) {
+      echo "FAILED: \n";
+      var_dump($x);
+      var_dump($y);
+      exit;
+    }
+}
+echo 'OK';
+?>
+--EXPECTF--
+OK
\ No newline at end of file
diff --git a/ext/gd/tests/image_type_to_mime_type_basic.phpt b/ext/gd/tests/image_type_to_mime_type_basic.phpt
index 5199fd2..b81bdbd 100644
--- a/ext/gd/tests/image_type_to_mime_type_basic.phpt
+++ b/ext/gd/tests/image_type_to_mime_type_basic.phpt
@@ -2,8 +2,7 @@
 image_type_to_mime_type()
 --SKIPIF--
 <?php 
-	if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available'); 
-	require_once('skipif_imagetype.inc');
+	if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available');
 ?>
 --FILE--
 <?php
@@ -61,4 +60,4 @@ string(18) "image/vnd.wap.wbmp"
 string(24) "application/octet-stream"
 string(9) "image/xbm"
 
-Done image_type_to_mime_type() test
\ No newline at end of file
+Done image_type_to_mime_type() test
diff --git a/ext/gd/tests/imagecopyresampled_basic.phpt b/ext/gd/tests/imagecopyresampled_basic.phpt
index 12ac155..a0454fa 100644
--- a/ext/gd/tests/imagecopyresampled_basic.phpt
+++ b/ext/gd/tests/imagecopyresampled_basic.phpt
@@ -3,7 +3,7 @@ imagecopyresampled()
 --SKIPIF--
 <?php 
 	if (!function_exists('imagecopyresampled')) die('skip imagecopyresampled() not available'); 
-	require_once('skipif_imagetype.inc');
+	if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled');
 ?>
 --FILE--
 <?php
diff --git a/ext/gd/tests/imagedashedline_basic.phpt b/ext/gd/tests/imagedashedline_basic.phpt
index 1d67975..be65af6 100644
--- a/ext/gd/tests/imagedashedline_basic.phpt
+++ b/ext/gd/tests/imagedashedline_basic.phpt
@@ -3,7 +3,7 @@ imagedashedline()
 --SKIPIF--
 <?php 
 	if (!function_exists('imagedashedline')) die('skip imagedashedline() not available'); 
-	require_once('skipif_imagetype.inc');
+	if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled');
 ?>
 --FILE--
 <?php
diff --git a/ext/gd/tests/imagefilledpolygon_basic.phpt b/ext/gd/tests/imagefilledpolygon_basic.phpt
index 6871a28..ded52da 100644
--- a/ext/gd/tests/imagefilledpolygon_basic.phpt
+++ b/ext/gd/tests/imagefilledpolygon_basic.phpt
@@ -3,7 +3,7 @@ imagefilledpolygon()
 --SKIPIF--
 <?php 
 	if (!function_exists('imagefilledpolygon')) die('skip imagefilledpolygon() not available'); 
-	require_once('skipif_imagetype.inc');
+	if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled');
 ?>
 --FILE--
 <?php
diff --git a/ext/gd/tests/imagefilledpolygon_negative.phpt b/ext/gd/tests/imagefilledpolygon_negative.phpt
new file mode 100644
index 0000000..ced8530
--- /dev/null
+++ b/ext/gd/tests/imagefilledpolygon_negative.phpt
@@ -0,0 +1,15 @@
+--TEST--
+imagefilledpolygon() with a negative num of points
+--SKIPIF--
+<?php 
+	if (!function_exists('imagefilledpolygon')) die('skip imagefilledpolygon() not available'); 
+?>
+--FILE--
+<?php
+$im = imagecreate(100, 100);
+$black = imagecolorallocate($im, 0, 0, 0);
+if (imagefilledpolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)) echo "should be false";
+imagedestroy($im);
+?>
+--EXPECTF--
+Warning: imagefilledpolygon(): You must give a positive number of points in %s on line %d
diff --git a/ext/gd/tests/imagepolygon_negative.phpt b/ext/gd/tests/imagepolygon_negative.phpt
new file mode 100644
index 0000000..bb9010c
--- /dev/null
+++ b/ext/gd/tests/imagepolygon_negative.phpt
@@ -0,0 +1,15 @@
+--TEST--
+imagepolygon() with a negative num of points
+--SKIPIF--
+<?php 
+	if (!function_exists('imagepolygon')) die('skip imagepolygon() not available'); 
+?>
+--FILE--
+<?php
+$im = imagecreate(100, 100);
+$black = imagecolorallocate($im, 0, 0, 0);
+if (imagepolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)) echo "should be false";
+imagedestroy($im);
+?>
+--EXPECTF--
+Warning: imagepolygon(): You must give a positive number of points in %s on line %d
diff --git a/ext/gd/tests/imagerectangle_basic.phpt b/ext/gd/tests/imagerectangle_basic.phpt
index 0574ad3..f706ee7 100755
--- a/ext/gd/tests/imagerectangle_basic.phpt
+++ b/ext/gd/tests/imagerectangle_basic.phpt
@@ -5,7 +5,7 @@ Ivan Rosolen <contato [at] ivanrosolen [dot] com>
 #testfest PHPSP on 2009-06-30
 --SKIPIF-- 
 <?php  
-if ( ! extension_loaded('gd') ) die( 'GD not present; skipping test' ); 
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' ); 
 ?> 
 --FILE--
 <?php
diff --git a/ext/gd/tests/imagerectangle_error2.phpt b/ext/gd/tests/imagerectangle_error2.phpt
index c6e7402..5fc1914 100755
--- a/ext/gd/tests/imagerectangle_error2.phpt
+++ b/ext/gd/tests/imagerectangle_error2.phpt
@@ -5,7 +5,7 @@ Ivan Rosolen <contato [at] ivanrosolen [dot] com>
 #testfest PHPSP on 2009-06-30
 --SKIPIF-- 
 <?php  
-if ( ! extension_loaded('gd') ) die( 'GD not present; skipping test' ); 
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' ); 
 ?> 
 --FILE--
 <?php
diff --git a/ext/gd/tests/libgd00100.phpt b/ext/gd/tests/libgd00100.phpt
new file mode 100644
index 0000000..abf4ee3
--- /dev/null
+++ b/ext/gd/tests/libgd00100.phpt
@@ -0,0 +1,119 @@
+--TEST--
+libgd #100 (spurious horizontal line drawn by gdImageFilledPolygon)
+--SKIPIF--
+<?php
+	if (!extension_loaded('gd')) die("skip gd extension not available\n");
+	if (!GD_BUNDLED) die("skip requires bundled GD library\n");
+?>
+--FILE--
+<?php
+$im = imagecreatetruecolor(256, 256);
+
+$white   = imagecolorallocatealpha($im, 255, 255, 255, 10);
+$black   = imagecolorallocatealpha($im,   0,   0,   0, 10);
+$red     = imagecolorallocatealpha($im, 255,   0,   0, 10);
+$green   = imagecolorallocatealpha($im,   0, 255,   0, 10);
+$blue    = imagecolorallocatealpha($im,   0,   0, 255, 10);
+$yellow  = imagecolorallocatealpha($im, 255, 255,   0, 10);
+$cyan    = imagecolorallocatealpha($im,   0, 255, 255, 10);
+$magenta = imagecolorallocatealpha($im, 255,   0, 255, 10);
+$purple  = imagecolorallocatealpha($im, 100,   0, 100, 10);
+
+imagefilledrectangle($im, 0, 0, 255, 255, $white);
+
+// M (bridge)
+$top = 240;
+$bot = 255;
+$d = 30;
+$x = 100;
+$points = array(
+  $x,      $top,
+  $x+2*$d, $top,
+  $x+2*$d, $bot,
+  $x+$d,   ($top+$bot)/2,
+  $x,      $bot
+);
+imagefilledpolygon($im, $points, 5, $yellow);
+
+// left-facing M not on baseline
+$top = 40;
+$bot = 70;
+$left = 120;
+$right = 180;
+$points = array(
+  $left,  $top,
+  $right, $top,
+  $right, $bot,
+  $left,  $bot,
+  ($left+$right)/2, ($top+$bot)/2
+);
+imagefilledpolygon($im, $points, 5, $purple);
+
+// left-facing M on baseline
+$top = 240;
+$bot = 270;
+$left = 20;
+$right = 80;
+$points = array(
+  $left,  $top,
+  $right, $top,
+  $right, $bot,
+  $left,  $bot,
+  ($left+$right)/2, ($top+$bot)/2
+);
+imagefilledpolygon($im, $points, 5, $magenta);
+
+// left-facing M on ceiling
+$top = -15;
+$bot = 15;
+$left = 20;
+$right = 80;
+$points = array(
+  $left,  $top,
+  $right, $top,
+  $right, $bot,
+  $left,  $bot,
+  ($left+$right)/2, ($top+$bot)/2
+);
+imagefilledpolygon($im, $points, 5, $blue);
+
+$d = 30;
+$x = 150;
+$y = 150;
+$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
+imagefilledpolygon($im, $diamond, 4, $green);
+
+$x = 180;
+$y = 225;
+$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
+imagefilledpolygon($im, $diamond, 4, $red);
+
+$x = 225;
+$y = 255;
+$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
+imagefilledpolygon($im, $diamond, 4, $cyan);
+
+// M (bridge) not touching bottom boundary
+$top = 100;
+$bot = 150;
+$x = 30;
+$points = array(
+  $x,      $top,
+  $x+2*$d, $top,
+  $x+2*$d, $bot,
+  $x+$d,   ($top+$bot)/2,
+  $x,      $bot
+);
+imagefilledpolygon($im, $points, 5, $black);
+
+ob_start();
+imagepng($im);
+$png = ob_get_contents();
+ob_end_clean();
+
+echo md5($png);
+
+imagedestroy($im);
+?>
+--EXPECTF--
+2e6cf558bb4dadf60c8b608d5f8cda4e
diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c
index 7a5f8d2..09c580f 100644
--- a/ext/gettext/gettext.c
+++ b/ext/gettext/gettext.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: gettext.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: gettext.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/gettext/php_gettext.h b/ext/gettext/php_gettext.h
index 926b877..dbaf5fb 100644
--- a/ext/gettext/php_gettext.h
+++ b/ext/gettext/php_gettext.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_gettext.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_gettext.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_GETTEXT_H
 #define PHP_GETTEXT_H
diff --git a/ext/gmp/config.w32 b/ext/gmp/config.w32
index 5897d24..01194fb 100644
--- a/ext/gmp/config.w32
+++ b/ext/gmp/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32 281914 2009-06-10 09:59:21Z pajoye $
+// $Id: config.w32 291937 2009-12-10 02:25:47Z pajoye $
 // vim:ft=javascript
 
 ARG_WITH("gmp", "Include GNU MP support.", "no");
@@ -8,6 +8,7 @@ if (PHP_GMP != "no") {
 		CHECK_HEADER_ADD_INCLUDE("gmp.h", "CFLAGS_GMP", PHP_GMP +  ";" + PHP_PHP_BUILD + "\\include\\mpir")) {
 		EXTENSION("gmp", "gmp.c");
 		AC_DEFINE('HAVE_GMP', 1, 'GMP support');
+		AC_DEFINE('HAVE_MPIR', 1, 'MPIR support');
 	} else {
 		WARNING("GMP not enabled; libraries and headers not found");
 	}
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index d4d7e30..f53dcd6 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -356,6 +356,9 @@ ZEND_MODULE_STARTUP_D(gmp)
 	REGISTER_LONG_CONSTANT("GMP_ROUND_ZERO", GMP_ROUND_ZERO, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("GMP_ROUND_PLUSINF", GMP_ROUND_PLUSINF, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("GMP_ROUND_MINUSINF", GMP_ROUND_MINUSINF, CONST_CS | CONST_PERSISTENT);
+#ifdef mpir_version
+	REGISTER_STRING_CONSTANT("GMP_MPIR_VERSION", (char *)mpir_version, CONST_CS | CONST_PERSISTENT);
+#endif
 	REGISTER_STRING_CONSTANT("GMP_VERSION", (char *)gmp_version, CONST_CS | CONST_PERSISTENT);
 
 	mp_set_memory_functions(gmp_emalloc, gmp_erealloc, gmp_efree);
@@ -383,7 +386,11 @@ ZEND_MODULE_INFO_D(gmp)
 {
 	php_info_print_table_start();
 	php_info_print_table_row(2, "gmp support", "enabled");
+#ifdef mpir_version
+	php_info_print_table_row(2, "MPIR version", mpir_version);
+#else
 	php_info_print_table_row(2, "GMP version", gmp_version);
+#endif
 	php_info_print_table_end();
 }
 /* }}} */
@@ -746,7 +753,11 @@ 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);
 		RETURN_FALSE;
 	}
@@ -796,14 +807,18 @@ ZEND_FUNCTION(gmp_strval)
 		return;
 	}
 
+#if __GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2
+	if ((base < 2 && base > -2) || base > 62 || base < -36) {
+#else
 	if (base < 2 || base > 36) {
+#endif
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld", base);
 		RETURN_FALSE;
 	}
 
 	FETCH_GMP_ZVAL(gmpnum, gmpnumber_arg, temp_a);
 
-	num_len = mpz_sizeinbase(*gmpnum, base);
+	num_len = mpz_sizeinbase(*gmpnum, abs(base));
 	out_string = emalloc(num_len+2);
 	if (mpz_sgn(*gmpnum) < 0) {
 		num_len++;
@@ -1359,8 +1374,11 @@ ZEND_FUNCTION(gmp_random)
 
 		GMPG(rand_initialized) = 1;
 	}
+#ifdef GMP_LIMB_BITS
+	mpz_urandomb(*gmpnum_result, GMPG(rand_state), GMP_ABS (limiter) * GMP_LIMB_BITS);
+#else
 	mpz_urandomb(*gmpnum_result, GMPG(rand_state), GMP_ABS (limiter) * __GMP_BITS_PER_MP_LIMB);
-
+#endif
 	ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp);
 }
 /* }}} */
diff --git a/ext/gmp/php_gmp.h b/ext/gmp/php_gmp.h
index da70710..dfe2080 100644
--- a/ext/gmp/php_gmp.h
+++ b/ext/gmp/php_gmp.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/gmp/tests/bug50283.phpt b/ext/gmp/tests/bug50283.phpt
new file mode 100644
index 0000000..e8132a7
--- /dev/null
+++ b/ext/gmp/tests/bug50283.phpt
@@ -0,0 +1,36 @@
+--TEST--
+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"; ?>
+--FILE--
+<?php
+$a = gmp_init("0x41682179fbf5");
+printf("Decimal: %s, -36-based: %s\n", gmp_strval($a), gmp_strval($a,-36));
+printf("Decimal: %s, 36-based: %s\n", gmp_strval($a), gmp_strval($a,36));
+printf("Decimal: %s, -1-based: %s\n", gmp_strval($a), gmp_strval($a,-1));
+printf("Decimal: %s, 1-based: %s\n", gmp_strval($a), gmp_strval($a,1));
+printf("Decimal: %s, -37-based: %s\n", gmp_strval($a), gmp_strval($a,-37));
+printf("Decimal: %s, 37-based: %s\n", gmp_strval($a), gmp_strval($a,37));
+printf("Decimal: %s, 62-based: %s\n", gmp_strval($a), gmp_strval($a,62));
+printf("Decimal: %s, 63-based: %s\n\n", gmp_strval($a), gmp_strval($a,63));
+printf("Base 32 and 62-based: %s\n", gmp_strval(gmp_init("gh82179fbf5", 32), 62));
+?>
+--EXPECTF--
+Decimal: 71915494046709, -36-based: PHPISCOOL
+Decimal: 71915494046709, 36-based: phpiscool
+
+Warning: gmp_strval(): Bad base for conversion: -1 in %s on line 5
+Decimal: 71915494046709, -1-based: 
+
+Warning: gmp_strval(): Bad base for conversion: 1 in %s on line 6
+Decimal: 71915494046709, 1-based: 
+
+Warning: gmp_strval(): Bad base for conversion: -37 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
+Decimal: 71915494046709, 63-based: 
+
+Base 32 and 62-based: 1NHkAcdIiD
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index f9de104..96c0ae2 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash.c 287429 2009-08-17 21:28:22Z garretts $ */
+/* $Id: hash.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/hash/hash_adler32.c b/ext/hash/hash_adler32.c
index b51f33d..9b26278 100644
--- a/ext/hash/hash_adler32.c
+++ b/ext/hash/hash_adler32.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_adler32.c 283144 2009-06-30 13:21:53Z scottmac $ */
+/* $Id: hash_adler32.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_hash.h"
 #include "php_hash_adler32.h"
diff --git a/ext/hash/hash_crc32.c b/ext/hash/hash_crc32.c
index cbce066..b3b6640 100644
--- a/ext/hash/hash_crc32.c
+++ b/ext/hash/hash_crc32.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_crc32.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: hash_crc32.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_hash.h"
 #include "php_hash_crc32.h"
diff --git a/ext/hash/hash_gost.c b/ext/hash/hash_gost.c
index dfc5078..5a430e3 100644
--- a/ext/hash/hash_gost.c
+++ b/ext/hash/hash_gost.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_gost.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: hash_gost.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_hash.h"
 #include "php_hash_gost.h"
diff --git a/ext/hash/hash_haval.c b/ext/hash/hash_haval.c
index b21f53d..528b284 100644
--- a/ext/hash/hash_haval.c
+++ b/ext/hash/hash_haval.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_haval.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: hash_haval.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_hash.h"
 #include "php_hash_haval.h"
diff --git a/ext/hash/hash_md.c b/ext/hash/hash_md.c
index 6423aef..419466f 100644
--- a/ext/hash/hash_md.c
+++ b/ext/hash/hash_md.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_md.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: hash_md.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_hash.h"
 #include "php_hash_md.h"
diff --git a/ext/hash/hash_ripemd.c b/ext/hash/hash_ripemd.c
index a3e9972..95c14e4 100644
--- a/ext/hash/hash_ripemd.c
+++ b/ext/hash/hash_ripemd.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_ripemd.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: hash_ripemd.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Heavily borrowed from md5.c & sha1.c of PHP archival fame
    Note that ripemd laughs in the face of logic and uses
diff --git a/ext/hash/hash_salsa.c b/ext/hash/hash_salsa.c
index 0b14466..357ce2e 100644
--- a/ext/hash/hash_salsa.c
+++ b/ext/hash/hash_salsa.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_salsa.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: hash_salsa.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_hash.h"
 #include "php_hash_salsa.h"
diff --git a/ext/hash/hash_sha.c b/ext/hash/hash_sha.c
index 177919d..b3e3f89 100644
--- a/ext/hash/hash_sha.c
+++ b/ext/hash/hash_sha.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_sha.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: hash_sha.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_hash.h"
 #include "php_hash_sha.h"
diff --git a/ext/hash/hash_snefru.c b/ext/hash/hash_snefru.c
index 56a5aaa..c91c7e4 100644
--- a/ext/hash/hash_snefru.c
+++ b/ext/hash/hash_snefru.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_snefru.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: hash_snefru.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_hash.h"
 #include "php_hash_snefru.h"
diff --git a/ext/hash/hash_tiger.c b/ext/hash/hash_tiger.c
index eba5226..5674eb2 100644
--- a/ext/hash/hash_tiger.c
+++ b/ext/hash/hash_tiger.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_tiger.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: hash_tiger.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_hash.h"
 #include "php_hash_tiger.h"
diff --git a/ext/hash/hash_whirlpool.c b/ext/hash/hash_whirlpool.c
index 18947f5..9ddc69b 100644
--- a/ext/hash/hash_whirlpool.c
+++ b/ext/hash/hash_whirlpool.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: hash_whirlpool.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: hash_whirlpool.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_hash.h"
 
diff --git a/ext/hash/php_hash.h b/ext/hash/php_hash.h
index 93e57be..3ae7905 100644
--- a/ext/hash/php_hash.h
+++ b/ext/hash/php_hash.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_H
 #define PHP_HASH_H
diff --git a/ext/hash/php_hash_adler32.h b/ext/hash/php_hash_adler32.h
index 4d1e86c..b42da4c 100644
--- a/ext/hash/php_hash_adler32.h
+++ b/ext/hash/php_hash_adler32.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_adler32.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_adler32.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_ADLER32_H
 #define PHP_HASH_ADLER32_H
diff --git a/ext/hash/php_hash_crc32.h b/ext/hash/php_hash_crc32.h
index d41f7e3..0631091 100644
--- a/ext/hash/php_hash_crc32.h
+++ b/ext/hash/php_hash_crc32.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_crc32.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_crc32.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_CRC32_H
 #define PHP_HASH_CRC32_H
diff --git a/ext/hash/php_hash_crc32_tables.h b/ext/hash/php_hash_crc32_tables.h
index 5a4d82f..ce1b162 100644
--- a/ext/hash/php_hash_crc32_tables.h
+++ b/ext/hash/php_hash_crc32_tables.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_crc32_tables.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_crc32_tables.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 static const php_hash_uint32 crc32_table[] = {  0x0,
 	0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
diff --git a/ext/hash/php_hash_gost.h b/ext/hash/php_hash_gost.h
index ac025eb..9fbe9c0 100644
--- a/ext/hash/php_hash_gost.h
+++ b/ext/hash/php_hash_gost.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_gost.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_gost.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_GOST_H
 #define PHP_HASH_GOST_H
diff --git a/ext/hash/php_hash_haval.h b/ext/hash/php_hash_haval.h
index 2675486..76d6a45 100644
--- a/ext/hash/php_hash_haval.h
+++ b/ext/hash/php_hash_haval.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_haval.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_haval.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_HAVAL_H
 #define PHP_HASH_HAVAL_H
diff --git a/ext/hash/php_hash_md.h b/ext/hash/php_hash_md.h
index 7256032..8394ae5 100644
--- a/ext/hash/php_hash_md.h
+++ b/ext/hash/php_hash_md.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_md.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_md.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_MD_H
 #define PHP_HASH_MD_H
diff --git a/ext/hash/php_hash_ripemd.h b/ext/hash/php_hash_ripemd.h
index 41680de..eab0505 100644
--- a/ext/hash/php_hash_ripemd.h
+++ b/ext/hash/php_hash_ripemd.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_ripemd.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_ripemd.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_RIPEMD_H
 #define PHP_HASH_RIPEMD_H
diff --git a/ext/hash/php_hash_salsa.h b/ext/hash/php_hash_salsa.h
index 57609c7..2a6a589 100644
--- a/ext/hash/php_hash_salsa.h
+++ b/ext/hash/php_hash_salsa.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_salsa.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_salsa.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_SALSA_H
 #define PHP_HASH_SALSA_H
diff --git a/ext/hash/php_hash_sha.h b/ext/hash/php_hash_sha.h
index 4dcc785..213f329 100644
--- a/ext/hash/php_hash_sha.h
+++ b/ext/hash/php_hash_sha.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_sha.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_sha.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_SHA_H
 #define PHP_HASH_SHA_H
diff --git a/ext/hash/php_hash_snefru.h b/ext/hash/php_hash_snefru.h
index 7d47210..b016064 100644
--- a/ext/hash/php_hash_snefru.h
+++ b/ext/hash/php_hash_snefru.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_snefru.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_snefru.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_SNEFRU_H
 #define PHP_HASH_SNEFRU_H
diff --git a/ext/hash/php_hash_snefru_tables.h b/ext/hash/php_hash_snefru_tables.h
index 94304ce..4d5f4ab 100644
--- a/ext/hash/php_hash_snefru_tables.h
+++ b/ext/hash/php_hash_snefru_tables.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_snefru_tables.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_snefru_tables.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 static const php_hash_uint32 tables[16][256]= {
 
diff --git a/ext/hash/php_hash_tiger.h b/ext/hash/php_hash_tiger.h
index 70b6b68..78b05e1 100644
--- a/ext/hash/php_hash_tiger.h
+++ b/ext/hash/php_hash_tiger.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_tiger.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_tiger.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_TIGER_H
 #define PHP_HASH_TIGER_H
diff --git a/ext/hash/php_hash_tiger_tables.h b/ext/hash/php_hash_tiger_tables.h
index 9de52a7..9e1f2f5 100644
--- a/ext/hash/php_hash_tiger_tables.h
+++ b/ext/hash/php_hash_tiger_tables.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_tiger_tables.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_tiger_tables.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define t1 (table)
 #define t2 (table+256)
diff --git a/ext/hash/php_hash_types.h b/ext/hash/php_hash_types.h
index 9cb50b9..6e52662 100644
--- a/ext/hash/php_hash_types.h
+++ b/ext/hash/php_hash_types.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_types.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_types.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_TYPES_H
 #define PHP_HASH_TYPES_H
diff --git a/ext/hash/php_hash_whirlpool.h b/ext/hash/php_hash_whirlpool.h
index 841c5ab..a871c23 100644
--- a/ext/hash/php_hash_whirlpool.h
+++ b/ext/hash/php_hash_whirlpool.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_whirlpool.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_whirlpool.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_WHIRLPOOL_H
 #define PHP_HASH_WHIRLPOOL_H
diff --git a/ext/hash/php_hash_whirlpool_tables.h b/ext/hash/php_hash_whirlpool_tables.h
index 5624558..d40e80b 100644
--- a/ext/hash/php_hash_whirlpool_tables.h
+++ b/ext/hash/php_hash_whirlpool_tables.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_whirlpool_tables.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_hash_whirlpool_tables.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HASH_WHIRLPOOL_TABLES_H
 #define PHP_HASH_WHIRLPOOL_TABLES_H
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index e5ef4b3..8007fec 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: iconv.c 277327 2009-03-17 05:31:04Z moriyoshi $ */
+/* $Id: iconv.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/iconv/php_iconv.h b/ext/iconv/php_iconv.h
index a19e56f..332ff33 100644
--- a/ext/iconv/php_iconv.h
+++ b/ext/iconv/php_iconv.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,21 +17,21 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Revision: 272370 $ */
+/* $Revision: 293978 $ */
 
 #ifndef PHP_ICONV_H
 #define PHP_ICONV_H
 
 #ifdef PHP_WIN32
-#	ifdef PHP_ICONV_EXPORTS
-#		define PHP_ICONV_API __declspec(dllexport)
-#	else
-#		define PHP_ICONV_API __declspec(dllimport)
-#	endif 
+# ifdef PHP_ICONV_EXPORTS
+#  define PHP_ICONV_API __declspec(dllexport)
+# else
+#  define PHP_ICONV_API __declspec(dllimport)
+# endif 
 #elif defined(__GNUC__) && __GNUC__ >= 4
-#	define PHP_ICONV_API __attribute__ ((visibility("default")))
+# define PHP_ICONV_API __attribute__ ((visibility("default")))
 #else
-#	define PHP_ICONV_API
+# define PHP_ICONV_API
 #endif
 
 #ifdef PHP_ATOM_INC
@@ -45,7 +45,6 @@
 #include "ext/iconv/php_php_iconv_h_path.h"
 #endif
 
-
 #ifdef HAVE_ICONV
 extern zend_module_entry iconv_module_entry;
 #define iconv_module_ptr &iconv_module_entry
@@ -73,9 +72,9 @@ ZEND_BEGIN_MODULE_GLOBALS(iconv)
 ZEND_END_MODULE_GLOBALS(iconv)
 
 #ifdef ZTS
-#define ICONVG(v) TSRMG(iconv_globals_id, zend_iconv_globals *, v)
+# define ICONVG(v) TSRMG(iconv_globals_id, zend_iconv_globals *, v)
 #else
-#define ICONVG(v) (iconv_globals.v)
+# define ICONVG(v) (iconv_globals.v)
 #endif
 
 #ifdef HAVE_IBM_ICONV
@@ -122,7 +121,6 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char * in_p, size_t in_len,
 
 #endif	/* PHP_ICONV_H */
 
-
 /*
  * Local variables:
  * tab-width: 4
diff --git a/ext/iconv/tests/iconv_encoding_basic.phpt b/ext/iconv/tests/iconv_encoding_basic.phpt
index 150f49b..7468581 100644
--- a/ext/iconv/tests/iconv_encoding_basic.phpt
+++ b/ext/iconv/tests/iconv_encoding_basic.phpt
@@ -5,6 +5,10 @@ Test iconv_get_encoding()/iconv_set_encoding() function : basic functionality
 extension_loaded('iconv') or die('skip');
 function_exists('iconv_get_encoding') or die("skip iconv_get_encoding() is not available in this build");
 ?>
+--INI--
+iconv.input_encoding=ISO-8859-1
+iconv.internal_encoding=ISO-8859-1
+iconv.output_encoding=ISO-8859-1
 --FILE--
 <?php
 /* Prototype  : mixed iconv_get_encoding([string type])
@@ -91,4 +95,4 @@ array(3) {
   ["internal_encoding"]=>
   string(5) "UTF-8"
 }
-Done
\ No newline at end of file
+Done
diff --git a/ext/iconv/tests/iconv_substr_basic.phpt b/ext/iconv/tests/iconv_substr_basic.phpt
index b8db8a1..0754fc8 100644
--- a/ext/iconv/tests/iconv_substr_basic.phpt
+++ b/ext/iconv/tests/iconv_substr_basic.phpt
@@ -5,6 +5,10 @@ Test iconv_substr() function : basic functionality
 extension_loaded('iconv') or die('skip');
 function_exists('iconv_substr') or die("skip iconv_substr() is not available in this build");
 ?>
+--INI--
+iconv.input_encoding=ISO-8859-1
+iconv.internal_encoding=ISO-8859-1
+iconv.output_encoding=ISO-8859-1
 --FILE--
 <?php
 /* Prototype  : string iconv_substr(string str, int offset, [int length, string charset])
@@ -52,4 +56,4 @@ string(14) "a5e69cace8aa9e"
 
 -- Multibyte string 2 --
 string(42) "e8aa9ee38386e382ade382b9e38388e381a7e38199"
-Done
\ No newline at end of file
+Done
diff --git a/ext/imap/config.m4 b/ext/imap/config.m4
index 96671e0..61f65ca 100644
--- a/ext/imap/config.m4
+++ b/ext/imap/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 279937 2009-05-05 01:22:44Z jani $
+dnl $Id: config.m4 294699 2010-02-07 13:06:54Z pajoye $
 dnl
 
 AC_DEFUN([IMAP_INC_CHK],[if test -r "$i$1/c-client.h"; then
@@ -147,23 +147,23 @@ if test "$PHP_IMAP" != "no"; then
 
     old_CFLAGS=$CFLAGS
     CFLAGS="-I$IMAP_INC_DIR"
-    AC_CACHE_CHECK(for U8T_CANONICAL, ac_cv_u8t_canonical,
+    AC_CACHE_CHECK(for U8T_DECOMPOSE, ac_cv_u8t_canonical,
       AC_TRY_COMPILE([
 #include <c-client.h>
       ],[
          int i = U8T_CANONICAL;
       ],[
-         ac_cv_u8t_canonical=yes
+         ac_cv_u8t_decompose=yes
       ],[
-         ac_cv_u8t_canonical=no
+         ac_cv_u8t_decompose=no
       ])
     )
     CFLAGS=$old_CFLAGS
 
-    if test "$ac_cv_u8t_canonical" = "no" && test "$ac_cv_utf8_mime2text" = "new"; then
+    if test "$ac_cv_u8t_decompose" = "no" && test "$ac_cv_utf8_mime2text" = "new"; then
 		AC_MSG_ERROR([utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.])
     fi
-    if test "$ac_cv_u8t_canonical" = "yes" && test "$ac_cv_utf8_mime2text" = "old"; then
+    if test "$ac_cv_u8t_decompose" = "yes" && test "$ac_cv_utf8_mime2text" = "old"; then
 		AC_MSG_ERROR([utf8_mime2text() has old signature, but U8T_CANONICAL is present. This should not happen. Check config.log for additional information.])
     fi
 
diff --git a/ext/imap/config.w32 b/ext/imap/config.w32
index 41c1b46..c9742b1 100644
--- a/ext/imap/config.w32
+++ b/ext/imap/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32 279950 2009-05-05 01:51:13Z jani $
+// $Id: config.w32 294699 2010-02-07 13:06:54Z pajoye $
 // vim:ft=javascript
 
 ARG_WITH("imap", "IMAP Support", "no");
@@ -21,6 +21,7 @@ if (PHP_IMAP == "yes") {
 		AC_DEFINE('HAVE_NEW_MIME2TEXT', 1, 'Have utf8_mime2text', true);
 		AC_DEFINE('HAVE_RFC822_OUTPUT_ADDRESS_LIST', 1, 'Have rfc822_output_address_list', true);
 		AC_DEFINE('HAVE_IMAP_MUTF7', 1, 'Have modified utf7 support', true);
+		AC_DEFINE('HAVE_NEW_MIME2TEXT', 1, 'Whether utf8_mime2text() has new signature');
 	} else {
 		WARNING("imap not enabled; libraries and headers not found");
 	}
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index f821942..34e55fc 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -26,7 +26,7 @@
    | PHP 4.0 updates:  Zeev Suraski <zeev at zend.com>                       |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_imap.c 289435 2009-10-09 17:38:19Z pajoye $ */
+/* $Id: php_imap.c 294699 2010-02-07 13:06:54Z pajoye $ */
 
 #define IMAP41
 
@@ -41,6 +41,7 @@
 #include "ext/standard/info.h"
 #include "ext/standard/file.h"
 #include "ext/standard/php_smart_str.h"
+#include "ext/pcre/php_pcre.h"
 
 #ifdef ERROR
 #undef ERROR
@@ -104,6 +105,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_open, 0, 0, 3)
 	ZEND_ARG_INFO(0, password)
 	ZEND_ARG_INFO(0, options)
 	ZEND_ARG_INFO(0, n_retries)
+	ZEND_ARG_INFO(0, params)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_reopen, 0, 0, 2)
@@ -118,6 +120,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_append, 0, 0, 3)
 	ZEND_ARG_INFO(0, folder)
 	ZEND_ARG_INFO(0, message)
 	ZEND_ARG_INFO(0, options)
+	ZEND_ARG_INFO(0, date)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_num_msg, 0, 0, 1)
@@ -1146,10 +1149,11 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 	long retries = 0, flags = NIL, cl_flags = NIL;
 	MAILSTREAM *imap_stream;
 	pils *imap_le_struct;
+	zval *params = NULL;
 	int argc = ZEND_NUM_ARGS();
 
-	if (zend_parse_parameters(argc TSRMLS_CC, "sss|ll", &mailbox, &mailbox_len, &user, &user_len,
-		&passwd, &passwd_len, &flags, &retries) == FAILURE) {
+	if (zend_parse_parameters(argc TSRMLS_CC, "sss|lla", &mailbox, &mailbox_len, &user, &user_len,
+		&passwd, &passwd_len, &flags, &retries, &params) == FAILURE) {
 		return;
 	}
 
@@ -1163,6 +1167,46 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 		}
 	}
 
+	if (params) {
+		zval **disabled_auth_method;
+
+		if (zend_hash_find(HASH_OF(params), "DISABLE_AUTHENTICATOR", sizeof("DISABLE_AUTHENTICATOR"), (void **)&disabled_auth_method) == SUCCESS) {
+			switch (Z_TYPE_PP(disabled_auth_method)) {
+				case IS_STRING:
+					if (Z_STRLEN_PP(disabled_auth_method) > 1) {
+						mail_parameters (NIL, DISABLE_AUTHENTICATOR, (void *)Z_STRVAL_PP(disabled_auth_method));
+					}
+					break;
+				case IS_ARRAY:
+					{
+						zval **z_auth_method;
+						int i;
+						int nelems = zend_hash_num_elements(Z_ARRVAL_PP(disabled_auth_method));
+
+						if (nelems == 0 ) {
+							break;
+						}
+						for (i = 0; i < nelems; i++) {
+							if (zend_hash_index_find(Z_ARRVAL_PP(disabled_auth_method), i, (void **) &z_auth_method) == SUCCESS) {
+								if (Z_TYPE_PP(z_auth_method) == IS_STRING) {
+									if (Z_STRLEN_PP(z_auth_method) > 1) {
+										mail_parameters (NIL, DISABLE_AUTHENTICATOR, (void *)Z_STRVAL_PP(disabled_auth_method));
+									}
+								} else {
+									php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument, expect string or array of strings");
+								}
+							}
+						}
+					}
+					break;
+				case IS_LONG:
+				default:
+					php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument, expect string or array of strings");
+					break;
+			}
+		}
+	}
+
 	if (IMAPG(imap_user)) {
 		efree(IMAPG(imap_user));
 	}
@@ -1265,25 +1309,47 @@ PHP_FUNCTION(imap_reopen)
 }
 /* }}} */
 
-/* {{{ proto bool imap_append(resource stream_id, string folder, string message [, string options])
+/* {{{ proto bool imap_append(resource stream_id, string folder, string message [, string options [, string internal_date]])
    Append a new message to a specified mailbox */
 PHP_FUNCTION(imap_append)
 {
 	zval *streamind;
-	char *folder, *message, *flags = NULL;
-	int folder_len, message_len, flags_len = 0;
+	char *folder, *message, *internal_date = NULL, *flags = NULL;
+	int folder_len, message_len, internal_date_len = 0, flags_len = 0;
 	pils *imap_le_struct;
 	STRING st;
-
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss|s", &streamind, &folder, &folder_len, &message, &message_len, &flags, &flags_len) == FAILURE) {
+	char* regex = "/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/";
+	const int regex_len = strlen(regex);
+	pcre_cache_entry *pce;				/* Compiled regex */
+	zval *subpats = NULL;				/* Parts (not used) */
+	long regex_flags = 0;				/* Flags (not used) */
+	long start_offset = 0;				/* Start offset (not used) */
+	int global = 0;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss|ss", &streamind, &folder, &folder_len, &message, &message_len, &flags, &flags_len, &internal_date, &internal_date_len) == FAILURE) {
 		return;
 	}
 
+	if (internal_date) {
+		/* Make sure the given internal_date string matches the RFC specifiedformat */
+		if ((pce = pcre_get_compiled_regex_cache(regex, regex_len TSRMLS_CC))== NULL) {
+			RETURN_FALSE;
+		}
+
+		php_pcre_match_impl(pce, internal_date, internal_date_len, return_value, subpats, global,
+			0, regex_flags, start_offset TSRMLS_CC);
+
+		if (!Z_LVAL_P(return_value)) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "internal date not correctly formatted");
+			internal_date = NULL;
+		}
+	}
+
 	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
 
 	INIT (&st, mail_string, (void *) message, message_len);
 
-	if (mail_append_full(imap_le_struct->imap_stream, folder, (flags ? flags : NIL), NIL, &st)) {
+	if (mail_append_full(imap_le_struct->imap_stream, folder, (flags ? flags : NIL), (internal_date ? internal_date : NIL), &st)) {
 		RETURN_TRUE;
 	} else {
 		RETURN_FALSE;
@@ -2598,7 +2664,7 @@ PHP_FUNCTION(imap_utf8)
 #ifndef HAVE_NEW_MIME2TEXT
 	utf8_mime2text(&src, &dest);
 #else
-	utf8_mime2text(&src, &dest, U8T_CANONICAL);
+	utf8_mime2text(&src, &dest, U8T_DECOMPOSE);
 #endif
 	RETVAL_STRINGL(dest.data, dest.size, 1);
 	if (dest.data) {
diff --git a/ext/imap/php_imap.h b/ext/imap/php_imap.h
index 5b7524b..9d869d2 100644
--- a/ext/imap/php_imap.h
+++ b/ext/imap/php_imap.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -27,7 +27,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_imap.h 279937 2009-05-05 01:22:44Z jani $ */
+/* $Id: php_imap.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_IMAP_H
 #define PHP_IMAP_H
diff --git a/ext/imap/tests/bug44098.phpt b/ext/imap/tests/bug44098.phpt
new file mode 100644
index 0000000..f758c11
--- /dev/null
+++ b/ext/imap/tests/bug44098.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #44098 (imap_utf8() returns only capital letters)
+--SKIPIF--
+<?php
+        if (!extension_loaded("imap")) { 
+                die("skip imap extension not available");  
+        }
+?>
+--FILE--
+<?php
+$exp = 'Luzon®14 dot CoM';
+$res = imap_utf8('=?iso-8859-1?b?THV6b26uMTQ=?= dot CoM');
+if ($res != $exp) {
+	echo "failed: got <$res>, expected <exp>\n";
+} else {
+	echo "ok";
+}
+?>
+--EXPECT--
+ok
diff --git a/ext/imap/tests/imap_body.phpt b/ext/imap/tests/imap_body.phpt
index 08f63db..40f35f0 100644
--- a/ext/imap/tests/imap_body.phpt
+++ b/ext/imap/tests/imap_body.phpt
@@ -15,6 +15,18 @@ imap_body();
 echo  "Checking with incorrect parameter type\n";
 imap_body('');
 imap_body(false);
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = imap_open($default_mailbox, $username, $password) or 
+	die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
+imap_body($stream_id);
+imap_body($stream_id,-1);
+imap_body($stream_id,1,-1);
+
+//Access not existing
+var_dump(imap_body($stream_id, 999, FT_UID));
+
+imap_close($stream_id);
+
 ?>
 --EXPECTF--
 Checking with no parameters
@@ -25,3 +37,12 @@ Checking with incorrect parameter type
 Warning: imap_body() expects at least 2 parameters, 1 given in %s on line %d
 
 Warning: imap_body() expects at least 2 parameters, 1 given in %s on line %d
+
+Warning: imap_body() expects at least 2 parameters, 1 given in %s on line %d
+
+Warning: imap_body(): Bad message number in %s on line %d
+
+Warning: imap_body(): invalid value for the options parameter in %s on line %d
+
+Warning: imap_body(): Bad message number in %s on line %d
+bool(false)
\ No newline at end of file
diff --git a/ext/imap/tests/imap_body_basic.phpt b/ext/imap/tests/imap_body_basic.phpt
index 7cd5181..0eb4a2b 100644
--- a/ext/imap/tests/imap_body_basic.phpt
+++ b/ext/imap/tests/imap_body_basic.phpt
@@ -27,6 +27,9 @@ echo "Msg Count in new mailbox: ". $check->Nmsgs . "\n";
 // show body for msg 1
 var_dump(imap_body($imap_stream, 1));
 
+//Access via FT_UID
+var_dump(imap_body($imap_stream, 1, FT_UID));
+
 imap_close($imap_stream);
 ?>
 ===Done===
@@ -40,5 +43,6 @@ Create a new mailbox for test
 Create a temporary mailbox and add 1 msgs
 .. mailbox '%s' created
 Msg Count in new mailbox: 1
-string(%d) "1: this is a test message, please ignore%a"
-===Done===
\ No newline at end of file
+%unicode|string%(%d) "1: this is a test message, please ignore%a"
+%unicode|string%(%d) "1: this is a test message, please ignore%a"
+===Done===
diff --git a/ext/imap/tests/imap_bodystruct_basic.phpt b/ext/imap/tests/imap_bodystruct_basic.phpt
index 4edc753..cc643a6 100644
--- a/ext/imap/tests/imap_bodystruct_basic.phpt
+++ b/ext/imap/tests/imap_bodystruct_basic.phpt
@@ -77,7 +77,7 @@ require_once('clean.inc');
 *** Testing string imap_bodystruct : basic functionality ***
 Create a new mailbox for test and add a multipart msgs
 Create a temporary mailbox and add 1 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 Get and validate structure of body part 1
 ifsubtype is 0 or 1
diff --git a/ext/imap/tests/imap_clearflag_full_basic.phpt b/ext/imap/tests/imap_clearflag_full_basic.phpt
index fb7465d..4269688 100644
--- a/ext/imap/tests/imap_clearflag_full_basic.phpt
+++ b/ext/imap/tests/imap_clearflag_full_basic.phpt
@@ -56,7 +56,7 @@ require_once('clean.inc');
 *** Testing imap_clearflag_full() : basic functionality ***
 Create a new mailbox for test
 Create a temporary mailbox and add 10 msgs
-.. mailbox '{localhost/norsh}INBOX.%s' created
+.. mailbox '{%s}%s' created
 Initial msg count in new_mailbox : 10
 Set some flags
 bool(true)
diff --git a/ext/imap/tests/imap_close_variation2.phpt b/ext/imap/tests/imap_close_variation2.phpt
index 6378e88..feadfed 100644
--- a/ext/imap/tests/imap_close_variation2.phpt
+++ b/ext/imap/tests/imap_close_variation2.phpt
@@ -118,7 +118,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_close() : usage variations ***
 Create a temporary mailbox and add 3 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- Iteration 1 --
 bool(true)
diff --git a/ext/imap/tests/imap_close_variation4.phpt b/ext/imap/tests/imap_close_variation4.phpt
index 65b0578..ca82619 100644
--- a/ext/imap/tests/imap_close_variation4.phpt
+++ b/ext/imap/tests/imap_close_variation4.phpt
@@ -66,7 +66,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_close() : usage variations ***
 Create a temporary mailbox and add 3 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- Iteration 1 --
 bool(true)
diff --git a/ext/imap/tests/imap_fetch_overview_basic.phpt b/ext/imap/tests/imap_fetch_overview_basic.phpt
index 80d5c69..2b4623f 100644
--- a/ext/imap/tests/imap_fetch_overview_basic.phpt
+++ b/ext/imap/tests/imap_fetch_overview_basic.phpt
@@ -77,7 +77,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetch_overview() : basic functionality ***
 Create a temporary mailbox and add 2 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- All possible arguments --
 
diff --git a/ext/imap/tests/imap_fetch_overview_error.phpt b/ext/imap/tests/imap_fetch_overview_error.phpt
index 2fc0f34..e300e62 100644
--- a/ext/imap/tests/imap_fetch_overview_error.phpt
+++ b/ext/imap/tests/imap_fetch_overview_error.phpt
@@ -42,7 +42,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 
 -- Testing imap_fetch_overview() function with more than expected no. of arguments --
 Create a temporary mailbox and add 2 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 Warning: imap_fetch_overview() expects at most 3 parameters, 4 given in %s on line %d
 NULL
diff --git a/ext/imap/tests/imap_fetch_overview_variation2.phpt b/ext/imap/tests/imap_fetch_overview_variation2.phpt
index dfc3783..8634cef 100644
--- a/ext/imap/tests/imap_fetch_overview_variation2.phpt
+++ b/ext/imap/tests/imap_fetch_overview_variation2.phpt
@@ -136,7 +136,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetch_overview() : usage variations ***
 Create a temporary mailbox and add 1 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- Testing with second argument value: int(0)
 Sequence out of range
diff --git a/ext/imap/tests/imap_fetch_overview_variation3.phpt b/ext/imap/tests/imap_fetch_overview_variation3.phpt
index 5fa56b5..7bd78d8 100644
--- a/ext/imap/tests/imap_fetch_overview_variation3.phpt
+++ b/ext/imap/tests/imap_fetch_overview_variation3.phpt
@@ -56,7 +56,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetch_overview() : usage variations ***
 Create a temporary mailbox and add 1 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 Testing with option value:%string|unicode%(1) "1"
 imap_fetch_overview() returns an object
diff --git a/ext/imap/tests/imap_fetch_overview_variation5.phpt b/ext/imap/tests/imap_fetch_overview_variation5.phpt
index 79861be..d5bc888 100644
--- a/ext/imap/tests/imap_fetch_overview_variation5.phpt
+++ b/ext/imap/tests/imap_fetch_overview_variation5.phpt
@@ -67,7 +67,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetch_overview() : usage variations ***
 Create a temporary mailbox and add 3 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- $msg_no is 0 --
 Sequence out of range
diff --git a/ext/imap/tests/imap_fetch_overview_variation6.phpt b/ext/imap/tests/imap_fetch_overview_variation6.phpt
index fda937e..6ee65f6 100644
--- a/ext/imap/tests/imap_fetch_overview_variation6.phpt
+++ b/ext/imap/tests/imap_fetch_overview_variation6.phpt
@@ -110,7 +110,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetch_overview() : usage variations ***
 Create a temporary mailbox and add 0 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 --> Object #1
 size is %d
diff --git a/ext/imap/tests/imap_fetchbody_basic.phpt b/ext/imap/tests/imap_fetchbody_basic.phpt
index 469d498..66b84b1 100644
--- a/ext/imap/tests/imap_fetchbody_basic.phpt
+++ b/ext/imap/tests/imap_fetchbody_basic.phpt
@@ -64,7 +64,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetchbody() : basic functionality ***
 Create a temporary mailbox and add 1 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- All possible arguments --
 -- Option is FT_UID --
diff --git a/ext/imap/tests/imap_fetchbody_error.phpt b/ext/imap/tests/imap_fetchbody_error.phpt
index 77b7164..f496fbd 100644
--- a/ext/imap/tests/imap_fetchbody_error.phpt
+++ b/ext/imap/tests/imap_fetchbody_error.phpt
@@ -45,7 +45,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 
 -- Testing imap_fetchbody() function with more than expected no. of arguments --
 Create a temporary mailbox and add 1 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 Warning: imap_fetchbody() expects at most 4 parameters, 5 given in %s on line %d
 NULL
diff --git a/ext/imap/tests/imap_fetchbody_variation2.phpt b/ext/imap/tests/imap_fetchbody_variation2.phpt
index e80ac39..64b7a32 100644
--- a/ext/imap/tests/imap_fetchbody_variation2.phpt
+++ b/ext/imap/tests/imap_fetchbody_variation2.phpt
@@ -103,7 +103,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetchbody() : usage variations ***
 Create a temporary mailbox and add 1 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- Iteration 1 --
 
diff --git a/ext/imap/tests/imap_fetchbody_variation4.phpt b/ext/imap/tests/imap_fetchbody_variation4.phpt
index 6b9579a..d8126bc 100644
--- a/ext/imap/tests/imap_fetchbody_variation4.phpt
+++ b/ext/imap/tests/imap_fetchbody_variation4.phpt
@@ -53,7 +53,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetchbody() : usage variations ***
 Create a temporary mailbox and add 1 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- Iteration 1 --
 FT_UID valid
diff --git a/ext/imap/tests/imap_fetchbody_variation6.phpt b/ext/imap/tests/imap_fetchbody_variation6.phpt
index 608a045..52a50a7 100644
--- a/ext/imap/tests/imap_fetchbody_variation6.phpt
+++ b/ext/imap/tests/imap_fetchbody_variation6.phpt
@@ -44,7 +44,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetchbody() : usage variations ***
 Create a temporary mailbox and add 3 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- $msg_no is 0 --
 
diff --git a/ext/imap/tests/imap_fetchheader_variation2.phpt b/ext/imap/tests/imap_fetchheader_variation2.phpt
index d2269ad..fe11577 100644
--- a/ext/imap/tests/imap_fetchheader_variation2.phpt
+++ b/ext/imap/tests/imap_fetchheader_variation2.phpt
@@ -118,7 +118,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetchheader() : usage variations ***
 Create a temporary mailbox and add 1 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- Iteration 1 --
 
@@ -128,7 +128,7 @@ bool(false)
 -- Iteration 2 --
 %unicode|string%(%d) "From: foo at anywhere.com
 Subject: Test msg 1
-To: webmaster at something.com
+To: %s
 MIME-Version: 1.0
 Content-Type: MULTIPART/mixed; BOUNDARY="%s"
 
@@ -182,7 +182,7 @@ bool(false)
 -- Iteration 12 --
 %unicode|string%(%d) "From: foo at anywhere.com
 Subject: Test msg 1
-To: webmaster at something.com
+To: %s
 MIME-Version: 1.0
 Content-Type: MULTIPART/mixed; BOUNDARY="%s"
 
@@ -196,7 +196,7 @@ bool(false)
 -- Iteration 14 --
 %unicode|string%(%d) "From: foo at anywhere.com
 Subject: Test msg 1
-To: webmaster at something.com
+To: %s
 MIME-Version: 1.0
 Content-Type: MULTIPART/mixed; BOUNDARY="%s"
 
diff --git a/ext/imap/tests/imap_fetchheader_variation3.phpt b/ext/imap/tests/imap_fetchheader_variation3.phpt
index e21c1a9..feba766 100644
--- a/ext/imap/tests/imap_fetchheader_variation3.phpt
+++ b/ext/imap/tests/imap_fetchheader_variation3.phpt
@@ -51,7 +51,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetchheader() : usage variations ***
 Create a temporary mailbox and add 1 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- Iteration 1 --
 FT_UID valid
diff --git a/ext/imap/tests/imap_fetchheader_variation5.phpt b/ext/imap/tests/imap_fetchheader_variation5.phpt
index 6f5b426..ed2aa84 100644
--- a/ext/imap/tests/imap_fetchheader_variation5.phpt
+++ b/ext/imap/tests/imap_fetchheader_variation5.phpt
@@ -45,7 +45,7 @@ require_once(dirname(__FILE__).'/clean.inc');
 --EXPECTF--
 *** Testing imap_fetchheader() : usage variations ***
 Create a temporary mailbox and add 3 msgs
-.. mailbox '{localhost/norsh}INBOX.phpttest' created
+.. mailbox '{%s}%s' created
 
 -- $msg_no is 0 --
 
@@ -64,7 +64,7 @@ bool(false)
 Notice: A non well formed numeric value encountered in %s on line %d
 %unicode|string%(%d) "From: foo at anywhere.com
 Subject: Test msg 1
-To: webmaster at something.com
+To: %s
 MIME-Version: 1.0
 Content-Type: MULTIPART/mixed; BOUNDARY="%s"
 
@@ -75,7 +75,7 @@ Content-Type: MULTIPART/mixed; BOUNDARY="%s"
 Notice: A non well formed numeric value encountered in %s on line %d
 %unicode|string%(%d) "From: foo at anywhere.com
 Subject: Test msg 1
-To: webmaster at something.com
+To: %s
 MIME-Version: 1.0
 Content-Type: MULTIPART/mixed; BOUNDARY="%s"
 
diff --git a/ext/imap/tests/imap_fetchstructure_basic.phpt b/ext/imap/tests/imap_fetchstructure_basic.phpt
new file mode 100644
index 0000000..7ad4fc5
--- /dev/null
+++ b/ext/imap/tests/imap_fetchstructure_basic.phpt
@@ -0,0 +1,70 @@
+--TEST--
+imap_fetchstructure() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_fetchstructure();
+
+echo  "Checking with incorrect parameter type\n";
+imap_fetchstructure('');
+imap_fetchstructure(false);
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = setup_test_mailbox('', 1);
+
+imap_fetchstructure($stream_id);
+imap_fetchstructure($stream_id,0);
+
+$z = imap_fetchstructure($stream_id,1);
+
+
+$fields = array('type','encoding','ifsubtype','subtype',
+'ifdescription','lines','bytes','parameters');
+
+foreach ($fields as $key) {
+	var_dump(isset($z->$key));
+}
+var_dump($z->type);
+var_dump($z->encoding);
+var_dump($z->bytes);
+var_dump($z->lines);
+var_dump(is_object($z->parameters));
+
+imap_close($stream_id);
+?>
+--CLEAN--
+<?php 
+require_once('clean.inc');
+?>
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_fetchstructure() expects at least 2 parameters, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_fetchstructure() expects at least 2 parameters, 1 given in %s on line %d
+
+Warning: imap_fetchstructure() expects at least 2 parameters, 1 given in %s on line %d
+Create a temporary mailbox and add 1 msgs
+.. mailbox '{%s}%s' created
+
+Warning: imap_fetchstructure() expects at least 2 parameters, 1 given in %s on line %d
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+bool(true)
\ No newline at end of file
diff --git a/ext/imap/tests/imap_gc_error.phpt b/ext/imap/tests/imap_gc_error.phpt
index c0830c0..f8e6201 100644
--- a/ext/imap/tests/imap_gc_error.phpt
+++ b/ext/imap/tests/imap_gc_error.phpt
@@ -16,6 +16,11 @@ echo  "Checking with incorrect parameter type\n";
 imap_gc('', false);
 imap_gc(false, false);
 
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = imap_open($default_mailbox, $username, $password) or 
+	die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
+imap_gc($stream_id, -1);
+
 ?>
 --EXPECTF--
 Checking with no parameters
@@ -26,3 +31,5 @@ Checking with incorrect parameter type
 Warning: imap_gc() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d
 
 Warning: imap_gc() expects parameter 1 to be resource, boolean given in %s on line %d
+
+Warning: imap_gc(): invalid value for the flags parameter in %s on line %d
diff --git a/ext/imap/tests/imap_getsubscribed_basic.phpt b/ext/imap/tests/imap_getsubscribed_basic.phpt
new file mode 100644
index 0000000..ba8a42d
--- /dev/null
+++ b/ext/imap/tests/imap_getsubscribed_basic.phpt
@@ -0,0 +1,68 @@
+--TEST--
+imap_getsubscribed() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_getsubscribed();
+
+echo  "Checking with incorrect parameter type\n";
+imap_getsubscribed('');
+imap_getsubscribed(false);
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = imap_open($default_mailbox, $username, $password) or 
+	die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
+
+imap_getsubscribed($stream_id);
+imap_getsubscribed($stream_id,$default_mailbox);
+var_dump(imap_getsubscribed($stream_id,$default_mailbox,'ezDvfXvbvcxSerz'));
+
+
+echo "Checking OK\n";
+
+$newbox = $default_mailbox . "." . $mailbox_prefix;
+
+imap_createmailbox($stream_id, $newbox);
+imap_subscribe($stream_id, $newbox);
+
+$z = imap_getsubscribed($stream_id,$default_mailbox,'*');
+
+var_dump(is_array($z));
+var_dump($z[0]);
+
+imap_close($stream_id);
+?>
+--CLEAN--
+<?php 
+require_once('clean.inc');
+?>
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_getsubscribed() expects exactly 3 parameters, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_getsubscribed() expects exactly 3 parameters, 1 given in %s on line %d
+
+Warning: imap_getsubscribed() expects exactly 3 parameters, 1 given in %s on line %d
+
+Warning: imap_getsubscribed() expects exactly 3 parameters, 1 given in %s on line %d
+
+Warning: imap_getsubscribed() expects exactly 3 parameters, 2 given in %s on line %d
+bool(false)
+Checking OK
+bool(true)
+object(stdClass)#%d (%d) {
+  [%sname"]=>
+  string(%d) "{%s}%s"
+  [%sattributes"]=>
+  int(%d)
+  [%sdelimiter"]=>
+  string(%d) "%s"
+}
\ No newline at end of file
diff --git a/ext/imap/tests/imap_headerinfo_basic.phpt b/ext/imap/tests/imap_headerinfo_basic.phpt
new file mode 100644
index 0000000..b772476
--- /dev/null
+++ b/ext/imap/tests/imap_headerinfo_basic.phpt
@@ -0,0 +1,129 @@
+--TEST--
+imap_headerinfo() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = setup_test_mailbox('', 1);
+
+$z = imap_headerinfo($stream_id, 1);
+
+$fields = array ('toaddress','to','fromaddress','from',
+'reply_toaddress','reply_to',
+	'senderaddress', 'sender', 
+'subject','Subject',
+	'Recent','Unseen','Flagged','Answered','Deleted','Draft',
+	'Msgno','MailDate','Size','udate');
+
+echo "Check general fields\n";
+foreach ($fields as $key) {
+	var_dump(isset($z->$key));
+}
+
+echo "Check type\n";
+var_dump($z->toaddress);
+var_dump($z->fromaddress);
+var_dump($z->reply_toaddress);
+var_dump($z->senderaddress);
+var_dump($z->subject);
+var_dump($z->Subject);
+
+if ($z->Recent == 'R' || $z->Recent == 'N' || $z->Recent == ' ') {
+	echo "Recent: OK";
+} else {
+	echo "Recent: error: ".$z->Recent;
+}
+echo "\n";
+
+if ($z->Unseen == 'U' || $z->Unseen == ' ') {
+	echo "Unseen: OK";
+} else {
+	echo "Unseen: error: ".$z->Unseen;
+}
+echo "\n";
+
+if ($z->Flagged == 'F' || $z->Flagged == ' ') {
+	echo "Flagged: OK";
+} else {
+	echo "Flagged: error: ".$z->Flagged;
+}
+echo "\n";
+
+if ($z->Answered == 'A' || $z->Answered == ' ') {
+	echo "Answered: OK";
+} else {
+	echo "Answered: error";
+}
+echo "\n";
+
+if ($z->Deleted == 'D' || $z->Deleted == ' ') {
+	echo "Deleted: OK";
+} else {
+	echo "Deleted: error";
+}
+echo "\n";
+
+if ($z->Draft == 'X' || $z->Draft == ' ') {
+	echo "Draft: OK";
+} else {
+	echo "Draft: error";
+}
+echo "\n";
+
+var_dump($z->Msgno);
+var_dump($z->Size);
+var_dump($z->udate);
+
+imap_close($stream_id);
+
+?>
+--CLEAN--
+<?php 
+require_once('clean.inc');
+?>
+--EXPECTF--
+Create a temporary mailbox and add 1 msgs
+.. mailbox '{%s}%s' created
+Check general fields
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Check type
+string(%d) "%s"
+string(%d) "%s"
+string(%d) "%s"
+string(%d) "%s"
+string(%d) "%s"
+string(%d) "%s"
+Recent: OK
+Unseen: OK
+Flagged: OK
+Answered: OK
+Deleted: OK
+Draft: OK
+string(%d) "%s"
+string(%d) "%d"
+int(%d)
\ No newline at end of file
diff --git a/ext/imap/tests/imap_headerinfo_error.phpt b/ext/imap/tests/imap_headerinfo_error.phpt
new file mode 100644
index 0000000..b526096
--- /dev/null
+++ b/ext/imap/tests/imap_headerinfo_error.phpt
@@ -0,0 +1,36 @@
+--TEST--
+imap_headerinfo() incorrect parameter count
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_headerinfo();
+
+echo  "Checking with incorrect parameter type\n";
+imap_headerinfo('');
+imap_headerinfo(false);
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = imap_open($default_mailbox, $username, $password) or 
+	die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
+	
+imap_headerinfo($stream_id);
+
+imap_close($stream_id);
+?>
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_headerinfo() expects at least 2 parameters, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_headerinfo() expects at least 2 parameters, 1 given in %s on line %d
+
+Warning: imap_headerinfo() expects at least 2 parameters, 1 given in %s on line %d
+
+Warning: imap_headerinfo() expects at least 2 parameters, 1 given in %s on line %d
diff --git a/ext/imap/tests/imap_list_basic.phpt b/ext/imap/tests/imap_list_basic.phpt
new file mode 100644
index 0000000..36f07f7
--- /dev/null
+++ b/ext/imap/tests/imap_list_basic.phpt
@@ -0,0 +1,47 @@
+--TEST--
+imap_list() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_list();
+
+echo  "Checking with incorrect parameter type\n";
+imap_list('');
+imap_list(false);
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = imap_open($default_mailbox, $username, $password) or 
+	die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
+
+imap_list($stream_id);
+imap_list($stream_id,$default_mailbox);
+imap_list($stream_id,$default_mailbox,'ezerz');
+
+
+$z = imap_list($stream_id,$default_mailbox,'*');
+var_dump(is_array($z));
+var_dump($z[0]);
+
+imap_close($stream_id);
+?>
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_list() expects exactly 3 parameters, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_list() expects exactly 3 parameters, 1 given in %s on line %d
+
+Warning: imap_list() expects exactly 3 parameters, 1 given in %s on line %d
+
+Warning: imap_list() expects exactly 3 parameters, 1 given in %s on line %d
+
+Warning: imap_list() expects exactly 3 parameters, 2 given in %s on line %d
+bool(true)
+string(%s) "{%s}%s"
\ No newline at end of file
diff --git a/ext/imap/tests/imap_lsub_basic.phpt b/ext/imap/tests/imap_lsub_basic.phpt
new file mode 100644
index 0000000..153ca2a
--- /dev/null
+++ b/ext/imap/tests/imap_lsub_basic.phpt
@@ -0,0 +1,61 @@
+--TEST--
+imap_lsub() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_lsub();
+
+echo  "Checking with incorrect parameter type\n";
+imap_lsub('');
+imap_lsub(false);
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = imap_open($default_mailbox, $username, $password) or 
+	die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
+
+imap_lsub($stream_id);
+imap_lsub($stream_id,$default_mailbox);
+var_dump(imap_lsub($stream_id,$default_mailbox,'ezDvfXvbvcxSerz'));
+
+
+echo "Checking OK\n";
+
+$newbox = $default_mailbox . "." . $mailbox_prefix;
+
+imap_createmailbox($stream_id, $newbox);
+imap_subscribe($stream_id, $newbox);
+
+$z = imap_lsub($stream_id,$default_mailbox,'*');
+
+var_dump(is_array($z));
+var_dump($z[0]);
+
+imap_close($stream_id);
+?>
+--CLEAN--
+<?php 
+require_once('clean.inc');
+?>
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_lsub() expects exactly 3 parameters, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_lsub() expects exactly 3 parameters, 1 given in %s on line %d
+
+Warning: imap_lsub() expects exactly 3 parameters, 1 given in %s on line %d
+
+Warning: imap_lsub() expects exactly 3 parameters, 1 given in %s on line %d
+
+Warning: imap_lsub() expects exactly 3 parameters, 2 given in %s on line %d
+bool(false)
+Checking OK
+bool(true)
+string(%s) "{%s}%s"
\ No newline at end of file
diff --git a/ext/imap/tests/imap_mail_copy.phpt b/ext/imap/tests/imap_mail_copy.phpt
new file mode 100644
index 0000000..47c5e61
--- /dev/null
+++ b/ext/imap/tests/imap_mail_copy.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Test imap_mail_copy() incorrect parameters
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_mail_copy();
+
+
+echo  "Checking with incorrect parameter type\n";
+imap_mail_copy('');
+imap_mail_copy(false);
+
+
+// more tests
+require_once(dirname(__FILE__).'/imap_include.inc');
+
+
+echo "Test with IMAP server\n";
+$stream_id = imap_open($default_mailbox, $username, $password) or 
+	die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
+	
+var_dump(imap_mail_copy($stream_id));
+var_dump(imap_mail_copy($stream_id,-1));
+var_dump(imap_mail_copy($stream_id, ''));
+
+imap_close($stream_id);
+?>
+===Done===
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_mail_copy() expects at least 3 parameters, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_mail_copy() expects at least 3 parameters, 1 given in %s on line %d
+
+Warning: imap_mail_copy() expects at least 3 parameters, 1 given in %s on line %d
+Test with IMAP server
+
+Warning: imap_mail_copy() expects at least 3 parameters, 1 given in %s on line %d
+NULL
+
+Warning: imap_mail_copy() expects at least 3 parameters, 2 given in %s on line %d
+NULL
+
+Warning: imap_mail_copy() expects at least 3 parameters, 2 given in %s on line %d
+NULL
+===Done===
\ No newline at end of file
diff --git a/ext/imap/tests/imap_mail_copy_basic.phpt b/ext/imap/tests/imap_mail_copy_basic.phpt
new file mode 100644
index 0000000..a7b9421
--- /dev/null
+++ b/ext/imap/tests/imap_mail_copy_basic.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Test imap_mail_copy() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+/* Prototype  : bool imap_mail_copy  ( resource $imap_stream  , string $msglist  , string $mailbox  [, int $options = 0  ] )
+ * Description: Copies mail messages specified by msglist  to specified mailbox. 
+ * Source code: ext/imap/php_imap.c
+ */
+
+echo "*** Testing imap_mail_copy() : basic functionality ***\n";
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+
+
+echo "Create a new mailbox for test\n";
+$imap_stream = setup_test_mailbox("", 1);
+if (!is_resource($imap_stream)) {
+	exit("TEST FAILED: Unable to create test mailbox\n");
+}
+
+$check = imap_check($imap_stream);
+echo "Msg Count in new mailbox: ". $check->Nmsgs . "\n";    
+
+var_dump(imap_mail_copy($imap_stream, '1', 'INBOX.'.$mailbox_prefix));
+
+imap_close($imap_stream);
+?>
+===Done===
+--CLEAN--
+<?php 
+require_once('clean.inc');
+?>
+--EXPECTF--
+*** Testing imap_mail_copy() : basic functionality ***
+Create a new mailbox for test
+Create a temporary mailbox and add 1 msgs
+.. mailbox '%s' created
+Msg Count in new mailbox: 1
+bool(true)
+===Done===
\ No newline at end of file
diff --git a/ext/imap/tests/imap_mail_move.phpt b/ext/imap/tests/imap_mail_move.phpt
new file mode 100644
index 0000000..67ddea7
--- /dev/null
+++ b/ext/imap/tests/imap_mail_move.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Test imap_mail_move() incorrect parameters
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_mail_move();
+
+
+echo  "Checking with incorrect parameter type\n";
+imap_mail_move('');
+imap_mail_move(false);
+
+
+// more tests
+require_once(dirname(__FILE__).'/imap_include.inc');
+
+
+echo "Test with IMAP server\n";
+$stream_id = imap_open($default_mailbox, $username, $password) or 
+	die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
+	
+var_dump(imap_mail_move($stream_id));
+var_dump(imap_mail_move($stream_id,-1));
+var_dump(imap_mail_move($stream_id, ''));
+
+imap_close($stream_id);
+?>
+===Done===
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_mail_move() expects at least 3 parameters, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_mail_move() expects at least 3 parameters, 1 given in %s on line %d
+
+Warning: imap_mail_move() expects at least 3 parameters, 1 given in %s on line %d
+Test with IMAP server
+
+Warning: imap_mail_move() expects at least 3 parameters, 1 given in %s on line %d
+NULL
+
+Warning: imap_mail_move() expects at least 3 parameters, 2 given in %s on line %d
+NULL
+
+Warning: imap_mail_move() expects at least 3 parameters, 2 given in %s on line %d
+NULL
+===Done===
\ No newline at end of file
diff --git a/ext/imap/tests/imap_mail_move_basic.phpt b/ext/imap/tests/imap_mail_move_basic.phpt
new file mode 100644
index 0000000..a543582
--- /dev/null
+++ b/ext/imap/tests/imap_mail_move_basic.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Test imap_mail_move() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+/* Prototype  : bool imap_mail_move  ( resource $imap_stream  , string $msglist  , string $mailbox  [, int $options = 0  ] )
+ * Description: Copies mail messages specified by msglist  to specified mailbox. 
+ * Source code: ext/imap/php_imap.c
+ */
+
+echo "*** Testing imap_mail_move() : basic functionality ***\n";
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+
+
+echo "Create a new mailbox for test\n";
+$imap_stream = setup_test_mailbox("", 1);
+if (!is_resource($imap_stream)) {
+	exit("TEST FAILED: Unable to create test mailbox\n");
+}
+
+$check = imap_check($imap_stream);
+echo "Msg Count in new mailbox: ". $check->Nmsgs . "\n";    
+
+var_dump(imap_mail_move($imap_stream, '1', 'INBOX.'.$mailbox_prefix));
+
+imap_close($imap_stream);
+?>
+===Done===
+--CLEAN--
+<?php 
+require_once('clean.inc');
+?>
+--EXPECTF--
+*** Testing imap_mail_move() : basic functionality ***
+Create a new mailbox for test
+Create a temporary mailbox and add 1 msgs
+.. mailbox '%s' created
+Msg Count in new mailbox: 1
+bool(true)
+===Done===
\ No newline at end of file
diff --git a/ext/imap/tests/imap_open_error.phpt b/ext/imap/tests/imap_open_error.phpt
index 7934ee2..83b0eba 100644
--- a/ext/imap/tests/imap_open_error.phpt
+++ b/ext/imap/tests/imap_open_error.phpt
@@ -20,6 +20,9 @@ echo "Checking with incorrect parameters\n" ;
 imap_open('', '', '');
 imap_open('', '', '', -1);
 
+require_once(dirname(__FILE__).'/imap_include.inc');
+imap_open($default_mailbox, $username, $password, NIL, -1);
+
 ?>
 --EXPECTF--
 Checking with no parameters
@@ -39,4 +42,6 @@ Warning: imap_open(): Couldn't open stream  in %s on line %d
 
 Warning: imap_open(): Couldn't open stream  in %s on line %d
 
+Warning: imap_open(): Retries must be greater or equal to 0 in %s on line %d
+
 Notice: Unknown: Can't open mailbox : no such mailbox (errflg=2) in Unknown on line 0
diff --git a/ext/imap/tests/imap_renamemailbox_basic.phpt b/ext/imap/tests/imap_renamemailbox_basic.phpt
new file mode 100644
index 0000000..b445f1d
--- /dev/null
+++ b/ext/imap/tests/imap_renamemailbox_basic.phpt
@@ -0,0 +1,66 @@
+--TEST--
+imap_renamemailbox() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_renamemailbox();
+
+echo  "Checking with incorrect parameter type\n";
+imap_renamemailbox('');
+imap_renamemailbox(false);
+
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+	
+$stream_id = setup_test_mailbox('', 1);
+
+if (!is_resource($stream_id)) {
+	exit("TEST FAILED: Unable to create test mailbox\n");
+}
+
+$newbox = $default_mailbox . "." . $mailbox_prefix;
+
+imap_renamemailbox($stream_id, $newbox.'not');
+imap_renamemailbox($stream_id, $newbox);
+
+//commented because of bug #49901
+//$ancError = error_reporting(0);
+//$z = imap_renamemailbox($stream_id, $newbox.'not2', $newbox.'2');
+//var_dump($z);
+//error_reporting($ancError);
+echo "Checking OK\n";
+
+
+var_dump(imap_createmailbox($stream_id, $newbox.'.test'));
+var_dump(imap_renamemailbox($stream_id, $newbox.'.test', $newbox.'.testd'));
+
+imap_close($stream_id);
+?>
+--CLEAN--
+<?php 
+require_once('clean.inc');
+?>
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_renamemailbox() expects exactly 3 parameters, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_renamemailbox() expects exactly 3 parameters, 1 given in %s on line %d
+
+Warning: imap_renamemailbox() expects exactly 3 parameters, 1 given in %s on line %d
+Create a temporary mailbox and add 1 msgs
+.. mailbox '{%s}%s' created
+
+Warning: imap_renamemailbox() expects exactly 3 parameters, 2 given in %s on line %d
+
+Warning: imap_renamemailbox() expects exactly 3 parameters, 2 given in %s on line %d
+Checking OK
+bool(true)
+bool(true)
diff --git a/ext/imap/tests/imap_rfc822_parse_headers_basic.phpt b/ext/imap/tests/imap_rfc822_parse_headers_basic.phpt
new file mode 100644
index 0000000..e425392
--- /dev/null
+++ b/ext/imap/tests/imap_rfc822_parse_headers_basic.phpt
@@ -0,0 +1,122 @@
+--TEST--
+imap_rfc822_parse_headers() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = setup_test_mailbox('', 1);
+
+$z = imap_headerinfo($stream_id, 1);
+
+$fields = array ('toaddress','to','fromaddress','from',
+'reply_toaddress','reply_to',
+	'senderaddress', 'sender', 
+'subject','Subject',
+	'MailDate','Size','udate');
+
+
+echo "Check general fields\n";
+foreach ($fields as $key) {
+	var_dump(isset($z->$key));
+}
+
+echo "Check type\n";
+var_dump($z->toaddress);
+var_dump($z->fromaddress);
+var_dump($z->reply_toaddress);
+var_dump($z->senderaddress);
+var_dump($z->subject);
+var_dump($z->Subject);
+
+if ($z->Recent == 'R' || $z->Recent == 'N' || $z->Recent == ' ') {
+	echo "Recent: OK";
+} else {
+	echo "Recent: error";
+}
+echo "\n";
+
+if ($z->Unseen == 'U' || $z->Unseen == ' ') {
+	echo "Unseen: OK";
+} else {
+	echo "Unseen: error";
+}
+echo "\n";
+
+if ($z->Flagged == 'F' || $z->Flagged == ' ') {
+	echo "Flagged: OK";
+} else {
+	echo "Flagged: error";
+}
+echo "\n";
+
+if ($z->Answered == 'A' || $z->Answered == ' ') {
+	echo "Answered: OK";
+} else {
+	echo "Answered: error";
+}
+echo "\n";
+
+if ($z->Deleted == 'D' || $z->Deleted == ' ') {
+	echo "Deleted: OK";
+} else {
+	echo "Deleted: error";
+}
+echo "\n";
+
+if ($z->Draft == 'X' || $z->Draft == ' ') {
+	echo "Draft: OK";
+} else {
+	echo "Draft: error";
+}
+echo "\n";
+
+var_dump($z->Msgno);
+var_dump($z->Size);
+var_dump($z->udate);
+
+imap_close($stream_id);
+
+?>
+--CLEAN--
+<?php 
+require_once('clean.inc');
+?>
+--EXPECTF--
+Create a temporary mailbox and add 1 msgs
+.. mailbox '{%s}%s' created
+Check general fields
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Check type
+string(%d) "%s"
+string(%d) "%s"
+string(%d) "%s"
+string(%d) "%s"
+string(%d) "%s"
+string(%d) "%s"
+Recent: OK
+Unseen: OK
+Flagged: OK
+Answered: OK
+Deleted: OK
+Draft: OK
+string(%d) "%s"
+string(%d) "%d"
+int(%d)
\ No newline at end of file
diff --git a/ext/imap/tests/imap_savebody_basic.phpt b/ext/imap/tests/imap_savebody_basic.phpt
new file mode 100644
index 0000000..91e6ce0
--- /dev/null
+++ b/ext/imap/tests/imap_savebody_basic.phpt
@@ -0,0 +1,61 @@
+--TEST--
+imap_savebody() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_savebody();
+
+echo  "Checking with incorrect parameter type\n";
+imap_savebody('');
+imap_savebody(false);
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = setup_test_mailbox('', 1);
+
+imap_savebody($stream_id);
+
+$file = dirname(__FILE__).'/tmpsavebody.txt';
+
+//with URL
+$z = imap_savebody($stream_id, $file, 1);
+var_dump($z);
+echo "Size: ".filesize($file)."\n";
+
+//With FOPEN
+$fp = fopen($file, 'w');
+$z = imap_savebody($stream_id, $fp, 1);
+fclose($fp);
+var_dump($z);
+echo "Size: ".filesize($file)."\n";
+
+imap_close($stream_id);
+?>
+--CLEAN--
+<?php 
+ at unlink(dirname(__FILE__).'/tmpsavebody.txt');
+require_once('clean.inc');
+?>
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_savebody() expects at least 3 parameters, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_savebody() expects at least 3 parameters, 1 given in %s on line %d
+
+Warning: imap_savebody() expects at least 3 parameters, 1 given in %s on line %d
+Create a temporary mailbox and add 1 msgs
+.. mailbox '{%s}%s' created
+
+Warning: imap_savebody() expects at least 3 parameters, 1 given in %s on line %d
+bool(true)
+Size: %d
+bool(true)
+Size: %d
+
diff --git a/ext/imap/tests/imap_timeout_basic.phpt b/ext/imap/tests/imap_timeout_basic.phpt
new file mode 100644
index 0000000..c2727e5
--- /dev/null
+++ b/ext/imap/tests/imap_timeout_basic.phpt
@@ -0,0 +1,60 @@
+--TEST--
+imap_timeout() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_timeout();
+
+echo  "Checking with incorrect parameter type\n";
+imap_timeout('');
+imap_timeout(false);
+
+echo "GET values:\n";
+var_dump(imap_timeout(IMAP_OPENTIMEOUT));
+var_dump(imap_timeout(IMAP_READTIMEOUT));
+var_dump(imap_timeout(IMAP_WRITETIMEOUT));
+var_dump(imap_timeout(IMAP_CLOSETIMEOUT));
+
+echo "SET values:\n";
+var_dump(imap_timeout(IMAP_OPENTIMEOUT, 10));
+var_dump(imap_timeout(IMAP_READTIMEOUT, 10));
+var_dump(imap_timeout(IMAP_WRITETIMEOUT, 10));
+
+//IMAP_CLOSETIMEOUT not implemented
+//var_dump(imap_timeout(IMAP_CLOSETIMEOUT, 10));
+
+echo "CHECK values:\n";
+var_dump(imap_timeout(IMAP_OPENTIMEOUT));
+var_dump(imap_timeout(IMAP_READTIMEOUT));
+var_dump(imap_timeout(IMAP_WRITETIMEOUT));
+
+//IMAP_CLOSETIMEOUT not implemented
+//var_dump(imap_timeout(IMAP_CLOSETIMEOUT));
+
+?>
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_timeout() expects at least 1 parameter, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_timeout() expects parameter 1 to be long, %s given in %s on line %d
+GET values:
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+SET values:
+bool(true)
+bool(true)
+bool(true)
+CHECK values:
+int(10)
+int(10)
+int(10)
diff --git a/ext/imap/tests/imap_undelete_basic.phpt b/ext/imap/tests/imap_undelete_basic.phpt
new file mode 100644
index 0000000..4b48b1b
--- /dev/null
+++ b/ext/imap/tests/imap_undelete_basic.phpt
@@ -0,0 +1,29 @@
+--TEST--
+imap_undelete() function : basic functionality 
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = setup_test_mailbox('', 1);
+
+imap_delete($stream_id, 1);
+
+var_dump(imap_undelete($stream_id, 1));
+
+imap_close($stream_id);
+
+?>
+--CLEAN--
+<?php 
+require_once('clean.inc');
+?>
+--EXPECTF--
+Create a temporary mailbox and add 1 msgs
+.. mailbox '{%s}%s' created
+bool(true)
\ No newline at end of file
diff --git a/ext/imap/tests/imap_undelete_error.phpt b/ext/imap/tests/imap_undelete_error.phpt
new file mode 100644
index 0000000..c82801e
--- /dev/null
+++ b/ext/imap/tests/imap_undelete_error.phpt
@@ -0,0 +1,36 @@
+--TEST--
+imap_undelete() incorrect parameter count
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+echo "Checking with no parameters\n";
+imap_undelete();
+
+echo  "Checking with incorrect parameter type\n";
+imap_undelete('');
+imap_undelete(false);
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+$stream_id = imap_open($default_mailbox, $username, $password) or 
+	die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
+	
+imap_undelete($stream_id);
+
+imap_close($stream_id);
+?>
+--EXPECTF--
+Checking with no parameters
+
+Warning: imap_undelete() expects at least 2 parameters, 0 given in %s on line %d
+Checking with incorrect parameter type
+
+Warning: imap_undelete() expects at least 2 parameters, 1 given in %s on line %d
+
+Warning: imap_undelete() expects at least 2 parameters, 1 given in %s on line %d
+
+Warning: imap_undelete() expects at least 2 parameters, 1 given in %s on line %d
diff --git a/ext/interbase/ibase_blobs.c b/ext/interbase/ibase_blobs.c
index bbbddbd..91c3d25 100644
--- a/ext/interbase/ibase_blobs.c
+++ b/ext/interbase/ibase_blobs.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ibase_blobs.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: ibase_blobs.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/interbase/ibase_events.c b/ext/interbase/ibase_events.c
index 51ff0cc..77b33ad 100644
--- a/ext/interbase/ibase_events.c
+++ b/ext/interbase/ibase_events.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ibase_events.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: ibase_events.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/interbase/ibase_query.c b/ext/interbase/ibase_query.c
index 6ef8301..8a58593 100644
--- a/ext/interbase/ibase_query.c
+++ b/ext/interbase/ibase_query.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ibase_query.c 286330 2009-07-25 23:37:47Z kalle $ */
+/* $Id: ibase_query.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/interbase/ibase_service.c b/ext/interbase/ibase_service.c
index 0801afc..92060d2 100644
--- a/ext/interbase/ibase_service.c
+++ b/ext/interbase/ibase_service.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ibase_service.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: ibase_service.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c
index 054c4ab..18ffbf2 100644
--- a/ext/interbase/interbase.c
+++ b/ext/interbase/interbase.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: interbase.c 284159 2009-07-16 00:04:59Z rasmus $ */
+/* $Id: interbase.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/interbase/php_ibase_includes.h b/ext/interbase/php_ibase_includes.h
index 4f02164..b83a32d 100755
--- a/ext/interbase/php_ibase_includes.h
+++ b/ext/interbase/php_ibase_includes.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_ibase_includes.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_ibase_includes.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_IBASE_INCLUDES_H
 #define PHP_IBASE_INCLUDES_H
diff --git a/ext/interbase/php_ibase_udf.c b/ext/interbase/php_ibase_udf.c
index 2816e95..d285ddc 100644
--- a/ext/interbase/php_ibase_udf.c
+++ b/ext/interbase/php_ibase_udf.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_ibase_udf.c 281727 2009-06-05 18:50:32Z mattwil $ */
+/* $Id: php_ibase_udf.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /**
 * This UDF library adds the ability to call PHP functions from SQL
diff --git a/ext/interbase/php_interbase.h b/ext/interbase/php_interbase.h
index 785cee8..2aa60ff 100644
--- a/ext/interbase/php_interbase.h
+++ b/ext/interbase/php_interbase.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_interbase.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_interbase.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
diff --git a/ext/intl/collator/collator_class.c b/ext/intl/collator/collator_class.c
index d064a2b..ee16ee0 100755
--- a/ext/intl/collator/collator_class.c
+++ b/ext/intl/collator/collator_class.c
@@ -125,6 +125,7 @@ function_entry Collator_class_functions[] = {
 	PHP_NAMED_FE( getLocale, ZEND_FN( collator_get_locale ), collator_1_arg )
 	PHP_NAMED_FE( getErrorCode, ZEND_FN( collator_get_error_code ), collator_0_args )
 	PHP_NAMED_FE( getErrorMessage, ZEND_FN( collator_get_error_message ), collator_0_args )
+	PHP_NAMED_FE( getSortKey, ZEND_FN( collator_get_sort_key ), collator_2_args )
 	{ NULL, NULL, NULL }
 };
 /* }}} */
diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c
index efe4ca6..929a9c0 100755
--- a/ext/intl/collator/collator_sort.c
+++ b/ext/intl/collator/collator_sort.c
@@ -523,6 +523,69 @@ PHP_FUNCTION( collator_asort )
 }
 /* }}} */
 
+/* {{{ proto bool Collator::getSortKey( Collator $coll, string $str )
+ * Get a sort key for a string from a Collator. }}} */
+/* {{{ proto bool collator_get_sort_key( Collator $coll, string $str )
+ * Get a sort key for a string from a Collator. }}} */
+PHP_FUNCTION( collator_get_sort_key )
+{
+	char*            str      = NULL;
+	int              str_len  = 0;
+	UChar*           ustr     = NULL;
+	int              ustr_len = 0;
+	uint8_t*         key     = NULL;
+	int              key_len = 0;
+
+	COLLATOR_METHOD_INIT_VARS
+
+	/* Parse parameters. */
+	if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os",
+		&object, Collator_ce_ptr, &str, &str_len ) == FAILURE )
+	{
+		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+			 "collator_get_sort_key: unable to parse input params", 0 TSRMLS_CC );
+
+		RETURN_FALSE;
+	}
+
+	/* Fetch the object. */
+	COLLATOR_METHOD_FETCH_OBJECT;
+
+
+	/*
+	 * Compare given strings (converting them to UTF-16 first).
+	 */
+
+	/* First convert the strings to UTF-16. */
+	intl_convert_utf8_to_utf16(
+		&ustr, &ustr_len, str, str_len, COLLATOR_ERROR_CODE_P( co ) );
+	if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) )
+	{
+		/* Set global error code. */
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+
+		/* Set error messages. */
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Error converting first argument to UTF-16", 0 TSRMLS_CC );
+		efree( ustr );
+		RETURN_FALSE;
+	}
+
+	key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, key, 0);
+	if(!key_len) {
+		efree( ustr );
+		RETURN_FALSE;
+	}
+	key = emalloc(key_len);
+	key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, key, key_len);
+	efree( ustr );
+	if(!key_len) {
+		RETURN_FALSE;
+	}
+	RETURN_STRINGL((char *)key, key_len, 0);
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
diff --git a/ext/intl/collator/collator_sort.h b/ext/intl/collator/collator_sort.h
index 0fafb9f..a990cdf 100755
--- a/ext/intl/collator/collator_sort.h
+++ b/ext/intl/collator/collator_sort.h
@@ -24,6 +24,7 @@ typedef int (*collator_compare_func_t)( zval *result, zval *op1, zval *op2 TSRML
 
 PHP_FUNCTION( collator_sort );
 PHP_FUNCTION( collator_sort_with_sort_keys );
+PHP_FUNCTION( collator_get_sort_key );
 PHP_FUNCTION( collator_asort );
 
 #endif // COLLATOR_SORT_H
diff --git a/ext/intl/config.m4 b/ext/intl/config.m4
index 9735b44..dc235db 100755
--- a/ext/intl/config.m4
+++ b/ext/intl/config.m4
@@ -52,6 +52,9 @@ if test "$PHP_INTL" != "no"; then
     msgformat/msgformat_parse.c \
     grapheme/grapheme_string.c \
     grapheme/grapheme_util.c \
+    resourcebundle/resourcebundle.c \
+    resourcebundle/resourcebundle_class.c \
+    resourcebundle/resourcebundle_iterator.c \
     idn/idn.c, $ext_shared,,$ICU_INCS)
 
   PHP_ADD_BUILD_DIR($ext_builddir/collator)
@@ -62,5 +65,6 @@ if test "$PHP_INTL" != "no"; then
   PHP_ADD_BUILD_DIR($ext_builddir/locale)
   PHP_ADD_BUILD_DIR($ext_builddir/msgformat)
   PHP_ADD_BUILD_DIR($ext_builddir/grapheme)
+  PHP_ADD_BUILD_DIR($ext_builddir/resourcebundle)
   PHP_ADD_BUILD_DIR($ext_builddir/idn)
 fi
diff --git a/ext/intl/config.w32 b/ext/intl/config.w32
index e7b6129..6635b89 100755
--- a/ext/intl/config.w32
+++ b/ext/intl/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32 274681 2009-01-26 22:34:49Z pajoye $
+// $Id: config.w32 294108 2010-01-27 17:29:38Z johannes $
 // vim:ft=javascript
 
 ARG_ENABLE("intl", "Enable internationalization support", "no");
@@ -66,6 +66,11 @@ if (PHP_INTL != "no") {
 		ADD_SOURCES(configure_module_dirname + "/idn", "\
 				idn.c",
 				"intl");
+		ADD_SOURCES(configure_module_dirname + "/resourcebundle", "\
+				resourcebundle.c \
+				resourcebundle_class.c \
+				resourcebundle_iterator.c",
+				"intl");
 		ADD_FLAG("LIBS_INTL", "icudt.lib icuin.lib icuio.lib icule.lib iculx.lib");
 		AC_DEFINE("HAVE_INTL", 1, "Internationalization support enabled");
 	} else {
diff --git a/ext/intl/dateformat/dateformat.c b/ext/intl/dateformat/dateformat.c
index 0eac9e9..6f74322 100755
--- a/ext/intl/dateformat/dateformat.c
+++ b/ext/intl/dateformat/dateformat.c
@@ -181,8 +181,7 @@ PHP_METHOD( IntlDateFormatter, __construct )
  */
 PHP_FUNCTION( datefmt_get_error_code )
 {
-	zval*                    object  = NULL;
-	IntlDateFormatter_object*  dfo     = NULL;
+	DATE_FORMAT_METHOD_INIT_VARS;
 
 	/* Parse parameters. */
 	if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
@@ -208,8 +207,7 @@ PHP_FUNCTION( datefmt_get_error_code )
 PHP_FUNCTION( datefmt_get_error_message )
 {
 	char*                    message = NULL;
-	zval*                    object  = NULL;
-	IntlDateFormatter_object*  dfo     = NULL;
+	DATE_FORMAT_METHOD_INIT_VARS;
 
 	/* Parse parameters. */
 	if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
@@ -224,7 +222,7 @@ PHP_FUNCTION( datefmt_get_error_message )
 	dfo = (IntlDateFormatter_object *) zend_object_store_get_object( object TSRMLS_CC );
 
 	/* Return last error message. */
-	message = intl_error_get_message( &dfo->datef_data.error TSRMLS_CC );
+	message = intl_error_get_message( INTL_DATA_ERROR_P(dfo) TSRMLS_CC );
 	RETURN_STRING( message, 0);
 }
 /* }}} */
diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.c
index e2454d5..8fa1756 100755
--- a/ext/intl/formatter/formatter_main.c
+++ b/ext/intl/formatter/formatter_main.c
@@ -141,7 +141,7 @@ PHP_FUNCTION( numfmt_get_error_message )
 	nfo = (NumberFormatter_object *) zend_object_store_get_object( object TSRMLS_CC );
 
 	/* Return last error message. */
-	message = intl_error_get_message( &INTL_DATA_ERROR(nfo) TSRMLS_CC );
+	message = intl_error_get_message( INTL_DATA_ERROR_P(nfo) TSRMLS_CC );
 	RETURN_STRING( message, 0);
 }
 /* }}} */
diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c
index edac518..ba883f3 100755
--- a/ext/intl/grapheme/grapheme_string.c
+++ b/ext/intl/grapheme/grapheme_string.c
@@ -83,7 +83,7 @@ PHP_FUNCTION(grapheme_strlen)
 		intl_error_set_code( NULL, status TSRMLS_CC );
 
 		/* Set error messages. */
-		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
 		efree( ustring );
 		RETURN_NULL();
 	}
@@ -446,7 +446,7 @@ PHP_FUNCTION(grapheme_substr)
 		intl_error_set_code( NULL, status TSRMLS_CC );
 
 		/* Set error messages. */
-		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
 		efree( ustr );
 		RETURN_FALSE;
 	}
@@ -507,7 +507,7 @@ PHP_FUNCTION(grapheme_substr)
 			intl_error_set_code( NULL, status TSRMLS_CC );
 
 			/* Set error messages. */
-			intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 1 TSRMLS_CC );
+			intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 TSRMLS_CC );
 
 			efree( sub_str );
 
@@ -563,7 +563,7 @@ PHP_FUNCTION(grapheme_substr)
 		intl_error_set_code( NULL, status TSRMLS_CC );
 
 		/* Set error messages. */
-		intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 1 TSRMLS_CC );
+		intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 TSRMLS_CC );
 
 		if ( NULL != sub_str )
 			efree( sub_str );
@@ -870,7 +870,7 @@ PHP_FUNCTION(grapheme_extract)
 		intl_error_set_code( NULL, status TSRMLS_CC );
 
 		/* Set error messages. */
-		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
 
 		if ( NULL != ustr )
 			efree( ustr );
diff --git a/ext/intl/grapheme/grapheme_util.c b/ext/intl/grapheme/grapheme_util.c
index 375c695..1978d27 100755
--- a/ext/intl/grapheme/grapheme_util.c
+++ b/ext/intl/grapheme/grapheme_util.c
@@ -169,7 +169,7 @@ grapheme_strrpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned c
         intl_error_set_code( NULL, status TSRMLS_CC );
 
         /* Set error messages. */
-        intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+        intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
         efree( uhaystack );
         return -1;
     }
@@ -202,7 +202,7 @@ grapheme_strrpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned c
         intl_error_set_code( NULL, status TSRMLS_CC );
 
         /* Set error messages. */
-        intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+        intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
         efree( uhaystack );
         efree( uneedle );
         ubrk_close (bi);
@@ -294,7 +294,7 @@ grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned ch
 		intl_error_set_code( NULL, status TSRMLS_CC );
 
 		/* Set error messages. */
-		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
 		efree( uhaystack );
 		return -1;
 	}
@@ -331,7 +331,7 @@ grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned ch
 		intl_error_set_code( NULL, status TSRMLS_CC );
 
 		/* Set error messages. */
-		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
 		efree( uhaystack );
 		efree( uneedle );
 		ubrk_close (bi);
diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c
index ca7e9e7..158b76e 100644
--- a/ext/intl/idn/idn.c
+++ b/ext/intl/idn/idn.c
@@ -15,7 +15,7 @@
    | Author: Pierre A. Joye <pierre at php.net>                              |
    +----------------------------------------------------------------------+
  */
-/* $Id: idn.c 283618 2009-07-06 23:48:27Z stas $ */
+/* $Id: idn.c 293979 2010-01-25 13:59:35Z johannes $ */
 
 /* {{{ includes */
 #ifdef HAVE_CONFIG_H
@@ -84,7 +84,7 @@ static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS, int mode)
 		intl_error_set_code(NULL, status TSRMLS_CC);
 
 		/* Set error messages. */
-		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
 		efree(ustring);
 		RETURN_FALSE;
 	} else {
@@ -111,7 +111,7 @@ static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS, int mode)
 			intl_error_set_code(NULL, status TSRMLS_CC);
 
 			/* Set error messages. */
-			intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 1 TSRMLS_CC );
+			intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 TSRMLS_CC );
 			efree(converted_utf8);
 			RETURN_FALSE;
 		}
diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c
index 79ae153..9c2e13d 100755
--- a/ext/intl/intl_error.c
+++ b/ext/intl/intl_error.c
@@ -44,10 +44,9 @@ static void intl_free_custom_error_msg( intl_error* err TSRMLS_DC )
 	if( !err && !( err = intl_g_error_get( TSRMLS_C ) ) )
 		return;
 
-	if( !err->free_custom_error_message )
-		return;
-
-	efree( err->custom_error_message );
+	if(err->free_custom_error_message ) {
+		efree( err->custom_error_message );
+	}
 
 	err->custom_error_message      = NULL;
 	err->free_custom_error_message = 0;
@@ -181,6 +180,16 @@ void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg TS
 }
 /* }}} */
 
+/* {{{ void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
+ * Set error code and message.
+ */
+void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg TSRMLS_DC )
+{
+	intl_errors_set_code( err, code TSRMLS_CC );
+	intl_errors_set_custom_msg( err, msg, copyMsg TSRMLS_CC );
+}
+/* }}} */
+
 /* {{{ void intl_errors_reset( intl_error* err )
  */
 void intl_errors_reset( intl_error* err TSRMLS_DC )
diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h
index 5c469e1..3adae85 100755
--- a/ext/intl/intl_error.h
+++ b/ext/intl/intl_error.h
@@ -42,5 +42,6 @@ char*       intl_error_get_message( intl_error* err TSRMLS_DC );
 void        intl_errors_reset( intl_error* err TSRMLS_DC );
 void        intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg TSRMLS_DC );
 void        intl_errors_set_code( intl_error* err, UErrorCode err_code TSRMLS_DC );
+void        intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg TSRMLS_DC );
 
 #endif // INTL_ERROR_H
diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c
index 9abdcdf..438e905 100755
--- a/ext/intl/locale/locale_methods.c
+++ b/ext/intl/locale/locale_methods.c
@@ -14,7 +14,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: locale_methods.c 283367 2009-07-02 22:36:16Z stas $ */
+/* $Id: locale_methods.c 293979 2010-01-25 13:59:35Z johannes $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -389,7 +389,7 @@ static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
 		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,  msg , 1 TSRMLS_CC );
 		efree(msg);
 
-		RETURN_NULL();
+		RETURN_FALSE;
     }
 
 	if(loc_name_len == 0) {
@@ -1129,10 +1129,10 @@ PHP_FUNCTION(locale_get_all_variants)
 	if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
 	&loc_name, &loc_name_len ) == FAILURE)
 	{
-	intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
 	     "locale_parse: unable to parse input params", 0 TSRMLS_CC );
 
-	RETURN_FALSE;
+		RETURN_FALSE;
 	}
 
 	if(loc_name_len == 0) {
@@ -1524,7 +1524,7 @@ PHP_FUNCTION(locale_lookup)
 	if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "as|bs", &arr, &loc_range, &loc_range_len,
 		&boolCanonical,	&fallback_loc, &fallback_loc_len) == FAILURE) {
 		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,	"locale_lookup: unable to parse input params", 0 TSRMLS_CC );
-		RETURN_NULL();
+		RETURN_FALSE;
 	}
 
 	if(loc_range_len == 0) {
@@ -1571,7 +1571,7 @@ PHP_FUNCTION(locale_accept_from_http)
 	{
 		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
 		"locale_accept_from_http: unable to parse input parameters", 0 TSRMLS_CC );
-		RETURN_NULL();
+		RETURN_FALSE;
 	}
 	
 	available = ures_openAvailableLocales(NULL, &status);
diff --git a/ext/intl/normalizer/normalizer_class.h b/ext/intl/normalizer/normalizer_class.h
index 1d21b7a..4d3f7d2 100755
--- a/ext/intl/normalizer/normalizer_class.h
+++ b/ext/intl/normalizer/normalizer_class.h
@@ -39,14 +39,5 @@ typedef struct {
 #define NORMALIZER_ERROR_CODE_P(co) &(INTL_ERROR_CODE(NORMALIZER_ERROR(co)))
 
 void normalizer_register_Normalizer_class( TSRMLS_D );
-void normalizer_object_init( Normalizer_object* co TSRMLS_DC );
-void normalizer_object_destroy( Normalizer_object* co TSRMLS_DC );
-
 extern zend_class_entry *Normalizer_ce_ptr;
-
-/* Auxiliary macros */
-
-#define NORMALIZER_METHOD_INIT_VARS     \
-    intl_error_reset( NULL TSRMLS_CC ); \
-
 #endif // #ifndef NORMALIZER_CLASS_H
diff --git a/ext/intl/normalizer/normalizer_normalize.c b/ext/intl/normalizer/normalizer_normalize.c
index eb14514..482c4a0 100755
--- a/ext/intl/normalizer/normalizer_normalize.c
+++ b/ext/intl/normalizer/normalizer_normalize.c
@@ -50,8 +50,6 @@ PHP_FUNCTION( normalizer_normalize )
 
 	int32_t			size_needed;
 		
-	NORMALIZER_METHOD_INIT_VARS
-
 	intl_error_reset( NULL TSRMLS_CC );
 
 	/* Parse parameters. */
@@ -59,9 +57,9 @@ PHP_FUNCTION( normalizer_normalize )
 				&input, &input_len, &form ) == FAILURE )
 	{
 		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
-						 "normalizer_normalize: unable to parse input params", 1 TSRMLS_CC );
+						 "normalizer_normalize: unable to parse input params", 0 TSRMLS_CC );
 
-		RETURN_NULL();
+		RETURN_FALSE;
 	}
 
 	expansion_factor = 1;
@@ -80,8 +78,8 @@ PHP_FUNCTION( normalizer_normalize )
 			break;
 		default:
 			intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
-						"normalizer_normalize: illegal normalization form", 1 TSRMLS_CC );
-			RETURN_NULL();
+						"normalizer_normalize: illegal normalization form", 0 TSRMLS_CC );
+			RETURN_FALSE;
 	}
 
 	/*
@@ -97,9 +95,9 @@ PHP_FUNCTION( normalizer_normalize )
 		intl_error_set_code( NULL, status TSRMLS_CC );
 
 		/* Set error messages. */
-		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+		intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
 		efree( uinput );
-		RETURN_NULL();
+		RETURN_FALSE;
 	}
 
 
@@ -136,10 +134,10 @@ PHP_FUNCTION( normalizer_normalize )
 		/* Bail out if an unexpected error occured. */
 		if( U_FAILURE(status)  ) {
 			/* Set error messages. */
-			intl_error_set_custom_msg( NULL,"Error normalizing string", 1 TSRMLS_CC );
+			intl_error_set_custom_msg( NULL,"Error normalizing string", 0 TSRMLS_CC );
 			efree( uret_buf );
 			efree( uinput );
-			RETURN_NULL();
+			RETURN_FALSE;
 		}
 	}
 
@@ -154,8 +152,8 @@ PHP_FUNCTION( normalizer_normalize )
 	if( U_FAILURE( status ) )
 	{
 		intl_error_set( NULL, status,
-				"normalizer_normalize: error converting normalized text UTF-8", 1 TSRMLS_CC );
-		RETURN_NULL();
+				"normalizer_normalize: error converting normalized text UTF-8", 0 TSRMLS_CC );
+		RETURN_FALSE;
 	}
 
 	/* Return it. */
@@ -181,8 +179,6 @@ PHP_FUNCTION( normalizer_is_normalized )
 		
 	UBool		uret = FALSE;
 		
-	NORMALIZER_METHOD_INIT_VARS
-
 	intl_error_reset( NULL TSRMLS_CC );
 
 	/* Parse parameters. */
@@ -190,7 +186,7 @@ PHP_FUNCTION( normalizer_is_normalized )
 				&input, &input_len, &form) == FAILURE )
 	{
 		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
-				"normalizer_is_normalized: unable to parse input params", 1 TSRMLS_CC );
+				"normalizer_is_normalized: unable to parse input params", 0 TSRMLS_CC );
 
 		RETURN_FALSE;
 	}
@@ -205,8 +201,8 @@ PHP_FUNCTION( normalizer_is_normalized )
 			break;
 		default:
 			intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
-						"normalizer_normalize: illegal normalization form", 1 TSRMLS_CC );
-			RETURN_NULL();
+						"normalizer_normalize: illegal normalization form", 0 TSRMLS_CC );
+			RETURN_FALSE;
 	}
 
 
@@ -223,7 +219,7 @@ PHP_FUNCTION( normalizer_is_normalized )
 		intl_error_set_code( NULL, status TSRMLS_CC );
 
 		/* Set error messages. */
-		intl_error_set_custom_msg( NULL, "Error converting string to UTF-16.", 1 TSRMLS_CC );
+		intl_error_set_custom_msg( NULL, "Error converting string to UTF-16.", 0 TSRMLS_CC );
 		efree( uinput );
 		RETURN_FALSE;
 	}
@@ -237,7 +233,7 @@ PHP_FUNCTION( normalizer_is_normalized )
 	/* Bail out if an unexpected error occured. */
 	if( U_FAILURE(status)  ) {
 		/* Set error messages. */
-		intl_error_set_custom_msg( NULL,"Error testing if string is the given normalization form.", 1 TSRMLS_CC );
+		intl_error_set_custom_msg( NULL,"Error testing if string is the given normalization form.", 0 TSRMLS_CC );
 		RETURN_FALSE;
 	}
 
diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c
index 831ace4..a9bfefd 100755
--- a/ext/intl/php_intl.c
+++ b/ext/intl/php_intl.c
@@ -62,6 +62,8 @@
 #include "dateformat/dateformat_parse.h"
 #include "dateformat/dateformat_data.h"
 
+#include "resourcebundle/resourcebundle_class.h"
+
 #include "idn/idn.h"
 
 #include "msgformat/msgformat.h"
@@ -74,11 +76,11 @@
 #define INTL_MODULE_VERSION PHP_INTL_VERSION
 
 /*
- * locale_get_default has a conflict since ICU also has 
+ * locale_get_default has a conflict since ICU also has
  * a function with the same  name
  * in fact ICU appends the version no. to it also
  * Hence the following undef for ICU version
- * Same true for the locale_set_default function 
+ * Same true for the locale_set_default function
 */
 #undef locale_get_default
 #undef locale_set_default
@@ -330,6 +332,36 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_idn_to_utf8, 0, 0, 1)
 	ZEND_ARG_INFO(0, option)
 	ZEND_ARG_INFO(0, status)
 ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_create_proc, 0, 0, 2 )
+	ZEND_ARG_INFO( 0, locale )
+	ZEND_ARG_INFO( 0, bundlename )
+	ZEND_ARG_INFO( 0, fallback )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_proc, 0, 0, 2 )
+    ZEND_ARG_INFO( 0, bundle )
+	ZEND_ARG_INFO( 0, index )
+	ZEND_ARG_INFO( 0, fallback )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_count_proc, 0, 0, 1 )
+  ZEND_ARG_INFO( 0, bundle )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_locales_proc, 0, 0, 1 )
+	ZEND_ARG_INFO( 0, bundlename )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_code_proc, 0, 0, 1 )
+  ZEND_ARG_INFO( 0, bundle )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_message_proc, 0, 0, 1 )
+  ZEND_ARG_INFO( 0, bundle )
+ZEND_END_ARG_INFO()
+
+
 /* }}} */
 
 /* {{{ intl_functions
@@ -351,6 +383,7 @@ zend_function_entry intl_functions[] = {
 	PHP_FE( collator_get_locale, collator_1_arg )
 	PHP_FE( collator_get_error_code, collator_0_args )
 	PHP_FE( collator_get_error_message, collator_0_args )
+	PHP_FE( collator_get_sort_key, collator_2_args )
 
 	/* formatter functions */
 	PHP_FE( numfmt_create, arginfo_numfmt_create )
@@ -421,7 +454,7 @@ zend_function_entry intl_functions[] = {
 	PHP_FE( datefmt_set_lenient, arginfo_msgfmt_get_locale )
 	PHP_FE( datefmt_format, arginfo_datefmt_format )
 	PHP_FE( datefmt_parse, datefmt_parse_args )
-    PHP_FE( datefmt_localtime , datefmt_parse_args )
+	PHP_FE( datefmt_localtime , datefmt_parse_args )
 	PHP_FE( datefmt_get_error_code, arginfo_msgfmt_get_error_code )
 	PHP_FE( datefmt_get_error_message, arginfo_msgfmt_get_error_message )
 
@@ -437,8 +470,16 @@ zend_function_entry intl_functions[] = {
 	PHP_FE( grapheme_extract, grapheme_extract_args )
 
 	/* IDN functions */
-	PHP_FE(idn_to_ascii, arginfo_idn_to_ascii)
-	PHP_FE(idn_to_utf8, arginfo_idn_to_ascii)
+	PHP_FE( idn_to_ascii, arginfo_idn_to_ascii)
+	PHP_FE( idn_to_utf8, arginfo_idn_to_ascii)
+
+	/* ResourceBundle functions */
+	PHP_FE( resourcebundle_create, arginfo_resourcebundle_create_proc )
+	PHP_FE( resourcebundle_get, arginfo_resourcebundle_get_proc )
+	PHP_FE( resourcebundle_count, arginfo_resourcebundle_count_proc )
+	PHP_FE( resourcebundle_locales, arginfo_resourcebundle_locales_proc )
+	PHP_FE( resourcebundle_get_error_code, arginfo_resourcebundle_get_error_code_proc )
+	PHP_FE( resourcebundle_get_error_message, arginfo_resourcebundle_get_error_message_proc )
 
 	/* common functions */
 	PHP_FE( intl_get_error_code, intl_0_args )
@@ -520,7 +561,7 @@ PHP_MINIT_FUNCTION( intl )
 
 	/* Expose Normalizer constants to PHP scripts */
 	normalizer_register_constants( INIT_FUNC_ARGS_PASSTHRU );
-	
+
 	/* Register 'Locale' PHP class */
 	locale_register_Locale_class( TSRMLS_C );
 
@@ -537,6 +578,9 @@ PHP_MINIT_FUNCTION( intl )
 	/* Expose DateFormat constants to PHP scripts */
 	dateformat_register_constants( INIT_FUNC_ARGS_PASSTHRU );
 
+	/* Register 'ResourceBundle' PHP class */
+	resourcebundle_register_class( TSRMLS_C);
+
 	/* Expose ICU error codes to PHP scripts. */
 	intl_expose_icu_error_codes( INIT_FUNC_ARGS_PASSTHRU );
 
diff --git a/ext/intl/php_intl.h b/ext/intl/php_intl.h
index 61455b6..3ae530a 100755
--- a/ext/intl/php_intl.h
+++ b/ext/intl/php_intl.h
@@ -63,7 +63,7 @@ PHP_RINIT_FUNCTION(intl);
 PHP_RSHUTDOWN_FUNCTION(intl);
 PHP_MINFO_FUNCTION(intl);
 
-#define PHP_INTL_VERSION "1.0.0"
+#define PHP_INTL_VERSION "1.0.3"
 
 #endif  /* PHP_INTL_H */
 
diff --git a/ext/intl/resourcebundle/TODO b/ext/intl/resourcebundle/TODO
new file mode 100755
index 0000000..ace4ceb
--- /dev/null
+++ b/ext/intl/resourcebundle/TODO
@@ -0,0 +1 @@
+- var_dump support
diff --git a/ext/intl/resourcebundle/resourcebundle.c b/ext/intl/resourcebundle/resourcebundle.c
new file mode 100644
index 0000000..3d881a2
--- /dev/null
+++ b/ext/intl/resourcebundle/resourcebundle.c
@@ -0,0 +1,93 @@
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license at php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Authors: Hans-Peter Oeri (University of St.Gallen) <hp at oeri.ch>      |
+   +----------------------------------------------------------------------+
+ */
+
+#include <unicode/ures.h>
+
+#include <zend.h>
+#include <zend_API.h>
+
+#include "intl_convert.h"
+#include "intl_data.h"
+#include "resourcebundle/resourcebundle_class.h"
+
+/* {{{ ResourceBundle_extract_value */
+void resourcebundle_extract_value( zval *return_value, ResourceBundle_object *source TSRMLS_DC ) 
+{
+	UResType               restype;
+	const UChar*           ufield;
+	const uint8_t*         bfield;
+	char *                 cfield;
+	const int32_t*         vfield;
+	int32_t                ilen;
+	int                    i;
+	long                   lfield;
+	ResourceBundle_object* newrb;
+
+	restype = ures_getType( source->child );
+	switch (restype)
+	{
+		case URES_STRING:
+			ufield = ures_getString( source->child, &ilen, &INTL_DATA_ERROR_CODE(source) );
+			INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve string value");
+			INTL_METHOD_RETVAL_UTF8(source, ufield, ilen, 0);
+			break;
+
+		case URES_BINARY:
+			bfield = ures_getBinary( source->child, &ilen, &INTL_DATA_ERROR_CODE(source) );
+			INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve binary value");
+			ZVAL_STRINGL( return_value, (char *) bfield, ilen, 1 );
+			break;
+
+		case URES_INT:
+			lfield = ures_getInt( source->child, &INTL_DATA_ERROR_CODE(source) );
+			INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve integer value");
+			ZVAL_LONG( return_value, lfield );
+			break;
+
+		case URES_INT_VECTOR:
+			vfield = ures_getIntVector( source->child, &ilen, &INTL_DATA_ERROR_CODE(source) );
+			INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve vector value");
+			array_init( return_value );
+			for (i=0; i<ilen; i++) {
+				add_next_index_long( return_value, vfield[i] );
+			}
+			break;
+
+		case URES_ARRAY:
+		case URES_TABLE:
+			object_init_ex( return_value, ResourceBundle_ce_ptr );
+			newrb = (ResourceBundle_object *) zend_object_store_get_object( return_value TSRMLS_CC );
+			newrb->me = source->child;
+			source->child = NULL;
+			intl_errors_reset(INTL_DATA_ERROR_P(source) TSRMLS_CC);
+			break;
+
+		default:
+			intl_errors_set(INTL_DATA_ERROR_P(source), U_ILLEGAL_ARGUMENT_ERROR, "Unknown resource type", 0 TSRMLS_CC);
+			RETURN_FALSE;
+			break;
+	}
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/intl/resourcebundle/resourcebundle.h b/ext/intl/resourcebundle/resourcebundle.h
new file mode 100644
index 0000000..607ece9
--- /dev/null
+++ b/ext/intl/resourcebundle/resourcebundle.h
@@ -0,0 +1,28 @@
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license at php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Authors: Hans-Peter Oeri (University of St.Gallen) <hp at oeri.ch>      |
+   +----------------------------------------------------------------------+
+ */
+
+#ifndef RESOURCEBUNDLE_H
+#define RESOURCEBUNDLE_H
+
+#include <unicode/ures.h>
+
+#include <zend.h>
+
+#include "resourcebundle/resourcebundle_class.h"
+
+void resourcebundle_extract_value( zval *target, ResourceBundle_object *source TSRMLS_DC);
+
+#endif // #ifndef RESOURCEBUNDLE_CLASS_H
diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c
new file mode 100644
index 0000000..1c9a689
--- /dev/null
+++ b/ext/intl/resourcebundle/resourcebundle_class.c
@@ -0,0 +1,434 @@
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license at php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Authors: Hans-Peter Oeri (University of St.Gallen) <hp at oeri.ch>      |
+   +----------------------------------------------------------------------+
+ */
+
+#include <stdlib.h>
+#include <unicode/ures.h>
+#include <unicode/uenum.h>
+
+#include <zend.h>
+#include <Zend/zend_exceptions.h>
+#include <Zend/zend_interfaces.h>
+#include <php.h>
+
+#include "php_intl.h"
+#include "intl_data.h"
+
+#include "resourcebundle/resourcebundle.h"
+#include "resourcebundle/resourcebundle_iterator.h"
+#include "resourcebundle/resourcebundle_class.h"
+
+zend_class_entry *ResourceBundle_ce_ptr = NULL;
+
+static zend_object_handlers ResourceBundle_object_handlers;
+
+/* {{{ ResourceBundle_object_dtor */
+static void ResourceBundle_object_destroy( void *object, zend_object_handle handle TSRMLS_DC )
+{
+	ResourceBundle_object *rb = (ResourceBundle_object *) object;
+
+	// only free local errors
+	intl_error_reset( INTL_DATA_ERROR_P(rb) TSRMLS_CC );
+
+	if (rb->me) {
+		ures_close( rb->me );
+	}
+	if (rb->child) {
+		ures_close( rb->child );
+	}
+
+	zend_object_std_dtor( object TSRMLS_CC );
+	efree(object);
+}
+/* }}} */
+
+/* {{{ ResourceBundle_object_create */
+static zend_object_value ResourceBundle_object_create( zend_class_entry *ce TSRMLS_DC )
+{
+	zend_object_value     retval;
+	ResourceBundle_object *rb;
+
+	rb = ecalloc( 1, sizeof(ResourceBundle_object) );
+
+	zend_object_std_init( (zend_object *) rb, ce TSRMLS_CC );
+
+	intl_error_init( INTL_DATA_ERROR_P(rb) TSRMLS_CC );
+	rb->me = NULL;
+	rb->child = NULL;
+
+	retval.handlers = &ResourceBundle_object_handlers;
+	retval.handle = zend_objects_store_put(	rb, ResourceBundle_object_destroy, NULL, NULL TSRMLS_CC );
+
+	return retval;
+}
+/* }}} */
+
+/* {{{ ResourceBundle_ctor */
+static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) 
+{
+	char *    bundlename;
+	int       bundlename_len = 0;
+	char *    locale;
+	int       locale_len = 0;
+	zend_bool fallback = 1;
+
+	char *    pbuf;
+
+	zval                  *object = return_value;
+	ResourceBundle_object *rb = (ResourceBundle_object *) zend_object_store_get_object( object TSRMLS_CC);
+
+	intl_error_reset( NULL TSRMLS_CC );
+
+	if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", 
+		&locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )
+	{
+		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+			"resourcebundle_ctor: unable to parse input parameters", 0 TSRMLS_CC );
+		zval_dtor( return_value );
+		RETURN_NULL();
+	}
+
+	INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
+
+	rb->me = ures_open(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));
+
+	INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle");
+
+	if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
+		intl_errors_set_code( NULL, INTL_DATA_ERROR_CODE(rb) TSRMLS_CC );
+		spprintf( &pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource '%s' without fallback from %s to %s",
+				bundlename, locale, ures_getLocale( rb->me, &INTL_DATA_ERROR_CODE(rb)) );
+		intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 TSRMLS_CC );
+		efree(pbuf);
+		zval_dtor( return_value );
+		RETURN_NULL();
+	}
+}
+/* }}} */
+
+/* {{{ arginfo_resourcebundle__construct */
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle___construct, 0, 0, 2 )
+	ZEND_ARG_INFO( 0, locale )
+	ZEND_ARG_INFO( 0, bundlename )
+	ZEND_ARG_INFO( 0, fallback )
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/* {{{ proto void ResourceBundle::__construct( string $bundlename [, string $locale [, bool $fallback = true ]] )
+ * ResourceBundle object constructor
+ */
+PHP_METHOD( ResourceBundle, __construct )
+{
+	return_value = getThis();
+	resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
+/* {{{ proto ResourceBundle ResourceBundle::create( string $bundlename [, string $locale [, bool $fallback = true ]] )
+proto ResourceBundle resourcebundle_create( string $bundlename [, string $locale [, bool $fallback = true ]] ) */
+PHP_FUNCTION( resourcebundle_create ) 
+{
+	object_init_ex( return_value, ResourceBundle_ce_ptr );
+	resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
+/* {{{ resourcebundle_array_fetch */
+static void resourcebundle_array_fetch(zval *object, zval *offset, zval *return_value, int fallback TSRMLS_DC) 
+{
+	int32_t     meindex;
+	char *      mekey;
+	long        mekeylen;
+    zend_bool    is_numeric = 0;
+	char         *pbuf;
+	ResourceBundle_object *rb;
+
+	intl_error_reset( NULL TSRMLS_CC );	
+	RESOURCEBUNDLE_METHOD_FETCH_OBJECT;
+
+	if(Z_TYPE_P(offset) == IS_LONG) {
+		is_numeric = 1;
+		meindex = Z_LVAL_P(offset);
+		rb->child = ures_getByIndex( rb->me, meindex, rb->child, &INTL_DATA_ERROR_CODE(rb) );
+	} else if(Z_TYPE_P(offset) == IS_STRING) {
+		mekey = Z_STRVAL_P(offset);
+		mekeylen = Z_STRLEN_P(offset);
+		rb->child = ures_getByKey(rb->me, mekey, rb->child, &INTL_DATA_ERROR_CODE(rb) );
+	} else {
+		intl_errors_set(INTL_DATA_ERROR_P(rb), U_ILLEGAL_ARGUMENT_ERROR,	
+			"resourcebundle_get: index should be integer or string", 0 TSRMLS_CC);
+		RETURN_NULL();
+	}
+
+	intl_error_set_code( NULL, INTL_DATA_ERROR_CODE(rb) TSRMLS_CC );	
+	if (U_FAILURE(INTL_DATA_ERROR_CODE(rb))) {
+		if (is_numeric) {
+			spprintf( &pbuf, 0, "Cannot load resource element %d", meindex );
+		} else {
+			spprintf( &pbuf, 0, "Cannot load resource element '%s'", mekey );
+		}
+		intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 TSRMLS_CC );
+		efree(pbuf);
+		RETURN_NULL();
+	}
+
+	if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
+		UErrorCode icuerror;
+		const char * locale = ures_getLocale( rb->me, &icuerror );
+		if (is_numeric) {
+			spprintf( &pbuf, 0, "Cannot load element %d without fallback from to %s", meindex, locale );
+		} else {
+			spprintf( &pbuf, 0, "Cannot load element '%s' without fallback from to %s", mekey, locale );
+		}
+		intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 TSRMLS_CC );
+		efree(pbuf);
+		RETURN_NULL();
+	}
+
+	resourcebundle_extract_value( return_value, rb TSRMLS_CC );
+}
+/* }}} */
+
+/* {{{ resourcebundle_array_get */
+zval *resourcebundle_array_get(zval *object, zval *offset, int type TSRMLS_DC) 
+{
+	zval *retval;
+
+	if(offset == NULL) {
+		php_error( E_ERROR, "Cannot apply [] to ResourceBundle object" );
+	}
+	MAKE_STD_ZVAL(retval);
+
+	resourcebundle_array_fetch(object, offset, retval, 1 TSRMLS_CC);
+	Z_DELREF_P(retval);
+	return retval;
+}
+/* }}} */
+
+/* {{{ arginfo_resourcebundle_get */
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get, 0, 0, 1 )
+	ZEND_ARG_INFO( 0, index )
+	ZEND_ARG_INFO( 0, fallback )
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/* {{{ proto mixed ResourceBundle::get( integer|string $resindex [, bool $fallback = true ] )
+ * proto mixed resourcebundle_get( ResourceBundle $rb, integer|string $resindex [, bool $fallback = true ] )
+ * Get resource identified by numerical index or key name.
+ */
+PHP_FUNCTION( resourcebundle_get )
+{
+	zend_bool   fallback = 1;
+	zval *		offset;
+	zval *      object;
+
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz|b",	&object, ResourceBundle_ce_ptr, &offset, &fallback ) == FAILURE) {
+		intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,	
+			"resourcebundle_get: unable to parse input params", 0 TSRMLS_CC);
+		RETURN_FALSE;
+	}
+
+	resourcebundle_array_fetch(object, offset, return_value, fallback TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ resourcebundle_array_count */
+int resourcebundle_array_count(zval *object, long *count TSRMLS_DC) 
+{
+	ResourceBundle_object *rb = (ResourceBundle_object *) zend_object_store_get_object( object TSRMLS_CC);
+
+	*count = ures_getSize( rb->me );
+
+	return SUCCESS;
+}
+/* }}} */
+
+/* {{{ arginfo_resourcebundle_count */
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_count, 0, 0, 0 )
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/* {{{ proto int ResourceBundle::count()
+ * proto int resourcebundle_count( ResourceBundle $bundle )
+ * Get resources count
+ */
+PHP_FUNCTION( resourcebundle_count )
+{
+	int32_t                len;
+	RESOURCEBUNDLE_METHOD_INIT_VARS;
+
+	if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, ResourceBundle_ce_ptr ) == FAILURE ) {
+		intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,	
+			"resourcebundle_count: unable to parse input params", 0 TSRMLS_CC);
+		RETURN_FALSE;
+	}
+
+	RESOURCEBUNDLE_METHOD_FETCH_OBJECT;
+
+	len = ures_getSize( rb->me );
+	RETURN_LONG( len );
+}
+
+/* {{{ arginfo_resourcebundle_getlocales */
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_getlocales, 0, 0, 1 )
+	ZEND_ARG_INFO( 0, bundlename )
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/* {{{ proto array ResourceBundle::getLocales( string $bundlename )
+ * proto array resourcebundle_locales( string $bundlename )
+ * Get available locales from ResourceBundle name
+ */
+PHP_FUNCTION( resourcebundle_locales )
+{
+	char * bundlename;
+	int    bundlename_len = 0;
+	const char * entry;
+	int entry_len;
+	UEnumeration *icuenum;
+	UErrorCode   icuerror = U_ZERO_ERROR;
+
+	intl_errors_reset( NULL TSRMLS_CC );
+
+	if( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &bundlename, &bundlename_len ) == FAILURE )
+	{
+		intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,	
+			"resourcebundle_locales: unable to parse input params", 0 TSRMLS_CC);
+		RETURN_FALSE;
+	}
+
+	if(bundlename_len == 0) {
+		// fetch default locales list
+		bundlename = NULL;
+	}
+
+	icuenum = ures_openAvailableLocales( bundlename, &icuerror );
+	INTL_CHECK_STATUS(icuerror, "Cannot fetch locales list");		
+
+	uenum_reset( icuenum, &icuerror );
+	INTL_CHECK_STATUS(icuerror, "Cannot iterate locales list");		
+
+	array_init( return_value );
+	while ((entry = uenum_next( icuenum, &entry_len, &icuerror ))) {
+		add_next_index_stringl( return_value, (char *) entry, entry_len, 1 );
+	}
+	uenum_close( icuenum );
+}
+/* }}} */
+
+/* {{{ arginfo_resourcebundle_get_error_code */
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_code, 0, 0, 0 )
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/* {{{ proto string ResourceBundle::getErrorCode( )
+ * proto string resourcebundle_get_error_code( ResourceBundle $bundle )
+ * Get text description for ResourceBundle's last error code.
+ */
+PHP_FUNCTION( resourcebundle_get_error_code )
+{
+	RESOURCEBUNDLE_METHOD_INIT_VARS;
+
+	if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
+		&object, ResourceBundle_ce_ptr ) == FAILURE )
+	{
+		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+			"resourcebundle_get_error_code: unable to parse input params", 0 TSRMLS_CC );
+		RETURN_FALSE;
+	}
+
+	rb = (ResourceBundle_object *) zend_object_store_get_object( object TSRMLS_CC );
+
+	RETURN_LONG(INTL_DATA_ERROR_CODE(rb));
+}
+/* }}} */
+
+/* {{{ arginfo_resourcebundle_get_error_message */
+ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_message, 0, 0, 0 )
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/* {{{ proto string ResourceBundle::getErrorMessage( )
+ * proto string resourcebundle_get_error_message( ResourceBundle $bundle )
+ * Get text description for ResourceBundle's last error.
+ */
+PHP_FUNCTION( resourcebundle_get_error_message )
+{
+	char* message = NULL;
+	RESOURCEBUNDLE_METHOD_INIT_VARS;
+
+	if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
+		&object, ResourceBundle_ce_ptr ) == FAILURE )
+	{
+		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+			"resourcebundle_get_error_message: unable to parse input params", 0 TSRMLS_CC );
+		RETURN_FALSE;
+	}
+
+	rb = (ResourceBundle_object *) zend_object_store_get_object( object TSRMLS_CC );
+	message = (char *)intl_error_get_message(INTL_DATA_ERROR_P(rb) TSRMLS_CC);
+	RETURN_STRING(message, 0);
+}
+/* }}} */
+
+/* {{{ ResourceBundle_class_functions
+ * Every 'ResourceBundle' class method has an entry in this table
+ */
+static function_entry ResourceBundle_class_functions[] = {
+	PHP_ME( ResourceBundle, __construct, arginfo_resourcebundle___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR )
+	ZEND_NAMED_ME( create, ZEND_FN( resourcebundle_create ), arginfo_resourcebundle___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
+	ZEND_NAMED_ME( get, ZEND_FN(resourcebundle_get), arginfo_resourcebundle_get, ZEND_ACC_PUBLIC )
+	ZEND_NAMED_ME( count, ZEND_FN(resourcebundle_count), arginfo_resourcebundle_count, ZEND_ACC_PUBLIC )
+	ZEND_NAMED_ME( getLocales, ZEND_FN(resourcebundle_locales), arginfo_resourcebundle_getlocales, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC )
+	ZEND_NAMED_ME( getErrorCode, ZEND_FN(resourcebundle_get_error_code), arginfo_resourcebundle_get_error_code, ZEND_ACC_PUBLIC )
+	ZEND_NAMED_ME( getErrorMessage, ZEND_FN(resourcebundle_get_error_message), arginfo_resourcebundle_get_error_message, ZEND_ACC_PUBLIC )
+	{ NULL, NULL, NULL }
+};
+/* }}} */
+
+/* {{{ resourcebundle_register_class
+ * Initialize 'ResourceBundle' class
+ */
+void resourcebundle_register_class( TSRMLS_D )
+{
+	zend_class_entry ce;
+
+	INIT_CLASS_ENTRY( ce, "ResourceBundle", ResourceBundle_class_functions );
+
+	ce.create_object = ResourceBundle_object_create;
+	ce.get_iterator = resourcebundle_get_iterator;
+
+	ResourceBundle_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC );
+
+	if( !ResourceBundle_ce_ptr )
+	{
+		zend_error(E_ERROR, "Failed to register ResourceBundle class");
+		return;
+	}
+
+	ResourceBundle_object_handlers = std_object_handlers;
+	ResourceBundle_object_handlers.read_dimension = resourcebundle_array_get;
+	ResourceBundle_object_handlers.count_elements = resourcebundle_array_count;
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/intl/resourcebundle/resourcebundle_class.h b/ext/intl/resourcebundle/resourcebundle_class.h
new file mode 100644
index 0000000..65330dd
--- /dev/null
+++ b/ext/intl/resourcebundle/resourcebundle_class.h
@@ -0,0 +1,48 @@
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license at php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Authors: Hans-Peter Oeri (University of St.Gallen) <hp at oeri.ch>      |
+   +----------------------------------------------------------------------+
+ */
+
+#ifndef RESOURCEBUNDLE_CLASS_H
+#define RESOURCEBUNDLE_CLASS_H
+
+#include <unicode/ures.h>
+
+#include <zend.h>
+
+#include "intl_error.h"
+
+typedef struct {
+	zend_object     zend;
+	intl_error      error;
+
+	UResourceBundle *me;
+	UResourceBundle *child;
+} ResourceBundle_object;
+
+#define RESOURCEBUNDLE_METHOD_INIT_VARS		INTL_METHOD_INIT_VARS(ResourceBundle, rb)
+#define RESOURCEBUNDLE_METHOD_FETCH_OBJECT	INTL_METHOD_FETCH_OBJECT(ResourceBundle, rb)
+#define RESOURCEBUNDLE_OBJECT(rb)			(rb)->me
+
+void resourcebundle_register_class( TSRMLS_D );
+extern zend_class_entry *ResourceBundle_ce_ptr;
+
+PHP_FUNCTION( resourcebundle_create );
+PHP_FUNCTION( resourcebundle_get );
+PHP_FUNCTION( resourcebundle_count );
+PHP_FUNCTION( resourcebundle_locales );
+PHP_FUNCTION( resourcebundle_get_error_code );
+PHP_FUNCTION( resourcebundle_get_error_message );
+
+#endif // #ifndef RESOURCEBUNDLE_CLASS_H
diff --git a/ext/intl/resourcebundle/resourcebundle_iterator.c b/ext/intl/resourcebundle/resourcebundle_iterator.c
new file mode 100644
index 0000000..16e1b92
--- /dev/null
+++ b/ext/intl/resourcebundle/resourcebundle_iterator.c
@@ -0,0 +1,192 @@
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license at php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Authors: Hans-Peter Oeri (University of St.Gallen) <hp at oeri.ch>      |
+   +----------------------------------------------------------------------+
+ */
+
+#include <php.h>
+#include <zend.h>
+#include <zend_API.h>
+
+#include "resourcebundle/resourcebundle.h"
+#include "resourcebundle/resourcebundle_class.h"
+#include "resourcebundle/resourcebundle_iterator.h"
+
+/*
+ * Although libicu offers iterator functions, they are not used here: libicu does iterate
+ * irrespective of array indices. Those cannot be recreated afterwards. Arrays as well as tables
+ * can however be accessed by numerical index, with table keys readable ex post.
+ */
+
+/* {{{ resourcebundle_iterator_read */
+static void resourcebundle_iterator_read( ResourceBundle_iterator *iterator TSRMLS_DC ) 
+{
+	UErrorCode icuerror = U_ZERO_ERROR;
+	ResourceBundle_object *rb = iterator->subject;
+
+	rb->child = ures_getByIndex( rb->me, iterator->i, rb->child, &icuerror );
+
+	if (U_SUCCESS(icuerror)) {
+		/* ATTN: key extraction must be the first thing to do... rb->child might be reset in read! */
+		if (iterator->is_table) {
+			iterator->currentkey = estrdup( ures_getKey( rb->child ) );
+		}
+		MAKE_STD_ZVAL( iterator->current );
+		resourcebundle_extract_value( iterator->current, rb TSRMLS_CC );
+	}
+	else {
+		// zend_throw_exception( spl_ce_OutOfRangeException, "Running past end of ResourceBundle", 0 TSRMLS_CC);
+		iterator->current = NULL;
+	}
+}
+/* }}} */
+
+/* {{{ resourcebundle_iterator_invalidate */
+static void resourcebundle_iterator_invalidate( zend_object_iterator *iter TSRMLS_DC ) 
+{
+	ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;
+
+	if (iterator->current) {
+		zval_ptr_dtor( &iterator->current );
+		iterator->current = NULL;
+	}
+	if (iterator->currentkey) {
+		efree( iterator->currentkey );
+		iterator->currentkey = NULL;
+	}
+}
+/* }}} */
+
+/* {{{ resourcebundle_iterator_dtor */
+static void resourcebundle_iterator_dtor( zend_object_iterator *iter TSRMLS_DC )
+{
+	ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;
+	zval                    *object = (zval *)iterator->intern.data;
+
+	resourcebundle_iterator_invalidate( iter TSRMLS_CC );
+
+	Z_DELREF_P(object);
+
+	efree(iterator);
+}
+/* }}} */
+
+/* {{{ resourcebundle_iterator_has_more */
+static int resourcebundle_iterator_has_more( zend_object_iterator *iter TSRMLS_DC )
+{
+	ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;
+	return (iterator->i < iterator->length) ? SUCCESS : FAILURE;
+}
+/* }}} */
+
+/* {{{ resourcebundle_iterator_current */
+static void resourcebundle_iterator_current( zend_object_iterator *iter, zval ***data TSRMLS_DC )
+{
+	ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;
+	if (!iterator->current) {
+		resourcebundle_iterator_read( iterator TSRMLS_CC);
+	}
+	*data = &iterator->current;
+}
+/* }}} */
+
+/* {{{ resourcebundle_iterator_key */
+static int resourcebundle_iterator_key( zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC )
+{
+	ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;
+
+	if (!iterator->current) {
+		resourcebundle_iterator_read( iterator TSRMLS_CC);
+	}
+	if (iterator->is_table) {
+		*str_key = estrdup( iterator->currentkey );
+		*str_key_len = strlen( iterator->currentkey ) + 1;
+		return HASH_KEY_IS_STRING;
+	}
+	else {
+		*int_key = iterator->i;
+		return HASH_KEY_IS_LONG;
+	}
+}
+/* }}} */
+
+/* {{{ resourcebundle_iterator_has_more */
+static void resourcebundle_iterator_step( zend_object_iterator *iter TSRMLS_DC )
+{
+	ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;
+
+	iterator->i++;
+	resourcebundle_iterator_invalidate( iter TSRMLS_CC );
+}
+/* }}} */
+
+/* {{{ resourcebundle_iterator_has_reset */
+static void resourcebundle_iterator_reset( zend_object_iterator *iter TSRMLS_DC )
+{
+	ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;
+
+	iterator->i = 0;
+	resourcebundle_iterator_invalidate( iter TSRMLS_CC );
+}
+/* }}} */
+
+/* {{{ resourcebundle_iterator_funcs */
+static zend_object_iterator_funcs resourcebundle_iterator_funcs = {
+	resourcebundle_iterator_dtor,
+	resourcebundle_iterator_has_more,
+	resourcebundle_iterator_current,
+	resourcebundle_iterator_key,
+	resourcebundle_iterator_step,
+	resourcebundle_iterator_reset,
+	resourcebundle_iterator_invalidate
+};
+/* }}} */
+
+/* {{{ resourcebundle_get_iterator */
+zend_object_iterator *resourcebundle_get_iterator( zend_class_entry *ce, zval *object, int byref TSRMLS_DC )
+{
+	ResourceBundle_object   *rb = (ResourceBundle_object *) zend_object_store_get_object( object TSRMLS_CC );
+	ResourceBundle_iterator *iterator = emalloc( sizeof( ResourceBundle_iterator ) );
+
+	if (byref) {
+	     php_error( E_ERROR, "ResourceBundle does not support writable iterators" );
+	}
+
+	Z_ADDREF_P(object);
+	iterator->intern.data = (void *) object;
+	iterator->intern.funcs = &resourcebundle_iterator_funcs;
+
+	iterator->subject = rb;
+
+	/* The iterated rb can only be either URES_TABLE or URES_ARRAY
+	 * All other types are returned as php primitives!
+	 */
+	iterator->is_table = (ures_getType( rb->me ) == URES_TABLE);
+	iterator->length = ures_getSize( rb->me );
+
+	iterator->current = NULL;
+	iterator->currentkey = NULL;
+	iterator->i = 0;
+
+	return (zend_object_iterator *) iterator;
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/intl/resourcebundle/resourcebundle_iterator.h b/ext/intl/resourcebundle/resourcebundle_iterator.h
new file mode 100644
index 0000000..90dba86
--- /dev/null
+++ b/ext/intl/resourcebundle/resourcebundle_iterator.h
@@ -0,0 +1,36 @@
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license at php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Authors: Hans-Peter Oeri (University of St.Gallen) <hp at oeri.ch>      |
+   +----------------------------------------------------------------------+
+ */
+
+#ifndef RESOURCEBUNDLE_ITERATOR_H
+#define RESOURCEBUNDLE_ITERATOR_H
+
+#include <zend.h>
+
+#include "resourcebundle/resourcebundle_class.h"
+
+typedef struct {
+	zend_object_iterator  intern;
+	ResourceBundle_object *subject;
+	zend_bool             is_table;
+	long                  length;
+	zval                  *current;
+	char                  *currentkey;
+	long                  i;
+} ResourceBundle_iterator;
+
+zend_object_iterator *resourcebundle_get_iterator( zend_class_entry *ce, zval *object, int byref TSRMLS_DC );
+
+#endif // #ifndef RESOURCEBUNDLE_ITERATOR_H
diff --git a/ext/intl/tests/_files/es-bundle.txt b/ext/intl/tests/_files/es-bundle.txt
new file mode 100755
index 0000000..46399a7
--- /dev/null
+++ b/ext/intl/tests/_files/es-bundle.txt
@@ -0,0 +1,21 @@
+es {
+    teststring:string { "Hola Mundo!" }
+
+    testint:int { 2 }
+
+    testvector:intvector { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }
+
+    testbin:bin { a1b2c3d4e5f67890 }
+
+    testtable:table {
+        major:int { 3 }
+        minor:int { 4 }
+        patch:int { 7 }
+    }
+
+    testarray:array {
+        "cadena 1",
+        "cadena 2",
+        "cadena 3"
+    }
+}
diff --git a/ext/intl/tests/_files/res_index.txt b/ext/intl/tests/_files/res_index.txt
new file mode 100755
index 0000000..a39bea5
--- /dev/null
+++ b/ext/intl/tests/_files/res_index.txt
@@ -0,0 +1,6 @@
+res_index:table(nofallback) {
+    InstalledLocales {
+es {""}
+root {""}
+    }
+}
\ No newline at end of file
diff --git a/ext/intl/tests/_files/resourcebundle.txt b/ext/intl/tests/_files/resourcebundle.txt
new file mode 100755
index 0000000..5b081da
--- /dev/null
+++ b/ext/intl/tests/_files/resourcebundle.txt
@@ -0,0 +1,21 @@
+root {
+    teststring:string { "Hello World!" }
+
+    testint:int { 2 }
+
+    testvector:intvector { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }
+
+    testbin:bin { a1b2c3d4e5f67890 }
+
+    testtable:table {
+        major:int { 3 }
+        minor:int { 4 }
+        patch:int { 7 }
+    }
+
+    testarray:array {
+        "string 1",
+        "string 2",
+        "string 3"
+    }
+}
diff --git a/ext/intl/tests/_files/resourcebundle/es.res b/ext/intl/tests/_files/resourcebundle/es.res
new file mode 100755
index 0000000000000000000000000000000000000000..f9d891d6ba81d903fe66abc66550082640eb2051
GIT binary patch
literal 384
zcmZ{gu}%U(5QhH)0nvuSiddYDG$aHmOe`$0p#Y1ks7RJ$BS&Dl+^qyVAAwh}z0z0k
z6{xIid<AR%nNXM*C;4|~zRAwcPKeLe1;k2-Y~Bw_Kyac!k4GS^GHO!eqa+veHut&D
z68EHG;=KBejr}^)aGE&v-b|MkE3+V9C5~rmd_32h$ujeTQ}&BtFoT7o578wliog8k
zAKp`5<|(s=)HPN7GU at g9{;~i5+3p0NGaq1$rM@@9Ghd!DzalSVh=@OCzm)4pYt$Ke
tKygLFA#18ovJckv4|RI6Dkiu?3zz7l!ztRpD<^F5ZhFi5Jx6>1z7ByxNvQw;

literal 0
HcmV?d00001

diff --git a/ext/intl/tests/_files/resourcebundle/res_index.res b/ext/intl/tests/_files/resourcebundle/res_index.res
new file mode 100755
index 0000000000000000000000000000000000000000..9dd3df2de3c30c005c88b105e2dc518fe741dc47
GIT binary patch
literal 128
zcmY#jxTP+_00K-5L8-+~j7$s+j4WUQFd at dkpuh%X at d2>}6a$qoFaoh>UU5lcPEKly
tPkwS at PHHg&5EbR;moThawF)Q=1PGdmL6^Y*$OoAt0K|+8G7LgMvjHuK67B#1

literal 0
HcmV?d00001

diff --git a/ext/intl/tests/_files/resourcebundle/root.res b/ext/intl/tests/_files/resourcebundle/root.res
new file mode 100755
index 0000000000000000000000000000000000000000..62cb48c45718392516578b864c11a8c34678cf3f
GIT binary patch
literal 388
zcmZ`#yGlbr5Ir~1Jj5b}Rj{~el131<5Yh-CMG8SklcW(gaY<H^&1LT*+W86oLfTvU
z3;u$Ym5sk(oijs<fH=#U$2rU}J1M?8ClD)PX!BlD0+ItI)ZGDTg;|rB>>#yRw0X>9
zaDJ|-^HJlIoyB#~bn3juXr at bxm3bt;a-Kdjakfy+gkWA!<GdUZ0S+E>q_`kc6o2{4
zfA}lq%k;8qO0<b$&t%r-{p0iJ_xVleW7Y#$Ecw>#7|{pj4`^v;8Mhc>49?7WlB`M`
vQAr4%NqESq4hgvlb^S-3QLKV{bkV^ndN}7MXTU4BY_K=GrhdaU`@r`W<Z4VQ

literal 0
HcmV?d00001

diff --git a/ext/intl/tests/badargs.phpt b/ext/intl/tests/badargs.phpt
new file mode 100755
index 0000000..9232bbf
--- /dev/null
+++ b/ext/intl/tests/badargs.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Check that bad argumens return the same
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+$funcs = get_extension_funcs("intl");
+function ignore_err() {}
+set_error_handler("ignore_err");
+$arg = new stdClass();
+foreach($funcs as $func) {
+        $rfunc = new ReflectionFunction($func);
+        if($rfunc->getNumberOfRequiredParameters() == 0) {
+                continue;
+        }
+        $res = $func($arg);
+        if($res != false) {
+                echo "$func: ";
+                var_dump($res);
+        }
+}
+echo "OK!\n";
+?>
+--EXPECT--
+OK!
diff --git a/ext/intl/tests/collator_get_sort_key.phpt b/ext/intl/tests/collator_get_sort_key.phpt
new file mode 100755
index 0000000..0186c26
--- /dev/null
+++ b/ext/intl/tests/collator_get_sort_key.phpt
@@ -0,0 +1,97 @@
+--TEST--
+collator_get_sort_key()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Get sort keys using various locales
+ */
+function sort_arrays( $locale, $data )
+{
+    $res_str = '';
+
+    $coll = ut_coll_create( $locale );
+
+	foreach($data as $value) {
+		$res_val = ut_coll_get_sort_key( $coll, $value );
+		$res_str .= "source: ".urlencode($value)."\n".
+					"key: ".urlencode($res_val)."\n";
+	}
+
+    return $res_str;
+}
+
+
+function ut_main()
+{
+    $res_str = '';
+
+    // Regular strings keys
+    $test_params = array(
+		'abc', 'abd', 'aaa', 
+		'аа', 'а', 'z',
+		'', null , '3',
+        'y'  , 'i'  , 'k'
+    );
+
+    $res_str .= sort_arrays( 'en_US', $test_params );
+
+    // Sort a non-ASCII array using ru_RU locale.
+    $test_params = array(
+		'абг', 'абв', 'жжж', 'эюя' 
+    );
+
+    $res_str .= sort_arrays( 'ru_RU', $test_params );
+
+    // Sort an array using Lithuanian locale.
+    $res_str .= sort_arrays( 'lt_LT', $test_params );
+
+    return $res_str . "\n";
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+source: abc
+key: %29%2B-%01%07%01%07%00
+source: abd
+key: %29%2B%2F%01%07%01%07%00
+source: aaa
+key: %29%29%29%01%07%01%07%00
+source: %D0%B0%D0%B0
+key: _++%01%06%01%06%00
+source: %D0%B0
+key: _+%01%05%01%05%00
+source: z
+key: %5B%01%05%01%05%00
+source: 
+key: %01%01%00
+source: 
+key: %01%01%00
+source: 3
+key: %26%80%01%05%01%05%00
+source: y
+key: Y%01%05%01%05%00
+source: i
+key: 9%01%05%01%05%00
+source: k
+key: %3D%01%05%01%05%00
+source: %D0%B0%D0%B1%D0%B3
+key: _+%2C0%01%07%01%07%00
+source: %D0%B0%D0%B1%D0%B2
+key: _+%2C.%01%07%01%07%00
+source: %D0%B6%D0%B6%D0%B6
+key: _LLL%01%07%01%07%00
+source: %D1%8D%D1%8E%D1%8F
+key: %60%05%09%0B%01%07%01%07%00
+source: %D0%B0%D0%B1%D0%B3
+key: _+%2C0%01%07%01%07%00
+source: %D0%B0%D0%B1%D0%B2
+key: _+%2C.%01%07%01%07%00
+source: %D0%B6%D0%B6%D0%B6
+key: _LLL%01%07%01%07%00
+source: %D1%8D%D1%8E%D1%8F
+key: %60%05%09%0B%01%07%01%07%00
\ No newline at end of file
diff --git a/ext/intl/tests/resourcebundle.build b/ext/intl/tests/resourcebundle.build
new file mode 100755
index 0000000..6a7eeae
--- /dev/null
+++ b/ext/intl/tests/resourcebundle.build
@@ -0,0 +1,33 @@
+<?php
+// THIS SCRIPT WILL REBUILD ResourceBundle bundles from source files
+
+// DEFINE YOUR ICU TOOLS PATH HERE
+define("ICU_DIR", "C:/PROJECTS/ICU40/BIN/");
+
+$here = dirname(__FILE__);
+
+$dir = new GlobIterator("$here/_files/*.txt", FilesystemIterator::KEY_AS_FILENAME);
+
+foreach($dir as $file) {
+  passthru( ICU_DIR."genrb -s $here/_files/ -d $here/_files/resourcebundle ".$file->getFileName());
+}
+
+$dir = new GlobIterator("$here/_files/resourcebundle/*.res", FilesystemIterator::KEY_AS_FILENAME);
+foreach($dir as $file) {
+  if($file->getFileName() == "res_index.res") continue;
+  $list[] = str_replace(".res", "", $file->getFileName());
+}
+
+$filelist = join(" {\"\"}\n", $list);
+$res_index = <<<END
+res_index:table(nofallback) {
+    InstalledLocales {
+$filelist {""}
+    }
+}
+END;
+file_put_contents("$here/_files/res_index.txt", $res_index);
+
+passthru( ICU_DIR."genrb -s $here/_files/ -d $here/_files/resourcebundle res_index.txt");
+
+// passthru(ICU_DIR."icupkg -tl -a $here/rb.txt -s $here/_files -d $here/_files new $here/_files/resourcebundle.dat");
\ No newline at end of file
diff --git a/ext/intl/tests/resourcebundle.inc b/ext/intl/tests/resourcebundle.inc
new file mode 100644
index 0000000..2ec138b
--- /dev/null
+++ b/ext/intl/tests/resourcebundle.inc
@@ -0,0 +1,13 @@
+<?php
+define('BUNDLE', dirname(__FILE__)."/_files/resourcebundle");
+
+function debug( $res ) {
+	if (is_null( $res )) {
+		$ret = "NULL\n";
+	}
+	else {
+		$ret = print_r( $res, true ). "\n";
+	}
+	return $ret . sprintf( "%5d: %s\n", intl_get_error_code(), intl_get_error_message() );
+}
+
diff --git a/ext/intl/tests/resourcebundle_arrayaccess.phpt b/ext/intl/tests/resourcebundle_arrayaccess.phpt
new file mode 100644
index 0000000..ef2c0a8
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_arrayaccess.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test ResourceBundle array access and count - existing/missing keys
+--FILE--
+<?php
+	include "resourcebundle.inc";
+
+	// fall back
+	$r = new ResourceBundle( 'en_US', BUNDLE );
+
+	printf( "length: %d\n", count($r) );
+	printf( "teststring: %s\n", $r['teststring'] );
+	printf( "testint: %d\n", $r['testint'] );
+
+	print_r( $r['testvector'] );
+
+	printf( "testbin: %s\n", bin2hex($r['testbin']) );
+
+	$r2 = $r['testtable'];
+	printf( "testtable: %d\n", $r2['major'] );
+
+	$r2 = $r['testarray'];
+	printf( "testarray: %s\n", $r2[2] );
+
+	$t = $r['nonexisting'];
+	echo debug( $t );
+?>
+--EXPECT--
+length: 6
+teststring: Hello World!
+testint: 2
+Array
+(
+    [0] => 1
+    [1] => 2
+    [2] => 3
+    [3] => 4
+    [4] => 5
+    [5] => 6
+    [6] => 7
+    [7] => 8
+    [8] => 9
+    [9] => 0
+)
+testbin: a1b2c3d4e5f67890
+testtable: 3
+testarray: string 3
+NULL
+    2: Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR
diff --git a/ext/intl/tests/resourcebundle_create.phpt b/ext/intl/tests/resourcebundle_create.phpt
new file mode 100644
index 0000000..4d96d3e
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_create.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test ResourceBundle::__construct() - existing/missing bundles/locales
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+	
+include "resourcebundle.inc";
+
+function ut_main() {
+	$str_res = '';
+	// all fine
+	$r1 = ut_resourcebundle_create( 'root', BUNDLE );
+	$str_res .= debug( $r1 );
+	$str_res .= print_r( $r1['teststring'], true)."\n";
+
+	// non-root one
+	$r1 = ut_resourcebundle_create( 'es', BUNDLE );
+	$str_res .= debug( $r1 );
+	$str_res .= print_r( $r1['teststring'], true)."\n";
+
+	// fall back
+	$r1 = ut_resourcebundle_create( 'en_US', BUNDLE );
+        $str_res .= debug( $r1 );
+	$str_res .= print_r( $r1['testsring'], true);
+
+	// fall out
+	$r2 = ut_resourcebundle_create( 'en_US', BUNDLE, false );
+        $str_res .= debug( $r2 );
+
+	// missing
+	$r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' );
+        $str_res .= debug( $r3 );
+	
+	return $str_res;
+}
+
+	include_once( 'ut_common.inc' );
+	ut_run();
+?>
+--EXPECTF--
+ResourceBundle Object
+(
+)
+
+    0: U_ZERO_ERROR
+Hello World!
+ResourceBundle Object
+(
+)
+
+    0: U_ZERO_ERROR
+Hola Mundo!
+ResourceBundle Object
+(
+)
+
+ -127: U_USING_DEFAULT_WARNING
+NULL
+ -127: resourcebundle_ctor: Cannot load libICU resource '%s/resourcebundle' without fallback from en_US to root: U_USING_DEFAULT_WARNING
+NULL
+    2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR
diff --git a/ext/intl/tests/resourcebundle_individual.phpt b/ext/intl/tests/resourcebundle_individual.phpt
new file mode 100644
index 0000000..182cbf3
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_individual.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Test ResourceBundle::get() and length() - existing/missing keys
+--FILE--
+<?php
+	include "resourcebundle.inc";
+
+function ut_main() {
+	$str_res = '';
+	// fall back
+	$r = ut_resourcebundle_create( 'en_US', BUNDLE );
+
+	$str_res .= sprintf( "length: %d\n", ut_resourcebundle_count($r) );
+	$str_res .= sprintf( "teststring: %s\n", ut_resourcebundle_get($r,  'teststring' ) );
+	$str_res .= sprintf( "testint: %d\n", ut_resourcebundle_get($r, 'testint' ) );
+
+	$str_res .= print_r( ut_resourcebundle_get($r, 'testvector' ), true );
+
+	$str_res .= sprintf( "testbin: %s\n", bin2hex(ut_resourcebundle_get( $r,'testbin' )) );
+
+	$r2 = ut_resourcebundle_get($r, 'testtable' );
+	$str_res .= sprintf( "testtable: %d\n", ut_resourcebundle_get($r2, 'major' ) );
+
+	$r2 = ut_resourcebundle_get($r,'testarray' );
+	$str_res .= sprintf( "testarray: %s\n", ut_resourcebundle_get($r2, 2 ) );
+
+	$t = ut_resourcebundle_get( $r, 'nonexisting' );
+	$str_res .= debug( $t );
+	
+	return $str_res;
+}
+	include_once( 'ut_common.inc' );
+	ut_run();
+?>
+--EXPECT--
+length: 6
+teststring: Hello World!
+testint: 2
+Array
+(
+    [0] => 1
+    [1] => 2
+    [2] => 3
+    [3] => 4
+    [4] => 5
+    [5] => 6
+    [6] => 7
+    [7] => 8
+    [8] => 9
+    [9] => 0
+)
+testbin: a1b2c3d4e5f67890
+testtable: 3
+testarray: string 3
+NULL
+    2: Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR
diff --git a/ext/intl/tests/resourcebundle_iterator.phpt b/ext/intl/tests/resourcebundle_iterator.phpt
new file mode 100644
index 0000000..31b0768
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_iterator.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Test ResourceBundle iterator
+--FILE--
+<?php
+	include "resourcebundle.inc";
+
+	// fall back
+	$r = new ResourceBundle( 'en_US', BUNDLE );
+
+	foreach ($r as $onekey => $oneval) {
+		echo "Here comes $onekey:\n";
+		switch (gettype($oneval)) {
+		  case 'string':
+		    echo bin2hex( $oneval ) . "\n";
+		    break;
+
+		  case 'integer':
+		    echo "$oneval\n";
+		    break;
+
+		  default:
+		    print_r( $oneval );
+		}
+		echo "\n";
+	}
+
+	echo "Testarray Contents:\n";
+	$r = $r->get( 'testarray' );
+	foreach ($r as $onekey => $oneval) {
+	   echo "$onekey => $oneval\n";
+	}
+?>
+--EXPECTF--
+Here comes testarray:
+ResourceBundle Object
+(
+)
+
+Here comes testbin:
+a1b2c3d4e5f67890
+
+Here comes testint:
+2
+
+Here comes teststring:
+48656c6c6f20576f726c6421
+
+Here comes testtable:
+ResourceBundle Object
+(
+)
+
+Here comes testvector:
+Array
+(
+    [0] => 1
+    [1] => 2
+    [2] => 3
+    [3] => 4
+    [4] => 5
+    [5] => 6
+    [6] => 7
+    [7] => 8
+    [8] => 9
+    [9] => 0
+)
+
+Testarray Contents:
+0 => string 1
+1 => string 2
+2 => string 3
diff --git a/ext/intl/tests/resourcebundle_locales.phpt b/ext/intl/tests/resourcebundle_locales.phpt
new file mode 100755
index 0000000..e14a7e5
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_locales.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test ResourceBundle::getLocales
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+	
+include "resourcebundle.inc";
+
+function ut_main() {
+	$str_res = '';
+
+	$str_res .= join("\n", ut_resourcebundle_locales(BUNDLE));
+	
+	return $str_res;
+}
+
+	include_once( 'ut_common.inc' );
+	ut_run();
+?>
+--EXPECT--
+es
+root
diff --git a/ext/intl/tests/ut_common.inc b/ext/intl/tests/ut_common.inc
index 4f20361..09be22b 100755
--- a/ext/intl/tests/ut_common.inc
+++ b/ext/intl/tests/ut_common.inc
@@ -59,6 +59,10 @@ function ut_coll_sort_with_sort_keys( $coll, &$arr )
 {
     return $GLOBALS['oo-mode'] ? $coll->sortWithSortKeys( $arr ) : collator_sort_with_sort_keys( $coll, $arr );
 }
+function ut_coll_get_sort_key( $coll, $str )
+{
+    return $GLOBALS['oo-mode'] ? $coll->getSortKey( $str ) : collator_get_sort_key( $coll, $str );
+}
 function ut_coll_asort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR )
 {
     return $GLOBALS['oo-mode'] ? $coll->asort( $arr, $sort_flag ) : collator_asort( $coll, $arr, $sort_flag );
@@ -385,4 +389,28 @@ function ut_datefmt_localtime( $fmt , $value , &$parse_pos=0 )
 {
     return $GLOBALS['oo-mode'] ? $fmt->localtime(  $value , $parse_pos ) : datefmt_localtime( $fmt ,  $value , $parse_pos );
 }
-?>
+
+function ut_resourcebundle_create( $locale, $bundle, $fallback=true )
+{
+    return $GLOBALS['oo-mode'] ? new ResourceBundle($locale, $bundle, $fallback): resourcebundle_create($locale, $bundle, $fallback);
+}
+function ut_resourcebundle_count($bundle )
+{
+    return $GLOBALS['oo-mode'] ? $bundle->count():resourcebundle_count($bundle);
+}
+function ut_resourcebundle_locales($bundle )
+{
+    return $GLOBALS['oo-mode'] ? ResourceBundle::getLocales($bundle):resourcebundle_locales($bundle);
+}
+function ut_resourcebundle_get($bundle, $idx )
+{
+    return $GLOBALS['oo-mode'] ? $bundle->get($idx):resourcebundle_get($bundle, $idx);
+}
+function ut_resourcebundle_get_error_code($bundle )
+{
+    return $GLOBALS['oo-mode'] ? $bundle->getErrorCode():resourcebundle_get_error_code($bundle);
+}
+function ut_resourcebundle_get_error_message($bundle )
+{
+    return $GLOBALS['oo-mode'] ? $bundle->getErrorMessage():resourcebundle_get_error_message($bundle);
+}
diff --git a/ext/json/json.c b/ext/json/json.c
index 1c2d63e..c434018 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: json.c 286385 2009-07-27 03:43:38Z scottmac $ */
+/* $Id: json.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/json/php_json.h b/ext/json/php_json.h
index dacacc1..44c876f 100644
--- a/ext/json/php_json.h
+++ b/ext/json/php_json.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_json.h 283185 2009-06-30 17:52:21Z stas $ */
+/* $Id: php_json.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_JSON_H
 #define PHP_JSON_H
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 4a8941c..c139124 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -23,7 +23,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: ldap.c 287897 2009-08-30 15:33:59Z iliaa $ */
+/* $Id: ldap.c 293036 2010-01-03 09:23:27Z sebastian $ */
 #define IS_EXT_MODULE
 
 #ifdef HAVE_CONFIG_H
@@ -225,7 +225,7 @@ PHP_MINFO_FUNCTION(ldap)
 
 	php_info_print_table_start();
 	php_info_print_table_row(2, "LDAP Support", "enabled");
-	php_info_print_table_row(2, "RCS Version", "$Id: ldap.c 287897 2009-08-30 15:33:59Z iliaa $");
+	php_info_print_table_row(2, "RCS Version", "$Id: ldap.c 293036 2010-01-03 09:23:27Z sebastian $");
 
 	if (LDAPG(max_links) == -1) {
 		snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links));
@@ -936,21 +936,21 @@ PHP_FUNCTION(ldap_get_entries)
 	ldap = ld->link;
 	num_entries = ldap_count_entries(ldap, ldap_result);
 
+	array_init(return_value);
+	add_assoc_long(return_value, "count", num_entries);
+
 	if (num_entries == 0) {
-		RETURN_NULL();
+		return;
 	}
-	num_entries = 0;
 	
 	ldap_result_entry = ldap_first_entry(ldap, ldap_result);
 	if (ldap_result_entry == NULL) {
+		zval_dtor(return_value);
 		RETURN_FALSE;
 	}
 
-	array_init(return_value);
-	add_assoc_long(return_value, "count", num_entries);
-
+	num_entries = 0;
 	while (ldap_result_entry != NULL) {
-
 		MAKE_STD_ZVAL(tmp1);
 		array_init(tmp1);
 
@@ -1583,14 +1583,17 @@ PHP_FUNCTION(ldap_get_option)
 #ifdef LDAP_OPT_NETWORK_TIMEOUT
 	case LDAP_OPT_NETWORK_TIMEOUT:
 		{
-			struct timeval *timeout;
+			struct timeval *timeout = NULL;
 
 			if (ldap_get_option(ld->link, LDAP_OPT_NETWORK_TIMEOUT, (void *) &timeout)) {
 				if (timeout) {
 					ldap_memfree(timeout);
 				}
 				RETURN_FALSE;
-			}		       
+			}		    
+			if (!timeout) {
+				RETURN_FALSE;
+			}
 			zval_dtor(retval);
 			ZVAL_LONG(retval, timeout->tv_sec);
 			ldap_memfree(timeout);
@@ -1908,6 +1911,7 @@ PHP_FUNCTION(ldap_first_reference)
 		resultentry->id = Z_LVAL_P(result);
 		zend_list_addref(resultentry->id);
 		resultentry->data = entry;
+		resultentry->ber = NULL;
 	}
 }
 /* }}} */
@@ -1936,6 +1940,7 @@ PHP_FUNCTION(ldap_next_reference)
 		resultentry_next->id = resultentry->id;
 		zend_list_addref(resultentry->id);
 		resultentry_next->data = entry_next;
+		resultentry_next->ber = NULL;
 	}
 }
 /* }}} */
diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h
index c30218a..fc4e3e8 100644
--- a/ext/ldap/php_ldap.h
+++ b/ext/ldap/php_ldap.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_ldap.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_ldap.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_LDAP_H
 #define PHP_LDAP_H
diff --git a/ext/ldap/tests/ldap_bind_basic.phpt b/ext/ldap/tests/ldap_bind_basic.phpt
index bac8d0d..b0babae 100644
--- a/ext/ldap/tests/ldap_bind_basic.phpt
+++ b/ext/ldap/tests/ldap_bind_basic.phpt
@@ -4,7 +4,8 @@ ldap_bind() - Basic anonymous binding
 Patrick Allaert <patrickallaert at php.net>
 # Belgian PHP Testfest 2009
 --SKIPIF--
-<?php require_once('skipif.inc'); ?>
+<?php require_once dirname(__FILE__) .'/skipif.inc'; ?>
+<?php require_once dirname(__FILE__) .'/skipifbindfailure.inc'; ?>
 --FILE--
 <?php
 require "connect.inc";
diff --git a/ext/ldap/tests/ldap_bind_variation.phpt b/ext/ldap/tests/ldap_bind_variation.phpt
index 64abf6c..24102f7 100644
--- a/ext/ldap/tests/ldap_bind_variation.phpt
+++ b/ext/ldap/tests/ldap_bind_variation.phpt
@@ -4,7 +4,8 @@ ldap_bind() - Advanced binding
 Patrick Allaert <patrickallaert at php.net>
 # Belgian PHP Testfest 2009
 --SKIPIF--
-<?php require_once('skipif.inc'); ?>
+<?php require_once dirname(__FILE__) .'/skipif.inc'; ?>
+<?php require_once dirname(__FILE__) .'/skipifbindfailure.inc'; ?>
 --FILE--
 <?php
 require "connect.inc";
diff --git a/ext/ldap/tests/ldap_get_entries_variation.phpt b/ext/ldap/tests/ldap_get_entries_variation.phpt
index 92c4974..cb0f306 100644
--- a/ext/ldap/tests/ldap_get_entries_variation.phpt
+++ b/ext/ldap/tests/ldap_get_entries_variation.phpt
@@ -29,5 +29,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
 remove_dummy_data($link);
 ?>
 --EXPECT--
-NULL
+array(1) {
+  ["count"]=>
+  int(0)
+}
 ===DONE===
diff --git a/ext/ldap/tests/ldap_mod_del_basic.phpt b/ext/ldap/tests/ldap_mod_del_basic.phpt
index 0d002bd..c7daba4 100644
--- a/ext/ldap/tests/ldap_mod_del_basic.phpt
+++ b/ext/ldap/tests/ldap_mod_del_basic.phpt
@@ -36,5 +36,8 @@ remove_dummy_data($link);
 ?>
 --EXPECT--
 bool(true)
-NULL
+array(1) {
+  ["count"]=>
+  int(0)
+}
 ===DONE===
diff --git a/ext/ldap/tests/ldap_search_error.phpt b/ext/ldap/tests/ldap_search_error.phpt
index c03bd2c..7e94613 100644
--- a/ext/ldap/tests/ldap_search_error.phpt
+++ b/ext/ldap/tests/ldap_search_error.phpt
@@ -4,9 +4,8 @@ ldap_search() - operation that should fail
 Davide Mendolia <idaf1er at gmail.com>
 Belgian PHP Testfest 2009
 --SKIPIF--
-<?php
-require_once('skipif.inc');
-?>
+<?php require_once dirname(__FILE__) .'/skipif.inc'; ?>
+<?php require_once dirname(__FILE__) .'/skipifbindfailure.inc'; ?>
 --FILE--
 <?php
 include "connect.inc";
diff --git a/ext/ldap/tests/ldap_start_tls_basic.phpt b/ext/ldap/tests/ldap_start_tls_basic.phpt
index 3ae50be..efc4356 100644
--- a/ext/ldap/tests/ldap_start_tls_basic.phpt
+++ b/ext/ldap/tests/ldap_start_tls_basic.phpt
@@ -4,7 +4,8 @@ ldap_start_tls() - Basic ldap_start_tls test
 Patrick Allaert <patrickallaert at php.net>
 # Belgian PHP Testfest 2009
 --SKIPIF--
-<?php require_once('skipif.inc'); ?>
+<?php require_once dirname(__FILE__) .'/skipif.inc'; ?>
+<?php require_once dirname(__FILE__) .'/skipifbindfailure.inc'; ?>
 --FILE--
 <?php
 require "connect.inc";
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index c1c0467..560c466 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: libxml.c 282654 2009-06-23 13:44:24Z bjori $ */
+/* $Id: libxml.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define IS_EXT_MODULE
 
@@ -622,6 +622,9 @@ static PHP_MINIT_FUNCTION(libxml)
 	REGISTER_LONG_CONSTANT("LIBXML_COMPACT",	XML_PARSE_COMPACT,		CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("LIBXML_NOXMLDECL",	XML_SAVE_NO_DECL,		CONST_CS | CONST_PERSISTENT);
 #endif
+#if LIBXML_VERSION >= 20703
+	REGISTER_LONG_CONSTANT("LIBXML_PARSEHUGE",	XML_PARSE_HUGE,			CONST_CS | CONST_PERSISTENT);
+#endif
 	REGISTER_LONG_CONSTANT("LIBXML_NOEMPTYTAG",	LIBXML_SAVE_NOEMPTYTAG,	CONST_CS | CONST_PERSISTENT);
 
 	/* Error levels */
diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h
index 8a10822..246882e 100644
--- a/ext/libxml/php_libxml.h
+++ b/ext/libxml/php_libxml.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_libxml.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_libxml.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
diff --git a/ext/mbstring/config.m4 b/ext/mbstring/config.m4
index ad0c16c..ef76783 100644
--- a/ext/mbstring/config.m4
+++ b/ext/mbstring/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 279059 2009-04-20 15:39:48Z jani $
+dnl $Id: config.m4 291283 2009-11-25 01:30:06Z rasmus $
 dnl
 
 AC_DEFUN([PHP_MBSTRING_ADD_SOURCES], [
@@ -74,7 +74,7 @@ AC_DEFUN([PHP_MBSTRING_SETUP_MBREGEX], [
         AC_DEFINE([USE_COMBINATION_EXPLOSION_CHECK],1,[whether to check multibyte regex backtrack])
       fi
 
-      AC_CACHE_CHECK(for variable length prototypes and stdarg.h, cv_php_mbstring_stdarg, [
+      AC_CACHE_CHECK(for variable length prototypes and stdarg.h, php_cv_mbstring_stdarg, [
         AC_TRY_RUN([
 #include <stdarg.h>
 int foo(int x, ...) {
@@ -86,14 +86,14 @@ int foo(int x, ...) {
 	return 0;
 }
 int main() { return foo(10, "", 3.14); }
-        ], [cv_php_mbstring_stdarg=yes], [cv_php_mbstring_stdarg=no], [
+        ], [php_cv_mbstring_stdarg=yes], [php_cv_mbstring_stdarg=no], [
           dnl cross-compile needs something here
           case $host_alias in
           *netware*)
-          cv_php_mbstring_stdarg=yes
+          php_cv_mbstring_stdarg=yes
           ;;
           *)
-          cv_php_mbstring_stdarg=no
+          php_cv_mbstring_stdarg=no
           ;;
           esac
         ])
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_utf16.c b/ext/mbstring/libmbfl/filters/mbfilter_utf16.c
index b6c2aed..5df6551 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_utf16.c
+++ b/ext/mbstring/libmbfl/filters/mbfilter_utf16.c
@@ -127,7 +127,7 @@ int mbfl_filt_conv_utf16_wchar(int c, mbfl_convert_filter *filter)
 	int n, endian;
 
 	endian = filter->status & 0xff00;
-	switch (filter->status & 0xff) {
+	switch (filter->status & 0x0f) {
 	case 0:
 		if (endian) {
 			n = c & 0xff;
@@ -144,15 +144,8 @@ int mbfl_filt_conv_utf16_wchar(int c, mbfl_convert_filter *filter)
 			n = c & 0xff;
 		}
 		n |= filter->cache & 0xffff;
-		filter->status &= ~0xff;
-		if (n == 0xfffe) {
-			if (endian) {
-				filter->status = 0;		/* big-endian */
-			} else {
-				filter->status = 0x100;		/* little-endian */
-			}
-			CK((*filter->output_function)(0xfeff, filter->data));
-		} else if (n >= 0xd800 && n < 0xdc00) {
+		filter->status &= ~0x0f;
+		if (n >= 0xd800 && n < 0xdc00) {
 			filter->cache = ((n & 0x3ff) << 16) + 0x400000;
 		} else if (n >= 0xdc00 && n < 0xe000) {
 			n &= 0x3ff;
@@ -166,7 +159,21 @@ int mbfl_filt_conv_utf16_wchar(int c, mbfl_convert_filter *filter)
 				CK((*filter->output_function)(n, filter->data));
 			}
 		} else {
+			int is_first = filter->status & 0x10;
 			filter->cache = 0;
+			filter->status |= 0x10;
+			if (!is_first) {
+				if (n == 0xfffe) {
+					if (endian) {
+						filter->status &= ~0x100;		/* big-endian */
+					} else {
+						filter->status |= 0x100;		/* little-endian */
+					}
+					break;
+				} else if (n == 0xfeff) {
+					break;
+				}
+			}
 			CK((*filter->output_function)(n, filter->data));
 		}
 		break;
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_utf8.c b/ext/mbstring/libmbfl/filters/mbfilter_utf8.c
index 20ff983..c6777b2 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_utf8.c
+++ b/ext/mbstring/libmbfl/filters/mbfilter_utf8.c
@@ -220,7 +220,7 @@ static int mbfl_filt_ident_utf8(int c, mbfl_identify_filter *filter)
 	if (c < 0x80) {
 		if (c < 0) { 
 			filter->flag = 1;	/* bad */
-		} else if (c != 0 && filter->status) {
+		} else if (filter->status) {
 			filter->flag = 1;	/* bad */
 		}
 		filter->status = 0;
diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c
index 1aeb38c..4997c5a 100644
--- a/ext/mbstring/libmbfl/mbfl/mbfilter.c
+++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c
@@ -622,7 +622,7 @@ mbfl_identify_encoding(mbfl_string *string, enum mbfl_no_encoding *elist, int el
 	if (!encoding) {
 		for (i = 0; i < num; i++) {
 			filter = &flist[i];
-			if (!filter->flag) {
+			if (!filter->flag && (!strict || !filter->status)) {
 				encoding = filter->encoding;
 				break;
 			}
diff --git a/ext/mbstring/mb_gpc.c b/ext/mbstring/mb_gpc.c
index b7dfd57..688a55d 100644
--- a/ext/mbstring/mb_gpc.c
+++ b/ext/mbstring/mb_gpc.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mb_gpc.c 284727 2009-07-24 23:48:58Z moriyoshi $ */
+/* $Id: mb_gpc.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* {{{ includes */
 #ifdef HAVE_CONFIG_H
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 3e46e82..2d24597 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mbstring.c 281226 2009-05-27 13:42:17Z tony2001 $ */
+/* $Id: mbstring.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
  * PHP 4 Multibyte String module "mbstring"
@@ -2665,10 +2665,6 @@ PHP_FUNCTION(mb_strcut)
 		RETURN_FALSE;
 	}
 
-	if (((unsigned int)from + (unsigned int)len) > string.len) {
-		len = string.len - from;
-	}
-
 	ret = mbfl_strcut(&string, &result, from, len);
 	if (ret == NULL) {
 		RETURN_FALSE;
diff --git a/ext/mbstring/mbstring.h b/ext/mbstring/mbstring.h
index ee0f8b8..52d0b40 100644
--- a/ext/mbstring/mbstring.h
+++ b/ext/mbstring/mbstring.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mbstring.h 277211 2009-03-15 20:42:56Z moriyoshi $ */
+/* $Id: mbstring.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
  * PHP 4 Multibyte String module "mbstring" (currently only for Japanese)
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index a3c5778..d9bac43 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_mbregex.c 281727 2009-06-05 18:50:32Z mattwil $ */
+/* $Id: php_mbregex.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 
 #ifdef HAVE_CONFIG_H
diff --git a/ext/mbstring/php_mbregex.h b/ext/mbstring/php_mbregex.h
index c9201df..dcc840f 100644
--- a/ext/mbstring/php_mbregex.h
+++ b/ext/mbstring/php_mbregex.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_mbregex.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_mbregex.h 293036 2010-01-03 09:23:27Z sebastian $ */
  
 #ifndef _PHP_MBREGEX_H
 #define _PHP_MBREGEX_H
diff --git a/ext/mbstring/php_unicode.c b/ext/mbstring/php_unicode.c
index bb17c16..55d7d51 100644
--- a/ext/mbstring/php_unicode.c
+++ b/ext/mbstring/php_unicode.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/mbstring/php_unicode.h b/ext/mbstring/php_unicode.h
index e35193d..1afd3f9 100644
--- a/ext/mbstring/php_unicode.h
+++ b/ext/mbstring/php_unicode.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/mbstring/tests/bug43994.phpt b/ext/mbstring/tests/bug43994.phpt
index 39a39f6..8fdb904 100644
--- a/ext/mbstring/tests/bug43994.phpt
+++ b/ext/mbstring/tests/bug43994.phpt
@@ -38,7 +38,7 @@ foreach($inputs as $input) {
 };
 ?>
 
---EXPECTF---- 
+--EXPECTF-- 
 
 -- Iteration 1 --
 Without $regs arg:
diff --git a/ext/mbstring/tests/bug45722.phpt b/ext/mbstring/tests/bug45722.phpt
index c05a010..97f6fe5 100644
--- a/ext/mbstring/tests/bug45722.phpt
+++ b/ext/mbstring/tests/bug45722.phpt
@@ -1,5 +1,7 @@
 --TEST--
 Bug #45722 (mb_check_encoding() crashes)
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
 --FILE--
 <?php
 var_dump(mb_check_encoding("&\xc2\xb7 TEST TEST TEST TEST TEST TEST", "HTML-ENTITIES"));
diff --git a/ext/mbstring/tests/bug47399.phpt b/ext/mbstring/tests/bug47399.phpt
index 7961868..3586e5c 100644
--- a/ext/mbstring/tests/bug47399.phpt
+++ b/ext/mbstring/tests/bug47399.phpt
@@ -1,5 +1,7 @@
 --TEST--
 Bug #47399 (mb_check_encoding() returns true for some illegal SJIS characters)
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
 --FILE--
 <?php
 foreach (array("Shift_JIS", "CP932") as $enc) {
diff --git a/ext/mbstring/tests/bug48697.phpt b/ext/mbstring/tests/bug48697.phpt
new file mode 100644
index 0000000..42bbe9f
--- /dev/null
+++ b/ext/mbstring/tests/bug48697.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #48697 (mb_internal_encoding() value gets reset by parse_str() or mb_parse_str()
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--FILE--
+<?php
+ini_set('mbstring.internal_encoding', 'ISO-8859-15');
+ini_set('mbstring.encoding_translation', true);
+var_dump(mb_internal_encoding());
+mb_internal_encoding('UTF-8');
+var_dump(mb_internal_encoding());
+parse_str('a=b');
+var_dump(mb_internal_encoding());
+mb_internal_encoding('UTF-8');
+var_dump(mb_internal_encoding());
+parse_str('a=b');
+var_dump(mb_internal_encoding());
+?>
+--EXPECT--
+string(11) "ISO-8859-15"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
diff --git a/ext/mbstring/tests/bug49354.phpt b/ext/mbstring/tests/bug49354.phpt
new file mode 100644
index 0000000..c25b405
--- /dev/null
+++ b/ext/mbstring/tests/bug49354.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #49354 (mb_strcut() cuts wrong length when offset is in the middle of a multibyte character)
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--FILE--
+<?php
+$crap = 'AåBäCöDü';
+var_dump(mb_strcut($crap, 0, 100, 'UTF-8'));
+var_dump(mb_strcut($crap, 1, 100, 'UTF-8'));
+var_dump(mb_strcut($crap, 2, 100, 'UTF-8'));
+var_dump(mb_strcut($crap, 3, 100, 'UTF-8'));
+var_dump(mb_strcut($crap, 12, 100, 'UTF-8'));
+var_dump(mb_strcut($crap, 13, 100, 'UTF-8'));
+?>
+--EXPECT--
+string(12) "AåBäCöDü"
+string(11) "åBäCöDü"
+string(11) "åBäCöDü"
+string(9) "BäCöDü"
+string(0) ""
+bool(false)
diff --git a/ext/mbstring/tests/bug49528.phpt b/ext/mbstring/tests/bug49528.phpt
new file mode 100644
index 0000000..b06c35f
--- /dev/null
+++ b/ext/mbstring/tests/bug49528.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #49528 (UTF-16 strings prefixed by BOM wrongly converted)
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--FILE--
+<?php
+var_dump(bin2hex(mb_convert_encoding("\xff\xfe\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
+var_dump(bin2hex(mb_convert_encoding("\xfe\xff\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
+var_dump(bin2hex(mb_convert_encoding("\xff\xfe\xff\xfe\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
+var_dump(bin2hex(mb_convert_encoding("\xff\xfe\xfe\xff\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
+var_dump(bin2hex(mb_convert_encoding("\xfe\xff\xff\xfe\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
+var_dump(bin2hex(mb_convert_encoding("\xfe\xff\xfe\xff\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
+?>
+--EXPECT--
+string(8) "02010403"
+string(8) "01020304"
+string(12) "feff02010403"
+string(12) "fffe02010403"
+string(12) "fffe01020304"
+string(12) "feff01020304"
diff --git a/ext/mbstring/tests/bug49536.phpt b/ext/mbstring/tests/bug49536.phpt
new file mode 100644
index 0000000..32685d2
--- /dev/null
+++ b/ext/mbstring/tests/bug49536.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #49536 (mb_detect_encoding() returns incorrect results when strict_mode is turned on)
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--FILE--
+<?php
+// non-strict mode
+var_dump(mb_detect_encoding("A\x81", "SJIS", false));
+// strict mode
+var_dump(mb_detect_encoding("A\x81", "SJIS", true));
+// non-strict mode
+var_dump(mb_detect_encoding("\xc0\x00", "UTF-8", false));
+// strict mode
+var_dump(mb_detect_encoding("\xc0\x00", "UTF-8", true));
+?>
+--EXPECT--
+string(4) "SJIS"
+bool(false)
+string(5) "UTF-8"
+bool(false)
diff --git a/ext/mbstring/tests/mb_encoding_aliases.phpt b/ext/mbstring/tests/mb_encoding_aliases.phpt
index 7b87045..2159481 100644
--- a/ext/mbstring/tests/mb_encoding_aliases.phpt
+++ b/ext/mbstring/tests/mb_encoding_aliases.phpt
@@ -1,5 +1,7 @@
 --TEST--
 mb_encoding_aliases()
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
 --FILE--
 <?php
 mb_encoding_aliases();
diff --git a/ext/mbstring/tests/mb_list_encodings.phpt b/ext/mbstring/tests/mb_list_encodings.phpt
index e155cb8..135a9ef 100644
--- a/ext/mbstring/tests/mb_list_encodings.phpt
+++ b/ext/mbstring/tests/mb_list_encodings.phpt
@@ -1,5 +1,7 @@
 --TEST--
 mb_list_encodings
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
 --FILE--
 <?php
 var_dump(in_array("7bit", mb_list_encodings()));
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
index c06bfb3..898bb3e 100644
--- a/ext/mcrypt/mcrypt.c
+++ b/ext/mcrypt/mcrypt.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    |          Derick Rethans <derick at derickrethans.nl>                    |
    +----------------------------------------------------------------------+
  */
-/* $Id: mcrypt.c 289433 2009-10-09 17:28:52Z pajoye $ */
+/* $Id: mcrypt.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/mcrypt/php_mcrypt.h b/ext/mcrypt/php_mcrypt.h
index 9561056..f90c359 100644
--- a/ext/mcrypt/php_mcrypt.h
+++ b/ext/mcrypt/php_mcrypt.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    |          Derick Rethans <derick at derickrethans.nl>                    |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_mcrypt.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_mcrypt.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_MCRYPT_H
 #define PHP_MCRYPT_H
diff --git a/ext/mcrypt/tests/bug46010.phpt b/ext/mcrypt/tests/bug46010.phpt
index 5aeb311..bacfb59 100644
--- a/ext/mcrypt/tests/bug46010.phpt
+++ b/ext/mcrypt/tests/bug46010.phpt
@@ -1,4 +1,4 @@
---TEST---
+--TEST--
 Bug #46010 (warnings incorrectly generated for iv in ecb mode)
 --FILE--
 <?php
diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c
index 74d89dd..8603add 100644
--- a/ext/mssql/php_mssql.c
+++ b/ext/mssql/php_mssql.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_mssql.c 284145 2009-07-15 19:09:15Z rasmus $ */
+/* $Id: php_mssql.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef COMPILE_DL_MSSQL
 #define HAVE_MSSQL 1
diff --git a/ext/mssql/php_mssql.h b/ext/mssql/php_mssql.h
index 2622d36..a41a5e0 100644
--- a/ext/mssql/php_mssql.h
+++ b/ext/mssql/php_mssql.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
  */
 
 
-/* $Id: php_mssql.h 281162 2009-05-26 12:32:00Z felipe $ */
+/* $Id: php_mssql.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_MSSQL_H
 #define PHP_MSSQL_H
diff --git a/ext/mysql/config.m4 b/ext/mysql/config.m4
index 47e9083..61e2446 100644
--- a/ext/mysql/config.m4
+++ b/ext/mysql/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 263087 2008-07-21 12:58:51Z andrey $
+dnl $Id: config.m4 291501 2009-11-30 15:11:29Z jani $
 dnl
 
 AC_DEFUN([MYSQL_LIB_CHK], [
@@ -58,18 +58,6 @@ if test "$PHP_MYSQL" = "mysqlnd"; then
   PHP_MYSQLND_ENABLED=yes
 
 elif test "$PHP_MYSQL" != "no"; then
-
-  AC_MSG_CHECKING([for MySQL UNIX socket location])
-  if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then
-    MYSQL_SOCK=$PHP_MYSQL_SOCK
-    AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ])
-    AC_MSG_RESULT([$MYSQL_SOCK])
-  elif test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL_SOCK" = "yes"; then
-    PHP_MYSQL_SOCKET_SEARCH
-  else
-    AC_MSG_RESULT([no])
-  fi
-
   MYSQL_DIR=
   MYSQL_INC_DIR=
 
@@ -152,6 +140,17 @@ fi
 
 dnl Enable extension
 if test "$PHP_MYSQL" != "no"; then
+  AC_MSG_CHECKING([for MySQL UNIX socket location])
+  if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then
+    MYSQL_SOCK=$PHP_MYSQL_SOCK
+    AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ])
+    AC_MSG_RESULT([$MYSQL_SOCK])
+  elif test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL_SOCK" = "yes"; then
+    PHP_MYSQL_SOCKET_SEARCH
+  else
+    AC_MSG_RESULT([no])
+  fi
+
   AC_DEFINE(HAVE_MYSQL, 1, [Whether you have MySQL])
   PHP_NEW_EXTENSION(mysql, php_mysql.c, $ext_shared)
   PHP_SUBST(MYSQL_SHARED_LIBADD)
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 9c10931..28d4d8e 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
  
-/* $Id: php_mysql.c 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: php_mysql.c 294891 2010-02-11 17:14:44Z johannes $ */
 
 /* TODO:
  *
@@ -125,10 +125,6 @@ typedef struct _php_mysql_conn {
 	int multi_query;
 } php_mysql_conn;
 
-#ifdef MYSQL_USE_MYSQLND
-static MYSQLND_ZVAL_PCACHE *mysql_mysqlnd_zval_cache;
-static MYSQLND_QCACHE		*mysql_mysqlnd_qcache;
-#endif
 
 #if MYSQL_VERSION_ID >= 40101
 #define MYSQL_DISABLE_MQ if (mysql->multi_query) { \
@@ -411,9 +407,6 @@ PHP_INI_BEGIN()
 	STD_PHP_INI_ENTRY("mysql.connect_timeout",		"60",	PHP_INI_ALL,		OnUpdateLong,		connect_timeout, 	zend_mysql_globals,		mysql_globals)
 	STD_PHP_INI_BOOLEAN("mysql.trace_mode",			"0",	PHP_INI_ALL,		OnUpdateLong,		trace_mode, 		zend_mysql_globals,		mysql_globals)
 	STD_PHP_INI_BOOLEAN("mysql.allow_local_infile",	"1",	PHP_INI_SYSTEM,		OnUpdateLong,		allow_local_infile, zend_mysql_globals,		mysql_globals)
-#ifdef MYSQL_USE_MYSQLND
-	STD_PHP_INI_ENTRY("mysql.cache_size",			"2000",	PHP_INI_SYSTEM,		OnUpdateLong,		cache_size,			zend_mysql_globals,		mysql_globals)
-#endif
 PHP_INI_END()
 /* }}} */
 
@@ -432,10 +425,6 @@ static PHP_GINIT_FUNCTION(mysql)
 	mysql_globals->trace_mode = 0;
 	mysql_globals->allow_local_infile = 1;
 	mysql_globals->result_allocated = 0;
-#ifdef MYSQL_USE_MYSQLND
-	mysql_globals->cache_size = 0;
-	mysql_globals->mysqlnd_thd_zval_cache = NULL;
-#endif
 }
 /* }}} */
 
@@ -465,9 +454,6 @@ ZEND_MODULE_STARTUP_D(mysql)
 		return FAILURE;
 	}
 #endif
-#else
-	mysql_mysqlnd_zval_cache = mysqlnd_palloc_init_cache(MySG(cache_size));
-	mysql_mysqlnd_qcache = mysqlnd_qcache_init_cache();
 #endif
 
 	return SUCCESS;
@@ -493,9 +479,6 @@ PHP_MSHUTDOWN_FUNCTION(mysql)
 	mysql_server_end();
 #endif
 #endif
-#else
-	mysqlnd_palloc_free_cache(mysql_mysqlnd_zval_cache);
-	mysqlnd_qcache_free_cache_reference(&mysql_mysqlnd_qcache);
 #endif
 
 	UNREGISTER_INI_ENTRIES();
@@ -519,10 +502,6 @@ PHP_RINIT_FUNCTION(mysql)
 	MySG(connect_errno) =0;
 	MySG(result_allocated) = 0;
 
-#ifdef MYSQL_USE_MYSQLND
-	MySG(mysqlnd_thd_zval_cache) = mysqlnd_palloc_rinit(mysql_mysqlnd_zval_cache);
-#endif
-
 	return SUCCESS;
 }
 /* }}} */
@@ -559,7 +538,6 @@ PHP_RSHUTDOWN_FUNCTION(mysql)
 
 #ifdef MYSQL_USE_MYSQLND
 	zend_hash_apply(&EG(persistent_list), (apply_func_t) php_mysql_persistent_helper TSRMLS_CC);
-	mysqlnd_palloc_rshutdown(MySG(mysqlnd_thd_zval_cache));
 #endif
 
 	return SUCCESS;
@@ -585,20 +563,6 @@ PHP_MINFO_FUNCTION(mysql)
 	php_info_print_table_row(2, "MYSQL_INCLUDE", PHP_MYSQL_INCLUDE);
 	php_info_print_table_row(2, "MYSQL_LIBS", PHP_MYSQL_LIBS);
 #endif
-#if defined(MYSQL_USE_MYSQLND)
-	{
-		zval values;
-
-		php_info_print_table_header(2, "Persistent cache", mysql_mysqlnd_zval_cache? "enabled":"disabled");
-		
-		if (mysql_mysqlnd_zval_cache) {
-			/* Now report cache status */
-			mysqlnd_palloc_stats(mysql_mysqlnd_zval_cache, &values);
-			mysqlnd_minfo_print_hash(&values);
-			zval_dtor(&values);
-		}
-	}
-#endif
 
 	php_info_print_table_end();
 
@@ -704,6 +668,9 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 			client_flags ^= CLIENT_LOCAL_FILES;
 		}
 
+#ifdef CLIENT_MULTI_RESULTS
+		client_flags |= CLIENT_MULTI_RESULTS; /* compatibility with 5.2, see bug#50416 */
+#endif
 #ifdef CLIENT_MULTI_STATEMENTS
 		client_flags &= ~CLIENT_MULTI_STATEMENTS;   /* don't allow multi_queries via connect parameter */
 #endif
@@ -776,8 +743,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)
 #else
-			if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, 
-								port, socket, client_flags, MySG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL)
+			if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, port, socket, client_flags TSRMLS_CC) == NULL)
 #endif
 			{
 				/* Populate connect error globals so that the error functions can read them */
@@ -825,8 +791,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)
 #else
-					if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, 
-										port, socket, client_flags, MySG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL)
+					if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, port, socket, client_flags TSRMLS_CC) == NULL)
 #endif
 					{
 						php_error_docref(NULL TSRMLS_CC, E_WARNING, "Link to server lost, unable to reconnect");
@@ -838,7 +803,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 				}
 			} else {
 #ifdef MYSQL_USE_MYSQLND
-				mysqlnd_restart_psession(mysql->conn, MySG(mysqlnd_thd_zval_cache));
+				mysqlnd_restart_psession(mysql->conn);
 #endif
 			}
 		}
@@ -897,8 +862,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) 
 #else
-		if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, 
-							port, socket, client_flags, MySG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL)
+		if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, port, socket, client_flags TSRMLS_CC) == NULL)
 #endif
 		{
 			/* Populate connect error globals so that the error functions can read them */
diff --git a/ext/mysql/php_mysql.h b/ext/mysql/php_mysql.h
index 33c3b2e..cef76ac 100644
--- a/ext/mysql/php_mysql.h
+++ b/ext/mysql/php_mysql.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
 */
 
 
-/* $Id: php_mysql.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_mysql.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_MYSQL_H
 #define PHP_MYSQL_H
diff --git a/ext/mysql/php_mysql_structs.h b/ext/mysql/php_mysql_structs.h
index d74eadc..0247dc8 100644
--- a/ext/mysql/php_mysql_structs.h
+++ b/ext/mysql/php_mysql_structs.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
 */
 
 
-/* $Id: php_mysql_structs.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_mysql_structs.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_MYSQL_STRUCTS_H
 #define PHP_MYSQL_STRUCTS_H
@@ -124,11 +124,6 @@ ZEND_BEGIN_MODULE_GLOBALS(mysql)
 	long result_allocated;
 	long trace_mode;
 	long allow_local_infile;
-#ifdef MYSQL_USE_MYSQLND
-	MYSQLND_THD_ZVAL_PCACHE *mysqlnd_thd_zval_cache;
-	MYSQLND_QCACHE			*mysqlnd_qcache;
-	long					cache_size;
-#endif
 ZEND_END_MODULE_GLOBALS(mysql)
 
 #ifdef ZTS
diff --git a/ext/mysql/tests/connect.inc b/ext/mysql/tests/connect.inc
index 86c0ee6..b5cc03e 100755
--- a/ext/mysql/tests/connect.inc
+++ b/ext/mysql/tests/connect.inc
@@ -19,30 +19,40 @@ if (!function_exists('sys_get_temp_dir')) {
 	}
 }
 
-/* wrapper to simplify test porting */
-function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL) {
-	global $connect_flags;
+if (!function_exists('my_mysql_connect')) {
+	/* wrapper to simplify test porting */
+	function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL, $persistent = false) {
+		global $connect_flags;
 
-	$flags = ($flags === NULL) ? $connect_flags : $flags;
+		$flags = ($flags === NULL) ? $connect_flags : $flags;
 
-	if ($socket)
-		$host = sprintf("%s:%s", $host, $socket);
-	else if ($port)
-		$host = sprintf("%s:%s", $host, $port);
+		if ($socket)
+			$host = sprintf("%s:%s", $host, $socket);
+		else if ($port)
+			$host = sprintf("%s:%s", $host, $port);
 
-	if (!$link = mysql_connect($host, $user, $passwd, true, $flags)) {
-		printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n",
-			$host, $user, $passwd,
-			mysql_errno(), mysql_error());
-		return false;
-	}
+		if ($persistent) {
+			$link = mysql_pconnect($host, $user, $passwd, $flags);
+		} else {
+			 $link = mysql_connect($host, $user, $passwd, true, $flags);
+		}
 
-	if (!mysql_select_db($db, $link)) {
-		printf("[000-b] [%d] %s\n", mysql_errno($link), mysql_error($link));
-		return false;
-	}
+		if (!$link) {
+			printf("[000-a] Cannot connect using host '%s', user '%s', password '****', persistent = %d, [%d] %s\n",
+				$host, $user, ($persistent) ? 1 : 0,
+				mysql_errno(), mysql_error());
+			return false;
+		}
 
-	return $link;
+		if (!mysql_select_db($db, $link)) {
+			printf("[000-b] [%d] %s\n", mysql_errno($link), mysql_error($link));
+			return false;
+		}
+
+		return $link;
+	}
+} else {
+	printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n");
 }
 
 /*
diff --git a/ext/mysql/tests/mysql_connect.phpt b/ext/mysql/tests/mysql_connect.phpt
index be094cc..773264e 100644
--- a/ext/mysql/tests/mysql_connect.phpt
+++ b/ext/mysql/tests/mysql_connect.phpt
@@ -35,19 +35,23 @@ printf("[005] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
 
 // Run the following tests without an anoynmous MySQL user and use a password for the test user!
 ini_set('mysql.default_socket', $socket);
-if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
-	printf("[006] Usage of mysql.default_socket failed\n");
-} else {
-	mysql_close($link);
+if (!is_null($socket)) {	
+	if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
+		printf("[006] Usage of mysql.default_socket failed\n");
+	} else {
+		mysql_close($link);
+	}
 }
 
 if (!ini_get('sql.safe_mode')) {
 
 	ini_set('mysql.default_port', $port);
-	if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
-		printf("[007] Usage of mysql.default_port failed\n");
-	} else {
-		mysql_close($link);
+	if (!is_null($port)) {
+		if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
+			printf("[007] Usage of mysql.default_port failed\n");
+		} else {
+			mysql_close($link);
+		}
 	}
 
 	ini_set('mysql.default_password', $passwd);
diff --git a/ext/mysql/tests/mysql_pconn_disable.phpt b/ext/mysql/tests/mysql_pconn_disable.phpt
index dfb04ee..532e2e5 100644
--- a/ext/mysql/tests/mysql_pconn_disable.phpt
+++ b/ext/mysql/tests/mysql_pconn_disable.phpt
@@ -13,19 +13,11 @@ mysql.max_links=2
 <?php
 	require_once("connect.inc");
 	require_once("table.inc");
-	// assert(ini_get('mysql.allow_persistent') == false);
 
-	if ($socket)
-		$myhost = sprintf("%s:%s", $host, $socket);
-	else if ($port)
-		$myhost = sprintf("%s:%s", $host, $port);
-	else
-	$myhost = $host;
-
-	if (($plink = mysql_pconnect($myhost, $user, $passwd)))
+	if (($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket, NULL, true)))
 		printf("[001] Can connect to the server.\n");
 
-	if (($res = @mysql_query('SELECT id FROM test ORDER BY id ASC', $plink)) &&
+	if (($res = mysql_query('SELECT id FROM test ORDER BY id ASC', $plink)) &&
 			($row = mysql_fetch_assoc($res)) &&
 			(mysql_free_result($res))) {
 		printf("[002] Can fetch data using persistent connection! Data = '%s'\n",
@@ -35,7 +27,7 @@ mysql.max_links=2
 	$thread_id = mysql_thread_id($plink);
 	mysql_close($plink);
 
-	if (!($plink = mysql_pconnect($myhost, $user, $passwd)))
+	if (!($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket, NULL, true)))
 		printf("[003] Cannot connect, [%d] %s\n", mysql_errno(), mysql_error());
 
 	if (mysql_thread_id($plink) != $thread_id)
@@ -44,7 +36,7 @@ mysql.max_links=2
 	$thread_id = mysql_thread_id($plink);
 	mysql_close($plink);
 
-	if (!($plink = mysql_connect($myhost, $user, $passwd, true)))
+	if (!($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)))
 		printf("[005] Cannot connect, [%d] %s\n", mysql_errno(), mysql_error());
 
 	if (mysql_thread_id($plink) == $thread_id)
diff --git a/ext/mysql/tests/mysql_pconn_max_links.phpt b/ext/mysql/tests/mysql_pconn_max_links.phpt
index 1d39e98..3eca0e5 100644
--- a/ext/mysql/tests/mysql_pconn_max_links.phpt
+++ b/ext/mysql/tests/mysql_pconn_max_links.phpt
@@ -18,6 +18,19 @@ Persistent connections and mysql.max_persistent
 	if (!mysql_select_db($db, $link))
 		die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link)));
 
+	if (!$res = mysql_query('SHOW VARIABLES LIKE "old_passwords"', $link)) {
+		die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link)));
+	}
+
+	if (mysql_num_rows($res) != 1) {
+		die(sprintf("skip Can't check if old_passwords = ON"));
+	}
+
+	$row = mysql_fetch_assoc($res);
+	mysql_free_result($res);
+	if ($row['Value'] == "ON")
+		die(sprintf("skip Test will fail because old_passwords = ON. Hint: old passwords are insecure!"));
+
 	if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link))
 		die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link)));
 
diff --git a/ext/mysql/tests/mysql_phpinfo.phpt b/ext/mysql/tests/mysql_phpinfo.phpt
index a57e42e..46600ab 100644
--- a/ext/mysql/tests/mysql_phpinfo.phpt
+++ b/ext/mysql/tests/mysql_phpinfo.phpt
@@ -1,8 +1,8 @@
 --TEST--
 phpinfo() mysql section
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -62,8 +62,7 @@ if ($IS_MYSQLND) {
 		'connect_failure', 'connection_reused', 'explicit_close', 'implicit_close',
 		'disconnect_close', 'in_middle_of_command_close', 'explicit_free_result',
 		'implicit_free_result', 'explicit_stmt_close', 'implicit_stmt_close',
-		'put_hits', 'put_misses', 'get_hits', 'get_misses',
-		'size', 'free_items', 'references', 'mysql.cache_size',
+		'size',
 	);
 	foreach ($expected as $k => $entry)
 		if (!stristr($phpinfo, $entry))
diff --git a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt
index 577ede3..a257f5f 100644
--- a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt
+++ b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt
@@ -4,6 +4,10 @@ LOAD DATA INFILE - open_basedir
 <?php
 require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
+require_once("connect.inc");
+
+if (!$IS_MYSQLND)
+	die("skip mysqlnd only, libmysql does not know about open_basedir restrictions");
 
 if (file_exists('./simple.csv') && !unlink('./simple.csv'))
 	die("skip Cannot remove previous CSV file");
@@ -13,6 +17,13 @@ if (!$fp = fopen('./simple.csv', 'w'))
 
 fclose($fp);
 @unlink('./simple.csv');
+
+if ($socket == "" && $host != NULL && $host != 'localhost' && $host != '.') {
+	/* could be a remote TCP/IP connection. LOCAL INFILE may not work */
+	if (gethostbyaddr($host) != gethostname()) {
+		die("skip LOAD DATA LOCAL INFILE will fail if connecting to remote MySQL");
+	}
+}
 ?>
 --INI--
 safe_mode=0
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index a3407b9..3ba50a1 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Ulf Wendel <uw at php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli.c 289630 2009-10-14 13:51:25Z johannes $ 
+  $Id: mysqli.c 293779 2010-01-20 17:09:28Z johannes $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -32,7 +32,6 @@
 #include "ext/standard/php_string.h"
 #include "php_mysqli_structs.h"
 #include "zend_exceptions.h"
-#include "ext/mysqlnd/mysqlnd_portability.h"
 
 ZEND_DECLARE_MODULE_GLOBALS(mysqli)
 static PHP_GINIT_FUNCTION(mysqli);
@@ -73,11 +72,6 @@ zend_class_entry *mysqli_driver_class_entry;
 zend_class_entry *mysqli_warning_class_entry;
 zend_class_entry *mysqli_exception_class_entry;
 
-#ifdef MYSQLI_USE_MYSQLND
-MYSQLND_ZVAL_PCACHE *mysqli_mysqlnd_zval_cache;
-MYSQLND_QCACHE		*mysqli_mysqlnd_qcache;
-#endif
-
 
 typedef int (*mysqli_read_t)(mysqli_object *obj, zval **retval TSRMLS_DC);
 typedef int (*mysqli_write_t)(mysqli_object *obj, zval *newval TSRMLS_DC);
@@ -228,22 +222,7 @@ static void mysqli_link_free_storage(void *object TSRMLS_DC)
 	if (my_res && my_res->ptr) {
 		MY_MYSQL *mysql = (MY_MYSQL *)my_res->ptr;
 		if (mysql->mysql) {
-			if (!mysql->persistent) {
-				mysqli_close(mysql->mysql, MYSQLI_CLOSE_IMPLICIT);
-			} else {
-				zend_rsrc_list_entry *le;
-				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;
-					
-						zend_ptr_stack_push(&plist->free_links, mysql->mysql);
-
-						MyG(num_links)--;
-						MyG(num_active_persistent)--;
-						MyG(num_inactive_persistent)++;
-					}
-				}
-			}
+			php_mysqli_close(mysql, MYSQLI_CLOSE_EXPLICIT TSRMLS_CC);
 		}
 		php_clear_mysql(mysql);
 		efree(mysql);
@@ -604,9 +583,6 @@ PHP_INI_BEGIN()
 #endif
 	STD_PHP_INI_BOOLEAN("mysqli.reconnect",				"0",	PHP_INI_SYSTEM,		OnUpdateLong,		reconnect,			zend_mysqli_globals,		mysqli_globals)
 	STD_PHP_INI_BOOLEAN("mysqli.allow_local_infile",	"1",	PHP_INI_SYSTEM,		OnUpdateLong,		allow_local_infile,	zend_mysqli_globals,		mysqli_globals)
-#ifdef MYSQLI_USE_MYSQLND
-	STD_PHP_INI_ENTRY("mysqli.cache_size",				"2000",	PHP_INI_SYSTEM,		OnUpdateLong,		cache_size,			zend_mysqli_globals,		mysqli_globals)
-#endif
 PHP_INI_END()
 /* }}} */
 
@@ -635,10 +611,6 @@ static PHP_GINIT_FUNCTION(mysqli)
 #else
 	mysqli_globals->embedded = 0;
 #endif
-#ifdef MYSQLI_USE_MYSQLND
-	mysqli_globals->cache_size = 0;
-	mysqli_globals->mysqlnd_thd_zval_cache = NULL;
-#endif
 }
 /* }}} */
 
@@ -656,9 +628,6 @@ PHP_MINIT_FUNCTION(mysqli)
 		return FAILURE;
 	}
 #endif
-#else
-	mysqli_mysqlnd_zval_cache = mysqlnd_palloc_init_cache(MyG(cache_size));
-	mysqli_mysqlnd_qcache = mysqlnd_qcache_init_cache();
 #endif
 
 	memcpy(&mysqli_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
@@ -749,9 +718,6 @@ PHP_MINIT_FUNCTION(mysqli)
 	/* for mysqli_query */
 	REGISTER_LONG_CONSTANT("MYSQLI_STORE_RESULT", MYSQLI_STORE_RESULT, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("MYSQLI_USE_RESULT", MYSQLI_USE_RESULT, CONST_CS | CONST_PERSISTENT);
-#if defined(MYSQLI_USE_MYSQLND) && defined(MYSQLND_THREADED)
-	REGISTER_LONG_CONSTANT("MYSQLI_BG_STORE_RESULT", MYSQLI_BG_STORE_RESULT, CONST_CS | CONST_PERSISTENT);
-#endif
 #if defined (MYSQLI_USE_MYSQLND)
 	REGISTER_LONG_CONSTANT("MYSQLI_ASYNC", MYSQLI_ASYNC, CONST_CS | CONST_PERSISTENT);
 #endif
@@ -899,9 +865,6 @@ PHP_MSHUTDOWN_FUNCTION(mysqli)
 	mysql_server_end();
 #endif
 #endif
-#else
-	mysqlnd_palloc_free_cache(mysqli_mysqlnd_zval_cache);
-	mysqlnd_qcache_free_cache_reference(&mysqli_mysqlnd_qcache);
 #endif
 
 	zend_hash_destroy(&mysqli_driver_properties);
@@ -927,9 +890,6 @@ PHP_RINIT_FUNCTION(mysqli)
 #endif
 	MyG(error_msg) = NULL;
 	MyG(error_no) = 0;
-#ifdef MYSQLI_USE_MYSQLND
-	MyG(mysqlnd_thd_zval_cache) = mysqlnd_palloc_rinit(mysqli_mysqlnd_zval_cache);
-#endif
 
 	return SUCCESS;
 }
@@ -969,7 +929,6 @@ PHP_RSHUTDOWN_FUNCTION(mysqli)
 	}
 #ifdef MYSQLI_USE_MYSQLND
 	zend_hash_apply(&EG(persistent_list), (apply_func_t) php_mysqli_persistent_helper_once TSRMLS_CC);
-	mysqlnd_palloc_rshutdown(MyG(mysqlnd_thd_zval_cache));
 #endif
 	return SUCCESS;
 }
@@ -994,19 +953,6 @@ PHP_MINFO_FUNCTION(mysqli)
 #if !defined(MYSQLI_USE_MYSQLND)
 	php_info_print_table_row(2, "Client API header version", MYSQL_SERVER_VERSION);
 	php_info_print_table_row(2, "MYSQLI_SOCKET", MYSQL_UNIX_ADDR);
-#else
-	{
-		zval values;
-
-		php_info_print_table_header(2, "Persistent cache", mysqli_mysqlnd_zval_cache? "enabled":"disabled");
-		
-		if (mysqli_mysqlnd_zval_cache) {
-			/* Now report cache status */
-			mysqlnd_palloc_stats(mysqli_mysqlnd_zval_cache, &values);
-			mysqlnd_minfo_print_hash(&values);
-			zval_dtor(&values);
-		}
-	}
 #endif
 	php_info_print_table_end();
 
@@ -1108,11 +1054,6 @@ PHP_FUNCTION(mysqli_result_construct)
 		case MYSQLI_USE_RESULT:
 			result = mysql_use_result(mysql->mysql);
 			break;
-#if defined(MYSQLI_USE_MYSQLND) && defined(MYSQLND_THREADED)
-		case MYSQLI_BG_STORE_RESULT:
-			result = mysqli_bg_store_result(mysql->mysql);
-			break;
-#endif
 		default:
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for resultmode");
 	}
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index b87b741..81cfeef 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Ulf Wendel <uw at php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_api.c 289630 2009-10-14 13:51:25Z johannes $ 
+  $Id: mysqli_api.c 294543 2010-02-04 20:28:55Z johannes $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -31,7 +31,6 @@
 #include "php_globals.h"
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
-#include "ext/mysqlnd/mysqlnd_portability.h"
 
 /* {{{ proto mixed mysqli_affected_rows(object link)
    Get number of affected rows in previous MySQL operation */
@@ -552,22 +551,12 @@ PHP_FUNCTION(mysqli_character_set_name)
 }
 /* }}} */
 
-/* {{{ proto bool mysqli_close(object link)
-   Close connection */
-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;
-	}
-
-	MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED);
 
+/* {{{ php_mysqli_close */
+void php_mysqli_close(MY_MYSQL * mysql, int close_type TSRMLS_DC)
+{
 	if (!mysql->persistent) {
-		mysqli_close(mysql->mysql, MYSQLI_CLOSE_EXPLICIT);
-		mysql->mysql = NULL;
+		mysqli_close(mysql->mysql, close_type);
 	} else {
 		zend_rsrc_list_entry *le;
 		if (zend_hash_find(&EG(persistent_list), mysql->hash_key, strlen(mysql->hash_key) + 1, (void **)&le) == SUCCESS) {
@@ -580,9 +569,29 @@ PHP_FUNCTION(mysqli_close)
 				MyG(num_inactive_persistent)++;
 			}
 		}
+		mysql->persistent = FALSE;
 	}
+	mysql->mysql = NULL;
 
 	php_clear_mysql(mysql);
+}
+/* }}} */
+
+
+/* {{{ proto bool mysqli_close(object link)
+   Close connection */
+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;
+	}
+
+	MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED);
+
+	php_mysqli_close(mysql, MYSQLI_CLOSE_EXPLICIT TSRMLS_CC);
 
 	MYSQLI_CLEAR_RESOURCE(&mysql_link);
 	efree(mysql);
@@ -1324,9 +1333,9 @@ PHP_FUNCTION(mysqli_info)
 }
 /* }}} */
 
-/* {{{ proto resource mysqli_init(void)
-   Initialize mysqli and return a resource for use with mysql_real_connect */
-PHP_FUNCTION(mysqli_init)
+
+/* {{{ php_mysqli_init() */
+void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS)
 {
 	MYSQLI_RESOURCE *mysqli_resource;
 	MY_MYSQL *mysql;
@@ -1363,6 +1372,15 @@ PHP_FUNCTION(mysqli_init)
 }
 /* }}} */
 
+
+/* {{{ proto resource mysqli_init(void)
+   Initialize mysqli and return a resource for use with mysql_real_connect */
+PHP_FUNCTION(mysqli_init)
+{
+	php_mysqli_init(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
 /* {{{ proto mixed mysqli_insert_id(object link)
    Get the ID generated from the previous INSERT operation */
 PHP_FUNCTION(mysqli_insert_id)
@@ -1579,6 +1597,68 @@ PHP_FUNCTION(mysqli_num_rows)
 }
 /* }}} */
 
+/* {{{ mysqli_options_get_option_zval_type */
+static int mysqli_options_get_option_zval_type(int option)
+{
+	switch (option) {
+#ifdef MYSQLI_USE_MYSQLND
+#if PHP_MAJOR_VERSION >= 6
+		case MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE:
+#endif
+		case MYSQLND_OPT_NET_CMD_BUFFER_SIZE:
+		case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
+#ifdef MYSQLND_STRING_TO_INT_CONVERSION
+		case MYSQLND_OPT_INT_AND_FLOAT_NATIVE:
+#endif
+#endif /* MYSQLI_USE_MYSQLND */
+		case MYSQL_OPT_CONNECT_TIMEOUT:
+#ifdef MYSQL_REPORT_DATA_TRUNCATION
+                case MYSQL_REPORT_DATA_TRUNCATION:
+#endif
+                case MYSQL_OPT_LOCAL_INFILE:
+                case MYSQL_OPT_NAMED_PIPE:
+#ifdef MYSQL_OPT_PROTOCOL
+                case MYSQL_OPT_PROTOCOL:
+#endif /* MySQL 4.1.0 */
+#ifdef MYSQL_OPT_READ_TIMEOUT
+		case MYSQL_OPT_READ_TIMEOUT:
+		case MYSQL_OPT_WRITE_TIMEOUT:
+		case MYSQL_OPT_GUESS_CONNECTION:
+		case MYSQL_OPT_USE_EMBEDDED_CONNECTION:
+		case MYSQL_OPT_USE_REMOTE_CONNECTION:
+		case MYSQL_SECURE_AUTH:
+#endif /* MySQL 4.1.1 */
+#ifdef MYSQL_OPT_RECONNECT
+		case MYSQL_OPT_RECONNECT:
+#endif /* MySQL 5.0.13 */
+#ifdef MYSQL_OPT_SSL_VERIFY_SERVER_CERT
+                case MYSQL_OPT_SSL_VERIFY_SERVER_CERT:
+#endif /* MySQL 5.0.23 */
+#ifdef MYSQL_OPT_COMPRESS
+		case MYSQL_OPT_COMPRESS:
+#endif /* mysqlnd @ PHP 5.3.2 */
+			return IS_LONG;
+
+#ifdef MYSQL_SHARED_MEMORY_BASE_NAME
+                case MYSQL_SHARED_MEMORY_BASE_NAME:
+#endif /* MySQL 4.1.0 */
+#ifdef MYSQL_SET_CLIENT_IP
+		case MYSQL_SET_CLIENT_IP:
+#endif /* MySQL 4.1.1 */
+		case MYSQL_READ_DEFAULT_FILE:
+		case MYSQL_READ_DEFAULT_GROUP:
+		case MYSQL_INIT_COMMAND:
+		case MYSQL_SET_CHARSET_NAME:
+		case MYSQL_SET_CHARSET_DIR:
+			return IS_STRING;
+
+		default:
+			return IS_NULL;
+	}
+}
+/* }}} */
+
+
 /* {{{ proto bool mysqli_options(object link, int flags, mixed values)
    Set options */
 PHP_FUNCTION(mysqli_options)
@@ -1589,6 +1669,7 @@ PHP_FUNCTION(mysqli_options)
 	long			mysql_option;
 	unsigned int	l_value;
 	long			ret;
+	int				expected_type;
 
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olz", &mysql_link, mysqli_link_class_entry, &mysql_option, &mysql_value) == FAILURE) {
 		return;
@@ -1600,16 +1681,30 @@ PHP_FUNCTION(mysqli_options)
 			RETURN_FALSE;
 		}
 	}
-
-	switch (Z_TYPE_PP(&mysql_value)) {
+	expected_type = mysqli_options_get_option_zval_type(mysql_option);
+	if (expected_type != Z_TYPE_P(mysql_value)) {
+		switch (expected_type) {
+			case IS_STRING:
+				convert_to_string_ex(&mysql_value);
+				break;
+			case IS_LONG:
+				convert_to_long_ex(&mysql_value);
+				break;
+			default:
+				break;
+		}
+	}
+	switch (expected_type) {
 		case IS_STRING:
 			ret = mysql_options(mysql->mysql, mysql_option, Z_STRVAL_PP(&mysql_value));
 			break;
-		default:
-			convert_to_long_ex(&mysql_value);
+		case IS_LONG:
 			l_value = Z_LVAL_PP(&mysql_value);
 			ret = mysql_options(mysql->mysql, mysql_option, (char *)&l_value);
 			break;
+		default:
+			ret = 1;
+			break;
 	}
 
 	RETURN_BOOL(!ret);
@@ -1673,7 +1768,7 @@ PHP_FUNCTION(mysqli_prepare)
 			memcpy(last_error, stmt->stmt->last_error, MYSQL_ERRMSG_SIZE);
 			memcpy(sqlstate, mysql->mysql->net.sqlstate, SQLSTATE_LENGTH+1);
 #else
-			mysqlnd_error_info error_info = mysql->mysql->error_info;
+			MYSQLND_ERROR_INFO error_info = mysql->mysql->error_info;
 #endif
 			mysqli_stmt_close(stmt->stmt, FALSE);
 			stmt->stmt = NULL;
diff --git a/ext/mysqli/mysqli_driver.c b/ext/mysqli/mysqli_driver.c
index a30e240..2d553f9 100644
--- a/ext/mysqli/mysqli_driver.c
+++ b/ext/mysqli/mysqli_driver.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
diff --git a/ext/mysqli/mysqli_embedded.c b/ext/mysqli/mysqli_embedded.c
index 5a7a0c2..1b3eb47 100644
--- a/ext/mysqli/mysqli_embedded.c
+++ b/ext/mysqli/mysqli_embedded.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
diff --git a/ext/mysqli/mysqli_exception.c b/ext/mysqli/mysqli_exception.c
index a8707f9..2bf65d0 100644
--- a/ext/mysqli/mysqli_exception.c
+++ b/ext/mysqli/mysqli_exception.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
diff --git a/ext/mysqli/mysqli_fe.c b/ext/mysqli/mysqli_fe.c
index 9023898..5e87842 100644
--- a/ext/mysqli/mysqli_fe.c
+++ b/ext/mysqli/mysqli_fe.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -15,7 +15,7 @@
   | Author: Georg Richter <georg at php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_fe.c 274296 2009-01-22 21:01:58Z johannes $ 
+  $Id: mysqli_fe.c 293036 2010-01-03 09:23:27Z sebastian $ 
 */
 
 #ifdef HAVE_CONFIG_H
diff --git a/ext/mysqli/mysqli_libmysql.h b/ext/mysqli/mysqli_libmysql.h
index 1ea1fc3..84fb7c8 100644
--- a/ext/mysqli/mysqli_libmysql.h
+++ b/ext/mysqli/mysqli_libmysql.h
@@ -1,9 +1,9 @@
 /*
-  +----------------------------------------------------------------------+
+  ----------------------------------------------------------------------
   | PHP Version 6                                                        |
-  +----------------------------------------------------------------------+
+  ----------------------------------------------------------------------
   | Copyright (c) 2007 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:           |
@@ -11,18 +11,21 @@
   | 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.               |
-  +----------------------------------------------------------------------+
+  ----------------------------------------------------------------------
   | Authors: Georg Richter <georg at mysql.com>                             |
   |          Andrey Hristov <andrey at mysql.com>                           |
   |          Ulf Wendel <uwendel at mysql.com>                              |
-  +----------------------------------------------------------------------+
+  ----------------------------------------------------------------------
 
 */
 
+#ifndef MYSQLI_LIBMYSQL_H
+#define MYSQLI_LIBMYSQL_H
+
 /* These are unused */
-#define MYSQLI_CLOSE_EXPLICIT
-#define MYSQLI_CLOSE_IMPLICIT
-#define MYSQLI_CLOSE_DISCONNECTED
+#define MYSQLI_CLOSE_EXPLICIT 0
+#define MYSQLI_CLOSE_IMPLICIT 1
+#define MYSQLI_CLOSE_DISCONNECTED 2
 #define MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE	200
 #define MYSQLND_OPT_INT_AND_YEAR_AS_INT				201
 
@@ -34,3 +37,80 @@
 #define mysqli_close(c, is_forced)			mysql_close((c))
 #define mysqli_stmt_close(c, implicit)		mysql_stmt_close((c))
 #define mysqli_free_result(r, is_forced)	mysql_free_result((r))
+#define mysqli_change_user_silent(c, u, p, d)   mysql_change_user((c), (u), (p), (d))
+
+
+/*
+  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 
+  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 !!!
+*/
+
+
+#ifndef uint1korr
+#define uint1korr(A)	(*(((uint8_t*)(A))))
+#endif
+
+#ifndef bit_uint2korr
+#define bit_uint2korr(A) ((uint16_t) (((uint16_t) (((unsigned char*) (A))[1])) +\
+                                   ((uint16_t) (((unsigned char*) (A))[0]) << 8)))
+#endif
+
+#ifndef bit_uint3korr
+#define bit_uint3korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
+                                   (((uint32_t) (((unsigned char*) (A))[0])) << 16)))
+#endif
+
+#ifndef bit_uint4korr
+#define bit_uint4korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
+                                   (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[0])) << 24)))
+#endif
+
+#ifndef bit_uint5korr
+#define bit_uint5korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[4])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[3])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 24)) +\
+                                    (((uint64_t) (((unsigned char*) (A))[0])) << 32))
+#endif
+
+#ifndef bit_uint6korr
+#define bit_uint6korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[5])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[3])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[1])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0]) << 8)))) <<\
+                                     32))
+#endif
+
+#ifndef bit_uint7korr
+#define bit_uint7korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[6])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[5])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[3])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0])) << 16))) <<\
+                                     32))
+#endif
+
+#ifndef bit_uint8korr
+#define bit_uint8korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[7])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[6])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[5])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0])) << 24))) <<\
+                                    32))
+#endif
+
+#endif /* MYSQLI_LIBMYSQL_H */
+
diff --git a/ext/mysqli/mysqli_mysqlnd.h b/ext/mysqli/mysqli_mysqlnd.h
index 574d956..1468ef2 100644
--- a/ext/mysqli/mysqli_mysqlnd.h
+++ b/ext/mysqli/mysqli_mysqlnd.h
@@ -23,6 +23,7 @@
 #define MYSQLI_MYSQLND_H
 
 #include "ext/mysqlnd/mysqlnd_libmysql_compat.h"
+#include "ext/mysqlnd/mysqlnd_portability.h"
 
 /* Here comes non-libmysql API to have less ifdefs in mysqli*/
 #define MYSQLI_CLOSE_EXPLICIT                  MYSQLND_CLOSE_EXPLICIT
@@ -37,8 +38,8 @@
 #define mysqli_close(c, how)			mysqlnd_close((c), (how))
 #define mysqli_stmt_close(c, implicit)	mysqlnd_stmt_close((c), (implicit))
 #define mysqli_free_result(r, implicit)	mysqlnd_free_result((r), (implicit))
-#define mysqli_bg_store_result(r)		mysqlnd_bg_store_result((r))
 #define mysqli_async_query(c, q, l)		mysqlnd_async_query((c), (q), (l))
+#define mysqli_change_user_silent(c, u, p, d)   mysqlnd_change_user((c), (u), (p), (d), TRUE)
 
 #define HAVE_STMT_NEXT_RESULT
 
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index c56485b..c2d9fa2 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Ulf Wendel <uw at php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_nonapi.c 290608 2009-11-12 17:48:36Z johannes $ 
+  $Id: mysqli_nonapi.c 294543 2010-02-04 20:28:55Z johannes $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -80,7 +80,8 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
 #endif
 
 	if (getThis() && !ZEND_NUM_ARGS() && in_ctor) {
-		RETURN_NULL();
+		php_mysqli_init(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+		return;
 	}
 	hostname = username = dbname = passwd = socket = NULL;
 
@@ -93,14 +94,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
 		if (object && instanceof_function(Z_OBJCE_P(object), mysqli_link_class_entry TSRMLS_CC)) {
 			mysqli_resource = ((mysqli_object *) zend_object_store_get_object(object TSRMLS_CC))->ptr;
 			if (mysqli_resource && mysqli_resource->ptr) {
-				mysql = (MY_MYSQL*) mysqli_resource->ptr;			
-				if (mysqli_resource->status > MYSQLI_STATUS_INITIALIZED) {
-					php_clear_mysql(mysql);
-					if (mysql->mysql) {
-						mysqli_close(mysql->mysql, MYSQLI_CLOSE_EXPLICIT);
-						mysql->mysql = NULL;
-					}
-				}
+				mysql = (MY_MYSQL*) mysqli_resource->ptr;
 			}
 		}
 		if (!mysql) {
@@ -126,7 +120,10 @@ 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 TSRMLS_CC);
+	}
 
 	if (!socket_len || !socket) {
 		socket = MyG(default_socket);
@@ -165,15 +162,6 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
 
 					do {
 						if (zend_ptr_stack_num_elements(&plist->free_links)) {
-							if (is_real_connect) {
-								/*
-								  Gotcha! If there are some options set on the handle with mysqli_options()
-								  they will be lost. We will fetch other handle with other options. This could
-								  be a source of bug reports of people complaining but...nothing else could be
-								  done, if they want PCONN!
-								*/
-								mysqli_close(mysql->mysql, MYSQLI_CLOSE_IMPLICIT);
-							}
 							mysql->mysql = zend_ptr_stack_pop(&plist->free_links);
 
 							MyG(num_inactive_persistent)--;
@@ -183,12 +171,12 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
 							/* reset variables */
 
 #ifndef MYSQLI_NO_CHANGE_USER_ON_PCONNECT
-							if (!mysql_change_user(mysql->mysql, username, passwd, dbname)) {
+							if (!mysqli_change_user_silent(mysql->mysql, username, passwd, dbname)) {
 #else
 							if (!mysql_ping(mysql->mysql)) {
 #endif
 #ifdef MYSQLI_USE_MYSQLND
-								mysqlnd_restart_psession(mysql->mysql, MyG(mysqlnd_thd_zval_cache));
+								mysqlnd_restart_psession(mysql->mysql);
 #endif
 								MyG(num_active_persistent)++;
 								goto end;
@@ -245,7 +233,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
 	if (mysql_real_connect(mysql->mysql, hostname, username, passwd, dbname, port, socket, CLIENT_MULTI_RESULTS) == NULL)
 #else
 	if (mysqlnd_connect(mysql->mysql, hostname, username, passwd, passwd_len, dbname, dbname_len,
-						port, socket, flags, MyG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL)
+						port, socket, flags TSRMLS_CC) == NULL)
 #endif
 	{
 		/* Save error messages - for mysqli_connect_error() & mysqli_connect_errno() */
@@ -302,6 +290,7 @@ err:
 	if (mysql->hash_key) {
 		efree(mysql->hash_key);
 		mysql->hash_key = NULL;
+		mysql->persistent = FALSE;
 	}
 	if (!is_real_connect) {
 		efree(mysql);
@@ -428,7 +417,7 @@ PHP_FUNCTION(mysqli_get_cache_stats)
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
 	}
-	mysqlnd_palloc_stats(mysqli_mysqlnd_zval_cache, return_value);
+	array_init(return_value);
 }
 /* }}} */
 
@@ -498,7 +487,7 @@ PHP_FUNCTION(mysqli_multi_query)
 		strcpy(s_sqlstate, mysql_sqlstate(mysql->mysql));
 		s_errno = mysql_errno(mysql->mysql);
 #else
-		mysqlnd_error_info error_info = mysql->mysql->error_info;
+		MYSQLND_ERROR_INFO error_info = mysql->mysql->error_info;
 #endif
 		MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
 		MYSQLI_DISABLE_MQ;
@@ -536,11 +525,7 @@ PHP_FUNCTION(mysqli_query)
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty query");
 		RETURN_FALSE;
 	}
-	if ((resultmode & ~MYSQLI_ASYNC) != MYSQLI_USE_RESULT && (resultmode & ~MYSQLI_ASYNC) != MYSQLI_STORE_RESULT
-#if defined(MYSQLI_USE_MYSQLND) && defined(MYSQLND_THREADED)
-		&& (resultmode & ~MYSQLI_ASYNC) != MYSQLI_BG_STORE_RESULT
-#endif
-	) {
+	if ((resultmode & ~MYSQLI_ASYNC) != MYSQLI_USE_RESULT && (resultmode & ~MYSQLI_ASYNC) != MYSQLI_STORE_RESULT) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for resultmode");
 		RETURN_FALSE;
 	}
@@ -581,11 +566,6 @@ PHP_FUNCTION(mysqli_query)
 		case MYSQLI_USE_RESULT:
 			result = mysql_use_result(mysql->mysql);
 			break;
-#if defined(MYSQLI_USE_MYSQLND) && defined(MYSQLND_THREADED)
-		case MYSQLI_BG_STORE_RESULT:
-			result = mysqli_bg_store_result(mysql->mysql);
-			break;
-#endif
 	}
 	if (!result) {
 		php_mysqli_throw_sql_exception((char *)mysql_sqlstate(mysql->mysql), mysql_errno(mysql->mysql) TSRMLS_CC,
@@ -819,11 +799,6 @@ PHP_FUNCTION(mysqli_reap_async_query)
 		case MYSQLI_USE_RESULT:
 			result = mysql_use_result(mysql->mysql);
 			break;
-#if defined(MYSQLI_USE_MYSQLND) && defined(MYSQLND_THREADED)
-		case MYSQLI_BG_STORE_RESULT:
-			result = mysqli_bg_store_result(mysql->mysql);
-			break;
-#endif
 	}
 
 	if (!result) {
diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c
index 40899f5..fdb3045 100644
--- a/ext/mysqli/mysqli_prop.c
+++ b/ext/mysqli/mysqli_prop.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -15,7 +15,7 @@
   | Author: Georg Richter <georg at php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_prop.c 281235 2009-05-27 15:05:28Z andrey $ 
+  $Id: mysqli_prop.c 293036 2010-01-03 09:23:27Z sebastian $ 
 */
 
 #ifdef HAVE_CONFIG_H
diff --git a/ext/mysqli/mysqli_report.c b/ext/mysqli/mysqli_report.c
index 1c5f916..f48688f 100644
--- a/ext/mysqli/mysqli_report.c
+++ b/ext/mysqli/mysqli_report.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -15,7 +15,7 @@
   | Author: Georg Richter <georg at php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_report.c 272370 2008-12-31 11:15:49Z sebastian $ 
+  $Id: mysqli_report.c 293036 2010-01-03 09:23:27Z sebastian $ 
 */
 
 #ifdef HAVE_CONFIG_H
diff --git a/ext/mysqli/mysqli_report.h b/ext/mysqli/mysqli_report.h
index 679108f..8c44802 100644
--- a/ext/mysqli/mysqli_report.h
+++ b/ext/mysqli/mysqli_report.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -15,7 +15,7 @@
   | Author: Georg Richter <georg at php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_report.h 272370 2008-12-31 11:15:49Z sebastian $
+  $Id: mysqli_report.h 293036 2010-01-03 09:23:27Z sebastian $
 */
 
 #ifndef __HAVE_MYSQLI_PROFILER_H__
diff --git a/ext/mysqli/mysqli_warning.c b/ext/mysqli/mysqli_warning.c
index b17694a..80c26eb 100644
--- a/ext/mysqli/mysqli_warning.c
+++ b/ext/mysqli/mysqli_warning.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
diff --git a/ext/mysqli/php_mysqli.h b/ext/mysqli/php_mysqli.h
index 773b7f2..2c279d0 100644
--- a/ext/mysqli/php_mysqli.h
+++ b/ext/mysqli/php_mysqli.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Ulf Wendel <uw at php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: php_mysqli.h 272370 2008-12-31 11:15:49Z sebastian $ 
+  $Id: php_mysqli.h 293036 2010-01-03 09:23:27Z sebastian $ 
 */
 
 #ifndef PHP_MYSQLI_H
diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h
index 789850b..beecf01 100644
--- a/ext/mysqli/php_mysqli_structs.h
+++ b/ext/mysqli/php_mysqli_structs.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -15,7 +15,7 @@
   | Author: Georg Richter <georg at php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: php_mysqli_structs.h 289630 2009-10-14 13:51:25Z johannes $ 
+  $Id: php_mysqli_structs.h 294543 2010-02-04 20:28:55Z johannes $ 
 */
 
 #ifndef PHP_MYSQLI_STRUCTS_H
@@ -196,11 +196,6 @@ 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[];
 
-#ifdef MYSQLI_USE_MYSQLND
-extern MYSQLND_ZVAL_PCACHE	*mysqli_mysqlnd_zval_cache;
-extern MYSQLND_QCACHE		*mysqli_mysqlnd_qcache;
-#endif
-
 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 *);
@@ -220,6 +215,9 @@ 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 TSRMLS_DC);
+
+
 #ifdef HAVE_SPL
 extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
 #endif
@@ -305,9 +303,6 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
 #define MYSQLI_STORE_RESULT 0
 #define MYSQLI_USE_RESULT 	1
 #ifdef MYSQLI_USE_MYSQLND
-#ifdef MYSQLND_THREADED
-#define MYSQLI_BG_STORE_RESULT 	4
-#endif
 #define MYSQLI_ASYNC	 	8
 #else
 /* libmysql */
@@ -343,6 +338,8 @@ if ((MyG(report_mode) & MYSQLI_REPORT_ERROR) && mysql_stmt_errno(stmt)) { \
 
 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;
@@ -367,9 +364,6 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqli)
 	HashTable		*report_ht;
 	unsigned long	multi_query;
 	unsigned long	embedded;
-#ifdef MYSQLI_USE_MYSQLND
-	MYSQLND_THD_ZVAL_PCACHE	*mysqlnd_thd_zval_cache;
-#endif
 ZEND_END_MODULE_GLOBALS(mysqli)
 
 
diff --git a/ext/mysqli/tests/001.phpt b/ext/mysqli/tests/001.phpt
index 4e19d81..ed09b2e 100644
--- a/ext/mysqli/tests/001.phpt
+++ b/ext/mysqli/tests/001.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$test = "";
 
diff --git a/ext/mysqli/tests/002.phpt b/ext/mysqli/tests/002.phpt
index 6bbdecf..c183108 100644
--- a/ext/mysqli/tests/002.phpt
+++ b/ext/mysqli/tests/002.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
@@ -48,7 +48,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/003.phpt b/ext/mysqli/tests/003.phpt
index e22fec1..9094c86 100644
--- a/ext/mysqli/tests/003.phpt
+++ b/ext/mysqli/tests/003.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
@@ -74,7 +74,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/004.phpt b/ext/mysqli/tests/004.phpt
index 1eae99d..184ecea 100644
--- a/ext/mysqli/tests/004.phpt
+++ b/ext/mysqli/tests/004.phpt
@@ -49,7 +49,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/005.phpt b/ext/mysqli/tests/005.phpt
index 728f45e..0d59f40 100644
--- a/ext/mysqli/tests/005.phpt
+++ b/ext/mysqli/tests/005.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -42,7 +42,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/006.phpt b/ext/mysqli/tests/006.phpt
index a10e22c..4974265 100644
--- a/ext/mysqli/tests/006.phpt
+++ b/ext/mysqli/tests/006.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -47,7 +47,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/007.phpt b/ext/mysqli/tests/007.phpt
index fe266bf..05a8ae5 100644
--- a/ext/mysqli/tests/007.phpt
+++ b/ext/mysqli/tests/007.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -47,7 +47,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/008.phpt b/ext/mysqli/tests/008.phpt
index 685110f..ba0e340 100644
--- a/ext/mysqli/tests/008.phpt
+++ b/ext/mysqli/tests/008.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -47,7 +47,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/009.phpt b/ext/mysqli/tests/009.phpt
index 0584a14..3e26f51 100644
--- a/ext/mysqli/tests/009.phpt
+++ b/ext/mysqli/tests/009.phpt
@@ -11,7 +11,7 @@ mysqli fetch bigint values (ok to fail with 4.1.x)
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -80,7 +80,7 @@ mysqli fetch bigint values (ok to fail with 4.1.x)
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/010.phpt b/ext/mysqli/tests/010.phpt
index de22c08..fab0c57 100644
--- a/ext/mysqli/tests/010.phpt
+++ b/ext/mysqli/tests/010.phpt
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -50,7 +50,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/011.phpt b/ext/mysqli/tests/011.phpt
index 4c4ff77..83f35e5 100644
--- a/ext/mysqli/tests/011.phpt
+++ b/ext/mysqli/tests/011.phpt
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -47,7 +47,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/012.phpt b/ext/mysqli/tests/012.phpt
index 2ce8104..da4a48a 100644
--- a/ext/mysqli/tests/012.phpt
+++ b/ext/mysqli/tests/012.phpt
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -46,7 +46,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/013.phpt b/ext/mysqli/tests/013.phpt
index 8c123d1..5ddb496 100644
--- a/ext/mysqli/tests/013.phpt
+++ b/ext/mysqli/tests/013.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -58,7 +58,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/014.phpt b/ext/mysqli/tests/014.phpt
index cd7fa19..8fb8cce 100644
--- a/ext/mysqli/tests/014.phpt
+++ b/ext/mysqli/tests/014.phpt
@@ -4,7 +4,7 @@ mysqli autocommit/commit/rollback
 <?php
 	require_once('skipif.inc');
 	require_once('skipifconnectfailure.inc');
-	include "connect.inc";
+	require_once("connect.inc");
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 	if (!$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) {
 		die("skip Cannot check for required InnoDB suppot");
@@ -21,7 +21,7 @@ mysqli autocommit/commit/rollback
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
 	if (!mysqli_autocommit($link, TRUE))
diff --git a/ext/mysqli/tests/015.phpt b/ext/mysqli/tests/015.phpt
index b3af014..c4f693f 100644
--- a/ext/mysqli/tests/015.phpt
+++ b/ext/mysqli/tests/015.phpt
@@ -4,20 +4,21 @@ mysqli autocommit/commit/rollback with innodb
 <?php
 	require_once('skipif.inc');
 	require_once('skipifconnectfailure.inc');
-	include "connect.inc";
+	require_once("connect.inc");
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 	$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
 	$row = mysqli_fetch_row($result);
 	mysqli_free_result($result);
 	mysqli_close($link);
 
-	if ($row[1] == "NO") {
-		printf ("skip innodb support not installed.");
+	if ($row[1] == "DISABLED" || $row[1] == "NO") {
+		printf ("skip innodb support is not installed or enabled.");
+		exit;
 	}
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 	if (!$link)
diff --git a/ext/mysqli/tests/016.phpt b/ext/mysqli/tests/016.phpt
index c8046de..ce1ea83 100644
--- a/ext/mysqli/tests/016.phpt
+++ b/ext/mysqli/tests/016.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/017.phpt b/ext/mysqli/tests/017.phpt
index 7220b4e..a48ae5c 100644
--- a/ext/mysqli/tests/017.phpt
+++ b/ext/mysqli/tests/017.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/018.phpt b/ext/mysqli/tests/018.phpt
index 1a8d762..8747644 100644
--- a/ext/mysqli/tests/018.phpt
+++ b/ext/mysqli/tests/018.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/019.phpt b/ext/mysqli/tests/019.phpt
index f3741a5..51cf973 100644
--- a/ext/mysqli/tests/019.phpt
+++ b/ext/mysqli/tests/019.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -57,7 +57,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/020.phpt b/ext/mysqli/tests/020.phpt
index f313a61..6e867d7 100644
--- a/ext/mysqli/tests/020.phpt
+++ b/ext/mysqli/tests/020.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -69,7 +69,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/021.phpt b/ext/mysqli/tests/021.phpt
index 3843566..5dec86c 100644
--- a/ext/mysqli/tests/021.phpt
+++ b/ext/mysqli/tests/021.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -40,7 +40,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/022.phpt b/ext/mysqli/tests/022.phpt
index 5c448b9..8e1f017 100644
--- a/ext/mysqli/tests/022.phpt
+++ b/ext/mysqli/tests/022.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -45,7 +45,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/023.phpt b/ext/mysqli/tests/023.phpt
index d3d4762..97c7812 100644
--- a/ext/mysqli/tests/023.phpt
+++ b/ext/mysqli/tests/023.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -54,7 +54,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/024.phpt b/ext/mysqli/tests/024.phpt
index 7dd5408..2cb93be 100644
--- a/ext/mysqli/tests/024.phpt
+++ b/ext/mysqli/tests/024.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -54,7 +54,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/025.phpt b/ext/mysqli/tests/025.phpt
index 9c076df..84a9f67 100644
--- a/ext/mysqli/tests/025.phpt
+++ b/ext/mysqli/tests/025.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -59,7 +59,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/026.phpt b/ext/mysqli/tests/026.phpt
index 57fe33e..ec4baa2 100644
--- a/ext/mysqli/tests/026.phpt
+++ b/ext/mysqli/tests/026.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -46,7 +46,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/027.phpt b/ext/mysqli/tests/027.phpt
index 0926b70..69233d6 100644
--- a/ext/mysqli/tests/027.phpt
+++ b/ext/mysqli/tests/027.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/028.phpt b/ext/mysqli/tests/028.phpt
index 6c4425e..af453dd 100644
--- a/ext/mysqli/tests/028.phpt
+++ b/ext/mysqli/tests/028.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/029.phpt b/ext/mysqli/tests/029.phpt
index bfc54bc..9364206 100644
--- a/ext/mysqli/tests/029.phpt
+++ b/ext/mysqli/tests/029.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -28,7 +28,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/030.phpt b/ext/mysqli/tests/030.phpt
index 656946f..c4b1710 100644
--- a/ext/mysqli/tests/030.phpt
+++ b/ext/mysqli/tests/030.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/031.phpt b/ext/mysqli/tests/031.phpt
index 9f632cb..9b8c720 100644
--- a/ext/mysqli/tests/031.phpt
+++ b/ext/mysqli/tests/031.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/032.phpt b/ext/mysqli/tests/032.phpt
index 386883d..5fcd548 100644
--- a/ext/mysqli/tests/032.phpt
+++ b/ext/mysqli/tests/032.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -28,7 +28,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/033.phpt b/ext/mysqli/tests/033.phpt
index ade0bb8..b499bd7 100644
--- a/ext/mysqli/tests/033.phpt
+++ b/ext/mysqli/tests/033.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/034.phpt b/ext/mysqli/tests/034.phpt
index cc41534..3fda560 100644
--- a/ext/mysqli/tests/034.phpt
+++ b/ext/mysqli/tests/034.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/035.phpt b/ext/mysqli/tests/035.phpt
index 7b621aa..7b18e02 100644
--- a/ext/mysqli/tests/035.phpt
+++ b/ext/mysqli/tests/035.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/036.phpt b/ext/mysqli/tests/036.phpt
index 4e68b6c..b0d259c 100644
--- a/ext/mysqli/tests/036.phpt
+++ b/ext/mysqli/tests/036.phpt
@@ -11,7 +11,7 @@ function test: mysqli_insert_id()
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -44,7 +44,7 @@ function test: mysqli_insert_id()
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/037.phpt b/ext/mysqli/tests/037.phpt
index 856bdc6..03d5d55 100644
--- a/ext/mysqli/tests/037.phpt
+++ b/ext/mysqli/tests/037.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 --FILE--
 <?php
 
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -34,7 +34,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/038.phpt b/ext/mysqli/tests/038.phpt
index 7be16f4..45b724c 100644
--- a/ext/mysqli/tests/038.phpt
+++ b/ext/mysqli/tests/038.phpt
@@ -7,8 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -35,7 +34,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/039.phpt b/ext/mysqli/tests/039.phpt
index 9ed7ef9..ae881e1 100644
--- a/ext/mysqli/tests/039.phpt
+++ b/ext/mysqli/tests/039.phpt
@@ -7,8 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/040.phpt b/ext/mysqli/tests/040.phpt
index 6b11516..3e28883 100644
--- a/ext/mysqli/tests/040.phpt
+++ b/ext/mysqli/tests/040.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -33,7 +33,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/041.phpt b/ext/mysqli/tests/041.phpt
index aac91f8..ec67e47 100644
--- a/ext/mysqli/tests/041.phpt
+++ b/ext/mysqli/tests/041.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 --FILE--
 <?php
 
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -24,7 +24,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/042.phpt b/ext/mysqli/tests/042.phpt
index 9d79f14..55da0cd 100644
--- a/ext/mysqli/tests/042.phpt
+++ b/ext/mysqli/tests/042.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -50,7 +50,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/043.phpt b/ext/mysqli/tests/043.phpt
index 51b2a91..5d060b9 100644
--- a/ext/mysqli/tests/043.phpt
+++ b/ext/mysqli/tests/043.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -42,7 +42,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/044.phpt b/ext/mysqli/tests/044.phpt
index 9d227f4..3ddae3e 100644
--- a/ext/mysqli/tests/044.phpt
+++ b/ext/mysqli/tests/044.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/045.phpt b/ext/mysqli/tests/045.phpt
index d5ee5ad..0b17060 100644
--- a/ext/mysqli/tests/045.phpt
+++ b/ext/mysqli/tests/045.phpt
@@ -6,7 +6,7 @@ mysqli_bind_result (SHOW)
 	require_once('skipifemb.inc');
 	require_once('skipifconnectfailure.inc');
 
-	include "connect.inc";
+	require_once("connect.inc");
 	$link = my_mysqli_connect($host, $user, $passwd);
 
 	$stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'");
@@ -20,7 +20,7 @@ mysqli_bind_result (SHOW)
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/046.phpt b/ext/mysqli/tests/046.phpt
index cf77392..18c86e3 100644
--- a/ext/mysqli/tests/046.phpt
+++ b/ext/mysqli/tests/046.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -36,7 +36,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/047.phpt b/ext/mysqli/tests/047.phpt
index 3401418..5a86857 100644
--- a/ext/mysqli/tests/047.phpt
+++ b/ext/mysqli/tests/047.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -47,7 +47,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/048.phpt b/ext/mysqli/tests/048.phpt
index 5ab60e5..afc0923 100644
--- a/ext/mysqli/tests/048.phpt
+++ b/ext/mysqli/tests/048.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -42,7 +42,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/049.phpt b/ext/mysqli/tests/049.phpt
index eb977a8..c87f369 100644
--- a/ext/mysqli/tests/049.phpt
+++ b/ext/mysqli/tests/049.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/050.phpt b/ext/mysqli/tests/050.phpt
index ba668f0..4e750c9 100644
--- a/ext/mysqli/tests/050.phpt
+++ b/ext/mysqli/tests/050.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/************************
 	 * non freed stamement
diff --git a/ext/mysqli/tests/051.phpt b/ext/mysqli/tests/051.phpt
index 8266515..ac85410 100644
--- a/ext/mysqli/tests/051.phpt
+++ b/ext/mysqli/tests/051.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/************************
 	 * free statement after close
diff --git a/ext/mysqli/tests/052.phpt b/ext/mysqli/tests/052.phpt
index f280d84..89336ad 100644
--- a/ext/mysqli/tests/052.phpt
+++ b/ext/mysqli/tests/052.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/************************
 	 * statement call  after close
diff --git a/ext/mysqli/tests/053.phpt b/ext/mysqli/tests/053.phpt
index e0bbcbe..a1840c9 100644
--- a/ext/mysqli/tests/053.phpt
+++ b/ext/mysqli/tests/053.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/************************
 	 * non freed resultset
diff --git a/ext/mysqli/tests/054.phpt b/ext/mysqli/tests/054.phpt
index 2d957cb..6bd45a7 100644
--- a/ext/mysqli/tests/054.phpt
+++ b/ext/mysqli/tests/054.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/************************
 	 * free resultset after close
diff --git a/ext/mysqli/tests/055.phpt b/ext/mysqli/tests/055.phpt
index 1f0461b..c73266e 100644
--- a/ext/mysqli/tests/055.phpt
+++ b/ext/mysqli/tests/055.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/************************
 	 * don't free anything
diff --git a/ext/mysqli/tests/056.phpt b/ext/mysqli/tests/056.phpt
index f5571ac..413e678 100644
--- a/ext/mysqli/tests/056.phpt
+++ b/ext/mysqli/tests/056.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	class foobar extends mysqli {
 		function test () {
diff --git a/ext/mysqli/tests/057.phpt b/ext/mysqli/tests/057.phpt
index 9da9a10..92f82d4 100644
--- a/ext/mysqli/tests/057.phpt
+++ b/ext/mysqli/tests/057.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -64,7 +64,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/058.phpt b/ext/mysqli/tests/058.phpt
index d1a90a0..a831261 100644
--- a/ext/mysqli/tests/058.phpt
+++ b/ext/mysqli/tests/058.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -50,7 +50,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/059.phpt b/ext/mysqli/tests/059.phpt
index 4897981..733a3ce 100644
--- a/ext/mysqli/tests/059.phpt
+++ b/ext/mysqli/tests/059.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -43,7 +43,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/060.phpt b/ext/mysqli/tests/060.phpt
index f1c20bf..5d17f8f 100644
--- a/ext/mysqli/tests/060.phpt
+++ b/ext/mysqli/tests/060.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	class test_class {
 		function __construct($arg1, $arg2) {
@@ -44,7 +44,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/061.phpt b/ext/mysqli/tests/061.phpt
index e40f3a2..08b4cda 100644
--- a/ext/mysqli/tests/061.phpt
+++ b/ext/mysqli/tests/061.phpt
@@ -9,7 +9,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	function my_read($fp, &$buffer, $buflen, &$error) {
 		$buffer = strrev(fread($fp, $buflen));
@@ -51,7 +51,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/062.phpt b/ext/mysqli/tests/062.phpt
index 0438553..bc6198c 100644
--- a/ext/mysqli/tests/062.phpt
+++ b/ext/mysqli/tests/062.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
diff --git a/ext/mysqli/tests/063.phpt b/ext/mysqli/tests/063.phpt
index 9b42ab7..b184d72 100644
--- a/ext/mysqli/tests/063.phpt
+++ b/ext/mysqli/tests/063.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
diff --git a/ext/mysqli/tests/064.phpt b/ext/mysqli/tests/064.phpt
index a308e4a..46af7a6 100644
--- a/ext/mysqli/tests/064.phpt
+++ b/ext/mysqli/tests/064.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
diff --git a/ext/mysqli/tests/065.phpt b/ext/mysqli/tests/065.phpt
index d0f1d16..172cecd 100644
--- a/ext/mysqli/tests/065.phpt
+++ b/ext/mysqli/tests/065.phpt
@@ -14,7 +14,7 @@ if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
 		printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
diff --git a/ext/mysqli/tests/066.phpt b/ext/mysqli/tests/066.phpt
index 7581876..91dfce5 100644
--- a/ext/mysqli/tests/066.phpt
+++ b/ext/mysqli/tests/066.phpt
@@ -7,8 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
@@ -30,7 +29,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/067.phpt b/ext/mysqli/tests/067.phpt
index f571495..d5795bd 100644
--- a/ext/mysqli/tests/067.phpt
+++ b/ext/mysqli/tests/067.phpt
@@ -4,7 +4,7 @@ function test: nested selects (cursors)
 <?php
 	require_once('skipif.inc');
 	require_once('skipifconnectfailure.inc');
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 		die("skip Cannot connect to check required version");
@@ -29,7 +29,7 @@ function test: nested selects (cursors)
 		return $stmt;
 	}
 
-	include "connect.inc";
+	require_once("connect.inc");
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
 	if ((!$IS_MYSQLND && mysqli_get_client_version() < 50009) ||
@@ -66,7 +66,7 @@ function test: nested selects (cursors)
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/069.phpt b/ext/mysqli/tests/069.phpt
index 404b6ab..ee76ca5 100644
--- a/ext/mysqli/tests/069.phpt
+++ b/ext/mysqli/tests/069.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 	$mysql->multi_query('SELECT 1;SELECT 2');
diff --git a/ext/mysqli/tests/070.phpt b/ext/mysqli/tests/070.phpt
index eee5125..b71d9b2 100644
--- a/ext/mysqli/tests/070.phpt
+++ b/ext/mysqli/tests/070.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 	var_dump($mysql->ping());
diff --git a/ext/mysqli/tests/071.phpt b/ext/mysqli/tests/071.phpt
index 8888fb1..38bc46b 100644
--- a/ext/mysqli/tests/071.phpt
+++ b/ext/mysqli/tests/071.phpt
@@ -8,13 +8,31 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
+	$version = $mysql->server_version;
 
 	var_dump($mysql->ping());
 
-	var_dump($mysql->kill($mysql->thread_id));
+	$ret = $mysql->kill($mysql->thread_id);
+	if ($IS_MYSQLND) {
+		if ($ret !== true){
+			printf("[001] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true));
+		}
+	} else {
+		/* libmysql return value seems to depend on server version */
+		if (($version >= 50123 || $version <= 40200) && $version != 50200) {
+			/* TODO: find exact version */
+			if ($ret !== true){
+				printf("[001] Expecting boolean/true got %s/%s @\n", gettype($ret), var_export($ret, true), $version);
+			}
+		} else {
+			if ($ret !== false){
+			printf("[001] Expecting boolean/false got %s/%s @\n", gettype($ret), var_export($ret, true), $version);
+			}
+		}
+	}
 
 	var_dump($mysql->ping());
 
@@ -24,7 +42,24 @@ require_once('skipifconnectfailure.inc');
 
 	var_dump(mysqli_ping($mysql));
 
-	var_dump(mysqli_kill($mysql, mysqli_thread_id($mysql)));
+	$ret = $mysql->kill($mysql->thread_id);
+	if ($IS_MYSQLND) {
+		if ($ret !== true){
+			printf("[002] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true));
+		}
+	} else {
+		/* libmysql return value seems to depend on server version */
+		if (($version >= 50123 || $version <= 40200) && $version != 50200) {
+			/* TODO: find exact version */
+			if ($ret !== true){
+				printf("[002] Expecting boolean/true got %s/%s @\n", gettype($ret), var_export($ret, true), $version);
+			}
+		} else {
+			if ($ret !== false){
+			printf("[002] Expecting boolean/false got %s/%s @\n", gettype($ret), var_export($ret, true), $version);
+			}
+		}
+	}
 
 	var_dump(mysqli_ping($mysql));
 
@@ -33,9 +68,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --EXPECT--
 bool(true)
-bool(true)
 bool(false)
 bool(true)
-bool(true)
 bool(false)
 done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/072.phpt b/ext/mysqli/tests/072.phpt
index 637014b..036253a 100644
--- a/ext/mysqli/tests/072.phpt
+++ b/ext/mysqli/tests/072.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
diff --git a/ext/mysqli/tests/073.phpt b/ext/mysqli/tests/073.phpt
index 7428bc3..c70f7d9 100644
--- a/ext/mysqli/tests/073.phpt
+++ b/ext/mysqli/tests/073.phpt
@@ -4,7 +4,7 @@ mysqli_driver properties
 <?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	var_dump($driver->embedded);
 	var_dump($driver->client_version);
diff --git a/ext/mysqli/tests/074.phpt b/ext/mysqli/tests/074.phpt
index 883655b..7d9d01b 100644
--- a/ext/mysqli/tests/074.phpt
+++ b/ext/mysqli/tests/074.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 --FILE--
 <?php
 
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
diff --git a/ext/mysqli/tests/bug28817.phpt b/ext/mysqli/tests/bug28817.phpt
index e5fa7d5..254c0e5 100644
--- a/ext/mysqli/tests/bug28817.phpt
+++ b/ext/mysqli/tests/bug28817.phpt
@@ -1,14 +1,14 @@
 --TEST--
 Bug #28817 (problems with properties declared in the class extending MySQLi)
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
-	
+	require_once("connect.inc");
+
 	class my_mysql extends mysqli {
 		public $p_test;
 
diff --git a/ext/mysqli/tests/bug29311.phpt b/ext/mysqli/tests/bug29311.phpt
index 83b1838..cd7b9ef 100644
--- a/ext/mysqli/tests/bug29311.phpt
+++ b/ext/mysqli/tests/bug29311.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	/* class 1 calls parent constructor */
 	class mysql1 extends mysqli {
diff --git a/ext/mysqli/tests/bug30967.phpt b/ext/mysqli/tests/bug30967.phpt
index 8051acb..48007ce 100644
--- a/ext/mysqli/tests/bug30967.phpt
+++ b/ext/mysqli/tests/bug30967.phpt
@@ -1,14 +1,14 @@
 --TEST--
 Bug #30967 (problems with properties declared in the class extending the class extending MySQLi)
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
-	
+	require_once("connect.inc");
+
 	class mysql1 extends mysqli {
 	}
 
diff --git a/ext/mysqli/tests/bug31668.phpt b/ext/mysqli/tests/bug31668.phpt
index cdca551..9b769a1 100644
--- a/ext/mysqli/tests/bug31668.phpt
+++ b/ext/mysqli/tests/bug31668.phpt
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 error_reporting = E_ALL & ~E_STRICT
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 	$mysql->multi_query('SELECT 1;SELECT 2');
diff --git a/ext/mysqli/tests/bug32405.phpt b/ext/mysqli/tests/bug32405.phpt
index 24bcdb4..0b3cad5 100644
--- a/ext/mysqli/tests/bug32405.phpt
+++ b/ext/mysqli/tests/bug32405.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include ("connect.inc");
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -33,7 +33,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/bug33263.phpt b/ext/mysqli/tests/bug33263.phpt
index 4f2a37c..ac2de19 100644
--- a/ext/mysqli/tests/bug33263.phpt
+++ b/ext/mysqli/tests/bug33263.phpt
@@ -8,8 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-
-	include "connect.inc";
+	require_once("connect.inc");
 
 	class test extends mysqli
 	{
diff --git a/ext/mysqli/tests/bug34810.phpt b/ext/mysqli/tests/bug34810.phpt
index fac8053..998d9f0 100644
--- a/ext/mysqli/tests/bug34810.phpt
+++ b/ext/mysqli/tests/bug34810.phpt
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
 
 class DbConnection {
 	public function connect() {
-		include "connect.inc";
+		require_once("connect.inc");
 
 		$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 		var_dump($link);
@@ -35,7 +35,7 @@ echo "Done\n";
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
@@ -55,7 +55,7 @@ object(mysqli)#%d (%d) {
   [%u|b%"connect_errno"]=>
   int(0)
   [%u|b%"connect_error"]=>
-  %unicode|string%(0) ""
+  NULL
   [%u|b%"errno"]=>
   int(0)
   [%u|b%"error"]=>
@@ -91,7 +91,7 @@ object(mysqli)#%d (%d) {
   [%u|b%"connect_errno"]=>
   int(0)
   [%u|b%"connect_error"]=>
-  %unicode|string%(0) ""
+  NULL
   [%u|b%"errno"]=>
   int(0)
   [%u|b%"error"]=>
diff --git a/ext/mysqli/tests/bug35103.phpt b/ext/mysqli/tests/bug35103.phpt
index 9c137b5..fc3cad0 100644
--- a/ext/mysqli/tests/bug35103.phpt
+++ b/ext/mysqli/tests/bug35103.phpt
@@ -12,7 +12,7 @@ $drop = <<<EOSQL
 DROP TABLE test_bint;
 DROP TABLE test_buint;
 EOSQL;
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 	$mysql->query("DROP TABLE IF EXISTS test_bint");
@@ -53,7 +53,7 @@ EOSQL;
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/bug35517.phpt b/ext/mysqli/tests/bug35517.phpt
index c769eed..746251f 100644
--- a/ext/mysqli/tests/bug35517.phpt
+++ b/ext/mysqli/tests/bug35517.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
@@ -39,7 +39,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/bug35759.phpt b/ext/mysqli/tests/bug35759.phpt
index 39b21c4..cbceb3b 100644
--- a/ext/mysqli/tests/bug35759.phpt
+++ b/ext/mysqli/tests/bug35759.phpt
@@ -14,7 +14,7 @@ CREATE TABLE blobby (
 
 
 EOSQL;
-	include "connect.inc";
+	require_once("connect.inc");
 	$col_num= 1000;
 
 	$mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
@@ -47,7 +47,7 @@ EOSQL;
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/bug36420.phpt b/ext/mysqli/tests/bug36420.phpt
index 54657a7..6dd03b3 100644
--- a/ext/mysqli/tests/bug36420.phpt
+++ b/ext/mysqli/tests/bug36420.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 --FILE--
 <?php
 
-include "connect.inc";
+require_once("connect.inc");
 $mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
 $result = $mysqli->query('select 1');
diff --git a/ext/mysqli/tests/bug36745.phpt b/ext/mysqli/tests/bug36745.phpt
index 511eaf3..5e203e1 100644
--- a/ext/mysqli/tests/bug36745.phpt
+++ b/ext/mysqli/tests/bug36745.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include ("connect.inc");
+	require_once("connect.inc");
 
 	/*** test mysqli_connect 127.0.0.1 ***/
 	$mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
@@ -23,7 +23,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/bug36802.phpt b/ext/mysqli/tests/bug36802.phpt
index d7144bd..3694a26 100644
--- a/ext/mysqli/tests/bug36802.phpt
+++ b/ext/mysqli/tests/bug36802.phpt
@@ -10,7 +10,7 @@ Bug #36802 (crashes with with mysqli_set_charset())
 		}
 	}
 
-	include "connect.inc";
+	require_once("connect.inc");
 	$mysql = mysqli_init();
 
 	/* following operations should not work */
diff --git a/ext/mysqli/tests/bug36949.phpt b/ext/mysqli/tests/bug36949.phpt
index 39909f9..2b3cc49 100644
--- a/ext/mysqli/tests/bug36949.phpt
+++ b/ext/mysqli/tests/bug36949.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 class A {
 
 	private $mysqli;
@@ -49,7 +49,7 @@ $B = new B();
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/bug37090.phpt b/ext/mysqli/tests/bug37090.phpt
index 7e8b493..839081d 100644
--- a/ext/mysqli/tests/bug37090.phpt
+++ b/ext/mysqli/tests/bug37090.phpt
@@ -13,7 +13,7 @@ if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1)) {
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
diff --git a/ext/mysqli/tests/bug38710.phpt b/ext/mysqli/tests/bug38710.phpt
index 280a51a..c3bb728 100755
--- a/ext/mysqli/tests/bug38710.phpt
+++ b/ext/mysqli/tests/bug38710.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 
 $db = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 $qry=$db->stmt_init();
diff --git a/ext/mysqli/tests/bug39457.phpt b/ext/mysqli/tests/bug39457.phpt
index b834ff1..ec9239b 100644
--- a/ext/mysqli/tests/bug39457.phpt
+++ b/ext/mysqli/tests/bug39457.phpt
@@ -1,13 +1,13 @@
 --TEST--
 Bug #39457 (Multiple invoked OO connections never close)
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysql = mysqli_init();
 	$mysql->connect($host, $user, $passwd, $db, $port, $socket);
diff --git a/ext/mysqli/tests/bug42548.phpt b/ext/mysqli/tests/bug42548.phpt
index c9950be..ef0c831 100644
--- a/ext/mysqli/tests/bug42548.phpt
+++ b/ext/mysqli/tests/bug42548.phpt
@@ -52,7 +52,7 @@ print "done!";
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/bug44897.phpt b/ext/mysqli/tests/bug44897.phpt
index 92fc0a2..84c245d 100644
--- a/ext/mysqli/tests/bug44897.phpt
+++ b/ext/mysqli/tests/bug44897.phpt
@@ -19,7 +19,6 @@ if (mysqli_get_server_version($link) <= 50000) {
 ?>
 --FILE--
 <?php
-	require_once("connect.inc");
 	require_once("table.inc");
 
 	if (!$link->query('DROP PROCEDURE IF EXISTS p'))
@@ -74,7 +73,7 @@ if (mysqli_get_server_version($link) <= 50000) {
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/bug46109.phpt b/ext/mysqli/tests/bug46109.phpt
index bbb2903..c377171 100644
--- a/ext/mysqli/tests/bug46109.phpt
+++ b/ext/mysqli/tests/bug46109.phpt
@@ -1,18 +1,18 @@
 --TEST--
 Bug #46109 (MySQLi::init - Memory leaks)
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysqli = new mysqli();
 	$mysqli->init();
 	$mysqli->init();
-	echo "done";	
+	echo "done";
 ?>
 --EXPECTF--
 done
diff --git a/ext/mysqli/tests/bug48909.phpt b/ext/mysqli/tests/bug48909.phpt
index 55c85a6..81df544 100644
--- a/ext/mysqli/tests/bug48909.phpt
+++ b/ext/mysqli/tests/bug48909.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	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",
diff --git a/ext/mysqli/tests/bug50772.phpt b/ext/mysqli/tests/bug50772.phpt
new file mode 100644
index 0000000..4724d0f
--- /dev/null
+++ b/ext/mysqli/tests/bug50772.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Bug #50772 (mysqli constructor without parameters does not return a working mysqli object)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+	include "connect.inc";
+	$db1 = new mysqli();
+
+	// These calls fail
+	$db1->options(MYSQLI_OPT_CONNECT_TIMEOUT, 3);
+	$db1->real_connect($host, $user, $passwd);
+	if(mysqli_connect_error()) {
+		echo "error 1\n";
+	} else {
+		echo "ok 1\n";
+	}
+
+	$db2 = mysqli_init();
+
+	$db2->options(MYSQLI_OPT_CONNECT_TIMEOUT, 3);
+	$db2->real_connect($host, $user, $passwd);
+	if(mysqli_connect_error()) {
+		echo "error 2\n";
+	} else {
+		echo "ok 2\n";
+	}
+	echo "done\n";
+?>
+--EXPECTF--
+ok 1
+ok 2
+done
\ No newline at end of file
diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc
index ad24286..48ba893 100644
--- a/ext/mysqli/tests/connect.inc
+++ b/ext/mysqli/tests/connect.inc
@@ -74,53 +74,58 @@
 		}
 	}
 
-	/**
-	* Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
-	*
-	* @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)?
-	*/
-	function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
-		global $connect_flags;
+	if (!function_exists('my_mysqli_connect')) {
 
-		$flags = ($enable_env_flags) ? $connect_flags : false;
+		/**
+		* Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
+		*
+		* @param enable_env_flags Enable setting of connection flags through 	env(MYSQL_TEST_CONNECT_FLAGS)?
+		*/
+		function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+			global $connect_flags;
 
-		if ($flags !== false) {
-			$link = mysqli_init();
-			if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags))
-				$link = false;
-		} else {
-			$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
-		}
+			$flags = ($enable_env_flags) ? $connect_flags : false;
 
-		return $link;
-	}
+			if ($flags !== false) {
+				$link = mysqli_init();
+				if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags))
+					$link = false;
+			} else {
+				$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+			}
 
-	/**
-	* Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
-	*
-	* @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)
-	*/
-	function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) {
-		global $connect_flags;
+			return $link;
+		}
 
-		if ($enable_env_flags)
-			$flags & $connect_flags;
+		/**
+		* Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
+		*
+		* @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)
+		*/
+		function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) {
+			global $connect_flags;
 
-		return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags);
-	}
+			if ($enable_env_flags)
+				$flags & $connect_flags;
 
-	class my_mysqli extends mysqli {
-		public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
-			global $connect_flags;
+			return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags);
+		}
 
-			$flags = ($enable_env_flags) ? $connect_flags : false;
+		class my_mysqli extends mysqli {
+			public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+				global $connect_flags;
 
-			if ($flags !== false) {
-				parent::init();
-				$this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags);
-			} else {
-				parent::__construct($host, $user, $passwd, $db, $port, $socket);
+				$flags = ($enable_env_flags) ? $connect_flags : false;
+
+				if ($flags !== false) {
+					parent::init();
+					$this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags);
+				} else {
+					parent::__construct($host, $user, $passwd, $db, $port, $socket);
+				}
 			}
 		}
+	} else {
+		printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n");
 	}
 ?>
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_affected_rows.phpt b/ext/mysqli/tests/mysqli_affected_rows.phpt
index 6cb5451..958b83c 100644
--- a/ext/mysqli/tests/mysqli_affected_rows.phpt
+++ b/ext/mysqli/tests/mysqli_affected_rows.phpt
@@ -8,7 +8,7 @@ mysqli_affected_rows()
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_affected_rows_oo.phpt b/ext/mysqli/tests/mysqli_affected_rows_oo.phpt
index 07b7bcb..6da026b 100644
--- a/ext/mysqli/tests/mysqli_affected_rows_oo.phpt
+++ b/ext/mysqli/tests/mysqli_affected_rows_oo.phpt
@@ -8,7 +8,7 @@ mysqli->affected_rows
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$mysqli = new mysqli();
 	if (NULL !== ($tmp = @$mysqli->affected_rows))
diff --git a/ext/mysqli/tests/mysqli_autocommit.phpt b/ext/mysqli/tests/mysqli_autocommit.phpt
index cdd5559..f1f63e7 100644
--- a/ext/mysqli/tests/mysqli_autocommit.phpt
+++ b/ext/mysqli/tests/mysqli_autocommit.phpt
@@ -26,7 +26,7 @@ mysqli_autocommit()
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_autocommit_oo.phpt b/ext/mysqli/tests/mysqli_autocommit_oo.phpt
index 8f2c4b4..b1777b9 100644
--- a/ext/mysqli/tests/mysqli_autocommit_oo.phpt
+++ b/ext/mysqli/tests/mysqli_autocommit_oo.phpt
@@ -29,7 +29,7 @@ mysqli->autocommit()
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!$mysqli = new my_mysqli($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",
diff --git a/ext/mysqli/tests/mysqli_change_user.phpt b/ext/mysqli/tests/mysqli_change_user.phpt
index d889ec8..b699229 100644
--- a/ext/mysqli/tests/mysqli_change_user.phpt
+++ b/ext/mysqli/tests/mysqli_change_user.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp	= NULL;
 	$link	= NULL;
diff --git a/ext/mysqli/tests/mysqli_change_user_insert_id.phpt b/ext/mysqli/tests/mysqli_change_user_insert_id.phpt
index 83efb51..30ea541 100644
--- a/ext/mysqli/tests/mysqli_change_user_insert_id.phpt
+++ b/ext/mysqli/tests/mysqli_change_user_insert_id.phpt
@@ -6,13 +6,16 @@ require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 require_once('connect.inc');
+
 if (!$IS_MYSQLND) {
 	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 		die("skip Can't test server version, might hit known bugs http://bugs.mysql.com/bug.php?id=30472, http://bugs.mysql.com/bug.php?id=45184");
-	if (mysqli_get_client_version($link) <= 50135)
-		/* TODO - check wich version got the patch */
+
+	if ((mysqli_get_client_version($link) <= 50139) || (mysqli_get_server_version($link) <= 50139))
+		/* #30472 got fixed in 5.1.23 but #45184 is open */
 		die(sprintf("skip libmysql %s should have bugs http://bugs.mysql.com/bug.php?id=30472, http://bugs.mysql.com/bug.php?id=45184",
 	 mysqli_get_client_version($link)));
+
 	mysqli_close($link);
 }
 ?>
diff --git a/ext/mysqli/tests/mysqli_change_user_rollback.phpt b/ext/mysqli/tests/mysqli_change_user_rollback.phpt
index a57f80b..97c2bd8 100644
--- a/ext/mysqli/tests/mysqli_change_user_rollback.phpt
+++ b/ext/mysqli/tests/mysqli_change_user_rollback.phpt
@@ -12,8 +12,9 @@ $row = mysqli_fetch_row($result);
 mysqli_free_result($result);
 mysqli_close($link);
 
-if ($row[1] == 'NO') {
-	printf ("skip ROLLBACK requires transactional engine InnoDB");
+if ($row[1] == "DISABLED" || $row[1] == "NO") {
+	printf ("skip innodb support is not installed or enabled.");
+	exit;
 }
 ?>
 --FILE--
diff --git a/ext/mysqli/tests/mysqli_character_set.phpt b/ext/mysqli/tests/mysqli_character_set.phpt
index 11c92ce..1fced9a 100644
--- a/ext/mysqli/tests/mysqli_character_set.phpt
+++ b/ext/mysqli/tests/mysqli_character_set.phpt
@@ -16,7 +16,7 @@ if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp	= NULL;
 	$link	= NULL;
diff --git a/ext/mysqli/tests/mysqli_character_set_name.phpt b/ext/mysqli/tests/mysqli_character_set_name.phpt
index 9a40099..3fa997b 100644
--- a/ext/mysqli/tests/mysqli_character_set_name.phpt
+++ b/ext/mysqli/tests/mysqli_character_set_name.phpt
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 --FILE--
 <?php
 	/* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_character_set_name_oo.phpt b/ext/mysqli/tests/mysqli_character_set_name_oo.phpt
index a56cf6a..43a83bb 100644
--- a/ext/mysqli/tests/mysqli_character_set_name_oo.phpt
+++ b/ext/mysqli/tests/mysqli_character_set_name_oo.phpt
@@ -9,7 +9,7 @@ mysqli_chararcter_set_name(), mysql_client_encoding() [alias]
 --FILE--
 <?php
 	/* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp	= NULL;
 	$link	= NULL;
diff --git a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt
index ad914b7..b86f69c 100644
--- a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt
+++ b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt
@@ -276,6 +276,6 @@ setting mysqli->unknown, mysqli_unknown = '13'
 setting mysqli->unknown, mysqli_unknown = 'friday'
 
 Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
-mysqli->connect_error = ''/%unicode|string% (''/%unicode|string%)
+mysqli->connect_error = ''/NULL (''/NULL)
 mysqli->connect_errno = '0'/integer ('0'/integer)
 done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_class_mysqli_properties_no_conn.phpt b/ext/mysqli/tests/mysqli_class_mysqli_properties_no_conn.phpt
new file mode 100644
index 0000000..d0940a7
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_class_mysqli_properties_no_conn.phpt
@@ -0,0 +1,282 @@
+--TEST--
+Interface of the class mysqli
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+	require('table.inc');
+
+	function dump_properties($mysqli) {
+
+		printf("\nClass variables:\n");
+		$variables = array_keys(get_class_vars(get_class($mysqli)));
+		sort($variables);
+		foreach ($variables as $k => $var) {
+			printf("%s = '%s'\n", $var, var_export(@$mysqli->$var, true));
+		}
+
+		printf("\nObject variables:\n");
+		$variables = array_keys(get_object_vars($mysqli));
+		foreach ($variables as $k => $var) {
+			printf("%s = '%s'\n", $var, var_export(@$mysqli->$var, true));
+		}
+
+		printf("\nMagic, magic properties:\n");
+
+		assert(@mysqli_affected_rows($mysqli) === @$mysqli->affected_rows);
+		printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->affected_rows, gettype(@$mysqli->affected_rows),
+			@mysqli_affected_rows($mysqli), gettype(@mysqli_affected_rows($mysqli)));
+
+		assert(@mysqli_get_client_info() === @$mysqli->client_info);
+		printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->client_info, gettype(@$mysqli->client_info),
+			@mysqli_get_client_info(), gettype(@mysqli_get_client_info()));
+
+		assert(@mysqli_get_client_version() === @$mysqli->client_version);
+		printf("mysqli->client_version =  '%s'/%s ('%s'/%s)\n",
+			@$mysqli->client_version, gettype(@$mysqli->client_version),
+			@mysqli_get_client_version(), gettype(@mysqli_get_client_version()));
+
+		assert(@mysqli_errno($mysqli) === @$mysqli->errno);
+		printf("mysqli->errno = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->errno, gettype(@$mysqli->errno),
+
+			@mysqli_errno($mysqli), gettype(@mysqli_errno($mysqli)));
+
+		assert(@mysqli_error($mysqli) === @$mysqli->error);
+		printf("mysqli->error = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->error, gettype(@$mysqli->error),
+			@mysqli_error($mysqli), gettype(@mysqli_error($mysqli)));
+
+		assert(@mysqli_field_count($mysqli) === @$mysqli->field_count);
+		printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->field_count, gettype(@$mysqli->field_count),
+			@mysqli_field_count($mysqli), gettype(@mysqli_field_count($mysqli)));
+
+		assert(@mysqli_insert_id($mysqli) === @$mysqli->insert_id);
+		printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->insert_id, gettype(@$mysqli->insert_id),
+			@mysqli_insert_id($mysqli), gettype(@mysqli_insert_id($mysqli)));
+
+		assert(@mysqli_sqlstate($mysqli) === @$mysqli->sqlstate);
+		printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->sqlstate, gettype(@$mysqli->sqlstate),
+			@mysqli_sqlstate($mysqli), gettype(@mysqli_sqlstate($mysqli)));
+
+		assert(@mysqli_get_host_info($mysqli) === @$mysqli->host_info);
+		printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->host_info, gettype(@$mysqli->host_info),
+			@mysqli_get_host_info($mysqli), gettype(@mysqli_get_host_info($mysqli)));
+
+		/* note that the data types are different */
+		assert(@mysqli_info($mysqli) == @$mysqli->info);
+		printf("mysqli->info = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->info, gettype(@$mysqli->info),
+			@mysqli_info($mysqli), gettype(@mysqli_info($mysqli)));
+
+		assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id);
+		assert(gettype(@$mysqli->thread_id) == gettype(@mysqli_thread_id($mysqli)));
+		printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->thread_id, gettype(@$mysqli->thread_id),
+			@mysqli_thread_id($mysqli), gettype(@mysqli_thread_id($mysqli)));
+
+		assert(@mysqli_get_proto_info($mysqli) === @$mysqli->protocol_version);
+		printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->protocol_version, gettype(@$mysqli->protocol_version),
+			@mysqli_get_proto_info($mysqli), gettype(@mysqli_get_proto_info($mysqli)));
+
+		assert(@mysqli_get_server_info($mysqli) === @$mysqli->server_info);
+		printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->server_info, gettype(@$mysqli->server_info),
+			@mysqli_get_server_info($mysqli), gettype(@mysqli_get_server_info($mysqli)));
+
+		assert(@mysqli_get_server_version($mysqli) === @$mysqli->server_version);
+		printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->server_version, gettype(@$mysqli->server_version),
+			@mysqli_get_server_version($mysqli), gettype(@mysqli_get_server_version($mysqli)));
+
+		assert(@mysqli_warning_count($mysqli) === @$mysqli->warning_count);
+		printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->warning_count, gettype(@$mysqli->warning_count),
+			@mysqli_warning_count($mysqli), gettype(@mysqli_warning_count($mysqli)));
+
+		printf("\nAccess to undefined properties:\n");
+		printf("mysqli->unknown = '%s'\n", @$mysqli->unknown);
+
+		@$mysqli->unknown = 13;
+		printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
+
+		$unknown = 'friday';
+		@$mysqli->unknown = $unknown;
+		printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
+
+		printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n");
+		assert(@mysqli_connect_error() === @$mysqli->connect_error);
+		printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->connect_error, gettype(@$mysqli->connect_error),
+			@mysqli_connect_error(), gettype(@mysqli_connect_error()));
+
+		assert(@mysqli_connect_errno() === @$mysqli->connect_errno);
+		printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n",
+			@$mysqli->connect_errno, gettype(@$mysqli->connect_errno),
+			@mysqli_connect_errno(), gettype(@mysqli_connect_errno()));
+	}
+
+	printf("Without RS\n");
+	$mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket);
+	dump_properties($mysqli);
+
+	printf("With RS\n");
+	$mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket);
+	$res = @$mysqli->query("SELECT * FROM test");
+	dump_properties($mysqli);
+
+	print "done!";
+?>
+--CLEAN--
+<?php require_once("clean_table.inc"); ?>
+--EXPECTF--
+Without RS
+
+Class variables:
+affected_rows = 'NULL'
+client_info = 'NULL'
+client_version = '%s'
+connect_errno = '%s'
+connect_error = ''%s'
+errno = 'NULL'
+error = 'NULL'
+field_count = 'NULL'
+host_info = 'NULL'
+info = 'NULL'
+insert_id = 'NULL'
+protocol_version = 'NULL'
+server_info = 'NULL'
+server_version = 'NULL'
+sqlstate = 'NULL'
+thread_id = 'NULL'
+warning_count = 'NULL'
+
+Object variables:
+affected_rows = 'NULL'
+client_info = 'NULL'
+client_version = '%s'
+connect_errno = '%s'
+connect_error = '%s'
+errno = 'NULL'
+error = 'NULL'
+field_count = 'NULL'
+host_info = 'NULL'
+info = 'NULL'
+insert_id = 'NULL'
+server_info = 'NULL'
+server_version = 'NULL'
+sqlstate = 'NULL'
+protocol_version = 'NULL'
+thread_id = 'NULL'
+warning_count = 'NULL'
+
+Magic, magic properties:
+mysqli->affected_rows = ''/NULL (''/NULL)
+
+Warning: assert(): Assertion failed in %s on line %d
+mysqli->client_info = ''/NULL ('%s'/%s)
+mysqli->client_version =  '%s'/integer ('%s'/integer)
+mysqli->errno = ''/NULL (''/NULL)
+mysqli->error = ''/NULL (''/NULL)
+mysqli->field_count = ''/NULL (''/NULL)
+mysqli->insert_id = ''/NULL (''/NULL)
+mysqli->sqlstate = ''/NULL (''/NULL)
+mysqli->host_info = ''/NULL (''/NULL)
+mysqli->info = ''/NULL (''/NULL)
+
+Warning: assert(): Assertion failed in %s on line %d
+mysqli->thread_id = ''/NULL (''/NULL)
+mysqli->protocol_version = ''/NULL (''/NULL)
+mysqli->server_info = ''/NULL (''/NULL)
+mysqli->server_version = ''/NULL (''/NULL)
+mysqli->warning_count = ''/NULL (''/NULL)
+
+Access to undefined properties:
+mysqli->unknown = ''
+setting mysqli->unknown, @mysqli_unknown = '13'
+setting mysqli->unknown, @mysqli_unknown = 'friday'
+
+Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
+mysqli->connect_error = '%s'/%s)
+mysqli->connect_errno = '%s'/integer ('%s'/integer)
+With RS
+
+Class variables:
+affected_rows = 'NULL'
+client_info = 'NULL'
+client_version = '%s'
+connect_errno = '%s'
+connect_error = '%s'
+errno = 'NULL'
+error = 'NULL'
+field_count = 'NULL'
+host_info = 'NULL'
+info = 'NULL'
+insert_id = 'NULL'
+protocol_version = 'NULL'
+server_info = 'NULL'
+server_version = 'NULL'
+sqlstate = 'NULL'
+thread_id = 'NULL'
+warning_count = 'NULL'
+
+Object variables:
+affected_rows = 'NULL'
+client_info = 'NULL'
+client_version = '%s'
+connect_errno = '%s'
+connect_error = '%s'
+errno = 'NULL'
+error = 'NULL'
+field_count = 'NULL'
+host_info = 'NULL'
+info = 'NULL'
+insert_id = 'NULL'
+server_info = 'NULL'
+server_version = 'NULL'
+sqlstate = 'NULL'
+protocol_version = 'NULL'
+thread_id = 'NULL'
+warning_count = 'NULL'
+
+Magic, magic properties:
+mysqli->affected_rows = ''/NULL (''/NULL)
+
+Warning: assert(): Assertion failed in %s on line %d
+mysqli->client_info = ''/NULL ('%s'/%s)
+mysqli->client_version =  '%s'/integer ('%s'/integer)
+mysqli->errno = ''/NULL (''/NULL)
+mysqli->error = ''/NULL (''/NULL)
+mysqli->field_count = ''/NULL (''/NULL)
+mysqli->insert_id = ''/NULL (''/NULL)
+mysqli->sqlstate = ''/NULL (''/NULL)
+mysqli->host_info = ''/NULL (''/NULL)
+mysqli->info = ''/NULL (''/NULL)
+
+Warning: assert(): Assertion failed in %s on line %d
+mysqli->thread_id = ''/NULL (''/NULL)
+mysqli->protocol_version = ''/NULL (''/NULL)
+mysqli->server_info = ''/NULL (''/NULL)
+mysqli->server_version = ''/NULL (''/NULL)
+mysqli->warning_count = ''/NULL (''/NULL)
+
+Access to undefined properties:
+mysqli->unknown = ''
+setting mysqli->unknown, @mysqli_unknown = '13'
+setting mysqli->unknown, @mysqli_unknown = 'friday'
+
+Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
+mysqli->connect_error = '%s'/%s)
+mysqli->connect_errno = '%s'/integer ('%s'/integer)
+done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_close.phpt b/ext/mysqli/tests/mysqli_close.phpt
index 713c6e1..c6ac92d 100644
--- a/ext/mysqli/tests/mysqli_close.phpt
+++ b/ext/mysqli/tests/mysqli_close.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_close_oo.phpt b/ext/mysqli/tests/mysqli_close_oo.phpt
index c3d6a93..be67f77 100644
--- a/ext/mysqli/tests/mysqli_close_oo.phpt
+++ b/ext/mysqli/tests/mysqli_close_oo.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_commit.phpt b/ext/mysqli/tests/mysqli_commit.phpt
index 6a3c1e8..66113b3 100644
--- a/ext/mysqli/tests/mysqli_commit.phpt
+++ b/ext/mysqli/tests/mysqli_commit.phpt
@@ -25,7 +25,7 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_commit_oo.phpt b/ext/mysqli/tests/mysqli_commit_oo.phpt
index 8d07299..fee7967 100644
--- a/ext/mysqli/tests/mysqli_commit_oo.phpt
+++ b/ext/mysqli/tests/mysqli_commit_oo.phpt
@@ -24,7 +24,7 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_connect.phpt b/ext/mysqli/tests/mysqli_connect.phpt
index dd2792f..cf7c7be 100644
--- a/ext/mysqli/tests/mysqli_connect.phpt
+++ b/ext/mysqli/tests/mysqli_connect.phpt
@@ -5,7 +5,7 @@ mysqli_connect()
 <?php require_once('skipifemb.inc'); ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_connect_errno.phpt b/ext/mysqli/tests/mysqli_connect_errno.phpt
index b48a75e..a7f90f1 100644
--- a/ext/mysqli/tests/mysqli_connect_errno.phpt
+++ b/ext/mysqli/tests/mysqli_connect_errno.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_connect_error.phpt b/ext/mysqli/tests/mysqli_connect_error.phpt
index e65dc0e..79ac3f1 100644
--- a/ext/mysqli/tests/mysqli_connect_error.phpt
+++ b/ext/mysqli/tests/mysqli_connect_error.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
@@ -21,8 +21,8 @@ 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 ('' !== ($tmp = mysqli_connect_error()))
-		printf("[003] Expecting string/'', got %s/%s\n", gettype($tmp), $tmp);
+	if (NULL !== ($tmp = mysqli_connect_error()))
+		printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	mysqli_close($link);
 
diff --git a/ext/mysqli/tests/mysqli_connect_oo.phpt b/ext/mysqli/tests/mysqli_connect_oo.phpt
index 63660fd..d406e24 100644
--- a/ext/mysqli/tests/mysqli_connect_oo.phpt
+++ b/ext/mysqli/tests/mysqli_connect_oo.phpt
@@ -5,7 +5,7 @@ new mysqli()
 <?php require_once('skipifemb.inc'); ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt b/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt
index ec5d101..2636abd 100644
--- a/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt
+++ b/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt
@@ -5,11 +5,15 @@ new mysqli()
 <?php require_once('skipifemb.inc'); ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
-	ini_set('mysqli.default_socket', 'socket');
+
+	if ($socket != "")
+		/* mysqli.default_socket requires non-empty string */
+		ini_set('mysqli.default_socket', 'socket');
+
 	ini_set('mysqli.default_port', 9999);
 	ini_set('mysqli.default_pw', 'password');
 	ini_set('mysqli.default_user', 'user');
@@ -18,21 +22,28 @@ new mysqli()
 	mysqli_report(MYSQLI_REPORT_OFF);
 	mysqli_report(MYSQLI_REPORT_STRICT);
 
-	ini_set('mysqli.default_socket', $socket);
-	try {
-		$mysqli = mysqli_init();
-		$mysqli->real_connect($host, $user, $passwd, $db, $port);
+	if ($socket != "") {
+		ini_set('mysqli.default_socket', $socket);
+		try {
+			$mysqli = mysqli_init();
+			$mysqli->real_connect($host, $user, $passwd, $db, $port);
 
-		if (!$res = $mysqli->query("SELECT 'mysqli.default_socket' AS testing"))
-			printf("[001] [%d] %s\n", $mysqli->errno, $mysqli->error);
-		var_dump($res->fetch_assoc());
-		$res->free_result();
+			if (!$res = $mysqli->query("SELECT 'mysqli.default_socket' AS testing"))
+				printf("[001] [%d] %s\n", $mysqli->errno, $mysqli->error);
+			$tmp = $res->fetch_assoc();
+			$res->free_result();
 
-		$mysqli->close();
+			if (!isset($tmp['testing']) || $tmp['testing'] != $socket) {
+				printf("[002] mysqli.default_socket not properly set?\n");
+				var_dump($tmp);
+			}
 
-	} catch (mysqli_sql_exception $e) {
-		printf("%s\n", $e->getMessage());
-		printf("[002] Usage of mysqli.default_socket failed\n");
+			$mysqli->close();
+
+		} catch (mysqli_sql_exception $e) {
+			printf("%s\n", $e->getMessage());
+			printf("[002] Usage of mysqli.default_socket failed\n");
+		}
 	}
 
 	ini_set('mysqli.default_port', $port);
@@ -145,10 +156,6 @@ new mysqli()
 --EXPECTF--
 array(1) {
   [%u|b%"testing"]=>
-  %unicode|string%(21) "mysqli.default_socket"
-}
-array(1) {
-  [%u|b%"testing"]=>
   %unicode|string%(19) "mysqli.default_port"
 }
 array(1) {
diff --git a/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt b/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt
index 1c2defc..5ede445 100644
--- a/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt
+++ b/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt
@@ -12,7 +12,7 @@ new mysqli()
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$myhost = 'invalidhost';
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_connect_twice.phpt b/ext/mysqli/tests/mysqli_connect_twice.phpt
index 7c6a726..a9d5b7e 100644
--- a/ext/mysqli/tests/mysqli_connect_twice.phpt
+++ b/ext/mysqli/tests/mysqli_connect_twice.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	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",
diff --git a/ext/mysqli/tests/mysqli_constants.phpt b/ext/mysqli/tests/mysqli_constants.phpt
index 23f5772..32a2593 100644
--- a/ext/mysqli/tests/mysqli_constants.phpt
+++ b/ext/mysqli/tests/mysqli_constants.phpt
@@ -117,7 +117,9 @@ require_once('skipifconnectfailure.inc');
 	if (($version > 51122 && $version < 60000) || ($version > 60003) || $IS_MYSQLND) {
 		$expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true;
 	}
-	if ($version > 60005 || $IS_MYSQLND) {
+
+	/* First introduced in MySQL 6.0, backported to MySQL 5.5 */
+	if ($version >= 50500 || $IS_MYSQLND) {
 		$expected_constants['MYSQLI_SERVER_QUERY_WAS_SLOW'] = true;
 	}
 
diff --git a/ext/mysqli/tests/mysqli_data_seek.phpt b/ext/mysqli/tests/mysqli_data_seek.phpt
index cb54c80..9e2d650 100644
--- a/ext/mysqli/tests/mysqli_data_seek.phpt
+++ b/ext/mysqli/tests/mysqli_data_seek.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_data_seek_oo.phpt b/ext/mysqli/tests/mysqli_data_seek_oo.phpt
index e75a04f..0858218 100644
--- a/ext/mysqli/tests/mysqli_data_seek_oo.phpt
+++ b/ext/mysqli/tests/mysqli_data_seek_oo.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt b/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt
index 79f081f..9814c6e 100644
--- a/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt
+++ b/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt
@@ -12,7 +12,7 @@ if (!function_exists('mysqli_disable_reads_from_master')) {
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_driver.phpt b/ext/mysqli/tests/mysqli_driver.phpt
index a2d1437..4e266a0 100644
--- a/ext/mysqli/tests/mysqli_driver.phpt
+++ b/ext/mysqli/tests/mysqli_driver.phpt
@@ -8,8 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
-	include "table.inc";
+	require("table.inc");
 
 	if (!is_object($driver = new mysqli_driver()))
 		printf("[001] Failed to create mysqli_driver object\n");
diff --git a/ext/mysqli/tests/mysqli_dump_debug_info.phpt b/ext/mysqli/tests/mysqli_dump_debug_info.phpt
index fe253e1..bd87ddf 100644
--- a/ext/mysqli/tests/mysqli_dump_debug_info.phpt
+++ b/ext/mysqli/tests/mysqli_dump_debug_info.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp	= NULL;
 	$link	= NULL;
diff --git a/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt b/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt
index 1d334f9..82edef5 100644
--- a/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt
+++ b/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp	= NULL;
 	$link	= NULL;
diff --git a/ext/mysqli/tests/mysqli_embedded_connect.phpt b/ext/mysqli/tests/mysqli_embedded_connect.phpt
index 5ee5fa7..37891f5 100644
--- a/ext/mysqli/tests/mysqli_embedded_connect.phpt
+++ b/ext/mysqli/tests/mysqli_embedded_connect.phpt
@@ -1,14 +1,14 @@
 --TEST--
 mysqli_embedded_connect()
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifnotemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 	$tmp    = NULL;
 	$link   = NULL;
 
diff --git a/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt b/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt
index 171ed56..e23ddd1 100644
--- a/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt
+++ b/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt
@@ -12,7 +12,7 @@ if (!function_exists('mysqli_enable_reads_from_master')) {
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_errno.phpt b/ext/mysqli/tests/mysqli_errno.phpt
index 48acbb6..0e9f049 100644
--- a/ext/mysqli/tests/mysqli_errno.phpt
+++ b/ext/mysqli/tests/mysqli_errno.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_errno_oo.phpt b/ext/mysqli/tests/mysqli_errno_oo.phpt
index 032f70a..bef4a60 100644
--- a/ext/mysqli/tests/mysqli_errno_oo.phpt
+++ b/ext/mysqli/tests/mysqli_errno_oo.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_error.phpt b/ext/mysqli/tests/mysqli_error.phpt
index 5173880..5e70d59 100644
--- a/ext/mysqli/tests/mysqli_error.phpt
+++ b/ext/mysqli/tests/mysqli_error.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_error_oo.phpt b/ext/mysqli/tests/mysqli_error_oo.phpt
index 456f8f9..31716d9 100644
--- a/ext/mysqli/tests/mysqli_error_oo.phpt
+++ b/ext/mysqli/tests/mysqli_error_oo.phpt
@@ -1,14 +1,14 @@
 --TEST--
 $mysqli->error
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_error_unicode.phpt b/ext/mysqli/tests/mysqli_error_unicode.phpt
index 8789f89..b59ed5f 100644
--- a/ext/mysqli/tests/mysqli_error_unicode.phpt
+++ b/ext/mysqli/tests/mysqli_error_unicode.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp	= NULL;
 	$link	= NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_all.phpt b/ext/mysqli/tests/mysqli_fetch_all.phpt
index 26401e7..eacecc9 100644
--- a/ext/mysqli/tests/mysqli_fetch_all.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_all.phpt
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_fetch_all'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_all_oo.phpt b/ext/mysqli/tests/mysqli_fetch_all_oo.phpt
index 297d92a..a71eb2b 100644
--- a/ext/mysqli/tests/mysqli_fetch_all_oo.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_all_oo.phpt
@@ -11,7 +11,7 @@ if (!function_exists('mysqli_fetch_all'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_array.phpt b/ext/mysqli/tests/mysqli_fetch_array.phpt
index f43804d..cff3141 100644
--- a/ext/mysqli/tests/mysqli_fetch_array.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_array.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 	$tmp    = NULL;
 	$link   = NULL;
 
diff --git a/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt b/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt
index d85eb9e..957ca12 100644
--- a/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt
@@ -8,7 +8,6 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 5")) {
diff --git a/ext/mysqli/tests/mysqli_fetch_array_large.phpt b/ext/mysqli/tests/mysqli_fetch_array_large.phpt
index aa8c768..25c00ba 100644
--- a/ext/mysqli/tests/mysqli_fetch_array_large.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_array_large.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	function mysqli_fetch_array_large($offset, $link, $package_size) {
 
@@ -19,53 +19,57 @@ require_once('skipifconnectfailure.inc');
 			$sql .= sprintf("('%s'), ", $random_char);
 
 		$sql = substr($sql, 0, -2);
-		assert(strlen($sql) < $package_size);
+		$len = strlen($sql);
+		assert($len < $package_size);
 
 		if (!@mysqli_query($link, $sql)) {
-			if (1153 == mysqli_errno($link) || stristr(mysqli_error($link), 'max_allowed_packet'))
-				/* [1153] Got a packet bigger than 'max_allowed_packet' bytes */
+			if (1153 == mysqli_errno($link) || 2006 == mysqli_errno($link) || stristr(mysqli_error($link), 'max_allowed_packet'))
+				/*
+					myslqnd - [1153] Got a packet bigger than 'max_allowed_packet' bytes
+					libmysql -[2006] MySQL server has gone away
+				*/
 				return false;
 
-			printf("[%03d + 1] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+			printf("[%03d + 1] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
 			return false;
 		}
 
 		/* buffered result set - let's hope we do not run into PHP memory limit... */
 		if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
-			printf("[%03d + 2] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+			printf("[%03d + 2] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
 			return false;
 		}
 
 		while ($row = mysqli_fetch_assoc($res)) {
 			if ($row['label'] != $random_char) {
-				printf("[%03d + 3] Wrong results - expecting '%s' got '%s', [%d] %s\n",
-					$offset, $random_char, $row['label'], mysqli_errno($link), mysqli_error($link));
+				printf("[%03d + 3] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n",
+					$offset, $random_char, $row['label'], $len, mysqli_errno($link), mysqli_error($link));
 				return false;
 			}
 		}
 		mysqli_free_result($res);
 
 		if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test")) {
-			printf("[%03d + 4] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+			printf("[%03d + 4] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
 			return false;
 		}
 
 		/* unbuffered result set */
 		if (!mysqli_stmt_execute($stmt)) {
-			printf("[%03d + 5] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+			printf("[%03d + 5] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
 			return false;
 		}
 
 		$id = $label = NULL;
 		if (!mysqli_stmt_bind_result($stmt, $id, $label)) {
-			printf("[%03d + 6] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+			printf("[%03d + 6] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
 			return false;
 		}
 
 		while (mysqli_stmt_fetch($stmt)) {
 			if ($label != $random_char) {
-				printf("[%03d + 7] Wrong results - expecting '%s' got '%s', [%d] %s\n",
-					$offset, $random_char, $label, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+				printf("[%03d + 7] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n",
+					$offset, $random_char, $label, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
 				return false;
 			}
 		}
diff --git a/ext/mysqli/tests/mysqli_fetch_array_many_rows.phpt b/ext/mysqli/tests/mysqli_fetch_array_many_rows.phpt
index c9ed7cc..82e4d7b 100644
--- a/ext/mysqli/tests/mysqli_fetch_array_many_rows.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_array_many_rows.phpt
@@ -8,7 +8,6 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require("table.inc");
 
 	// do as much as we can do in 5 seconds
diff --git a/ext/mysqli/tests/mysqli_fetch_array_oo.phpt b/ext/mysqli/tests/mysqli_fetch_array_oo.phpt
index fcabb59..78c2130 100644
--- a/ext/mysqli/tests/mysqli_fetch_array_oo.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_array_oo.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_assoc.phpt b/ext/mysqli/tests/mysqli_fetch_assoc.phpt
index 6aaed3e..edf143b 100644
--- a/ext/mysqli/tests/mysqli_fetch_assoc.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_assoc.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_assoc_no_alias.phpt b/ext/mysqli/tests/mysqli_fetch_assoc_no_alias.phpt
index fa60582..a273b73 100644
--- a/ext/mysqli/tests/mysqli_fetch_assoc_no_alias.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_assoc_no_alias.phpt
@@ -8,7 +8,6 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	if (!$res = mysqli_query($link, "SELECT 1, 2")) {
diff --git a/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt b/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt
index 18d60c4..fa00ecd 100644
--- a/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt
@@ -5,7 +5,7 @@ mysqli_fetch_assoc() - utf8
 	require_once('skipif.inc');
 	require_once('skipifemb.inc');
 	require_once('skipifconnectfailure.inc');
-	require('connect.inc');
+	require_once("connect.inc");
 
 	if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 		die("skip Cannot connect to server to check charsets");
@@ -35,7 +35,6 @@ mysqli_fetch_assoc() - utf8
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	/* some cyrillic (utf8) comes here */
diff --git a/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt b/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt
index e9a746e..8a71fa7 100644
--- a/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_field.phpt b/ext/mysqli/tests/mysqli_fetch_field.phpt
index dba9f2f..e905992 100644
--- a/ext/mysqli/tests/mysqli_fetch_field.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_field.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_field_direct.phpt b/ext/mysqli/tests/mysqli_fetch_field_direct.phpt
index 5b4dc56..33c5a0c 100644
--- a/ext/mysqli/tests/mysqli_fetch_field_direct.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_field_direct.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt b/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt
index f107513..23d46f3 100644
--- a/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_field_flags.phpt b/ext/mysqli/tests/mysqli_fetch_field_flags.phpt
index 6f1cea2..42cbc14 100644
--- a/ext/mysqli/tests/mysqli_fetch_field_flags.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_field_flags.phpt
@@ -17,7 +17,7 @@ mysqli_close($link);
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 /* TODO: mysqli.c needs to export a few more constants - see all the defined() calls! */
 
@@ -144,7 +144,7 @@ mysqli_close($link);
 			case 'TIMESTAMP NOT NULL':
 				// http://bugs.mysql.com/bug.php?id=30081 - new flag introduced in 5.1.24/6.0.4
 				$version = mysqli_get_server_version($link);
-				if ((($version >  50122) && ($version < 60000)) ||
+				if ((($version >  50122) && ($version < 60000) && ($version != 50200)) ||
 						($version >= 60004)) {
 					// new flag ON_UPDATE_NOW_FLAG (8192)
 					$expected_flags .= ' ON_UPDATE_NOW';
@@ -165,7 +165,7 @@ mysqli_close($link);
 
 			case 'BIT':
 				$version = mysqli_get_server_version($link);
-				if ($version <= 50105) {
+				if (($version <= 50114 && $version > 50100) || ($version == 50200)) {
 					// TODO - check exact version!
 					$expected_flags = trim(str_replace('UNSIGNED', '', $expected_flags));
 				}
@@ -176,8 +176,8 @@ mysqli_close($link);
 
 		list($missing_flags, $unexpected_flags, $flags_found) = checkFlags($field->flags, $expected_flags, $flags);
 		if ($unexpected_flags) {
-			printf("[006] Found unexpected flags '%s' for %s, found '%s'\n",
-				$unexpected_flags, $column_def, $flags_found);
+			printf("[006] Found unexpected flags '%s' for %s, found '%s' with MySQL %s'\n",
+				$unexpected_flags, $column_def, $flags_found, mysqli_get_server_version($link));
 		}
 		if ($missing_flags) {
 			printf("[007] The flags '%s' have not been reported for %s, found '%s'\n",
diff --git a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt
index 2c169ed..f7dcd9b 100644
--- a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_field_types.phpt b/ext/mysqli/tests/mysqli_fetch_field_types.phpt
index ae18f0c..5d7e5eb 100644
--- a/ext/mysqli/tests/mysqli_fetch_field_types.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_field_types.phpt
@@ -8,7 +8,6 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	function mysqli_field_datatypes($link, $sql_type, $php_value, $php_type, $datatypes) {
diff --git a/ext/mysqli/tests/mysqli_fetch_fields.phpt b/ext/mysqli/tests/mysqli_fetch_fields.phpt
index 0acec54..a87956d 100644
--- a/ext/mysqli/tests/mysqli_fetch_fields.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_fields.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_lengths.phpt b/ext/mysqli/tests/mysqli_fetch_lengths.phpt
index 71c2349..1abc611 100644
--- a/ext/mysqli/tests/mysqli_fetch_lengths.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_lengths.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
 		printf("[001] Cannot connect\n");
diff --git a/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt b/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt
index ef7d762..7523621 100644
--- a/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
 		printf("[001] Cannot connect\n");
diff --git a/ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt b/ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt
index fc7efe4..2fa80cf 100644
--- a/ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_object_no_object.phpt b/ext/mysqli/tests/mysqli_fetch_object_no_object.phpt
index c767422..c8e2b85 100644
--- a/ext/mysqli/tests/mysqli_fetch_object_no_object.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_object_no_object.phpt
@@ -8,7 +8,6 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 	if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5")) {
 		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
diff --git a/ext/mysqli/tests/mysqli_fetch_object_oo.phpt b/ext/mysqli/tests/mysqli_fetch_object_oo.phpt
index 10b39e2..3b263e4 100644
--- a/ext/mysqli/tests/mysqli_fetch_object_oo.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_object_oo.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fetch_row.phpt b/ext/mysqli/tests/mysqli_fetch_row.phpt
index bb44fd4..e0359e0 100644
--- a/ext/mysqli/tests/mysqli_fetch_row.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_row.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_field_count.phpt b/ext/mysqli/tests/mysqli_field_count.phpt
index 5c63b86..9a778c9 100644
--- a/ext/mysqli/tests/mysqli_field_count.phpt
+++ b/ext/mysqli/tests/mysqli_field_count.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_field_seek.phpt b/ext/mysqli/tests/mysqli_field_seek.phpt
index 9d17f1a..58692a6 100644
--- a/ext/mysqli/tests/mysqli_field_seek.phpt
+++ b/ext/mysqli/tests/mysqli_field_seek.phpt
@@ -54,7 +54,7 @@ require_once('skipifconnectfailure.inc');
 		return $ret;
 	}
 
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_field_tell.phpt b/ext/mysqli/tests/mysqli_field_tell.phpt
index 9609a7c..f1e43c4 100644
--- a/ext/mysqli/tests/mysqli_field_tell.phpt
+++ b/ext/mysqli/tests/mysqli_field_tell.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_fork.phpt b/ext/mysqli/tests/mysqli_fork.phpt
index 7e5aac9..6c5096f 100644
--- a/ext/mysqli/tests/mysqli_fork.phpt
+++ b/ext/mysqli/tests/mysqli_fork.phpt
@@ -32,7 +32,6 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
 ?>
 --FILE--
 <?php
-	require_once("connect.inc");
 	require_once("table.inc");
 
 	$res = mysqli_query($link, "SELECT 'dumped by the parent' AS message");
@@ -236,7 +235,7 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_free_result.phpt b/ext/mysqli/tests/mysqli_free_result.phpt
index 1454353..a065e14 100644
--- a/ext/mysqli/tests/mysqli_free_result.phpt
+++ b/ext/mysqli/tests/mysqli_free_result.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$db = 'test';
 	$tmp    = NULL;
diff --git a/ext/mysqli/tests/mysqli_get_cache_stats.phpt b/ext/mysqli/tests/mysqli_get_cache_stats.phpt
deleted file mode 100644
index d49e399..0000000
--- a/ext/mysqli/tests/mysqli_get_cache_stats.phpt
+++ /dev/null
@@ -1,116 +0,0 @@
---TEST--
-mysqli_get_cache_stats()
---XFAIL--
-zval caching has been temporarily disabled for the 5.3.0 release
---INI--
-mysqlnd.collect_statistics="1"
-mysqlnd.collect_memory_statistics="1"
---SKIPIF--
-<?PHP
-require_once('skipif.inc');
-require_once('skipifemb.inc');
-require_once('skipifconnectfailure.inc');
-if (!function_exists('mysqli_get_cache_stats')) {
-	die("skip only available with mysqlnd");
-}
-?>
---FILE--
-<?php
-	$tmp = $link = null;
-	if (!is_null($tmp = @mysqli_get_cache_stats($link)))
-		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
-	include "connect.inc";
-
-	if (!is_array($info = mysqli_get_cache_stats()) || empty($info))
-		printf("[002] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
-
-	var_dump($info);
-
-	if ($info["size"] !== $info['free_items'])
-		printf("[003] Unused cache should have size (%d) == free_items (%d)\n",
-			$info["size"], $info['free_items']);
-
-	require_once('table.inc');
-
-	if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info))
-		printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info);
-
-	if ($info['size'] !== $new_info['size'])
-		printf("[005] Cache size should not have changes! Expecting int/%d, got %s/%d\n",
-			$info['size'], gettype($new_info['size']), $new_info['size']);
-
-	if (count($info) != count($new_info)) {
-		printf("[006] Both arrays should have the same number of entries\n");
-		var_dump($info);
-		var_dump($new_info);
-	}
-
-	if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
-		printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
-	if (!is_object($res = mysqli_use_result($link)))
-		printf("[008] Expecting object, got %s/%s. [%d] %s\n",
-			gettype($res), $res, mysqli_errno($link), mysqli_error($link));
-
-	if (!$row = mysqli_fetch_assoc($res))
-		printf("[009] There should be at least one row in the test table for this test, [%d] %s\n",
-			mysqli_errno($link), mysqli_error($link));
-
-	if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info))
-		printf("[010] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info);
-
-	if ($new_info['get_hits'] <= $info['get_hits'])
-		printf("[011] get_hits should have increased, %d (new) <= %d (old)!\n",
-			$new_info['get_hits'], $info['get_hits']);
-
-	if (!$row = mysqli_fetch_assoc($res))
-		printf("[012] There should be two rows in the test table for this test, [%d] %s\n",
-			mysqli_errno($link), mysqli_error($link));
-
-	if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info))
-		printf("[013] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info);
-
-	if ($new_info['put_misses'] <= $info['put_misses'])
-		printf("[014] put_misses should have increased, %d (new) <= %d (old)!\n",
-			$new_info['put_misses'], $info['put_misses']);
-
-	if ($new_info['references'] < $info['references'] + 2)
-		printf("[015] reference counter should have increased, %d (new) < %d + 2 (old)!\n",
-			$new_info['references'], $info['references']);
-
-	unset($row);
-	mysqli_free_result($res);
-
-	if (!is_array($info = mysqli_get_cache_stats()) || empty($info))
-		printf("[016] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
-
-	if ($info['free_items'] <= $new_info['free_items'])
-		printf("[017] Looks like cached entries never get free'd.\n");
-
-	mysqli_close($link);
-
-	print "done!";
-?>
---CLEAN--
-<?php
-	require_once("clean_table.inc");
-?>
---EXPECTF--
-array(7) {
-  [%u|b%"put_hits"]=>
-  int(0)
-  [%u|b%"put_misses"]=>
-  int(0)
-  [%u|b%"get_hits"]=>
-  int(0)
-  [%u|b%"get_misses"]=>
-  int(0)
-  [%u|b%"size"]=>
-  int(%d)
-  [%u|b%"free_items"]=>
-  int(%d)
-  [%u|b%"references"]=>
-  int(%d)
-}
-done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_get_cache_stats_free_buffered.phpt b/ext/mysqli/tests/mysqli_get_cache_stats_free_buffered.phpt
deleted file mode 100644
index 0bb90fa..0000000
--- a/ext/mysqli/tests/mysqli_get_cache_stats_free_buffered.phpt
+++ /dev/null
@@ -1,99 +0,0 @@
---TEST--
-mysqli_get_cache_stats() - freeing for buffered result sets
---XFAIL--
-zval caching has been temporarily disabled for the 5.3.0 release
---INI--
-mysqlnd.collect_statistics="1"
-mysqlnd.collect_memory_statistics="1"
---SKIPIF--
-<?PHP
-require_once('skipif.inc');
-require_once('skipifemb.inc');
-require_once('skipifconnectfailure.inc');
-if (!function_exists('mysqli_get_cache_stats')) {
-	die("skip only available with mysqlnd");
-}
-?>
---FILE--
-<?php
-	include "connect.inc";
-	require_once('table.inc');
-
-	if (!is_array($info = mysqli_get_cache_stats()) || empty($info))
-		printf("[001] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
-
-	if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id"))
-		printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
-	$rows = array();
-	while ($rows[] = mysqli_fetch_assoc($res))
-		;
-	mysqli_free_result($res);
-
-	if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info))
-		printf("[003] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info);
-
-	if ($new_info['free_items'] >= $info['free_items']) {
-		printf("[004] mysqli_free_result() should not yet have free slots again, because \$rows still exists\n");
-		var_dump($info);
-			var_dump($new_info);
-	}
-
-	/* nothing should change because GC will happen some time after free_result */
-	unset($rows);
-
-	if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info))
-		printf("[005] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info);
-
-	if (defined("WE_HAVE_GARBAGE_COLLECTOR_TO_FREE_AFTER_ON_UNSET_AFTER_FREE_RESULT")) {
-		/*
-			For now we can't reclaim the slots after the free_result is called.
-			unset() should happen before free_result().
-		*/
-		if ($new_info['free_items'] < $info['free_items']) {
-			printf("[006] \$rows has been unset, free item count should be back to the original value\n");
-			var_dump($info);
-			var_dump($new_info);
-		}
-	} else {
-		/* We have to reset $info */
-		$info = mysqli_get_cache_stats();
-	}
-
-	if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id"))
-		printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
-	$rows = array();
-	while ($rows[] = mysqli_fetch_assoc($res))
-		;
-	unset($rows);
-	mysqli_free_result($res);
-
-	if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info))
-		printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info);
-
-	if ($new_info['free_items'] < $info['free_items']) {
-		printf("[009] \$rows has been unset, mysqli_free_result() has been called, free item count should be back to the original value\n");
-		var_dump($info);
-		var_dump($new_info);
-	}
-
-	mysqli_close($link);
-
-	if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info))
-		printf("[010] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info);
-
-	if ($new_info['free_items'] < $info['free_items']) {
-		printf("[011] connection has been closed, free item count should be back to the original value\n");
-		var_dump($info);
-		var_dump($new_info);
-	}
-
-	print "done!";
-?>
---CLEAN--
-<?php
-	require_once("clean_table.inc");
-?>
---EXPECTF--
-done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_get_charset.phpt b/ext/mysqli/tests/mysqli_get_charset.phpt
index 314853d..8f81b33 100644
--- a/ext/mysqli/tests/mysqli_get_charset.phpt
+++ b/ext/mysqli/tests/mysqli_get_charset.phpt
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_get_charset'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_get_client_info.phpt b/ext/mysqli/tests/mysqli_get_client_info.phpt
index c927231..bb3f5cc 100644
--- a/ext/mysqli/tests/mysqli_get_client_info.phpt
+++ b/ext/mysqli/tests/mysqli_get_client_info.phpt
@@ -1,14 +1,14 @@
 --TEST--
 mysqli_get_client_info()
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 	if (!is_string($info = mysqli_get_client_info()) || ('' === $info))
 		printf("[001] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info);
 
diff --git a/ext/mysqli/tests/mysqli_get_client_stats.phpt b/ext/mysqli/tests/mysqli_get_client_stats.phpt
index ed75f7b..74c0cc8 100644
--- a/ext/mysqli/tests/mysqli_get_client_stats.phpt
+++ b/ext/mysqli/tests/mysqli_get_client_stats.phpt
@@ -84,7 +84,7 @@ mysqlnd.collect_memory_statistics=1
 	if (!is_null($tmp = @mysqli_get_client_stats($link)))
 		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!is_array($info = mysqli_get_client_stats()) || empty($info))
 		printf("[002] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
@@ -862,7 +862,7 @@ mysqlnd.collect_memory_statistics=1
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
@@ -887,7 +887,7 @@ if (!mysqli_query($link, "DROP SERVER IF EXISTS myself"))
 mysqli_close($link);
 ?>
 --EXPECTF--
-array(121) {
+array(152) {
   [%u|b%"bytes_sent"]=>
   %unicode|string%(1) "0"
   [%u|b%"bytes_received"]=>
@@ -974,6 +974,10 @@ array(121) {
   %unicode|string%(1) "0"
   [%u|b%"rows_fetched_from_client_ps_cursor"]=>
   %unicode|string%(1) "0"
+  [%u|b%"rows_affected_normal"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"rows_affected_ps"]=>
+  %unicode|string%(1) "0"
   [%u|b%"rows_skipped_normal"]=>
   %unicode|string%(1) "0"
   [%u|b%"rows_skipped_ps"]=>
@@ -1130,6 +1134,64 @@ array(121) {
   %unicode|string%(1) "0"
   [%u|b%"init_command_failed_count"]=>
   %unicode|string%(1) "0"
+  [%u|b%"com_quit"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_init_db"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_query"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_field_list"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_create_db"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_drop_db"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_refresh"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_shutdown"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_statistics"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_process_info"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_connect"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_process_kill"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_debug"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_ping"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_time"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_delayed_insert"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_change_user"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_binlog_dump"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_table_dump"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_connect_out"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_register_slave"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_stmt_prepare"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_stmt_execute"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_stmt_send_long_data"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_stmt_close"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_stmt_reset"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_stmt_set_option"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_stmt_fetch"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"com_deamon"]=>
+  %unicode|string%(1) "0"
 }
 Testing buffered normal...
 Testing buffered normal... - SELECT id, label FROM test
diff --git a/ext/mysqli/tests/mysqli_get_connection_stats.phpt b/ext/mysqli/tests/mysqli_get_connection_stats.phpt
index 698a468..64eba16 100644
--- a/ext/mysqli/tests/mysqli_get_connection_stats.phpt
+++ b/ext/mysqli/tests/mysqli_get_connection_stats.phpt
@@ -21,8 +21,7 @@ if (!function_exists('mysqli_get_connection_stats')) {
 	if (!is_null($tmp = @mysqli_get_connection_stats($link)))
 		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-	include "connect.inc";
-	include "table.inc";
+	require("table.inc");
 
 	if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info))
 		printf("[003] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
@@ -63,7 +62,7 @@ if (!function_exists('mysqli_get_connection_stats')) {
 	}
 
 	mysqli_close($link);
-	include "table.inc";
+	require("table.inc");
 
 	if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info))
 		printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
diff --git a/ext/mysqli/tests/mysqli_get_host_info.phpt b/ext/mysqli/tests/mysqli_get_host_info.phpt
index 63fdad2..2c3c0f8 100644
--- a/ext/mysqli/tests/mysqli_get_host_info.phpt
+++ b/ext/mysqli/tests/mysqli_get_host_info.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!is_null($tmp = @mysqli_get_host_info()))
 		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
@@ -20,6 +20,11 @@ require_once('skipifconnectfailure.inc');
 	if (!is_string($info = mysqli_get_host_info($link)) || ('' === $info))
 		printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info);
 
+	if ($IS_MYSQLND && $host != 'localhost' && $host != '127.0.0.1' && $port != '' && $host != "" && strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+		/* this should be a TCP/IP connection and not a Unix Socket (or SHM or Named Pipe) */
+		if (!stristr($info, "TCP/IP"))
+			printf("[004] Should be a TCP/IP connection but mysqlnd says '%s'\n", $info);	
+	}
 	print "done!";
 ?>
 --CLEAN--
diff --git a/ext/mysqli/tests/mysqli_get_proto_info.phpt b/ext/mysqli/tests/mysqli_get_proto_info.phpt
index b5dd985..7fbefeb 100644
--- a/ext/mysqli/tests/mysqli_get_proto_info.phpt
+++ b/ext/mysqli/tests/mysqli_get_proto_info.phpt
@@ -1,14 +1,14 @@
 --TEST--
 mysqli_get_proto_info()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!is_null($tmp = @mysqli_get_proto_info()))
 		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
diff --git a/ext/mysqli/tests/mysqli_get_server_info.phpt b/ext/mysqli/tests/mysqli_get_server_info.phpt
index f10cc4c..a7f7853 100644
--- a/ext/mysqli/tests/mysqli_get_server_info.phpt
+++ b/ext/mysqli/tests/mysqli_get_server_info.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!is_null($tmp = @mysqli_get_server_info()))
 		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
diff --git a/ext/mysqli/tests/mysqli_get_server_version.phpt b/ext/mysqli/tests/mysqli_get_server_version.phpt
index a97c9a2..b30c4a3 100644
--- a/ext/mysqli/tests/mysqli_get_server_version.phpt
+++ b/ext/mysqli/tests/mysqli_get_server_version.phpt
@@ -1,14 +1,14 @@
 --TEST--
 mysqli_get_server_version()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!is_null($tmp = @mysqli_get_server_version()))
 		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
diff --git a/ext/mysqli/tests/mysqli_get_warnings.phpt b/ext/mysqli/tests/mysqli_get_warnings.phpt
index 1472f29..00548de 100644
--- a/ext/mysqli/tests/mysqli_get_warnings.phpt
+++ b/ext/mysqli/tests/mysqli_get_warnings.phpt
@@ -11,7 +11,7 @@ if (!$TEST_EXPERIMENTAL)
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
@@ -144,7 +144,7 @@ if (!$TEST_EXPERIMENTAL)
 	print "done!";
 ?>
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_info.phpt b/ext/mysqli/tests/mysqli_info.phpt
index caa7c90..2d5004f 100644
--- a/ext/mysqli/tests/mysqli_info.phpt
+++ b/ext/mysqli/tests/mysqli_info.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	if (!is_null($tmp = @mysqli_info()))
 		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
diff --git a/ext/mysqli/tests/mysqli_insert_id.phpt b/ext/mysqli/tests/mysqli_insert_id.phpt
index a5491bf..549d71d 100644
--- a/ext/mysqli/tests/mysqli_insert_id.phpt
+++ b/ext/mysqli/tests/mysqli_insert_id.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_insert_id_variation.phpt b/ext/mysqli/tests/mysqli_insert_id_variation.phpt
index 1717b30..e858ca0 100644
--- a/ext/mysqli/tests/mysqli_insert_id_variation.phpt
+++ b/ext/mysqli/tests/mysqli_insert_id_variation.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-include "connect.inc";
+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",
@@ -90,7 +90,7 @@ echo "DONE";
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt b/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt
new file mode 100644
index 0000000..725636e
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt
@@ -0,0 +1,108 @@
+--TEST--
+INSERT and packet overflow
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+	die(sprintf("SKIP [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
+
+$max_len = pow(2, 24);
+if (!$res = mysqli_query($link, "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'"))
+	die(sprintf("SKIP [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
+
+if (!mysqli_query($link, "SET NAMES 'latin1'"))
+	die(sprintf("SKIP [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
+
+mysqli_close($link);
+?>
+--INI--
+memory_limit=256M
+--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());
+
+	if (!$res = mysqli_query($link, "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'"))
+		printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (!$row = mysqli_fetch_assoc($res))
+		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	mysqli_free_result($res);
+
+	if (0 === ($org_max_allowed_packet = (int)$row['Value']))
+		printf("[004] Cannot determine max_allowed_packet size and/or bogus max_allowed_packet setting used.\n");
+
+	$max_len = pow(2, 24);
+	if ($org_max_allowed_packet < $max_len) {
+		if (!mysqli_query($link, "SET GLOBAL max_allowed_packet = " . ($max_len + 100)))
+			printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	}
+	mysqli_close($link);
+	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+		printf("[006] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+
+	if (!mysqli_query($link, "SET NAMES 'latin1'"))
+		printf("[007] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+
+	if (!$res = mysqli_query($link, "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'"))
+		printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (!$row = mysqli_fetch_assoc($res))
+		printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	mysqli_free_result($res);
+
+	if (0 === ($max_allowed_packet = (int)$row['Value']))
+		printf("[010] Cannot determine max_allowed_packet size and/or bogus max_allowed_packet setting used.\n");
+
+	$max_len = pow(2, 24);
+	if ($max_allowed_packet < $max_len) {
+		printf("[011] Failed to change max_allowed_packet");
+	}
+
+	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_len = strlen($query_prefix) + strlen($query_postfix);
+	$com_query_len = 2;
+
+
+	$blob = str_repeat('a', $max_len - $com_query_len - $query_len);
+	$query = sprintf("%s%s%s", $query_prefix, $blob, $query_postfix);
+
+	if (!mysqli_query($link, $query))
+		printf("[013] max_allowed_packet = %d, strlen(query) = %d, [%d] %s\n", $max_allowed_packet, strlen($query), mysqli_errno($link), mysqli_error($link));
+
+	if (!$res = mysqli_query($link, "SELECT col_blob FROM test"))
+		printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (!$row = mysqli_fetch_assoc($res)) {
+		printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	} else {
+		if ($row['col_blob'] != $blob) {
+			printf("[016] Blob seems wrong, dumping data\n");
+			var_dump(strlen($row['col_blob']));
+			var_dump(strlen($blob));
+		}
+		mysqli_free_result($res);
+	}
+
+	if (!mysqli_query($link, "SET GLOBAL max_allowed_packet = " . $org_max_allowed_packet))
+		printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	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_kill.phpt b/ext/mysqli/tests/mysqli_kill.phpt
index 64daad8..5706adf 100644
--- a/ext/mysqli/tests/mysqli_kill.phpt
+++ b/ext/mysqli/tests/mysqli_kill.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
@@ -91,7 +91,7 @@ object(mysqli)#%d (%d) {
   [%u|b%"connect_errno"]=>
   int(0)
   [%u|b%"connect_error"]=>
-  %unicode|string%(0) ""
+  NULL
   [%u|b%"errno"]=>
   int(2006)
   [%u|b%"error"]=>
diff --git a/ext/mysqli/tests/mysqli_more_results.phpt b/ext/mysqli/tests/mysqli_more_results.phpt
index 49de0d7..271c63e 100644
--- a/ext/mysqli/tests/mysqli_more_results.phpt
+++ b/ext/mysqli/tests/mysqli_more_results.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$strict_on = false;
 	if (defined('E_STRICT')) {
diff --git a/ext/mysqli/tests/mysqli_multi_query.phpt b/ext/mysqli/tests/mysqli_multi_query.phpt
index dd26fd7..91c07c2 100644
--- a/ext/mysqli/tests/mysqli_multi_query.phpt
+++ b/ext/mysqli/tests/mysqli_multi_query.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$strict_on = false;
 	if (defined('E_STRICT')) {
diff --git a/ext/mysqli/tests/mysqli_next_result.phpt b/ext/mysqli/tests/mysqli_next_result.phpt
index 0dc49c7..c36920e 100644
--- a/ext/mysqli/tests/mysqli_next_result.phpt
+++ b/ext/mysqli/tests/mysqli_next_result.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$strict_on = false;
 	if (defined('E_STRICT')) {
diff --git a/ext/mysqli/tests/mysqli_no_reconnect.phpt b/ext/mysqli/tests/mysqli_no_reconnect.phpt
index aa7b1c3..0fbc1ff 100644
--- a/ext/mysqli/tests/mysqli_no_reconnect.phpt
+++ b/ext/mysqli/tests/mysqli_no_reconnect.phpt
@@ -78,8 +78,19 @@ mysqli.reconnect=0
 			mysqli_connect_errno(), mysqli_connect_error());
 
 	$thread_id_timeout = mysqli_thread_id($link);
-	if (!mysqli_query($link, sprintf('KILL %d', $thread_id_timeout)))
-		printf("[013] Cannot KILL timeout connection, [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+	if ($IS_MYSQLND) {
+		/* 
+		mysqlnd is a bit more verbose than libmysql. mysqlnd should print:
+		Warning: mysqli_query(): MySQL server has gone away in %s on line %d
+
+		Warning: mysqli_query(): Error reading result set's header in %d on line %d
+		*/
+		if (!@mysqli_query($link, sprintf('KILL %d', $thread_id_timeout)))
+			printf("[013] Cannot KILL timeout connection, [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+	} else {
+		if (!mysqli_query($link, sprintf('KILL %d', $thread_id_timeout)))
+			printf("[013] Cannot KILL timeout connection, [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+	}
 	// Give the server a second to really kill the other thread...
 	sleep(1);
 
diff --git a/ext/mysqli/tests/mysqli_num_fields.phpt b/ext/mysqli/tests/mysqli_num_fields.phpt
index 8882557..4c2510a 100644
--- a/ext/mysqli/tests/mysqli_num_fields.phpt
+++ b/ext/mysqli/tests/mysqli_num_fields.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_num_rows.phpt b/ext/mysqli/tests/mysqli_num_rows.phpt
index f1798cc..376ddd4 100644
--- a/ext/mysqli/tests/mysqli_num_rows.phpt
+++ b/ext/mysqli/tests/mysqli_num_rows.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_options.phpt b/ext/mysqli/tests/mysqli_options.phpt
index 670f9ac..1da140b 100644
--- a/ext/mysqli/tests/mysqli_options.phpt
+++ b/ext/mysqli/tests/mysqli_options.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 /*
 TODO: ext/mysqli might lack support for those options which are available
@@ -111,6 +111,8 @@ bool(true)
 bool(true)
 %s(23) "MYSQLI_OPT_LOCAL_INFILE"
 bool(true)
+
+Notice: Array to string conversion in %s on line %d
 %s(19) "MYSQLI_INIT_COMMAND"
 bool(true)
 %s(25) "MYSQLI_READ_DEFAULT_GROUP"
diff --git a/ext/mysqli/tests/mysqli_options_init_command.phpt b/ext/mysqli/tests/mysqli_options_init_command.phpt
index 2ba2ce4..a78dfca 100644
--- a/ext/mysqli/tests/mysqli_options_init_command.phpt
+++ b/ext/mysqli/tests/mysqli_options_init_command.phpt
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
 --FILE--
 <?php
 	/* see mysqli.c for details */
-	include "connect.inc";
+	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",
diff --git a/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt b/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt
new file mode 100644
index 0000000..f40965e
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt
@@ -0,0 +1,164 @@
+--TEST--
+Calling connect() on an open persistent connection to create a new persistent connection
+--SKIPIF--
+<?php
+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
+mysqli.max_persistent=-1
+mysqli.max_links=-1
+--FILE--
+<?php
+	require_once("connect.inc");
+
+	$phost = 'p:' . $host;
+
+	if (!$link = my_mysqli_connect($phost, $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",
+			$phost, $user, $db, $port, $socket);
+
+	if (!$thread_id = $link->thread_id)
+		printf("[002] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+		printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+
+	if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0))
+		printf("[004] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
+
+	if ($thread_id == $new_thread_id)
+		printf("[005] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
+
+	if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
+		!($row = mysqli_fetch_assoc($res)))
+		printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	var_dump($row);
+	mysqli_free_result($res);
+
+	mysqli_close($link);
+
+	if (!$link = new my_mysqli($phost, $user, $passwd, $db, $port, $socket))
+		printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+			$phost, $user, $db, $port, $socket);
+
+	if (!$thread_id = $link->thread_id)
+		printf("[008] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket)))
+		printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+
+	if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0))
+		printf("[010] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
+
+	if ($thread_id == $new_thread_id)
+		printf("[011] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
+
+	if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
+			!($row = $res->fetch_assoc()))
+		printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	var_dump($row);
+	mysqli_free_result($res);
+
+	mysqli_close($link);
+
+	if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
+		printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+
+	if (!$link = mysqli_connect($phost, $user, $passwd, $db, $port, $socket))
+		printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+			$phost, $user, $db, $port, $socket);
+
+	if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
+		printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+
+	printf("Flipping phost/host order\n");
+
+		if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+		printf("[016] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+			$host, $user, $db, $port, $socket);
+
+	if (!$thread_id = mysqli_thread_id($link))
+		printf("[017] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (true !== ($tmp = my_mysqli_real_connect($link, $phost, $user, $passwd, $db, $port, $socket)))
+		printf("[018] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+
+	if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0))
+		printf("[019] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
+
+	if ($thread_id == $new_thread_id)
+		printf("[020] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
+
+	if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
+		!($row = mysqli_fetch_assoc($res)))
+		printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	var_dump($row);
+	mysqli_free_result($res);
+
+	mysqli_close($link);
+
+	if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
+		printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+			$host, $user, $db, $port, $socket);
+
+	if (!$thread_id = $link->thread_id)
+		printf("[023] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (true !== ($tmp = $link->real_connect($phost, $user, $passwd, $db, $port, $socket)))
+		printf("[024] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+
+	if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0))
+		printf("[025] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
+
+	if ($thread_id == $new_thread_id)
+		printf("[026] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
+
+	if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
+			!($row = $res->fetch_assoc()))
+		printf("[027] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	var_dump($row);
+	mysqli_free_result($res);
+
+	mysqli_close($link);
+
+	if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
+		printf("[028] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+
+	if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+		printf("[029] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+			$host, $user, $db, $port, $socket);
+
+	if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
+		printf("[030] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+
+	print "done!";
+?>
+--EXPECTF--
+array(1) {
+  [%u|b%"it_works"]=>
+  %unicode|string%(2) "ok"
+}
+array(1) {
+  [%u|b%"syntax"]=>
+  %unicode|string%(18) "works also with oo"
+}
+Flipping phost/host order
+array(1) {
+  [%u|b%"it_works"]=>
+  %unicode|string%(2) "ok"
+}
+array(1) {
+  [%u|b%"syntax"]=>
+  %unicode|string%(18) "works also with oo"
+}
+done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_pconn_disabled.phpt b/ext/mysqli/tests/mysqli_pconn_disabled.phpt
index ee0efc4..1fe6271 100644
--- a/ext/mysqli/tests/mysqli_pconn_disabled.phpt
+++ b/ext/mysqli/tests/mysqli_pconn_disabled.phpt
@@ -17,7 +17,7 @@ mysqli.max_persistent=2
 mysqli.max_links=2
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$host = 'p:' . $host;
 	if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
diff --git a/ext/mysqli/tests/mysqli_pconn_max_links.phpt b/ext/mysqli/tests/mysqli_pconn_max_links.phpt
index 3ccb761..8e75539 100644
--- a/ext/mysqli/tests/mysqli_pconn_max_links.phpt
+++ b/ext/mysqli/tests/mysqli_pconn_max_links.phpt
@@ -160,7 +160,7 @@ mysqli.max_persistent=2
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_pconn_reuse.phpt b/ext/mysqli/tests/mysqli_pconn_reuse.phpt
index 8a43e7c..b42800a 100644
--- a/ext/mysqli/tests/mysqli_pconn_reuse.phpt
+++ b/ext/mysqli/tests/mysqli_pconn_reuse.phpt
@@ -17,7 +17,7 @@ mysqli.max_persistent=2
 mysqli.max_links=2
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$host = 'p:' . $host;
 	if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
diff --git a/ext/mysqli/tests/mysqli_pconn_twice.phpt b/ext/mysqli/tests/mysqli_pconn_twice.phpt
new file mode 100644
index 0000000..12800c2
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_pconn_twice.phpt
@@ -0,0 +1,79 @@
+--TEST--
+Calling connect() on an open persistent connection to create a new persistent connection
+--SKIPIF--
+<?php
+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
+mysqli.max_persistent=-1
+mysqli.max_links=-1
+--FILE--
+<?php
+	require_once("connect.inc");
+
+	$host = 'p:' . $host;
+	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);
+
+	if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+		printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+
+	/* it is undefined which pooled connection we get - thread ids may differ */
+
+	if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
+		!($row = mysqli_fetch_assoc($res)))
+		printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	var_dump($row);
+	mysqli_free_result($res);
+
+	mysqli_close($link);
+
+	if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
+		printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+			$host, $user, $db, $port, $socket);
+
+
+	if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket)))
+		printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+
+	/* it is undefined which pooled connection we get - thread ids may differ */
+
+	if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
+			!($row = $res->fetch_assoc()))
+		printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	var_dump($row);
+	mysqli_free_result($res);
+
+	mysqli_close($link);
+
+	if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
+		printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+
+	if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+		printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+			$host, $user, $db, $port, $socket);
+
+	if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
+		printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+
+	print "done!";
+?>
+--EXPECTF--
+array(1) {
+  [%u|b%"it_works"]=>
+  %unicode|string%(2) "ok"
+}
+array(1) {
+  [%u|b%"syntax"]=>
+  %unicode|string%(18) "works also with oo"
+}
+done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_pconnect.phpt b/ext/mysqli/tests/mysqli_pconnect.phpt
index 57b44eb..fbb1092 100644
--- a/ext/mysqli/tests/mysqli_pconnect.phpt
+++ b/ext/mysqli/tests/mysqli_pconnect.phpt
@@ -11,7 +11,7 @@ if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$host = 'p:' . $host;
 	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
diff --git a/ext/mysqli/tests/mysqli_phpinfo.phpt b/ext/mysqli/tests/mysqli_phpinfo.phpt
index 14fdfcd..d60636a 100644
--- a/ext/mysqli/tests/mysqli_phpinfo.phpt
+++ b/ext/mysqli/tests/mysqli_phpinfo.phpt
@@ -57,8 +57,7 @@ require_once('skipifconnectfailure.inc');
 			'connect_failure', 'connection_reused', 'explicit_close', 'implicit_close',
 			'disconnect_close', 'in_middle_of_command_close', 'explicit_free_result',
 			'implicit_free_result', 'explicit_stmt_close', 'implicit_stmt_close',
-			'put_hits', 'put_misses', 'get_hits', 'get_misses',
-			'size', 'free_items', 'references', 'mysqli.cache_size',
+			'size',
 			'mysqli.allow_local_infile',
 			'mysqli.allow_persistent', 'mysqli.max_persistent'
 		);
diff --git a/ext/mysqli/tests/mysqli_ping.phpt b/ext/mysqli/tests/mysqli_ping.phpt
index 80a2a20..d9a134c 100644
--- a/ext/mysqli/tests/mysqli_ping.phpt
+++ b/ext/mysqli/tests/mysqli_ping.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt b/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt
index 56f9182..9c02cf9 100644
--- a/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt
+++ b/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt
@@ -155,7 +155,7 @@ if (!$IS_MYSQLND)
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_prepare.phpt b/ext/mysqli/tests/mysqli_prepare.phpt
index 0737aba..bba8274 100644
--- a/ext/mysqli/tests/mysqli_prepare.phpt
+++ b/ext/mysqli/tests/mysqli_prepare.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
@@ -118,7 +118,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_prepare_no_object.phpt b/ext/mysqli/tests/mysqli_prepare_no_object.phpt
index 3d022f4..e45de69 100644
--- a/ext/mysqli/tests/mysqli_prepare_no_object.phpt
+++ b/ext/mysqli/tests/mysqli_prepare_no_object.phpt
@@ -8,7 +8,6 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	if (false !== ($tmp = mysqli_prepare($link, false)))
diff --git a/ext/mysqli/tests/mysqli_query.phpt b/ext/mysqli/tests/mysqli_query.phpt
index 0e45f03..73bebe1 100644
--- a/ext/mysqli/tests/mysqli_query.phpt
+++ b/ext/mysqli/tests/mysqli_query.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
@@ -114,7 +114,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_query_local_infile_large.phpt b/ext/mysqli/tests/mysqli_query_local_infile_large.phpt
index 306dfce..8b115a5 100644
--- a/ext/mysqli/tests/mysqli_query_local_infile_large.phpt
+++ b/ext/mysqli/tests/mysqli_query_local_infile_large.phpt
@@ -31,7 +31,7 @@ mysqli.allow_local_infile=1
 	fclose($fp);
 	printf("Filesize in bytes: %d\nRows: %d\n", $bytes, $rowno);
 
-	include "connect.inc";
+	require_once("connect.inc");
  	if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
 		printf("[002] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
@@ -72,7 +72,7 @@ $file = tempnam(sys_get_temp_dir(), 'mysqli_test.cvs');
 if (file_exists($file))
 	unlink($file);
 
-include "connect.inc";
+require_once("connect.inc");
 if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
 	printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_query_stored_proc.phpt b/ext/mysqli/tests/mysqli_query_stored_proc.phpt
index 0ca71a4..10bf86b 100644
--- a/ext/mysqli/tests/mysqli_query_stored_proc.phpt
+++ b/ext/mysqli/tests/mysqli_query_stored_proc.phpt
@@ -152,7 +152,7 @@ END;')) {
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_real_escape_string.phpt b/ext/mysqli/tests/mysqli_real_escape_string.phpt
index b25c72a..6c37258 100644
--- a/ext/mysqli/tests/mysqli_real_escape_string.phpt
+++ b/ext/mysqli/tests/mysqli_real_escape_string.phpt
@@ -1,14 +1,14 @@
 --TEST--
 mysqli_real_escape_string()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt b/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt
index 038cca9..7930992 100644
--- a/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt
+++ b/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt
@@ -1,14 +1,14 @@
 --TEST--
 mysqli_real_escape_string()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp	= NULL;
 	$link	= NULL;
diff --git a/ext/mysqli/tests/mysqli_real_query.phpt b/ext/mysqli/tests/mysqli_real_query.phpt
index 8e30344..866ad6a 100644
--- a/ext/mysqli/tests/mysqli_real_query.phpt
+++ b/ext/mysqli/tests/mysqli_real_query.phpt
@@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
@@ -91,7 +91,7 @@ ver_param;')) {
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_report.phpt b/ext/mysqli/tests/mysqli_report.phpt
index dc92799..11ddef8 100644
--- a/ext/mysqli/tests/mysqli_report.phpt
+++ b/ext/mysqli/tests/mysqli_report.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_report_wo_ps.phpt b/ext/mysqli/tests/mysqli_report_wo_ps.phpt
index 0890926..e7ba6bb 100644
--- a/ext/mysqli/tests/mysqli_report_wo_ps.phpt
+++ b/ext/mysqli/tests/mysqli_report_wo_ps.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_result_unclonable.phpt b/ext/mysqli/tests/mysqli_result_unclonable.phpt
index dfde9a7..0ecc30b 100644
--- a/ext/mysqli/tests/mysqli_result_unclonable.phpt
+++ b/ext/mysqli/tests/mysqli_result_unclonable.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	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",
diff --git a/ext/mysqli/tests/mysqli_rollback.phpt b/ext/mysqli/tests/mysqli_rollback.phpt
index 616f50d..1b1fe8b 100644
--- a/ext/mysqli/tests/mysqli_rollback.phpt
+++ b/ext/mysqli/tests/mysqli_rollback.phpt
@@ -29,7 +29,7 @@ mysqli_rollback()
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_select_db.phpt b/ext/mysqli/tests/mysqli_select_db.phpt
index bc774cf..d700a2b 100644
--- a/ext/mysqli/tests/mysqli_select_db.phpt
+++ b/ext/mysqli/tests/mysqli_select_db.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_send_query.phpt b/ext/mysqli/tests/mysqli_send_query.phpt
index 53cf250..7de2bfc 100755
--- a/ext/mysqli/tests/mysqli_send_query.phpt
+++ b/ext/mysqli/tests/mysqli_send_query.phpt
@@ -15,7 +15,7 @@ if (!$TEST_EXPERIMENTAL)
 --FILE--
 <?php
 	/* NOTE: tests is a stub, but function is deprecated, as long as it does not crash when invoking it... */
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_set_charset.phpt b/ext/mysqli/tests/mysqli_set_charset.phpt
index baf97bd..4f4aaa5 100644
--- a/ext/mysqli/tests/mysqli_set_charset.phpt
+++ b/ext/mysqli/tests/mysqli_set_charset.phpt
@@ -50,7 +50,7 @@ if ((($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin1"', MYSQLI_STOR
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt
index 5cb1459..c8da018 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
 	die("skip - function not available.");
 
 require_once('connect.inc');
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt
index ec097fe..ad0a353 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt
@@ -13,7 +13,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
 if (!$TEST_EXPERIMENTAL)
     die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt
index 03f4288..e7df96e 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
 	die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt
index cb8162d..c2ee87b 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
 	die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
@@ -33,8 +33,7 @@ if ('ON' != $row['Value'])
 mysqli.allow_local_infile=1
 --FILE--
 <?php
-	include "connect.inc";
-	include("table.inc");
+	require("table.inc");
 	require_once('local_infile_tools.inc');
 
 	function callback_close_link($fp, &$buffer, $buflen, &$error) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt
index 7498e64..4ebf8de 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
 	die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
@@ -33,8 +33,7 @@ if ('ON' != $row['Value'])
 mysqli.allow_local_infile=1
 --FILE--
 <?php
-	include "connect.inc";
-	include("table.inc");
+	require_once("table.inc");
 	require_once('local_infile_tools.inc');
 
 	function callback_closefile($fp, &$buffer, $buflen, &$error) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt
index 7e24458..3d94a54 100755
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
 	die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt
index 3757b61..09b4f90 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
 	die("skip - function not available.");
 
 require_once('connect.inc');
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
@@ -30,8 +30,7 @@ if ('ON' != $row['Value'])
 mysqli.allow_local_infile=1
 --FILE--
 <?php
-	include "connect.inc";
-	include("table.inc");
+	require("table.inc");
 	require_once('local_infile_tools.inc');
 
 	function callback_kill_link($fp, &$buffer, $buflen, &$error) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt
index 30a3bcc..ca42705 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
 	die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt
index 465dcdb..8b56dea 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
 	die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt
index 5ea82e9..1c47292 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
 	die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt
index 6354630..6113aba 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
 	die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt
index c30f6ea..423ad83 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
 	die("skip - function not available.");
 
 require_once('connect.inc');
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt
index cde8f4b..33dd516 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
 	die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt
index a793ac6..9af9974 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
 	die("skip - experimental (= unsupported) feature");
 
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt
index c89fc21..e6dfecb 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
 	die("skip - function not available.");
 
 require_once('connect.inc');
-if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 	die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
diff --git a/ext/mysqli/tests/mysqli_set_opt.phpt b/ext/mysqli/tests/mysqli_set_opt.phpt
index 21aacd2..7c96d59 100644
--- a/ext/mysqli/tests/mysqli_set_opt.phpt
+++ b/ext/mysqli/tests/mysqli_set_opt.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_set_opt_numeric_and_datetime_as_unicode.phpt b/ext/mysqli/tests/mysqli_set_opt_numeric_and_datetime_as_unicode.phpt
index 77047a1..7e0593c 100644
--- a/ext/mysqli/tests/mysqli_set_opt_numeric_and_datetime_as_unicode.phpt
+++ b/ext/mysqli/tests/mysqli_set_opt_numeric_and_datetime_as_unicode.phpt
@@ -14,8 +14,7 @@ if (!stristr(mysqli_get_client_info(), "mysqlnd"))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
-	include "table.inc";
+	require_once("table.inc");
 
 	if (true !== ($tmp = mysqli_set_opt($link, MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, 1)))
 		printf("[001] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
diff --git a/ext/mysqli/tests/mysqli_sqlstate.phpt b/ext/mysqli/tests/mysqli_sqlstate.phpt
index 0ed39f4..56580cd 100644
--- a/ext/mysqli/tests/mysqli_sqlstate.phpt
+++ b/ext/mysqli/tests/mysqli_sqlstate.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_ssl_set.phpt b/ext/mysqli/tests/mysqli_ssl_set.phpt
index e868f34..2abae55 100644
--- a/ext/mysqli/tests/mysqli_ssl_set.phpt
+++ b/ext/mysqli/tests/mysqli_ssl_set.phpt
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_ssl_set'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stat.phpt b/ext/mysqli/tests/mysqli_stat.phpt
index 7d7d4e7..f1cd56c 100644
--- a/ext/mysqli/tests/mysqli_stat.phpt
+++ b/ext/mysqli/tests/mysqli_stat.phpt
@@ -1,14 +1,14 @@
 --TEST--
 mysqli_stat()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt b/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt
index d4761dd..4765d64 100644
--- a/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_attr_get.phpt b/ext/mysqli/tests/mysqli_stmt_attr_get.phpt
index abedf56..a4eb4d0 100644
--- a/ext/mysqli/tests/mysqli_stmt_attr_get.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_attr_get.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt b/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt
index 26bbf96..0d5e8f9 100644
--- a/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt
@@ -9,7 +9,6 @@ die("SKIP: prefetch isn't supported at the moment");
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	$stmt = mysqli_stmt_init($link);
diff --git a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
index 7bc9882..5ff6e5e 100644
--- a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
@@ -45,23 +45,27 @@ require_once('skipifconnectfailure.inc');
 		printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	$stmt->prepare("SELECT * FROM test");
+	
 	mt_srand(microtime(true));
+
+	/* mysqlnd detects invalid attributes, libmysql does not AFAIK */
+	$invalid_ret = ($IS_MYSQLND) ? false : true;
+
 	for ($i = -100; $i < 1000; $i++) {
 		if (in_array($i, $valid_attr))
 			continue;
 		$invalid_attr = $i;
-		if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) {
-			printf("[006a] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp);
+		if ($invalid_ret !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) {
+			printf("[006a] Expecting boolean/%s for attribute %d, got %s/%s\n", $invalid_ret, $invalid_attr, gettype($tmp), $tmp);
 		}
 	}
 
-	for ($i = 0; $i < 10; $i++) {
+	for ($i = 0; $i < 2; $i++) {
 		do {
 			$invalid_attr = mt_rand(-1 * (min(4294967296, PHP_INT_MAX) + 1), min(4294967296, PHP_INT_MAX));
 		} while (in_array($invalid_attr, $valid_attr));
-		if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) {
-			/* Although it may be desired to get false neither the MySQL Client Library nor mysqlnd are supposed to detect invalid codes */
-			printf("[006b] Expecting boolean/true for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp);
+		if ($invalid_ret !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) {
+			printf("[006b] Expecting boolean/%s for attribute %d, got %s/%s\n", $invalid_ret, $invalid_attr, gettype($tmp), $tmp);
 		}
 	}
 	$stmt->close();
diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param.phpt
index 9aaac98..33ef317 100644
--- a/ext/mysqli/tests/mysqli_stmt_bind_param.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_bind_param.phpt
@@ -17,7 +17,7 @@ require_once('skipifconnectfailure.inc');
 	in this file and we test mysqli_stmt_bind_result() in the other
 	test -- therefore the "duplicate" makes some sense to me.
 	*/
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
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 a7d3674..e1e3a92 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
@@ -8,7 +8,6 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	class foo {
diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt
index 24d4314..91cb9d0 100644
--- a/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt
@@ -8,7 +8,6 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	function findRow($offset, $link, $id, $label) {
diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt
index ab871ce..daab40c 100644
--- a/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt
@@ -8,7 +8,6 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	function bind_twice($link, $engine, $sql_type1, $sql_type2, $bind_type1, $bind_type2, $bind_value1, $bind_value2, $offset) {
diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result.phpt
index f575674..5b7da34 100644
--- a/ext/mysqli/tests/mysqli_stmt_bind_result.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_bind_result.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$hint_str_or_unicode = (version_compare(PHP_VERSION, '5.9.9', '>') == 1) ? "unicode":"string";
 
diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt
index 1eef767..acf0d0b 100644
--- a/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	function dec32bin($dec, $bits) {
 
diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt
index 511f7e3..ee659d4 100644
--- a/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt
@@ -8,7 +8,6 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	$stmt = mysqli_stmt_init($link);
diff --git a/ext/mysqli/tests/mysqli_stmt_close.phpt b/ext/mysqli/tests/mysqli_stmt_close.phpt
index b38f0cd..64e76e5 100644
--- a/ext/mysqli/tests/mysqli_stmt_close.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_close.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_data_seek.phpt b/ext/mysqli/tests/mysqli_stmt_data_seek.phpt
index 246158e..a1cebea 100644
--- a/ext/mysqli/tests/mysqli_stmt_data_seek.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_data_seek.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_datatype_change.phpt b/ext/mysqli/tests/mysqli_stmt_datatype_change.phpt
index 25c183a..b23f94d 100644
--- a/ext/mysqli/tests/mysqli_stmt_datatype_change.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_datatype_change.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 	if (!$c1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
 		printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
 			$host, $user, $db, $port, $socket);
@@ -56,7 +56,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_stmt_errno.phpt b/ext/mysqli/tests/mysqli_stmt_errno.phpt
index 59fde71..070f251 100644
--- a/ext/mysqli/tests/mysqli_stmt_errno.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_errno.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_error.phpt b/ext/mysqli/tests/mysqli_stmt_error.phpt
index ffb77fe..e18aa07 100644
--- a/ext/mysqli/tests/mysqli_stmt_error.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_error.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_execute.phpt b/ext/mysqli/tests/mysqli_stmt_execute.phpt
index d1d62c2..6176386 100644
--- a/ext/mysqli/tests/mysqli_stmt_execute.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_execute.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt
index afedea4..29e3947 100644
--- a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt
@@ -183,7 +183,7 @@ if (mysqli_get_server_version($link) <= 50000) {
 ?>
 --CLEAN--
 <?php
-include "connect.inc";
+require_once("connect.inc");
 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
diff --git a/ext/mysqli/tests/mysqli_stmt_fetch.phpt b/ext/mysqli/tests/mysqli_stmt_fetch.phpt
index 6f70148..fca5100 100644
--- a/ext/mysqli/tests/mysqli_stmt_fetch.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_fetch.phpt
@@ -13,7 +13,7 @@ require_once('skipifconnectfailure.inc');
 	mysqli_stmt_bind_result.phpt already. Restrict
 	this test case to the basics.
 	*/
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt b/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt
index e63591a..0cbc05f 100644
--- a/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt
@@ -8,8 +8,8 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
-	require('table.inc');
+	require_once("connect.inc");
+	require_once('table.inc');
 
 	$bind_res = $id = null;
 	if (!($stmt = mysqli_stmt_init($link)) ||
diff --git a/ext/mysqli/tests/mysqli_stmt_field_count.phpt b/ext/mysqli/tests/mysqli_stmt_field_count.phpt
index 2dbf487..7dfd3a4 100644
--- a/ext/mysqli/tests/mysqli_stmt_field_count.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_field_count.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_free_result.phpt b/ext/mysqli/tests/mysqli_stmt_free_result.phpt
index 12c1a34..08b33b7 100644
--- a/ext/mysqli/tests/mysqli_stmt_free_result.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_free_result.phpt
@@ -13,7 +13,7 @@ require_once('skipifconnectfailure.inc');
 	mysqli_stmt_bind_result.phpt already. Restrict
 	this test case to the basics.
 	*/
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_get_result.phpt b/ext/mysqli/tests/mysqli_stmt_get_result.phpt
index 58a7f0c..fe18be4 100644
--- a/ext/mysqli/tests/mysqli_stmt_get_result.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_get_result.phpt
@@ -16,7 +16,7 @@ if (!function_exists('mysqli_stmt_get_result'))
 	mysqli_stmt_bind_result.phpt already. Restrict
 	this test case to the basics.
 	*/
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp	= NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_get_result2.phpt b/ext/mysqli/tests/mysqli_stmt_get_result2.phpt
index 1f493d2..8c2aad1 100644
--- a/ext/mysqli/tests/mysqli_stmt_get_result2.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_get_result2.phpt
@@ -15,7 +15,7 @@ if (!function_exists('mysqli_stmt_get_result'))
 	mysqli_stmt_bind_result.phpt already. Restrict
 	this test case to the basics.
 	*/
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp	= NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt
index dab805c..046f904 100644
--- a/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt
@@ -11,7 +11,6 @@ mysqli_stmt_get_result() - meta data, field_count()
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	if (!$stmt = mysqli_stmt_init($link))
diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt
index 7fdabc0..8689880 100644
--- a/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt
@@ -11,7 +11,6 @@ if (!function_exists('mysqli_stmt_get_result'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	if (!$stmt = mysqli_stmt_init($link))
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 43ec10c..1a2dba4 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
@@ -11,7 +11,6 @@ if (!function_exists('mysqli_stmt_get_result'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	if (!($stmt = mysqli_stmt_init($link)) ||
diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt
index 717b39b..c057f7d 100644
--- a/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt
@@ -16,7 +16,6 @@ if (!function_exists('mysqli_stmt_get_result'))
 	mysqli_stmt_bind_result.phpt already. Restrict
 	this test case to the basics.
 	*/
-	include "connect.inc";
 	require('table.inc');
 
 	if (!$stmt = mysqli_stmt_init($link))
diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt
index c4312c6..ffb655d 100644
--- a/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt
@@ -11,7 +11,6 @@ if (!function_exists('mysqli_stmt_get_result'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	if (!$stmt = mysqli_stmt_init($link))
diff --git a/ext/mysqli/tests/mysqli_stmt_init.phpt b/ext/mysqli/tests/mysqli_stmt_init.phpt
index 7d0154d..4f09719 100644
--- a/ext/mysqli/tests/mysqli_stmt_init.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_init.phpt
@@ -13,7 +13,7 @@ require_once('skipifconnectfailure.inc');
 	mysqli_stmt_bind_result.phpt already. Restrict
 	this test case to the basics.
 	*/
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_insert_id.phpt b/ext/mysqli/tests/mysqli_stmt_insert_id.phpt
index 0347e66..c7a5aff 100644
--- a/ext/mysqli/tests/mysqli_stmt_insert_id.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_insert_id.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_num_rows.phpt b/ext/mysqli/tests/mysqli_stmt_num_rows.phpt
index 4f3bc61..28ee64f 100644
--- a/ext/mysqli/tests/mysqli_stmt_num_rows.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_num_rows.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_param_count.phpt b/ext/mysqli/tests/mysqli_stmt_param_count.phpt
index f55acfb..84bcfd9 100644
--- a/ext/mysqli/tests/mysqli_stmt_param_count.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_param_count.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_prepare.phpt b/ext/mysqli/tests/mysqli_stmt_prepare.phpt
index 115e1a5..3eb576a 100644
--- a/ext/mysqli/tests/mysqli_stmt_prepare.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_prepare.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	// Note: No SQL tests here! We can expand one of the *fetch()
 	// tests to a generic SQL test, if we ever need that.
diff --git a/ext/mysqli/tests/mysqli_stmt_reset.phpt b/ext/mysqli/tests/mysqli_stmt_reset.phpt
index 9f8864d..d731da2 100644
--- a/ext/mysqli/tests/mysqli_stmt_reset.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_reset.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	// Note: No SQL tests here! We can expand one of the *fetch()
 	// tests to a generic SQL test, if we ever need that.
diff --git a/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt b/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt
index 34d3bb2..faccdf9 100644
--- a/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt b/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt
index f0b7757..a7dad1b 100644
--- a/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt
@@ -10,7 +10,6 @@ die("skip Check again when the Klingons visit earth - http://bugs.mysql.com/bug.
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	function testStatement($offset, $link, $sql, $expected_lib, $expected_mysqlnd, $check_mysqlnd, $compare) {
diff --git a/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt b/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt
index 4f173ef..1a6a3d7 100644
--- a/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_libmysql.phpt b/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_libmysql.phpt
index 5bd40d8..a1fc200 100644
--- a/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_libmysql.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_libmysql.phpt
@@ -11,7 +11,6 @@ if (stristr(mysqli_get_client_info(), 'mysqlnd'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	if (!$stmt = mysqli_stmt_init($link))
diff --git a/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_mysqlnd.phpt b/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_mysqlnd.phpt
index be8e595..95d2302 100644
--- a/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_mysqlnd.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_mysqlnd.phpt
@@ -11,7 +11,6 @@ if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
 ?>
 --FILE--
 <?php
-	include "connect.inc";
 	require('table.inc');
 
 	if (!$stmt = mysqli_stmt_init($link))
diff --git a/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt b/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt
index b8a97cd..5ea35df 100644
--- a/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_store_result.phpt b/ext/mysqli/tests/mysqli_stmt_store_result.phpt
index ee0bf83..a6411ca 100644
--- a/ext/mysqli/tests/mysqli_stmt_store_result.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_store_result.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_stmt_unclonable.phpt b/ext/mysqli/tests/mysqli_stmt_unclonable.phpt
index edddbea..57d8d6d 100644
--- a/ext/mysqli/tests/mysqli_stmt_unclonable.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_unclonable.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	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",
diff --git a/ext/mysqli/tests/mysqli_store_result.phpt b/ext/mysqli/tests/mysqli_store_result.phpt
index 206cae3..c61c124 100644
--- a/ext/mysqli/tests/mysqli_store_result.phpt
+++ b/ext/mysqli/tests/mysqli_store_result.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_thread_id.phpt b/ext/mysqli/tests/mysqli_thread_id.phpt
index a67060a..3a7e1ae 100644
--- a/ext/mysqli/tests/mysqli_thread_id.phpt
+++ b/ext/mysqli/tests/mysqli_thread_id.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_unclonable.phpt b/ext/mysqli/tests/mysqli_unclonable.phpt
index d21eafa..e332b9f 100644
--- a/ext/mysqli/tests/mysqli_unclonable.phpt
+++ b/ext/mysqli/tests/mysqli_unclonable.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	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",
diff --git a/ext/mysqli/tests/mysqli_use_result.phpt b/ext/mysqli/tests/mysqli_use_result.phpt
index d1b09f1..25d1692 100644
--- a/ext/mysqli/tests/mysqli_use_result.phpt
+++ b/ext/mysqli/tests/mysqli_use_result.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_warning_count.phpt b/ext/mysqli/tests/mysqli_warning_count.phpt
index 0293fe8..cff9c02 100644
--- a/ext/mysqli/tests/mysqli_warning_count.phpt
+++ b/ext/mysqli/tests/mysqli_warning_count.phpt
@@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	require_once("connect.inc");
 
 	$tmp    = NULL;
 	$link   = NULL;
diff --git a/ext/mysqli/tests/mysqli_warning_unclonable.phpt b/ext/mysqli/tests/mysqli_warning_unclonable.phpt
index 57d5de7..d3ae47d 100644
--- a/ext/mysqli/tests/mysqli_warning_unclonable.phpt
+++ b/ext/mysqli/tests/mysqli_warning_unclonable.phpt
@@ -11,7 +11,7 @@ if (!$TEST_EXPERIMENTAL)
 ?>
 --FILE--
 <?php
-	include "connect.inc";
+	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",
diff --git a/ext/mysqlnd/config.w32 b/ext/mysqlnd/config.w32
index 5677189..1bc8572 100644
--- a/ext/mysqlnd/config.w32
+++ b/ext/mysqlnd/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32 259731 2008-05-14 03:13:17Z auroraeosrose $
+// $Id: config.w32 292204 2009-12-16 12:59:38Z andrey $
 // vim:ft=javascript
 
 ARG_WITH("mysqlnd", "Mysql Native Client Driver", "yes");
@@ -11,15 +11,19 @@ if (PHP_MYSQLND != "no") {
 			"mysqlnd_charset.c " +
 			"mysqlnd_debug.c " +
 			"mysqlnd_loaddata.c " +
-			"mysqlnd_palloc.c " +
+			"mysqlnd_net.c " +
 			"mysqlnd_ps.c " +
 			"mysqlnd_ps_codec.c " +
-			"mysqlnd_qcache.c " +
 			"mysqlnd_result.c " +
 			"mysqlnd_result_meta.c " +
 			"mysqlnd_statistics.c " +
 			"mysqlnd_wireprotocol.c " +
 			"php_mysqlnd.c";
 		EXTENSION("mysqlnd", mysqlnd_source, false);
+		if (((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib;zlib.lib", "mysqlnd", PHP_MYSQLND))) || 
+			(PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "mysqlnd", PHP_MYSQLND)) || (PHP_ZLIB == "yes" && (!PHP_ZLIB_SHARED)))
+		{
+			AC_DEFINE("MYSQLND_COMPRESSION_ENABLED", 1, "Compression support");
+		}
 	}
-}
\ No newline at end of file
+}
diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4
index 48dfe74..f931776 100644
--- a/ext/mysqlnd/config9.m4
+++ b/ext/mysqlnd/config9.m4
@@ -1,27 +1,40 @@
 dnl
-dnl $Id: config9.m4 289630 2009-10-14 13:51:25Z johannes $
+dnl $Id: config9.m4 292495 2009-12-22 19:30:09Z johannes $
 dnl config.m4 for mysqlnd driver
 
-PHP_ARG_ENABLE(mysqlnd_threading, whether to enable threaded fetch in mysqlnd,
-[  --enable-mysqlnd-threading
-                            EXPERIMENTAL: Enable mysqlnd threaded fetch.
-                            Note: This forces ZTS on!], no, no)
+
+PHP_ARG_ENABLE(disable_mysqlnd_compression_support, whether to disable compressed protocol support in mysqlnd,
+[  --disable-mysqlnd-compression-support
+                            Enable support for the MySQL compressed protocol in mysqlnd], yes)
+
+if test -z "$PHP_ZLIB_DIR"; then
+  PHP_ARG_WITH(zlib-dir, for the location of libz,
+  [  --with-zlib-dir[=DIR]       mysqlnd: Set the path to libz install prefix], no, no)
+fi
 
 dnl If some extension uses mysqlnd it will get compiled in PHP core
 if test "$PHP_MYSQLND_ENABLED" = "yes"; then
   mysqlnd_sources="mysqlnd.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
-                   mysqlnd_ps.c mysqlnd_loaddata.c mysqlnd_palloc.c \
-                   mysqlnd_ps_codec.c mysqlnd_statistics.c mysqlnd_qcache.c\
+                   mysqlnd_ps.c mysqlnd_loaddata.c mysqlnd_net.c \
+                   mysqlnd_ps_codec.c mysqlnd_statistics.c \
 				   mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\
 				   mysqlnd_block_alloc.c php_mysqlnd.c"
 
   PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, no)
   PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)
+  PHP_INSTALL_HEADERS([ext/mysqlnd/])
 
   dnl Windows uses config.w32 thus this code is safe for now
-  if test "$PHP_MYSQLND_THREADING" = "yes"; then
-    PHP_BUILD_THREAD_SAFE
-    AC_DEFINE([MYSQLND_THREADED], 1, [Use mysqlnd internal threading])
+
+  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
+      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
 fi
 
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c
index 42fa79d..31fb47a 100644
--- a/ext/mysqlnd/mysqlnd.c
+++ b/ext/mysqlnd/mysqlnd.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd.c 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysqlnd.c 294543 2010-02-04 20:28:55Z johannes $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -27,9 +27,8 @@
 #include "mysqlnd_statistics.h"
 #include "mysqlnd_charset.h"
 #include "mysqlnd_debug.h"
-#include "mysqlnd_block_alloc.h"
 /* for php_get_current_user() */
-#include "ext/standard/basic_functions.h" 
+#include "ext/standard/basic_functions.h"
 
 /* the server doesn't support 4byte utf8, but let's make it forward compatible */
 #define MYSQLND_MAX_ALLOWED_USER_LEN	256  /* 64 char * 4byte */
@@ -58,20 +57,19 @@ extern MYSQLND_CHARSET *mysqlnd_charsets;
 
 
 
-const char * const mysqlnd_old_passwd  = "mysqlnd cannot connect to MySQL 4.1+ using old authentication";
-const char * const mysqlnd_server_gone = "MySQL server has gone away";
-const char * const mysqlnd_out_of_sync = "Commands out of sync; you can't run this command now";
+PHPAPI const char * const mysqlnd_old_passwd  = "mysqlnd cannot connect to MySQL 4.1+ using old authentication";
+PHPAPI const char * const mysqlnd_server_gone = "MySQL server has gone away";
+PHPAPI const char * const mysqlnd_out_of_sync = "Commands out of sync; you can't run this command now";
 
-MYSQLND_STATS *mysqlnd_global_stats = NULL;
+PHPAPI MYSQLND_STATS *mysqlnd_global_stats = NULL;
 static zend_bool mysqlnd_library_initted = FALSE;
 
-
 static enum_func_status mysqlnd_send_close(MYSQLND * conn TSRMLS_DC);
 
 static struct st_mysqlnd_conn_methods *mysqlnd_conn_methods;
 
 /* {{{ mysqlnd_library_end */
-void mysqlnd_library_end(TSRMLS_D)
+PHPAPI void mysqlnd_library_end(TSRMLS_D)
 {
 	if (mysqlnd_library_initted == TRUE) {
 		mysqlnd_stats_end(mysqlnd_global_stats);
@@ -147,18 +145,10 @@ MYSQLND_METHOD(mysqlnd_conn, free_contents)(MYSQLND *conn TSRMLS_DC)
 		conn->current_result = NULL;
 	}
 
-	if (conn->net.stream) {
-		DBG_INF_FMT("Freeing stream. abstract=%p", conn->net.stream->abstract);
-		if (pers) {
-			php_stream_free(conn->net.stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
-		} else {
-			php_stream_free(conn->net.stream, PHP_STREAM_FREE_CLOSE);
-		
-		}
-		conn->net.stream = NULL;
-	}
+	conn->net->m.free_contents(conn->net TSRMLS_CC);
 
 	DBG_INF("Freeing memory of members");
+
 	if (conn->host) {
 		DBG_INF("Freeing host");
 		mnd_pefree(conn->host, pers);
@@ -174,6 +164,11 @@ MYSQLND_METHOD(mysqlnd_conn, free_contents)(MYSQLND *conn TSRMLS_DC)
 		mnd_pefree(conn->passwd, pers);
 		conn->passwd = NULL;
 	}
+	if (conn->connect_or_select_db) {
+		DBG_INF("Freeing connect_or_select_db");
+		mnd_pefree(conn->connect_or_select_db, pers);
+		conn->connect_or_select_db = NULL;
+	}
 	if (conn->unix_socket) {
 		DBG_INF("Freeing unix_socket");
 		mnd_pefree(conn->unix_socket, pers);
@@ -203,26 +198,6 @@ MYSQLND_METHOD(mysqlnd_conn, free_contents)(MYSQLND *conn TSRMLS_DC)
 		mnd_pefree(conn->last_message, pers);
 		conn->last_message = NULL;
 	}
-	if (conn->zval_cache) {
-		DBG_INF("Freeing zval cache reference");
-		mysqlnd_palloc_free_thd_cache_reference(&conn->zval_cache);
-		conn->zval_cache = NULL;
-	}
-	if (conn->result_set_memory_pool) {
-		mysqlnd_mempool_destroy(conn->result_set_memory_pool TSRMLS_CC);
-		conn->result_set_memory_pool = NULL;
-	}
-	if (conn->qcache) {
-		DBG_INF("Freeing qcache reference");
-		mysqlnd_qcache_free_cache_reference(&conn->qcache);
-		conn->qcache = NULL;
-	}
-	if (conn->net.cmd_buffer.buffer) {
-		DBG_INF("Freeing cmd buffer");
-		mnd_pefree(conn->net.cmd_buffer.buffer, pers);
-		conn->net.cmd_buffer.buffer = NULL;
-	}
-
 	conn->charset = NULL;
 	conn->greet_charset = NULL;
 
@@ -241,21 +216,21 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_conn, dtor)(MYSQLND *conn TSRMLS_DC)
 	conn->m->free_contents(conn TSRMLS_CC);
 	conn->m->free_options(conn TSRMLS_CC);
 
-#ifdef MYSQLND_THREADED
-	if (conn->thread_is_running) {
-		pthread_mutex_lock(&conn->LOCK_work);
-		conn->thread_killed = TRUE;
-		pthread_cond_signal(&conn->COND_work);
-		pthread_cond_wait(&conn->COND_thread_ended, &conn->LOCK_work);
-		pthread_mutex_unlock(&conn->LOCK_work);
+	if (conn->net) {
+		DBG_INF("Freeing net");
+		mysqlnd_net_free(conn->net TSRMLS_CC);
+		conn->net = NULL;
 	}
 
-	tsrm_mutex_free(conn->LOCK_state);
+	if (conn->protocol) {
+		DBG_INF("Freeing protocol");
+		mysqlnd_protocol_free(conn->protocol TSRMLS_CC);
+		conn->protocol = NULL;
+	}
 
-	pthread_cond_destroy(&conn->COND_work);
-	pthread_cond_destroy(&conn->COND_work_done);
-	pthread_mutex_destroy(&conn->LOCK_work);
-#endif
+	if (conn->stats) {
+		mysqlnd_stats_end(conn->stats);
+	}
 
 	mnd_pefree(conn, conn->persistent);
 
@@ -264,23 +239,21 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_conn, dtor)(MYSQLND *conn TSRMLS_DC)
 /* }}} */
 
 
-/* {{{ mysqlnd_simple_command_handle_response */
-enum_func_status
-mysqlnd_simple_command_handle_response(MYSQLND *conn, enum php_mysql_packet_type ok_packet,
-									   zend_bool silent, enum php_mysqlnd_server_command command,
-									   zend_bool ignore_upsert_status
-									   TSRMLS_DC)
+/* {{{ mysqlnd_conn::simple_command_handle_response */
+static enum_func_status
+MYSQLND_METHOD(mysqlnd_conn, simple_command_handle_response)(MYSQLND *conn, enum mysqlnd_packet_type ok_packet,
+									   						 zend_bool silent, enum php_mysqlnd_server_command command,
+									   						 zend_bool ignore_upsert_status TSRMLS_DC)
 {
 	enum_func_status ret;
 
-	DBG_ENTER("mysqlnd_simple_command_handle_response");
+	DBG_ENTER("mysqlnd_conn::simple_command_handle_response");
 	DBG_INF_FMT("silent=%d packet=%d command=%s", silent, ok_packet, mysqlnd_command_to_text[command]);
 
 	switch (ok_packet) {
 		case PROT_OK_PACKET:{
-			php_mysql_packet_ok ok_response;
-			PACKET_INIT_ALLOCA(ok_response, PROT_OK_PACKET);
-			if (FAIL == (ret = PACKET_READ_ALLOCA(ok_response, conn))) {
+			MYSQLND_PACKET_OK * ok_response = conn->protocol->m.get_ok_packet(conn->protocol, FALSE TSRMLS_CC);
+			if (FAIL == (ret = PACKET_READ(ok_response, conn))) {
 				if (!silent) {
 					DBG_ERR_FMT("Error while reading %s's OK packet", mysqlnd_command_to_text[command]);
 					php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while reading %s's OK packet. PID=%d",
@@ -288,10 +261,9 @@ mysqlnd_simple_command_handle_response(MYSQLND *conn, enum php_mysql_packet_type
 				}
 			} else {
 				DBG_INF_FMT("OK from server");
-				if (0xFF == ok_response.field_count) {
+				if (0xFF == ok_response->field_count) {
 					/* The server signalled error. Set the error */
-					SET_CLIENT_ERROR(conn->error_info, ok_response.error_no,
-									 ok_response.sqlstate, ok_response.error); 
+					SET_CLIENT_ERROR(conn->error_info, ok_response->error_no, ok_response->sqlstate, ok_response->error);
 					ret = FAIL;
 					/*
 					  Cover a protocol design error: error packet does not
@@ -306,24 +278,23 @@ mysqlnd_simple_command_handle_response(MYSQLND *conn, enum php_mysql_packet_type
 					SET_ERROR_AFF_ROWS(conn);
 				} else {
 					SET_NEW_MESSAGE(conn->last_message, conn->last_message_len,
-									ok_response.message, ok_response.message_len,
+									ok_response->message, ok_response->message_len,
 									conn->persistent);
 
 					if (!ignore_upsert_status) {
-						conn->upsert_status.warning_count = ok_response.warning_count;
-						conn->upsert_status.server_status = ok_response.server_status;
-						conn->upsert_status.affected_rows = ok_response.affected_rows;
-						conn->upsert_status.last_insert_id = ok_response.last_insert_id;
+						conn->upsert_status.warning_count = ok_response->warning_count;
+						conn->upsert_status.server_status = ok_response->server_status;
+						conn->upsert_status.affected_rows = ok_response->affected_rows;
+						conn->upsert_status.last_insert_id = ok_response->last_insert_id;
 					}
 				}
 			}
-			PACKET_FREE_ALLOCA(ok_response);
+			PACKET_FREE(ok_response);
 			break;
 		}
 		case PROT_EOF_PACKET:{
-			php_mysql_packet_eof ok_response;
-			PACKET_INIT_ALLOCA(ok_response, PROT_EOF_PACKET);
-			if (FAIL == (ret = PACKET_READ_ALLOCA(ok_response, conn))) {
+			MYSQLND_PACKET_EOF * ok_response = conn->protocol->m.get_eof_packet(conn->protocol, FALSE TSRMLS_CC);
+			if (FAIL == (ret = PACKET_READ(ok_response, conn))) {
 				SET_CLIENT_ERROR(conn->error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE,
 								 "Malformed packet");
 				if (!silent) {
@@ -331,24 +302,23 @@ mysqlnd_simple_command_handle_response(MYSQLND *conn, enum php_mysql_packet_type
 					php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while reading %s's EOF packet. PID=%d",
 								 	mysqlnd_command_to_text[command], getpid());
 				}
-			} else if (0xFF == ok_response.field_count) {
+			} else if (0xFF == ok_response->field_count) {
 				/* The server signalled error. Set the error */
-				SET_CLIENT_ERROR(conn->error_info, ok_response.error_no,
-								 ok_response.sqlstate, ok_response.error);
+				SET_CLIENT_ERROR(conn->error_info, ok_response->error_no, ok_response->sqlstate, ok_response->error);
 				SET_ERROR_AFF_ROWS(conn);
-			} else if (0xFE != ok_response.field_count) {
+			} else if (0xFE != ok_response->field_count) {
 				SET_CLIENT_ERROR(conn->error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE,
 								 "Malformed packet");
 				if (!silent) {
-					DBG_ERR_FMT("EOF packet expected, field count wasn't 0xFE but 0x%2X", ok_response.field_count);
+					DBG_ERR_FMT("EOF packet expected, field count wasn't 0xFE but 0x%2X", ok_response->field_count);
 					php_error_docref(NULL TSRMLS_CC, E_WARNING,
 									"EOF packet expected, field count wasn't 0xFE but 0x%2X",
-									ok_response.field_count);
+									ok_response->field_count);
 				}
 			} else {
 				DBG_INF_FMT("OK from server");
 			}
-			PACKET_FREE_ALLOCA(ok_response);
+			PACKET_FREE(ok_response);
 			break;
 		}
 		default:
@@ -365,17 +335,16 @@ mysqlnd_simple_command_handle_response(MYSQLND *conn, enum php_mysql_packet_type
 /* }}} */
 
 
-/* {{{ mysqlnd_simple_command */
-enum_func_status
-mysqlnd_simple_command(MYSQLND *conn, enum php_mysqlnd_server_command command,
-					   const char * const arg, size_t arg_len,
-					   enum php_mysql_packet_type ok_packet, zend_bool silent, 
-					   zend_bool ignore_upsert_status TSRMLS_DC)
+/* {{{ mysqlnd_conn::simple_command */
+static enum_func_status
+MYSQLND_METHOD(mysqlnd_conn, simple_command)(MYSQLND *conn, enum php_mysqlnd_server_command command,
+			   const char * const arg, size_t arg_len, enum mysqlnd_packet_type ok_packet, zend_bool silent,
+			   zend_bool ignore_upsert_status TSRMLS_DC)
 {
 	enum_func_status ret = PASS;
-	php_mysql_packet_command cmd_packet;
+	MYSQLND_PACKET_COMMAND * cmd_packet;
 
-	DBG_ENTER("mysqlnd_simple_command");
+	DBG_ENTER("mysqlnd_conn::simple_command");
 	DBG_INF_FMT("command=%s ok_packet=%d silent=%d", mysqlnd_command_to_text[command], ok_packet, silent);
 
 	switch (CONN_GET_STATE(conn)) {
@@ -399,14 +368,16 @@ mysqlnd_simple_command(MYSQLND *conn, enum php_mysqlnd_server_command command,
 	SET_ERROR_AFF_ROWS(conn);
 	SET_EMPTY_ERROR(conn->error_info);
 
-	PACKET_INIT_ALLOCA(cmd_packet, PROT_CMD_PACKET);
-	cmd_packet.command = command;
+	cmd_packet = conn->protocol->m.get_command_packet(conn->protocol, FALSE TSRMLS_CC);
+	cmd_packet->command = command;
 	if (arg && arg_len) {
-		cmd_packet.argument = arg;
-		cmd_packet.arg_len  = arg_len;
+		cmd_packet->argument = arg;
+		cmd_packet->arg_len  = arg_len;
 	}
 
-	if (! PACKET_WRITE_ALLOCA(cmd_packet, conn)) {
+	MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_COM_QUIT + command - 1 /* because of COM_SLEEP */ );
+
+	if (! PACKET_WRITE(cmd_packet, conn)) {
 		if (!silent) {
 			DBG_ERR_FMT("Error while sending %s packet", mysqlnd_command_to_text[command]);
 			php_error(E_WARNING, "Error while sending %s packet. PID=%d", mysqlnd_command_to_text[command], getpid());
@@ -414,15 +385,10 @@ mysqlnd_simple_command(MYSQLND *conn, enum php_mysqlnd_server_command command,
 		DBG_ERR("Server is gone");
 		ret = FAIL;
 	} else if (ok_packet != PROT_LAST) {
-		ret = mysqlnd_simple_command_handle_response(conn, ok_packet, silent, command, ignore_upsert_status TSRMLS_CC);
+		ret = conn->m->simple_command_handle_response(conn, ok_packet, silent, command, ignore_upsert_status TSRMLS_CC);
 	}
 
-	/*
-	  There is no need to call FREE_ALLOCA on cmd_packet as the
-	  only allocated string is cmd_packet.argument and it was passed
-	  to us. We should not free it.
-	*/
-
+	PACKET_FREE(cmd_packet);
 	DBG_INF(ret == PASS ? "PASS":"FAIL");
 	DBG_RETURN(ret);
 }
@@ -431,36 +397,24 @@ mysqlnd_simple_command(MYSQLND *conn, enum php_mysqlnd_server_command command,
 
 /* {{{ mysqlnd_conn::set_server_option */
 static enum_func_status
-MYSQLND_METHOD(mysqlnd_conn, set_server_option)(MYSQLND * const conn,
-												enum_mysqlnd_server_option option TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_conn, set_server_option)(MYSQLND * const conn, enum_mysqlnd_server_option option TSRMLS_DC)
 {
 	enum_func_status ret;
 	char buffer[2];
 	DBG_ENTER("mysqlnd_conn::set_server_option");
 
 	int2store(buffer, (unsigned int) option);
-	ret = mysqlnd_simple_command(conn, COM_SET_OPTION, buffer, sizeof(buffer),
-								 PROT_EOF_PACKET, FALSE, TRUE TSRMLS_CC);
+	ret = conn->m->simple_command(conn, COM_SET_OPTION, buffer, sizeof(buffer), PROT_EOF_PACKET, FALSE, TRUE TSRMLS_CC);
 	DBG_RETURN(ret);
 }
 /* }}} */
 
 
 /* {{{ _mysqlnd_restart_psession */
-PHPAPI void _mysqlnd_restart_psession(MYSQLND *conn, MYSQLND_THD_ZVAL_PCACHE *cache TSRMLS_DC) 
+PHPAPI void _mysqlnd_restart_psession(MYSQLND *conn TSRMLS_DC)
 {
 	DBG_ENTER("_mysqlnd_restart_psession");
-	MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_CONNECT_REUSED);
-	/* Free here what should not be seen by the next script */
-	if (conn->last_message) {
-		mnd_pefree(conn->last_message, conn->persistent);
-		conn->last_message = NULL;
-	}
-	/*
-	  The thd zval cache is always freed on request shutdown, so this has happened already.
-	  Don't touch the old value! Get new reference
-	*/
-	conn->zval_cache = mysqlnd_palloc_get_thd_cache_reference(cache);
+	conn->m->restart_psession(conn TSRMLS_CC);
 	DBG_VOID_RETURN;
 }
 /* }}} */
@@ -470,40 +424,62 @@ PHPAPI void _mysqlnd_restart_psession(MYSQLND *conn, MYSQLND_THD_ZVAL_PCACHE *ca
 PHPAPI void _mysqlnd_end_psession(MYSQLND *conn TSRMLS_DC)
 {
 	DBG_ENTER("_mysqlnd_end_psession");
-	/* The thd zval cache is always freed on request shutdown, so this has happened already */
-	mysqlnd_palloc_free_thd_cache_reference(&conn->zval_cache);
+	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)
+{
+	DBG_ENTER("mysqlnd_conn::restart_psession");
+	MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_CONNECT_REUSED);
+	/* Free here what should not be seen by the next script */
+	if (conn->last_message) {
+		mnd_pefree(conn->last_message, conn->persistent);
+		conn->last_message = NULL;
+	}
+	DBG_RETURN(PASS);
+}
+/* }}} */
+
 
-/* {{{ mysqlnd_connect */
-PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
+/* {{{ mysqlnd_conn::end_psession */
+static enum_func_status
+MYSQLND_METHOD(mysqlnd_conn, end_psession)(MYSQLND * conn TSRMLS_DC)
+{
+	DBG_ENTER("mysqlnd_conn::end_psession");
+	DBG_RETURN(PASS);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_conn::connect */
+static enum_func_status
+MYSQLND_METHOD(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,
-						 MYSQLND_THD_ZVAL_PCACHE *zval_cache
+						 unsigned int mysql_flags
 						 TSRMLS_DC)
 {
 	char *transport = NULL, *errstr = NULL;
-	char *hashed_details = NULL;
-	int transport_len, hashed_details_len, errcode = 0, host_len;
-	unsigned int streams_options = ENFORCE_SAFE_MODE;
-	unsigned int streams_flags = STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT;
+	int transport_len, errcode = 0, host_len;
 	zend_bool self_alloced = FALSE;
-	struct timeval tv;
 	zend_bool unix_socket = FALSE;
 	const MYSQLND_CHARSET * charset;
 	zend_bool reconnect = FALSE;
+	zend_bool saved_compression = FALSE;
 
-	php_mysql_packet_greet greet_packet;
-	php_mysql_packet_auth *auth_packet;
-	php_mysql_packet_ok ok_packet;
+	MYSQLND_PACKET_GREET * greet_packet = NULL;
+	MYSQLND_PACKET_AUTH * auth_packet = NULL;
+	MYSQLND_PACKET_OK * ok_packet = NULL;
+
+	DBG_ENTER("mysqlnd_conn::connect");
 
-	DBG_ENTER("mysqlnd_connect");
 	DBG_INF_FMT("host=%s user=%s db=%s port=%d flags=%d persistent=%d state=%d",
 				host?host:"", user?user:"", db?db:"", port, mysql_flags,
 				conn? conn->persistent:0, conn? CONN_GET_STATE(conn):-1);
@@ -513,17 +489,26 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
 		DBG_INF("Connecting on a connected handle.");
 
 		if (CONN_GET_STATE(conn) < CONN_QUIT_SENT) {
-			MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_CLOSE_IMPLICIT);
+			MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_CLOSE_IMPLICIT);
 			reconnect = TRUE;
 			mysqlnd_send_close(conn TSRMLS_CC);
 		}
 
 		conn->m->free_contents(conn TSRMLS_CC);
-		MYSQLND_DEC_CONN_STATISTIC(&conn->stats, STAT_OPENED_CONNECTIONS);
+		MYSQLND_DEC_CONN_STATISTIC(conn->stats, STAT_OPENED_CONNECTIONS);
 		if (conn->persistent) {
-			MYSQLND_DEC_CONN_STATISTIC(&conn->stats, STAT_OPENED_PERSISTENT_CONNECTIONS);
+			MYSQLND_DEC_CONN_STATISTIC(conn->stats, STAT_OPENED_PERSISTENT_CONNECTIONS);
 		}
 		/* Now reconnect using the same handle */
+		if (conn->net->compressed) {
+			/*
+			  we need to save the state. As we will re-connect, net->compressed should be off, or
+			  we will look for a compression header as part of the greet message, but there will
+			  be none.
+			*/
+			saved_compression = TRUE;
+			conn->net->compressed = FALSE;
+		}
 	}
 
 	if (!host || !host[0]) {
@@ -551,123 +536,54 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
 		}
 		transport_len = spprintf(&transport, 0, "unix://%s", socket);
 		unix_socket = TRUE;
-	} else 
+	} else
 #endif
 	{
 		transport_len = spprintf(&transport, 0, "tcp://%s:%d", host, port);
 	}
-	DBG_INF_FMT("transport=%p", transport);
+	DBG_INF_FMT("transport=%s", transport);
 
 
-	PACKET_INIT_ALLOCA(greet_packet, PROT_GREET_PACKET);
-	PACKET_INIT(auth_packet, PROT_AUTH_PACKET, php_mysql_packet_auth *, FALSE);
-	PACKET_INIT_ALLOCA(ok_packet, PROT_OK_PACKET);
-
-	if (!conn) {
-		conn = mysqlnd_init(FALSE);
-		self_alloced = TRUE;
-	}
+	greet_packet = conn->protocol->m.get_greet_packet(conn->protocol, FALSE TSRMLS_CC);
+	auth_packet = conn->protocol->m.get_auth_packet(conn->protocol, FALSE TSRMLS_CC);
+	ok_packet = conn->protocol->m.get_ok_packet(conn->protocol, FALSE TSRMLS_CC);
 
 	if (conn->persistent) {
-		hashed_details_len = spprintf(&hashed_details, 0, "%p", conn);
-		DBG_INF_FMT("hashed_details=%s", hashed_details);
-	} 
-
-	CONN_SET_STATE(conn, CONN_ALLOCED);
-	conn->net.packet_no = 0;
-
-	if (conn->options.timeout_connect) {
-		tv.tv_sec = conn->options.timeout_connect;
-		tv.tv_usec = 0;
-	}
-	if (conn->persistent) {
 		conn->scheme = pestrndup(transport, transport_len, 1);
 		mnd_efree(transport);
 	} else {
 		conn->scheme = transport;
 	}
+	conn->scheme_len = transport_len;
 	DBG_INF(conn->scheme);
-	conn->net.stream = php_stream_xport_create(conn->scheme, transport_len, streams_options, streams_flags,
-											   hashed_details, 
-											   (conn->options.timeout_connect) ? &tv : NULL,
-											    NULL /*ctx*/, &errstr, &errcode);
-	DBG_INF_FMT("stream=%p", conn->net.stream);
-
-	if (errstr || !conn->net.stream) {
-		if (hashed_details) {
-			mnd_efree(hashed_details);
-		}
-		errcode = CR_CONNECTION_ERROR;
-		goto err;
-	}
-
-	if (hashed_details) {
-		/*
-		  If persistent, the streams register it in EG(persistent_list).
-		  This is unwanted. ext/mysql or ext/mysqli are responsible to clean,
-		  whatever they have to.
-		*/
-		zend_rsrc_list_entry *le;
-
-		if (zend_hash_find(&EG(persistent_list), hashed_details, hashed_details_len + 1,
-						   (void*) &le) == SUCCESS) {
-			/*
-			  in_free will let streams code skip destructing - big HACK,
-			  but STREAMS suck big time regarding persistent streams.
-			  Just not compatible for extensions that need persistency.
-			*/
-			conn->net.stream->in_free = 1;
-			zend_hash_del(&EG(persistent_list), hashed_details, hashed_details_len + 1);
-			conn->net.stream->in_free = 0;
-		}
-#if ZEND_DEBUG
-		/* Shut-up the streams, they don't know what they are doing */
-		conn->net.stream->__exposed = 1;
-#endif
-		mnd_efree(hashed_details);
-	}
-
-	if (!conn->options.timeout_read) {
-		/* should always happen because read_timeout cannot be set via API */
-		conn->options.timeout_read = (unsigned int) MYSQLND_G(net_read_timeout);
-	}
-	if (conn->options.timeout_read)
-	{
-		tv.tv_sec = conn->options.timeout_read;
-		tv.tv_usec = 0;
-		php_stream_set_option(conn->net.stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv);
+	if (FAIL == conn->net->m.connect(conn->net, conn->scheme, transport_len, conn->persistent, &errstr, &errcode TSRMLS_CC)) {
+		goto err;	
 	}
 
-	if (!unix_socket) {
-		/* Set TCP_NODELAY */
-		mysqlnd_set_sock_no_delay(conn->net.stream);
-	}
+	DBG_INF_FMT("stream=%p", conn->net->stream);
 
-	if (FAIL == PACKET_READ_ALLOCA(greet_packet, conn)) {
+	if (FAIL == PACKET_READ(greet_packet, conn)) {
 		DBG_ERR("Error while reading greeting packet");
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while reading greeting packet. PID=%d", getpid());
 		goto err;
-	} else if (greet_packet.error_no) {
-		DBG_ERR_FMT("errorno=%d error=%s", greet_packet.error_no, greet_packet.error);
-		SET_CLIENT_ERROR(conn->error_info, greet_packet.error_no,
-						 greet_packet.sqlstate, greet_packet.error);
-		goto err;	
-	} else if (greet_packet.pre41) {
-		DBG_ERR_FMT("Connecting to 3.22, 3.23 & 4.0 is not supported. Server is %-.32s",
-					greet_packet.server_version);
+	} else if (greet_packet->error_no) {
+		DBG_ERR_FMT("errorno=%d error=%s", greet_packet->error_no, greet_packet->error);
+		SET_CLIENT_ERROR(conn->error_info, greet_packet->error_no, greet_packet->sqlstate, greet_packet->error);
+		goto err;
+	} else if (greet_packet->pre41) {
+		DBG_ERR_FMT("Connecting to 3.22, 3.23 & 4.0 is not supported. Server is %-.32s", greet_packet->server_version);
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connecting to 3.22, 3.23 & 4.0 "
-						" is not supported. Server is %-.32s", greet_packet.server_version);
+						" is not supported. Server is %-.32s", greet_packet->server_version);
 		SET_CLIENT_ERROR(conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE,
 						 "Connecting to 3.22, 3.23 & 4.0 servers is not supported");
 		goto err;
 	}
 
-	conn->thread_id			= greet_packet.thread_id;
-	conn->protocol_version	= greet_packet.protocol_version;
-	conn->server_version	= greet_packet.server_version;
-	greet_packet.server_version = NULL; /* The string will be freed otherwise */
+	conn->thread_id			= greet_packet->thread_id;
+	conn->protocol_version	= greet_packet->protocol_version;
+	conn->server_version	= pestrdup(greet_packet->server_version, conn->persistent);
 
-	conn->greet_charset = mysqlnd_find_charset_nr(greet_packet.charset_no);
+	conn->greet_charset = mysqlnd_find_charset_nr(greet_packet->charset_no);
 	/* we allow load data local infile by default */
 	mysql_flags  |= CLIENT_LOCAL_FILES | CLIENT_PS_MULTI_RESULTS;
 #ifndef MYSQLND_COMPRESSION_ENABLED
@@ -687,7 +603,7 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
 #if PHP_MAJOR_VERSION >= 6
 		auth_packet->charset_no	= 200;/* utf8 - swedish collation, check mysqlnd_charset.c */
 #else
-		auth_packet->charset_no	= greet_packet.charset_no;
+		auth_packet->charset_no	= greet_packet->charset_no;
 #endif
 	}
 	auth_packet->db			= db;
@@ -696,42 +612,56 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
 	auth_packet->client_flags= mysql_flags;
 
 	conn->scramble = auth_packet->server_scramble_buf = mnd_pemalloc(SCRAMBLE_LENGTH, conn->persistent);
-	memcpy(auth_packet->server_scramble_buf, greet_packet.scramble_buf, SCRAMBLE_LENGTH);
+	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);
-		goto err;	
+		goto err;
 	}
 
-	if (FAIL == PACKET_READ_ALLOCA(ok_packet, conn) || ok_packet.field_count >= 0xFE) {
-		if (ok_packet.field_count == 0xFE) {
+	if (FAIL == PACKET_READ(ok_packet, conn) || ok_packet->field_count >= 0xFE) {
+		if (ok_packet->field_count == 0xFE) {
 			/* old authentication with new server  !*/
 			DBG_ERR(mysqlnd_old_passwd);
 			SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd);
-		} else if (ok_packet.field_count == 0xFF) {
-			if (ok_packet.sqlstate[0]) {
+		} else if (ok_packet->field_count == 0xFF) {
+			if (ok_packet->sqlstate[0]) {
 				if (!self_alloced) {
-					strlcpy(conn->error_info.sqlstate, ok_packet.sqlstate, sizeof(conn->error_info.sqlstate));
+					strlcpy(conn->error_info.sqlstate, ok_packet->sqlstate, sizeof(conn->error_info.sqlstate));
 				}
-				DBG_ERR_FMT("ERROR:%d [SQLSTATE:%s] %s",
-							ok_packet.error_no, ok_packet.sqlstate, ok_packet.error);
+				DBG_ERR_FMT("ERROR:%d [SQLSTATE:%s] %s", ok_packet->error_no, ok_packet->sqlstate, ok_packet->error);
 			}
 			if (!self_alloced) {
-				conn->error_info.error_no = ok_packet.error_no;
-				strlcpy(conn->error_info.error, ok_packet.error, sizeof(conn->error_info.error));
+				conn->error_info.error_no = ok_packet->error_no;
+				strlcpy(conn->error_info.error, ok_packet->error, sizeof(conn->error_info.error));
 			}
 		}
 	} else {
 		CONN_SET_STATE(conn, CONN_READY);
+		if (!self_alloced && saved_compression) {
+			conn->net->compressed = TRUE;
+		}
+		/*
+		  If a connect on a existing handle is performed and mysql_flags is
+		  passed which doesn't CLIENT_COMPRESS, then we need to overwrite the value
+		  which we set based on saved_compression.
+		*/
+		conn->net->compressed = mysql_flags & CLIENT_COMPRESS? TRUE:FALSE;
 
 		conn->user				= pestrdup(user, conn->persistent);
+		conn->user_len			= strlen(conn->user);
 		conn->passwd			= pestrndup(passwd, passwd_len, conn->persistent);
+		conn->passwd_len		= passwd_len;
 		conn->port				= port;
-		if (host && !socket) {
+		conn->connect_or_select_db = pestrndup(db, db_len, conn->persistent);
+		conn->connect_or_select_db_len = db_len;
+
+		if (!unix_socket) {
 			char *p;
 
 			conn->host = pestrdup(host, conn->persistent);
-			spprintf(&p, 0, "MySQL host info: %s via TCP/IP", conn->host);
+			conn->host_len = strlen(conn->host);
+			spprintf(&p, 0, "%s via TCP/IP", conn->host);
 			if (conn->persistent) {
 				conn->host_info = pestrdup(p, 1);
 				mnd_efree(p);
@@ -740,46 +670,38 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
 			}
 		} else {
 			conn->unix_socket	= pestrdup(socket, conn->persistent);
-			conn->host_info		= pestrdup("MySQL host info: Localhost via UNIX socket", conn->persistent);
+			conn->unix_socket_len = strlen(conn->unix_socket);
+			conn->host_info		= pestrdup("Localhost via UNIX socket", conn->persistent);
 		}
 		conn->client_flag		= auth_packet->client_flags;
 		conn->max_packet_size	= auth_packet->max_packet_size;
 		/* todo: check if charset is available */
 		conn->charset			= mysqlnd_find_charset_nr(auth_packet->charset_no);
-		conn->server_capabilities = greet_packet.server_capabilities;
+		conn->server_capabilities = greet_packet->server_capabilities;
 		conn->upsert_status.warning_count = 0;
-		conn->upsert_status.server_status = greet_packet.server_status;
+		conn->upsert_status.server_status = greet_packet->server_status;
 		conn->upsert_status.affected_rows = 0;
 		SET_NEW_MESSAGE(conn->last_message, conn->last_message_len,
-						ok_packet.message, ok_packet.message_len,
+						ok_packet->message, ok_packet->message_len,
 						conn->persistent);
 
 		SET_EMPTY_ERROR(conn->error_info);
 
-		conn->zval_cache = mysqlnd_palloc_get_thd_cache_reference(zval_cache);
-
 		mysqlnd_local_infile_default(conn);
 		{
-			unsigned int buf_size;
-			buf_size = MYSQLND_G(net_read_buffer_size); /* this is long, cast to unsigned int*/
-			conn->m->set_client_option(conn, MYSQLND_OPT_NET_READ_BUFFER_SIZE,
-								   		(char *)&buf_size TSRMLS_CC);
-
-			buf_size = MYSQLND_G(net_cmd_buffer_size); /* this is long, cast to unsigned int*/
-			conn->m->set_client_option(conn, MYSQLND_OPT_NET_CMD_BUFFER_SIZE,
-								   		(char *)&buf_size TSRMLS_CC);			
+			unsigned int buf_size = MYSQLND_G(net_cmd_buffer_size); /* this is long, cast to unsigned int*/
+			conn->m->set_client_option(conn, MYSQLND_OPT_NET_CMD_BUFFER_SIZE, (char *)&buf_size TSRMLS_CC);
 		}
 
-		MYSQLND_INC_CONN_STATISTIC_W_VALUE2(&conn->stats, STAT_CONNECT_SUCCESS, 1, STAT_OPENED_CONNECTIONS, 1);
+		MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn->stats, STAT_CONNECT_SUCCESS, 1, STAT_OPENED_CONNECTIONS, 1);
 		if (reconnect) {
-			MYSQLND_INC_GLOBAL_STATISTIC(STAT_RECONNECT);	
+			MYSQLND_INC_GLOBAL_STATISTIC(STAT_RECONNECT);
 		}
 		if (conn->persistent) {
-			MYSQLND_INC_CONN_STATISTIC_W_VALUE2(&conn->stats, STAT_PCONNECT_SUCCESS, 1, STAT_OPENED_PERSISTENT_CONNECTIONS, 1);
+			MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn->stats, STAT_PCONNECT_SUCCESS, 1, STAT_OPENED_PERSISTENT_CONNECTIONS, 1);
 		}
 
 		DBG_INF_FMT("connection_id=%llu", conn->thread_id);
-		conn->result_set_memory_pool = mysqlnd_mempool_create(16000 TSRMLS_CC);
 #if PHP_MAJOR_VERSION >= 6
 		{
 			unsigned int as_unicode = 1;
@@ -788,29 +710,14 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
 			DBG_INF("unicode set");
 		}
 #endif
-#ifdef MYSQLND_THREADED
-		{
-			pthread_t th;
-			pthread_attr_t connection_attrib;
-			conn->tsrm_ls = tsrm_ls;
-
-			pthread_attr_init(&connection_attrib);
-			pthread_attr_setdetachstate(&connection_attrib, PTHREAD_CREATE_DETACHED);
-
-			conn->thread_is_running = TRUE;
-			if (pthread_create(&th, &connection_attrib, mysqlnd_fetch_thread, (void*)conn)) {
-				conn->thread_is_running = FALSE;
-			}
-		}
-#endif
 
 		if (conn->options.init_commands) {
 			int current_command = 0;
 			for (; current_command < conn->options.num_commands; ++current_command) {
 				const char * const command = conn->options.init_commands[current_command];
-				MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_INIT_COMMAND_EXECUTED_COUNT);
+				MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_INIT_COMMAND_EXECUTED_COUNT);
 				if (PASS != conn->m->query(conn, command, strlen(command) TSRMLS_CC)) {
-					MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_INIT_COMMAND_FAILED_COUNT);
+					MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_INIT_COMMAND_FAILED_COUNT);
 					goto err;
 				}
 				if (conn->last_query_type == QUERY_SELECT) {
@@ -820,16 +727,16 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
 			}
 		}
 
-		PACKET_FREE_ALLOCA(greet_packet);
+		PACKET_FREE(greet_packet);
 		PACKET_FREE(auth_packet);
-		PACKET_FREE_ALLOCA(ok_packet);
+		PACKET_FREE(ok_packet);
 
-		DBG_RETURN(conn);
+		DBG_RETURN(PASS);
 	}
 err:
-	PACKET_FREE_ALLOCA(greet_packet);
+	PACKET_FREE(greet_packet);
 	PACKET_FREE(auth_packet);
-	PACKET_FREE_ALLOCA(ok_packet);
+	PACKET_FREE(ok_packet);
 
 	if (errstr) {
 		DBG_ERR_FMT("[%d] %.64s (trying to connect via %s)", errcode, errstr, conn->scheme);
@@ -844,24 +751,56 @@ err:
 		conn->scheme = NULL;
 	}
 
-	if (self_alloced) {
-		/*
-		  We have alloced, thus there are no references to this
-		  object - we are free to kill it!
-		*/
-		conn->m->dtor(conn TSRMLS_CC);
-	} else {
-		/* This will also close conn->net.stream if it has been opened */
-		conn->m->free_contents(conn TSRMLS_CC);
-		MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_CONNECT_FAILURE);
+	MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_CONNECT_FAILURE);
+
+	DBG_RETURN(FAIL);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_connect */
+PHPAPI MYSQLND * mysqlnd_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)
+{
+	enum_func_status ret;
+	zend_bool self_alloced = FALSE;
+
+	DBG_ENTER("mysqlnd_connect");
+	DBG_INF_FMT("host=%s user=%s db=%s port=%d flags=%d", host?host:"", user?user:"", db?db:"", port, mysql_flags);
+
+	if (!conn) {
+		conn = mysqlnd_init(FALSE);
+		self_alloced = TRUE;
+	}
+
+	ret = conn->m->connect(conn, host, user, passwd, passwd_len, db, db_len, port, socket, mysql_flags TSRMLS_CC);
+
+	if (ret == FAIL) {
+		if (self_alloced) {
+			/*
+			  We have alloced, thus there are no references to this
+			  object - we are free to kill it!
+			*/
+			conn->m->dtor(conn TSRMLS_CC);
+		} else {
+			/* This will also close conn->net->stream if it has been opened */
+			conn->m->free_contents(conn TSRMLS_CC);
+		}
+		DBG_RETURN(NULL);
 	}
-	DBG_RETURN(NULL);
+	DBG_RETURN(conn);
 }
 /* }}} */
 
 
 /* {{{ mysqlnd_conn::query */
-/* 
+/*
   If conn->error_info.error_no is not zero, then we had an error.
   Still the result from the query is PASS
 */
@@ -872,7 +811,7 @@ MYSQLND_METHOD(mysqlnd_conn, query)(MYSQLND *conn, const char *query, unsigned i
 	DBG_ENTER("mysqlnd_conn::query");
 	DBG_INF_FMT("conn=%llu query=%s", conn->thread_id, query);
 
-	if (PASS != mysqlnd_simple_command(conn, COM_QUERY, query, query_len,
+	if (PASS != conn->m->simple_command(conn, COM_QUERY, query, query_len,
 									   PROT_LAST /* we will handle the OK packet*/,
 									   FALSE, FALSE TSRMLS_CC)) {
 		DBG_RETURN(FAIL);
@@ -882,7 +821,11 @@ MYSQLND_METHOD(mysqlnd_conn, query)(MYSQLND *conn, const char *query, unsigned i
 	  Here read the result set. We don't do it in simple_command because it need
 	  information from the ok packet. We will fetch it ourselves.
 	*/
-	ret = mysqlnd_query_read_result_set_header(conn, NULL TSRMLS_CC);
+	ret = conn->m->query_read_result_set_header(conn, NULL TSRMLS_CC);
+	if (ret == PASS && conn->last_query_type == QUERY_UPSERT && conn->upsert_status.affected_rows) {
+		MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats, STAT_ROWS_AFFECTED_NORMAL, conn->upsert_status.affected_rows);
+	}
+
 	DBG_RETURN(ret);
 }
 /* }}} */
@@ -896,7 +839,7 @@ MYSQLND_METHOD(mysqlnd_conn, send_query)(MYSQLND *conn, const char *query, unsig
 	DBG_ENTER("mysqlnd_conn::send_query");
 	DBG_INF_FMT("conn=%llu query=%s", conn->thread_id, query);
 
-	ret = mysqlnd_simple_command(conn, COM_QUERY, query, query_len,
+	ret = conn->m->simple_command(conn, COM_QUERY, query, query_len,
 								 PROT_LAST /* we will handle the OK packet*/,
 								 FALSE, FALSE TSRMLS_CC);
 	CONN_SET_STATE(conn, CONN_QUERY_SENT);
@@ -904,7 +847,8 @@ MYSQLND_METHOD(mysqlnd_conn, send_query)(MYSQLND *conn, const char *query, unsig
 }
 /* }}} */
 
-/* {{{ mysqlnd_conn::send_query */
+
+/* {{{ mysqlnd_conn::reap_query */
 static enum_func_status
 MYSQLND_METHOD(mysqlnd_conn, reap_query)(MYSQLND * conn TSRMLS_DC)
 {
@@ -914,9 +858,10 @@ MYSQLND_METHOD(mysqlnd_conn, reap_query)(MYSQLND * conn TSRMLS_DC)
 
 	if (state <= CONN_READY || state == CONN_QUIT_SENT) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connection not opened, clear or has been closed");
-		DBG_RETURN(FAIL);	
+		DBG_ERR_FMT("Connection not opened, clear or has been closed. State=%d", state);
+		DBG_RETURN(FAIL);
 	}
-	DBG_RETURN(mysqlnd_query_read_result_set_header(conn, NULL TSRMLS_CC));
+	DBG_RETURN(conn->m->query_read_result_set_header(conn, NULL TSRMLS_CC));
 }
 /* }}} */
 
@@ -949,7 +894,7 @@ MYSQLND ** mysqlnd_stream_array_check_for_readiness(MYSQLND ** conn_array TSRMLS
 			}
 			p++;
 		}
-		*ret_p = NULL; 
+		*ret_p = NULL;
 	}
 	return ret;
 }
@@ -968,9 +913,9 @@ static int mysqlnd_stream_array_to_fd_set(MYSQLND **conn_array, fd_set *fds, php
 		 * when casting.  It is only used here so that the buffered data warning
 		 * is not displayed.
 		 * */
-		if (SUCCESS == php_stream_cast((*p)->net.stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL,
+		if (SUCCESS == php_stream_cast((*p)->net->stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL,
 										(void*)&this_fd, 1) && this_fd >= 0) {
-			
+
 			PHP_SAFE_FD_SET(this_fd, fds);
 
 			if (this_fd > *max_fd) {
@@ -993,7 +938,7 @@ static int mysqlnd_stream_array_from_fd_set(MYSQLND **conn_array, fd_set *fds TS
 	MYSQLND **fwd = conn_array, **bckwd = conn_array;
 
 	while (*fwd) {
-		if (SUCCESS == php_stream_cast((*fwd)->net.stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL,
+		if (SUCCESS == php_stream_cast((*fwd)->net->stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL,
 										(void*)&this_fd, 1) && this_fd >= 0) {
 			if (PHP_SAFE_FD_ISSET(this_fd, fds)) {
 				if (disproportion) {
@@ -1009,7 +954,7 @@ static int mysqlnd_stream_array_from_fd_set(MYSQLND **conn_array, fd_set *fds TS
 		fwd++;
 	}
 	*bckwd = NULL;/* NULL-terminate the list */
-	
+
 	return ret;
 }
 
@@ -1062,6 +1007,7 @@ _mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQLND ***dont_poll, long s
 
 	if (!sets) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, *dont_poll ? "All arrays passed are clear":"No stream arrays were passed");
+		DBG_ERR_FMT(*dont_poll ? "All arrays passed are clear":"No stream arrays were passed");
 		DBG_RETURN(FAIL);
 	}
 
@@ -1070,14 +1016,14 @@ _mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQLND ***dont_poll, long s
 	/* Solaris + BSD do not like microsecond values which are >= 1 sec */
 	if (usec > 999999) {
 		tv.tv_sec = sec + (usec / 1000000);
-		tv.tv_usec = usec % 1000000;			
+		tv.tv_usec = usec % 1000000;
 	} else {
 		tv.tv_sec = sec;
 		tv.tv_usec = usec;
 	}
 
 	tv_p = &tv;
-	
+
 	retval = php_select(max_fd + 1, &rfds, &wfds, &efds, tv_p);
 
 	if (retval == -1) {
@@ -1127,11 +1073,11 @@ MYSQLND_METHOD(mysqlnd_conn, list_fields)(MYSQLND *conn, const char *table, cons
 
 	if (achtung_wild && (wild_len = strlen(achtung_wild))) {
 		memcpy(p, achtung_wild, MIN(wild_len, MYSQLND_MAX_ALLOWED_DB_LEN * 4));
-		p += wild_len;	
+		p += wild_len;
 		*p++ = '\0';
 	}
 
-	if (PASS != mysqlnd_simple_command(conn, COM_FIELD_LIST, buff, p - buff,
+	if (PASS != conn->m->simple_command(conn, COM_FIELD_LIST, buff, p - buff,
 									   PROT_LAST /* we will handle the OK packet*/,
 									   FALSE, TRUE TSRMLS_CC)) {
 		DBG_RETURN(NULL);
@@ -1140,7 +1086,7 @@ MYSQLND_METHOD(mysqlnd_conn, list_fields)(MYSQLND *conn, const char *table, cons
 	   Prepare for the worst case.
 	   MyISAM goes to 2500 BIT columns, double it for safety.
 	 */
-	result = mysqlnd_result_init(5000, mysqlnd_palloc_get_thd_cache_reference(conn->zval_cache) TSRMLS_CC);
+	result = mysqlnd_result_init(5000 TSRMLS_CC);
 
 
 	if (FAIL == result->m.read_result_metadata(result, conn TSRMLS_CC)) {
@@ -1161,8 +1107,7 @@ MYSQLND_METHOD(mysqlnd_conn, list_fields)(MYSQLND *conn, const char *table, cons
 
 /* {{{ mysqlnd_conn::list_method */
 MYSQLND_RES *
-MYSQLND_METHOD(mysqlnd_conn, list_method)(MYSQLND *conn, const char *query,
-										  const char *achtung_wild, char *par1 TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_conn, list_method)(MYSQLND *conn, const char *query, const char *achtung_wild, char *par1 TSRMLS_DC)
 {
 	char *show_query = NULL;
 	size_t show_query_len;
@@ -1175,14 +1120,14 @@ MYSQLND_METHOD(mysqlnd_conn, list_method)(MYSQLND *conn, const char *query,
 		if (achtung_wild) {
 			show_query_len = spprintf(&show_query, 0, query, par1, achtung_wild);
 		} else {
-			show_query_len = spprintf(&show_query, 0, query, par1);	
+			show_query_len = spprintf(&show_query, 0, query, par1);
 		}
 	} else {
 		if (achtung_wild) {
 			show_query_len = spprintf(&show_query, 0, query, achtung_wild);
 		} else {
-			show_query_len = strlen(show_query = (char *)query);	
-		}	
+			show_query_len = strlen(show_query = (char *)query);
+		}
 	}
 
 	if (PASS == conn->m->query(conn, show_query, show_query_len TSRMLS_CC)) {
@@ -1198,7 +1143,7 @@ MYSQLND_METHOD(mysqlnd_conn, list_method)(MYSQLND *conn, const char *query,
 
 /* {{{ mysqlnd_conn::errno */
 static unsigned int
-MYSQLND_METHOD(mysqlnd_conn, errno)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, errno)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->error_info.error_no;
 }
@@ -1207,7 +1152,7 @@ MYSQLND_METHOD(mysqlnd_conn, errno)(const MYSQLND * const conn)
 
 /* {{{ mysqlnd_conn::error */
 static const char *
-MYSQLND_METHOD(mysqlnd_conn, error)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, error)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->error_info.error;
 }
@@ -1216,7 +1161,7 @@ MYSQLND_METHOD(mysqlnd_conn, error)(const MYSQLND * const conn)
 
 /* {{{ mysqlnd_conn::sqlstate */
 static const char *
-MYSQLND_METHOD(mysqlnd_conn, sqlstate)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, sqlstate)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->error_info.sqlstate[0] ? conn->error_info.sqlstate:MYSQLND_SQLSTATE_NULL;
 }
@@ -1235,8 +1180,7 @@ PHPAPI ulong mysqlnd_old_escape_string(char *newstr, const char *escapestr, size
 
 /* {{{ mysqlnd_conn::escape_string */
 static ulong
-MYSQLND_METHOD(mysqlnd_conn, escape_string)(const MYSQLND * const conn, char *newstr,
-											const char *escapestr, size_t escapestr_len TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_conn, escape_string)(const MYSQLND * const conn, char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC)
 {
 	DBG_ENTER("mysqlnd_conn::escape_string");
 	DBG_INF_FMT("conn=%llu", conn->thread_id);
@@ -1254,29 +1198,33 @@ MYSQLND_METHOD(mysqlnd_conn, dump_debug_info)(MYSQLND * const conn TSRMLS_DC)
 {
 	DBG_ENTER("mysqlnd_conn::dump_debug_info");
 	DBG_INF_FMT("conn=%llu", conn->thread_id);
-	DBG_RETURN(mysqlnd_simple_command(conn, COM_DEBUG, NULL, 0, PROT_EOF_PACKET, FALSE, TRUE TSRMLS_CC));
+	DBG_RETURN(conn->m->simple_command(conn, COM_DEBUG, NULL, 0, PROT_EOF_PACKET, FALSE, TRUE TSRMLS_CC));
 }
 /* }}} */
 
 
 /* {{{ mysqlnd_conn::select_db */
 static enum_func_status
-MYSQLND_METHOD(mysqlnd_conn, select_db)(MYSQLND * const conn,
-										const char * const db,
-										unsigned int db_len TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_conn, select_db)(MYSQLND * const conn, const char * const db, unsigned int db_len TSRMLS_DC)
 {
 	enum_func_status ret;
 
 	DBG_ENTER("mysqlnd_conn::select_db");
 	DBG_INF_FMT("conn=%llu db=%s", conn->thread_id, db);
 
-	ret = mysqlnd_simple_command(conn, COM_INIT_DB, db, db_len, PROT_OK_PACKET, FALSE, TRUE TSRMLS_CC);
+	ret = conn->m->simple_command(conn, COM_INIT_DB, db, db_len, PROT_OK_PACKET, FALSE, TRUE TSRMLS_CC);
 	/*
 	  The server sends 0 but libmysql doesn't read it and has established
 	  a protocol of giving back -1. Thus we have to follow it :(
 	*/
 	SET_ERROR_AFF_ROWS(conn);
-
+	if (ret == PASS) {
+		if (conn->connect_or_select_db) {
+			pefree(conn->connect_or_select_db, conn->persistent);
+		}
+		conn->connect_or_select_db = pestrndup(db, db_len, conn->persistent);
+		conn->connect_or_select_db_len = db_len;
+	}
 	DBG_RETURN(ret);
 }
 /* }}} */
@@ -1291,7 +1239,7 @@ MYSQLND_METHOD(mysqlnd_conn, ping)(MYSQLND * const conn TSRMLS_DC)
 	DBG_ENTER("mysqlnd_conn::ping");
 	DBG_INF_FMT("conn=%llu", conn->thread_id);
 
-	ret = mysqlnd_simple_command(conn, COM_PING, NULL, 0, PROT_OK_PACKET, TRUE, TRUE TSRMLS_CC);
+	ret = conn->m->simple_command(conn, COM_PING, NULL, 0, PROT_OK_PACKET, TRUE, TRUE TSRMLS_CC);
 	/*
 	  The server sends 0 but libmysql doesn't read it and has established
 	  a protocol of giving back -1. Thus we have to follow it :(
@@ -1309,24 +1257,24 @@ static enum_func_status
 MYSQLND_METHOD(mysqlnd_conn, stat)(MYSQLND *conn, char **message, unsigned int * message_len TSRMLS_DC)
 {
 	enum_func_status ret;
-	php_mysql_packet_stats stats_header;
+	MYSQLND_PACKET_STATS * stats_header;
 
 	DBG_ENTER("mysqlnd_conn::stat");
 	DBG_INF_FMT("conn=%llu", conn->thread_id);
 
-	ret = mysqlnd_simple_command(conn, COM_STATISTICS, NULL, 0, PROT_LAST, FALSE, TRUE TSRMLS_CC);
+	ret = conn->m->simple_command(conn, COM_STATISTICS, NULL, 0, PROT_LAST, FALSE, TRUE TSRMLS_CC);
 	if (FAIL == ret) {
 		DBG_RETURN(FAIL);
 	}
-	PACKET_INIT_ALLOCA(stats_header, PROT_STATS_PACKET);
-	if (FAIL == (ret = PACKET_READ_ALLOCA(stats_header, conn))) {
+	stats_header = conn->protocol->m.get_stats_packet(conn->protocol, FALSE TSRMLS_CC);
+	if (FAIL == (ret = PACKET_READ(stats_header, conn))) {
 		DBG_RETURN(FAIL);
 	}
-	*message = stats_header.message;
-	*message_len = stats_header.message_len;
+	*message = stats_header->message;
+	*message_len = stats_header->message_len;
 	/* Ownership transfer */
-	stats_header.message = NULL;
-	PACKET_FREE_ALLOCA(stats_header);
+	stats_header->message = NULL;
+	PACKET_FREE(stats_header);
 
 	DBG_INF(*message);
 	DBG_RETURN(PASS);
@@ -1348,13 +1296,13 @@ MYSQLND_METHOD(mysqlnd_conn, kill)(MYSQLND *conn, unsigned int pid TSRMLS_DC)
 
 	/* If we kill ourselves don't expect OK packet, PROT_LAST will skip it */
 	if (pid != conn->thread_id) {
-		ret = mysqlnd_simple_command(conn, COM_PROCESS_KILL, buff, 4, PROT_OK_PACKET, FALSE, TRUE TSRMLS_CC);
+		ret = conn->m->simple_command(conn, COM_PROCESS_KILL, buff, 4, PROT_OK_PACKET, FALSE, TRUE TSRMLS_CC);
 		/*
 		  The server sends 0 but libmysql doesn't read it and has established
 		  a protocol of giving back -1. Thus we have to follow it :(
 		*/
 		SET_ERROR_AFF_ROWS(conn);
-	} else if (PASS == (ret = mysqlnd_simple_command(conn, COM_PROCESS_KILL, buff,
+	} 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);
 	}
@@ -1408,7 +1356,7 @@ MYSQLND_METHOD(mysqlnd_conn, refresh)(MYSQLND * const conn, uint8_t options TSRM
 
 	int1store(bits, options);
 
-	DBG_RETURN(mysqlnd_simple_command(conn, COM_REFRESH, (char *)bits, 1, PROT_OK_PACKET, FALSE, TRUE TSRMLS_CC));
+	DBG_RETURN(conn->m->simple_command(conn, COM_REFRESH, (char *)bits, 1, PROT_OK_PACKET, FALSE, TRUE TSRMLS_CC));
 }
 /* }}} */
 
@@ -1423,7 +1371,7 @@ MYSQLND_METHOD(mysqlnd_conn, shutdown)(MYSQLND * const conn, uint8_t level TSRML
 
 	int1store(bits, level);
 
-	DBG_RETURN(mysqlnd_simple_command(conn, COM_SHUTDOWN, (char *)bits, 1, PROT_OK_PACKET, FALSE, TRUE TSRMLS_CC));
+	DBG_RETURN(conn->m->simple_command(conn, COM_SHUTDOWN, (char *)bits, 1, PROT_OK_PACKET, FALSE, TRUE TSRMLS_CC));
 }
 /* }}} */
 
@@ -1435,14 +1383,14 @@ mysqlnd_send_close(MYSQLND * conn TSRMLS_DC)
 	enum_func_status ret = PASS;
 
 	DBG_ENTER("mysqlnd_send_close");
-	DBG_INF_FMT("conn=%llu conn->net.stream->abstract=%p",
-				conn->thread_id, conn->net.stream? conn->net.stream->abstract:NULL);
+	DBG_INF_FMT("conn=%llu conn->net->stream->abstract=%p",
+				conn->thread_id, conn->net->stream? conn->net->stream->abstract:NULL);
 
 	switch (CONN_GET_STATE(conn)) {
 		case CONN_READY:
 			DBG_INF("Connection clean, sending COM_QUIT");
-			if (conn->net.stream) {
-				ret =  mysqlnd_simple_command(conn, COM_QUIT, NULL, 0, PROT_LAST, TRUE, TRUE TSRMLS_CC);
+			if (conn->net->stream) {
+				ret =  conn->m->simple_command(conn, COM_QUIT, NULL, 0, PROT_LAST, TRUE, TRUE TSRMLS_CC);
 			}
 			/* Do nothing */
 			break;
@@ -1499,10 +1447,10 @@ MYSQLND_METHOD(mysqlnd_conn, close)(MYSQLND * conn, enum_connection_close_type c
 	DBG_INF_FMT("conn=%llu", conn->thread_id);
 
 	if (conn->state >= CONN_READY) {
-		MYSQLND_INC_CONN_STATISTIC(&conn->stats, stat);
-		MYSQLND_DEC_CONN_STATISTIC(&conn->stats, STAT_OPENED_CONNECTIONS);
+		MYSQLND_INC_CONN_STATISTIC(conn->stats, stat);
+		MYSQLND_DEC_CONN_STATISTIC(conn->stats, STAT_OPENED_CONNECTIONS);
 		if (conn->persistent) {
-			MYSQLND_DEC_CONN_STATISTIC(&conn->stats, STAT_OPENED_PERSISTENT_CONNECTIONS);
+			MYSQLND_DEC_CONN_STATISTIC(conn->stats, STAT_OPENED_PERSISTENT_CONNECTIONS);
 		}
 	}
 
@@ -1553,25 +1501,12 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_conn, free_reference)(MYSQLND * const conn TSRMLS
 
 
 /* {{{ mysqlnd_conn::get_state */
-#ifdef MYSQLND_THREADED
-static enum mysqlnd_connection_state
-MYSQLND_METHOD_PRIVATE(mysqlnd_conn, get_state)(MYSQLND * const conn TSRMLS_DC)
-{
-	enum mysqlnd_connection_state state;
-	DBG_ENTER("mysqlnd_conn::get_state");
-	tsrm_mutex_lock(conn->LOCK_state);
-	state = conn->state;
-	tsrm_mutex_unlock(conn->LOCK_state);
-	DBG_RETURN(state);
-}
-#else
 static enum mysqlnd_connection_state
 MYSQLND_METHOD_PRIVATE(mysqlnd_conn, get_state)(MYSQLND * const conn TSRMLS_DC)
 {
 	DBG_ENTER("mysqlnd_conn::get_state");
 	DBG_RETURN(conn->state);
 }
-#endif
 /* }}} */
 
 
@@ -1580,14 +1515,8 @@ static void
 MYSQLND_METHOD_PRIVATE(mysqlnd_conn, set_state)(MYSQLND * const conn, enum mysqlnd_connection_state new_state TSRMLS_DC)
 {
 	DBG_ENTER("mysqlnd_conn::set_state");
-#ifdef MYSQLND_THREADED
- 	tsrm_mutex_lock(conn->LOCK_state);
-#endif
 	DBG_INF_FMT("New state=%d", new_state);
 	conn->state = new_state;
-#ifdef MYSQLND_THREADED
-	tsrm_mutex_unlock(conn->LOCK_state);
-#endif
 	DBG_VOID_RETURN;
 }
 /* }}} */
@@ -1595,7 +1524,7 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_conn, set_state)(MYSQLND * const conn, enum mysql
 
 /* {{{ mysqlnd_conn::field_count */
 static unsigned int
-MYSQLND_METHOD(mysqlnd_conn, field_count)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, field_count)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->field_count;
 }
@@ -1604,7 +1533,7 @@ MYSQLND_METHOD(mysqlnd_conn, field_count)(const MYSQLND * const conn)
 
 /* {{{ mysqlnd_conn::insert_id */
 static uint64_t
-MYSQLND_METHOD(mysqlnd_conn, insert_id)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, insert_id)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->upsert_status.last_insert_id;
 }
@@ -1613,7 +1542,7 @@ MYSQLND_METHOD(mysqlnd_conn, insert_id)(const MYSQLND * const conn)
 
 /* {{{ mysqlnd_conn::affected_rows */
 static uint64_t
-MYSQLND_METHOD(mysqlnd_conn, affected_rows)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, affected_rows)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->upsert_status.affected_rows;
 }
@@ -1622,7 +1551,7 @@ MYSQLND_METHOD(mysqlnd_conn, affected_rows)(const MYSQLND * const conn)
 
 /* {{{ mysqlnd_conn::warning_count */
 static unsigned int
-MYSQLND_METHOD(mysqlnd_conn, warning_count)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, warning_count)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->upsert_status.warning_count;
 }
@@ -1631,7 +1560,7 @@ MYSQLND_METHOD(mysqlnd_conn, warning_count)(const MYSQLND * const conn)
 
 /* {{{ mysqlnd_conn::info */
 static const char *
-MYSQLND_METHOD(mysqlnd_conn, info)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, info)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->last_message;
 }
@@ -1656,7 +1585,7 @@ PHPAPI unsigned int mysqlnd_get_client_version()
 
 /* {{{ mysqlnd_conn::get_server_info */
 static const char *
-MYSQLND_METHOD(mysqlnd_conn, get_server_info)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, get_server_info)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->server_version;
 }
@@ -1665,7 +1594,7 @@ MYSQLND_METHOD(mysqlnd_conn, get_server_info)(const MYSQLND * const conn)
 
 /* {{{ mysqlnd_conn::get_host_info */
 static const char *
-MYSQLND_METHOD(mysqlnd_conn, get_host_info)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, get_host_info)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->host_info;
 }
@@ -1674,7 +1603,7 @@ MYSQLND_METHOD(mysqlnd_conn, get_host_info)(const MYSQLND * const conn)
 
 /* {{{ mysqlnd_conn::get_proto_info */
 static unsigned int
-MYSQLND_METHOD(mysqlnd_conn, get_proto_info)(const MYSQLND *const conn)
+MYSQLND_METHOD(mysqlnd_conn, get_proto_info)(const MYSQLND *const conn TSRMLS_DC)
 {
 	return conn->protocol_version;
 }
@@ -1683,7 +1612,7 @@ MYSQLND_METHOD(mysqlnd_conn, get_proto_info)(const MYSQLND *const conn)
 
 /* {{{ mysqlnd_conn::charset_name */
 static const char *
-MYSQLND_METHOD(mysqlnd_conn, charset_name)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, charset_name)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->charset->name;
 }
@@ -1692,7 +1621,7 @@ MYSQLND_METHOD(mysqlnd_conn, charset_name)(const MYSQLND * const conn)
 
 /* {{{ mysqlnd_conn::thread_id */
 static uint64_t
-MYSQLND_METHOD(mysqlnd_conn, thread_id)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, thread_id)(const MYSQLND * const conn TSRMLS_DC)
 {
 	return conn->thread_id;
 }
@@ -1701,7 +1630,7 @@ MYSQLND_METHOD(mysqlnd_conn, thread_id)(const MYSQLND * const conn)
 
 /* {{{ mysqlnd_conn::get_server_version */
 static unsigned long
-MYSQLND_METHOD(mysqlnd_conn, get_server_version)(const MYSQLND * const conn)
+MYSQLND_METHOD(mysqlnd_conn, get_server_version)(const MYSQLND * const conn TSRMLS_DC)
 {
 	long major, minor, patch;
 	char *p;
@@ -1715,7 +1644,7 @@ MYSQLND_METHOD(mysqlnd_conn, get_server_version)(const MYSQLND * const conn)
 	minor = strtol(p, &p, 10);
 	p += 1; /* consume the dot */
 	patch = strtol(p, &p, 10);
-	
+
 	return (unsigned long)(major * 10000L + (unsigned long)(minor * 100L + patch));
 }
 /* }}} */
@@ -1751,7 +1680,7 @@ MYSQLND_METHOD(mysqlnd_conn, next_result)(MYSQLND * const conn TSRMLS_DC)
 	  We are sure that there is a result set, since conn->state is set accordingly
 	  in mysqlnd_store_result() or mysqlnd_fetch_row_unbuffered()
 	*/
-	if (FAIL == (ret = mysqlnd_query_read_result_set_header(conn, NULL TSRMLS_CC))) {
+	if (FAIL == (ret = conn->m->query_read_result_set_header(conn, NULL TSRMLS_CC))) {
 		/*
 		  There can be an error in the middle of a multi-statement, which will cancel the multi-statement.
 		  So there are no more results and we should just return FALSE, error_no has been set
@@ -1826,7 +1755,8 @@ static enum_func_status
 MYSQLND_METHOD(mysqlnd_conn, change_user)(MYSQLND * const conn,
 										  const char *user,
 										  const char *passwd,
-										  const char *db TSRMLS_DC)
+										  const char *db,
+										  zend_bool silent TSRMLS_DC)
 {
 	/*
 	  User could be max 16 * 3 (utf8), pass is 20 usually, db is up to 64*3
@@ -1835,13 +1765,13 @@ MYSQLND_METHOD(mysqlnd_conn, change_user)(MYSQLND * const conn,
 	*/
 	size_t user_len;
 	enum_func_status ret;
-	php_mysql_packet_chg_user_resp chg_user_resp;
+	MYSQLND_PACKET_CHG_USER_RESPONSE * chg_user_resp;
 	char buffer[MYSQLND_MAX_ALLOWED_USER_LEN + 1 + SCRAMBLE_LENGTH + MYSQLND_MAX_ALLOWED_DB_LEN + 1];
 	char *p = buffer;
 
 	DBG_ENTER("mysqlnd_conn::change_user");
-	DBG_INF_FMT("conn=%llu user=%s passwd=%s db=%s",
-				conn->thread_id, user?user:"", passwd?"***":"null", db?db:"");
+	DBG_INF_FMT("conn=%llu user=%s passwd=%s db=%s silent=%d",
+				conn->thread_id, user?user:"", passwd?"***":"null", db?db:"", (silent == TRUE)?1:0 );
 
 	if (!user) {
 		user = "";
@@ -1876,16 +1806,16 @@ MYSQLND_METHOD(mysqlnd_conn, change_user)(MYSQLND * const conn,
 	}
 	*p++ = '\0';
 
-	if (PASS != mysqlnd_simple_command(conn, COM_CHANGE_USER, buffer, p - buffer,
+	if (PASS != conn->m->simple_command(conn, COM_CHANGE_USER, buffer, p - buffer,
 									   PROT_LAST /* we will handle the OK packet*/,
-									   FALSE, TRUE TSRMLS_CC)) {
+									   silent, TRUE TSRMLS_CC)) {
 		DBG_RETURN(FAIL);
 	}
 
-	PACKET_INIT_ALLOCA(chg_user_resp, PROT_CHG_USER_PACKET);
-	ret = PACKET_READ_ALLOCA(chg_user_resp, conn);
-	conn->error_info = chg_user_resp.error_info;
-	PACKET_FREE_ALLOCA(chg_user_resp);
+	chg_user_resp = conn->protocol->m.get_change_user_response_packet(conn->protocol, FALSE TSRMLS_CC);
+	ret = PACKET_READ(chg_user_resp, conn);
+	conn->error_info = chg_user_resp->error_info;
+	PACKET_FREE(chg_user_resp);
 
 	if (conn->error_info.error_no) {
 		ret = FAIL;
@@ -1897,10 +1827,9 @@ MYSQLND_METHOD(mysqlnd_conn, change_user)(MYSQLND * const conn,
 		if (mysqlnd_get_server_version(conn) > 50113L &&
 			mysqlnd_get_server_version(conn) < 50118L)
 		{
-			php_mysql_packet_ok redundant_error_packet;
-			PACKET_INIT_ALLOCA(redundant_error_packet, PROT_OK_PACKET);
-			PACKET_READ_ALLOCA(redundant_error_packet, conn);
-			PACKET_FREE_ALLOCA(redundant_error_packet);
+			MYSQLND_PACKET_OK * redundant_error_packet = conn->protocol->m.get_ok_packet(conn->protocol, FALSE TSRMLS_CC);
+			PACKET_READ(redundant_error_packet, conn);
+			PACKET_FREE(redundant_error_packet);
 			DBG_INF_FMT("Server is %d, buggy, sends two ERR messages", mysqlnd_get_server_version(conn));
 		}
 	}
@@ -1939,44 +1868,31 @@ MYSQLND_METHOD(mysqlnd_conn, set_client_option)(MYSQLND * const conn,
 	DBG_ENTER("mysqlnd_conn::set_client_option");
 	DBG_INF_FMT("conn=%llu option=%d", 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:
+#endif
+		case MYSQL_OPT_CONNECT_TIMEOUT:
+		case MYSQLND_OPT_NET_CMD_BUFFER_SIZE:
+		case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
+			conn->net->m.set_client_option(conn->net, option, value TSRMLS_CC);
+			break;
 #if PHP_MAJOR_VERSION >= 6
 		case MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE:
 			conn->options.numeric_and_datetime_as_unicode = *(unsigned int*) value;
 			break;
 #endif
-		case MYSQLND_OPT_NET_CMD_BUFFER_SIZE:
-			if (*(unsigned int*) value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) {
-				DBG_RETURN(FAIL);
-			}
-			conn->net.cmd_buffer.length = *(unsigned int*) value;
-			if (!conn->net.cmd_buffer.buffer) {
-				conn->net.cmd_buffer.buffer = mnd_pemalloc(conn->net.cmd_buffer.length, conn->persistent);
-			} else {
-				conn->net.cmd_buffer.buffer = mnd_perealloc(conn->net.cmd_buffer.buffer,
-															conn->net.cmd_buffer.length,
-															conn->persistent);
-			}
-			break;
-		case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
-			conn->options.net_read_buffer_size = *(unsigned int*) value;
-			break;
 #ifdef MYSQLND_STRING_TO_INT_CONVERSION
 		case MYSQLND_OPT_INT_AND_FLOAT_NATIVE:
+			DBG_INF("MYSQLND_OPT_INT_AND_FLOAT_NATIVE");
 			conn->options.int_and_float_native = *(unsigned int*) value;
 			break;
 #endif
-		case MYSQL_OPT_CONNECT_TIMEOUT:
-			conn->options.timeout_connect = *(unsigned int*) value;
-			break;
-#ifdef WHEN_SUPPORTED_BY_MYSQLI
-		case MYSQL_OPT_READ_TIMEOUT:
-			conn->options.timeout_read = *(unsigned int*) value;
-			break;
-		case MYSQL_OPT_WRITE_TIMEOUT:
-			conn->options.timeout_write = *(unsigned int*) value;
-			break;
-#endif
 		case MYSQL_OPT_LOCAL_INFILE:
+			DBG_INF("MYSQL_OPT_LOCAL_INFILE");
 			if (!value || (*(unsigned int*) value) ? 1 : 0) {
 				conn->options.flags |= CLIENT_LOCAL_FILES;
 			} else {
@@ -1984,15 +1900,14 @@ MYSQLND_METHOD(mysqlnd_conn, set_client_option)(MYSQLND * const conn,
 			}
 			break;
 		case MYSQL_INIT_COMMAND:
+			DBG_INF("MYSQL_INIT_COMMAND");
+			DBG_INF_FMT("command=%s", value);
 			/* when num_commands is 0, then realloc will be effectively a malloc call, internally */
 			conn->options.init_commands = mnd_perealloc(conn->options.init_commands, sizeof(char *) * (conn->options.num_commands + 1),
 														conn->persistent);
 			conn->options.init_commands[conn->options.num_commands] = pestrdup(value, conn->persistent);
 			++conn->options.num_commands;
 			break;
-#ifdef WHEN_SUPPORTED_BY_MYSQLI
-		case MYSQL_OPT_COMPRESS:
-#endif
 		case MYSQL_READ_DEFAULT_FILE:
 		case MYSQL_READ_DEFAULT_GROUP:
 #ifdef WHEN_SUPPORTED_BY_MYSQLI
@@ -2003,7 +1918,9 @@ MYSQLND_METHOD(mysqlnd_conn, set_client_option)(MYSQLND * const conn,
 			/* currently not supported. Todo!! */
 			break;
 		case MYSQL_SET_CHARSET_NAME:
+			DBG_INF("MYSQL_SET_CHARSET_NAME");
 			conn->options.charset_name = pestrdup(value, conn->persistent);
+			DBG_INF_FMT("charset=%s", conn->options.charset_name);
 			break;
 #ifdef WHEN_SUPPORTED_BY_MYSQLI
 		case MYSQL_SET_CHARSET_DIR:
@@ -2055,7 +1972,7 @@ MYSQLND_METHOD(mysqlnd_conn, use_result)(MYSQLND * const conn TSRMLS_DC)
 		DBG_RETURN(NULL);
 	}
 
-	MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_UNBUFFERED_SETS);
+	MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_UNBUFFERED_SETS);
 
 	result = conn->current_result;
 	conn->current_result = NULL;
@@ -2088,7 +2005,7 @@ MYSQLND_METHOD(mysqlnd_conn, store_result)(MYSQLND * const conn TSRMLS_DC)
 		DBG_RETURN(NULL);
 	}
 
-	MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_BUFFERED_SETS);
+	MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_BUFFERED_SETS);
 
 	result = conn->current_result;
 	conn->current_result = NULL;
@@ -2099,44 +2016,6 @@ MYSQLND_METHOD(mysqlnd_conn, store_result)(MYSQLND * const conn TSRMLS_DC)
 /* }}} */
 
 
-/* {{{ mysqlnd_conn::background_store_result */
-MYSQLND_RES *
-MYSQLND_METHOD(mysqlnd_conn, background_store_result)(MYSQLND * const conn TSRMLS_DC)
-{
-	MYSQLND_RES *result;
-
-	DBG_ENTER("mysqlnd_conn::store_result");
-	DBG_INF_FMT("conn=%llu", conn->thread_id);
-
-	if (!conn->current_result) {
-		DBG_RETURN(NULL);
-	}
-
-	/* Nothing to store for UPSERT/LOAD DATA*/
-	if (conn->last_query_type != QUERY_SELECT || CONN_GET_STATE(conn) != CONN_FETCHING_DATA) {
-		SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE,
-						 mysqlnd_out_of_sync);
-		DBG_ERR("Command out of sync");
-		DBG_RETURN(NULL);
-	}
-
-	MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_BUFFERED_SETS);
-
-	result = conn->current_result;
-
-	result = result->m.background_store_result(result, conn, FALSE TSRMLS_CC);
-
-	/*
-	  Should be here, because current_result is used by the fetching thread to get data info
-	  The thread is contacted in mysqlnd_res::background_store_result().
-	*/
-	conn->current_result = NULL;
-
-	DBG_RETURN(result);
-}
-/* }}} */
-
-
 /* {{{ mysqlnd_conn::get_connection_stats */
 static void
 MYSQLND_METHOD(mysqlnd_conn, get_connection_stats)(const MYSQLND * const conn,
@@ -2145,15 +2024,20 @@ MYSQLND_METHOD(mysqlnd_conn, get_connection_stats)(const MYSQLND * const conn,
 {
 	DBG_ENTER("mysqlnd_conn::get_connection_stats");
 	DBG_INF_FMT("conn=%llu", conn->thread_id);
-	mysqlnd_fill_stats_hash(&(conn->stats), return_value TSRMLS_CC ZEND_FILE_LINE_CC);
+	mysqlnd_fill_stats_hash(conn->stats, mysqlnd_stats_values_names, return_value TSRMLS_CC ZEND_FILE_LINE_CC);
 	DBG_VOID_RETURN;
 }
 /* }}} */
 
 
 MYSQLND_STMT * _mysqlnd_stmt_init(MYSQLND * const conn TSRMLS_DC);
+static void MYSQLND_METHOD(mysqlnd_conn, init)(MYSQLND * conn TSRMLS_DC);
 
+static
 MYSQLND_CLASS_METHODS_START(mysqlnd_conn)
+	MYSQLND_METHOD(mysqlnd_conn, init),
+	MYSQLND_METHOD(mysqlnd_conn, connect),
+
 	MYSQLND_METHOD(mysqlnd_conn, escape_string),
 	MYSQLND_METHOD(mysqlnd_conn, set_charset),
 	MYSQLND_METHOD(mysqlnd_conn, query),
@@ -2161,7 +2045,6 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_conn)
 	MYSQLND_METHOD(mysqlnd_conn, reap_query),
 	MYSQLND_METHOD(mysqlnd_conn, use_result),
 	MYSQLND_METHOD(mysqlnd_conn, store_result),
-	MYSQLND_METHOD(mysqlnd_conn, background_store_result),
 	MYSQLND_METHOD(mysqlnd_conn, next_result),
 	MYSQLND_METHOD(mysqlnd_conn, more_results),
 
@@ -2206,49 +2089,66 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_conn)
 
 	MYSQLND_METHOD_PRIVATE(mysqlnd_conn, dtor),
 
+	mysqlnd_query_read_result_set_header,
+
 	MYSQLND_METHOD_PRIVATE(mysqlnd_conn, get_reference),
 	MYSQLND_METHOD_PRIVATE(mysqlnd_conn, free_reference),
 	MYSQLND_METHOD_PRIVATE(mysqlnd_conn, get_state),
 	MYSQLND_METHOD_PRIVATE(mysqlnd_conn, set_state),
+
+	MYSQLND_METHOD(mysqlnd_conn, simple_command),
+	MYSQLND_METHOD(mysqlnd_conn, simple_command_handle_response),
+	MYSQLND_METHOD(mysqlnd_conn, restart_psession),
+	MYSQLND_METHOD(mysqlnd_conn, end_psession)
 MYSQLND_CLASS_METHODS_END;
 
 
+/* {{{ mysqlnd_conn::init */
+static void
+MYSQLND_METHOD(mysqlnd_conn, init)(MYSQLND * conn TSRMLS_DC)
+{
+	DBG_ENTER("mysqlnd_conn::init");
+	conn->net = mysqlnd_net_init(conn->persistent TSRMLS_CC);
+	conn->protocol = mysqlnd_protocol_init(conn->persistent TSRMLS_CC);
+	mysqlnd_stats_init(&conn->stats, STAT_LAST);
+
+	SET_ERROR_AFF_ROWS(conn);
+
+	DBG_VOID_RETURN;
+}
+/* }}} */
+
+
 /* {{{ mysqlnd_init */
-PHPAPI MYSQLND *_mysqlnd_init(zend_bool persistent TSRMLS_DC)
+PHPAPI MYSQLND * _mysqlnd_init(zend_bool persistent TSRMLS_DC)
 {
-	MYSQLND *ret = mnd_pecalloc(1, sizeof(MYSQLND), persistent);
+	size_t alloc_size = sizeof(MYSQLND) + mysqlnd_plugin_count() * sizeof(void *);
+	MYSQLND *ret = mnd_pecalloc(1, alloc_size, persistent);
 
 	DBG_ENTER("mysqlnd_init");
 	DBG_INF_FMT("persistent=%d", persistent);
 
-	SET_ERROR_AFF_ROWS(ret);
 	ret->persistent = persistent;
-
 	ret->m = mysqlnd_conn_methods;
+	CONN_SET_STATE(ret, CONN_ALLOCED);
 	ret->m->get_reference(ret TSRMLS_CC);
 
-#ifdef MYSQLND_THREADED
-	ret->LOCK_state = tsrm_mutex_alloc();
-
-	pthread_mutex_init(&ret->LOCK_work, NULL);
-	pthread_cond_init(&ret->COND_work, NULL);
-	pthread_cond_init(&ret->COND_work_done, NULL);
-	pthread_cond_init(&ret->COND_thread_ended, NULL);
-#endif
+	ret->m->init(ret TSRMLS_CC);
 
 	DBG_RETURN(ret);
 }
 /* }}} */
 
+
 /* {{{ mysqlnd_library_init */
-void mysqlnd_library_init(TSRMLS_D)
+PHPAPI void mysqlnd_library_init(TSRMLS_D)
 {
 	if (mysqlnd_library_initted == FALSE) {
 		mysqlnd_library_initted = TRUE;
 		mysqlnd_conn_methods = &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_conn);
 		_mysqlnd_init_ps_subsystem();
 		/* Should be calloc, as mnd_calloc will reference LOCK_access*/
-		mysqlnd_stats_init(&mysqlnd_global_stats);
+		mysqlnd_stats_init(&mysqlnd_global_stats, STAT_LAST);
 	}
 }
 /* }}} */
@@ -2267,6 +2167,37 @@ PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods)
 }
 /* }}} */
 
+
+static unsigned int mysqlnd_plugins_counter = 0;
+
+/* {{{ mysqlnd_plugin_register */
+PHPAPI unsigned int mysqlnd_plugin_register()
+{
+	return mysqlnd_plugins_counter++;
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_plugin_count */
+PHPAPI unsigned int mysqlnd_plugin_count()
+{
+	return mysqlnd_plugins_counter;
+}
+/* }}} */
+
+
+/* {{{ _mysqlnd_plugin_get_plugin_connection_data */
+PHPAPI void ** _mysqlnd_plugin_get_plugin_connection_data(const MYSQLND * conn, unsigned int plugin_id TSRMLS_DC)
+{
+	DBG_ENTER("_mysqlnd_plugin_get_plugin_connection_data");
+	DBG_INF_FMT("plugin_id=%u", plugin_id);
+	if (!conn || plugin_id >= mysqlnd_plugin_count()) {
+		return NULL;
+	}
+	DBG_RETURN((void *)((char *)conn + sizeof(MYSQLND) + plugin_id * sizeof(void *)));
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
diff --git a/ext/mysqlnd/mysqlnd.h b/ext/mysqlnd/mysqlnd.h
index 3b3f637..1b51c4f 100644
--- a/ext/mysqlnd/mysqlnd.h
+++ b/ext/mysqlnd/mysqlnd.h
@@ -17,13 +17,13 @@
   |          Ulf Wendel <uwendel at mysql.com>                              |
   +----------------------------------------------------------------------+
 */
-/* $Id: mysqlnd.h 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysqlnd.h 294543 2010-02-04 20:28:55Z johannes $ */
 
 #ifndef MYSQLND_H
 #define MYSQLND_H
 
-#define MYSQLND_VERSION "mysqlnd 5.0.5-dev - 081106 - $Revision: 289630 $"
-#define MYSQLND_VERSION_ID 50005
+#define MYSQLND_VERSION "mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $"
+#define MYSQLND_VERSION_ID 50007
 
 /* This forces inlining of some accessor functions */
 #define MYSQLND_USE_OPTIMISATIONS 0
@@ -40,7 +40,7 @@
   on production systems, if of course measured performance degradation is not
   minimal.
 */
-#if PHP_DEBUG
+#if A0 && PHP_DEBUG
 #define MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND 1
 #endif
 
@@ -59,11 +59,24 @@
 #include "mysqlnd_structs.h"
 
 
+/* Library related */
+PHPAPI void mysqlnd_library_init(TSRMLS_D);
+PHPAPI void mysqlnd_library_end(TSRMLS_D);
 
+PHPAPI unsigned int mysqlnd_plugin_register();
+PHPAPI unsigned int mysqlnd_plugin_count();
+PHPAPI void ** _mysqlnd_plugin_get_plugin_connection_data(const MYSQLND * conn, unsigned int plugin_id TSRMLS_DC);
+#define mysqlnd_plugin_get_plugin_connection_data(c, p_id) _mysqlnd_plugin_get_plugin_connection_data((c), (p_id) TSRMLS_CC)
+
+PHPAPI void ** _mysqlnd_plugin_get_plugin_result_data(const MYSQLND_RES * result, unsigned int plugin_id TSRMLS_DC);
+#define mysqlnd_plugin_get_plugin_result_data(r, p_id) _mysqlnd_plugin_get_plugin_result_data((r), (p_id) TSRMLS_CC)
+
+PHPAPI void ** _mysqlnd_plugin_get_plugin_stmt_data(const MYSQLND_STMT * stmt, unsigned int plugin_id TSRMLS_DC);
+#define mysqlnd_plugin_get_plugin_stmt_data(s, p_id) _mysqlnd_plugin_get_plugin_stmt_data((s), (p_id) TSRMLS_CC)
+
+PHPAPI void ** _mysqlnd_plugin_get_plugin_protocol_data(const MYSQLND_PROTOCOL * protocol, unsigned int plugin_id TSRMLS_DC);
+#define mysqlnd_plugin_get_plugin_protocol_data(p, p_id) _mysqlnd_plugin_get_plugin_protocol_data((p), (p_id) TSRMLS_CC)
 
-/* Library related */
-void mysqlnd_library_init(TSRMLS_D);
-void mysqlnd_library_end(TSRMLS_D);
 
 PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods();
 PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods);
@@ -72,8 +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, cache) _mysqlnd_restart_psession((conn), (cache) TSRMLS_CC)
-PHPAPI void _mysqlnd_restart_psession(MYSQLND *conn, MYSQLND_THD_ZVAL_PCACHE *cache TSRMLS_DC);
+#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);
 PHPAPI void mysqlnd_minfo_print_hash(zval *values);
@@ -92,11 +105,10 @@ PHPAPI MYSQLND * mysqlnd_connect(MYSQLND *conn,
 						  const char *db, unsigned int db_len,
 						  unsigned int port,
 						  const char *socket,
-						  unsigned int mysql_flags,
-						  MYSQLND_THD_ZVAL_PCACHE *zval_cache
+						  unsigned int mysql_flags
 						  TSRMLS_DC);
 
-#define mysqlnd_change_user(conn, user, passwd, db)		(conn)->m->change_user((conn), (user), (passwd), (db) TSRMLS_CC)
+#define mysqlnd_change_user(conn, user, passwd, db, silent)		(conn)->m->change_user((conn), (user), (passwd), (db), (silent) TSRMLS_CC)
 
 #define mysqlnd_debug(x)								_mysqlnd_debug((x) TSRMLS_CC)
 PHPAPI void _mysqlnd_debug(const char *mode TSRMLS_DC);
@@ -120,7 +132,6 @@ PHPAPI enum_func_status _mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQ
 
 #define mysqlnd_use_result(conn)		(conn)->m->use_result((conn) TSRMLS_CC)
 #define mysqlnd_store_result(conn)		(conn)->m->store_result((conn) TSRMLS_CC)
-#define mysqlnd_bg_store_result(conn) 	(conn)->m->background_store_result((conn) TSRMLS_CC)
 #define mysqlnd_next_result(conn)		(conn)->m->next_result((conn) TSRMLS_CC)
 #define mysqlnd_more_results(conn)		(conn)->m->more_results((conn) TSRMLS_CC)
 #define mysqlnd_free_result(r,e_or_i)	((MYSQLND_RES*)r)->m.free_result(((MYSQLND_RES*)(r)), (e_or_i) TSRMLS_CC)
@@ -151,7 +162,7 @@ PHPAPI enum_func_status _mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQ
 #define mysqlnd_num_rows(result)		((result)->stored_data? (result)->stored_data->row_count:0)
 #define mysqlnd_num_fields(result)		(result)->field_count
 
-#define mysqlnd_fetch_lengths(result)	((result)->m.fetch_lengths? (result)->m.fetch_lengths((result)):NULL)
+#define mysqlnd_fetch_lengths(result)	((result)->m.fetch_lengths? (result)->m.fetch_lengths((result)  TSRMLS_CC) : NULL)
 
 #define mysqlnd_field_seek(result, ofs)			(result)->m.seek_field((result), (ofs))
 #define mysqlnd_field_tell(result)				((result)->meta? (result)->meta->current_field:0)
@@ -181,31 +192,32 @@ PHPAPI enum_func_status _mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQ
 /*****************************************************************************************************/
 
 /* Errors */
-#define mysqlnd_errno(conn)				(conn)->m->get_error_no((conn))
-#define mysqlnd_error(conn)				(conn)->m->get_error_str((conn))
-#define mysqlnd_sqlstate(conn)  		(conn)->m->get_sqlstate((conn))
+#define mysqlnd_errno(conn)				(conn)->m->get_error_no((conn) TSRMLS_CC)
+#define mysqlnd_error(conn)				(conn)->m->get_error_str((conn) TSRMLS_CC)
+#define mysqlnd_sqlstate(conn)  		(conn)->m->get_sqlstate((conn) TSRMLS_CC)
 
 /* Charset */
-#define mysqlnd_character_set_name(conn) (conn)->m->charset_name((conn))
+#define mysqlnd_character_set_name(conn) (conn)->m->charset_name((conn) TSRMLS_CC)
 
 /* Simple metadata */
-#define mysqlnd_field_count(conn)		(conn)->m->get_field_count((conn))
-#define mysqlnd_insert_id(conn)			(conn)->m->get_last_insert_id((conn))
-#define mysqlnd_affected_rows(conn)		(conn)->m->get_affected_rows((conn))
-#define mysqlnd_warning_count(conn)		(conn)->m->get_warning_count((conn))
-#define mysqlnd_info(conn)				(conn)->m->get_last_message((conn))
-#define mysqlnd_get_server_info(conn)	(conn)->m->get_server_information((conn))
-#define mysqlnd_get_host_info(conn)		(conn)->m->get_host_information((conn))
-#define mysqlnd_get_proto_info(conn)	(conn)->m->get_protocol_information((conn))
-#define mysqlnd_thread_id(conn)			(conn)->m->get_thread_id((conn))
-
-#define mysqlnd_num_rows(result)		(result)->m.num_rows((result))
-#define mysqlnd_num_fields(result)		(result)->m.num_fields((result))
-
-PHPAPI unsigned long * mysqlnd_fetch_lengths(MYSQLND_RES * const result);
-
-#define mysqlnd_field_seek(result, ofs)			(result)->m.seek_field((result), (ofs))
-#define mysqlnd_field_tell(result)				(result)->m.field_tell((result))
+#define mysqlnd_field_count(conn)		(conn)->m->get_field_count((conn) TSRMLS_CC)
+#define mysqlnd_insert_id(conn)			(conn)->m->get_last_insert_id((conn) TSRMLS_CC)
+#define mysqlnd_affected_rows(conn)		(conn)->m->get_affected_rows((conn) TSRMLS_CC)
+#define mysqlnd_warning_count(conn)		(conn)->m->get_warning_count((conn) TSRMLS_CC)
+#define mysqlnd_info(conn)				(conn)->m->get_last_message((conn) TSRMLS_CC)
+#define mysqlnd_get_server_info(conn)	(conn)->m->get_server_information((conn) TSRMLS_CC)
+#define mysqlnd_get_host_info(conn)		(conn)->m->get_host_information((conn) TSRMLS_CC)
+#define mysqlnd_get_proto_info(conn)	(conn)->m->get_protocol_information((conn) TSRMLS_CC)
+#define mysqlnd_thread_id(conn)			(conn)->m->get_thread_id((conn) TSRMLS_CC)
+
+#define mysqlnd_num_rows(result)		(result)->m.num_rows((result) TSRMLS_CC)
+#define mysqlnd_num_fields(result)		(result)->m.num_fields((result) TSRMLS_CC)
+
+#define mysqlnd_fetch_lengths(result)	_mysqlnd_fetch_lengths((result) TSRMLS_CC)
+PHPAPI unsigned long * _mysqlnd_fetch_lengths(MYSQLND_RES * const result  TSRMLS_DC);
+
+#define mysqlnd_field_seek(result, ofs)			(result)->m.seek_field((result), (ofs) TSRMLS_CC)
+#define mysqlnd_field_tell(result)				(result)->m.field_tell((result) TSRMLS_CC)
 #define mysqlnd_fetch_field(result)				(result)->m.fetch_field((result) TSRMLS_CC)
 #define mysqlnd_fetch_field_direct(result,fnr)	(result)->m.fetch_field_direct((result), (fnr) TSRMLS_CC)
 #define mysqlnd_fetch_fields(result)			(result)->m.fetch_fields((result) TSRMLS_CC)
@@ -215,15 +227,15 @@ PHPAPI const char *	mysqlnd_get_client_info();
 PHPAPI unsigned int	mysqlnd_get_client_version();
 
 /* PS */
-#define mysqlnd_stmt_insert_id(stmt)		(stmt)->m->get_last_insert_id((stmt))
-#define mysqlnd_stmt_affected_rows(stmt)	(stmt)->m->get_affected_rows((stmt))
-#define mysqlnd_stmt_num_rows(stmt)			(stmt)->m->get_num_rows((stmt))
-#define mysqlnd_stmt_param_count(stmt)		(stmt)->m->get_param_count((stmt))
-#define mysqlnd_stmt_field_count(stmt)		(stmt)->m->get_field_count((stmt))
-#define mysqlnd_stmt_warning_count(stmt)	(stmt)->m->get_warning_count((stmt))
-#define mysqlnd_stmt_errno(stmt)			(stmt)->m->get_error_no((stmt))
-#define mysqlnd_stmt_error(stmt)			(stmt)->m->get_error_str((stmt))
-#define mysqlnd_stmt_sqlstate(stmt)			(stmt)->m->get_sqlstate((stmt))
+#define mysqlnd_stmt_insert_id(stmt)		(stmt)->m->get_last_insert_id((stmt) TSRMLS_CC)
+#define mysqlnd_stmt_affected_rows(stmt)	(stmt)->m->get_affected_rows((stmt) TSRMLS_CC)
+#define mysqlnd_stmt_num_rows(stmt)			(stmt)->m->get_num_rows((stmt) TSRMLS_CC)
+#define mysqlnd_stmt_param_count(stmt)		(stmt)->m->get_param_count((stmt) TSRMLS_CC)
+#define mysqlnd_stmt_field_count(stmt)		(stmt)->m->get_field_count((stmt) TSRMLS_CC)
+#define mysqlnd_stmt_warning_count(stmt)	(stmt)->m->get_warning_count((stmt) TSRMLS_CC)
+#define mysqlnd_stmt_errno(stmt)			(stmt)->m->get_error_no((stmt) TSRMLS_CC)
+#define mysqlnd_stmt_error(stmt)			(stmt)->m->get_error_str((stmt) TSRMLS_CC)
+#define mysqlnd_stmt_sqlstate(stmt)			(stmt)->m->get_sqlstate((stmt) TSRMLS_CC)
 #endif /* MYSQLND_USE_OPTIMISATIONS */
 /*****************************************************************************************************/
 
@@ -252,7 +264,7 @@ PHPAPI void mysqlnd_set_local_infile_handler(MYSQLND * const conn, const char *
 #define mysqlnd_kill(conn, pid)				(conn)->m->kill_connection((conn), (pid) TSRMLS_CC)
 #define mysqlnd_refresh(conn, options)		(conn)->m->refresh_server((conn), (options) TSRMLS_CC)
 #define mysqlnd_shutdown(conn, level)		(conn)->m->shutdown_server((conn), (level) TSRMLS_CC)
-#define mysqlnd_get_server_version(conn)	(conn)->m->get_server_version((conn))
+#define mysqlnd_get_server_version(conn)	(conn)->m->get_server_version((conn) TSRMLS_CC)
 #define mysqlnd_set_character_set(conn, cs)	(conn)->m->set_charset((conn), (cs) TSRMLS_CC)
 #define mysqlnd_stat(conn, msg, msg_len)	(conn)->m->get_server_statistics((conn), (msg), (msg_len) TSRMLS_CC)
 #define mysqlnd_options(conn, opt, value)	(conn)->m->set_client_option((conn), (opt), (value) TSRMLS_CC)
@@ -270,7 +282,6 @@ PHPAPI ulong mysqlnd_old_escape_string(char *newstr, const char *escapestr, size
 /* PS */
 #define mysqlnd_stmt_init(conn)				(conn)->m->stmt_init((conn) TSRMLS_CC)
 #define mysqlnd_stmt_store_result(stmt)		(!mysqlnd_stmt_field_count((stmt)) ? PASS:((stmt)->m->store_result((stmt) TSRMLS_CC)? PASS:FAIL))
-#define mysqlnd_stmt_bg_store_result(stmt)	(!mysqlnd_stmt_field_count((stmt)) ? PASS:((stmt)->m->background_store_result((stmt) TSRMLS_CC)? PASS:FAIL))
 #define mysqlnd_stmt_get_result(stmt)		(stmt)->m->get_result((stmt) TSRMLS_CC)
 #define mysqlnd_stmt_more_results(stmt)		(stmt)->m->more_results((stmt) TSRMLS_CC)
 #define mysqlnd_stmt_next_result(stmt)		(stmt)->m->next_result((stmt) TSRMLS_CC)
@@ -302,63 +313,6 @@ PHPAPI ulong mysqlnd_old_escape_string(char *newstr, const char *escapestr, size
 /* Performance statistics */
 PHPAPI void			_mysqlnd_get_client_stats(zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC);
 
-/* Persistent caching zval allocator */
-#define mysqlnd_palloc_init_cache(size)		_mysqlnd_palloc_init_cache((size) TSRMLS_CC)
-#define mysqlnd_palloc_free_cache(cache)	_mysqlnd_palloc_free_cache((cache) TSRMLS_CC)
-PHPAPI MYSQLND_ZVAL_PCACHE*		_mysqlnd_palloc_init_cache(unsigned int cache_size TSRMLS_DC);
-PHPAPI void 					_mysqlnd_palloc_free_cache(MYSQLND_ZVAL_PCACHE *cache TSRMLS_DC);
-PHPAPI void						mysqlnd_palloc_stats(const MYSQLND_ZVAL_PCACHE * const cache,
-													 zval *return_value);
-
-#define mysqlnd_palloc_rinit(cache)		_mysqlnd_palloc_rinit((cache) TSRMLS_CC)
-#define mysqlnd_palloc_rshutdown(cache)	_mysqlnd_palloc_rshutdown((cache) TSRMLS_CC)
-PHPAPI MYSQLND_THD_ZVAL_PCACHE * _mysqlnd_palloc_rinit(MYSQLND_ZVAL_PCACHE * cache TSRMLS_DC);
-PHPAPI void						 _mysqlnd_palloc_rshutdown(MYSQLND_THD_ZVAL_PCACHE * cache TSRMLS_DC);
-
-
-#define mysqlnd_palloc_init_thd_cache(cache) 			_mysqlnd_palloc_init_thd_cache((cache) TSRMLS_CC)
-#define mysqlnd_palloc_free_thd_cache_reference(cache)	_mysqlnd_palloc_free_thd_cache_reference((cache) TSRMLS_CC)
-#define mysqlnd_palloc_get_thd_cache_reference(cache)	_mysqlnd_palloc_get_thd_cache_reference((cache) TSRMLS_CC)
-
-PHPAPI MYSQLND_THD_ZVAL_PCACHE*	_mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const cache TSRMLS_DC);
-MYSQLND_THD_ZVAL_PCACHE*		_mysqlnd_palloc_get_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE * const cache TSRMLS_DC);
-PHPAPI void						_mysqlnd_palloc_free_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE **cache TSRMLS_DC);
-
-
-/* There two should not be used from outside */
-void *	mysqlnd_palloc_get_zval(MYSQLND_THD_ZVAL_PCACHE * const cache, zend_bool *allocated TSRMLS_DC);
-void	mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_THD_ZVAL_PCACHE * const cache,
-									 enum_mysqlnd_res_type type, zend_bool *copy_ctor_called TSRMLS_DC);
-
-
-
-/* ---------------------- QUERY CACHE ---------------*/
-struct st_mysqlnd_qcache {
-	HashTable		*ht;
-	unsigned int	references;
-#ifdef ZTS
-	MUTEX_T		LOCK_access;
-#endif
-};
-
-
-typedef struct st_mysqlnd_qcache_element {
-	MYSQLND_RES_BUFFERED *data;
-	MYSQLND_RES_METADATA *meta;
-	const char * query;
-	size_t	query_len;
-} MYSQLND_QCACHE_ELEMENT;
-
-
-PHPAPI MYSQLND_QCACHE *	mysqlnd_qcache_init_cache();
-PHPAPI MYSQLND_QCACHE *	mysqlnd_qcache_get_cache_reference(MYSQLND_QCACHE * const cache);
-PHPAPI void				mysqlnd_qcache_free_cache_reference(MYSQLND_QCACHE **cache);
-PHPAPI void				mysqlnd_qcache_stats(const MYSQLND_QCACHE * const cache, zval *return_value);
-MYSQLND_RES * 		mysqlnd_qcache_get(MYSQLND_QCACHE * const cache, const char * query,
-									   size_t query_len);
-void				mysqlnd_qcache_put(MYSQLND_QCACHE * const cache, char * query, size_t query_len,
-									   MYSQLND_RES_BUFFERED * const result, MYSQLND_RES_METADATA * const meta);
-
 /* double check the class name to avoid naming conflicts when using these: */
 #define MYSQLND_METHOD(class, method) php_##class##_##method##_pub
 #define MYSQLND_METHOD_PRIVATE(class, method) php_##class##_##method##_priv
@@ -371,9 +325,6 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqlnd)
 	long			net_cmd_buffer_size;
 	long			net_read_buffer_size;
 	long			log_mask;
-#ifdef MYSQLND_THREADED
-	THREAD_T		thread_id;
-#endif
 	long			net_read_timeout;
 ZEND_END_MODULE_GLOBALS(mysqlnd)
 
@@ -386,6 +337,8 @@ ZEND_EXTERN_MODULE_GLOBALS(mysqlnd);
 #endif
 
 
+PHPAPI void mysqlnd_minfo_print_hash(zval *values);
+
 #endif	/* MYSQLND_H */
 
 
diff --git a/ext/mysqlnd/mysqlnd_block_alloc.c b/ext/mysqlnd/mysqlnd_block_alloc.c
index cf7be9f..8c7f7d9 100644
--- a/ext/mysqlnd/mysqlnd_block_alloc.c
+++ b/ext/mysqlnd/mysqlnd_block_alloc.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_block_alloc.c 282779 2009-06-25 19:03:52Z johannes $ */
+/* $Id: mysqlnd_block_alloc.c 293779 2010-01-20 17:09:28Z johannes $ */
 
 #include "php.h"
 #include "mysqlnd.h"
@@ -160,7 +160,7 @@ MYSQLND_MEMORY_POOL_CHUNK * mysqlnd_mempool_get_chunk(MYSQLND_MEMORY_POOL * pool
 
 
 /* {{{ mysqlnd_mempool_create */
-MYSQLND_MEMORY_POOL *
+PHPAPI MYSQLND_MEMORY_POOL *
 mysqlnd_mempool_create(size_t arena_size TSRMLS_DC)
 {
 	/* We calloc, because we free(). We don't mnd_calloc()  for a reason. */
@@ -179,7 +179,7 @@ mysqlnd_mempool_create(size_t arena_size TSRMLS_DC)
 
 
 /* {{{ mysqlnd_mempool_destroy */
-void
+PHPAPI void
 mysqlnd_mempool_destroy(MYSQLND_MEMORY_POOL * pool TSRMLS_DC)
 {
 	DBG_ENTER("mysqlnd_mempool_destroy");
diff --git a/ext/mysqlnd/mysqlnd_block_alloc.h b/ext/mysqlnd/mysqlnd_block_alloc.h
index 5657621..0607d42 100644
--- a/ext/mysqlnd/mysqlnd_block_alloc.h
+++ b/ext/mysqlnd/mysqlnd_block_alloc.h
@@ -18,13 +18,13 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_block_alloc.h 282779 2009-06-25 19:03:52Z johannes $ */
+/* $Id: mysqlnd_block_alloc.h 293779 2010-01-20 17:09:28Z johannes $ */
 
 #ifndef MYSQLND_BLOCK_ALLOC_H
 #define MYSQLND_BLOCK_ALLOC_H
 
-MYSQLND_MEMORY_POOL *	mysqlnd_mempool_create(size_t arena_size TSRMLS_DC);
-void 					mysqlnd_mempool_destroy(MYSQLND_MEMORY_POOL * pool TSRMLS_DC);
+PHPAPI MYSQLND_MEMORY_POOL *	mysqlnd_mempool_create(size_t arena_size TSRMLS_DC);
+PHPAPI void 					mysqlnd_mempool_destroy(MYSQLND_MEMORY_POOL * pool TSRMLS_DC);
 
 #endif	/* MYSQLND_BLOCK_ALLOC_H */
 
diff --git a/ext/mysqlnd/mysqlnd_charset.c b/ext/mysqlnd/mysqlnd_charset.c
index 3fc434c..7ec9bfb 100644
--- a/ext/mysqlnd/mysqlnd_charset.c
+++ b/ext/mysqlnd/mysqlnd_charset.c
@@ -171,7 +171,7 @@ static unsigned int check_mb_eucjpms(const char *start, const char *end)
 	if (valid_eucjpms_ss2(start[0]) && (end - start) > 1 && valid_eucjpms_kata(start[1])) {
 		return 2;
 	}
-	if (valid_eucjpms_ss3(start[0]) && (end - start) > 2 && valid_eucjpms(start[1]) && 
+	if (valid_eucjpms_ss3(start[0]) && (end - start) > 2 && valid_eucjpms(start[1]) &&
 		valid_eucjpms(start[2])) {
 		return 2;
 	}
@@ -199,7 +199,7 @@ static unsigned int mysqlnd_mbcharlen_eucjpms(unsigned int jpms)
 
 static unsigned int check_mb_gb2312(const char *start, const char *end)
 {
-	return (valid_gb2312_head((unsigned int)start[0]) && end - start > 1 && 
+	return (valid_gb2312_head((unsigned int)start[0]) && end - start > 1 &&
 			valid_gb2312_tail((unsigned int)start[1])) ? 2 : 0;
 }
 
@@ -311,12 +311,12 @@ const MYSQLND_CHARSET mysqlnd_charsets[] =
 	{  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},	
+	{  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, 2, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
+	{  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},
@@ -372,7 +372,7 @@ const MYSQLND_CHARSET mysqlnd_charsets[] =
 	{  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", "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},
@@ -424,7 +424,47 @@ const MYSQLND_CHARSET mysqlnd_charsets[] =
 	{ 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},
-	{ 254, "utf8", "utf8_general_cs", 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}
 };
 /* }}} */
@@ -449,7 +489,7 @@ const MYSQLND_CHARSET mysqlnd_charsets60[] =
 	{  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},	
+	{  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},
@@ -635,7 +675,7 @@ PHPAPI ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset, char
 	for (;escapestr < end; escapestr++) {
 		unsigned int len = 0;
 		/* check unicode characters */
-		
+
 		if (cset->char_maxlen > 1 && (len = cset->mb_valid(escapestr, end))) {
 
 			/* check possible overflow */
@@ -685,7 +725,8 @@ PHPAPI ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, cha
 	zend_bool	escape_overflow = FALSE;
 
 	DBG_ENTER("mysqlnd_cset_escape_slashes");
-	
+	DBG_INF_FMT("charset=%s", cset->name);
+
 	for (;escapestr < end; escapestr++) {
 		char esc = '\0';
 		unsigned int len = 0;
diff --git a/ext/mysqlnd/mysqlnd_charset.h b/ext/mysqlnd/mysqlnd_charset.h
index 432fd03..46cf03f 100644
--- a/ext/mysqlnd/mysqlnd_charset.h
+++ b/ext/mysqlnd/mysqlnd_charset.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 6                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c
index 3537c13..2c2764f 100644
--- a/ext/mysqlnd/mysqlnd_debug.c
+++ b/ext/mysqlnd/mysqlnd_debug.c
@@ -1,4 +1,4 @@
-/*
+;/*
   +----------------------------------------------------------------------+
   | PHP Version 6                                                        |
   +----------------------------------------------------------------------+
@@ -18,14 +18,13 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_debug.c 282779 2009-06-25 19:03:52Z johannes $ */
+/* $Id: mysqlnd_debug.c 294543 2010-02-04 20:28:55Z johannes $ */
 
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_priv.h"
 #include "mysqlnd_debug.h"
 #include "mysqlnd_wireprotocol.h"
-#include "mysqlnd_palloc.h"
 #include "mysqlnd_statistics.h"
 #include "zend_builtin_functions.h"
 
@@ -48,18 +47,37 @@ static const char * const mysqlnd_debug_default_trace_file = "/tmp/mysqlnd.trace
 #define MYSQLND_DEBUG_FLUSH					128
 #define MYSQLND_DEBUG_TRACE_MEMORY_CALLS	256
 
-static char * mysqlnd_emalloc_name	= "_mysqlnd_emalloc";
-static char * mysqlnd_pemalloc_name	= "_mysqlnd_pemalloc";
-static char * mysqlnd_ecalloc_name	= "_mysqlnd_ecalloc";
-static char * mysqlnd_pecalloc_name	= "_mysqlnd_pecalloc";
-static char * mysqlnd_erealloc_name	= "_mysqlnd_erealloc";
-static char * mysqlnd_perealloc_name= "_mysqlnd_perealloc";
-static char * mysqlnd_efree_name	= "_mysqlnd_efree";
-static char * mysqlnd_pefree_name	= "_mysqlnd_pefree";
-static char * mysqlnd_malloc_name	= "_mysqlnd_malloc";
-static char * mysqlnd_calloc_name	= "_mysqlnd_calloc";
-static char * mysqlnd_realloc_name	= "_mysqlnd_realloc";
-static char * mysqlnd_free_name		= "_mysqlnd_free";
+static const char mysqlnd_emalloc_name[]	= "_mysqlnd_emalloc";
+static const char mysqlnd_pemalloc_name[]	= "_mysqlnd_pemalloc";
+static const char mysqlnd_ecalloc_name[]	= "_mysqlnd_ecalloc";
+static const char mysqlnd_pecalloc_name[]	= "_mysqlnd_pecalloc";
+static const char mysqlnd_erealloc_name[]	= "_mysqlnd_erealloc";
+static const char mysqlnd_perealloc_name[]	= "_mysqlnd_perealloc";
+static const char mysqlnd_efree_name[]		= "_mysqlnd_efree";
+static const char mysqlnd_pefree_name[]		= "_mysqlnd_pefree";
+static const char mysqlnd_malloc_name[]		= "_mysqlnd_malloc";
+static const char mysqlnd_calloc_name[]		= "_mysqlnd_calloc";
+static const char mysqlnd_realloc_name[]	= "_mysqlnd_realloc";
+static const char mysqlnd_free_name[]		= "_mysqlnd_free";
+
+const char * mysqlnd_debug_std_no_trace_funcs[] =
+{
+	mysqlnd_emalloc_name,
+	mysqlnd_ecalloc_name,
+	mysqlnd_efree_name,
+	mysqlnd_erealloc_name,
+	mysqlnd_pemalloc_name,
+	mysqlnd_pecalloc_name,
+	mysqlnd_pefree_name,
+	mysqlnd_perealloc_name,
+	mysqlnd_malloc_name,
+	mysqlnd_calloc_name,
+	mysqlnd_realloc_name,
+	mysqlnd_free_name,
+	mysqlnd_read_header_name,
+	mysqlnd_read_body_name,
+	NULL /* must be always last */
+};
 
 /* {{{ mysqlnd_debug::open */
 static enum_func_status
@@ -95,12 +113,6 @@ MYSQLND_METHOD(mysqlnd_debug, log)(MYSQLND_DEBUG * self,
 		 line_buffer[6], level_buffer[7];
 	MYSQLND_ZTS(self);
 
-#ifdef MYSQLND_THREADED
-	if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
-		return PASS; /* don't trace background threads */
-	}
-#endif
-
 	if (!self->stream) {
 		if (FAIL == self->m->open(self, FALSE)) {
 			return FAIL;
@@ -201,12 +213,6 @@ MYSQLND_METHOD(mysqlnd_debug, log_va)(MYSQLND_DEBUG *self,
 		 line_buffer[6], level_buffer[7];
 	MYSQLND_ZTS(self);
 
-#ifdef MYSQLND_THREADED
-	if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
-		return PASS; /* don't trace background threads */
-	}
-#endif
-
 	if (!self->stream) {
 		if (FAIL == self->m->open(self, FALSE)) {
 			return FAIL;
@@ -301,34 +307,24 @@ MYSQLND_METHOD(mysqlnd_debug, log_va)(MYSQLND_DEBUG *self,
 static zend_bool
 MYSQLND_METHOD(mysqlnd_debug, func_enter)(MYSQLND_DEBUG * self,
 										  unsigned int line, const char * const file,
-										  char * func_name, unsigned int func_name_len)
+										  const char * const func_name, unsigned int func_name_len)
 {
-#ifdef MYSQLND_THREADED
-	MYSQLND_ZTS(self);
-#endif
 	if ((self->flags & MYSQLND_DEBUG_DUMP_TRACE) == 0 || self->file_name == NULL) {
 		return FALSE;
 	}
-#ifdef MYSQLND_THREADED
-	if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
-		return FALSE; /* don't trace background threads */
-	}
-#endif
 	if (zend_stack_count(&self->call_stack) >= self->nest_level_limit) {
 		return FALSE;
 	}
 
-	if ((self->flags & MYSQLND_DEBUG_TRACE_MEMORY_CALLS) == 0 && 
-		(func_name == mysqlnd_emalloc_name	|| func_name == mysqlnd_pemalloc_name	||
-		 func_name == mysqlnd_ecalloc_name	|| func_name == mysqlnd_pecalloc_name	||
-		 func_name == mysqlnd_erealloc_name || func_name == mysqlnd_perealloc_name	||
-		 func_name == mysqlnd_efree_name	|| func_name == mysqlnd_pefree_name		|| 
-		 func_name == mysqlnd_malloc_name	|| func_name == mysqlnd_calloc_name		|| 
-		 func_name == mysqlnd_realloc_name	|| func_name == mysqlnd_free_name		||
-		 func_name == mysqlnd_palloc_zval_ptr_dtor_name	|| func_name == mysqlnd_palloc_get_zval_name ||
-		 func_name == mysqlnd_read_header_name || func_name == mysqlnd_read_body_name)) {
-		zend_stack_push(&self->call_stack, "", sizeof(""));
-	   	return FALSE;
+	if ((self->flags & MYSQLND_DEBUG_TRACE_MEMORY_CALLS) == 0 && self->skip_functions) {
+		const char ** p = self->skip_functions;
+		while (*p) {
+			if (*p == func_name) {
+				zend_stack_push(&self->call_stack, "", sizeof(""));
+			   	return FALSE;	
+			}
+			p++;
+		}
 	}
 
 	zend_stack_push(&self->call_stack, func_name, func_name_len + 1);
@@ -351,17 +347,9 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin
 										  const char * const file)
 {
 	char *func_name;
-#ifdef MYSQLND_THREADED
-	MYSQLND_ZTS(self);
-#endif
 	if ((self->flags & MYSQLND_DEBUG_DUMP_TRACE) == 0 || self->file_name == NULL) {
 		return PASS;
 	}
-#ifdef MYSQLND_THREADED
-	if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
-		return PASS; /* don't trace background threads */
-	}
-#endif
 	if (zend_stack_count(&self->call_stack) >= self->nest_level_limit) {
 		return PASS;
 	}
@@ -618,7 +606,8 @@ MYSQLND_CLASS_METHODS_END;
 
 
 /* {{{ mysqlnd_debug_init */
-PHPAPI MYSQLND_DEBUG *mysqlnd_debug_init(TSRMLS_D)
+PHPAPI MYSQLND_DEBUG *
+mysqlnd_debug_init(const char * skip_functions[] TSRMLS_DC)
 {
 	MYSQLND_DEBUG *ret = ecalloc(1, sizeof(MYSQLND_DEBUG));
 #ifdef ZTS
@@ -630,6 +619,7 @@ PHPAPI MYSQLND_DEBUG *mysqlnd_debug_init(TSRMLS_D)
 	zend_hash_init(&ret->not_filtered_functions, 0, NULL, NULL, 0);
 
 	ret->m = & mysqlnd_mysqlnd_debug_methods;
+	ret->skip_functions = skip_functions;
 	
 	return ret;
 }
@@ -637,12 +627,12 @@ PHPAPI MYSQLND_DEBUG *mysqlnd_debug_init(TSRMLS_D)
 
 
 /* {{{ _mysqlnd_debug */
-PHPAPI void _mysqlnd_debug(const char *mode TSRMLS_DC)
+PHPAPI void _mysqlnd_debug(const char * mode TSRMLS_DC)
 {
 #ifdef PHP_DEBUG
 	MYSQLND_DEBUG *dbg = MYSQLND_G(dbg);
 	if (!dbg) {
-		MYSQLND_G(dbg) = dbg = mysqlnd_debug_init(TSRMLS_C);
+		MYSQLND_G(dbg) = dbg = mysqlnd_debug_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC);
 		if (!dbg) {
 			return;
 		}
@@ -670,11 +660,6 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D)
 {
 	void *ret;
 	DBG_ENTER(mysqlnd_emalloc_name);
-#ifdef MYSQLND_THREADED
-	if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
-		DBG_RETURN(_mysqlnd_pemalloc(size, 1 TSRMLS_CC ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC));
-	}
-#endif
 
 	DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
 	DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
@@ -723,11 +708,6 @@ void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
 {
 	void *ret;
 	DBG_ENTER(mysqlnd_ecalloc_name);
-#ifdef MYSQLND_THREADED
-	if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
-		DBG_RETURN(_mysqlnd_pecalloc(nmemb, size, 1 TSRMLS_CC ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC));
-	}
-#endif
 	DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
 	DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
 
@@ -776,11 +756,6 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D)
 {
 	void *ret;
 	DBG_ENTER(mysqlnd_erealloc_name);
-#ifdef MYSQLND_THREADED
-	if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
-		DBG_RETURN(_mysqlnd_perealloc(ptr, new_size, 1 TSRMLS_CC ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC));
-	}
-#endif
 	DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
 	DBG_INF_FMT("ptr=%p new_size=%lu", ptr, new_size); 
 	DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
@@ -830,11 +805,6 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL
 void _mysqlnd_efree(void *ptr MYSQLND_MEM_D)
 {
 	DBG_ENTER(mysqlnd_efree_name);
-#ifdef MYSQLND_THREADED
-	if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
-		DBG_RETURN(_mysqlnd_pefree(ptr, 1 TSRMLS_CC ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC));
-	}
-#endif
 	DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
 	DBG_INF_FMT("ptr=%p", ptr); 
 	DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
@@ -1143,11 +1113,18 @@ static int mysqlnd_build_trace_string(zval **frame TSRMLS_DC, int num_args, va_l
 	long line;
 	HashTable *ht = Z_ARRVAL_PP(frame);
 	zval **file, **tmp;
+	uint * level;
 
+	level = va_arg(args, uint *);
 	str = va_arg(args, char**);
 	len = va_arg(args, int*);
 	num = va_arg(args, int*);
 
+	if (!*level) {
+		return ZEND_HASH_APPLY_KEEP;
+	}
+	--*level;
+
 	s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 1 + 1);
 	sprintf(s_tmp, "#%d ", (*num)++);
 	TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
@@ -1313,11 +1290,18 @@ static int mysqlnd_build_trace_string(zval **frame TSRMLS_DC, int num_args, va_l
 	long line;
 	HashTable *ht = Z_ARRVAL_PP(frame);
 	zval **file, **tmp;
+	uint * level;
 
+	level = va_arg(args, uint *);
 	str = va_arg(args, char**);
 	len = va_arg(args, int*);
 	num = va_arg(args, int*);
 
+	if (!*level) {
+		return ZEND_HASH_APPLY_KEEP;
+	}
+	--*level;
+
 	s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 1 + 1);
 	sprintf(s_tmp, "#%d ", (*num)++);
 	TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
@@ -1353,24 +1337,30 @@ static int mysqlnd_build_trace_string(zval **frame TSRMLS_DC, int num_args, va_l
 #endif
 
 
-char * mysqlnd_get_backtrace(TSRMLS_D)
+PHPAPI char * mysqlnd_get_backtrace(uint max_levels, size_t * length TSRMLS_DC)
 {
 	zval *trace;
 	char *res = estrdup(""), **str = &res, *s_tmp;
 	int res_len = 0, *len = &res_len, num = 0;
+	if (max_levels == 0) {
+		max_levels = 99999;
+	}
 
 	MAKE_STD_ZVAL(trace);
 	zend_fetch_debug_backtrace(trace, 0, 0 TSRMLS_CC);
 
-	zend_hash_apply_with_arguments(Z_ARRVAL_P(trace) TSRMLS_CC, (apply_func_args_t)mysqlnd_build_trace_string, 3, str, len, &num);
+	zend_hash_apply_with_arguments(Z_ARRVAL_P(trace) TSRMLS_CC, (apply_func_args_t)mysqlnd_build_trace_string, 4, &max_levels, str, len, &num);
 	zval_ptr_dtor(&trace);
 
-	s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1);
-	sprintf(s_tmp, "#%d {main}", num);
-	TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
-	efree(s_tmp);
+	if (max_levels) {
+		s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1);
+		sprintf(s_tmp, "#%d {main}", num);
+		TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
+		efree(s_tmp);
+	}
 
 	res[res_len] = '\0';
+	*length = res_len;
 
 	return res;
 }
diff --git a/ext/mysqlnd/mysqlnd_debug.h b/ext/mysqlnd/mysqlnd_debug.h
index 13eeb24..be46cf0 100644
--- a/ext/mysqlnd/mysqlnd_debug.h
+++ b/ext/mysqlnd/mysqlnd_debug.h
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_debug.h 278018 2009-03-30 13:55:47Z johannes $ */
+/* $Id: mysqlnd_debug.h 294543 2010-02-04 20:28:55Z johannes $ */
 
 #ifndef MYSQLND_DEBUG_H
 #define MYSQLND_DEBUG_H
@@ -36,7 +36,7 @@ struct st_mysqlnd_debug_methods
 	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,
-							char * func_name, unsigned int func_name_len);
+							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);
@@ -55,43 +55,67 @@ struct st_mysqlnd_debug
 	zend_stack call_stack;
 	HashTable not_filtered_functions;
 	struct st_mysqlnd_debug_methods *m;
+	const char ** skip_functions;
 };
 
+PHPAPI extern const char * mysqlnd_debug_std_no_trace_funcs[];
 
-PHPAPI MYSQLND_DEBUG *mysqlnd_debug_init(TSRMLS_D);
+PHPAPI MYSQLND_DEBUG * mysqlnd_debug_init(const char * skip_functions[] TSRMLS_DC);
 
 #define MYSQLND_MEM_D 	TSRMLS_DC ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC
 
 
-void *	_mysqlnd_emalloc(size_t size MYSQLND_MEM_D);
-void *	_mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D);
-void *	_mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D);
-void *	_mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent MYSQLND_MEM_D);
-void *	_mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D);
-void *	_mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQLND_MEM_D);
-void 	_mysqlnd_efree(void *ptr MYSQLND_MEM_D);
-void 	_mysqlnd_pefree(void *ptr, zend_bool persistent MYSQLND_MEM_D);
-void *	_mysqlnd_malloc(size_t size MYSQLND_MEM_D);
-void *	_mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D);
-void *	_mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D);
-void	_mysqlnd_free(void *ptr MYSQLND_MEM_D);
+PHPAPI void *	_mysqlnd_emalloc(size_t size MYSQLND_MEM_D);
+PHPAPI void *	_mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D);
+PHPAPI void *	_mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D);
+PHPAPI void *	_mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent MYSQLND_MEM_D);
+PHPAPI void *	_mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D);
+PHPAPI void *	_mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQLND_MEM_D);
+PHPAPI void 	_mysqlnd_efree(void *ptr MYSQLND_MEM_D);
+PHPAPI void 	_mysqlnd_pefree(void *ptr, zend_bool persistent MYSQLND_MEM_D);
+PHPAPI void *	_mysqlnd_malloc(size_t size MYSQLND_MEM_D);
+PHPAPI void *	_mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D);
+PHPAPI void *	_mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D);
+PHPAPI void	_mysqlnd_free(void *ptr MYSQLND_MEM_D);
 
-char *	mysqlnd_get_backtrace(TSRMLS_D);
+PHPAPI char *	mysqlnd_get_backtrace(uint max_levels, size_t * length TSRMLS_DC);
+
+#if defined(__GNUC__)
+#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)
+
+#else
+static inline void DBG_INF_EX(MYSQLND_DEBUG * dbg_obj, const char * const msg) {}
+static inline void DBG_ERR_EX(MYSQLND_DEBUG * dbg_obj, const char * const msg) {}
+static inline void DBG_INF_FMT_EX(MYSQLND_DEBUG * dbg_obj, ...) {}
+static inline void DBG_ERR_FMT_EX(MYSQLND_DEBUG * dbg_obj, ...) {}
+static inline void DBG_ENTER_EX(MYSQLND_DEBUG * dbg_obj, const char * const func_name) {}
+#define DBG_RETURN_EX(dbg_obj, value) return (value)
+#define DBG_VOID_RETURN_EX(dbg_obj) return
+
+#endif
 
 #if MYSQLND_DBG_ENABLED == 1
 
-#define DBG_INF(msg) do { if (dbg_skip_trace == FALSE) MYSQLND_G(dbg)->m->log(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "info : ", (msg)); } while (0)
-#define DBG_ERR(msg) do { if (dbg_skip_trace == FALSE) MYSQLND_G(dbg)->m->log(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "error: ", (msg)); } while (0)
-#define DBG_INF_FMT(...) do { if (dbg_skip_trace == FALSE) MYSQLND_G(dbg)->m->log_va(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "info : ", __VA_ARGS__); } while (0)
-#define DBG_ERR_FMT(...) do { if (dbg_skip_trace == FALSE) MYSQLND_G(dbg)->m->log_va(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "error: ", __VA_ARGS__); } while (0)
+#define DBG_INF(msg)		DBG_INF_EX(MYSQLND_G(dbg), (msg))
+#define DBG_ERR(msg)		DBG_ERR_EX(MYSQLND_G(dbg), (msg))
+#define DBG_INF_FMT(...)	DBG_INF_FMT_EX(MYSQLND_G(dbg), __VA_ARGS__)
+#define DBG_ERR_FMT(...)	DBG_ERR_FMT_EX(MYSQLND_G(dbg), __VA_ARGS__)
 
-#define DBG_ENTER(func_name) zend_bool dbg_skip_trace = TRUE; if (MYSQLND_G(dbg)) dbg_skip_trace = !MYSQLND_G(dbg)->m->func_enter(MYSQLND_G(dbg), __LINE__, __FILE__, func_name, strlen(func_name));
-#define DBG_RETURN(value)	do { if (MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->func_leave(MYSQLND_G(dbg), __LINE__, __FILE__); return (value); } while (0)
-#define DBG_VOID_RETURN		do { if (MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->func_leave(MYSQLND_G(dbg), __LINE__, __FILE__); return; } while (0)
+#define DBG_ENTER(func_name)	DBG_ENTER_EX(MYSQLND_G(dbg), (func_name))
+#define DBG_RETURN(value)		DBG_RETURN_EX(MYSQLND_G(dbg), (value))
+#define DBG_VOID_RETURN			DBG_VOID_RETURN_EX(MYSQLND_G(dbg))
 
 #elif MYSQLND_DBG_ENABLED == 0
 
 
+
 static inline void DBG_INF(const char * const msg) {}
 static inline void DBG_ERR(const char * const msg) {}
 static inline void DBG_INF_FMT(const char * const format, ...) {}
@@ -99,6 +123,7 @@ static inline void DBG_ERR_FMT(const char * const format, ...) {}
 static inline void DBG_ENTER(const char * const func_name) {}
 #define DBG_RETURN(value)	return (value)
 #define DBG_VOID_RETURN		return
+
 #endif
 
 
diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h
index 554dab8..281319c 100644
--- a/ext/mysqlnd/mysqlnd_enum_n_def.h
+++ b/ext/mysqlnd/mysqlnd_enum_n_def.h
@@ -18,10 +18,21 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_enum_n_def.h 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysqlnd_enum_n_def.h 293779 2010-01-20 17:09:28Z johannes $ */
 #ifndef MYSQLND_ENUM_N_DEF_H
 #define MYSQLND_ENUM_N_DEF_H
 
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+#define MYSQLND_MIN_COMPRESS_LEN 0
+
 #define MYSQLND_MAX_PACKET_SIZE (256L*256L*256L-1)
 
 #define MYSQLND_ERRMSG_SIZE			512
@@ -354,6 +365,8 @@ typedef enum mysqlnd_collected_stats
 	STAT_ROWS_FETCHED_FROM_CLIENT_PS_BUF,
 	STAT_ROWS_FETCHED_FROM_CLIENT_PS_UNBUF,
 	STAT_ROWS_FETCHED_FROM_CLIENT_PS_CURSOR,
+	STAT_ROWS_AFFECTED_NORMAL,
+	STAT_ROWS_AFFECTED_PS,
 	STAT_ROWS_SKIPPED_NORMAL,
 	STAT_ROWS_SKIPPED_PS,
 	STAT_COPY_ON_WRITE_SAVED,
@@ -432,10 +445,93 @@ typedef enum mysqlnd_collected_stats
 	STAT_BINARY_TYPE_FETCHED_OTHER,
 	STAT_INIT_COMMAND_EXECUTED_COUNT,
 	STAT_INIT_COMMAND_FAILED_COUNT,
+	STAT_COM_QUIT,
+	STAT_COM_INIT_DB,
+	STAT_COM_QUERY,
+	STAT_COM_FIELD_LIST,
+	STAT_COM_CREATE_DB,
+	STAT_COM_DROP_DB,
+	STAT_COM_REFRESH,
+	STAT_COM_SHUTDOWN,
+	STAT_COM_STATISTICS,
+	STAT_COM_PROCESS_INFO,
+	STAT_COM_CONNECT,
+	STAT_COM_PROCESS_KILL,
+	STAT_COM_DEBUG,
+	STAT_COM_PING,
+	STAT_COM_TIME,
+	STAT_COM_DELAYED_INSERT,
+	STAT_COM_CHANGE_USER,
+	STAT_COM_BINLOG_DUMP,
+	STAT_COM_TABLE_DUMP,
+	STAT_COM_CONNECT_OUT,
+	STAT_COM_REGISTER_SLAVE,
+	STAT_COM_STMT_PREPARE,
+	STAT_COM_STMT_EXECUTE,
+	STAT_COM_STMT_SEND_LONG_DATA,
+	STAT_COM_STMT_CLOSE,
+	STAT_COM_STMT_RESET,
+	STAT_COM_SET_OPTION,
+	STAT_COM_STMT_FETCH,
+	STAT_COM_DAEMON,
 	STAT_LAST /* Should be always the last */
 } enum_mysqlnd_collected_stats;
 
 
+/* Enums */
+enum mysqlnd_packet_type
+{
+	PROT_GREET_PACKET= 0,
+	PROT_AUTH_PACKET,
+	PROT_OK_PACKET,
+	PROT_EOF_PACKET,
+	PROT_CMD_PACKET,
+	PROT_RSET_HEADER_PACKET,
+	PROT_RSET_FLD_PACKET,
+	PROT_ROW_PACKET,
+	PROT_STATS_PACKET,
+	PROT_PREPARE_RESP_PACKET,
+	PROT_CHG_USER_RESP_PACKET,
+	PROT_LAST, /* should always be last */
+};
+
+
+enum php_mysqlnd_server_command
+{
+	COM_SLEEP = 0,
+	COM_QUIT,
+	COM_INIT_DB,
+	COM_QUERY,
+	COM_FIELD_LIST,
+	COM_CREATE_DB,
+	COM_DROP_DB,
+	COM_REFRESH,
+	COM_SHUTDOWN,
+	COM_STATISTICS,
+	COM_PROCESS_INFO,
+	COM_CONNECT,
+	COM_PROCESS_KILL,
+	COM_DEBUG,
+	COM_PING,
+	COM_TIME = 15,
+	COM_DELAYED_INSERT,
+	COM_CHANGE_USER,
+	COM_BINLOG_DUMP,
+	COM_TABLE_DUMP,
+	COM_CONNECT_OUT = 20,
+	COM_REGISTER_SLAVE,
+	COM_STMT_PREPARE = 22,
+	COM_STMT_EXECUTE = 23,
+	COM_STMT_SEND_LONG_DATA = 24,
+	COM_STMT_CLOSE = 25,
+	COM_STMT_RESET = 26,
+	COM_SET_OPTION = 27,
+	COM_STMT_FETCH = 28,
+	COM_DAEMON,
+	COM_END
+};
+
+
 #define MYSQLND_DEFAULT_PREFETCH_ROWS (ulong) 1
 
 #define MYSQLND_REFRESH_GRANT      1	/* Refresh grant tables */
diff --git a/ext/mysqlnd/mysqlnd_libmysql_compat.h b/ext/mysqlnd/mysqlnd_libmysql_compat.h
index a9e15c7..78f48c9 100644
--- a/ext/mysqlnd/mysqlnd_libmysql_compat.h
+++ b/ext/mysqlnd/mysqlnd_libmysql_compat.h
@@ -41,7 +41,7 @@
 /* functions */
 #define mysql_affected_rows(r)			mysqlnd_affected_rows((r))
 #define mysql_autocommit(r,m)			mysqlnd_autocommit((r),(m))
-#define mysql_change_user(r,a,b,c)		mysqlnd_change_user((r), (a), (b), (c))
+#define mysql_change_user(r,a,b,c)		mysqlnd_change_user((r), (a), (b), (c), FALSE)
 #define mysql_character_set_name(c)		mysqlnd_character_set_name((c))
 #define mysql_close(r)					mysqlnd_close((r), MYSQLND_CLOSE_EXPLICIT)
 #define mysql_commit(r)					mysqlnd_commit((r))
diff --git a/ext/mysqlnd/mysqlnd_loaddata.c b/ext/mysqlnd/mysqlnd_loaddata.c
index f37aff5..77670ec 100644
--- a/ext/mysqlnd/mysqlnd_loaddata.c
+++ b/ext/mysqlnd/mysqlnd_loaddata.c
@@ -25,12 +25,6 @@
 #include "mysqlnd_priv.h"
 #include "mysqlnd_debug.h"
 
-enum_func_status mysqlnd_simple_command_handle_response(MYSQLND *conn,
-										enum php_mysql_packet_type ok_packet,
-										zend_bool silent, enum php_mysqlnd_server_command command,
-										zend_bool ignore_upsert_status
-									  	TSRMLS_DC);
-
 
 #define ALLOC_CALLBACK_ARGS(a, b, c)\
 if (c) {\
@@ -75,7 +69,7 @@ int mysqlnd_local_infile_init(void **ptr, char *filename, void **userdata TSRMLS
 
 	if (info->fd == NULL) {
 		snprintf((char *)info->error_msg, sizeof(info->error_msg), "Can't find file '%-.64s'.", filename);
-		info->error_no = MYSQLND_EE_FILENOTFOUND; 
+		info->error_no = MYSQLND_EE_FILENOTFOUND;
 		DBG_RETURN(1);
 	}
 
@@ -188,7 +182,7 @@ mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_w
 	if (!(conn->options.flags & CLIENT_LOCAL_FILES)) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "LOAD DATA LOCAL INFILE forbidden");
 		/* write empty packet to server */
-		ret = mysqlnd_stream_write_w_header(conn, empty_packet, 0 TSRMLS_CC);
+		ret = conn->net->m.send(conn, empty_packet, 0 TSRMLS_CC);
 		*is_warning = TRUE;
 		goto infile_error;
 	}
@@ -196,7 +190,7 @@ mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_w
 	infile = conn->infile;
 	/* allocate buffer for reading data */
 	buf = (char *)mnd_ecalloc(1, buflen);
-	
+
 	*is_warning = FALSE;
 
 	/* init handler: allocate read buffer and open file */
@@ -208,14 +202,14 @@ mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_w
 				infile.local_infile_error(info, conn->error_info.error,
 										  sizeof(conn->error_info.error) TSRMLS_CC);
 		/* write empty packet to server */
-		ret = mysqlnd_stream_write_w_header(conn, empty_packet, 0 TSRMLS_CC);
+		ret = conn->net->m.send(conn, empty_packet, 0 TSRMLS_CC);
 		goto infile_error;
 	}
 
 	/* read data */
 	while ((bufsize = infile.local_infile_read (info, buf + MYSQLND_HEADER_SIZE,
 												buflen - MYSQLND_HEADER_SIZE TSRMLS_CC)) > 0) {
-		if ((ret = mysqlnd_stream_write_w_header(conn, buf, bufsize TSRMLS_CC)) < 0) {
+		if ((ret = conn->net->m.send(conn, buf, bufsize TSRMLS_CC)) < 0) {
 			DBG_ERR_FMT("Error during read : %d %s %s", CR_SERVER_LOST, UNKNOWN_SQLSTATE, lost_conn);
 			SET_CLIENT_ERROR(conn->error_info, CR_SERVER_LOST, UNKNOWN_SQLSTATE, lost_conn);
 			goto infile_error;
@@ -223,7 +217,7 @@ mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_w
 	}
 
 	/* send empty packet for eof */
-	if ((ret = mysqlnd_stream_write_w_header(conn, empty_packet, 0 TSRMLS_CC)) < 0) {
+	if ((ret = conn->net->m.send(conn, empty_packet, 0 TSRMLS_CC)) < 0) {
 		SET_CLIENT_ERROR(conn->error_info, CR_SERVER_LOST, UNKNOWN_SQLSTATE, lost_conn);
 		goto infile_error;
 	}
@@ -242,7 +236,7 @@ mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_w
 
 infile_error:
 	/* get response from server and update upsert values */
-	if (FAIL == mysqlnd_simple_command_handle_response(conn, PROT_OK_PACKET, FALSE, COM_QUERY, FALSE TSRMLS_CC)) {
+	if (FAIL == conn->m->simple_command_handle_response(conn, PROT_OK_PACKET, FALSE, COM_QUERY, FALSE TSRMLS_CC)) {
 		result = FAIL;
 	}
 
diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c
new file mode 100644
index 0000000..8f4c46e
--- /dev/null
+++ b/ext/mysqlnd/mysqlnd_net.c
@@ -0,0 +1,744 @@
+/*
+  +----------------------------------------------------------------------+
+  | PHP Version 6                                                        |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 2006-2009 The PHP Group                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.txt                                  |
+  | If you did not receive a copy of the PHP license and are unable to   |
+  | obtain it through the world-wide-web, please send a note to          |
+  | license at php.net so we can mail you a copy immediately.               |
+  +----------------------------------------------------------------------+
+  | Authors: Georg Richter <georg at mysql.com>                             |
+  |          Andrey Hristov <andrey at mysql.com>                           |
+  |          Ulf Wendel <uwendel at mysql.com>                              |
+  +----------------------------------------------------------------------+
+*/
+#include "php.h"
+#include "php_globals.h"
+#include "mysqlnd.h"
+#include "mysqlnd_priv.h"
+#include "mysqlnd_wireprotocol.h"
+#include "mysqlnd_statistics.h"
+#include "mysqlnd_debug.h"
+#include "mysqlnd_block_alloc.h"
+#include "ext/standard/sha1.h"
+#include "php_network.h"
+#include "zend_ini.h"
+#ifdef MYSQLND_COMPRESSION_ENABLED
+#include <zlib.h>
+#endif
+
+#ifndef PHP_WIN32
+#include <netinet/tcp.h>
+#else
+#include <winsock.h>
+#endif
+
+
+/* {{{ mysqlnd_set_sock_no_delay */
+static int
+mysqlnd_set_sock_no_delay(php_stream * stream)
+{
+
+	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");
+
+	if (result == -1) {
+		ret = FAILURE;
+	}
+
+	DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_net::network_read */
+static enum_func_status
+MYSQLND_METHOD(mysqlnd_net, network_read)(MYSQLND * conn, zend_uchar * buffer, size_t count TSRMLS_DC)
+{
+	size_t to_read = count, ret;
+	size_t old_chunk_size = conn->net->stream->chunk_size;
+	DBG_ENTER("mysqlnd_net::network_read");
+	DBG_INF_FMT("count=%u", count);
+	conn->net->stream->chunk_size = MIN(to_read, conn->net->options.net_read_buffer_size);
+	while (to_read) {
+		if (!(ret = php_stream_read(conn->net->stream, (char *) buffer, to_read))) {
+			DBG_ERR_FMT("Error while reading header from socket");
+			DBG_RETURN(FAIL);
+		}
+		buffer += ret;
+		to_read -= ret;
+	}
+	MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats, STAT_BYTES_RECEIVED, count);
+	conn->net->stream->chunk_size = old_chunk_size;
+	DBG_RETURN(PASS);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_net::network_write */
+static size_t
+MYSQLND_METHOD(mysqlnd_net, network_write)(MYSQLND * const conn, const zend_uchar * const buf, size_t count TSRMLS_DC)
+{
+	size_t ret;
+	DBG_ENTER("mysqlnd_net::network_write");
+	ret = php_stream_write(conn->net->stream, (char *)buf, count);
+	DBG_RETURN(ret);
+}
+/* }}} */
+
+
+
+/* {{{ mysqlnd_net::connect */
+static enum_func_status
+MYSQLND_METHOD(mysqlnd_net, connect)(MYSQLND_NET * net, const char * const scheme, size_t scheme_len, zend_bool persistent, char **errstr, int * errcode TSRMLS_DC)
+{
+	unsigned int streams_options = ENFORCE_SAFE_MODE;
+	unsigned int streams_flags = STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT;
+	char * hashed_details = NULL;
+	int hashed_details_len = 0;
+	struct timeval tv;
+	DBG_ENTER("mysqlnd_net::connect");
+
+	if (persistent) {
+		hashed_details_len = spprintf(&hashed_details, 0, "%p", net);
+		DBG_INF_FMT("hashed_details=%s", hashed_details);
+	}
+
+	net->packet_no = net->compressed_envelope_packet_no = 0;
+
+	if (net->options.timeout_connect) {
+		tv.tv_sec = net->options.timeout_connect;
+		tv.tv_usec = 0;
+	}
+
+	net->stream = php_stream_xport_create(scheme, scheme_len, streams_options, streams_flags,
+										  hashed_details, (net->options.timeout_connect) ? &tv : NULL,
+										  NULL /*ctx*/, errstr, errcode);
+
+
+	if (*errstr || !net->stream) {
+		if (hashed_details) {
+			efree(hashed_details);
+		}
+		*errcode = CR_CONNECTION_ERROR;
+		DBG_RETURN(FAIL);
+	}
+
+	if (hashed_details) {
+		/*
+		  If persistent, the streams register it in EG(persistent_list).
+		  This is unwanted. ext/mysql or ext/mysqli are responsible to clean,
+		  whatever they have to.
+		*/
+		zend_rsrc_list_entry *le;
+
+		if (zend_hash_find(&EG(persistent_list), hashed_details, hashed_details_len + 1,
+						   (void*) &le) == SUCCESS) {
+			/*
+			  in_free will let streams code skip destructing - big HACK,
+			  but STREAMS suck big time regarding persistent streams.
+			  Just not compatible for extensions that need persistency.
+			*/
+			net->stream->in_free = 1;
+			zend_hash_del(&EG(persistent_list), hashed_details, hashed_details_len + 1);
+			net->stream->in_free = 0;
+		}
+#if ZEND_DEBUG
+		/* Shut-up the streams, they don't know what they are doing */
+		net->stream->__exposed = 1;
+#endif
+		efree(hashed_details);
+	}
+
+	if (!net->options.timeout_read) {
+		/* should always happen because read_timeout cannot be set via API */
+		net->options.timeout_read = (unsigned int) MYSQLND_G(net_read_timeout);
+	}
+	if (net->options.timeout_read)
+	{
+		tv.tv_sec = net->options.timeout_read;
+		tv.tv_usec = 0;
+		php_stream_set_option(net->stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv);
+	}
+
+	if (!memcmp(scheme, "tcp://", sizeof("tcp://") - 1)) {
+		/* TCP -> Set TCP_NODELAY */
+		mysqlnd_set_sock_no_delay(net->stream);
+	}
+
+	{
+		unsigned int buf_size = MYSQLND_G(net_read_buffer_size); /* this is long, cast to unsigned int*/
+		net->m.set_client_option(net, MYSQLND_OPT_NET_READ_BUFFER_SIZE, (char *)&buf_size TSRMLS_CC);
+	}
+
+
+	DBG_RETURN(PASS);
+}
+/* }}} */
+
+
+/* We assume that MYSQLND_HEADER_SIZE is 4 bytes !! */
+#define STORE_HEADER_SIZE(safe_storage, buffer)  int4store((safe_storage), (*(uint32_t *)(buffer)))
+#define RESTORE_HEADER_SIZE(buffer, safe_storage) STORE_HEADER_SIZE((safe_storage), (buffer))
+
+/* {{{ mysqlnd_net::send */
+/*
+  IMPORTANT : It's expected that buf has place in the beginning for MYSQLND_HEADER_SIZE !!!!
+  			  This is done for performance reasons in the caller of this function.
+			  Otherwise we will have to do send two TCP packets, or do new alloc and memcpy.
+			  Neither are quick, thus the clients of this function are obligated to do
+			  what they are asked for.
+
+  `count` is actually the length of the payload data. Thus :
+  count + MYSQLND_HEADER_SIZE = sizeof(buf) (not the pointer but the actual buffer)
+*/
+size_t
+MYSQLND_METHOD(mysqlnd_net, send)(MYSQLND * const conn, char * const buf, size_t count TSRMLS_DC)
+{
+	zend_uchar safe_buf[((MYSQLND_HEADER_SIZE) + (sizeof(zend_uchar)) - 1) / (sizeof(zend_uchar))];
+	zend_uchar *safe_storage = safe_buf;
+	MYSQLND_NET *net = conn->net;
+	size_t old_chunk_size = net->stream->chunk_size;
+	size_t ret, packets_sent = 1;
+	size_t left = count;
+	zend_uchar *p = (zend_uchar *) buf;
+	zend_uchar * compress_buf = NULL;
+	size_t to_be_sent;
+
+	DBG_ENTER("mysqlnd_net::send");
+	DBG_INF_FMT("conn=%llu count=%lu compression=%d", conn->thread_id, count, net->compressed);
+
+	net->stream->chunk_size = MYSQLND_MAX_PACKET_SIZE;
+
+	if (net->compressed == TRUE) {
+		size_t comp_buf_size = MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE + MIN(left, MYSQLND_MAX_PACKET_SIZE);
+		DBG_INF_FMT("compress_buf_size=%d", comp_buf_size);
+		compress_buf = emalloc(comp_buf_size);
+	}
+
+	do {
+		to_be_sent = MIN(left, MYSQLND_MAX_PACKET_SIZE);
+#ifdef MYSQLND_COMPRESSION_ENABLED
+		if (net->compressed == TRUE) {
+			/* here we need to compress the data and then write it, first comes the compressed header */
+			size_t tmp_complen = to_be_sent;
+			size_t payload_size;
+			zend_uchar * uncompressed_payload = p; /* should include the header */
+
+			STORE_HEADER_SIZE(safe_storage, uncompressed_payload);
+			int3store(uncompressed_payload, to_be_sent);
+			int1store(uncompressed_payload + 3, net->packet_no);
+			if (PASS == net->m.encode((compress_buf + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE), tmp_complen, uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE TSRMLS_CC)) {
+				int3store(compress_buf + MYSQLND_HEADER_SIZE, to_be_sent + MYSQLND_HEADER_SIZE);
+				payload_size = tmp_complen;
+			} else {
+				int3store(compress_buf + MYSQLND_HEADER_SIZE, 0);
+				memcpy(compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE);
+				payload_size = to_be_sent + MYSQLND_HEADER_SIZE;
+			}
+			RESTORE_HEADER_SIZE(uncompressed_payload, safe_storage);
+
+			int3store(compress_buf, payload_size);
+			int1store(compress_buf + 3, net->packet_no);
+			DBG_INF_FMT("writing %d bytes to the network", payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE);
+			ret = conn->net->m.network_write(conn, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE TSRMLS_CC);
+			net->compressed_envelope_packet_no++;
+  #if WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY
+			if (res == Z_OK) {
+				size_t decompressed_size = left + MYSQLND_HEADER_SIZE;
+				zend_uchar * decompressed_data = malloc(decompressed_size);
+				int error = net->m.decode(decompressed_data, decompressed_size, compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, payload_size);
+				if (error == Z_OK) {
+					int i;
+					DBG_INF("success decompressing");
+					for (i = 0 ; i < decompressed_size; i++) {
+						if (i && (i % 30 == 0)) {
+							printf("\n\t\t");
+						}
+						printf("%.2X ", (int)*((char*)&(decompressed_data[i])));
+						DBG_INF_FMT("%.2X ", (int)*((char*)&(decompressed_data[i])));
+					}
+				} else {
+					DBG_INF("error decompressing");
+				}
+				free(decompressed_data);
+			}
+  #endif /* WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY */
+		} else
+#endif /* MYSQLND_COMPRESSION_ENABLED */
+		{
+			DBG_INF("no compression");
+			STORE_HEADER_SIZE(safe_storage, p);
+			int3store(p, to_be_sent);
+			int1store(p + 3, net->packet_no);
+			ret = conn->net->m.network_write(conn, p, to_be_sent + MYSQLND_HEADER_SIZE TSRMLS_CC);
+			RESTORE_HEADER_SIZE(p, safe_storage);
+			net->compressed_envelope_packet_no++;
+		}
+		net->packet_no++;
+
+		p += to_be_sent;
+		left -= to_be_sent;
+		packets_sent++;
+		/*
+		  if left is 0 then there is nothing more to send, but if the last packet was exactly 
+		  with the size MYSQLND_MAX_PACKET_SIZE we need to send additional packet, which has
+		  empty payload. Thus if left == 0 we check for to_be_sent being the max size. If it is
+		  indeed it then loop once more, then to_be_sent will become 0, left will stay 0. Empty
+		  packet will be sent and this loop will end.
+		*/
+	} while (ret && (left > 0 || to_be_sent == MYSQLND_MAX_PACKET_SIZE));
+
+	DBG_INF_FMT("packet_size=%d packet_no=%d", left, net->packet_no);
+	/* Even for zero size payload we have to send a packet */
+	if (!ret) {
+		DBG_ERR_FMT("Can't %u send bytes", count);
+		conn->state = CONN_QUIT_SENT;
+		SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
+	}
+
+	MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn->stats,
+			STAT_BYTES_SENT, count + packets_sent * MYSQLND_HEADER_SIZE,
+			STAT_PROTOCOL_OVERHEAD_OUT, packets_sent * MYSQLND_HEADER_SIZE,
+			STAT_PACKETS_SENT, packets_sent);
+
+	net->stream->chunk_size = old_chunk_size;
+	if (compress_buf) {
+		efree(compress_buf);
+	}
+	DBG_RETURN(ret);
+}
+/* }}} */
+
+
+#ifdef MYSQLND_COMPRESSION_ENABLED
+/* {{{ php_mysqlnd_read_buffer_is_empty */
+static zend_bool
+php_mysqlnd_read_buffer_is_empty(MYSQLND_READ_BUFFER * buffer)
+{
+	return buffer->len? FALSE:TRUE;
+}
+/* }}} */
+
+
+/* {{{ php_mysqlnd_read_buffer_read */
+static void
+php_mysqlnd_read_buffer_read(MYSQLND_READ_BUFFER * buffer, size_t count, zend_uchar * dest)
+{
+	if (buffer->len >= count) {
+		memcpy(dest, buffer->data + buffer->offset, count);
+		buffer->offset += count;
+		buffer->len -= count;
+	}
+}
+/* }}} */
+
+
+/* {{{ php_mysqlnd_read_buffer_bytes_left */
+static size_t
+php_mysqlnd_read_buffer_bytes_left(MYSQLND_READ_BUFFER * buffer)
+{
+	return buffer->len;
+}
+/* }}} */
+
+
+/* {{{ php_mysqlnd_read_buffer_free */
+static void
+php_mysqlnd_read_buffer_free(MYSQLND_READ_BUFFER ** buffer TSRMLS_DC)
+{
+	DBG_ENTER("php_mysqlnd_read_buffer_free");
+	if (*buffer) {
+		mnd_efree((*buffer)->data);
+		mnd_efree(*buffer);
+		*buffer = NULL;
+	}
+	DBG_VOID_RETURN;
+}
+/* }}} */
+
+
+/* {{{ php_mysqlnd_create_read_buffer */
+static MYSQLND_READ_BUFFER *
+mysqlnd_create_read_buffer(size_t count TSRMLS_DC)
+{
+	MYSQLND_READ_BUFFER * ret = mnd_emalloc(sizeof(MYSQLND_READ_BUFFER));
+	DBG_ENTER("mysqlnd_create_read_buffer");
+	ret->is_empty = php_mysqlnd_read_buffer_is_empty;
+	ret->read = php_mysqlnd_read_buffer_read;
+	ret->bytes_left = php_mysqlnd_read_buffer_bytes_left;
+	ret->free_buffer = php_mysqlnd_read_buffer_free;
+	ret->data = mnd_emalloc(count);
+	ret->size = ret->len = count;
+	ret->offset = 0;
+	DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_read_compressed_packet_from_stream_and_fill_read_buffer */
+static enum_func_status
+mysqlnd_read_compressed_packet_from_stream_and_fill_read_buffer(MYSQLND * conn, size_t net_payload_size TSRMLS_DC)
+{
+	MYSQLND_NET * net = conn->net;
+	size_t decompressed_size;
+	enum_func_status ret = PASS;
+	zend_uchar * compressed_data = NULL;
+	zend_uchar comp_header[COMPRESSED_HEADER_SIZE];
+	DBG_ENTER("mysqlnd_read_compressed_packet_from_stream_and_fill_read_buffer");
+
+	/* Read the compressed header */
+	if (FAIL == conn->net->m.network_read(conn, comp_header, COMPRESSED_HEADER_SIZE TSRMLS_CC)) {
+		DBG_RETURN(FAIL);
+	}
+	decompressed_size = uint3korr(comp_header);
+
+	/* When decompressed_size is 0, then the data is not compressed, and we have wasted 3 bytes */
+	/* we need to decompress the data */
+
+	if (decompressed_size) {
+		compressed_data = emalloc(net_payload_size);
+		if (FAIL == conn->net->m.network_read(conn, compressed_data, net_payload_size TSRMLS_CC)) {
+			ret = FAIL;
+			goto end;
+		}
+		net->uncompressed_data = mysqlnd_create_read_buffer(decompressed_size TSRMLS_CC);
+		ret = net->m.decode(net->uncompressed_data->data, decompressed_size, compressed_data, net_payload_size TSRMLS_CC);
+		if (ret == FAIL) {
+			goto end;
+		}
+	} else {
+		DBG_INF_FMT("The server decided not to compress the data. Our job is easy. Copying %u bytes", net_payload_size);
+		net->uncompressed_data = mysqlnd_create_read_buffer(net_payload_size TSRMLS_CC);
+		if (FAIL == conn->net->m.network_read(conn, net->uncompressed_data->data, net_payload_size TSRMLS_CC)) {
+			ret = FAIL;
+			goto end;
+		}
+	}
+end:
+	if (compressed_data) {
+		efree(compressed_data);
+	}
+	DBG_RETURN(ret);
+}
+/* }}} */
+#endif /* MYSQLND_COMPRESSION_ENABLED */
+
+
+/* {{{ mysqlnd_net::decode */
+static enum_func_status
+MYSQLND_METHOD(mysqlnd_net, decode)(zend_uchar * uncompressed_data, size_t uncompressed_data_len,
+									const zend_uchar * const compressed_data, size_t compressed_data_len TSRMLS_DC)
+{
+	int error;
+	uLongf tmp_complen = uncompressed_data_len;
+	DBG_ENTER("mysqlnd_net::decode");
+	error = uncompress(uncompressed_data, &tmp_complen, compressed_data, compressed_data_len);
+
+	DBG_INF_FMT("compressed data: decomp_len=%d compressed_size=%d", tmp_complen, compressed_data_len);
+	if (error != Z_OK) {
+		DBG_INF_FMT("decompression NOT successful. error=%d Z_OK=%d Z_BUF_ERROR=%d Z_MEM_ERROR=%d", error, Z_OK, Z_BUF_ERROR, Z_MEM_ERROR);
+	}
+	DBG_RETURN(error == Z_OK? PASS:FAIL);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_net::encode */
+static enum_func_status
+MYSQLND_METHOD(mysqlnd_net, encode)(zend_uchar * compress_buffer, size_t compress_buffer_len,
+									const zend_uchar * const uncompressed_data, size_t uncompressed_data_len TSRMLS_DC)
+{
+	int error;
+	uLongf tmp_complen = compress_buffer_len;
+	DBG_ENTER("mysqlnd_net::encode");
+	error = compress(compress_buffer, &tmp_complen, uncompressed_data, uncompressed_data_len);
+
+	if (error != Z_OK) {
+		DBG_INF_FMT("compression NOT successful. error=%d Z_OK=%d Z_BUF_ERROR=%d Z_MEM_ERROR=%d", error, Z_OK, Z_BUF_ERROR, Z_MEM_ERROR);
+	} else {
+		DBG_INF_FMT("compression successful. compressed size=%d", tmp_complen);
+	}
+	DBG_RETURN(error == Z_OK? PASS:FAIL);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_net::receive */
+static size_t
+MYSQLND_METHOD(mysqlnd_net, receive)(MYSQLND * conn, zend_uchar * buffer, size_t count TSRMLS_DC)
+{
+	size_t to_read = count;
+	zend_uchar * p = buffer;
+	MYSQLND_NET * net = conn->net;
+
+	DBG_ENTER("mysqlnd_net::receive");
+#ifdef MYSQLND_COMPRESSION_ENABLED
+	if (net->compressed) {
+		if (net->uncompressed_data) {
+			size_t to_read_from_buffer = MIN(net->uncompressed_data->bytes_left(net->uncompressed_data), to_read);
+			DBG_INF_FMT("reading %u from uncompressed_data buffer", to_read_from_buffer);
+			if (to_read_from_buffer) {
+				net->uncompressed_data->read(net->uncompressed_data, to_read_from_buffer, (zend_uchar *) p);
+				p += to_read_from_buffer;
+				to_read -= to_read_from_buffer;
+			}
+			DBG_INF_FMT("left %u to read", to_read);
+			if (TRUE == net->uncompressed_data->is_empty(net->uncompressed_data)) {
+				/* Everything was consumed. This should never happen here, but for security */
+				net->uncompressed_data->free_buffer(&net->uncompressed_data TSRMLS_CC);
+			}
+		}
+		if (to_read) {
+			zend_uchar net_header[MYSQLND_HEADER_SIZE];
+			size_t net_payload_size;
+			zend_uchar packet_no;
+
+			if (FAIL == net->m.network_read(conn, net_header, MYSQLND_HEADER_SIZE TSRMLS_CC)) {
+				DBG_RETURN(FAIL);
+			}
+			net_payload_size = uint3korr(net_header);
+			packet_no = uint1korr(net_header + 3);
+			if (net->compressed_envelope_packet_no != packet_no) {
+				DBG_ERR_FMT("Transport level: packets out of order. Expected %d received %d. Packet size=%d",
+							net->compressed_envelope_packet_no, packet_no, net_payload_size);
+
+				php_error(E_WARNING, "Packets out of order. Expected %d received %d. Packet size="MYSQLND_SZ_T_SPEC,
+						  net->compressed_envelope_packet_no, packet_no, net_payload_size);
+				DBG_RETURN(FAIL);
+			}
+			net->compressed_envelope_packet_no++;
+#ifdef MYSQLND_DUMP_HEADER_N_BODY
+			DBG_INF_FMT("HEADER: hwd_packet_no=%d size=%3d", packet_no, net_payload_size);
+#endif
+			/* Now let's read from the wire, decompress it and fill the read buffer */
+			mysqlnd_read_compressed_packet_from_stream_and_fill_read_buffer(conn, net_payload_size TSRMLS_CC);
+
+			/*
+			  Now a bit of recursion - read from the read buffer,
+			  if the data which we have just read from the wire
+			  is not enough, then the recursive call will try to
+			  satisfy it until it is satisfied.
+			*/
+			DBG_RETURN(net->m.receive(conn, p, to_read TSRMLS_CC));
+		}
+		DBG_RETURN(PASS);
+	}
+#endif /* MYSQLND_COMPRESSION_ENABLED */
+	DBG_RETURN(net->m.network_read(conn, p, to_read TSRMLS_CC));
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_net::set_client_option */
+static enum_func_status
+MYSQLND_METHOD(mysqlnd_net, set_client_option)(MYSQLND_NET * const net, enum mysqlnd_option option, const char * const value TSRMLS_DC)
+{
+	DBG_ENTER("mysqlnd_net::set_client_option");
+	DBG_INF_FMT("option=%d", option);
+	switch (option) {
+		case MYSQLND_OPT_NET_CMD_BUFFER_SIZE:
+			DBG_INF("MYSQLND_OPT_NET_CMD_BUFFER_SIZE");
+			if (*(unsigned int*) value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) {
+				DBG_RETURN(FAIL);
+			}
+			net->cmd_buffer.length = *(unsigned int*) value;
+			DBG_INF_FMT("new_length=%u", net->cmd_buffer.length);
+			if (!net->cmd_buffer.buffer) {
+				net->cmd_buffer.buffer = mnd_pemalloc(net->cmd_buffer.length, net->persistent);
+			} else {
+				net->cmd_buffer.buffer = mnd_perealloc(net->cmd_buffer.buffer, net->cmd_buffer.length, net->persistent);
+			}
+			break;
+		case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
+			DBG_INF("MYSQLND_OPT_NET_READ_BUFFER_SIZE");
+			net->options.net_read_buffer_size = *(unsigned int*) value;
+			DBG_INF_FMT("new_length=%u", net->options.net_read_buffer_size);
+			break;
+		case MYSQL_OPT_CONNECT_TIMEOUT:
+			DBG_INF("MYSQL_OPT_CONNECT_TIMEOUT");
+			net->options.timeout_connect = *(unsigned int*) value;
+			break;
+#ifdef WHEN_SUPPORTED_BY_MYSQLI
+		case MYSQL_OPT_READ_TIMEOUT:
+			DBG_INF("MYSQL_OPT_READ_TIMEOUT");
+			net->options.timeout_read = *(unsigned int*) value;
+			break;
+		case MYSQL_OPT_WRITE_TIMEOUT:
+			DBG_INF("MYSQL_OPT_WRITE_TIMEOUT");
+			net->options.timeout_write = *(unsigned int*) value;
+			break;
+#endif
+#ifdef WHEN_SUPPORTED_BY_MYSQLI
+		case MYSQL_OPT_COMPRESS:
+#endif
+			/* currently not supported. Todo!! */
+			break;
+		default:
+			DBG_RETURN(FAIL);
+	}
+	DBG_RETURN(PASS);
+}
+/* }}} */
+
+/* {{{ mysqlnd_net::consume_uneaten_data */
+size_t 
+MYSQLND_METHOD(mysqlnd_net, consume_uneaten_data)(MYSQLND_NET * const net, enum php_mysqlnd_server_command cmd TSRMLS_DC)
+{
+#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND
+	/*
+	  Switch to non-blocking mode and try to consume something from
+	  the line, if possible, then continue. This saves us from looking for
+	  the actuall place where out-of-order packets have been sent.
+	  If someone is completely sure that everything is fine, he can switch it
+	  off.
+	*/
+	char tmp_buf[256];
+	size_t skipped_bytes = 0;
+	int opt = PHP_STREAM_OPTION_BLOCKING;
+	int was_blocked = net->stream->ops->set_option(net->stream, opt, 0, NULL TSRMLS_CC);
+
+	DBG_ENTER("mysqlnd_net::consume_uneaten_data");
+
+	if (PHP_STREAM_OPTION_RETURN_ERR != was_blocked) {
+		/* Do a read of 1 byte */
+		int bytes_consumed;
+
+		do {
+			skipped_bytes += (bytes_consumed = php_stream_read(net->stream, tmp_buf, sizeof(tmp_buf)));
+		} while (bytes_consumed == sizeof(tmp_buf));
+
+		if (was_blocked) {
+			net->stream->ops->set_option(net->stream, opt, 1, NULL TSRMLS_CC);
+		}
+
+		if (bytes_consumed) {
+			DBG_ERR_FMT("Skipped %u bytes. Last command %s hasn't consumed all the output from the server",
+						bytes_consumed, mysqlnd_command_to_text[net->last_command]);
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Skipped %u bytes. Last command %s hasn't "
+							 "consumed all the output from the server",
+							 bytes_consumed, mysqlnd_command_to_text[net->last_command]);
+		}
+	}
+	net->last_command = cmd;
+
+	DBG_RETURN(skipped_bytes);
+#else
+	return 0;
+#endif
+}
+/* }}} */
+
+
+
+/* {{{ mysqlnd_net::set_client_option */
+static void
+MYSQLND_METHOD(mysqlnd_net, free_contents)(MYSQLND_NET * net TSRMLS_DC)
+{
+	DBG_ENTER("mysqlnd_net::free_contents");
+
+#ifdef MYSQLND_COMPRESSION_ENABLED
+	if (net->uncompressed_data) {
+		net->uncompressed_data->free_buffer(&net->uncompressed_data TSRMLS_CC);
+	}
+#endif
+	DBG_VOID_RETURN;
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_net_init */
+PHPAPI MYSQLND_NET *
+mysqlnd_net_init(zend_bool persistent TSRMLS_DC)
+{
+	size_t alloc_size = sizeof(MYSQLND_NET) + mysqlnd_plugin_count() * sizeof(void *);
+	MYSQLND_NET * net = mnd_pecalloc(1, alloc_size, persistent);
+
+	DBG_ENTER("mysqlnd_net_init");
+	DBG_INF_FMT("persistent=%d", persistent);
+	net->persistent = persistent;
+
+	net->m.connect = MYSQLND_METHOD(mysqlnd_net, connect);
+	net->m.send = MYSQLND_METHOD(mysqlnd_net, send);
+	net->m.receive = MYSQLND_METHOD(mysqlnd_net, receive);
+	net->m.set_client_option = MYSQLND_METHOD(mysqlnd_net, set_client_option);
+	net->m.network_read = MYSQLND_METHOD(mysqlnd_net, network_read);
+	net->m.network_write = MYSQLND_METHOD(mysqlnd_net, network_write);
+	net->m.decode = MYSQLND_METHOD(mysqlnd_net, decode);
+	net->m.encode = MYSQLND_METHOD(mysqlnd_net, encode);
+	net->m.consume_uneaten_data = MYSQLND_METHOD(mysqlnd_net, consume_uneaten_data);
+	net->m.free_contents = MYSQLND_METHOD(mysqlnd_net, free_contents);
+
+	{
+		unsigned int buf_size = MYSQLND_G(net_read_buffer_size); /* this is long, cast to unsigned int*/
+		net->m.set_client_option(net, MYSQLND_OPT_NET_CMD_BUFFER_SIZE, (char *) &buf_size TSRMLS_CC);
+	}
+	DBG_RETURN(net);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_net_free */
+PHPAPI void
+mysqlnd_net_free(MYSQLND_NET * const net TSRMLS_DC)
+{
+	zend_bool pers = net->persistent;
+
+	DBG_ENTER("mysqlnd_net_free");
+
+	if (net) {
+		net->m.free_contents(net TSRMLS_CC);
+		if (net->cmd_buffer.buffer) {
+			DBG_INF("Freeing cmd buffer");
+			mnd_pefree(net->cmd_buffer.buffer, pers);
+			net->cmd_buffer.buffer = NULL;
+		}
+
+		if (net->stream) {
+			DBG_INF_FMT("Freeing stream. abstract=%p", net->stream->abstract);
+			if (pers) {
+				php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
+			} else {
+				php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE);	
+			}
+			net->stream = NULL;
+		}
+		mnd_pefree(net, pers);
+	}
+	DBG_VOID_RETURN;
+}
+/* }}} */
+
+
+/* {{{ _mysqlnd_plugin_get_plugin_net_data */
+PHPAPI void ** _mysqlnd_plugin_get_plugin_net_data(const MYSQLND_NET * net, unsigned int plugin_id TSRMLS_DC)
+{
+	DBG_ENTER("_mysqlnd_plugin_get_plugin_net_data");
+	DBG_INF_FMT("plugin_id=%u", plugin_id);
+	if (!net || plugin_id >= mysqlnd_plugin_count()) {
+		return NULL;
+	}
+	DBG_RETURN((void *)((char *)net + sizeof(MYSQLND_NET) + plugin_id * sizeof(void *)));
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/mysqlnd/mysqlnd_net.h b/ext/mysqlnd/mysqlnd_net.h
new file mode 100644
index 0000000..8f75a8e
--- /dev/null
+++ b/ext/mysqlnd/mysqlnd_net.h
@@ -0,0 +1,38 @@
+/*
+  +----------------------------------------------------------------------+
+  | PHP Version 6                                                        |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 2006-2009 The PHP Group                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.txt                                  |
+  | If you did not receive a copy of the PHP license and are unable to   |
+  | obtain it through the world-wide-web, please send a note to          |
+  | license at php.net so we can mail you a copy immediately.               |
+  +----------------------------------------------------------------------+
+  | Authors: Georg Richter <georg at mysql.com>                             |
+  |          Andrey Hristov <andrey at mysql.com>                           |
+  |          Ulf Wendel <uwendel at mysql.com>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: mysqlnd_wireprotocol.h 291983 2009-12-11 11:58:57Z andrey $ */
+
+#ifndef MYSQLND_NET_H
+#define MYSQLND_NET_H
+
+PHPAPI MYSQLND_NET * mysqlnd_net_init(zend_bool persistent TSRMLS_DC);
+PHPAPI void mysqlnd_net_free(MYSQLND_NET * const net TSRMLS_DC);
+
+#endif /* MYSQLND_NET_H */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/mysqlnd/mysqlnd_palloc.c b/ext/mysqlnd/mysqlnd_palloc.c
deleted file mode 100644
index 6146e6f..0000000
--- a/ext/mysqlnd/mysqlnd_palloc.c
+++ /dev/null
@@ -1,605 +0,0 @@
-/*
-  +----------------------------------------------------------------------+
-  | PHP Version 6                                                        |
-  +----------------------------------------------------------------------+
-  | Copyright (c) 2006-2009 The PHP Group                                |
-  +----------------------------------------------------------------------+
-  | This source file is subject to version 3.01 of the PHP license,      |
-  | that is bundled with this package in the file LICENSE, and is        |
-  | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
-  | If you did not receive a copy of the PHP license and are unable to   |
-  | obtain it through the world-wide-web, please send a note to          |
-  | license at php.net so we can mail you a copy immediately.               |
-  +----------------------------------------------------------------------+
-  | Authors: Georg Richter <georg at mysql.com>                             |
-  |          Andrey Hristov <andrey at mysql.com>                           |
-  |          Ulf Wendel <uwendel at mysql.com>                              |
-  +----------------------------------------------------------------------+
-*/
-
-/* $Id: mysqlnd_palloc.c 289630 2009-10-14 13:51:25Z johannes $ */
-#include "php.h"
-#include "mysqlnd.h"
-#include "mysqlnd_priv.h"
-#include "mysqlnd_palloc.h"
-#include "mysqlnd_debug.h"
-
-/* Used in mysqlnd_debug.c */
-char * mysqlnd_palloc_zval_ptr_dtor_name = "mysqlnd_palloc_zval_ptr_dtor";
-char * mysqlnd_palloc_get_zval_name = "mysqlnd_palloc_get_zval";
-
-
-#ifdef ZTS
-#define LOCK_PCACHE(cache)  tsrm_mutex_lock((cache)->LOCK_access)
-#define UNLOCK_PCACHE(cache) tsrm_mutex_unlock((cache)->LOCK_access)
-#else
-#define LOCK_PCACHE(cache)
-#define UNLOCK_PCACHE(cache)
-#endif
-
-
-/* {{{ _mysqlnd_palloc_init_cache */
-PHPAPI MYSQLND_ZVAL_PCACHE* _mysqlnd_palloc_init_cache(unsigned int cache_size TSRMLS_DC)
-{
-	MYSQLND_ZVAL_PCACHE *ret = mnd_calloc(1, sizeof(MYSQLND_ZVAL_PCACHE));
-	unsigned int i;
-
-	DBG_ENTER("_mysqlnd_palloc_init_cache");
-	DBG_INF_FMT("cache=%p size=%u", ret, cache_size);
-
-#ifdef ZTS
-	ret->LOCK_access = tsrm_mutex_alloc();
-#endif
-
-	ret->max_items = cache_size;
-	ret->free_items = cache_size;
-	ret->references = 1;
-
-	/* 1. First initialize the free list part of the structure */
-	/* One more for empty position of last_added - always 0x0, bounds checking */
-	ret->free_list.ptr_line = mnd_calloc(ret->max_items + 1, sizeof(mysqlnd_zval *));
-	ret->free_list.last_added = ret->free_list.ptr_line + ret->max_items;
-	ret->free_list.canary1 = (void*)0xBEEF;
-	ret->free_list.canary2 = (void*)0xAFFE;
-
-	/* 3. Allocate and initialize our zvals and initialize the free list */
-	ret->block = mnd_calloc(ret->max_items, sizeof(mysqlnd_zval));
-	ret->last_in_block = &(ret->block[ret->max_items]);
-	for (i = 0; i < ret->max_items; i++) {
-		/* 1. Initialize */
-		INIT_PZVAL(&(ret->block[i].zv));
-		ZVAL_NULL(&(ret->block[i].zv));
-		/* Assure it will never be freed before MSHUTDOWN */
-		Z_ADDREF_P(&(ret->block[i].zv));
-		/* 2. Add to the free list  */
-		*(--ret->free_list.last_added) = &(ret->block[i]);
-	}
-
-	DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_palloc_get_cache_reference */
-MYSQLND_ZVAL_PCACHE* mysqlnd_palloc_get_cache_reference(MYSQLND_ZVAL_PCACHE * const cache)
-{
-	if (cache) {
-		LOCK_PCACHE(cache);
-		cache->references++;
-		UNLOCK_PCACHE(cache);
-	}
-	return cache;
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_palloc_free_cache */
-/*
-  As this call will happen on MSHUTDOWN(), then we don't need to copy the zvals with
-  copy_ctor but scrap what they point to with zval_dtor() and then just free our
-  pre-allocated block. Precondition is that we ZVAL_NULL() the zvals when we put them
-  to the free list after usage. We ZVAL_NULL() them when we allocate them in the 
-  constructor of the cache.
-*/
-void _mysqlnd_palloc_free_cache(MYSQLND_ZVAL_PCACHE *cache TSRMLS_DC)
-{
-	DBG_ENTER("_mysqlnd_palloc_free_cache");
-	DBG_INF_FMT("cache=%p", cache);
-
-#ifdef ZTS
-	tsrm_mutex_free(cache->LOCK_access);
-#endif
-
-	/* Data in pointed by 'block' was cleaned in RSHUTDOWN */
-	mnd_free(cache->block);
-	mnd_free(cache->free_list.ptr_line);
-	mnd_free(cache);
-
-	DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/* {{{ _mysqlnd_palloc_init_thd_cache */
-PHPAPI MYSQLND_THD_ZVAL_PCACHE* _mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const cache TSRMLS_DC)
-{
-	MYSQLND_THD_ZVAL_PCACHE *ret = mnd_calloc(1, sizeof(MYSQLND_THD_ZVAL_PCACHE));
-	DBG_ENTER("_mysqlnd_palloc_init_thd_cache");
-	DBG_INF_FMT("ret = %p", ret);
-	
-#if PHP_DEBUG
-	LOCK_PCACHE(cache);
-	if (cache->references == 1 && cache->max_items != cache->free_items) {
-		UNLOCK_PCACHE(cache);
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "No references to mysqlnd's zval cache but max_items != free_items");
-	} else {
-		UNLOCK_PCACHE(cache);
-	}
-#endif
-	ret->parent = mysqlnd_palloc_get_cache_reference(cache);
-
-#ifdef ZTS
-	ret->thread_id = tsrm_thread_id();
-#endif
-
-	ret->references = 1;
-
-	/* 1. Initialize the GC list */
-	ret->gc_list.ptr_line = mnd_calloc(cache->max_items, sizeof(mysqlnd_zval *));
-	/* Backward and forward looping is possible */
-	ret->gc_list.last_added = ret->gc_list.ptr_line;
-	ret->gc_list.canary1 = (void*)0xCAFE;
-	ret->gc_list.canary2 = (void*)0x190280;
-
-	DBG_INF_FMT("ptr_line=%p last_added=%p", ret->gc_list.ptr_line, ret->gc_list.last_added);
-	DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ _mysqlnd_palloc_get_thd_cache_reference */
-MYSQLND_THD_ZVAL_PCACHE* _mysqlnd_palloc_get_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE * const cache TSRMLS_DC)
-{
-	DBG_ENTER("_mysqlnd_palloc_get_thd_cache_reference");
-	if (cache) {
-		++cache->references;
-		DBG_INF_FMT("cache=%p new_refc=%d gc_list.canary1=%p gc_list.canary2=%p",
-					cache, cache->references, cache->gc_list.canary1, cache->gc_list.canary2);
-		mysqlnd_palloc_get_cache_reference(cache->parent);
-	}
-	DBG_RETURN(cache);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_palloc_free_cache */
-/*
-  As this call will happen on MSHUTDOWN(), then we don't need to copy the zvals with
-  copy_ctor but scrap what they point to with zval_dtor() and then just free our
-  pre-allocated block. Precondition is that we ZVAL_NULL() the zvals when we put them
-  to the free list after usage. We ZVAL_NULL() them when we allocate them in the 
-  constructor of the cache.
-*/
-static
-void mysqlnd_palloc_free_thd_cache(MYSQLND_THD_ZVAL_PCACHE *thd_cache TSRMLS_DC)
-{
-	MYSQLND_ZVAL_PCACHE *global_cache;
-	mysqlnd_zval **p;
-
-	DBG_ENTER("mysqlnd_palloc_free_thd_cache");
-	DBG_INF_FMT("thd_cache=%p", thd_cache);
-
-	if ((global_cache = thd_cache->parent)) {
-		/*
-		  Keep in mind that for pthreads pthread_equal() should be used to be
-		  fully standard compliant. However, the PHP code all-around, incl. the
-		  the Zend MM uses direct comparison.
-		*/
-		p = thd_cache->gc_list.ptr_line;
-		while (p < thd_cache->gc_list.last_added) {
-			zval_dtor(&(*p)->zv);
-			p++;
-		}
-
-		p = thd_cache->gc_list.ptr_line;
-
-		LOCK_PCACHE(global_cache);
-		while (p < thd_cache->gc_list.last_added) {
-			(*p)->point_type = MYSQLND_POINTS_FREE;
-			*(--global_cache->free_list.last_added) = *p;
-			++global_cache->free_items;
-#ifdef ZTS
-			memset(&((*p)->thread_id), 0, sizeof(THREAD_T));
-#endif
-			p++;
-		}
-		UNLOCK_PCACHE(global_cache);
-
-	}
-	mnd_free(thd_cache->gc_list.ptr_line);
-	mnd_free(thd_cache);
-
-	DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/* {{{ _mysqlnd_palloc_free_thd_cache_reference */
-PHPAPI void _mysqlnd_palloc_free_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE **cache TSRMLS_DC)
-{
-	DBG_ENTER("_mysqlnd_palloc_free_thd_cache_reference");
-	if (*cache) {
-		--(*cache)->parent->references;
-		DBG_INF_FMT("cache=%p references_left=%d canary1=%p canary2=%p",
-					*cache, (*cache)->references, (*cache)->gc_list.canary1, (*cache)->gc_list.canary2);
-
-		DBG_INF_FMT("gc_list.ptr_line=%p gc_list.last_added=%p", (*cache)->gc_list.ptr_line, (*cache)->gc_list.last_added);
-
-		if (--(*cache)->references == 0) {
-			mysqlnd_palloc_free_thd_cache(*cache TSRMLS_CC);
-		}
-		*cache = NULL;
-	}
-	DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/*
-  The cache line is a big contiguous array of zval pointers.
-  Because the CPU cache will cache starting from an address, and not
-  before it, then we have to organize our structure according to this.
-  Thus, if 'last_added' is valid pointer (not NULL) then last_added is
-  increased. When zval is cached, if there is room, last_added is decreased
-  and then the zval pointer will be assigned to it. This means that some
-  positions may become hot points and stay in the cache.
-  Imagine we have 5 pointers in a line
-  1. last_added = list_item->ptr_line + cache->max_items;
-  2. get_zval -> *last_added = NULL. Use MAKE_STD_ZVAL
-  3. get_zval -> *last_added = NULL. Use MAKE_STD_ZVAL
-  4. get_zval -> *last_added = NULL. Use MAKE_STD_ZVAL
-	0x0
-	0x0
-	0x0
-	0x0
-	0x0
-	---
-	empty_position, always 0x0 <-- last_added
-
-  5. free_zval -> if (free_items++ != max_items) {// we can add more
-				    *(--last_added) = zval_ptr;
-				 }
-	(memory addresses increase downwards)
-	0x0
-	0x0
-	0x0
-	0x0 
-	0xA <-- last_added
-	---
-	0x0
-
-  6. free_zval -> if (free_items++ != max_items) {// we can add more
-				   *(--last_added) = zval_ptr;
-				 }
-	0x0
-	0x0
-	0x0
-	0xB <-- last_added
-	0xA 
-	---
-	0x0
-
-  7. free_zval -> if (free_items++ != max_items) {// we can add more
-				   *(--last_added) = zval_ptr;
-				 }
-	0x0
-	0x0
-	0xC <-- last_added
-	0xB
-	0xA
-	---
-	0x0
-
-  8. get_zval -> *last_added != NULL. -> p = *last_added; *last_added++ = NULL;
-	0x0
-	0x0
-	0x0
-	0xB <-- last_added
-	0xA
-	---
-	0x0
-
-  9. get_zval -> *last_added != NULL. -> p = *last_added; *last_added++ = NULL;
-	0x0
-	0x0
-	0x0
-	0x0
-	0xA <-- last_added
-	---
-	0x0
-
-  10. get_zval -> *last_added != NULL. -> p = *last_added; *last_added++ = NULL;
-	0x0
-	0x0
-	0x0
-	0x0
-	0x0
-	---
-	0x0 <-- last_added
-
-*/
-
-
-/* {{{ mysqlnd_palloc_get_zval */
-void *mysqlnd_palloc_get_zval(MYSQLND_THD_ZVAL_PCACHE * const thd_cache, zend_bool *allocated TSRMLS_DC)
-{
-	void *ret = NULL;
-
-	DBG_ENTER("mysqlnd_palloc_get_zval");
-	if (thd_cache) {
-		DBG_INF_FMT("cache=%p *last_added=%p free_items=%d",
-					thd_cache, thd_cache->parent->free_list.last_added,
-					thd_cache->parent->free_items);
-		DBG_INF_FMT("gc_list.ptr_line=%p gc_list.last_added=%p gc_list.canary1=%p gc_list.canary2=%p",
-					thd_cache->gc_list.ptr_line, thd_cache->gc_list.last_added,
-					thd_cache->gc_list.canary1, thd_cache->gc_list.canary2);
-	}
-
-	if (thd_cache) {
-		MYSQLND_ZVAL_PCACHE *cache = thd_cache->parent;
-		LOCK_PCACHE(cache);
-
-		DBG_INF_FMT("free_items=%d free_list.ptr_line=%p free_list.last_added=%p *free_list.last_added=%p free_list.canary1=%p free_list.canary2=%p",
-					cache->free_items, cache->free_list.ptr_line, cache->free_list.last_added,
-					*cache->free_list.last_added,
-					cache->free_list.canary1, cache->free_list.canary2);
-
-		/* We have max_items + 1 allocated block for free_list, thus we know if we */
-		if ((ret = *cache->free_list.last_added)) {
-			*cache->free_list.last_added++ = NULL;
-			*allocated = FALSE;
-#ifdef ZTS
-			((mysqlnd_zval *) ret)->thread_id = thd_cache->thread_id;
-#endif
-			--cache->free_items;
-			++cache->get_hits;
-		} else {
-			++cache->get_misses;
-		}
-		UNLOCK_PCACHE(cache);
-	}
-	if (!ret) {
-		/*
-		  We allocate a bit more. The user of this function will use it, but at
-		  end it will use only the zval part. Because the zval part is first then
-		  when freeing the zval part the whole allocated block will be cleaned, not
-		  only the zval part (by the Engine when destructing the zval).
-		*/
-		ALLOC_ZVAL(ret);
-		INIT_PZVAL((zval *) ret);
-		*allocated = TRUE;
-	} else {
-		/* This will set the refcount to 1, increase it, to keep the variable */
-		INIT_PZVAL(&((mysqlnd_zval *) ret)->zv);
-		Z_ADDREF_P(&(((mysqlnd_zval *)ret)->zv));
-	}
-
-	DBG_INF_FMT("allocated=%d ret=%p", *allocated, ret);
-	DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_palloc_zval_ptr_dtor */
-void mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_THD_ZVAL_PCACHE * const thd_cache,
-								  enum_mysqlnd_res_type type, zend_bool *copy_ctor_called TSRMLS_DC)
-{
-	MYSQLND_ZVAL_PCACHE *cache;
-	DBG_ENTER("mysqlnd_palloc_zval_ptr_dtor");
-	if (thd_cache) {
-		DBG_INF_FMT("cache=%p parent_block=%p last_in_block=%p *zv=%p refc=%d type=%d ",
-					thd_cache,
-					thd_cache->parent->block,
-					thd_cache->parent->last_in_block,
-					*zv, Z_REFCOUNT_PP(zv), type);
-		DBG_INF_FMT("gc_list.ptr_line=%p gc_list.last_added=%p gc_list.canary1=%p gc_list.canary2=%p",
-					thd_cache->gc_list.ptr_line, thd_cache->gc_list.last_added, thd_cache->gc_list.canary1, thd_cache->gc_list.canary2);
-	}
-	*copy_ctor_called = FALSE;
-	/* Check whether cache is used and the zval is from the cache */
-	if (!thd_cache || !(cache = thd_cache->parent) || ((char *)*zv < (char *)thd_cache->parent->block ||
-													   (char *)*zv > (char *)thd_cache->parent->last_in_block)) {
-		/*
-		  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) {
-			; /* do nothing, zval_ptr_dtor will do the job*/
-		} else if (Z_REFCOUNT_PP(zv) > 1) {
-			/*
-			  Not a prepared statement, then we have to
-			  call copy_ctor and then zval_ptr_dtor()
-
-			  In Unicode mode the destruction  of the zvals should not call
-			  zval_copy_ctor() because then we will leak.
-			  I suppose we can use UG(unicode) in mysqlnd.c when freeing a result set
-			  to check if we need to call copy_ctor().
-
-			  If the type is IS_UNICODE, which can happen with PHP6, then we don't
-			  need to copy_ctor, as the data doesn't point to our internal buffers.
-			  If it's string (in PHP5 always) and in PHP6 if data is binary, then
-			  it still points to internal buffers and has to be copied.
-			*/
-			if (Z_TYPE_PP(zv) == IS_STRING) {
-				zval_copy_ctor(*zv);
-			}
-			*copy_ctor_called = TRUE;
-		} else {
-			if (Z_TYPE_PP(zv) == IS_STRING) {
-				ZVAL_NULL(*zv);
-			}
-		}
-		zval_ptr_dtor(zv);
-		DBG_VOID_RETURN;
-	}
-
-	/* The zval is from our cache */
-	/* refcount is always > 1, because we call Z_ADDREF_P(). Thus test refcount > 2 */
-	if (Z_REFCOUNT_PP(zv) > 2) {
-		/*
-		  Because the zval is first element in mysqlnd_zval structure, then we can
-		  do upcasting from zval to mysqlnd_zval here. Because we know that this
-		  zval is part of our pre-allocated block.
-
-		  Now check whether this zval points to ZE allocated memory or to our
-		  buffers. If it points to the internal buffers, call copy_ctor()
-		  which will do estrndup for strings. And nothing for null, int, double.
-
-		  This branch will be skipped for PS, because there is no need to copy
-		  what is pointed by them, as they don't point to the internal buffers.
-		*/
-		if (((mysqlnd_zval *)*zv)->point_type == MYSQLND_POINTS_INT_BUFFER) {
-			zval_copy_ctor(*zv);
-			*copy_ctor_called = TRUE;
-			((mysqlnd_zval *)*zv)->point_type = MYSQLND_POINTS_EXT_BUFFER;
-		}
-		/*
-		  This will decrease the counter of the user-level (mysqlnd). When the engine
-		  layer (the script) has finished working this this zval, when the variable is
-		  no more used, out of scope whatever, then it will try zval_ptr_dtor() but
-		  and the refcount will reach 1 and the engine won't try to destruct the
-		  memory allocated by us.
-		*/
-		zval_ptr_dtor(zv);
-
-		/*
-		  Unfortunately, we can't return this variable to the free_list
-		  because it's still used. And this cleaning up will happen at request
-		  shutdown :(.
-		*/
-		LOCK_PCACHE(cache);
-		DBG_INF_FMT("gc_list.ptr_line=%p gc_list.last_added=%p *gc_list.last_added=%p free_list.canary1=%p free_list.canary2=%p",
-					thd_cache->gc_list.ptr_line,
-					thd_cache->gc_list.last_added,
-					*thd_cache->gc_list.last_added,
-					cache->free_list.canary1, cache->free_list.canary2);
-		if ((thd_cache->gc_list.last_added - thd_cache->gc_list.ptr_line) > (int) cache->max_items) {
-			DBG_ERR("Buffer overflow follows");
-			DBG_ERR_FMT("parent->max_items=%d parent->free_items=%d diff=%d",
-						cache->max_items, cache->free_items,
-						thd_cache->gc_list.last_added - thd_cache->gc_list.ptr_line);
-
-			php_error_docref(NULL TSRMLS_CC, E_WARNING, "We will get buffer overflow");
-		}
-		++cache->put_misses;
-		*(thd_cache->gc_list.last_added++) = (mysqlnd_zval *)*zv;
-		UNLOCK_PCACHE(cache);
-	} else {
-		DBG_INF("No user reference");
-		/* No user reference */
-		if (((mysqlnd_zval *)*zv)->point_type == MYSQLND_POINTS_EXT_BUFFER) {
-			DBG_INF("Points to external buffer. Calling zval_dtor");
-			/*
-			  PS are here
-			  Unicode mode goes also here if the column is not binary but a text
-			*/
-			zval_dtor(*zv);
-		}
-		LOCK_PCACHE(cache);
-		++cache->put_hits;
-		++cache->free_items;
-		((mysqlnd_zval *)*zv)->point_type = MYSQLND_POINTS_FREE;
-		Z_DELREF_PP(zv);	/* Make it 1 */
-		ZVAL_NULL(*zv);
-#ifdef ZTS
-		memset(&((mysqlnd_zval *)*zv)->thread_id, 0, sizeof(THREAD_T));
-#endif
-		*(--cache->free_list.last_added) = (mysqlnd_zval *)*zv;
-
-		UNLOCK_PCACHE(cache);
-	}
-	DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/* {{{ _mysqlnd_palloc_rinit */
-PHPAPI MYSQLND_THD_ZVAL_PCACHE * _mysqlnd_palloc_rinit(MYSQLND_ZVAL_PCACHE * cache TSRMLS_DC)
-{
-	return mysqlnd_palloc_init_thd_cache(cache);
-}
-/* }}} */
-
-
-/* {{{ _mysqlnd_palloc_rshutdown */
-PHPAPI void _mysqlnd_palloc_rshutdown(MYSQLND_THD_ZVAL_PCACHE * thd_cache TSRMLS_DC)
-{
-	DBG_ENTER("_mysqlnd_palloc_rshutdown");
-	DBG_INF_FMT("cache=%p", thd_cache);
-	mysqlnd_palloc_free_thd_cache_reference(&thd_cache);
-	DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_palloc_rshutdown */
-PHPAPI void mysqlnd_palloc_stats(const MYSQLND_ZVAL_PCACHE * const cache, zval *return_value)
-{
-	if (cache) {
-#if PHP_MAJOR_VERSION >= 6
-		UChar *ustr;
-		int ulen;
-			
-		TSRMLS_FETCH();
-#endif
-
-		LOCK_PCACHE(cache);
-		array_init(return_value);
-#if PHP_MAJOR_VERSION >= 6
-		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, "put_hits", sizeof("put_hits") TSRMLS_CC);
-		add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen + 1, cache->put_hits);
-		efree(ustr);
-		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, "put_misses", sizeof("put_misses") TSRMLS_CC);
-		add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen + 1, cache->put_hits);
-		efree(ustr);
-		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, "get_hits", sizeof("get_hits") TSRMLS_CC);
-		add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen + 1, cache->put_hits);
-		efree(ustr);
-		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, "get_misses", sizeof("get_misses") TSRMLS_CC);
-		add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen + 1, cache->put_hits);
-		efree(ustr);
-		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, "size", sizeof("size") TSRMLS_CC);
-		add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen + 1, cache->put_hits);
-		efree(ustr);
-		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, "free_items", sizeof("free_items") TSRMLS_CC);
-		add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen + 1, cache->put_hits);
-		efree(ustr);
-		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, "references", sizeof("references") TSRMLS_CC);
-		add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen + 1, cache->put_hits);
-		efree(ustr);
-#else
-		add_assoc_long_ex(return_value, "put_hits",		sizeof("put_hits"),		cache->put_hits);
-		add_assoc_long_ex(return_value, "put_misses",	sizeof("put_misses"),	cache->put_misses);
-		add_assoc_long_ex(return_value, "get_hits",		sizeof("get_hits"),		cache->get_hits);
-		add_assoc_long_ex(return_value, "get_misses",	sizeof("get_misses"),	cache->get_misses);
-		add_assoc_long_ex(return_value, "size",			sizeof("size"),			cache->max_items);
-		add_assoc_long_ex(return_value, "free_items",	sizeof("free_items"),	cache->free_items);
-		add_assoc_long_ex(return_value, "references",	sizeof("references"),	cache->references);
-#endif
-		UNLOCK_PCACHE(cache);
-	} else {
-		ZVAL_NULL(return_value);
-	}
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_palloc.h b/ext/mysqlnd/mysqlnd_palloc.h
deleted file mode 100644
index b67c01d..0000000
--- a/ext/mysqlnd/mysqlnd_palloc.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-  +----------------------------------------------------------------------+
-  | PHP Version 6                                                        |
-  +----------------------------------------------------------------------+
-  | Copyright (c) 2006-2009 The PHP Group                                |
-  +----------------------------------------------------------------------+
-  | This source file is subject to version 3.01 of the PHP license,      |
-  | that is bundled with this package in the file LICENSE, and is        |
-  | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
-  | If you did not receive a copy of the PHP license and are unable to   |
-  | obtain it through the world-wide-web, please send a note to          |
-  | license at php.net so we can mail you a copy immediately.               |
-  +----------------------------------------------------------------------+
-  | Authors: Georg Richter <georg at mysql.com>                             |
-  |          Andrey Hristov <andrey at mysql.com>                           |
-  |          Ulf Wendel <uwendel at mysql.com>                              |
-  +----------------------------------------------------------------------+
-*/
-
-/* $Id: mysqlnd_palloc.h 272370 2008-12-31 11:15:49Z sebastian $ */
-#ifndef MYSQLND_PALLOC_H
-#define MYSQLND_PALLOC_H
-
-/* Used in mysqlnd_debug.c */
-extern char * mysqlnd_palloc_zval_ptr_dtor_name;
-extern char * mysqlnd_palloc_get_zval_name;
-
-
-/* Session caching allocator */
-struct st_mysqlnd_zval_list {
-	zval 	**ptr_line;
-	zval	**last_added;
-};
-
-typedef struct st_mysqlnd_zval_cache	MYSQLND_ZVAL_CACHE;
-
-struct st_mysqlnd_zval_cache {
-	struct st_mysqlnd_zval_list	*free_list;
-	unsigned int		free_items;
-	unsigned int		max_items;
-	unsigned int		references;
-	unsigned long		get_hits;
-	unsigned long		get_misses;
-	unsigned long		put_hits;
-	unsigned long		put_full_misses;
-	unsigned long		put_refcount_misses;
-};
-
-
-enum mysqlnd_zval_ptr_type
-{
-	MYSQLND_POINTS_INT_BUFFER,
-	MYSQLND_POINTS_EXT_BUFFER,
-	MYSQLND_POINTS_FREE
-};
-
-/* Persistent caching allocator */
-typedef struct st_mysqlnd_zval {
-	/* Should be first */
-	zval		zv;
-	enum mysqlnd_zval_ptr_type	point_type;
-#ifdef ZTS
-	THREAD_T	thread_id;
-#endif
-} mysqlnd_zval;
-
-
-typedef struct st_mysqlnd_ndzval_list {
-	mysqlnd_zval 	**ptr_line;		/* we allocate this, all are pointers to the block */
-	void			*canary1;
-	void			*canary2;
-	mysqlnd_zval	**last_added;	/* this points to the ptr_line, and moves left-right. It's our stack */
-} mysqlnd_ndzval_list;
-
-
-struct st_mysqlnd_zval_pcache {
-	mysqlnd_zval		*block;
-	mysqlnd_zval		*last_in_block;
-	mysqlnd_ndzval_list	free_list;	/* Fetch from here */
-
-#ifdef ZTS
-	MUTEX_T 			LOCK_access;
-#endif
-	unsigned int		references;
-
-	/* These are just for statistics and not used for operational purposes */
-	unsigned int		free_items;
-	unsigned int		max_items;
-
-	unsigned long		get_hits;
-	unsigned long		get_misses;
-	unsigned long		put_hits;
-	unsigned long		put_misses;
-};
-
-struct st_mysqlnd_thread_zval_pcache {
-	struct st_mysqlnd_zval_pcache *parent;
-
-	unsigned int		references;
-#ifdef ZTS
-	THREAD_T			thread_id;
-#endif
-	mysqlnd_ndzval_list	gc_list;		/* GC these from time to time */
-};
-
-#endif /* MYSQLND_PALLOC_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_portability.h b/ext/mysqlnd/mysqlnd_portability.h
index 43cb505..ed0a5c8 100644
--- a/ext/mysqlnd/mysqlnd_portability.h
+++ b/ext/mysqlnd/mysqlnd_portability.h
@@ -235,47 +235,44 @@ typedef unsigned long long uint64_t;
 #define uint1korr(A)	(*(((uint8_t*)(A))))
 
 /* Bit values are sent in reverted order of bytes, compared to normal !!! */
-#define bit_uint2korr(A) ((uint16_t) (((uint16_t) (((zend_uchar*) (A))[1])) +\
-									((uint16_t) (((zend_uchar*) (A))[0]) << 8)))
-#define bit_uint3korr(A) ((uint32_t) (((uint32_t) (((zend_uchar*) (A))[2])) +\
-									(((uint32_t) (((zend_uchar*) (A))[1])) << 8) +\
-									(((uint32_t) (((zend_uchar*) (A))[0])) << 16)))
-
-#define bit_uint4korr(A) ((uint32_t) (((uint32_t) (((zend_uchar*) (A))[3])) +\
-									(((uint32_t) (((zend_uchar*) (A))[2])) << 8) +\
-									(((uint32_t) (((zend_uchar*) (A))[1])) << 16) +\
-									(((uint32_t) (((zend_uchar*) (A))[0])) << 24)))
-
-#define bit_uint5korr(A)  ((uint64_t)(((uint32_t) ((zend_uchar) (A)[4])) +\
-                                  (((uint32_t) ((zend_uchar) (A)[3])) << 8) +\
-                                  (((uint32_t) ((zend_uchar) (A)[2])) << 16) +\
-                                  (((uint32_t) ((zend_uchar) (A)[1])) << 24)) +\
-                               (((uint64_t) ((zend_uchar) (A)[0])) << 32))
-
-#define bit_uint6korr(A)	((uint64_t)(((uint32_t) (((zend_uchar*) (A))[5])) +\
-									(((uint32_t) (((zend_uchar*) (A))[4])) << 8) +\
-									(((uint32_t) (((zend_uchar*) (A))[3])) << 16) +\
-									(((uint32_t) (((zend_uchar*) (A))[2])) << 24)) +\
-									(((uint64_t) (((uint32_t) (((zend_uchar*) (A))[1])) +\
-									(((uint32_t) (((zend_uchar*) (A))[0]) << 8)))) << 32))
-
-#define bit_uint7korr(A)	((uint64_t)(((uint32_t) (((zend_uchar*) (A))[6])) +\
-									(((uint32_t) (((zend_uchar*) (A))[5])) << 8) +\
-									(((uint32_t) (((zend_uchar*) (A))[4])) << 16) +\
-									(((uint32_t) (((zend_uchar*) (A))[3])) << 24)) +\
-									(((uint64_t) (((uint32_t) (((zend_uchar*) (A))[2])) +\
-									(((uint32_t) (((zend_uchar*) (A))[1])) << 8) +\
-									(((uint32_t) (((zend_uchar*) (A))[0])) << 16))) << 32))
-
-
-#define bit_uint8korr(A) ((uint64_t)(((uint32_t) (((zend_uchar*) (A))[7])) +\
-									(((uint32_t) (((zend_uchar*) (A))[6])) << 8) +\
-									(((uint32_t) (((zend_uchar*) (A))[5])) << 16) +\
-									(((uint32_t) (((zend_uchar*) (A))[4])) << 24)) +\
-									(((uint64_t) (((uint32_t) (((zend_uchar*) (A))[3])) +\
-									(((uint32_t) (((zend_uchar*) (A))[2])) << 8) +\
-									(((uint32_t) (((zend_uchar*) (A))[1])) << 16) +\
-									(((uint32_t) (((zend_uchar*) (A))[0])) << 24))) << 32))
+#define bit_uint2korr(A) ((uint16_t) (((uint16_t) (((unsigned char*) (A))[1])) +\
+                                   ((uint16_t) (((unsigned char*) (A))[0]) << 8)))
+#define bit_uint3korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
+                                   (((uint32_t) (((unsigned char*) (A))[0])) << 16)))
+#define bit_uint4korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
+                                   (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[0])) << 24)))
+#define bit_uint5korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[4])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[3])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 24)) +\
+                                    (((uint64_t) (((unsigned char*) (A))[0])) << 32))
+#define bit_uint6korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[5])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[3])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[1])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0]) << 8)))) <<\
+                                     32))
+#define bit_uint7korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[6])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[5])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[3])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0])) << 16))) <<\
+                                     32))
+#define bit_uint8korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[7])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[6])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[5])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0])) << 24))) <<\
+                                    32))
 
 
 /*
@@ -372,16 +369,6 @@ typedef union {
                                (((uint32_t) ((zend_uchar) (A)[2])) << 16) +\
                                (((uint32_t) ((zend_uchar) (A)[3])) << 24))
 
-
-#define bit_uint8korr(A) ((uint64_t)(((uint32_t) (((zend_uchar*) (A))[7])) +\
-									(((uint32_t) (((zend_uchar*) (A))[6])) << 8) +\
-									(((uint32_t) (((zend_uchar*) (A))[5])) << 16) +\
-									(((uint32_t) (((zend_uchar*) (A))[4])) << 24)) +\
-									(((uint64_t) (((uint32_t) (((zend_uchar*) (A))[3])) +\
-									(((uint32_t) (((zend_uchar*) (A))[2])) << 8) +\
-									(((uint32_t) (((zend_uchar*) (A))[1])) << 16) +\
-									(((uint32_t) (((zend_uchar*) (A))[0])) << 24))) << 32))
-
 #define uint8korr(A)	((uint64_t)(((uint32_t) ((zend_uchar) (A)[0])) +\
 									(((uint32_t) ((zend_uchar) (A)[1])) << 8) +\
 									(((uint32_t) ((zend_uchar) (A)[2])) << 16) +\
diff --git a/ext/mysqlnd/mysqlnd_priv.h b/ext/mysqlnd/mysqlnd_priv.h
index b15e915..c9f40cd 100644
--- a/ext/mysqlnd/mysqlnd_priv.h
+++ b/ext/mysqlnd/mysqlnd_priv.h
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_priv.h 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysqlnd_priv.h 293779 2010-01-20 17:09:28Z johannes $ */
 
 #ifndef MYSQLND_PRIV_H
 #define MYSQLND_PRIV_H
@@ -37,21 +37,12 @@
 #include "TSRM.h"
 #endif
 
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
 #ifndef pestrndup
 #define pestrndup(s, length, persistent) ((persistent)?zend_strndup((s),(length)):estrndup((s),(length)))
 #endif
 
 #define MYSQLND_CLASS_METHOD_TABLE_NAME(class) mysqlnd_##class##_methods
-#define MYSQLND_CLASS_METHODS_START(class) static \
-									 struct st_##class##_methods MYSQLND_CLASS_METHOD_TABLE_NAME(class) = {
+#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
@@ -163,9 +154,9 @@ struct st_mysqlnd_perm_bind {
 
 extern struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + 1];
 
-extern const char * const mysqlnd_old_passwd;
-extern const char * const mysqlnd_out_of_sync;
-extern const char * const mysqlnd_server_gone;
+PHPAPI extern const char * const mysqlnd_old_passwd;
+PHPAPI extern const char * const mysqlnd_out_of_sync;
+PHPAPI extern const char * const mysqlnd_server_gone;
 
 enum_func_status mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_warning TSRMLS_DC);
 
@@ -178,9 +169,6 @@ void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field,
 								unsigned int pack_len, zend_uchar **row, zend_bool as_unicode,
 								unsigned int byte_count TSRMLS_DC);
 
-
-
-int mysqlnd_set_sock_no_delay(php_stream *stream);
 #endif	/* MYSQLND_PRIV_H */
 
 
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c
index 68f0a82..06ec510 100644
--- a/ext/mysqlnd/mysqlnd_ps.c
+++ b/ext/mysqlnd/mysqlnd_ps.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_ps.c 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysqlnd_ps.c 294543 2010-02-04 20:28:55Z johannes $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -27,6 +27,7 @@
 #include "mysqlnd_result_meta.h"
 #include "mysqlnd_statistics.h"
 #include "mysqlnd_debug.h"
+#include "mysqlnd_block_alloc.h"
 
 
 #define MYSQLND_SILENT
@@ -37,13 +38,6 @@ const char * const mysqlnd_stmt_not_prepared = "Statement not prepared";
 
 static struct st_mysqlnd_stmt_methods *mysqlnd_stmt_methods;
 
-/* Exported by mysqlnd.c */
-enum_func_status mysqlnd_simple_command(MYSQLND *conn, enum php_mysqlnd_server_command command,
-										const char * const arg, size_t arg_len,
-										enum php_mysql_packet_type ok_packet,
-										zend_bool silent, zend_bool ignore_upsert_status
-										TSRMLS_DC);
-
 /* Exported by mysqlnd_ps_codec.c */
 zend_uchar* mysqlnd_stmt_execute_generate_request(MYSQLND_STMT *stmt, size_t *request_len,
 												  zend_bool *free_buffer TSRMLS_DC);
@@ -100,95 +94,16 @@ MYSQLND_METHOD(mysqlnd_stmt, store_result)(MYSQLND_STMT * const stmt TSRMLS_DC)
 
 	SET_EMPTY_ERROR(stmt->error_info);
 	SET_EMPTY_ERROR(stmt->conn->error_info);
-	MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_PS_BUFFERED_SETS);
+	MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_PS_BUFFERED_SETS);
 
 	result = stmt->result;
 	result->type			= MYSQLND_RES_PS_BUF;
 	result->m.fetch_row		= mysqlnd_fetch_stmt_row_buffered;
 	result->m.fetch_lengths	= NULL;/* makes no sense */
-	if (!result->zval_cache) {
-		result->zval_cache = mysqlnd_palloc_get_thd_cache_reference(conn->zval_cache);
-	}
 
-	/* Create room for 'next_extend' rows */
+	result->result_set_memory_pool = mysqlnd_mempool_create(16000 TSRMLS_CC);
 
-	ret = mysqlnd_store_result_fetch_data(conn, result, result->meta,
-										  TRUE, to_cache TSRMLS_CC);
-
-	if (PASS == ret) {
-		/* libmysql API docs say it should be so for SELECT statements */
-		stmt->upsert_status.affected_rows = stmt->result->stored_data->row_count;
-
-		stmt->state = MYSQLND_STMT_USE_OR_STORE_CALLED;
-	} else {
-		conn->error_info = result->stored_data->error_info;
-		stmt->result->m.free_result_contents(stmt->result TSRMLS_CC);
-		mnd_efree(stmt->result);
-		stmt->result = NULL;
-		stmt->state = MYSQLND_STMT_PREPARED;
-	}
-
-	DBG_RETURN(result);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_stmt::background_store_result */
-static MYSQLND_RES *
-MYSQLND_METHOD(mysqlnd_stmt, background_store_result)(MYSQLND_STMT * const stmt TSRMLS_DC)
-{
-	enum_func_status ret;
-	MYSQLND *conn = stmt->conn;
-	MYSQLND_RES *result;
-	zend_bool to_cache = FALSE;
-
-	DBG_ENTER("mysqlnd_stmt::background_store_result");
-	DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
-
-	/* be compliant with libmysql - NULL will turn */
-	if (!stmt->field_count) {
-		DBG_RETURN(NULL);
-	}
-
-	if (stmt->cursor_exists) {
-		/* Silently convert buffered to unbuffered, for now */
-		MYSQLND_RES * res = stmt->m->use_result(stmt TSRMLS_CC);
-		DBG_RETURN(res);
-	}
-
-	/* Nothing to store for UPSERT/LOAD DATA*/
-	if (CONN_GET_STATE(conn) != CONN_FETCHING_DATA ||
-		stmt->state != MYSQLND_STMT_WAITING_USE_OR_STORE)
-	{
-		SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC,
-						 UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
-		DBG_RETURN(NULL);
-	}
-
-	stmt->default_rset_handler = stmt->m->store_result;
-
-	SET_EMPTY_ERROR(stmt->error_info);
-	SET_EMPTY_ERROR(stmt->conn->error_info);
-	MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_PS_BUFFERED_SETS);
-
-	result = stmt->result;
-	result->type			= MYSQLND_RES_PS_BUF;
-	result->m.fetch_row		= mysqlnd_fetch_stmt_row_buffered;
-	result->m.fetch_lengths	= NULL;/* makes no sense */
-	if (!result->zval_cache) {
-		result->zval_cache = mysqlnd_palloc_get_thd_cache_reference(conn->zval_cache);
-	}
-
-	/* Create room for 'next_extend' rows */
-
-	/* Not set for SHOW statements at PREPARE stage */
-	if (result->conn) {
-		result->conn->m->free_reference(result->conn TSRMLS_CC);
-		result->conn = NULL;	/* store result does not reference  the connection */
-	}
-
-	ret = mysqlnd_store_result_fetch_data(conn, result, result->meta,
-										  TRUE, to_cache TSRMLS_CC);
+	ret = result->m.store_result_fetch_data(conn, result, result->meta, TRUE, to_cache TSRMLS_CC);
 
 	if (PASS == ret) {
 		/* libmysql API docs say it should be so for SELECT statements */
@@ -237,10 +152,9 @@ MYSQLND_METHOD(mysqlnd_stmt, get_result)(MYSQLND_STMT * const stmt TSRMLS_DC)
 
 	SET_EMPTY_ERROR(stmt->error_info);
 	SET_EMPTY_ERROR(stmt->conn->error_info);
-	MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_BUFFERED_SETS);
+	MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_BUFFERED_SETS);
 
-	result = mysqlnd_result_init(stmt->result->field_count,
-								 mysqlnd_palloc_get_thd_cache_reference(conn->zval_cache) TSRMLS_CC);	
+	result = mysqlnd_result_init(stmt->result->field_count TSRMLS_CC);	
 
 	result->meta = stmt->result->meta->m->clone_metadata(stmt->result->meta, FALSE TSRMLS_CC);
 
@@ -304,20 +218,20 @@ mysqlnd_stmt_skip_metadata(MYSQLND_STMT *stmt TSRMLS_DC)
 	/* Follows parameter metadata, we have just to skip it, as libmysql does */
 	unsigned int i = 0;
 	enum_func_status ret = PASS;
-	php_mysql_packet_res_field field_packet;
+	MYSQLND_PACKET_RES_FIELD * field_packet;
 
 	DBG_ENTER("mysqlnd_stmt_skip_metadata");
 	DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
 
-	PACKET_INIT_ALLOCA(field_packet, PROT_RSET_FLD_PACKET);
-	field_packet.skip_parsing = TRUE;
+	field_packet = stmt->conn->protocol->m.get_result_field_packet(stmt->conn->protocol, FALSE TSRMLS_CC);
+	field_packet->skip_parsing = TRUE;
 	for (;i < stmt->param_count; i++) {
-		if (FAIL == PACKET_READ_ALLOCA(field_packet, stmt->conn)) {
+		if (FAIL == PACKET_READ(field_packet, stmt->conn)) {
 			ret = FAIL;
 			break;
 		}
 	}
-	PACKET_FREE_ALLOCA(field_packet);
+	PACKET_FREE(field_packet);
 
 	DBG_RETURN(ret);
 }
@@ -328,31 +242,31 @@ mysqlnd_stmt_skip_metadata(MYSQLND_STMT *stmt TSRMLS_DC)
 static enum_func_status
 mysqlnd_stmt_read_prepare_response(MYSQLND_STMT *stmt TSRMLS_DC)
 {
-	php_mysql_packet_prepare_response prepare_resp;
+	MYSQLND_PACKET_PREPARE_RESPONSE * prepare_resp;
 	enum_func_status ret = PASS;
 
 	DBG_ENTER("mysqlnd_stmt_read_prepare_response");
 	DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
 
-	PACKET_INIT_ALLOCA(prepare_resp, PROT_PREPARE_RESP_PACKET);
-	if (FAIL == PACKET_READ_ALLOCA(prepare_resp, stmt->conn)) {
+	prepare_resp = stmt->conn->protocol->m.get_prepare_response_packet(stmt->conn->protocol, FALSE TSRMLS_CC);
+	if (FAIL == PACKET_READ(prepare_resp, stmt->conn)) {
 		ret = FAIL;
 		goto done;
 	}
 
-	if (0xFF == prepare_resp.error_code) {
-		stmt->error_info = stmt->conn->error_info = prepare_resp.error_info;
+	if (0xFF == prepare_resp->error_code) {
+		stmt->error_info = stmt->conn->error_info = prepare_resp->error_info;
 		ret = FAIL;
 		goto done;
 	}
 
-	stmt->stmt_id = prepare_resp.stmt_id;
-	stmt->warning_count = stmt->conn->upsert_status.warning_count = prepare_resp.warning_count;
-	stmt->field_count = stmt->conn->field_count = prepare_resp.field_count;
-	stmt->param_count = prepare_resp.param_count;
-	PACKET_FREE_ALLOCA(prepare_resp);
-
+	stmt->stmt_id = prepare_resp->stmt_id;
+	stmt->warning_count = stmt->conn->upsert_status.warning_count = prepare_resp->warning_count;
+	stmt->field_count = stmt->conn->field_count = prepare_resp->field_count;
+	stmt->param_count = prepare_resp->param_count;
 done:
+	PACKET_FREE(prepare_resp);
+
 	DBG_RETURN(ret);
 }
 /* }}} */
@@ -362,14 +276,14 @@ done:
 static enum_func_status
 mysqlnd_stmt_prepare_read_eof(MYSQLND_STMT *stmt TSRMLS_DC)
 {
-	php_mysql_packet_eof fields_eof;
+	MYSQLND_PACKET_EOF * fields_eof;
 	enum_func_status ret;
 
 	DBG_ENTER("mysqlnd_stmt_prepare_read_eof");
 	DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
 
-	PACKET_INIT_ALLOCA(fields_eof, PROT_EOF_PACKET);
-	if (FAIL == (ret = PACKET_READ_ALLOCA(fields_eof, stmt->conn))) {
+	fields_eof = stmt->conn->protocol->m.get_eof_packet(stmt->conn->protocol, FALSE TSRMLS_CC);
+	if (FAIL == (ret = PACKET_READ(fields_eof, stmt->conn))) {
 		if (stmt->result) {
 			stmt->result->m.free_result_contents(stmt->result TSRMLS_CC);
 			mnd_efree(stmt->result);
@@ -377,11 +291,11 @@ mysqlnd_stmt_prepare_read_eof(MYSQLND_STMT *stmt TSRMLS_DC)
 			stmt->state = MYSQLND_STMT_INITTED;
 		}
 	} else {
-		stmt->upsert_status.server_status = fields_eof.server_status;
-		stmt->upsert_status.warning_count = fields_eof.warning_count;
+		stmt->upsert_status.server_status = fields_eof->server_status;
+		stmt->upsert_status.warning_count = fields_eof->warning_count;
 		stmt->state = MYSQLND_STMT_PREPARED;
 	}
-	PACKET_FREE_ALLOCA(fields_eof);
+	PACKET_FREE(fields_eof);
 
 	DBG_RETURN(ret);
 }
@@ -390,8 +304,7 @@ mysqlnd_stmt_prepare_read_eof(MYSQLND_STMT *stmt TSRMLS_DC)
 
 /* {{{ mysqlnd_stmt::prepare */
 static enum_func_status
-MYSQLND_METHOD(mysqlnd_stmt, prepare)(MYSQLND_STMT * const stmt, const char * const query,
-									  unsigned int query_len TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_stmt, prepare)(MYSQLND_STMT * const stmt, const char * const query, unsigned int query_len TSRMLS_DC)
 {
 	MYSQLND_STMT *stmt_to_prepare = stmt;
 
@@ -422,8 +335,8 @@ MYSQLND_METHOD(mysqlnd_stmt, prepare)(MYSQLND_STMT * const stmt, const char * co
 		stmt_to_prepare = mysqlnd_stmt_init(stmt->conn);
 	}
 
-	if (FAIL == mysqlnd_simple_command(stmt_to_prepare->conn, COM_STMT_PREPARE, query,
-									   query_len, PROT_LAST, FALSE, TRUE TSRMLS_CC) ||
+	if (FAIL == stmt_to_prepare->conn->m->simple_command(stmt_to_prepare->conn, COM_STMT_PREPARE, query,
+															query_len, PROT_LAST, FALSE, TRUE TSRMLS_CC) ||
 		FAIL == mysqlnd_stmt_read_prepare_response(stmt_to_prepare TSRMLS_CC)) {
 		goto fail;
 	}
@@ -442,9 +355,7 @@ MYSQLND_METHOD(mysqlnd_stmt, prepare)(MYSQLND_STMT * const stmt, const char * co
 	  no metadata at prepare.
 	*/
 	if (stmt_to_prepare->field_count) {
-		MYSQLND_RES *result = mysqlnd_result_init(stmt_to_prepare->field_count,
-												  mysqlnd_palloc_get_thd_cache_reference(stmt->conn->zval_cache)
-												  TSRMLS_CC);
+		MYSQLND_RES *result = mysqlnd_result_init(stmt_to_prepare->field_count TSRMLS_CC);
 		/* Allocate the result now as it is needed for the reading of metadata */
 		stmt_to_prepare->result = result; 
 
@@ -686,9 +597,9 @@ MYSQLND_METHOD(mysqlnd_stmt, execute)(MYSQLND_STMT * const stmt TSRMLS_DC)
 	
 	/* support for buffer types should be added here ! */
 
-	ret = mysqlnd_simple_command(stmt->conn, COM_STMT_EXECUTE, (char *)request, request_len,
-								 PROT_LAST /* we will handle the response packet*/,
-								 FALSE, FALSE TSRMLS_CC);
+	ret = stmt->conn->m->simple_command(stmt->conn, COM_STMT_EXECUTE, (char *)request, request_len,
+										PROT_LAST /* we will handle the response packet*/,
+										FALSE, FALSE TSRMLS_CC);
 
 	if (free_request) {
 		mnd_efree(request);
@@ -701,15 +612,19 @@ MYSQLND_METHOD(mysqlnd_stmt, execute)(MYSQLND_STMT * const stmt TSRMLS_DC)
 	}
 	stmt->execute_count++;
 
-	DBG_RETURN(mysqlnd_stmt_execute_parse_response(stmt TSRMLS_CC));
+	ret = mysqlnd_stmt_execute_parse_response(stmt TSRMLS_CC);
+
+	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);
+	}
+	DBG_RETURN(ret);
 }
 /* }}} */
 
 
 /* {{{ mysqlnd_fetch_stmt_row_buffered */
 enum_func_status
-mysqlnd_fetch_stmt_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags,
-								zend_bool *fetched_anything TSRMLS_DC)
+mysqlnd_fetch_stmt_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags, zend_bool *fetched_anything TSRMLS_DC)
 {
 	MYSQLND_STMT *stmt = (MYSQLND_STMT *) param;
 	MYSQLND_RES_BUFFERED *set = result->stored_data;
@@ -735,7 +650,10 @@ mysqlnd_fetch_stmt_row_buffered(MYSQLND_RES *result, void *param, unsigned int f
 									  current_row,
 									  meta->field_count,
 									  meta->fields,
-									  result->conn TSRMLS_CC);
+									  result->stored_data->persistent,
+									  result->conn->options.numeric_and_datetime_as_unicode,
+									  result->conn->options.int_and_float_native,
+									  result->conn->stats TSRMLS_CC);
 				if (stmt->update_max_length) {
 					for (i = 0; i < result->field_count; i++) {
 						/*
@@ -801,12 +719,11 @@ mysqlnd_fetch_stmt_row_buffered(MYSQLND_RES *result, void *param, unsigned int f
 
 /* {{{ mysqlnd_stmt_fetch_row_unbuffered */
 static enum_func_status
-mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flags,
-								zend_bool *fetched_anything TSRMLS_DC)
+mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flags, zend_bool *fetched_anything TSRMLS_DC)
 {
 	enum_func_status ret;
 	MYSQLND_STMT *stmt = (MYSQLND_STMT *) param;
-	php_mysql_packet_row *row_packet = result->row_packet;
+	MYSQLND_PACKET_ROW *row_packet = result->row_packet;
 
 	DBG_ENTER("mysqlnd_stmt_fetch_row_unbuffered");
 
@@ -827,7 +744,7 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int
 
 	/*
 	  If we skip rows (stmt == NULL || stmt->result_bind == NULL) we have to
-	  mysqlnd_unbuffered_free_last_data() before it. The function returns always true.
+	  result->m.unbuffered_free_last_data() before it. The function returns always true.
 	*/
 	if (PASS == (ret = PACKET_READ(row_packet, result->conn)) && !row_packet->eof) {
 		unsigned int i, field_count = result->field_count;
@@ -835,7 +752,7 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int
 		*fetched_anything = TRUE;
 
 		if (!row_packet->skip_extraction) {
-			mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
+			result->m.unbuffered_free_last_data(result TSRMLS_CC);
 
 			DBG_INF("extracting data");
 			result->unbuf->last_row_data = row_packet->fields;
@@ -847,14 +764,17 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int
 								  result->unbuf->last_row_data,
 								  row_packet->field_count,
 								  row_packet->fields_metadata,
-								  result->conn TSRMLS_CC);
+								  FALSE,
+								  result->conn->options.numeric_and_datetime_as_unicode,
+								  result->conn->options.int_and_float_native,
+								  result->conn->stats TSRMLS_CC);
 
 			for (i = 0; i < field_count; i++) {
 				if (stmt->result_bind[i].bound == TRUE) {
 					zval *data = result->unbuf->last_row_data[i];
 					/*
 					  stmt->result_bind[i].zv has been already destructed
-					  in mysqlnd_unbuffered_free_last_data()
+					  in result->m.unbuffered_free_last_data()
 					*/
 #ifndef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
 					zval_dtor(stmt->result_bind[i].zv);
@@ -871,16 +791,16 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int
 							result->meta->fields[i].max_length = Z_STRLEN_P(data);
 						}
 						stmt->result_bind[i].zv->value = data->value;
-						// copied data, thus also the ownership. Thus null data
+						/* copied data, thus also the ownership. Thus null data */
 						ZVAL_NULL(data);
 					}
 				}
 			}
-			MYSQLND_INC_CONN_STATISTIC(&stmt->conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_PS_UNBUF);
+			MYSQLND_INC_CONN_STATISTIC(stmt->conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_PS_UNBUF);
 		} else {
 			DBG_INF("skipping extraction");
 			/*
-			  Data has been allocated and usually mysqlnd_unbuffered_free_last_data()
+			  Data has been allocated and usually result->m.unbuffered_free_last_data()
 			  frees it but we can't call this function as it will cause problems with
 			  the bound variables. Thus we need to do part of what it does or Zend will
 			  report leaks.
@@ -943,7 +863,7 @@ MYSQLND_METHOD(mysqlnd_stmt, use_result)(MYSQLND_STMT *stmt TSRMLS_DC)
 
 	SET_EMPTY_ERROR(stmt->error_info);
 
-	MYSQLND_INC_CONN_STATISTIC(&stmt->conn->stats, STAT_PS_UNBUFFERED_SETS);
+	MYSQLND_INC_CONN_STATISTIC(stmt->conn->stats, STAT_PS_UNBUFFERED_SETS);
 	result = stmt->result;
 
 	DBG_INF_FMT("%scursor exists", stmt->cursor_exists? "":"no ");
@@ -962,13 +882,12 @@ MYSQLND_METHOD(mysqlnd_stmt, use_result)(MYSQLND_STMT *stmt TSRMLS_DC)
 
 /* {{{ mysqlnd_fetch_row_cursor */
 enum_func_status
-mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int flags,
-							  zend_bool *fetched_anything TSRMLS_DC)
+mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int flags, zend_bool *fetched_anything TSRMLS_DC)
 {
 	enum_func_status ret;
 	MYSQLND_STMT *stmt = (MYSQLND_STMT *) param;
 	zend_uchar buf[STMT_ID_LENGTH /* statement id */ + 4 /* number of rows to fetch */];
-	php_mysql_packet_row *row_packet = result->row_packet;
+	MYSQLND_PACKET_ROW *row_packet = result->row_packet;
 
 	DBG_ENTER("mysqlnd_fetch_stmt_row_cursor");
 
@@ -993,9 +912,9 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla
 	int4store(buf, stmt->stmt_id);
 	int4store(buf + STMT_ID_LENGTH, 1); /* for now fetch only one row */
 
-	if (FAIL == mysqlnd_simple_command(stmt->conn, COM_STMT_FETCH, (char *)buf, sizeof(buf),
-									   PROT_LAST /* we will handle the response packet*/,
-									   FALSE, TRUE TSRMLS_CC)) {
+	if (FAIL == stmt->conn->m->simple_command(stmt->conn, COM_STMT_FETCH, (char *)buf, sizeof(buf),
+											  PROT_LAST /* we will handle the response packet*/,
+											  FALSE, TRUE TSRMLS_CC)) {
 		stmt->error_info = stmt->conn->error_info;
 		DBG_RETURN(FAIL);
 	}
@@ -1009,7 +928,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla
 
 		DBG_INF_FMT("skip_extraction=%d", row_packet->skip_extraction); 
 		if (!row_packet->skip_extraction) {
-			mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
+			result->m.unbuffered_free_last_data(result TSRMLS_CC);
 
 			DBG_INF("extracting data");
 			result->unbuf->last_row_data = row_packet->fields;
@@ -1021,7 +940,10 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla
 								  result->unbuf->last_row_data,
 								  row_packet->field_count,
 								  row_packet->fields_metadata,
-								  result->conn TSRMLS_CC);
+								  FALSE,
+								  result->conn->options.numeric_and_datetime_as_unicode,
+								  result->conn->options.int_and_float_native,
+								  result->conn->stats TSRMLS_CC);
 
 			/* If no result bind, do nothing. We consumed the data */
 			for (i = 0; i < field_count; i++) {
@@ -1029,7 +951,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla
 					zval *data = result->unbuf->last_row_data[i];
 					/*
 					  stmt->result_bind[i].zv has been already destructed
-					  in mysqlnd_unbuffered_free_last_data()
+					  in result->m.unbuffered_free_last_data()
 					*/
 #ifndef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
 					zval_dtor(stmt->result_bind[i].zv);
@@ -1047,7 +969,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla
 							result->meta->fields[i].max_length = Z_STRLEN_P(data);
 						}
 						stmt->result_bind[i].zv->value = data->value;
-						// copied data, thus also the ownership. Thus null data
+						/* copied data, thus also the ownership. Thus null data */
 						ZVAL_NULL(data);
 					}
 				}
@@ -1055,7 +977,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla
 		} else {
 			DBG_INF("skipping extraction");
 			/*
-			  Data has been allocated and usually mysqlnd_unbuffered_free_last_data()
+			  Data has been allocated and usually result->m.unbuffered_free_last_data()
 			  frees it but we can't call this function as it will cause problems with
 			  the bound variables. Thus we need to do part of what it does or Zend will
 			  report leaks.
@@ -1069,7 +991,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla
 			row_packet->row_buffer->free_chunk(row_packet->row_buffer, TRUE TSRMLS_CC);
 			row_packet->row_buffer = NULL;
 		}
-		MYSQLND_INC_CONN_STATISTIC(&stmt->conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_PS_CURSOR);
+		MYSQLND_INC_CONN_STATISTIC(stmt->conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_PS_CURSOR);
 	} else {
 		*fetched_anything = FALSE;
 
@@ -1101,8 +1023,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla
 
 /* {{{ mysqlnd_stmt::fetch */
 static enum_func_status
-MYSQLND_METHOD(mysqlnd_stmt, fetch)(MYSQLND_STMT * const stmt,
-									zend_bool * const fetched_anything TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_stmt, fetch)(MYSQLND_STMT * const stmt, zend_bool * const fetched_anything TSRMLS_DC)
 {
 	enum_func_status ret;
 	DBG_ENTER("mysqlnd_stmt::fetch");
@@ -1200,7 +1121,7 @@ MYSQLND_METHOD(mysqlnd_stmt, reset)(MYSQLND_STMT * const stmt TSRMLS_DC)
 
 		int4store(cmd_buf, stmt->stmt_id);
 		if (CONN_GET_STATE(conn) == CONN_READY &&
-			FAIL == (ret = mysqlnd_simple_command(conn, COM_STMT_RESET, (char *)cmd_buf,
+			FAIL == (ret = conn->m->simple_command(conn, COM_STMT_RESET, (char *)cmd_buf,
 												  sizeof(cmd_buf), PROT_OK_PACKET,
 												  FALSE, TRUE TSRMLS_CC))) {
 			stmt->error_info = conn->error_info;
@@ -1257,7 +1178,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const stmt, unsigned
 	  XXX:	Unfortunately we have to allocate additional buffer to be able the
 			additional data, which is like a header inside the payload.
 			This should be optimised, but it will be a pervasive change, so
-			mysqlnd_simple_command() will accept not a buffer, but actually MYSQLND_STRING*
+			conn->m->simple_command() will accept not a buffer, but actually MYSQLND_STRING*
 			terminated by NULL, to send. If the strings are not big, we can collapse them
 			on the buffer every connection has, but otherwise we will just send them
 			one by one to the wire.
@@ -1273,7 +1194,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const stmt, unsigned
 		memcpy(cmd_buf + STMT_ID_LENGTH + 2, data, length);
 
 		/* COM_STMT_SEND_LONG_DATA doesn't send an OK packet*/
-		ret = mysqlnd_simple_command(conn, cmd, (char *)cmd_buf, packet_len,
+		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) {
@@ -1299,7 +1220,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const stmt, unsigned
 #if HAVE_USLEEP && !defined(PHP_WIN32)
 		usleep(120000);
 #endif
-		if ((packet_len = php_mysqlnd_consume_uneaten_data(conn, cmd TSRMLS_CC))) {
+		if ((packet_len = conn->net->m.consume_uneaten_data(conn->net, cmd TSRMLS_CC))) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "There was an error "
 							 "while sending long data. Probably max_allowed_packet_size "
 							 "is smaller than the data. You have to increase it or send "
@@ -1319,8 +1240,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const stmt, unsigned
 
 /* {{{ mysqlnd_stmt::bind_parameters */
 static enum_func_status
-MYSQLND_METHOD(mysqlnd_stmt, bind_parameters)(MYSQLND_STMT * const stmt,
-											  MYSQLND_PARAM_BIND * const param_bind TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_stmt, bind_parameters)(MYSQLND_STMT * const stmt, MYSQLND_PARAM_BIND * const param_bind TSRMLS_DC)
 {
 	DBG_ENTER("mysqlnd_stmt::bind_param");
 	DBG_INF_FMT("stmt=%lu param_count=%u", stmt->stmt_id, stmt->param_count);
@@ -1586,7 +1506,7 @@ MYSQLND_METHOD(mysqlnd_stmt, set_result_bind_dtor)(MYSQLND_STMT * const stmt,
 
 /* {{{ mysqlnd_stmt::insert_id */
 static uint64_t
-MYSQLND_METHOD(mysqlnd_stmt, insert_id)(const MYSQLND_STMT * const stmt)
+MYSQLND_METHOD(mysqlnd_stmt, insert_id)(const MYSQLND_STMT * const stmt TSRMLS_DC)
 {
 	return stmt->upsert_status.last_insert_id;
 }
@@ -1595,7 +1515,7 @@ MYSQLND_METHOD(mysqlnd_stmt, insert_id)(const MYSQLND_STMT * const stmt)
 
 /* {{{ mysqlnd_stmt::affected_rows */
 static uint64_t
-MYSQLND_METHOD(mysqlnd_stmt, affected_rows)(const MYSQLND_STMT * const stmt)
+MYSQLND_METHOD(mysqlnd_stmt, affected_rows)(const MYSQLND_STMT * const stmt TSRMLS_DC)
 {
 	return stmt->upsert_status.affected_rows;
 }
@@ -1604,7 +1524,7 @@ MYSQLND_METHOD(mysqlnd_stmt, affected_rows)(const MYSQLND_STMT * const stmt)
 
 /* {{{ mysqlnd_stmt::num_rows */
 static uint64_t
-MYSQLND_METHOD(mysqlnd_stmt, num_rows)(const MYSQLND_STMT * const stmt)
+MYSQLND_METHOD(mysqlnd_stmt, num_rows)(const MYSQLND_STMT * const stmt TSRMLS_DC)
 {
 	return stmt->result? mysqlnd_num_rows(stmt->result):0;
 }
@@ -1613,7 +1533,7 @@ MYSQLND_METHOD(mysqlnd_stmt, num_rows)(const MYSQLND_STMT * const stmt)
 
 /* {{{ mysqlnd_stmt::warning_count */
 static unsigned int
-MYSQLND_METHOD(mysqlnd_stmt, warning_count)(const MYSQLND_STMT * const stmt)
+MYSQLND_METHOD(mysqlnd_stmt, warning_count)(const MYSQLND_STMT * const stmt TSRMLS_DC)
 {
 	return stmt->upsert_status.warning_count;
 }
@@ -1622,7 +1542,7 @@ MYSQLND_METHOD(mysqlnd_stmt, warning_count)(const MYSQLND_STMT * const stmt)
 
 /* {{{ mysqlnd_stmt::field_count */
 static unsigned int
-MYSQLND_METHOD(mysqlnd_stmt, field_count)(const MYSQLND_STMT * const stmt)
+MYSQLND_METHOD(mysqlnd_stmt, field_count)(const MYSQLND_STMT * const stmt TSRMLS_DC)
 {
 	return stmt->field_count;
 }
@@ -1631,7 +1551,7 @@ MYSQLND_METHOD(mysqlnd_stmt, field_count)(const MYSQLND_STMT * const stmt)
 
 /* {{{ mysqlnd_stmt::param_count */
 static unsigned int
-MYSQLND_METHOD(mysqlnd_stmt, param_count)(const MYSQLND_STMT * const stmt)
+MYSQLND_METHOD(mysqlnd_stmt, param_count)(const MYSQLND_STMT * const stmt TSRMLS_DC)
 {
 	return stmt->param_count;
 }
@@ -1640,7 +1560,7 @@ MYSQLND_METHOD(mysqlnd_stmt, param_count)(const MYSQLND_STMT * const stmt)
 
 /* {{{ mysqlnd_stmt::errno */
 static unsigned int
-MYSQLND_METHOD(mysqlnd_stmt, errno)(const MYSQLND_STMT * const stmt)
+MYSQLND_METHOD(mysqlnd_stmt, errno)(const MYSQLND_STMT * const stmt TSRMLS_DC)
 {
 	return stmt->error_info.error_no;
 }
@@ -1649,7 +1569,7 @@ MYSQLND_METHOD(mysqlnd_stmt, errno)(const MYSQLND_STMT * const stmt)
 
 /* {{{ mysqlnd_stmt::error */
 static const char *
-MYSQLND_METHOD(mysqlnd_stmt, error)(const MYSQLND_STMT * const stmt)
+MYSQLND_METHOD(mysqlnd_stmt, error)(const MYSQLND_STMT * const stmt TSRMLS_DC)
 {
 	return stmt->error_info.error;
 }
@@ -1658,7 +1578,7 @@ MYSQLND_METHOD(mysqlnd_stmt, error)(const MYSQLND_STMT * const stmt)
 
 /* {{{ mysqlnd_stmt::sqlstate */
 static const char *
-MYSQLND_METHOD(mysqlnd_stmt, sqlstate)(const MYSQLND_STMT * const stmt)
+MYSQLND_METHOD(mysqlnd_stmt, sqlstate)(const MYSQLND_STMT * const stmt TSRMLS_DC)
 {
 	return stmt->error_info.sqlstate[0] ? stmt->error_info.sqlstate:MYSQLND_SQLSTATE_NULL;
 }
@@ -1676,7 +1596,7 @@ MYSQLND_METHOD(mysqlnd_stmt, data_seek)(const MYSQLND_STMT * const stmt, uint64_
 
 /* {{{ mysqlnd_stmt::param_metadata */
 static MYSQLND_RES *
-MYSQLND_METHOD(mysqlnd_stmt, param_metadata)(MYSQLND_STMT * const stmt)
+MYSQLND_METHOD(mysqlnd_stmt, param_metadata)(MYSQLND_STMT * const stmt TSRMLS_DC)
 {
 	if (!stmt->param_count) {
 		return NULL;
@@ -1703,7 +1623,7 @@ MYSQLND_METHOD(mysqlnd_stmt, result_metadata)(MYSQLND_STMT * const stmt TSRMLS_D
 
 	if (stmt->update_max_length && stmt->result->stored_data) {
 		/* stored result, we have to update the max_length before we clone the meta data :( */
-		mysqlnd_res_initialize_result_set_rest(stmt->result TSRMLS_CC);
+		stmt->result->m.initialize_result_set_rest(stmt->result TSRMLS_CC);
 	}
 	/*
 	  TODO: This implementation is kind of a hack,
@@ -1714,7 +1634,7 @@ MYSQLND_METHOD(mysqlnd_stmt, result_metadata)(MYSQLND_STMT * const stmt TSRMLS_D
 	  In the meantime we don't need a zval cache reference for this fake
 	  result set, so we don't get one.
 	*/
-	result = mysqlnd_result_init(stmt->field_count, NULL TSRMLS_CC);
+	result = mysqlnd_result_init(stmt->field_count TSRMLS_CC);
 	result->type = MYSQLND_RES_NORMAL;
 	result->m.fetch_row = result->m.fetch_row_normal_unbuffered;
 	result->unbuf = mnd_ecalloc(1, sizeof(MYSQLND_RES_UNBUFFERED));
@@ -2043,7 +1963,7 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, net_close)(MYSQLND_STMT * const stmt, zend_
 
 		int4store(cmd_buf, stmt->stmt_id);
 		if (CONN_GET_STATE(conn) == CONN_READY &&
-			FAIL == mysqlnd_simple_command(conn, COM_STMT_CLOSE, (char *)cmd_buf, sizeof(cmd_buf),
+			FAIL == conn->m->simple_command(conn, COM_STMT_CLOSE, (char *)cmd_buf, sizeof(cmd_buf),
 										   PROT_LAST /* COM_STMT_CLOSE doesn't send an OK packet*/,
 										   FALSE, TRUE TSRMLS_CC)) {
 			stmt->error_info = conn->error_info;
@@ -2061,7 +1981,7 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, net_close)(MYSQLND_STMT * const stmt, zend_
 			break;
 	}
 	if (stat != STAT_LAST) {
-		MYSQLND_INC_CONN_STATISTIC(&conn->stats, stat);
+		MYSQLND_INC_CONN_STATISTIC(conn->stats, stat);
 	}
 
 	if (stmt->execute_cmd_buffer.buffer) {
@@ -2106,7 +2026,6 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_stmt)
 	MYSQLND_METHOD(mysqlnd_stmt, execute),
 	MYSQLND_METHOD(mysqlnd_stmt, use_result),
 	MYSQLND_METHOD(mysqlnd_stmt, store_result),
-	MYSQLND_METHOD(mysqlnd_stmt, background_store_result),
 	MYSQLND_METHOD(mysqlnd_stmt, get_result),
 	MYSQLND_METHOD(mysqlnd_stmt, more_results),
 	MYSQLND_METHOD(mysqlnd_stmt, next_result),
@@ -2149,7 +2068,8 @@ MYSQLND_CLASS_METHODS_END;
 /* {{{ _mysqlnd_stmt_init */
 MYSQLND_STMT * _mysqlnd_stmt_init(MYSQLND * const conn TSRMLS_DC)
 {
-	MYSQLND_STMT *stmt = mnd_ecalloc(1, sizeof(MYSQLND_STMT));
+	size_t alloc_size = sizeof(MYSQLND_STMT) + mysqlnd_plugin_count() * sizeof(void *);
+	MYSQLND_STMT *stmt = mnd_ecalloc(1, alloc_size);
 
 	DBG_ENTER("_mysqlnd_stmt_init");
 	DBG_INF_FMT("stmt=%p", stmt); 
@@ -2175,6 +2095,19 @@ MYSQLND_STMT * _mysqlnd_stmt_init(MYSQLND * const conn TSRMLS_DC)
 /* }}} */
 
 
+/* {{{ _mysqlnd_plugin_get_plugin_stmt_data */
+PHPAPI void ** _mysqlnd_plugin_get_plugin_stmt_data(const MYSQLND_STMT * stmt, unsigned int plugin_id TSRMLS_DC)
+{
+	DBG_ENTER("_mysqlnd_plugin_get_plugin_stmt_data");
+	DBG_INF_FMT("plugin_id=%u", plugin_id);
+	if (!stmt || plugin_id >= mysqlnd_plugin_count()) {
+		return NULL;
+	}
+	DBG_RETURN((void *)((char *)stmt + sizeof(MYSQLND_STMT) + plugin_id * sizeof(void *)));
+}
+/* }}} */
+
+
 /* {{{ mysqlnd_efree_param_bind_dtor */
 PHPAPI void
 mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind TSRMLS_DC)
diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c
index 65be192..650584c 100644
--- a/ext/mysqlnd/mysqlnd_ps_codec.c
+++ b/ext/mysqlnd/mysqlnd_ps_codec.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_ps_codec.c 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysqlnd_ps_codec.c 289030 2009-09-30 23:34:56Z andrey $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
diff --git a/ext/mysqlnd/mysqlnd_qcache.c b/ext/mysqlnd/mysqlnd_qcache.c
deleted file mode 100644
index 467ad09..0000000
--- a/ext/mysqlnd/mysqlnd_qcache.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
-  +----------------------------------------------------------------------+
-  | PHP Version 6                                                        |
-  +----------------------------------------------------------------------+
-  | Copyright (c) 2006-2009 The PHP Group                                |
-  +----------------------------------------------------------------------+
-  | This source file is subject to version 3.01 of the PHP license,      |
-  | that is bundled with this package in the file LICENSE, and is        |
-  | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
-  | If you did not receive a copy of the PHP license and are unable to   |
-  | obtain it through the world-wide-web, please send a note to          |
-  | license at php.net so we can mail you a copy immediately.               |
-  +----------------------------------------------------------------------+
-  | Authors: Georg Richter <georg at mysql.com>                             |
-  |          Andrey Hristov <andrey at mysql.com>                           |
-  |          Ulf Wendel <uwendel at mysql.com>                              |
-  +----------------------------------------------------------------------+
-*/
-
-/* $Id: mysqlnd_qcache.c 272370 2008-12-31 11:15:49Z sebastian $ */
-#include "php.h"
-#include "mysqlnd.h"
-#include "mysqlnd_priv.h"
-#include "mysqlnd_statistics.h"
-
-#define MYSQLND_SILENT
-
-#ifdef ZTS
-#define LOCK_QCACHE(cache)		tsrm_mutex_lock((cache)->LOCK_access)
-#define UNLOCK_QCACHE(cache)	tsrm_mutex_unlock((cache)->LOCK_access)
-#else
-#define LOCK_QCACHE(cache)
-#define UNLOCK_QCACHE(cache)
-#endif
-
-
-/* {{{ mysqlnd_qcache_init_cache */
-PHPAPI MYSQLND_QCACHE * mysqlnd_qcache_init_cache()
-{
-	MYSQLND_QCACHE *cache = calloc(1, sizeof(MYSQLND_QCACHE));
-#ifndef MYSQLND_SILENT
-	php_printf("[mysqlnd_qcache_init_cache %p]\n", cache);
-#endif
-
-	cache->references = 1;
-#ifdef ZTS
-	cache->LOCK_access = tsrm_mutex_alloc();
-#endif
-	cache->ht = malloc(sizeof(HashTable));
-	zend_hash_init(cache->ht, 10 /* init_elements */, NULL, NULL, TRUE /*pers*/);
-
-	return cache;
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_qcache_get_cache_reference */
-PHPAPI MYSQLND_QCACHE * mysqlnd_qcache_get_cache_reference(MYSQLND_QCACHE * const cache)
-{
-	if (cache) {
-#ifndef MYSQLND_SILENT
-		php_printf("[mysqlnd_qcache_get_cache_reference %p will become %d]\n", cache, cache->references+1);
-#endif
-		LOCK_QCACHE(cache);
-		cache->references++;
-		UNLOCK_QCACHE(cache);
-	}
-	return cache;
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_qcache_free_cache */
-/*
-  As this call will happen on MSHUTDOWN(), then we don't need to copy the zvals with
-  copy_ctor but scrap what they point to with zval_dtor() and then just free our
-  pre-allocated block. Precondition is that we ZVAL_NULL() the zvals when we put them
-  to the free list after usage. We ZVAL_NULL() them when we allocate them in the 
-  constructor of the cache.
-*/
-static
-void mysqlnd_qcache_free_cache(MYSQLND_QCACHE *cache)
-{
-#ifndef MYSQLND_SILENT
-	php_printf("[mysqlnd_qcache_free_cache %p]\n", cache);
-#endif
-
-#ifdef ZTS
-	tsrm_mutex_free(cache->LOCK_access);
-#endif
-	zend_hash_destroy(cache->ht);
-	free(cache->ht);
-	free(cache);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_qcache_free_cache_reference */
-PHPAPI void mysqlnd_qcache_free_cache_reference(MYSQLND_QCACHE **cache)
-{
-	if (*cache) {
-		zend_bool to_free;
-#ifndef MYSQLND_SILENT
-		php_printf("[mysqlnd_qcache_free_cache_reference %p] refs=%d\n", *cache, (*cache)->references);
-#endif
-		LOCK_QCACHE(*cache);
-		to_free = --(*cache)->references == 0;
-		/* Unlock before destroying */
-		UNLOCK_QCACHE(*cache);
-		if (to_free) {
-			mysqlnd_qcache_free_cache(*cache);
-		}
-		*cache = NULL;
-	}
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_qcache_free_cache_reference */
-PHPAPI void mysqlnd_qcache_stats(const MYSQLND_QCACHE * const cache, zval *return_value)
-{
-	if (cache) {
-		LOCK_QCACHE(cache);
-		array_init(return_value);
-		add_assoc_long_ex(return_value, "references",	sizeof("references"),	cache->references);
-		UNLOCK_QCACHE(cache);
-	} else {
-		ZVAL_NULL(return_value);
-	}
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index e724820..2e1d012 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -18,10 +18,11 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result.c 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysqlnd_result.c 294543 2010-02-04 20:28:55Z johannes $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
+#include "mysqlnd_block_alloc.h"
 #include "mysqlnd_priv.h"
 #include "mysqlnd_result.h"
 #include "mysqlnd_result_meta.h"
@@ -32,75 +33,17 @@
 
 #define MYSQLND_SILENT
 
-#ifdef MYSQLND_THREADED
-/* {{{ mysqlnd_fetch_thread */
-void * mysqlnd_fetch_thread(void *arg)
-{
-	MYSQLND *conn = (MYSQLND *) arg;
-	MYSQLND_RES * result = NULL;
-	void ***tsrm_ls = conn->tsrm_ls;
-#ifndef MYSQLND_SILENT
-	printf("THREAD] conn=%p tsrm_ls=%p\n", conn, conn->tsrm_ls);
-#endif
-	do {
-		pthread_mutex_lock(&conn->LOCK_work);
-		while (conn->thread_killed == FALSE && !conn->current_result) {
-#ifndef MYSQLND_SILENT
-			printf("THREAD] Waiting for work in %s\n", __FUNCTION__);
-#endif
-			pthread_cond_wait(&conn->COND_work, &conn->LOCK_work);
-		}
-		if (conn->thread_killed == TRUE) {
-#ifndef MYSQLND_SILENT
-			printf("THREAD] Thread killed in %s\n", __FUNCTION__);
-#endif
-			pthread_cond_signal(&conn->COND_thread_ended);
-			pthread_mutex_unlock(&conn->LOCK_work);
-			break;
-		}
-#ifndef MYSQLND_SILENT
-		printf("THREAD] Got work in %s\n", __FUNCTION__);
-#endif
-		CONN_SET_STATE(conn, CONN_FETCHING_DATA);
-		result = conn->current_result;
-		conn->current_result = NULL;
-		pthread_cond_signal(&conn->COND_work); /* sent notification back */
-		pthread_mutex_unlock(&conn->LOCK_work);
-
-#ifndef MYSQLND_SILENT
-		printf("THREAD] Starting fetch %s\n", __FUNCTION__);
-#endif
-		mysqlnd_background_store_result_fetch_data(result TSRMLS_CC);
-
-		/* do fetch the data from the wire */
 
-		pthread_mutex_lock(&conn->LOCK_work);
-		CONN_SET_STATE(conn, CONN_READY);
-		pthread_cond_signal(&conn->COND_work_done);
-#ifndef MYSQLND_SILENT
-		printf("THREAD] Signaling work done in %s\n", __FUNCTION__);
-#endif
-		pthread_mutex_unlock(&conn->LOCK_work);
-	} while (1);
-
-#ifndef MYSQLND_SILENT
-	printf("THREAD] Exiting worker thread in %s\n", __FUNCTION__);
-#endif
-	return NULL;
-}
-/* }}} */
-#endif /* MYSQLND_THREADED */
-
-
-/* {{{ mysqlnd_res_initialize_result_set_rest */
-void mysqlnd_res_initialize_result_set_rest(MYSQLND_RES * const result TSRMLS_DC)
+/* {{{ mysqlnd_res::initialize_result_set_rest */
+static void
+MYSQLND_METHOD(mysqlnd_res, initialize_result_set_rest)(MYSQLND_RES * const result TSRMLS_DC)
 {
 	unsigned int i;
 	zval **data_cursor = result->stored_data->data;
 	zval **data_begin = result->stored_data->data;
 	unsigned int field_count = result->meta->field_count;
 	unsigned int row_count = result->stored_data->row_count;
-	DBG_ENTER("mysqlnd_res_initialize_result_set_rest");
+	DBG_ENTER("mysqlnd_res::initialize_result_set_rest");
 
 	if (!data_cursor || row_count == result->stored_data->initialized_rows) {
 		DBG_VOID_RETURN;
@@ -113,7 +56,10 @@ void mysqlnd_res_initialize_result_set_rest(MYSQLND_RES * const result TSRMLS_DC
 						data_cursor,
 						result->meta->field_count,
 						result->meta->fields,
-						result->conn TSRMLS_CC);
+						result->stored_data->persistent,
+						result->conn->options.numeric_and_datetime_as_unicode,
+						result->conn->options.int_and_float_native,
+						result->conn->stats TSRMLS_CC);
 			for (i = 0; i < result->field_count; i++) {
 				/*
 				  NULL fields are 0 length, 0 is not more than 0
@@ -135,12 +81,60 @@ void mysqlnd_res_initialize_result_set_rest(MYSQLND_RES * const result TSRMLS_DC
 /* }}} */
 
 
-/* {{{ mysqlnd_unbuffered_free_last_data */
-void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC)
+
+/* {{{ mysqlnd_palloc_zval_ptr_dtor */
+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;
+	{
+		/*
+		  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) {
+			; /* do nothing, zval_ptr_dtor will do the job*/
+		} else if (Z_REFCOUNT_PP(zv) > 1) {
+			/*
+			  Not a prepared statement, then we have to
+			  call copy_ctor and then zval_ptr_dtor()
+
+			  In Unicode mode the destruction  of the zvals should not call
+			  zval_copy_ctor() because then we will leak.
+			  I suppose we can use UG(unicode) in mysqlnd.c when freeing a result set
+			  to check if we need to call copy_ctor().
+
+			  If the type is IS_UNICODE, which can happen with PHP6, then we don't
+			  need to copy_ctor, as the data doesn't point to our internal buffers.
+			  If it's string (in PHP5 always) and in PHP6 if data is binary, then
+			  it still points to internal buffers and has to be copied.
+			*/
+			if (Z_TYPE_PP(zv) == IS_STRING) {
+				zval_copy_ctor(*zv);
+			}
+			*copy_ctor_called = TRUE;
+		} else {
+			if (Z_TYPE_PP(zv) == IS_STRING) {
+				ZVAL_NULL(*zv);
+			}
+		}
+		zval_ptr_dtor(zv);
+		DBG_VOID_RETURN;
+	}
+
+	DBG_VOID_RETURN;
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_res::unbuffered_free_last_data */
+static void
+MYSQLND_METHOD(mysqlnd_res, unbuffered_free_last_data)(MYSQLND_RES * result TSRMLS_DC)
 {
 	MYSQLND_RES_UNBUFFERED *unbuf = result->unbuf;
 
-	DBG_ENTER("mysqlnd_unbuffered_free_last_data");
+	DBG_ENTER("mysqlnd_res::unbuffered_free_last_data");
 
 	if (!unbuf) {
 		DBG_VOID_RETURN;
@@ -150,13 +144,11 @@ void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC)
 	if (unbuf->last_row_data) {
 		unsigned int i, ctor_called_count = 0;
 		zend_bool copy_ctor_called;
-		MYSQLND_STATS *global_stats = result->conn? &result->conn->stats:NULL;
+		MYSQLND_STATS *global_stats = result->conn? result->conn->stats:NULL;
 
 		DBG_INF_FMT("%u columns to free", result->field_count);
 		for (i = 0; i < result->field_count; i++) {
-			mysqlnd_palloc_zval_ptr_dtor(&(unbuf->last_row_data[i]),
-										 result->zval_cache, result->type,
-										 &copy_ctor_called TSRMLS_CC);
+			mysqlnd_palloc_zval_ptr_dtor(&(unbuf->last_row_data[i]), result->type, &copy_ctor_called TSRMLS_CC);
 			if (copy_ctor_called) {
 				ctor_called_count++;
 			}
@@ -186,15 +178,15 @@ void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC)
 /* }}} */
 
 
-/* {{{ mysqlnd_free_buffered_data */
-void mysqlnd_free_buffered_data(MYSQLND_RES *result TSRMLS_DC)
+/* {{{ mysqlnd_res::free_buffered_data */
+static void
+MYSQLND_METHOD(mysqlnd_res, free_buffered_data)(MYSQLND_RES *result TSRMLS_DC)
 {
-	MYSQLND_THD_ZVAL_PCACHE  *zval_cache = result->zval_cache;
 	MYSQLND_RES_BUFFERED *set = result->stored_data;
 	unsigned int field_count = result->field_count;
 	int row;
 
-	DBG_ENTER("mysqlnd_free_buffered_data");
+	DBG_ENTER("mysqlnd_res::free_buffered_data");
 	DBG_INF_FMT("Freeing "MYSQLND_LLU_SPEC" row(s)", set->row_count);
 
 	DBG_INF_FMT("before: real_usage=%lu  usage=%lu", zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC));
@@ -208,8 +200,7 @@ void mysqlnd_free_buffered_data(MYSQLND_RES *result TSRMLS_DC)
 			if (current_row[0] == NULL) {
 				break;/* row that was never initialized */
 			}
-			mysqlnd_palloc_zval_ptr_dtor(&(current_row[col]), zval_cache,
-										 result->type, &copy_ctor_called TSRMLS_CC);
+			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=%d", copy_ctor_called);
 #endif
@@ -232,87 +223,6 @@ void mysqlnd_free_buffered_data(MYSQLND_RES *result TSRMLS_DC)
 	}
 	set->data_cursor = NULL;
 	set->row_count	= 0;
-	if (set->qcache) {
-		mysqlnd_qcache_free_cache_reference(&set->qcache);
-	}
-
-	DBG_INF("Freeing set");
-	mnd_pefree(set, set->persistent);
-
-	DBG_INF_FMT("after: real_usage=%lu  usage=%lu", zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC));
-	DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-#ifdef MYSQLND_THREADED
-/* {{{ mysqlnd_free_background_buffered_data */
-void mysqlnd_free_background_buffered_data(MYSQLND_RES *result TSRMLS_DC)
-{
-	MYSQLND_THD_ZVAL_PCACHE  *zval_cache = result->zval_cache;
-	MYSQLND_RES_BG_BUFFERED *set = result->bg_stored_data;
-	unsigned int field_count = result->field_count;
-	int row;
-
-	DBG_ENTER("mysqlnd_free_buffered_data");
-	DBG_INF_FMT("Freeing "MYSQLND_LLU_SPEC" row(s)", set->row_count);
-
-	do {
-		tsrm_mutex_lock(set->LOCK);
-		if (set->bg_fetch_finished) {
-			tsrm_mutex_unlock(set->LOCK);
-			break;
-		}
-		tsrm_mutex_unlock(set->LOCK);
-#if HAVE_USLEEP
-		usleep(2000);
-#else
-		{
-			volatile int i;
-			for (i = 0; i < 1000; i++);
-		}
-#endif
-	} while (1);
-
-	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--) {
-		MYSQLND_MEMORY_POOL_CHUNK *current_buffer = set->row_buffers[row];
-		/* It could be the case that the user fetched no rows - then no set->data */
-		if (row < set->data_size && set->data[row]) {
-			zval **current_row = set->data[row];
-			unsigned int col;
-
-			for (col = 0; col < field_count; col++) {
-				zend_bool copy_ctor_called;
-				mysqlnd_palloc_zval_ptr_dtor(&(current_row[col]), zval_cache,
-											 result->type, &copy_ctor_called TSRMLS_CC);
-#if MYSQLND_DEBUG_MEMORY
-				DBG_INF_FMT("Copy_ctor_called=%d", copy_ctor_called);
-#endif
-				MYSQLND_INC_GLOBAL_STATISTIC(copy_ctor_called? STAT_COPY_ON_WRITE_PERFORMED:
-															   STAT_COPY_ON_WRITE_SAVED);
-			}
-#if MYSQLND_DEBUG_MEMORY
-			DBG_INF("Freeing current_row & current_buffer");
-#endif
-			mnd_pefree(current_row, set->persistent);
-		}
-		current_buffer->free_chunk(current_buffer, TRUE TSRMLS_CC);
-	}
-	DBG_INF("Freeing data & row_buffer");
-	mnd_pefree(set->data, set->persistent);
-	mnd_pefree(set->row_buffers, set->persistent);
-	set->data			= NULL;
-	set->row_buffers	= NULL;
-	set->data_cursor	= NULL;
-	set->row_count	= 0;
-	if (set->qcache) {
-		mysqlnd_qcache_free_cache_reference(&set->qcache);
-	}
-
-	if (set->LOCK) {
-		tsrm_mutex_free(set->LOCK);
-	}
 
 	DBG_INF("Freeing set");
 	mnd_pefree(set, set->persistent);
@@ -321,7 +231,6 @@ void mysqlnd_free_background_buffered_data(MYSQLND_RES *result TSRMLS_DC)
 	DBG_VOID_RETURN;
 }
 /* }}} */
-#endif /* MYSQL_THREADING */
 
 
 /* {{{ mysqlnd_res::free_result_buffers */
@@ -332,19 +241,13 @@ MYSQLND_METHOD(mysqlnd_res, free_result_buffers)(MYSQLND_RES *result TSRMLS_DC)
 	DBG_INF_FMT("%s", result->unbuf? "unbuffered":(result->stored_data? "buffered":"unknown"));
 
 	if (result->unbuf) {
-		mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
+		result->m.unbuffered_free_last_data(result TSRMLS_CC);
 		mnd_efree(result->unbuf);
 		result->unbuf = NULL;
 	} else if (result->stored_data) {
-		mysqlnd_free_buffered_data(result TSRMLS_CC);
+		result->m.free_buffered_data(result TSRMLS_CC);
 		result->stored_data = NULL;
 	}
-#ifdef MYSQLND_THREADED
-	else if (result->bg_stored_data) {
-		mysqlnd_free_background_buffered_data(result TSRMLS_CC);
-		result->bg_stored_data = NULL;	
-	}
-#endif
 
 	if (result->lengths) {
 		mnd_efree(result->lengths);
@@ -357,6 +260,12 @@ MYSQLND_METHOD(mysqlnd_res, free_result_buffers)(MYSQLND_RES *result TSRMLS_DC)
 		result->row_packet = NULL;
 	}
 
+	if (result->result_set_memory_pool) {
+		DBG_INF("Freeing memory pool");
+		mysqlnd_mempool_destroy(result->result_set_memory_pool TSRMLS_CC);
+		result->result_set_memory_pool = NULL;	
+	}
+
 	DBG_VOID_RETURN;
 }
 /* }}} */
@@ -375,12 +284,6 @@ void mysqlnd_internal_free_result_contents(MYSQLND_RES *result TSRMLS_DC)
 		result->meta = NULL;
 	}
 
-	if (result->zval_cache) {
-		DBG_INF("Freeing zval cache reference");
-		mysqlnd_palloc_free_thd_cache_reference(&result->zval_cache);
-		result->zval_cache = NULL;
-	}
-
 	DBG_VOID_RETURN;
 }
 /* }}} */
@@ -451,21 +354,21 @@ enum_func_status
 mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC)
 {
 	enum_func_status ret;
-	php_mysql_packet_rset_header rset_header;
+	MYSQLND_PACKET_RSET_HEADER * rset_header;
 
 	DBG_ENTER("mysqlnd_query_read_result_set_header");
 	DBG_INF_FMT("stmt=%d", stmt? stmt->stmt_id:0);
 
 	ret = FAIL;
-	PACKET_INIT_ALLOCA(rset_header, PROT_RSET_HEADER_PACKET);
+	rset_header = conn->protocol->m.get_rset_header_packet(conn->protocol, FALSE TSRMLS_CC);
 	do {
 		SET_ERROR_AFF_ROWS(conn);
-		if (FAIL == (ret = PACKET_READ_ALLOCA(rset_header, conn))) {
+		if (FAIL == (ret = PACKET_READ(rset_header, conn))) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error reading result set's header");
 			break;
 		}
 
-		if (rset_header.error_info.error_no) {
+		if (rset_header->error_info.error_no) {
 			/*
 			  Cover a protocol design error: error packet does not
 			  contain the server status. Therefore, the client has no way
@@ -480,7 +383,7 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
 			  This will copy the error code and the messages, as they
 			  are buffers in the struct
 			*/
-			conn->error_info = rset_header.error_info;
+			conn->error_info = rset_header->error_info;
 			ret = FAIL;
 			/* Return back from CONN_QUERY_SENT */
 			CONN_SET_STATE(conn, CONN_READY);
@@ -488,27 +391,27 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
 		}
 		conn->error_info.error_no = 0;
 
-		switch (rset_header.field_count) {
+		switch (rset_header->field_count) {
 			case MYSQLND_NULL_LENGTH: {	/* LOAD DATA LOCAL INFILE */
 				zend_bool is_warning;
 				DBG_INF("LOAD DATA");
 				conn->last_query_type = QUERY_LOAD_LOCAL;
 				CONN_SET_STATE(conn, CONN_SENDING_LOAD_DATA);
-				ret = mysqlnd_handle_local_infile(conn, rset_header.info_or_local_file, &is_warning TSRMLS_CC);
+				ret = mysqlnd_handle_local_infile(conn, rset_header->info_or_local_file, &is_warning TSRMLS_CC);
 				CONN_SET_STATE(conn,  (ret == PASS || is_warning == TRUE)? CONN_READY:CONN_QUIT_SENT);
-				MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_NON_RSET_QUERY);
+				MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_NON_RSET_QUERY);
 				break;
 			}
 			case 0:				/* UPSERT */
 				DBG_INF("UPSERT");
 				conn->last_query_type = QUERY_UPSERT;
-				conn->field_count = rset_header.field_count;
-				conn->upsert_status.warning_count = rset_header.warning_count;
-				conn->upsert_status.server_status = rset_header.server_status;
-				conn->upsert_status.affected_rows = rset_header.affected_rows;
-				conn->upsert_status.last_insert_id = rset_header.last_insert_id;
+				conn->field_count = rset_header->field_count;
+				conn->upsert_status.warning_count = rset_header->warning_count;
+				conn->upsert_status.server_status = rset_header->server_status;
+				conn->upsert_status.affected_rows = rset_header->affected_rows;
+				conn->upsert_status.last_insert_id = rset_header->last_insert_id;
 				SET_NEW_MESSAGE(conn->last_message, conn->last_message_len,
-								rset_header.info_or_local_file, rset_header.info_or_local_file_len,
+								rset_header->info_or_local_file, rset_header->info_or_local_file_len,
 								conn->persistent);
 				/* Result set can follow UPSERT statement, check server_status */
 				if (conn->upsert_status.server_status & SERVER_MORE_RESULTS_EXISTS) {
@@ -517,17 +420,17 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
 					CONN_SET_STATE(conn, CONN_READY);
 				}
 				ret = PASS;
-				MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_NON_RSET_QUERY);
+				MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_NON_RSET_QUERY);
 				break;
 			default:{			/* Result set	*/
-				php_mysql_packet_eof fields_eof;
+				MYSQLND_PACKET_EOF * fields_eof;
 				MYSQLND_RES *result;
 				enum_mysqlnd_collected_stats stat = STAT_LAST;
 
 				DBG_INF("Result set pending");
 				SET_EMPTY_MESSAGE(conn->last_message, conn->last_message_len, conn->persistent);
 
-				MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_RSET_QUERY);
+				MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_RSET_QUERY);
 				memset(&conn->upsert_status, 0, sizeof(conn->upsert_status));
 				/* restore after zeroing */
 				SET_ERROR_AFF_ROWS(conn);
@@ -535,13 +438,9 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
 				conn->last_query_type = QUERY_SELECT;
 				CONN_SET_STATE(conn, CONN_FETCHING_DATA);
 				/* PS has already allocated it */
-				conn->field_count = rset_header.field_count;
+				conn->field_count = rset_header->field_count;
 				if (!stmt) {
-					result =
-						conn->current_result=
-							mysqlnd_result_init(rset_header.field_count,
-												mysqlnd_palloc_get_thd_cache_reference(conn->zval_cache)
-												TSRMLS_CC);
+					result = conn->current_result = mysqlnd_result_init(rset_header->field_count TSRMLS_CC);
 				} else {
 					if (!stmt->result) {
 						DBG_INF("This is 'SHOW'/'EXPLAIN'-like query.");
@@ -550,11 +449,7 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
 						  prepared statements can't send result set metadata for these queries
 						  on prepare stage. Read it now.
 						*/
-						result =
-							stmt->result =
-								mysqlnd_result_init(rset_header.field_count,
-													mysqlnd_palloc_get_thd_cache_reference(conn->zval_cache)
-													TSRMLS_CC);
+						result = stmt->result = mysqlnd_result_init(rset_header->field_count TSRMLS_CC);
 					} else {
 						/*
 						  Update result set metadata if it for some reason changed between
@@ -583,8 +478,8 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
 				}
 
 				/* Check for SERVER_STATUS_MORE_RESULTS if needed */
-				PACKET_INIT_ALLOCA(fields_eof, PROT_EOF_PACKET);
-				if (FAIL == (ret = PACKET_READ_ALLOCA(fields_eof, conn))) {
+				fields_eof = conn->protocol->m.get_eof_packet(conn->protocol, FALSE TSRMLS_CC);
+				if (FAIL == (ret = PACKET_READ(fields_eof, conn))) {
 					DBG_ERR("Error ocurred while reading the EOF packet");
 					result->m.free_result_contents(result TSRMLS_CC);
 					mnd_efree(result);
@@ -597,9 +492,9 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
 					}
 				} else {
 					unsigned int to_log = MYSQLND_G(log_mask);
-					to_log &= fields_eof.server_status;
-					DBG_INF_FMT("warnings=%u server_status=%u", fields_eof.warning_count, fields_eof.server_status);
-					conn->upsert_status.warning_count = fields_eof.warning_count;
+					to_log &= fields_eof->server_status;
+					DBG_INF_FMT("warnings=%u server_status=%u", fields_eof->warning_count, fields_eof->server_status);
+					conn->upsert_status.warning_count = fields_eof->warning_count;
 					/*
 					  If SERVER_MORE_RESULTS_EXISTS is set then this is either MULTI_QUERY or a CALL()
 					  The first packet after sending the query/com_execute has the bit set only
@@ -607,12 +502,12 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
 					  will include many result sets. What actually matters are the bits set at the end
 					  of every result set (the EOF packet).
 					*/
-					conn->upsert_status.server_status = fields_eof.server_status;
-					if (fields_eof.server_status & SERVER_QUERY_NO_GOOD_INDEX_USED) {
+					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;
-					} else if (fields_eof.server_status & SERVER_QUERY_NO_INDEX_USED) {
+					} else if (fields_eof->server_status & SERVER_QUERY_NO_INDEX_USED) {
 						stat = STAT_NO_INDEX_USED;
-					} else if (fields_eof.server_status & SERVER_QUERY_WAS_SLOW) {
+					} else if (fields_eof->server_status & SERVER_QUERY_WAS_SLOW) {
 						stat = STAT_QUERY_WAS_SLOW;
 					}
 					if (to_log) {
@@ -621,17 +516,17 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
 						php_log_err(backtrace TSRMLS_CC);
 						efree(backtrace);
 #endif
-						MYSQLND_INC_CONN_STATISTIC(&conn->stats, stat);
 					}
+					MYSQLND_INC_CONN_STATISTIC(conn->stats, stat);
 				}
 
-				PACKET_FREE_ALLOCA(fields_eof);
+				PACKET_FREE(fields_eof);
 
 				break;
 			}
 		}
 	} while (0);
-	PACKET_FREE_ALLOCA(rset_header);
+	PACKET_FREE(rset_header);
 
 	DBG_INF(ret == PASS? "PASS":"FAIL");
 	DBG_RETURN(ret);
@@ -647,7 +542,7 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
   completeness.
 */
 static 
-unsigned long * mysqlnd_fetch_lengths_buffered(MYSQLND_RES * const result)
+unsigned long * mysqlnd_fetch_lengths_buffered(MYSQLND_RES * const result TSRMLS_DC)
 {
 	unsigned int i;
 	zval **previous_row;
@@ -676,48 +571,9 @@ unsigned long * mysqlnd_fetch_lengths_buffered(MYSQLND_RES * const result)
 /* }}} */
 
 
-#ifdef MYSQLND_THREADED
-/* {{{ mysqlnd_fetch_lengths_async_buffered */
-/*
-  Do lazy initialization for buffered results. As PHP strings have
-  length inside, this function makes not much sense in the context
-  of PHP, to be called as separate function. But let's have it for
-  completeness.
-*/
-static 
-unsigned long * mysqlnd_fetch_lengths_async_buffered(MYSQLND_RES * const result)
-{
-	int i;
-	zval **previous_row;
-	MYSQLND_RES_BG_BUFFERED *set = result->bg_stored_data;
-
-	/*
-	  If:
-	  - unbuffered result
-	  - first row has not been read
-	  - last_row has been read
-	*/
-	if (set->data_cursor == NULL ||
-		set->data_cursor == set->data ||
-		((set->data_cursor - set->data) > set->row_count))
-	{
-		return NULL;/* No rows or no more rows */
-	}
-
-	previous_row = *(set->data_cursor - 1);
-	for (i = 0; i < result->meta->field_count; i++) {
-		result->lengths[i] = (Z_TYPE_P(previous_row[i]) == IS_NULL)? 0:Z_STRLEN_P(previous_row[i]);
-	}
-
-	return result->lengths;
-}
-/* }}} */
-#endif
-
-
 /* {{{ mysqlnd_fetch_lengths_unbuffered */
 static
-unsigned long * mysqlnd_fetch_lengths_unbuffered(MYSQLND_RES * const result)
+unsigned long * mysqlnd_fetch_lengths_unbuffered(MYSQLND_RES * const result TSRMLS_DC)
 {
 	return result->lengths;
 }
@@ -725,9 +581,9 @@ unsigned long * mysqlnd_fetch_lengths_unbuffered(MYSQLND_RES * const result)
 
 #if !defined(MYSQLND_USE_OPTIMISATIONS) || MYSQLND_USE_OPTIMISATIONS == 0
 /* {{{ mysqlnd_res::fetch_lengths */
-PHPAPI unsigned long * mysqlnd_fetch_lengths(MYSQLND_RES * const result)
+PHPAPI unsigned long * _mysqlnd_fetch_lengths(MYSQLND_RES * const result TSRMLS_DC)
 {
-	return result->m.fetch_lengths? result->m.fetch_lengths(result):NULL;
+	return result->m.fetch_lengths? result->m.fetch_lengths(result TSRMLS_CC) : NULL;
 }
 /* }}} */
 #endif
@@ -740,7 +596,7 @@ mysqlnd_fetch_row_unbuffered_c(MYSQLND_RES *result TSRMLS_DC)
 	MYSQLND_ROW_C 			retrow = NULL;
 	unsigned int			i,
 							field_count = result->field_count;
-	php_mysql_packet_row	*row_packet = result->row_packet;
+	MYSQLND_PACKET_ROW	*row_packet = result->row_packet;
 	unsigned long			*lengths = result->lengths;
 
 	DBG_ENTER("mysqlnd_fetch_row_unbuffered_c");
@@ -759,19 +615,19 @@ mysqlnd_fetch_row_unbuffered_c(MYSQLND_RES *result TSRMLS_DC)
 
 	/*
 	  If we skip rows (row == NULL) we have to
-	  mysqlnd_unbuffered_free_last_data() before it. The function returns always true.
+	  result->m.unbuffered_free_last_data() before it. The function returns always true.
 	*/
 	if (PASS == (ret = PACKET_READ(row_packet, result->conn)) && !row_packet->eof) {
 		result->unbuf->row_count++;
 
-		mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
+		result->m.unbuffered_free_last_data(result TSRMLS_CC);
 
 		result->unbuf->last_row_data = row_packet->fields;
 		result->unbuf->last_row_buffer = row_packet->row_buffer;
 		row_packet->fields = NULL;
 		row_packet->row_buffer = NULL;
 
-		MYSQLND_INC_CONN_STATISTIC(&result->conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_UNBUF);
+		MYSQLND_INC_CONN_STATISTIC(result->conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_UNBUF);
 
 		if (!row_packet->skip_extraction) {
 			MYSQLND_FIELD *field = result->meta->fields;
@@ -781,7 +637,10 @@ mysqlnd_fetch_row_unbuffered_c(MYSQLND_RES *result TSRMLS_DC)
 								  result->unbuf->last_row_data,
 								  row_packet->field_count,
 								  row_packet->fields_metadata,
-								  result->conn TSRMLS_CC);
+								  FALSE,
+								  result->conn->options.numeric_and_datetime_as_unicode,
+								  result->conn->options.int_and_float_native,
+								  result->conn->stats TSRMLS_CC);
 
 			retrow = mnd_malloc(result->field_count * sizeof(char *));
 
@@ -829,7 +688,7 @@ mysqlnd_fetch_row_unbuffered_c(MYSQLND_RES *result TSRMLS_DC)
 		} else {
 			CONN_SET_STATE(result->conn, CONN_READY);
 		}
-		mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
+		result->m.unbuffered_free_last_data(result TSRMLS_CC);
 	}
 
 	DBG_RETURN(retrow);
@@ -839,12 +698,11 @@ mysqlnd_fetch_row_unbuffered_c(MYSQLND_RES *result TSRMLS_DC)
 
 /* {{{ mysqlnd_fetch_row_unbuffered */
 static enum_func_status
-mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flags,
-							zend_bool *fetched_anything TSRMLS_DC)
+mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flags, zend_bool *fetched_anything TSRMLS_DC)
 {
 	enum_func_status		ret;
 	zval 					*row = (zval *) param;
-	php_mysql_packet_row	*row_packet = result->row_packet;
+	MYSQLND_PACKET_ROW	*row_packet = result->row_packet;
 
 	DBG_ENTER("mysqlnd_fetch_row_unbuffered");
 	DBG_INF_FMT("flags=%d", flags);
@@ -864,13 +722,13 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flag
 
 	/*
 	  If we skip rows (row == NULL) we have to
-	  mysqlnd_unbuffered_free_last_data() before it. The function returns always true.
+	  result->m.unbuffered_free_last_data() before it. The function returns always true.
 	*/
 	if (PASS == (ret = PACKET_READ(row_packet, result->conn)) && !row_packet->eof) {
 		result->unbuf->row_count++;
 		*fetched_anything = TRUE;
 
-		mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
+		result->m.unbuffered_free_last_data(result TSRMLS_CC);
 
 		result->unbuf->last_row_data = row_packet->fields;
 		result->unbuf->last_row_buffer = row_packet->row_buffer;
@@ -878,7 +736,7 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flag
 		row_packet->row_buffer = NULL;
 
 
-		MYSQLND_INC_CONN_STATISTIC(&result->conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_UNBUF);
+		MYSQLND_INC_CONN_STATISTIC(result->conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_UNBUF);
 
 		if (!row_packet->skip_extraction) {
 			HashTable *row_ht = Z_ARRVAL_P(row);
@@ -891,7 +749,10 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flag
 								  result->unbuf->last_row_data,
 								  field_count,
 								  row_packet->fields_metadata,
-								  result->conn TSRMLS_CC);
+								  FALSE,
+								  result->conn->options.numeric_and_datetime_as_unicode,
+								  result->conn->options.int_and_float_native,
+								  result->conn->stats TSRMLS_CC);
 
 			for (i = 0; i < field_count; i++, field++, zend_hash_key++) {
 				zval *data = result->unbuf->last_row_data[i];
@@ -962,7 +823,7 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flag
 		} else {
 			CONN_SET_STATE(result->conn, CONN_READY);
 		}
-		mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
+		result->m.unbuffered_free_last_data(result TSRMLS_CC);
 		*fetched_anything = FALSE;
 	}
 
@@ -996,13 +857,16 @@ MYSQLND_METHOD(mysqlnd_res, use_result)(MYSQLND_RES * const result, zend_bool ps
 	}
 	result->unbuf = mnd_ecalloc(1, sizeof(MYSQLND_RES_UNBUFFERED));
 
+	result->result_set_memory_pool = mysqlnd_mempool_create(16000 TSRMLS_CC);
+
 	/*
 	  Will be freed in the mysqlnd_internal_free_result_contents() called
 	  by the resource destructor. mysqlnd_fetch_row_unbuffered() expects
 	  this to be not NULL.
 	*/
 	/* FALSE = non-persistent */
-	PACKET_INIT(result->row_packet, PROT_ROW_PACKET, php_mysql_packet_row *, FALSE);
+	result->row_packet = result->conn->protocol->m.get_row_packet(result->conn->protocol, FALSE TSRMLS_CC);
+	result->row_packet->result_set_memory_pool = result->result_set_memory_pool;
 	result->row_packet->field_count = result->field_count;
 	result->row_packet->binary_protocol = ps;
 	result->row_packet->fields_metadata = result->meta->fields;
@@ -1039,7 +903,10 @@ mysqlnd_fetch_row_buffered_c(MYSQLND_RES *result TSRMLS_DC)
 								  current_row,
 								  result->meta->field_count,
 								  result->meta->fields,
-								  result->conn TSRMLS_CC);
+								  FALSE,
+								  result->conn->options.numeric_and_datetime_as_unicode,
+								  result->conn->options.int_and_float_native,
+								  result->conn->stats TSRMLS_CC);
 			for (i = 0; i < result->field_count; i++) {
 				/*
 				  NULL fields are 0 length, 0 is not more than 0
@@ -1080,8 +947,7 @@ mysqlnd_fetch_row_buffered_c(MYSQLND_RES *result TSRMLS_DC)
 
 /* {{{ mysqlnd_fetch_row_buffered */
 static enum_func_status
-mysqlnd_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags,
-						   zend_bool *fetched_anything TSRMLS_DC)
+mysqlnd_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags, zend_bool *fetched_anything TSRMLS_DC)
 {
 	unsigned int i;
 	zval *row = (zval *) param;
@@ -1105,7 +971,10 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags,
 								  current_row,
 								  result->meta->field_count,
 								  result->meta->fields,
-								  result->conn TSRMLS_CC);
+								  result->stored_data->persistent,
+								  result->conn->options.numeric_and_datetime_as_unicode,
+								  result->conn->options.int_and_float_native,
+								  result->conn->stats TSRMLS_CC);
 			for (i = 0; i < result->field_count; i++) {
 				/*
 				  NULL fields are 0 length, 0 is not more than 0
@@ -1174,19 +1043,19 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags,
 
 #define STORE_RESULT_PREALLOCATED_SET_IF_NOT_EMPTY 2
 
-/* {{{ mysqlnd_store_result_fetch_data */
+/* {{{ mysqlnd_res::store_result_fetch_data */
 enum_func_status
-mysqlnd_store_result_fetch_data(MYSQLND * const conn, MYSQLND_RES *result,
-								MYSQLND_RES_METADATA *meta,
-								zend_bool binary_protocol,
-								zend_bool to_cache TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND * const conn, MYSQLND_RES *result,
+													MYSQLND_RES_METADATA *meta,
+													zend_bool binary_protocol,
+													zend_bool to_cache TSRMLS_DC)
 {
 	enum_func_status ret;
-	php_mysql_packet_row *row_packet;
+	MYSQLND_PACKET_ROW *row_packet;
 	unsigned int next_extend = STORE_RESULT_PREALLOCATED_SET_IF_NOT_EMPTY, free_rows = 1;
 	MYSQLND_RES_BUFFERED *set;
 
-	DBG_ENTER("mysqlnd_store_result_fetch_data");
+	DBG_ENTER("mysqlnd_res::store_result_fetch_data");
 	DBG_INF_FMT("conn=%llu binary_proto=%d to_cache=%d",
 				conn->thread_id, binary_protocol, to_cache);
 
@@ -1195,14 +1064,14 @@ mysqlnd_store_result_fetch_data(MYSQLND * const conn, MYSQLND_RES *result,
 		set->row_buffers = mnd_pemalloc(free_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), to_cache);
 	}
 	set->persistent	= to_cache;
-	set->qcache		= to_cache? mysqlnd_qcache_get_cache_reference(conn->qcache):NULL;
 	set->references	= 1;
 
 	result->m.row_decoder = binary_protocol? php_mysqlnd_rowp_read_binary_protocol:
 											 php_mysqlnd_rowp_read_text_protocol;
 
 	/* non-persistent */
-	PACKET_INIT(row_packet, PROT_ROW_PACKET, php_mysql_packet_row *, FALSE);
+	row_packet = conn->protocol->m.get_row_packet(conn->protocol, FALSE TSRMLS_CC);
+	row_packet->result_set_memory_pool = result->result_set_memory_pool;
 	row_packet->field_count = meta->field_count;
 	row_packet->binary_protocol = binary_protocol;
 	row_packet->fields_metadata = meta->fields;
@@ -1242,7 +1111,7 @@ mysqlnd_store_result_fetch_data(MYSQLND * const conn, MYSQLND_RES *result,
 		memset(set->data, 0, set->row_count * meta->field_count * sizeof(zval *));
 	}
 
-	MYSQLND_INC_CONN_STATISTIC_W_VALUE(&conn->stats,
+	MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats,
 									   binary_protocol? STAT_ROWS_BUFFERED_FROM_CLIENT_PS:
 														STAT_ROWS_BUFFERED_FROM_CLIENT_NORMAL,
 									   set->row_count);
@@ -1303,10 +1172,10 @@ MYSQLND_METHOD(mysqlnd_res, store_result)(MYSQLND_RES * result,
 
 	CONN_SET_STATE(conn, CONN_FETCHING_DATA);
 
+	result->result_set_memory_pool = mysqlnd_mempool_create(16000 TSRMLS_CC);
 	result->lengths = mnd_ecalloc(result->field_count, sizeof(unsigned long));
 
-	ret = mysqlnd_store_result_fetch_data(conn, result, result->meta,
-										  ps_protocol, to_cache TSRMLS_CC);
+	ret = result->m.store_result_fetch_data(conn, result, result->meta, ps_protocol, to_cache TSRMLS_CC);
 	if (PASS == ret) {
 		/* libmysql's documentation says it should be so for SELECT statements */
 		conn->upsert_status.affected_rows = result->stored_data->row_count;
@@ -1321,322 +1190,6 @@ MYSQLND_METHOD(mysqlnd_res, store_result)(MYSQLND_RES * result,
 /* }}} */
 
 
-#ifdef MYSQLND_THREADED
-/* {{{ mysqlnd_fetch_row_async_buffered */
-static enum_func_status
-mysqlnd_fetch_row_async_buffered(MYSQLND_RES *result, void *param, unsigned int flags,
-								 zend_bool *fetched_anything TSRMLS_DC)
-{
-	zval *row = (zval *) param;
-	MYSQLND_RES_BG_BUFFERED *set = result->bg_stored_data;
-
-	DBG_ENTER("mysqlnd_fetch_row_async_buffered");
-	DBG_INF_FMT("flags=%u row=%p", flags, row);
-
-	do {
-	 	tsrm_mutex_lock(set->LOCK);
-		if (set->bg_fetch_finished == TRUE) {
-			/* Don't unlock here, will be done later */
-			break;
-		}
-		if (!set->data_cursor || (set->data_cursor - set->data) < (set->row_count)) {
- 			tsrm_mutex_unlock(set->LOCK);
-#if HAVE_USLEEP
-			usleep(2000);
-#else
-			volatile int i = 0;
-			for (int i = 0; i < 100; i++);
-#endif
-		} else {
-			break;
-		}
-	} while (1);
-
-	/* At the point we are still under LOCK */
-	if (set->data_cursor && (set->data_cursor - set->data) < (set->row_count)) {
-		uint64_t row_num = set->data_cursor - set->data;
-		zval **current_row = *set->data_cursor++;
-		unsigned int i;
-
-		set->initialized_rows++;
-		/* We don't forget to release the lock */
-		tsrm_mutex_unlock(set->LOCK);
-
-		/* If there was no decoding in background, we have to decode here */
-		if (set->decode_in_foreground == TRUE) {
-			MYSQLND_MEMORY_POOL_CHUNK *current_buffer = set->row_buffers[row_num];
-			result->m.row_decoder(current_buffer,
-								  current_row,
-								  result->meta->field_count,
-								  result->meta->fields,
-								  result->conn TSRMLS_CC);
-
-			for (i = 0; i < result->field_count; i++) {
-				/*
-				  NULL fields are 0 length, 0 is not more than 0
-				  String of zero size, definitely can't be the next max_length.
-				  Thus for NULL and zero-length we are quite efficient.
-				*/
-				if (Z_TYPE_P(current_row[i]) >= IS_STRING) {
-					unsigned long len = Z_STRLEN_P(current_row[i]);
-					if (result->meta->fields[i].max_length < len) {
-						result->meta->fields[i].max_length = len;
-					}
-				}
-			}
-		}
-
-
-		for (i = 0; i < result->field_count; i++) {
-			zval *data = current_row[i];
-
-			/*
-			  Let us later know what to do with this zval. If ref_count > 1, we will just
-			  decrease it, otherwise free it. zval_ptr_dtor() make this very easy job.
-			*/
-			Z_ADDREF_P(data);
-			
-			if ((flags & MYSQLND_FETCH_BOTH) == MYSQLND_FETCH_BOTH) {
-				Z_ADDREF_P(data);
-			}
-			if (flags & MYSQLND_FETCH_NUM) {
-				zend_hash_next_index_insert(Z_ARRVAL_P(row), &data, sizeof(zval *), NULL);
-			}
-			if (flags & MYSQLND_FETCH_ASSOC) {
-				/* zend_hash_quick_update needs length + trailing zero */
-				/* QQ: Error handling ? */
-				/*
-				  zend_hash_quick_update does not check, as add_assoc_zval_ex do, whether
-				  the index is a numeric and convert it to it. This however means constant
-				  hashing of the column name, which is not needed as it can be precomputed.
-				*/
-				if (result->meta->zend_hash_keys[i].is_numeric == FALSE) {
-#if PHP_MAJOR_VERSION >= 6
-					zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,
-											 result->meta->zend_hash_keys[i].ustr,
-											 result->meta->zend_hash_keys[i].ulen + 1,
-											 result->meta->zend_hash_keys[i].key,
-											 (void *) &data, sizeof(zval *), NULL);
-#else
-					zend_hash_quick_update(Z_ARRVAL_P(row),
-										   result->meta->fields[i].name,
-										   result->meta->fields[i].name_length + 1,
-										   result->meta->zend_hash_keys[i].key,
-										   (void *) &data, sizeof(zval *), NULL);
-#endif
-				} else {
-					zend_hash_index_update(Z_ARRVAL_P(row),
-										   result->meta->zend_hash_keys[i].key,
-										   (void *) &data, sizeof(zval *), NULL);
-				}
-			}
-		}
-		*fetched_anything = TRUE;
-		MYSQLND_INC_GLOBAL_STATISTIC(STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_BUF);
-	} else {
-		set->data_cursor = NULL;
-		/* We don't forget to release the lock */
-		tsrm_mutex_unlock(set->LOCK);
-		*fetched_anything = FALSE;
-		DBG_INF("EOF reached");
-	}
-
-	DBG_INF_FMT("ret=PASS fetched=%d", *fetched_anything);
-	DBG_RETURN(PASS);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_background_store_result_fetch_data */
-enum_func_status
-mysqlnd_background_store_result_fetch_data(MYSQLND_RES *result TSRMLS_DC)
-{
-	enum_func_status ret;
-	php_mysql_packet_row *row_packet;
-	unsigned int next_extend = STORE_RESULT_PREALLOCATED_SET_IF_NOT_EMPTY, free_rows;
-	MYSQLND_RES_BG_BUFFERED *set = result->bg_stored_data;
-	MYSQLND *conn = result->conn;
-
-	DBG_ENTER("mysqlnd_background_store_result_fetch_data");
-
-	free_rows = next_extend;
-
-	/* persistent */
-	PACKET_INIT(row_packet, PROT_ROW_PACKET, php_mysql_packet_row *, TRUE);
-	row_packet->field_count = result->meta->field_count;
-	row_packet->binary_protocol = result->m.row_decoder == php_mysqlnd_rowp_read_binary_protocol;
-	row_packet->fields_metadata = result->meta->fields;
-	row_packet->bit_fields_count	= result->meta->bit_fields_count;
-	row_packet->bit_fields_total_len= result->meta->bit_fields_total_len;
-	row_packet->persistent_alloc = TRUE;
-
-	while (FAIL != (ret = PACKET_READ(row_packet, conn)) && !row_packet->eof) {
-		tsrm_mutex_lock(set->LOCK);
-		if (!free_rows) {
-			uint64_t total_rows = free_rows = next_extend = next_extend * 5 / 3; /* extend with 33% */
-			uint64_t old_size;
-			total_rows += set->row_count;
-
-			old_size = set->data_size;
-			set->data_size = total_rows;
-			set->data = mnd_perealloc(set->data, set->data_size * sizeof(zval **), set->persistent);
-#if 0
-			memset(set->data + old_size, 0, (set->data_size - old_size) * sizeof(zval **));
-#endif
-			set->row_buffers = mnd_perealloc(set->row_buffers,
-											 total_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *),
-											 set->persistent);
-		}
-		set->row_buffers[set->row_count] = row_packet->row_buffer;
-		set->data[set->row_count] = row_packet->fields;
-
-		if (set->decode_in_foreground == FALSE) {
-			unsigned int i;
-			result->m.row_decoder(set->row_buffers[set->row_count],
-								  set->data[set->row_count],
-								  result->meta->field_count,
-								  result->meta->fields,
-								  result->conn TSRMLS_CC);
-
-			for (i = 0; i < result->field_count; i++) {
-				/*
-				  NULL fields are 0 length, 0 is not more than 0
-				  String of zero size, definitely can't be the next max_length.
-				  Thus for NULL and zero-length we are quite efficient.
-				*/
-				if (Z_TYPE_P(set->data[set->row_count][i]) >= IS_STRING) {
-					unsigned long len = Z_STRLEN_P(set->data[set->row_count][i]);
-					if (result->meta->fields[i].max_length < len) {
-						result->meta->fields[i].max_length = len;
-					}
-				}
-			}
-		}
-		set->row_count++;
-
-	 	tsrm_mutex_unlock(set->LOCK);
-		free_rows--;
-
-		/* So row_packet's destructor function won't efree() it */
-		row_packet->row_buffer = NULL;
-		row_packet->fields = NULL;
-
-		/*
-		  No need to FREE_ALLOCA as we can reuse the
-		  'lengths' and 'fields' arrays. For lengths its absolutely safe.
-		  'fields' is reused because the ownership of the strings has been
-		  transfered above. 
-		*/
-	}
-#if 0
-	MYSQLND_INC_CONN_STATISTIC_W_VALUE(&conn->stats,
-									   binary_protocol? STAT_ROWS_BUFFERED_FROM_CLIENT_PS:
-														STAT_ROWS_BUFFERED_FROM_CLIENT_NORMAL,
-									   set->row_count);
-#endif
-	tsrm_mutex_lock(set->LOCK);
-	/* Finally clean */
-	if (row_packet->eof) {
-		set->upsert_status.warning_count = row_packet->warning_count;
-		set->upsert_status.server_status = row_packet->server_status;
-	}
-	/* save some memory */
-	if (free_rows) {
-		set->data_size = set->row_count;
-		set->data = mnd_perealloc(set->data,
-								 (size_t) set->data_size * sizeof(zval **), set->persistent);
-		set->row_buffers = mnd_perealloc(set->row_buffers,
-										 set->row_count * sizeof(MYSQLND_MEMORY_POOL_CHUNK *),
-										 set->persistent);
-	}
-	if (ret == FAIL) {
-		set->error_info = row_packet->error_info;
-	} else {
-		/* Position at the first row */
-		set->data_cursor = set->data;	
-
-		/* libmysql's documentation says it should be so for SELECT statements */
-		conn->upsert_status.affected_rows = set->row_count;
-		set->upsert_status.affected_rows = set->row_count;
-	}
-	set->bg_fetch_finished = TRUE;
-	tsrm_mutex_unlock(set->LOCK);
-
-	PACKET_FREE(row_packet);
-
-	if (conn->upsert_status.server_status & SERVER_MORE_RESULTS_EXISTS) {
-		CONN_SET_STATE(conn, CONN_NEXT_RESULT_PENDING);
-	} else {
-		CONN_SET_STATE(conn, CONN_READY);
-	}
-	DBG_INF_FMT("ret=%s row_count=%u warnings=%u server_status=%u", ret == PASS? "PASS":"FAIL",
-				set->row_count, conn->upsert_status.warning_count, conn->upsert_status.server_status);
-	DBG_RETURN(ret);
-}
-/* }}} */
-#endif
-
-
-/* {{{ mysqlnd_res::background_store_result */
-static MYSQLND_RES *
-MYSQLND_METHOD(mysqlnd_res, background_store_result)(MYSQLND_RES * result, MYSQLND * const conn, zend_bool ps TSRMLS_DC)
-{
-#ifndef MYSQLND_THREADED
-	return (result->m.store_result(result, conn, ps TSRMLS_CC));
-#else
-	enum_func_status ret;
-	zend_bool to_cache = TRUE;
-
-	DBG_ENTER("mysqlnd_res::background_store_result");
-	DBG_INF_FMT("conn=%d ps_protocol=%d", conn->thread_id, ps);
-
-	/* We need the conn because we are doing lazy zval initialization in buffered_fetch_row */
-	result->conn 			= conn->m->get_reference(conn TSRMLS_CC);
-	result->type			= MYSQLND_RES_NORMAL;
-	result->m.fetch_row		= mysqlnd_fetch_row_async_buffered;
-	result->m.fetch_lengths	= mysqlnd_fetch_lengths_async_buffered;
-
-	result->bg_stored_data = mnd_pecalloc(1, sizeof(MYSQLND_RES_BG_BUFFERED), to_cache);
-	result->bg_stored_data->data_size	= STORE_RESULT_PREALLOCATED_SET_IF_NOT_EMPTY;
-	result->bg_stored_data->data		= mnd_pecalloc(result->bg_stored_data->data_size, sizeof(zval **), to_cache);
-	result->bg_stored_data->row_buffers	= mnd_pemalloc(STORE_RESULT_PREALLOCATED_SET_IF_NOT_EMPTY * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), to_cache);
-	result->bg_stored_data->persistent	= to_cache;
-	result->bg_stored_data->qcache		= to_cache? mysqlnd_qcache_get_cache_reference(conn->qcache):NULL;
-	result->bg_stored_data->references	= 1;
-
-	result->bg_stored_data->LOCK = tsrm_mutex_alloc();
-
-	result->m.row_decoder = ps? php_mysqlnd_rowp_read_binary_protocol:
-								php_mysqlnd_rowp_read_text_protocol;
-
-	CONN_SET_STATE(conn, CONN_FETCHING_DATA);
-	/*
-	  This should be definitely TRUE. Decoding in background means creating zvals
-	  which is not very safe for Zend MM, will complain in debug mode and more problems
-	  also manifest themselves - unstable.
-	*/
-	result->bg_stored_data->decode_in_foreground = TRUE;
-
-	result->lengths = mnd_ecalloc(result->field_count, sizeof(unsigned long));
-
-	pthread_mutex_lock(&conn->LOCK_work);
-
-	pthread_cond_signal(&conn->COND_work);
-	do {
-		pthread_cond_wait(&conn->COND_work, &conn->LOCK_work);
-	} while (conn->current_result); /* this is our invariant */
-	pthread_mutex_unlock(&conn->LOCK_work);
-
-#if 0
-	ret = mysqlnd_background_store_result_fetch_data(result TSRMLS_CC);
-#endif
-
-	DBG_RETURN(result);
-#endif
-}
-/* }}} */
-
-
 /* {{{ mysqlnd_res::skip_result */
 static enum_func_status
 MYSQLND_METHOD(mysqlnd_res, skip_result)(MYSQLND_RES * const result TSRMLS_DC)
@@ -1654,7 +1207,7 @@ MYSQLND_METHOD(mysqlnd_res, skip_result)(MYSQLND_RES * const result TSRMLS_DC)
 	{
 		DBG_INF("skipping result");
 		/* We have to fetch all data to clean the line */
-		MYSQLND_INC_CONN_STATISTIC(&result->conn->stats,
+		MYSQLND_INC_CONN_STATISTIC(result->conn->stats,
 									result->type == MYSQLND_RES_NORMAL? STAT_FLUSHED_NORMAL_SETS:
 																		STAT_FLUSHED_PS_SETS);
 
@@ -1677,7 +1230,7 @@ MYSQLND_METHOD(mysqlnd_res, free_result)(MYSQLND_RES *result, zend_bool implicit
 	DBG_INF_FMT("implicit=%d", implicit);
 
 	result->m.skip_result(result TSRMLS_CC);
-	MYSQLND_INC_CONN_STATISTIC(result->conn? &result->conn->stats : NULL,
+	MYSQLND_INC_CONN_STATISTIC(result->conn? result->conn->stats : NULL,
 							   implicit == TRUE?	STAT_FREE_RESULT_IMPLICIT:
 							   						STAT_FREE_RESULT_EXPLICIT);
 
@@ -1712,7 +1265,7 @@ MYSQLND_METHOD(mysqlnd_res, data_seek)(MYSQLND_RES *result, uint64_t row TSRMLS_
 
 /* {{{ mysqlnd_res::num_rows */
 static uint64_t
-MYSQLND_METHOD(mysqlnd_res, num_rows)(const MYSQLND_RES * const result)
+MYSQLND_METHOD(mysqlnd_res, num_rows)(const MYSQLND_RES * const result TSRMLS_DC)
 {
 	/* Be compatible with libmysql. We count row_count, but will return 0 */
 	return result->stored_data? result->stored_data->row_count:0;
@@ -1722,7 +1275,7 @@ MYSQLND_METHOD(mysqlnd_res, num_rows)(const MYSQLND_RES * const result)
 
 /* {{{ mysqlnd_res::num_fields */
 static unsigned int
-MYSQLND_METHOD(mysqlnd_res, num_fields)(const MYSQLND_RES * const result)
+MYSQLND_METHOD(mysqlnd_res, num_fields)(const MYSQLND_RES * const result TSRMLS_DC)
 {
 	return result->field_count;
 }
@@ -1748,7 +1301,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_field)(MYSQLND_RES * const result TSRMLS_DC)
 		if (result->stored_data && (result->stored_data->initialized_rows < result->stored_data->row_count)) {
 			DBG_INF_FMT("We have decode the whole result set to be able to satisfy this meta request");
 			/* we have to initialize the rest to get the updated max length */
-			mysqlnd_res_initialize_result_set_rest(result TSRMLS_CC);
+			result->m.initialize_result_set_rest(result TSRMLS_CC);
 		}
 		DBG_RETURN(result->meta->m->fetch_field(result->meta TSRMLS_CC));
 	}
@@ -1759,8 +1312,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_field)(MYSQLND_RES * const result TSRMLS_DC)
 
 /* {{{ mysqlnd_res::fetch_field_direct */
 static const MYSQLND_FIELD *
-MYSQLND_METHOD(mysqlnd_res, fetch_field_direct)(MYSQLND_RES * const result,
-												MYSQLND_FIELD_OFFSET fieldnr TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_res, fetch_field_direct)(MYSQLND_RES * const result, MYSQLND_FIELD_OFFSET fieldnr TSRMLS_DC)
 {
 	DBG_ENTER("mysqlnd_res::fetch_field_direct");
 	if (result->meta) {
@@ -1777,7 +1329,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_field_direct)(MYSQLND_RES * const result,
 		if (result->stored_data && (result->stored_data->initialized_rows < result->stored_data->row_count)) {
 			DBG_INF_FMT("We have decode the whole result set to be able to satisfy this meta request");
 			/* we have to initialized the rest to get the updated max length */
-			mysqlnd_res_initialize_result_set_rest(result TSRMLS_CC);
+			result->m.initialize_result_set_rest(result TSRMLS_CC);
 		}
 		DBG_RETURN(result->meta->m->fetch_field_direct(result->meta, fieldnr TSRMLS_CC));
 	}
@@ -1795,7 +1347,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_fields)(MYSQLND_RES * const result TSRMLS_DC)
 	if (result->meta) {
 		if (result->stored_data && (result->stored_data->initialized_rows < result->stored_data->row_count)) {
 			/* we have to initialize the rest to get the updated max length */
-			mysqlnd_res_initialize_result_set_rest(result TSRMLS_CC);
+			result->m.initialize_result_set_rest(result TSRMLS_CC);
 		}
 		DBG_RETURN(result->meta->m->fetch_fields(result->meta TSRMLS_CC));
 	}
@@ -1807,8 +1359,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_fields)(MYSQLND_RES * const result TSRMLS_DC)
 
 /* {{{ mysqlnd_res::field_seek */
 static MYSQLND_FIELD_OFFSET
-MYSQLND_METHOD(mysqlnd_res, field_seek)(MYSQLND_RES * const result,
-										MYSQLND_FIELD_OFFSET field_offset)
+MYSQLND_METHOD(mysqlnd_res, field_seek)(MYSQLND_RES * const result, MYSQLND_FIELD_OFFSET field_offset TSRMLS_DC)
 {
 	MYSQLND_FIELD_OFFSET return_value = 0;
 	if (result->meta) {
@@ -1822,9 +1373,9 @@ MYSQLND_METHOD(mysqlnd_res, field_seek)(MYSQLND_RES * const result,
 
 /* {{{ mysqlnd_res::field_tell */
 static MYSQLND_FIELD_OFFSET
-MYSQLND_METHOD(mysqlnd_res, field_tell)(const MYSQLND_RES * const result)
+MYSQLND_METHOD(mysqlnd_res, field_tell)(const MYSQLND_RES * const result TSRMLS_DC)
 {
-	return result->meta? result->meta->m->field_tell(result->meta):0;
+	return result->meta? result->meta->m->field_tell(result->meta TSRMLS_CC) : 0;
 }
 /* }}} */
 
@@ -1896,8 +1447,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_row_c)(MYSQLND_RES *result TSRMLS_DC)
 
 /* {{{ mysqlnd_res::fetch_all */
 static void
-MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES *result, unsigned int flags,
-									   zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC)
+MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES *result, unsigned int flags, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC)
 {
 	zval  *row;
 	ulong i = 0;
@@ -1932,8 +1482,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES *result, unsigned int flags,
 
 /* {{{ mysqlnd_res::fetch_field_data */
 static void
-MYSQLND_METHOD(mysqlnd_res, fetch_field_data)(MYSQLND_RES *result, unsigned int offset,
-											  zval *return_value TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_res, fetch_field_data)(MYSQLND_RES *result, unsigned int offset, zval *return_value TSRMLS_DC)
 {
 	zval row;
 	zval **entry;
@@ -1976,19 +1525,19 @@ MYSQLND_METHOD(mysqlnd_res, fetch_field_data)(MYSQLND_RES *result, unsigned int
 
 
 /* {{{ mysqlnd_result_init */
-MYSQLND_RES *mysqlnd_result_init(unsigned int field_count, MYSQLND_THD_ZVAL_PCACHE *cache TSRMLS_DC)
+PHPAPI MYSQLND_RES *
+mysqlnd_result_init(unsigned int field_count TSRMLS_DC)
 {
-	MYSQLND_RES *ret = mnd_ecalloc(1, sizeof(MYSQLND_RES));
+	size_t alloc_size = sizeof(MYSQLND_RES) + mysqlnd_plugin_count() * sizeof(void *);
+	MYSQLND_RES *ret = mnd_ecalloc(1, alloc_size);
 
 	DBG_ENTER("mysqlnd_result_init");
-	DBG_INF_FMT("field_count=%u cache=%p", field_count, cache);
+	DBG_INF_FMT("field_count=%u", field_count);
 
 	ret->field_count	= field_count;
-	ret->zval_cache		= cache;
 
 	ret->m.use_result	= MYSQLND_METHOD(mysqlnd_res, use_result);
 	ret->m.store_result	= MYSQLND_METHOD(mysqlnd_res, store_result);
-	ret->m.background_store_result	= MYSQLND_METHOD(mysqlnd_res, background_store_result);
 	ret->m.free_result	= MYSQLND_METHOD(mysqlnd_res, free_result);
 	ret->m.seek_data	= MYSQLND_METHOD(mysqlnd_res, data_seek);
 	ret->m.num_rows		= MYSQLND_METHOD(mysqlnd_res, num_rows);
@@ -2007,8 +1556,13 @@ MYSQLND_RES *mysqlnd_result_init(unsigned int field_count, MYSQLND_THD_ZVAL_PCAC
 	ret->m.free_result_buffers	= MYSQLND_METHOD(mysqlnd_res, free_result_buffers);
 	ret->m.free_result_internal = mysqlnd_internal_free_result;
 	ret->m.free_result_contents = mysqlnd_internal_free_result_contents;
+	ret->m.free_buffered_data = MYSQLND_METHOD(mysqlnd_res, free_buffered_data);
+	ret->m.unbuffered_free_last_data = MYSQLND_METHOD(mysqlnd_res, unbuffered_free_last_data);
 
 	ret->m.read_result_metadata = MYSQLND_METHOD(mysqlnd_res, read_result_metadata);
+	ret->m.store_result_fetch_data = MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data);
+	ret->m.initialize_result_set_rest = MYSQLND_METHOD(mysqlnd_res, initialize_result_set_rest);
+
 	ret->m.fetch_row_normal_buffered	= mysqlnd_fetch_row_buffered;
 	ret->m.fetch_row_normal_unbuffered	= mysqlnd_fetch_row_unbuffered;
 	ret->m.row_decoder = NULL;
@@ -2017,6 +1571,19 @@ MYSQLND_RES *mysqlnd_result_init(unsigned int field_count, MYSQLND_THD_ZVAL_PCAC
 }
 /* }}} */
 
+
+/* {{{ _mysqlnd_plugin_get_plugin_result_data */
+PHPAPI void ** _mysqlnd_plugin_get_plugin_result_data(const MYSQLND_RES * result, unsigned int plugin_id TSRMLS_DC)
+{
+	DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data");
+	DBG_INF_FMT("plugin_id=%u", plugin_id);
+	if (!result || plugin_id >= mysqlnd_plugin_count()) {
+		return NULL;
+	}
+	DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES) + plugin_id * sizeof(void *)));
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
diff --git a/ext/mysqlnd/mysqlnd_result.h b/ext/mysqlnd/mysqlnd_result.h
index 1f7a249..0ed188d 100644
--- a/ext/mysqlnd/mysqlnd_result.h
+++ b/ext/mysqlnd/mysqlnd_result.h
@@ -18,31 +18,15 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: mysqlnd_result.h 293779 2010-01-20 17:09:28Z johannes $ */
 
 #ifndef MYSQLND_RESULT_H
 #define MYSQLND_RESULT_H
 
-MYSQLND_RES *mysqlnd_result_init(unsigned int field_count, MYSQLND_THD_ZVAL_PCACHE *cache TSRMLS_DC);
-
-void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC);
-
-enum_func_status
-mysqlnd_store_result_fetch_data(MYSQLND * const conn, MYSQLND_RES *result,
-								MYSQLND_RES_METADATA *meta,
-								zend_bool binary_protocol,
-								zend_bool to_cache TSRMLS_DC);
+PHPAPI MYSQLND_RES * mysqlnd_result_init(unsigned int field_count TSRMLS_DC);
 
 enum_func_status mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC);
 
-void mysqlnd_res_initialize_result_set_rest(MYSQLND_RES * const result TSRMLS_DC);
-
-
-#ifdef MYSQLND_THREADED
-void * mysqlnd_fetch_thread(void *arg);
-#endif
-
-enum_func_status mysqlnd_background_store_result_fetch_data(MYSQLND_RES *result TSRMLS_DC);
 #endif /* MYSQLND_RESULT_H */
 
 /*
diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c
index 8a8787f..108b839 100644
--- a/ext/mysqlnd/mysqlnd_result_meta.c
+++ b/ext/mysqlnd/mysqlnd_result_meta.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result_meta.c 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysqlnd_result_meta.c 294543 2010-02-04 20:28:55Z johannes $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_priv.h"
@@ -138,11 +138,10 @@ zend_bool mysqlnd_unicode_is_key_numeric(UChar *key, size_t length, long *idx)
 
 /* {{{ mysqlnd_res_meta::read_metadata */
 static enum_func_status
-MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const meta,
-												MYSQLND *conn TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const meta, MYSQLND *conn TSRMLS_DC)
 {
 	unsigned int i = 0;
-	php_mysql_packet_res_field field_packet;
+	MYSQLND_PACKET_RES_FIELD * field_packet;
 #if PHP_MAJOR_VERSION >= 6
 	UChar *ustr;
 	int ulen;
@@ -150,7 +149,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
 
 	DBG_ENTER("mysqlnd_res_meta::read_metadata");
 
-	PACKET_INIT_ALLOCA(field_packet, PROT_RSET_FLD_PACKET);
+	field_packet = conn->protocol->m.get_result_field_packet(conn->protocol, FALSE TSRMLS_CC);
 	for (;i < meta->field_count; i++) {
 		long idx;
 
@@ -160,19 +159,19 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
 			meta->fields[i].root = NULL;
 		}
 
-		field_packet.metadata = &(meta->fields[i]);
-		if (FAIL == PACKET_READ_ALLOCA(field_packet, conn)) {
-			PACKET_FREE_ALLOCA(field_packet);
+		field_packet->metadata = &(meta->fields[i]);
+		if (FAIL == PACKET_READ(field_packet, conn)) {
+			PACKET_FREE(field_packet);
 			DBG_RETURN(FAIL);
 		}
-		if (field_packet.error_info.error_no) {
-			conn->error_info = field_packet.error_info;
+		if (field_packet->error_info.error_no) {
+			conn->error_info = field_packet->error_info;
 			/* Return back from CONN_QUERY_SENT */
-			PACKET_FREE_ALLOCA(field_packet);
+			PACKET_FREE(field_packet);
 			DBG_RETURN(FAIL);
 		}
 		
-		if (field_packet.stupid_list_fields_eof == TRUE) {
+		if (field_packet->stupid_list_fields_eof == TRUE) {
 			meta->field_count = i;
 			break;
 		}
@@ -184,7 +183,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
 							 "Unknown type %d sent by the server. "
 							 "Please send a report to the developers",
 							 meta->fields[i].type);
-			PACKET_FREE_ALLOCA(field_packet);
+			PACKET_FREE(field_packet);
 			DBG_RETURN(FAIL);
 		}
 		if (meta->fields[i].type == MYSQL_TYPE_BIT) {
@@ -240,19 +239,19 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
 #else
 		/* For BC we have to check whether the key is numeric and use it like this */
 		if ((meta->zend_hash_keys[i].is_numeric =
-					mysqlnd_is_key_numeric(field_packet.metadata->name,
-										   field_packet.metadata->name_length + 1,
+					mysqlnd_is_key_numeric(field_packet->metadata->name,
+										   field_packet->metadata->name_length + 1,
 										   &idx)))
 		{
 			meta->zend_hash_keys[i].key = idx;
 		} else {
 			meta->zend_hash_keys[i].key =
-					zend_get_hash_value(field_packet.metadata->name,
-										field_packet.metadata->name_length + 1);
+					zend_get_hash_value(field_packet->metadata->name,
+										field_packet->metadata->name_length + 1);
 		}
 #endif
 	}
-	PACKET_FREE_ALLOCA(field_packet);
+	PACKET_FREE(field_packet);
 
 	DBG_RETURN(PASS);
 }
@@ -303,8 +302,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, free)(MYSQLND_RES_METADATA *meta, zend_bool per
 
 /* {{{ mysqlnd_res::clone_metadata */
 static MYSQLND_RES_METADATA *
-MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * const meta,
-												 zend_bool persistent TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * const meta, zend_bool persistent TSRMLS_DC)
 {
 	unsigned int i;
 	/* +1 is to have empty marker at the end */
@@ -393,8 +391,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, fetch_field)(MYSQLND_RES_METADATA * const meta
 
 /* {{{ mysqlnd_res_meta::fetch_field_direct */
 static const MYSQLND_FIELD *
-MYSQLND_METHOD(mysqlnd_res_meta, fetch_field_direct)(const MYSQLND_RES_METADATA * const meta,
-													 MYSQLND_FIELD_OFFSET fieldnr TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_res_meta, fetch_field_direct)(const MYSQLND_RES_METADATA * const meta, MYSQLND_FIELD_OFFSET fieldnr TSRMLS_DC)
 {
 	DBG_ENTER("mysqlnd_res_meta::fetch_field_direct");
 	DBG_INF_FMT("fieldnr=%d", fieldnr);
@@ -418,7 +415,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, fetch_fields)(MYSQLND_RES_METADATA * const meta
 
 /* {{{ mysqlnd_res_meta::field_tell */
 static MYSQLND_FIELD_OFFSET
-MYSQLND_METHOD(mysqlnd_res_meta, field_tell)(const MYSQLND_RES_METADATA * const meta)
+MYSQLND_METHOD(mysqlnd_res_meta, field_tell)(const MYSQLND_RES_METADATA * const meta TSRMLS_DC)
 {
 	return meta->current_field;
 }
@@ -437,7 +434,7 @@ MYSQLND_CLASS_METHODS_END;
 
 
 /* {{{ mysqlnd_result_meta_init */
-MYSQLND_RES_METADATA *
+PHPAPI MYSQLND_RES_METADATA *
 mysqlnd_result_meta_init(unsigned int field_count TSRMLS_DC)
 {
 	MYSQLND_RES_METADATA *ret;
diff --git a/ext/mysqlnd/mysqlnd_result_meta.h b/ext/mysqlnd/mysqlnd_result_meta.h
index d4da967..6a3d916 100644
--- a/ext/mysqlnd/mysqlnd_result_meta.h
+++ b/ext/mysqlnd/mysqlnd_result_meta.h
@@ -18,13 +18,13 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result_meta.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: mysqlnd_result_meta.h 293779 2010-01-20 17:09:28Z johannes $ */
 
 #ifndef MYSQLND_RESULT_META_H
 #define MYSQLND_RESULT_META_H
 
 
-MYSQLND_RES_METADATA *mysqlnd_result_meta_init(unsigned int field_count TSRMLS_DC);
+PHPAPI MYSQLND_RES_METADATA * mysqlnd_result_meta_init(unsigned int field_count TSRMLS_DC);
 
 
 
diff --git a/ext/mysqlnd/mysqlnd_statistics.c b/ext/mysqlnd/mysqlnd_statistics.c
index 6126141..1fa8d14 100644
--- a/ext/mysqlnd/mysqlnd_statistics.c
+++ b/ext/mysqlnd/mysqlnd_statistics.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_statistics.c 287807 2009-08-27 13:16:39Z andrey $ */
+/* $Id: mysqlnd_statistics.c 293779 2010-01-20 17:09:28Z johannes $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_priv.h"
@@ -76,6 +76,8 @@ const MYSQLND_STRING mysqlnd_stats_values_names[STAT_LAST] =
 	{ STR_W_LEN("rows_fetched_from_client_ps_buffered") },
 	{ STR_W_LEN("rows_fetched_from_client_ps_unbuffered") },
 	{ STR_W_LEN("rows_fetched_from_client_ps_cursor") },
+	{ STR_W_LEN("rows_affected_normal") },
+	{ STR_W_LEN("rows_affected_ps") },
 	{ STR_W_LEN("rows_skipped_normal") },
 	{ STR_W_LEN("rows_skipped_ps") },
 	{ STR_W_LEN("copy_on_write_saved") },
@@ -153,19 +155,48 @@ const MYSQLND_STRING mysqlnd_stats_values_names[STAT_LAST] =
 	{ STR_W_LEN("proto_binary_fetched_geometry") },
 	{ STR_W_LEN("proto_binary_fetched_other") },
 	{ STR_W_LEN("init_command_executed_count") },
-	{ STR_W_LEN("init_command_failed_count") }	
+	{ STR_W_LEN("init_command_failed_count") },
+	{ STR_W_LEN("com_quit") },
+	{ STR_W_LEN("com_init_db") },
+	{ STR_W_LEN("com_query") },
+	{ STR_W_LEN("com_field_list") },
+	{ STR_W_LEN("com_create_db") },
+	{ STR_W_LEN("com_drop_db") },
+	{ STR_W_LEN("com_refresh") },
+	{ STR_W_LEN("com_shutdown") },
+	{ STR_W_LEN("com_statistics") },
+	{ STR_W_LEN("com_process_info") },
+	{ STR_W_LEN("com_connect") },
+	{ STR_W_LEN("com_process_kill") },
+	{ STR_W_LEN("com_debug") },
+	{ STR_W_LEN("com_ping") },
+	{ STR_W_LEN("com_time") },
+	{ STR_W_LEN("com_delayed_insert") },
+	{ STR_W_LEN("com_change_user") },
+	{ STR_W_LEN("com_binlog_dump") },
+	{ STR_W_LEN("com_table_dump") },
+	{ STR_W_LEN("com_connect_out") },
+	{ STR_W_LEN("com_register_slave") },
+	{ STR_W_LEN("com_stmt_prepare") },
+	{ STR_W_LEN("com_stmt_execute") },
+	{ STR_W_LEN("com_stmt_send_long_data") },
+	{ STR_W_LEN("com_stmt_close") },
+	{ STR_W_LEN("com_stmt_reset") },
+	{ STR_W_LEN("com_stmt_set_option") },
+	{ STR_W_LEN("com_stmt_fetch") },
+	{ STR_W_LEN("com_deamon") }
 };
 /* }}} */
 
 
 /* {{{ mysqlnd_fill_stats_hash */
-void
-mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC)
+PHPAPI void
+mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, const MYSQLND_STRING * names, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC)
 {
 	unsigned int i;
 
-	mysqlnd_array_init(return_value, STAT_LAST);
-	for (i = 0; i < STAT_LAST; i++) {
+	mysqlnd_array_init(return_value, stats->count);
+	for (i = 0; i < stats->count; i++) {
 #if PHP_MAJOR_VERSION >= 6
 		UChar *ustr, *tstr;
 		int ulen, tlen;
@@ -174,15 +205,13 @@ mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, zval *return_value TS
 		
 		sprintf((char *)&tmp, MYSQLND_LLU_SPEC, stats->values[i]);
 #if PHP_MAJOR_VERSION >= 6
-		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, mysqlnd_stats_values_names[i].s,
-								mysqlnd_stats_values_names[i].l + 1 TSRMLS_CC);
+		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, names[i].s, names[i].l + 1 TSRMLS_CC);
 		zend_string_to_unicode(UG(utf8_conv), &tstr, &tlen, tmp, strlen(tmp) + 1 TSRMLS_CC);
 		add_u_assoc_unicode_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen, tstr, 1);
 		efree(ustr);
 		efree(tstr);
 #else
-		add_assoc_string_ex(return_value, mysqlnd_stats_values_names[i].s,
-							mysqlnd_stats_values_names[i].l + 1, tmp, 1);
+		add_assoc_string_ex(return_value, names[i].s, names[i].l + 1, tmp, 1);
 #endif
 	}
 }
@@ -198,17 +227,21 @@ PHPAPI void _mysqlnd_get_client_stats(zval *return_value TSRMLS_DC ZEND_FILE_LIN
 		memset(&stats, 0, sizeof(stats));
 		stats_ptr = &stats;
 	}
-	mysqlnd_fill_stats_hash(stats_ptr, return_value TSRMLS_CC ZEND_FILE_LINE_CC);
+	mysqlnd_fill_stats_hash(stats_ptr, mysqlnd_stats_values_names, return_value TSRMLS_CC ZEND_FILE_LINE_CC);
 	DBG_VOID_RETURN;
 }
 /* }}} */
 
 
 /* {{{ mysqlnd_stats_init */
-void
-mysqlnd_stats_init(MYSQLND_STATS ** stats)
+PHPAPI void
+mysqlnd_stats_init(MYSQLND_STATS ** stats, size_t statistic_count)
 {
 	*stats = calloc(1, sizeof(MYSQLND_STATS));
+	(*stats)->values = calloc(statistic_count, sizeof(uint64_t));
+	(*stats)->triggers = calloc(statistic_count, sizeof(mysqlnd_stat_trigger));
+	(*stats)->in_trigger = FALSE;
+	(*stats)->count = statistic_count;
 #ifdef ZTS
 	(*stats)->LOCK_access = tsrm_mutex_alloc();
 #endif
@@ -218,18 +251,53 @@ mysqlnd_stats_init(MYSQLND_STATS ** stats)
 
 
 /* {{{ mysqlnd_stats_end */
-void
+PHPAPI void
 mysqlnd_stats_end(MYSQLND_STATS * stats)
 {
 #ifdef ZTS
 	tsrm_mutex_free(stats->LOCK_access);
 #endif
+	free(stats->triggers);
+	free(stats->values);
 	/* mnd_free will reference LOCK_access and crash...*/
 	free(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_stat_trigger ret = NULL;
+	DBG_ENTER("mysqlnd_stats_set_trigger");
+	if (stats) {
+		MYSQLND_STATS_LOCK(stats);
+		ret = stats->triggers[stat];
+		stats->triggers[stat] = trigger;
+		MYSQLND_STATS_UNLOCK(stats);
+	}
+	DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_stats_set_handler */
+PHPAPI mysqlnd_stat_trigger
+mysqlnd_stats_reset_triggers(MYSQLND_STATS * const stats TSRMLS_DC)
+{
+	mysqlnd_stat_trigger ret = NULL;
+	DBG_ENTER("mysqlnd_stats_reset_trigger");
+	if (stats) {
+		MYSQLND_STATS_LOCK(stats);
+		memset(stats->triggers, 0, stats->count * sizeof(mysqlnd_stat_trigger));
+		MYSQLND_STATS_UNLOCK(stats);
+	}
+	DBG_RETURN(ret);
+}
+/* }}} */
+
+
 /*
  * Local variables:
  * tab-width: 4
diff --git a/ext/mysqlnd/mysqlnd_statistics.h b/ext/mysqlnd/mysqlnd_statistics.h
index 184d0e3..a3281b4 100644
--- a/ext/mysqlnd/mysqlnd_statistics.h
+++ b/ext/mysqlnd/mysqlnd_statistics.h
@@ -18,13 +18,13 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_statistics.h 282029 2009-06-12 13:24:57Z andrey $ */
+/* $Id: mysqlnd_statistics.h 294543 2010-02-04 20:28:55Z johannes $ */
 
 #ifndef MYSQLND_STATISTICS_H
 #define MYSQLND_STATISTICS_H
 
 
-extern MYSQLND_STATS *mysqlnd_global_stats;
+PHPAPI extern MYSQLND_STATS * mysqlnd_global_stats;
 
 typedef struct st_mysqlnd_string
 {
@@ -35,243 +35,121 @@ typedef struct st_mysqlnd_string
 extern const MYSQLND_STRING mysqlnd_stats_values_names[];
 
 #ifdef ZTS
+#define MYSQLND_STATS_LOCK(stats) tsrm_mutex_lock((stats)->LOCK_access)
+#define MYSQLND_STATS_UNLOCK(stats) tsrm_mutex_unlock((stats)->LOCK_access)
+#else
+#define MYSQLND_STATS_LOCK(stats)
+#define MYSQLND_STATS_UNLOCK(stats)
+#endif
 
-#define MYSQLND_INC_GLOBAL_STATISTIC(statistic) \
- { \
- 	if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
-		DBG_INF_FMT("Global stat increase [%s]", mysqlnd_stats_values_names[(statistic)].s); \
-			\
- 		tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
-		mysqlnd_global_stats->values[(statistic)]++; \
-		tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
-	}\
- }
-
-#define MYSQLND_DEC_CONN_STATISTIC(conn_stats, statistic) \
- { \
- 	if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
-		DBG_INF_FMT("Global&conn stat decrease [%s]", mysqlnd_stats_values_names[(statistic)].s); \
-			\
- 		tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
-		mysqlnd_global_stats->values[(statistic)]--; \
-		tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
-		if ((conn_stats)) { \
-			((MYSQLND_STATS *) conn_stats)->values[(statistic)]--; \
-		} \
-	}\
- }
-
-#define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2) \
+#define MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(stats, statistic, value) \
+	{ \
+		 	MYSQLND_STATS_LOCK(stats); \
+			(stats)->values[(statistic)] += (value); \
+			if ((stats)->triggers[(statistic)] && (stats)->in_trigger == FALSE) { \
+				(stats)->in_trigger = TRUE; \
+		 		MYSQLND_STATS_UNLOCK(stats); \
+																							\
+				(stats)->triggers[(statistic)]((stats), (statistic), (value) TSRMLS_CC); \
+																							\
+		 		MYSQLND_STATS_LOCK(stats); \
+				(stats)->in_trigger = FALSE; \
+			} \
+			MYSQLND_STATS_UNLOCK(_p_s); \
+	} \
+	
+#define MYSQLND_DEC_STATISTIC(enabler, stats, statistic) \
  { \
- 	if (MYSQLND_G(collect_statistics)) { \
-		uint64_t v1 = (uint64_t) (value1); \
-		uint64_t v2 = (uint64_t) (value2); \
-		enum_mysqlnd_collected_stats _s1 = (statistic1);\
-		enum_mysqlnd_collected_stats _s2 = (statistic2);\
-								 \
-		if (_s1 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
-		if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
-										\
- 		tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
-		if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
-		if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
-		tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
+	enum_mysqlnd_collected_stats _s = (statistic);\
+	MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
+ 	if ((enabler) && _p_s && _s != _p_s->count) { \
+		MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, -1); \
 	}\
  }
 
-#define MYSQLND_INC_CONN_STATISTIC(conn_stats, statistic) \
+#define MYSQLND_INC_STATISTIC(enabler, stats, statistic) \
  { \
- 	if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
-		DBG_INF_FMT("Global&Conn stat increase [%s]", mysqlnd_stats_values_names[(statistic)].s); \
-			\
- 		tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
-		mysqlnd_global_stats->values[(statistic)]++; \
-		tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
-		if ((conn_stats)) { \
-			((MYSQLND_STATS *) conn_stats)->values[(statistic)]++; \
-		} \
+	enum_mysqlnd_collected_stats _s = (statistic);\
+	MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
+ 	if ((enabler) && _p_s && _s != _p_s->count) { \
+		MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, 1); \
 	}\
  }
 
-#define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value) \
+#define MYSQLND_INC_STATISTIC_W_VALUE(enabler, stats, statistic, value) \
  { \
- 	if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
+	enum_mysqlnd_collected_stats _s = (statistic);\
+	MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
+ 	if ((enabler) && _p_s && _s != _p_s->count) { \
 		uint64_t v = (uint64_t) (value); \
-		DBG_INF_FMT("Global&Conn stat increase w value [%s]", mysqlnd_stats_values_names[(statistic)].s); \
-			\
-		tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
-		mysqlnd_global_stats->values[(statistic)] += v; \
-		tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
-		if ((conn_stats)) { \
-			((MYSQLND_STATS *) conn_stats)->values[(statistic)]+= v; \
-		} \
+		MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, v); \
 	}\
  }
 
-#define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2) \
+#define MYSQLND_INC_STATISTIC_W_VALUE2(enabler, stats, statistic1, value1, statistic2, value2) \
  { \
- 	if (MYSQLND_G(collect_statistics)) { \
+	MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
+ 	if ((enabler) && _p_s) { \
 		uint64_t v1 = (uint64_t) (value1); \
 		uint64_t v2 = (uint64_t) (value2); \
 		enum_mysqlnd_collected_stats _s1 = (statistic1);\
 		enum_mysqlnd_collected_stats _s2 = (statistic2);\
-								 \
-		if (_s1 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
-		if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
-					\
-		tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
-		if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
-		if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
-		tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
-		if ((conn_stats)) { \
-			if (_s1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s1]+= v1; \
-			if (_s2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s2]+= v2; \
-		} \
-	} \
+		if (_s1 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s1, v1); \
+		if (_s2 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s2, v2); \
+	}\
  }
 
-
-#define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3) \
+#define MYSQLND_INC_STATISTIC_W_VALUE3(enabler, stats, statistic1, value1, statistic2, value2, statistic3, value3) \
  { \
- 	if (MYSQLND_G(collect_statistics)) { \
+	MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
+ 	if ((enabler) && _p_s) { \
 		uint64_t v1 = (uint64_t) (value1); \
 		uint64_t v2 = (uint64_t) (value2); \
 		uint64_t v3 = (uint64_t) (value3); \
-		enum_mysqlnd_collected_stats _s1 = (statistic1); \
-		enum_mysqlnd_collected_stats _s2 = (statistic2); \
-		enum_mysqlnd_collected_stats _s3 = (statistic3); \
-								 \
-		if (_s1 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
-		if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
-		if (_s3 != STAT_LAST) DBG_INF_FMT("Global stat increase3 [%s]", mysqlnd_stats_values_names[_s3].s); \
-								 		\
-		tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
-		if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
-		if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
-		if (_s3 != STAT_LAST) mysqlnd_global_stats->values[_s3]+= v3; \
-		tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
-		if ((conn_stats)) { \
-			if (_s1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s1]+= v1; \
-			if (_s2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s2]+= v2; \
-			if (_s3 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s3]+= v3; \
-		} \
-	} \
+		enum_mysqlnd_collected_stats _s1 = (statistic1);\
+		enum_mysqlnd_collected_stats _s2 = (statistic2);\
+		enum_mysqlnd_collected_stats _s3 = (statistic3);\
+		if (_s1 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s1, v1); \
+		if (_s2 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s2, v2); \
+		if (_s3 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s3, v3); \
+	}\
  }
 
 
-#else /* NON-ZTS */
-
 #define MYSQLND_INC_GLOBAL_STATISTIC(statistic) \
- { \
- 	if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
-		DBG_INF_FMT("Global stat increase [%s]", mysqlnd_stats_values_names[(statistic)].s); \
-		mysqlnd_global_stats->values[(statistic)]++; \
-	} \
- }
-
+	 MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic))
 
 #define MYSQLND_DEC_CONN_STATISTIC(conn_stats, statistic) \
- { \
- 	if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
-		DBG_INF_FMT("Global&Conn stat decrease [%s]", mysqlnd_stats_values_names[(statistic)].s); \
-		mysqlnd_global_stats->values[(statistic)]--; \
-		if ((conn_stats)) { \
-			((MYSQLND_STATS *) conn_stats)->values[(statistic)]--; \
-		} \
-	} \
- }
+	 MYSQLND_DEC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic))
 
 #define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2) \
- { \
- 	if (MYSQLND_G(collect_statistics)) { \
-		uint64_t v1 = (uint64_t) (value1); \
-		uint64_t v2 = (uint64_t) (value2); \
-		enum_mysqlnd_collected_stats _s1 = (statistic1);\
-		enum_mysqlnd_collected_stats _s2 = (statistic2);\
-								 \
-		if (_s1 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
-		if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
-			\
-		if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
-		if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
-	}\
- }
+ 	MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2))
 
 #define MYSQLND_INC_CONN_STATISTIC(conn_stats, statistic) \
- { \
- 	if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
-		DBG_INF_FMT("Global&Conn stat increase [%s]", mysqlnd_stats_values_names[(statistic)].s); \
-		mysqlnd_global_stats->values[(statistic)]++; \
-		if ((conn_stats)) { \
-			((MYSQLND_STATS *) conn_stats)->values[(statistic)]++; \
-		} \
-	} \
- }
+	 MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic)); \
+	 MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), (conn_stats), (statistic));
 
 #define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value) \
- { \
- 	if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
-		uint64_t v = (uint64_t) (value); \
-		DBG_INF_FMT("Global&Conn stats increase w value [%s]", mysqlnd_stats_values_names[(statistic)].s); \
-		mysqlnd_global_stats->values[(statistic)] += v; \
-		if ((conn_stats)) { \
-			((MYSQLND_STATS *) conn_stats)->values[(statistic)] += v; \
-		} \
-	} \
- } 
+	 MYSQLND_INC_STATISTIC_W_VALUE(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic), (value)); \
+	 MYSQLND_INC_STATISTIC_W_VALUE(MYSQLND_G(collect_statistics), (conn_stats), (statistic), (value));
 
 #define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2) \
- { \
- 	if (MYSQLND_G(collect_statistics)) { \
-		uint64_t v1 = (uint64_t) (value1); \
-		uint64_t v2 = (uint64_t) (value2); \
-		enum_mysqlnd_collected_stats _s1 = (statistic1);\
-		enum_mysqlnd_collected_stats _s2 = (statistic2);\
-		if (_s1 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
-		if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
-								 \
-		if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
-		if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
-		if ((conn_stats)) { \
-			if (_s1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s1]+= v1; \
-			if (_s2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s2]+= v2; \
-		} \
-	} \
- }
+	 MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2)); \
+	 MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), (conn_stats), (statistic1), (value1), (statistic2), (value2));
 
 #define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3) \
- { \
- 	if (MYSQLND_G(collect_statistics)) { \
-		uint64_t v1 = (uint64_t) (value1); \
-		uint64_t v2 = (uint64_t) (value2); \
-		uint64_t v3 = (uint64_t) (value3); \
-		enum_mysqlnd_collected_stats _s1 = (statistic1); \
-		enum_mysqlnd_collected_stats _s2 = (statistic2); \
-		enum_mysqlnd_collected_stats _s3 = (statistic3); \
-								 \
-		if (_s1 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
-		if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
-		if (_s3 != STAT_LAST) DBG_INF_FMT("Global stat increase3 [%s]", mysqlnd_stats_values_names[_s3].s); \
-								\
-		if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
-		if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
-		if (_s3 != STAT_LAST) mysqlnd_global_stats->values[_s3]+= v3; \
-		if ((conn_stats)) { \
-			if (_s1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s1]+= v1; \
-			if (_s2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s2]+= v2; \
-			if (_s3 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s3]+= v3; \
-		} \
-	} \
- }
+	 MYSQLND_INC_STATISTIC_W_VALUE3(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2), (statistic3), (value3)); \
+	 MYSQLND_INC_STATISTIC_W_VALUE3(MYSQLND_G(collect_statistics), (conn_stats), (statistic1), (value1), (statistic2), (value2), (statistic3), (value3));
 
-#endif
 
-void mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, zval *return_value
-							 TSRMLS_DC ZEND_FILE_LINE_DC);
+PHPAPI void mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, const MYSQLND_STRING * names, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC);
+
+PHPAPI void mysqlnd_stats_init(MYSQLND_STATS ** stats, size_t statistic_count);
+PHPAPI void mysqlnd_stats_end(MYSQLND_STATS * stats);
 
+PHPAPI mysqlnd_stat_trigger mysqlnd_stats_set_trigger(MYSQLND_STATS * const stats, enum_mysqlnd_collected_stats stat, mysqlnd_stat_trigger trigger TSRMLS_DC);
+PHPAPI mysqlnd_stat_trigger mysqlnd_stats_reset_triggers(MYSQLND_STATS * const stats TSRMLS_DC);
 
-void mysqlnd_stats_init(MYSQLND_STATS ** stats);
-void mysqlnd_stats_end(MYSQLND_STATS * stats);
 
 #endif	/* MYSQLND_STATISTICS_H */
 
diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h
index ad61d9c..99f4016 100644
--- a/ext/mysqlnd/mysqlnd_structs.h
+++ b/ext/mysqlnd/mysqlnd_structs.h
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_structs.h 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysqlnd_structs.h 294543 2010-02-04 20:28:55Z johannes $ */
 
 #ifndef MYSQLND_STRUCTS_H
 #define MYSQLND_STRUCTS_H
@@ -48,7 +48,7 @@ struct st_mysqlnd_memory_pool_chunk
 	uint64_t			app;
 	MYSQLND_MEMORY_POOL *pool;
 	zend_uchar			*ptr;
-	unsigned int				size;
+	unsigned int		size;
 	void				(*resize_chunk)(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int size TSRMLS_DC);
 	void				(*free_chunk)(MYSQLND_MEMORY_POOL_CHUNK * chunk, zend_bool cache_it TSRMLS_DC);
 	zend_bool			from_pool;
@@ -96,7 +96,7 @@ typedef struct st_mysqlnd_upsert_result
 	unsigned int	server_status;
 	uint64_t		affected_rows;
 	uint64_t		last_insert_id;
-} mysqlnd_upsert_status;
+} MYSQLND_UPSERT_STATUS;
 
 
 typedef struct st_mysqlnd_error_info
@@ -104,12 +104,7 @@ typedef struct st_mysqlnd_error_info
 	char error[MYSQLND_ERRMSG_SIZE+1];
 	char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1];
 	unsigned int error_no;
-} mysqlnd_error_info;
-
-
-typedef struct st_mysqlnd_zval_pcache			MYSQLND_ZVAL_PCACHE;
-typedef struct st_mysqlnd_thread_zval_pcache	MYSQLND_THD_ZVAL_PCACHE;
-typedef struct st_mysqlnd_qcache				MYSQLND_QCACHE;
+} MYSQLND_ERROR_INFO;
 
 
 typedef struct st_mysqlnd_infile_info
@@ -146,13 +141,8 @@ typedef struct st_mysqlnd_infile
 	void	*userdata;
 } MYSQLND_INFILE;
 
-typedef struct st_mysqlnd_option
+typedef struct st_mysqlnd_options
 {
-	/* timeouts */
-	unsigned int		timeout_connect;
-	unsigned int		timeout_read;
-	unsigned int		timeout_write;
-
 	ulong		flags;
 
 	/* init commands - we need to send them to server directly after connect */
@@ -179,11 +169,22 @@ typedef struct st_mysqlnd_option
 #ifdef MYSQLND_STRING_TO_INT_CONVERSION
 	zend_bool	int_and_float_native;
 #endif
+} MYSQLND_OPTIONS;
+
+typedef struct st_mysqlnd_net_options
+{
+	/* timeouts */
+	unsigned int timeout_connect;
+	unsigned int timeout_read;
+	unsigned int timeout_write;
+
 	unsigned int net_read_buffer_size;
-} MYSQLND_OPTION;
+} MYSQLND_NET_OPTIONS;
 
 
 typedef struct st_mysqlnd_connection MYSQLND;
+typedef struct st_mysqlnd_net	MYSQLND_NET;
+typedef struct st_mysqlnd_protocol	MYSQLND_PROTOCOL;
 typedef struct st_mysqlnd_res	MYSQLND_RES;
 typedef char** 					MYSQLND_ROW_C;		/* return data as array of strings */
 typedef struct st_mysqlnd_stmt	MYSQLND_STMT;
@@ -195,7 +196,6 @@ typedef struct st_mysqlnd_result_bind MYSQLND_RESULT_BIND;
 
 typedef struct st_mysqlnd_result_metadata MYSQLND_RES_METADATA;
 typedef struct st_mysqlnd_buffered_result MYSQLND_RES_BUFFERED;
-typedef struct st_mysqlnd_background_buffered_result MYSQLND_RES_BG_BUFFERED;
 typedef struct st_mysqlnd_unbuffered_result MYSQLND_RES_UNBUFFERED;
 
 typedef struct st_mysqlnd_debug MYSQLND_DEBUG;
@@ -208,32 +208,82 @@ typedef enum_func_status  (*mysqlnd_fetch_row_func)(MYSQLND_RES *result,
 													zend_bool *fetched_anything
 													TSRMLS_DC);
 
-typedef struct st_mysqlnd_stats
+typedef struct st_mysqlnd_stats MYSQLND_STATS;
+
+typedef void (*mysqlnd_stat_trigger)(MYSQLND_STATS * stats, enum_mysqlnd_collected_stats stat, int64_t change TSRMLS_DC);
+
+struct st_mysqlnd_stats
 {
-	uint64_t	values[STAT_LAST];
+	uint64_t				*values;
+	mysqlnd_stat_trigger 	*triggers;
+	size_t					count;
+	zend_bool				in_trigger;
 #ifdef ZTS
 	MUTEX_T	LOCK_access;
 #endif
-} MYSQLND_STATS;
+};
+
 
+typedef struct st_mysqlnd_read_buffer {
+	zend_uchar 	* data;
+	size_t 		offset;
+	size_t 		size;
+	size_t		len;
+	zend_bool	(*is_empty)(struct st_mysqlnd_read_buffer *);
+	void		(*read)(struct st_mysqlnd_read_buffer *, size_t count, zend_uchar * dest);
+	size_t		(*bytes_left)(struct st_mysqlnd_read_buffer *);
+	void		(*free_buffer)(struct st_mysqlnd_read_buffer ** TSRMLS_DC);
+} MYSQLND_READ_BUFFER;
 
-typedef struct st_mysqlnd_net
+
+struct st_mysqlnd_net_methods
 {
-	php_stream		*stream;
-	/* sequence for simple checking of correct packets */
-	zend_uchar		packet_no;
+	enum_func_status	(*connect)(MYSQLND_NET * net, const char * const scheme, size_t scheme_len, zend_bool persistent, char **errstr, int * errcode TSRMLS_DC);
+	size_t				(*send)(MYSQLND * const conn, char * const buf, size_t count TSRMLS_DC);
+	size_t				(*receive)(MYSQLND * conn, zend_uchar * buffer, size_t count TSRMLS_DC);
+	enum_func_status	(*set_client_option)(MYSQLND_NET * const net, enum_mysqlnd_option option, const char * const value TSRMLS_DC);
+	enum_func_status	(*network_read)(MYSQLND * conn, zend_uchar * buffer, size_t count TSRMLS_DC);
+	size_t 				(*network_write)(MYSQLND * const conn, const zend_uchar * const buf, size_t count TSRMLS_DC);
+	enum_func_status	(*decode)(zend_uchar * uncompressed_data, size_t uncompressed_data_len, const zend_uchar * const compressed_data, size_t compressed_data_len TSRMLS_DC);
+	enum_func_status	(*encode)(zend_uchar * compress_buffer, size_t compress_buffer_len, const zend_uchar * const uncompressed_data, size_t uncompressed_data_len TSRMLS_DC);
+	size_t				(*consume_uneaten_data)(MYSQLND_NET * const net, enum php_mysqlnd_server_command cmd TSRMLS_DC);
+	void				(*free_contents)(MYSQLND_NET * net TSRMLS_DC);
+};
 
-#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND
-	zend_uchar		last_command;
-#endif
 
-	/* cmd buffer */
-	MYSQLND_CMD_BUFFER	cmd_buffer;
-} MYSQLND_NET;
+struct st_mysqlnd_packet_greet;
+struct st_mysqlnd_packet_greet;
+struct st_mysqlnd_packet_auth;
+struct st_mysqlnd_packet_ok;
+struct st_mysqlnd_packet_command;
+struct st_mysqlnd_packet_eof;
+struct st_mysqlnd_packet_rset_header;
+struct st_mysqlnd_packet_res_field;
+struct st_mysqlnd_packet_row;
+struct st_mysqlnd_packet_stats;
+struct st_mysqlnd_packet_prepare_response;
+struct st_mysqlnd_packet_chg_user_resp;
+
+struct st_mysqlnd_protocol_methods
+{
+	struct st_mysqlnd_packet_greet *		(*get_greet_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+	struct st_mysqlnd_packet_auth *			(*get_auth_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+	struct st_mysqlnd_packet_ok *			(*get_ok_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+	struct st_mysqlnd_packet_command *		(*get_command_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+	struct st_mysqlnd_packet_eof *			(*get_eof_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+	struct st_mysqlnd_packet_rset_header *	(*get_rset_header_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+	struct st_mysqlnd_packet_res_field *	(*get_result_field_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+	struct st_mysqlnd_packet_row *			(*get_row_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+	struct st_mysqlnd_packet_stats *		(*get_stats_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+	struct st_mysqlnd_packet_prepare_response *(*get_prepare_response_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+	struct st_mysqlnd_packet_chg_user_resp*(*get_change_user_response_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC);
+};
 
 
 struct st_mysqlnd_conn_methods
 {
+	void				(*init)(MYSQLND * conn TSRMLS_DC);
+	enum_func_status	(*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);
 	ulong				(*escape_string)(const MYSQLND * const conn, char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC);
 	enum_func_status	(*set_charset)(MYSQLND * const conn, const char * const charset TSRMLS_DC);
 	enum_func_status	(*query)(MYSQLND *conn, const char *query, unsigned int query_len TSRMLS_DC);
@@ -241,7 +291,6 @@ struct st_mysqlnd_conn_methods
 	enum_func_status	(*reap_query)(MYSQLND *conn TSRMLS_DC);
 	MYSQLND_RES *		(*use_result)(MYSQLND * const conn TSRMLS_DC);
 	MYSQLND_RES *		(*store_result)(MYSQLND * const conn TSRMLS_DC);
-	MYSQLND_RES *		(*background_store_result)(MYSQLND * const conn TSRMLS_DC);
 	enum_func_status	(*next_result)(MYSQLND * const conn TSRMLS_DC);
 	zend_bool			(*more_results)(const MYSQLND * const conn TSRMLS_DC);
 
@@ -254,29 +303,29 @@ struct st_mysqlnd_conn_methods
 	enum_func_status	(*kill_connection)(MYSQLND *conn, unsigned int pid TSRMLS_DC);
 	enum_func_status	(*select_db)(MYSQLND * const conn, const char * const db, unsigned int db_len TSRMLS_DC);
 	enum_func_status	(*server_dump_debug_information)(MYSQLND * const conn TSRMLS_DC);
-	enum_func_status	(*change_user)(MYSQLND * const conn, const char * user, const char * passwd, const char * db TSRMLS_DC);
+	enum_func_status	(*change_user)(MYSQLND * const conn, const char * user, const char * passwd, const char * db, zend_bool silent TSRMLS_DC);
 
-	unsigned int		(*get_error_no)(const MYSQLND * const conn);
-	const char *		(*get_error_str)(const MYSQLND * const conn);
-	const char *		(*get_sqlstate)(const MYSQLND * const conn);
-	uint64_t			(*get_thread_id)(const MYSQLND * const conn);
+	unsigned int		(*get_error_no)(const MYSQLND * const conn TSRMLS_DC);
+	const char *		(*get_error_str)(const MYSQLND * const conn TSRMLS_DC);
+	const char *		(*get_sqlstate)(const MYSQLND * const conn TSRMLS_DC);
+	uint64_t			(*get_thread_id)(const MYSQLND * const conn TSRMLS_DC);
 	void				(*get_statistics)(const MYSQLND * const conn, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC);
 
-	unsigned long		(*get_server_version)(const MYSQLND * const conn);
-	const char *		(*get_server_information)(const MYSQLND * const conn);
+	unsigned long		(*get_server_version)(const MYSQLND * const conn TSRMLS_DC);
+	const char *		(*get_server_information)(const MYSQLND * const conn TSRMLS_DC);
 	enum_func_status	(*get_server_statistics)(MYSQLND *conn, char **message, unsigned int * message_len TSRMLS_DC);
-	const char *		(*get_host_information)(const MYSQLND * const conn);
-	unsigned int		(*get_protocol_information)(const MYSQLND * const conn);
-	const char *		(*get_last_message)(const MYSQLND * const conn);
-	const char *		(*charset_name)(const MYSQLND * const conn);
+	const char *		(*get_host_information)(const MYSQLND * const conn TSRMLS_DC);
+	unsigned int		(*get_protocol_information)(const MYSQLND * const conn TSRMLS_DC);
+	const char *		(*get_last_message)(const MYSQLND * const conn TSRMLS_DC);
+	const char *		(*charset_name)(const MYSQLND * const conn TSRMLS_DC);
 	MYSQLND_RES *		(*list_fields)(MYSQLND *conn, const char *table, const char *achtung_wild TSRMLS_DC);
 	MYSQLND_RES *		(*list_method)(MYSQLND *conn, const char *query, const char *achtung_wild, char *par1 TSRMLS_DC);
 
-	uint64_t			(*get_last_insert_id)(const MYSQLND * const conn);
-	uint64_t			(*get_affected_rows)(const MYSQLND * const conn);
-	unsigned int		(*get_warning_count)(const MYSQLND * const conn);
+	uint64_t			(*get_last_insert_id)(const MYSQLND * const conn TSRMLS_DC);
+	uint64_t			(*get_affected_rows)(const MYSQLND * const conn TSRMLS_DC);
+	unsigned int		(*get_warning_count)(const MYSQLND * const conn TSRMLS_DC);
 
-	unsigned int		(*get_field_count)(const MYSQLND * const conn);
+	unsigned int		(*get_field_count)(const MYSQLND * const conn TSRMLS_DC);
 
 	enum_func_status	(*set_server_option)(MYSQLND * const conn, enum_mysqlnd_server_option option TSRMLS_DC);
 	enum_func_status	(*set_client_option)(MYSQLND * const conn, enum_mysqlnd_option option, const char * const value TSRMLS_DC);
@@ -285,10 +334,18 @@ struct st_mysqlnd_conn_methods
 	enum_func_status	(*close)(MYSQLND *conn, enum_connection_close_type close_type TSRMLS_DC);
 	void				(*dtor)(MYSQLND *conn TSRMLS_DC);	/* private */
 
+	enum_func_status	(*query_read_result_set_header)(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC);
+
 	MYSQLND *			(*get_reference)(MYSQLND * const conn TSRMLS_DC);
 	enum_func_status	(*free_reference)(MYSQLND * const conn TSRMLS_DC);
 	enum mysqlnd_connection_state (*get_state)(MYSQLND * const conn TSRMLS_DC);
 	void				(*set_state)(MYSQLND * const conn, enum mysqlnd_connection_state new_state TSRMLS_DC);
+
+	enum_func_status	(*simple_command)(MYSQLND *conn, enum php_mysqlnd_server_command command, const char * const arg, size_t arg_len, enum mysqlnd_packet_type ok_packet, zend_bool silent, zend_bool ignore_upsert_status TSRMLS_DC);
+	enum_func_status	(*simple_command_handle_response)(MYSQLND *conn, enum mysqlnd_packet_type ok_packet, zend_bool silent, enum php_mysqlnd_server_command command, zend_bool ignore_upsert_status TSRMLS_DC);
+
+	enum_func_status	(*restart_psession)(MYSQLND *conn TSRMLS_DC);
+	enum_func_status	(*end_psession)(MYSQLND *conn TSRMLS_DC);
 };
 
 
@@ -300,30 +357,38 @@ struct st_mysqlnd_res_methods
 
 	MYSQLND_RES *		(*use_result)(MYSQLND_RES * const result, zend_bool ps_protocol TSRMLS_DC);
 	MYSQLND_RES *		(*store_result)(MYSQLND_RES * result, MYSQLND * const conn, zend_bool ps TSRMLS_DC);
-	MYSQLND_RES *		(*background_store_result)(MYSQLND_RES * result, MYSQLND * const conn, zend_bool ps TSRMLS_DC);
 	void 				(*fetch_into)(MYSQLND_RES *result, unsigned int flags, zval *return_value, enum_mysqlnd_extension ext TSRMLS_DC ZEND_FILE_LINE_DC);
 	MYSQLND_ROW_C 		(*fetch_row_c)(MYSQLND_RES *result TSRMLS_DC);
 	void 				(*fetch_all)(MYSQLND_RES *result, unsigned int flags, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC);
 	void 				(*fetch_field_data)(MYSQLND_RES *result, unsigned int offset, zval *return_value TSRMLS_DC);
-	uint64_t			(*num_rows)(const MYSQLND_RES * const result);
-	unsigned int		(*num_fields)(const MYSQLND_RES * const result);
+	uint64_t			(*num_rows)(const MYSQLND_RES * const result TSRMLS_DC);
+	unsigned int		(*num_fields)(const MYSQLND_RES * const result TSRMLS_DC);
 	enum_func_status	(*skip_result)(MYSQLND_RES * const result TSRMLS_DC);
 	enum_func_status	(*seek_data)(MYSQLND_RES * result, uint64_t row TSRMLS_DC);
-	MYSQLND_FIELD_OFFSET (*seek_field)(MYSQLND_RES * const result, MYSQLND_FIELD_OFFSET field_offset);
-	MYSQLND_FIELD_OFFSET (*field_tell)(const MYSQLND_RES * const result);
+	MYSQLND_FIELD_OFFSET (*seek_field)(MYSQLND_RES * const result, MYSQLND_FIELD_OFFSET field_offset TSRMLS_DC);
+	MYSQLND_FIELD_OFFSET (*field_tell)(const MYSQLND_RES * const result TSRMLS_DC);
 	const MYSQLND_FIELD *(*fetch_field)(MYSQLND_RES * const result TSRMLS_DC);
 	const MYSQLND_FIELD *(*fetch_field_direct)(MYSQLND_RES * const result, MYSQLND_FIELD_OFFSET fieldnr TSRMLS_DC);
 	const MYSQLND_FIELD *(*fetch_fields)(MYSQLND_RES * const result TSRMLS_DC);
 
-	enum_func_status	(*read_result_metadata)(MYSQLND_RES *result, MYSQLND *conn TSRMLS_DC);
-	unsigned long *		(*fetch_lengths)(MYSQLND_RES * const result);
+	enum_func_status	(*read_result_metadata)(MYSQLND_RES *result, MYSQLND * conn TSRMLS_DC);
+	unsigned long *		(*fetch_lengths)(MYSQLND_RES * const result TSRMLS_DC);
+	enum_func_status	(*store_result_fetch_data)(MYSQLND * const conn, MYSQLND_RES *result, MYSQLND_RES_METADATA *meta, zend_bool binary_protocol, zend_bool to_cache TSRMLS_DC);
+	void 				(*initialize_result_set_rest)(MYSQLND_RES * const result TSRMLS_DC);
+
 	void				(*free_result_buffers)(MYSQLND_RES * result TSRMLS_DC);	/* private */
 	enum_func_status	(*free_result)(MYSQLND_RES * result, zend_bool implicit TSRMLS_DC);
-	void 				(*free_result_internal)(MYSQLND_RES *result TSRMLS_DC);
-	void 				(*free_result_contents)(MYSQLND_RES *result TSRMLS_DC);
-
-	/* for decoding - binary or text protocol */	
-	void 				(*row_decoder)(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields, unsigned int field_count, MYSQLND_FIELD *fields_metadata, MYSQLND *conn TSRMLS_DC);
+	void				(*free_result_internal)(MYSQLND_RES *result TSRMLS_DC);
+	void				(*free_result_contents)(MYSQLND_RES *result TSRMLS_DC);
+	void				(*free_buffered_data)(MYSQLND_RES *result TSRMLS_DC);
+	void				(*unbuffered_free_last_data)(MYSQLND_RES *result TSRMLS_DC);
+
+	/* for decoding - binary or text protocol */
+	void				(*row_decoder)(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields,
+									unsigned int field_count, MYSQLND_FIELD *fields_metadata,
+									zend_bool persistent,
+									zend_bool as_unicode, zend_bool as_int_or_float,
+									MYSQLND_STATS * stats TSRMLS_DC);
 };
 
 
@@ -332,7 +397,7 @@ struct st_mysqlnd_res_meta_methods
 	const MYSQLND_FIELD *	(*fetch_field)(MYSQLND_RES_METADATA * const meta TSRMLS_DC);
 	const MYSQLND_FIELD *	(*fetch_field_direct)(const MYSQLND_RES_METADATA * const meta, MYSQLND_FIELD_OFFSET fieldnr TSRMLS_DC);
 	const MYSQLND_FIELD *	(*fetch_fields)(MYSQLND_RES_METADATA * const meta TSRMLS_DC);
-	MYSQLND_FIELD_OFFSET	(*field_tell)(const MYSQLND_RES_METADATA * const meta);
+	MYSQLND_FIELD_OFFSET	(*field_tell)(const MYSQLND_RES_METADATA * const meta TSRMLS_DC);
 	enum_func_status		(*read_metadata)(MYSQLND_RES_METADATA * const meta, MYSQLND *conn TSRMLS_DC);
 	MYSQLND_RES_METADATA *	(*clone_metadata)(const MYSQLND_RES_METADATA * const meta, zend_bool persistent TSRMLS_DC);
 	void					(*free_metadata)(MYSQLND_RES_METADATA *meta, zend_bool persistent TSRMLS_DC);
@@ -345,7 +410,6 @@ struct st_mysqlnd_stmt_methods
 	enum_func_status	(*execute)(MYSQLND_STMT * const stmt TSRMLS_DC);
 	MYSQLND_RES *		(*use_result)(MYSQLND_STMT * const stmt TSRMLS_DC);
 	MYSQLND_RES *		(*store_result)(MYSQLND_STMT * const stmt TSRMLS_DC);
-	MYSQLND_RES *		(*background_store_result)(MYSQLND_STMT * const stmt TSRMLS_DC);
 	MYSQLND_RES *		(*get_result)(MYSQLND_STMT * const stmt TSRMLS_DC);
 	zend_bool			(*more_results)(const MYSQLND_STMT * const stmt TSRMLS_DC);
 	enum_func_status	(*next_result)(MYSQLND_STMT * const stmt TSRMLS_DC);
@@ -364,46 +428,83 @@ struct st_mysqlnd_stmt_methods
 	enum_func_status	(*bind_result)(MYSQLND_STMT * const stmt, MYSQLND_RESULT_BIND * const result_bind TSRMLS_DC);
 	enum_func_status	(*bind_one_result)(MYSQLND_STMT * const stmt, unsigned int param_no TSRMLS_DC);
 	void				(*set_result_bind_dtor)(MYSQLND_STMT * const stmt, void (*result_bind_dtor)(MYSQLND_RESULT_BIND * TSRMLS_DC) TSRMLS_DC);
-	enum_func_status	(*send_long_data)(MYSQLND_STMT * const stmt, unsigned int param_num,
-										  const char * const data, unsigned long length TSRMLS_DC);
-	MYSQLND_RES *		(*get_parameter_metadata)(MYSQLND_STMT * const stmt);
+	enum_func_status	(*send_long_data)(MYSQLND_STMT * const stmt, unsigned int param_num, const char * const data, unsigned long length TSRMLS_DC);
+	MYSQLND_RES *		(*get_parameter_metadata)(MYSQLND_STMT * const stmt TSRMLS_DC);
 	MYSQLND_RES *		(*get_result_metadata)(MYSQLND_STMT * const stmt TSRMLS_DC);
 
-	uint64_t			(*get_last_insert_id)(const MYSQLND_STMT * const stmt);
-	uint64_t			(*get_affected_rows)(const MYSQLND_STMT * const stmt);
-	uint64_t			(*get_num_rows)(const MYSQLND_STMT * const stmt);
+	uint64_t			(*get_last_insert_id)(const MYSQLND_STMT * const stmt TSRMLS_DC);
+	uint64_t			(*get_affected_rows)(const MYSQLND_STMT * const stmt TSRMLS_DC);
+	uint64_t			(*get_num_rows)(const MYSQLND_STMT * const stmt TSRMLS_DC);
 
-	unsigned int		(*get_param_count)(const MYSQLND_STMT * const stmt);
-	unsigned int		(*get_field_count)(const MYSQLND_STMT * const stmt);
-	unsigned int		(*get_warning_count)(const MYSQLND_STMT * const stmt);
+	unsigned int		(*get_param_count)(const MYSQLND_STMT * const stmt TSRMLS_DC);
+	unsigned int		(*get_field_count)(const MYSQLND_STMT * const stmt TSRMLS_DC);
+	unsigned int		(*get_warning_count)(const MYSQLND_STMT * const stmt TSRMLS_DC);
 
-	unsigned int		(*get_error_no)(const MYSQLND_STMT * const stmt);
-	const char *		(*get_error_str)(const MYSQLND_STMT * const stmt);
-	const char *		(*get_sqlstate)(const MYSQLND_STMT * const stmt);
+	unsigned int		(*get_error_no)(const MYSQLND_STMT * const stmt TSRMLS_DC);
+	const char *		(*get_error_str)(const MYSQLND_STMT * const stmt TSRMLS_DC);
+	const char *		(*get_sqlstate)(const MYSQLND_STMT * const stmt TSRMLS_DC);
 
 	enum_func_status	(*get_attribute)(const MYSQLND_STMT * const stmt, enum mysqlnd_stmt_attr attr_type, void * const value TSRMLS_DC);
 	enum_func_status	(*set_attribute)(MYSQLND_STMT * const stmt, enum mysqlnd_stmt_attr attr_type, const void * const value TSRMLS_DC);
 };
 
 
+struct st_mysqlnd_net
+{
+	php_stream			*stream;
+	struct st_mysqlnd_net_methods m;
+
+	/* sequence for simple checking of correct packets */
+	zend_uchar			packet_no;
+	zend_bool			compressed;
+	zend_uchar			compressed_envelope_packet_no;
+#ifdef MYSQLND_COMPRESSION_ENABLED
+	MYSQLND_READ_BUFFER	* uncompressed_data;
+#endif
+#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND
+	zend_uchar			last_command;
+#endif
+	/* cmd buffer */
+	MYSQLND_CMD_BUFFER	cmd_buffer;
+
+	MYSQLND_NET_OPTIONS options;
+
+	zend_bool			persistent;
+};
+
+
+struct st_mysqlnd_protocol
+{
+	struct st_mysqlnd_protocol_methods m;
+	zend_bool persistent;
+};
+
+
 struct st_mysqlnd_connection
 {
 /* Operation related */
-	MYSQLND_NET		net;
+	MYSQLND_NET		* net;
+	MYSQLND_PROTOCOL * protocol;
 
 /* Information related */
 	char			*host;
+	unsigned int	host_len;
 	char			*unix_socket;
+	unsigned int	unix_socket_len;
 	char			*user;
+	unsigned int	user_len;
 	char			*passwd;
-	unsigned int	*passwd_len;
+	unsigned int	passwd_len;
 	char			*scheme;
+	unsigned int	scheme_len;
 	uint64_t		thread_id;
 	char			*server_version;
 	char			*host_info;
 	unsigned char	*scramble;
 	const MYSQLND_CHARSET *charset;
 	const MYSQLND_CHARSET *greet_charset;
+	char 			*connect_or_select_db;
+	unsigned int	connect_or_select_db_len;
 	MYSQLND_INFILE	infile;
 	unsigned int	protocol_version;
 	unsigned long	max_packet_size;
@@ -412,12 +513,12 @@ struct st_mysqlnd_connection
 	unsigned long	server_capabilities;
 
 	/* For UPSERT queries */
-	mysqlnd_upsert_status upsert_status;
+	MYSQLND_UPSERT_STATUS upsert_status;
 	char			*last_message;
 	unsigned int	last_message_len;
 
 	/* If error packet, we use these */
-	mysqlnd_error_info	error_info;
+	MYSQLND_ERROR_INFO	error_info;
 
 	/*
 	  To prevent queries during unbuffered fetches. Also to
@@ -439,43 +540,19 @@ struct st_mysqlnd_connection
 
 	/* Temporal storage for mysql_query */
 	unsigned int	field_count;
-	
+
 	/* persistent connection */
 	zend_bool		persistent;
 
 	/* options */
-	MYSQLND_OPTION	options;
-
-	/* zval cache */
-	MYSQLND_THD_ZVAL_PCACHE	*zval_cache;
-
-	/* qcache */
-	MYSQLND_QCACHE	*qcache;
-
-	MYSQLND_MEMORY_POOL * result_set_memory_pool;
+	MYSQLND_OPTIONS	options;
 
 	/* stats */
-	MYSQLND_STATS	stats;
-
-#ifdef MYSQLND_THREADED
-	MUTEX_T			LOCK_state;
-
-	pthread_cond_t	COND_work_done;
-
-	pthread_mutex_t	LOCK_work;
-	pthread_cond_t	COND_work;
-	pthread_cond_t	COND_thread_ended;
-	zend_bool		thread_is_running;
-	zend_bool		thread_killed;
-	void ***		tsrm_ls;
-#endif
-
+	MYSQLND_STATS	* stats;
 
 	struct st_mysqlnd_conn_methods *m;
 };
 
-typedef struct st_php_mysql_packet_row php_mysql_packet_row;
-
 
 struct mysqlnd_field_hash_key
 {
@@ -484,7 +561,7 @@ struct mysqlnd_field_hash_key
 #if PHP_MAJOR_VERSION >= 6
 	zstr			ustr;
 	unsigned int	ulen;
-#endif	
+#endif
 };
 
 
@@ -502,31 +579,6 @@ struct st_mysqlnd_result_metadata
 };
 
 
-struct st_mysqlnd_background_buffered_result
-{
-	zval			***data;
-	uint64_t		data_size;
-	zval			***data_cursor;
-	MYSQLND_MEMORY_POOL_CHUNK **row_buffers;
-	uint64_t		row_count;
-	uint64_t		initialized_rows;
-	zend_bool		persistent;
-
-	MYSQLND_QCACHE	*qcache;
-	unsigned int	references;
-
-	zend_bool		decode_in_foreground;
-
-#ifdef ZTS
-	zend_bool		bg_fetch_finished;
-	MUTEX_T			LOCK;
-#endif
-
-	mysqlnd_error_info		error_info;
-	mysqlnd_upsert_status	upsert_status;
-};
-
-
 struct st_mysqlnd_buffered_result
 {
 	zval				**data;
@@ -536,10 +588,9 @@ struct st_mysqlnd_buffered_result
 	uint64_t			initialized_rows;
 	zend_bool			persistent;
 
-	MYSQLND_QCACHE		*qcache;
 	unsigned int		references;
 
-	mysqlnd_error_info	error_info;
+	MYSQLND_ERROR_INFO	error_info;
 };
 
 
@@ -567,19 +618,17 @@ struct st_mysqlnd_res
 
 	/* To be used with store_result() - both normal and PS */
 	MYSQLND_RES_BUFFERED		*stored_data;
-	MYSQLND_RES_BG_BUFFERED		*bg_stored_data;
 	MYSQLND_RES_UNBUFFERED		*unbuf;
 
 	/*
 	  Column lengths of current row - both buffered and unbuffered.
-	  For buffered results it duplicates the data found in **data 
+	  For buffered results it duplicates the data found in **data
 	*/
 	unsigned long			*lengths;
 
-	php_mysql_packet_row	*row_packet;
+	struct st_mysqlnd_packet_row * row_packet;
 
-	/* zval cache */
-	MYSQLND_THD_ZVAL_PCACHE	*zval_cache;
+	MYSQLND_MEMORY_POOL * result_set_memory_pool;
 };
 
 
@@ -612,9 +661,9 @@ struct st_mysqlnd_stmt
 	MYSQLND_RESULT_BIND			*result_bind;
 	zend_bool					result_zvals_separated_once;
 
-	mysqlnd_upsert_status		upsert_status;
+	MYSQLND_UPSERT_STATUS		upsert_status;
 
-	mysqlnd_error_info			error_info;
+	MYSQLND_ERROR_INFO			error_info;
 
 	zend_bool					update_max_length;
 	unsigned long				prefetch_rows;
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
index cc0697c..5710377 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
@@ -23,29 +23,18 @@
 #include "mysqlnd_priv.h"
 #include "mysqlnd_wireprotocol.h"
 #include "mysqlnd_statistics.h"
-#include "mysqlnd_palloc.h"
 #include "mysqlnd_debug.h"
 #include "mysqlnd_block_alloc.h"
 #include "ext/standard/sha1.h"
-#include "php_network.h"
 #include "zend_ini.h"
 
-#ifndef PHP_WIN32
-#include <netinet/tcp.h>
-#else
-#include <winsock.h>
-#endif
-
-#define USE_CORK 0
-
 #define MYSQLND_SILENT 1
 
-#define MYSQLND_DUMP_HEADER_N_BODY2
-#define MYSQLND_DUMP_HEADER_N_BODY_FULL2
-
+#define MYSQLND_DUMP_HEADER_N_BODY
 
 #define	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_size, packet_type_as_text, packet_type) \
 	{ \
+		DBG_INF_FMT("buf=%p size=%u", (buf), (buf_size)); \
 		if (FAIL == mysqlnd_read_header((conn), &((packet)->header) TSRMLS_CC)) {\
 			CONN_SET_STATE(conn, CONN_QUIT_SENT); \
 			SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);\
@@ -54,36 +43,37 @@
 			DBG_RETURN(FAIL);\
 		}\
 		if ((buf_size) < (packet)->header.size) { \
-			DBG_ERR_FMT("Packet buffer wasn't big enough %u bytes will be unread", \
-						(packet)->header.size - (buf_size)); \
+			DBG_ERR_FMT("Packet buffer %u wasn't big enough %u, %u bytes will be unread", \
+						(buf_size), (packet)->header.size, (packet)->header.size - (buf_size)); \
+						DBG_RETURN(FAIL); \
 		}\
-		if (!mysqlnd_read_body((conn), (buf), \
-							   MIN((buf_size), (packet)->header.size) TSRMLS_CC)) { \
+		if (FAIL == conn->net->m.receive((conn), (buf), (packet)->header.size TSRMLS_CC)) { \
 			CONN_SET_STATE(conn, CONN_QUIT_SENT); \
 			SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);\
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", mysqlnd_server_gone); \
-			DBG_ERR_FMT("Empty %s packet body", (packet_type_as_text)); \
+			DBG_ERR_FMT("Empty '%s' packet body", (packet_type_as_text)); \
 			DBG_RETURN(FAIL);\
 		} \
-		MYSQLND_INC_CONN_STATISTIC_W_VALUE2(&conn->stats, packet_type_to_statistic_byte_count[packet_type], \
+		MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn->stats, packet_type_to_statistic_byte_count[packet_type], \
 											MYSQLND_HEADER_SIZE + (packet)->header.size, \
 											packet_type_to_statistic_packet_count[packet_type], \
 											1); \
 	}
 
 
-extern mysqlnd_packet_methods packet_methods[];
-
 static const char *unknown_sqlstate= "HY000";
 
 char * const mysqlnd_empty_string = "";
 
 /* Used in mysqlnd_debug.c */
-char * mysqlnd_read_header_name	= "mysqlnd_read_header";
-char * mysqlnd_read_body_name	= "mysqlnd_read_body";
+const char mysqlnd_read_header_name[]	= "mysqlnd_read_header";
+const char mysqlnd_read_body_name[]		= "mysqlnd_read_body";
+
 
+#define ERROR_MARKER 0xFF
+#define EODATA_MARKER 0xFE
 
-/* {{{ mysqlnd_command_to_text 
+/* {{{ mysqlnd_command_to_text
  */
 const char * const mysqlnd_command_to_text[COM_END] =
 {
@@ -128,7 +118,7 @@ static enum_mysqlnd_collected_stats packet_type_to_statistic_packet_count[PROT_L
 };
 
 
-/* {{{ php_mysqlnd_net_field_length 
+/* {{{ php_mysqlnd_net_field_length
    Get next field's length */
 unsigned long php_mysqlnd_net_field_length(zend_uchar **packet)
 {
@@ -157,7 +147,7 @@ unsigned long php_mysqlnd_net_field_length(zend_uchar **packet)
 /* }}} */
 
 
-/* {{{ php_mysqlnd_net_field_length_ll 
+/* {{{ php_mysqlnd_net_field_length_ll
    Get next field's length */
 uint64_t php_mysqlnd_net_field_length_ll(zend_uchar **packet)
 {
@@ -212,59 +202,11 @@ zend_uchar *php_mysqlnd_net_store_length(zend_uchar *packet, uint64_t length)
 /* }}} */
 
 
-/* {{{ php_mysqlnd_consume_uneaten_data */
-#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND
-size_t php_mysqlnd_consume_uneaten_data(MYSQLND * const conn, enum php_mysqlnd_server_command cmd TSRMLS_DC)
-{
-
-	/*
-	  Switch to non-blocking mode and try to consume something from
-	  the line, if possible, then continue. This saves us from looking for
-	  the actuall place where out-of-order packets have been sent.
-	  If someone is completely sure that everything is fine, he can switch it
-	  off.
-	*/
-	char tmp_buf[256];
-	MYSQLND_NET *net = &conn->net;
-	size_t skipped_bytes = 0;
-	int opt = PHP_STREAM_OPTION_BLOCKING;
-	int was_blocked = net->stream->ops->set_option(net->stream, opt, 0, NULL TSRMLS_CC);
-
-	DBG_ENTER("php_mysqlnd_consume_uneaten_data");
-
-	if (PHP_STREAM_OPTION_RETURN_ERR != was_blocked) {
-		/* Do a read of 1 byte */
-		int bytes_consumed;
-
-		do {
-			skipped_bytes += (bytes_consumed = php_stream_read(net->stream, tmp_buf, sizeof(tmp_buf)));
-		} while (bytes_consumed == sizeof(tmp_buf));
-
-		if (was_blocked) {
-			net->stream->ops->set_option(net->stream, opt, 1, NULL TSRMLS_CC);
-		}
-
-		if (bytes_consumed) {
-			DBG_ERR_FMT("Skipped %u bytes. Last command %s hasn't consumed all the output from the server",
-						bytes_consumed, mysqlnd_command_to_text[net->last_command]);
-			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Skipped %u bytes. Last command %s hasn't "
-							 "consumed all the output from the server",
-							 bytes_consumed, mysqlnd_command_to_text[net->last_command]);
-		}
-	}
-	net->last_command = cmd;
-
-	DBG_RETURN(skipped_bytes);
-}
-#endif
-/* }}} */
-
-
 /* {{{ php_mysqlnd_read_error_from_line */
-static
-enum_func_status php_mysqlnd_read_error_from_line(zend_uchar *buf, size_t buf_len,
-												  char *error, int error_buf_len,
-												  unsigned int *error_no, char *sqlstate TSRMLS_DC)
+static enum_func_status
+php_mysqlnd_read_error_from_line(zend_uchar *buf, size_t buf_len,
+								char *error, int error_buf_len,
+								unsigned int *error_no, char *sqlstate TSRMLS_DC)
 {
 	zend_uchar *p = buf;
 	int error_msg_len= 0;
@@ -288,215 +230,46 @@ enum_func_status php_mysqlnd_read_error_from_line(zend_uchar *buf, size_t buf_le
 	}
 	sqlstate[MYSQLND_SQLSTATE_LENGTH] = '\0';
 	error[error_msg_len]= '\0';
-	
-	DBG_RETURN(FAIL);
-} 
-/* }}} */
-
-
-/* {{{ mysqlnd_set_sock_no_delay */
-int mysqlnd_set_sock_no_delay(php_stream *stream)
-{
-
-	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");
-
-	if (result == -1) {
-		ret = FAILURE;
-	}
-
-	DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* We assume that MYSQLND_HEADER_SIZE is 4 bytes !! */
-#define STORE_HEADER_SIZE(safe_storage, buffer)  int4store((safe_storage), (*(uint32_t *)(buffer)))
-#define RESTORE_HEADER_SIZE(buffer, safe_storage) STORE_HEADER_SIZE((safe_storage), (buffer))
-
-/* {{{ mysqlnd_stream_write_w_header */
-/*
-  IMPORTANT : It's expected that buf has place in the beginning for MYSQLND_HEADER_SIZE !!!!
-  			  This is done for performance reasons in the caller of this function.
-			  Otherwise we will have to do send two TCP packets, or do new alloc and memcpy.
-			  Neither are quick, thus the clients of this function are obligated to do
-			  what they are asked for.
-
-  `count` is actually the length of the payload data. Thus :
-  count + MYSQLND_HEADER_SIZE = sizeof(buf) (not the pointer but the actual buffer)
-*/
-size_t mysqlnd_stream_write_w_header(MYSQLND * const conn, char * const buf, size_t count TSRMLS_DC)
-{
-	zend_uchar safe_buf[((MYSQLND_HEADER_SIZE) + (sizeof(zend_uchar)) - 1) / (sizeof(zend_uchar))];
-	zend_uchar *safe_storage = safe_buf;
-	MYSQLND_NET *net = &conn->net;
-	size_t old_chunk_size = net->stream->chunk_size;
-	size_t ret, left = count, packets_sent = 1;
-	zend_uchar *p = (zend_uchar *) buf;
-
-	DBG_ENTER("mysqlnd_stream_write_w_header");
-	DBG_INF_FMT("conn=%llu count=%lu", conn->thread_id, count);
-
-	net->stream->chunk_size = MYSQLND_MAX_PACKET_SIZE;
-
-	while (left > MYSQLND_MAX_PACKET_SIZE) {
-		STORE_HEADER_SIZE(safe_storage, p);
-		int3store(p, MYSQLND_MAX_PACKET_SIZE);
-		int1store(p + 3, net->packet_no);
-		net->packet_no++;
-		ret = php_stream_write(net->stream, (char *)p, MYSQLND_MAX_PACKET_SIZE + MYSQLND_HEADER_SIZE);
-		RESTORE_HEADER_SIZE(p, safe_storage);
-
-		p += MYSQLND_MAX_PACKET_SIZE;
-		left -= MYSQLND_MAX_PACKET_SIZE;
-
-		packets_sent++;
-	}
-	/* Even for zero size payload we have to send a packet */
-	STORE_HEADER_SIZE(safe_storage, p);
-	int3store(p, left);
-	int1store(p + 3, net->packet_no);
-	net->packet_no++;
-	ret = php_stream_write(net->stream, (char *)p, left + MYSQLND_HEADER_SIZE);
-	RESTORE_HEADER_SIZE(p, safe_storage);
-
-	if (!ret) {
-		DBG_ERR_FMT("Can't %u send bytes", count);
-		conn->state = CONN_QUIT_SENT;
-		SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
-	}
-
-	MYSQLND_INC_CONN_STATISTIC_W_VALUE3(&conn->stats,
-			STAT_BYTES_SENT, count + packets_sent * MYSQLND_HEADER_SIZE,
-			STAT_PROTOCOL_OVERHEAD_OUT, packets_sent * MYSQLND_HEADER_SIZE,
-			STAT_PACKETS_SENT, packets_sent);
 
-	net->stream->chunk_size = old_chunk_size;
-
-	DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_stream_write_w_command */
-#if USE_CORK && defined(TCP_CORK)
-static
-size_t mysqlnd_stream_write_w_command(MYSQLND * const conn, enum php_mysqlnd_server_command command,
-									  const char * const buf, size_t count TSRMLS_DC)
-{
-	zend_uchar safe_buf[((MYSQLND_HEADER_SIZE) + (sizeof(zend_uchar)) - 1) / (sizeof(zend_uchar))];
-	zend_uchar *safe_storage = (char *) &safe_buf;
-	MYSQLND_NET *net = &conn->net;
-	size_t old_chunk_size = net->stream->chunk_size;
-	size_t ret, left = count, header_len = MYSQLND_HEADER_SIZE + 1, packets_sent = 1;
-	const zend_uchar *p = (zend_uchar *) buf;
-	zend_bool command_sent = FALSE;
-	int corked = 1;
-
-	DBG_ENTER("mysqlnd_stream_write_w_command");
-
-	net->stream->chunk_size = MYSQLND_MAX_PACKET_SIZE;
-
-	setsockopt(((php_netstream_data_t*)net->stream->abstract)->socket,
-				IPPROTO_TCP, TCP_CORK, &corked, sizeof(corked));
-
-	int1store(safe_storage + MYSQLND_HEADER_SIZE, command);
-	while (left > MYSQLND_MAX_PACKET_SIZE) {
-		size_t body_size = MYSQLND_MAX_PACKET_SIZE;
-
-		int3store(safe_storage, MYSQLND_MAX_PACKET_SIZE);
-		int1store(safe_storage + 3, net->packet_no);
-		net->packet_no++;
-		
-		ret = php_stream_write(net->stream, (char *)safe_storage, header_len);
-		if (command_sent == FALSE) {
-			--header_len;
-			/* Sent one byte less*/
-			--body_size;
-			command_sent = TRUE;
-		}
-
-		ret = php_stream_write(net->stream, (char *)p, body_size);
-
-		p += body_size;
-		left -= body_size;
-
-		packets_sent++;
-	}
-	/* Even for zero size payload we have to send a packet */
-	int3store(safe_storage, header_len == MYSQLND_HEADER_SIZE? left:left+1);
-	int1store(safe_storage + 3, net->packet_no);
-	net->packet_no++;
-	
-	ret = php_stream_write(net->stream, (char *)safe_storage, header_len);
-
-	if (left) {
-		ret = php_stream_write(net->stream, (char *)p, left);
-	}
-	corked = 0;
-	setsockopt(((php_netstream_data_t*)net->stream->abstract)->socket,
-				IPPROTO_TCP, TCP_CORK, &corked, sizeof(corked));
-
-	MYSQLND_INC_CONN_STATISTIC_W_VALUE3(&conn->stats, STAT_BYTES_SENT,
-				count + packets_sent * MYSQLND_HEADER_SIZE);
-				STAT_PROTOCOL_OVERHEAD_OUT, packets_sent * MYSQLND_HEADER_SIZE);
-				STAT_PACKETS_SENT, packets_sent);
-
-	net->stream->chunk_size = old_chunk_size;
-
-	DBG_RETURN(ret);
+	DBG_RETURN(FAIL);
 }
-#endif
 /* }}} */
 
 
 /* {{{ mysqlnd_read_header */
 static enum_func_status
-mysqlnd_read_header(MYSQLND *conn, mysqlnd_packet_header *header TSRMLS_DC)
+mysqlnd_read_header(MYSQLND * conn, MYSQLND_PACKET_HEADER * header TSRMLS_DC)
 {
-	MYSQLND_NET *net = &conn->net;
-	char buffer[MYSQLND_HEADER_SIZE];
-	char *p = buffer;
-	int to_read = MYSQLND_HEADER_SIZE, ret;
+	MYSQLND_NET * net = conn->net;
+	zend_uchar buffer[MYSQLND_HEADER_SIZE];
 
-	DBG_ENTER(mysqlnd_read_header_name);
-
-	do {
-		if (!(ret= php_stream_read(net->stream, p, to_read))) {
-			DBG_ERR_FMT("Error while reading header from socket");
-			return FAIL;
-		}
-		p += ret;
-		to_read -= ret;
-	} while (to_read);
+	DBG_ENTER("mysqlnd_read_header_name");
+	DBG_INF_FMT("compressed=%d conn_id=%u", net->compressed, conn->thread_id);
+	if (FAIL == net->m.receive(conn, buffer, MYSQLND_HEADER_SIZE TSRMLS_CC)) {
+		DBG_RETURN(FAIL);
+	}
 
 	header->size = uint3korr(buffer);
 	header->packet_no = uint1korr(buffer + 3);
 
-	MYSQLND_INC_CONN_STATISTIC_W_VALUE3(&conn->stats,
-							STAT_BYTES_RECEIVED, MYSQLND_HEADER_SIZE,
+#ifdef MYSQLND_DUMP_HEADER_N_BODY
+	DBG_INF_FMT("HEADER: prot_packet_no=%d size=%3d", header->packet_no, header->size);
+#endif
+	MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn->stats,
 							STAT_PROTOCOL_OVERHEAD_IN, MYSQLND_HEADER_SIZE,
 							STAT_PACKETS_RECEIVED, 1);
 
-	if (net->packet_no == header->packet_no) {
+	if (net->compressed || net->packet_no == header->packet_no) {
 		/*
 		  Have to increase the number, so we can send correct number back. It will
 		  round at 255 as this is unsigned char. The server needs this for simple
 		  flow control checking.
 		*/
 		net->packet_no++;
-#ifdef MYSQLND_DUMP_HEADER_N_BODY
-		DBG_ERR_FMT("HEADER: packet_no=%d size=%3d", header->packet_no, header->size);
-#endif
 		DBG_RETURN(PASS);
 	}
 
-	DBG_ERR_FMT("Packets out of order. Expected %d received %d. Packet size=%d",
+	DBG_ERR_FMT("Logical link: packets out of order. Expected %d received %d. Packet size=%d",
 				net->packet_no, header->packet_no, header->size);
 
 	php_error(E_WARNING, "Packets out of order. Expected %d received %d. Packet size="MYSQLND_SZ_T_SPEC,
@@ -506,65 +279,14 @@ mysqlnd_read_header(MYSQLND *conn, mysqlnd_packet_header *header TSRMLS_DC)
 /* }}} */
 
 
-/* {{{ mysqlnd_read_body */
-static
-size_t mysqlnd_read_body(MYSQLND *conn, zend_uchar *buf, size_t size TSRMLS_DC)
-{
-	size_t ret;
-	char *p = (char *)buf;
-	unsigned int iter = 0;
-	MYSQLND_NET *net = &conn->net;
-	size_t old_chunk_size = net->stream->chunk_size;
-
-	DBG_ENTER(mysqlnd_read_body_name);
-	DBG_INF_FMT("chunk_size=%d", net->stream->chunk_size);
-
-	net->stream->chunk_size = MIN(size, conn->options.net_read_buffer_size);
-	do {
-		size -= (ret = php_stream_read(net->stream, p, size));
-		if (size > 0 || iter++) {
-			DBG_INF_FMT("read=%d buf=%p p=%p chunk_size=%d left=%d",
-						ret, buf, p , net->stream->chunk_size, size);
-		}
-		p += ret;
-	} while (size > 0);
-
-	MYSQLND_INC_CONN_STATISTIC_W_VALUE(&conn->stats, STAT_BYTES_RECEIVED, p - (char*)buf);
-	net->stream->chunk_size = old_chunk_size;
-
-#ifdef MYSQLND_DUMP_HEADER_N_BODY_FULL
-	{
-		unsigned int i;
-		DBG_INF_FMT("BODY: requested=%d last_read=%3d", p - (char*)buf, ret);
-		for (i = 0 ; i < p - (char*)buf; i++) {
-			if (i && (i % 30 == 0)) {
-				printf("\n\t\t");
-			}
-			printf("[%c] ", *(char *)(&(buf[i])));
-		}
-		for (i = 0 ; i < p - (char*)buf; i++) {
-			if (i && (i % 30 == 0)) {
-				printf("\n\t\t");
-			}
-			printf("%.2X ", (int)*((char*)&(buf[i])));
-		}
-		php_printf("\n\t\t\t-=-=-=-=-\n");
-	}
-#endif
-
-	DBG_RETURN(p - (char*)buf);
-}
-/* }}} */
-
-
 /* {{{ php_mysqlnd_greet_read */
 static enum_func_status
 php_mysqlnd_greet_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 {
-	zend_uchar buf[512];
+	zend_uchar buf[2048];
 	zend_uchar *p = buf;
 	zend_uchar *begin = buf;
-	php_mysql_packet_greet *packet= (php_mysql_packet_greet *) _packet;
+	MYSQLND_PACKET_GREET *packet= (MYSQLND_PACKET_GREET *) _packet;
 
 	DBG_ENTER("php_mysqlnd_greet_read");
 
@@ -573,7 +295,7 @@ php_mysqlnd_greet_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 	packet->protocol_version = uint1korr(p);
 	p++;
 
-	if (packet->protocol_version == 0xFF) {
+	if (ERROR_MARKER == packet->protocol_version) {
 		php_mysqlnd_read_error_from_line(p, packet->header.size - 1,
 										 packet->error, sizeof(packet->error),
 										 &packet->error_no, packet->sqlstate
@@ -589,7 +311,7 @@ php_mysqlnd_greet_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 		DBG_RETURN(PASS);
 	}
 
-	packet->server_version = pestrdup((char *)p, conn->persistent);
+	packet->server_version = estrdup((char *)p);
 	p+= strlen(packet->server_version) + 1; /* eat the '\0' */
 
 	packet->thread_id = uint4korr(p);
@@ -642,7 +364,7 @@ php_mysqlnd_greet_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 static
 void php_mysqlnd_greet_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
-	php_mysql_packet_greet *p= (php_mysql_packet_greet *) _packet;
+	MYSQLND_PACKET_GREET *p= (MYSQLND_PACKET_GREET *) _packet;
 	if (p->server_version) {
 		mnd_efree(p->server_version);
 		p->server_version = NULL;
@@ -678,7 +400,7 @@ void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const sc
 	PHP_SHA1_CTX context;
 	zend_uchar sha1[SHA1_MAX_LENGTH];
 	zend_uchar sha2[SHA1_MAX_LENGTH];
-	
+
 
 	/* Phase 1: hash password */
 	PHP_SHA1Init(&context);
@@ -709,7 +431,7 @@ size_t php_mysqlnd_auth_write(void *_packet, MYSQLND *conn TSRMLS_DC)
 	char buffer[1024];
 	register char *p= buffer + MYSQLND_HEADER_SIZE; /* start after the header */
 	int len;
-	register php_mysql_packet_auth *packet= (php_mysql_packet_auth *) _packet;
+	register MYSQLND_PACKET_AUTH *packet= (MYSQLND_PACKET_AUTH *) _packet;
 
 	DBG_ENTER("php_mysqlnd_auth_write");
 
@@ -722,7 +444,7 @@ size_t php_mysqlnd_auth_write(void *_packet, MYSQLND *conn TSRMLS_DC)
 	if (PG(open_basedir) && strlen(PG(open_basedir))) {
 		packet->client_flags ^= CLIENT_LOCAL_FILES;
 	}
-	
+
 	int4store(p, packet->client_flags);
 	p+= 4;
 
@@ -733,7 +455,7 @@ size_t php_mysqlnd_auth_write(void *_packet, MYSQLND *conn TSRMLS_DC)
 	p++;
 
 	memset(p, 0, 23); /* filler */
-	p+= 23;	
+	p+= 23;
 
 	len= strlen(packet->user);
 	memcpy(p, packet->user, len);
@@ -761,40 +483,45 @@ size_t php_mysqlnd_auth_write(void *_packet, MYSQLND *conn TSRMLS_DC)
 	/* Handle CLIENT_CONNECT_WITH_DB */
 	/* no \0 for no DB */
 
-	DBG_RETURN(mysqlnd_stream_write_w_header(conn, buffer, p - buffer - MYSQLND_HEADER_SIZE TSRMLS_CC));
+	DBG_RETURN(conn->net->m.send(conn, buffer, p - buffer - MYSQLND_HEADER_SIZE TSRMLS_CC));
 }
 /* }}} */
 
+
 /* {{{ php_mysqlnd_auth_free_mem */
 static
 void php_mysqlnd_auth_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
 	if (!alloca) {
-		mnd_pefree((php_mysql_packet_auth *) _packet, ((php_mysql_packet_auth *)_packet)->header.persistent);
+		mnd_pefree((MYSQLND_PACKET_AUTH *) _packet, ((MYSQLND_PACKET_AUTH *)_packet)->header.persistent);
 	}
 }
 /* }}} */
 
 
+#define OK_BUFFER_SIZE 2048
+
 /* {{{ php_mysqlnd_ok_read */
 static enum_func_status
 php_mysqlnd_ok_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 {
-	zend_uchar buf[1024];
+	zend_uchar local_buf[OK_BUFFER_SIZE];
+	size_t buf_len = conn->net->cmd_buffer.buffer? conn->net->cmd_buffer.length : OK_BUFFER_SIZE;
+	zend_uchar *buf = conn->net->cmd_buffer.buffer? (zend_uchar *) conn->net->cmd_buffer.buffer : local_buf;
 	zend_uchar *p = buf;
 	zend_uchar *begin = buf;
 	unsigned long i;
-	register php_mysql_packet_ok *packet= (php_mysql_packet_ok *) _packet;
+	register MYSQLND_PACKET_OK *packet= (MYSQLND_PACKET_OK *) _packet;
 
 	DBG_ENTER("php_mysqlnd_ok_read");
 
-	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "OK", PROT_OK_PACKET);
+	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_len, "OK", PROT_OK_PACKET);
 
-	/* Should be always 0x0 or 0xFF for error */
+	/* Should be always 0x0 or ERROR_MARKER for error */
 	packet->field_count = uint1korr(p);
 	p++;
 
-	if (0xFF == packet->field_count) {
+	if (ERROR_MARKER == packet->field_count) {
 		php_mysqlnd_read_error_from_line(p, packet->header.size - 1,
 										 packet->error, sizeof(packet->error),
 										 &packet->error_no, packet->sqlstate
@@ -813,7 +540,7 @@ php_mysqlnd_ok_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 
 	/* There is a message */
 	if (packet->header.size > p - buf && (i = php_mysqlnd_net_field_length(&p))) {
-		packet->message = estrndup((char *)p, MIN(i, sizeof(buf) - (p - buf)));
+		packet->message = estrndup((char *)p, MIN(i, buf_len - (p - begin)));
 		packet->message_len = i;
 	} else {
 		packet->message = NULL;
@@ -838,7 +565,7 @@ php_mysqlnd_ok_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 static
 void php_mysqlnd_ok_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
-	php_mysql_packet_ok *p= (php_mysql_packet_ok *) _packet;
+	MYSQLND_PACKET_OK *p= (MYSQLND_PACKET_OK *) _packet;
 	if (p->message) {
 		mnd_efree(p->message);
 		p->message = NULL;
@@ -860,20 +587,21 @@ php_mysqlnd_eof_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 
 	  Error : error_code + '#' + sqlstate + MYSQLND_ERRMSG_SIZE
 	*/
-	php_mysql_packet_eof *packet= (php_mysql_packet_eof *) _packet;
-	zend_uchar buf[5 + 10 + sizeof(packet->sqlstate) + sizeof(packet->error)];
+	MYSQLND_PACKET_EOF *packet= (MYSQLND_PACKET_EOF *) _packet;
+	size_t buf_len = conn->net->cmd_buffer.length;
+	zend_uchar *buf = (zend_uchar *) conn->net->cmd_buffer.buffer;
 	zend_uchar *p = buf;
 	zend_uchar *begin = buf;
 
 	DBG_ENTER("php_mysqlnd_eof_read");
 
-	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "EOF", PROT_EOF_PACKET);
+	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_len, "EOF", PROT_EOF_PACKET);
 
-	/* Should be always 0xFE */
+	/* Should be always EODATA_MARKER */
 	packet->field_count = uint1korr(p);
 	p++;
 
-	if (0xFF == packet->field_count) {
+	if (ERROR_MARKER == packet->field_count) {
 		php_mysqlnd_read_error_from_line(p, packet->header.size - 1,
 										 packet->error, sizeof(packet->error),
 										 &packet->error_no, packet->sqlstate
@@ -901,7 +629,7 @@ php_mysqlnd_eof_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "EOF packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
 						 p - begin - packet->header.size);
 	}
-	
+
 	DBG_INF_FMT("EOF packet: fields=%d status=%d warnings=%d",
 				packet->field_count, packet->server_status, packet->warning_count);
 
@@ -915,7 +643,7 @@ static
 void php_mysqlnd_eof_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
 	if (!alloca) {
-		mnd_pefree(_packet, ((php_mysql_packet_eof *)_packet)->header.persistent);
+		mnd_pefree(_packet, ((MYSQLND_PACKET_EOF *)_packet)->header.persistent);
 	}
 }
 /* }}} */
@@ -925,8 +653,8 @@ void php_mysqlnd_eof_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 size_t php_mysqlnd_cmd_write(void *_packet, MYSQLND *conn TSRMLS_DC)
 {
 	/* Let's have some space, which we can use, if not enough, we will allocate new buffer */
-	php_mysql_packet_command *packet= (php_mysql_packet_command *) _packet;
-	MYSQLND_NET *net = &conn->net;
+	MYSQLND_PACKET_COMMAND *packet= (MYSQLND_PACKET_COMMAND *) _packet;
+	MYSQLND_NET *net = conn->net;
 	unsigned int error_reporting = EG(error_reporting);
 	size_t written;
 
@@ -936,27 +664,24 @@ size_t php_mysqlnd_cmd_write(void *_packet, MYSQLND *conn TSRMLS_DC)
 	  Every command starts a new TX and packet numbers are reset to 0.
 	*/
 	net->packet_no = 0;
+	net->compressed_envelope_packet_no = 0; /* this is for the response */
 
 	if (error_reporting) {
 		EG(error_reporting) = 0;
 	}
 
-	MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_PACKETS_SENT_CMD);
-	
+	MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_PACKETS_SENT_CMD);
+
 #ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND
-	php_mysqlnd_consume_uneaten_data(conn, packet->command TSRMLS_CC);
+	net->m.consume_uneaten_data(net, packet->command TSRMLS_CC);
 #endif
 
 	if (!packet->argument || !packet->arg_len) {
 		char buffer[MYSQLND_HEADER_SIZE + 1];
 
 		int1store(buffer + MYSQLND_HEADER_SIZE, packet->command);
-		written = mysqlnd_stream_write_w_header(conn, buffer, 1 TSRMLS_CC);
+		written = conn->net->m.send(conn, buffer, 1 TSRMLS_CC);
 	} else {
-#if USE_CORK && defined(TCP_CORK)
-		written = mysqlnd_stream_write_w_command(conn, packet->command, packet->argument,
-												 packet->arg_len TSRMLS_CC));
-#else
 		size_t tmp_len = packet->arg_len + 1 + MYSQLND_HEADER_SIZE, ret;
 		zend_uchar *tmp, *p;
 		tmp = (tmp_len > net->cmd_buffer.length)? mnd_emalloc(tmp_len):net->cmd_buffer.buffer;
@@ -967,13 +692,12 @@ size_t php_mysqlnd_cmd_write(void *_packet, MYSQLND *conn TSRMLS_DC)
 
 		memcpy(p, packet->argument, packet->arg_len);
 
-		ret = mysqlnd_stream_write_w_header(conn, (char *)tmp, tmp_len - MYSQLND_HEADER_SIZE TSRMLS_CC);
+		ret = conn->net->m.send(conn, (char *)tmp, tmp_len - MYSQLND_HEADER_SIZE TSRMLS_CC);
 		if (tmp != net->cmd_buffer.buffer) {
-			MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_CMD_BUFFER_TOO_SMALL);
+			MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_CMD_BUFFER_TOO_SMALL);
 			mnd_efree(tmp);
 		}
 		written = ret;
-#endif
 	}
 	if (error_reporting) {
 		/* restore error reporting */
@@ -989,7 +713,7 @@ static
 void php_mysqlnd_cmd_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
 	if (!alloca) {
-		mnd_pefree(_packet, ((php_mysql_packet_command *)_packet)->header.persistent);
+		mnd_pefree(_packet, ((MYSQLND_PACKET_COMMAND *)_packet)->header.persistent);
 	}
 }
 /* }}} */
@@ -999,21 +723,22 @@ void php_mysqlnd_cmd_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 static enum_func_status
 php_mysqlnd_rset_header_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 {
-	zend_uchar buf[1024];
+	size_t buf_len = conn->net->cmd_buffer.length;
+	zend_uchar *buf = (zend_uchar *) conn->net->cmd_buffer.buffer;
 	zend_uchar *p = buf;
 	zend_uchar *begin = buf;
 	size_t len;
-	php_mysql_packet_rset_header *packet= (php_mysql_packet_rset_header *) _packet;
+	MYSQLND_PACKET_RSET_HEADER *packet= (MYSQLND_PACKET_RSET_HEADER *) _packet;
 
 	DBG_ENTER("php_mysqlnd_rset_header_read");
 
-	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "resultset header", PROT_RSET_HEADER_PACKET);
+	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_len, "resultset header", PROT_RSET_HEADER_PACKET);
 
 	/*
-	  Don't increment. First byte is 0xFF on error, but otherwise is starting byte
+	  Don't increment. First byte is ERROR_MARKER on error, but otherwise is starting byte
 	  of encoded sequence for length.
 	*/
-	if (*p == 0xFF) {
+	if (ERROR_MARKER == *p) {
 		/* Error */
 		p++;
 		php_mysqlnd_read_error_from_line(p, packet->header.size - 1,
@@ -1076,7 +801,8 @@ php_mysqlnd_rset_header_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 static
 void php_mysqlnd_rset_header_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
-	php_mysql_packet_rset_header *p= (php_mysql_packet_rset_header *) _packet;
+	MYSQLND_PACKET_RSET_HEADER *p= (MYSQLND_PACKET_RSET_HEADER *) _packet;
+	DBG_ENTER("php_mysqlnd_rset_header_free_mem");
 	if (p->info_or_local_file) {
 		mnd_efree(p->info_or_local_file);
 		p->info_or_local_file = NULL;
@@ -1084,6 +810,7 @@ void php_mysqlnd_rset_header_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 	if (!alloca) {
 		mnd_pefree(p, p->header.persistent);
 	}
+	DBG_VOID_RETURN;
 }
 /* }}} */
 
@@ -1109,12 +836,12 @@ static enum_func_status
 php_mysqlnd_rset_field_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 {
 	/* Should be enough for the metadata of a single row */
-	php_mysql_packet_res_field *packet= (php_mysql_packet_res_field *) _packet;
-	zend_uchar *buf = (zend_uchar *) conn->net.cmd_buffer.buffer;
+	MYSQLND_PACKET_RES_FIELD *packet= (MYSQLND_PACKET_RES_FIELD *) _packet;
+	size_t buf_len = conn->net->cmd_buffer.length, total_len = 0;
+	zend_uchar *buf = (zend_uchar *) conn->net->cmd_buffer.buffer;
 	zend_uchar *p = buf;
 	zend_uchar *begin = buf;
 	char *root_ptr;
-	size_t buf_len = conn->net.cmd_buffer.length, total_len = 0;
 	unsigned long len;
 	MYSQLND_FIELD *meta;
 	unsigned int i, field_count = sizeof(rset_field_offsets)/sizeof(size_t);
@@ -1126,7 +853,7 @@ php_mysqlnd_rset_field_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 	if (packet->skip_parsing) {
 		DBG_RETURN(PASS);
 	}
-	if (*p == 0xFF) {
+	if (ERROR_MARKER == *p) {
 		/* Error */
 		p++;
 		php_mysqlnd_read_error_from_line(p, packet->header.size - 1,
@@ -1135,7 +862,7 @@ php_mysqlnd_rset_field_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 										 TSRMLS_CC);
 		DBG_ERR_FMT("Server error : (%d) %s", packet->error_info.error_no, packet->error_info.error);
 		DBG_RETURN(PASS);
-	} else if (*p == 0xFE && packet->header.size < 8) {
+	} else if (EODATA_MARKER == *p && packet->header.size < 8) {
 		/* Premature EOF. That should be COM_FIELD_LIST */
 		DBG_INF("Premature EOF. That should be COM_FIELD_LIST");
 		packet->stupid_list_fields_eof = TRUE;
@@ -1229,7 +956,8 @@ php_mysqlnd_rset_field_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 	if (meta->db && meta->db != mysqlnd_empty_string) {
 		len = meta->db_length;
 		meta->db = memcpy(root_ptr, meta->db, len);
-		*(root_ptr + len) = '\0';
+		*(root_ptr +=len) = '\0';
+		root_ptr++;
 	}
 
 	if (meta->table && meta->table != mysqlnd_empty_string) {
@@ -1278,7 +1006,7 @@ faulty_or_fake:
 static
 void php_mysqlnd_rset_field_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
-	php_mysql_packet_res_field *p= (php_mysql_packet_res_field *) _packet;
+	MYSQLND_PACKET_RES_FIELD *p= (MYSQLND_PACKET_RES_FIELD *) _packet;
 
 	/* p->metadata was passed to us as temporal buffer */
 	if (!alloca) {
@@ -1288,13 +1016,15 @@ void php_mysqlnd_rset_field_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 /* }}} */
 
 
+/* {{{ php_mysqlnd_read_row_ex */
 static enum_func_status
-php_mysqlnd_read_row_ex(MYSQLND *conn, MYSQLND_MEMORY_POOL_CHUNK **buffer,
+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,
 						unsigned int prealloc_more_bytes TSRMLS_DC)
 {
 	enum_func_status ret = PASS;
-	mysqlnd_packet_header header;
+	MYSQLND_PACKET_HEADER header;
 	zend_uchar *p = NULL;
 	zend_bool first_iteration = TRUE;
 
@@ -1323,8 +1053,7 @@ php_mysqlnd_read_row_ex(MYSQLND *conn, MYSQLND_MEMORY_POOL_CHUNK **buffer,
 			  We need a trailing \0 for the last string, in case of text-mode,
 			  to be able to implement read-only variables. Thus, we add + 1.
 			*/
-			*buffer = conn->result_set_memory_pool->get_chunk(conn->result_set_memory_pool,
-															  *data_size + 1 TSRMLS_CC);
+			*buffer = result_set_memory_pool->get_chunk(result_set_memory_pool, *data_size + 1 TSRMLS_CC);
 			p = (*buffer)->ptr;
 		} else if (!first_iteration) {
 			/* Empty packet after MYSQLND_MAX_PACKET_SIZE packet. That's ok, break */
@@ -1343,10 +1072,9 @@ php_mysqlnd_read_row_ex(MYSQLND *conn, MYSQLND_MEMORY_POOL_CHUNK **buffer,
 			p = (*buffer)->ptr + (*data_size - header.size);
 		}
 
-		if (!mysqlnd_read_body(conn, p, header.size TSRMLS_CC)) {
+		if ((ret = conn->net->m.receive(conn, p, header.size TSRMLS_CC))) {
 			DBG_ERR("Empty row packet body");
 			php_error(E_WARNING, "Empty row packet body");
-			ret = FAIL;
 			break;
 		}
 
@@ -1354,56 +1082,42 @@ php_mysqlnd_read_row_ex(MYSQLND *conn, MYSQLND_MEMORY_POOL_CHUNK **buffer,
 			break;
 		}
 	}
-	if (ret == FAIL) {
+	if (ret == FAIL && *buffer) {
 		(*buffer)->free_chunk((*buffer), TRUE TSRMLS_CC);
 		*buffer = NULL;
 	}
 	*data_size -= prealloc_more_bytes;
 	DBG_RETURN(ret);
 }
+/* }}} */
 
 
 /* {{{ php_mysqlnd_rowp_read_binary_protocol */
 void php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields,
-										   unsigned int field_count, MYSQLND_FIELD *fields_metadata,
-										   MYSQLND *conn TSRMLS_DC)
+										 unsigned int field_count, MYSQLND_FIELD *fields_metadata,
+										 zend_bool persistent,
+										 zend_bool as_unicode, zend_bool as_int_or_float,
+										 MYSQLND_STATS * stats TSRMLS_DC)
 {
 	int i;
 	zend_uchar *p = row_buffer->ptr;
 	zend_uchar *null_ptr, bit;
 	zval **current_field, **end_field, **start_field;
-	zend_bool as_unicode = conn->options.numeric_and_datetime_as_unicode;
-#ifdef USE_ZVAL_CACHE
-	zend_bool allocated;
-	void *obj;
-#endif
 
 	DBG_ENTER("php_mysqlnd_rowp_read_binary_protocol");
 
 	end_field = (current_field = start_field = fields) + field_count;
 
 
-	/* skip the first byte, not 0xFE -> 0x0, status */
+	/* 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++) {
-#ifdef USE_ZVAL_CACHE
-		DBG_INF("Trying to use the zval cache");
-		obj = mysqlnd_palloc_get_zval(conn->zval_cache, &allocated TSRMLS_CC);
-		if (allocated) {
-			*current_field = (zval *) obj;
-		} else {
-			/* It's from the cache, so we can upcast here */
-			*current_field = &((mysqlnd_zval *) obj)->zv;			
-			((mysqlnd_zval *) obj)->point_type = MYSQLND_POINTS_EXT_BUFFER;
-		}
-#else
 		DBG_INF("Directly creating zval");
 		MAKE_STD_ZVAL(*current_field);
-#endif
 
 		DBG_INF_FMT("Into zval=%p decoding column %d [%s.%s.%s] type=%d field->flags&unsigned=%d flags=%u is_bit=%d as_unicode=%d",
 			*current_field, i,
@@ -1412,7 +1126,7 @@ void php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffe
 		if (*null_ptr & bit) {
 			DBG_INF("It's null");
 			ZVAL_NULL(*current_field);
-			MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_BINARY_TYPE_FETCHED_NULL);
+			MYSQLND_INC_CONN_STATISTIC(stats, 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],
@@ -1449,8 +1163,8 @@ void php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffe
 					case MYSQL_TYPE_STRING:		statistic = STAT_BINARY_TYPE_FETCHED_STRING; break;
 					case MYSQL_TYPE_GEOMETRY:	statistic = STAT_BINARY_TYPE_FETCHED_GEOMETRY; break;
 					default: statistic = STAT_BINARY_TYPE_FETCHED_OTHER; break;
-				}			
-				MYSQLND_INC_CONN_STATISTIC(&conn->stats, statistic);
+				}
+				MYSQLND_INC_CONN_STATISTIC(stats, statistic);
 			}
 		}
 		if (!((bit<<=1) & 255)) {
@@ -1467,7 +1181,9 @@ void php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffe
 /* {{{ php_mysqlnd_rowp_read_text_protocol */
 void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields,
 										 unsigned int field_count, MYSQLND_FIELD *fields_metadata,
-										 MYSQLND *conn TSRMLS_DC)
+										 zend_bool persistent,
+										 zend_bool as_unicode, zend_bool as_int_or_float,
+										 MYSQLND_STATS * stats TSRMLS_DC)
 {
 	int i;
 	zend_bool last_field_was_string = FALSE;
@@ -1475,39 +1191,22 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
 	zend_uchar *p = row_buffer->ptr;
 	size_t data_size = row_buffer->app;
 	zend_uchar *bit_area = (zend_uchar*) row_buffer->ptr + data_size + 1; /* we allocate from here */
-	zend_bool as_unicode = conn->options.numeric_and_datetime_as_unicode;
-#ifdef MYSQLND_STRING_TO_INT_CONVERSION
-	zend_bool as_int_or_float = conn->options.int_and_float_native;
-#endif
 
 	DBG_ENTER("php_mysqlnd_rowp_read_text_protocol");
 
 	end_field = (current_field = start_field = fields) + field_count;
 	for (i = 0; current_field < end_field; current_field++, i++) {
 		/* Don't reverse the order. It is significant!*/
-		void *obj = NULL;
-		zend_bool allocated = TRUE;
 		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);
 
-#ifdef USE_ZVAL_CACHE
-		obj = mysqlnd_palloc_get_zval(conn->zval_cache, &allocated TSRMLS_CC);
-		if (allocated) {
-			*current_field = (zval *) obj;
-		} else {
-			/* It's from the cache, so we can upcast here */
-			*current_field = &((mysqlnd_zval *) obj)->zv;	
-			((mysqlnd_zval *) obj)->point_type = MYSQLND_POINTS_FREE;
-		}
-#else
 		DBG_INF("Directly creating zval");
 		MAKE_STD_ZVAL(*current_field);
-#endif
 
 		if (current_field > start_field && last_field_was_string) {
 			/*
-			  Normal queries: 
+			  Normal queries:
 			  We have to put \0 now to the end of the previous field, if it was
 			  a string. IS_NULL doesn't matter. Because we have already read our
 			  length, then we can overwrite it in the row buffer.
@@ -1561,8 +1260,8 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
 					case MYSQL_TYPE_STRING:		statistic = STAT_TEXT_TYPE_FETCHED_STRING; break;
 					case MYSQL_TYPE_GEOMETRY:	statistic = STAT_TEXT_TYPE_FETCHED_GEOMETRY; break;
 					default: statistic = STAT_TEXT_TYPE_FETCHED_OTHER; break;
-				}			
-				MYSQLND_INC_CONN_STATISTIC(&conn->stats, statistic);
+				}
+				MYSQLND_INC_CONN_STATISTIC(stats, statistic);
 			}
 
 #ifdef MYSQLND_STRING_TO_INT_CONVERSION
@@ -1594,7 +1293,7 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
 #if SIZEOF_LONG==8
 					if (uns == TRUE && v > 9223372036854775807L)
 #elif SIZEOF_LONG==4
-					if ((uns == TRUE && v > L64(2147483647)) || 
+					if ((uns == TRUE && v > L64(2147483647)) ||
 						(uns == FALSE && (( L64(2147483647) < (int64_t) v) ||
 						(L64(-2147483648) > (int64_t) v))))
 #endif /* SIZEOF */
@@ -1636,14 +1335,11 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
 #if PHP_MAJOR_VERSION >= 6
 					if (as_unicode) {
 						ZVAL_UTF8_STRINGL(*current_field, start, bit_area - start - 1, 0);
-					} else 			
+					} else
 #endif
 					{
 						ZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, 0);
 					}
-					if (allocated == FALSE) {
-						((mysqlnd_zval *) obj)->point_type = MYSQLND_POINTS_INT_BUFFER;
-					}
 				} else if (Z_TYPE_PP(current_field) == IS_STRING){
 					memcpy(bit_area, Z_STRVAL_PP(current_field), Z_STRLEN_PP(current_field));
 					bit_area += Z_STRLEN_PP(current_field);
@@ -1652,26 +1348,20 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
 #if PHP_MAJOR_VERSION >= 6
 					if (as_unicode) {
 						ZVAL_UTF8_STRINGL(*current_field, start, bit_area - start - 1, 0);
-					} else 			
+					} else
 #endif
 					{
 						ZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, 0);
 					}
-					if (allocated == FALSE) {
-						((mysqlnd_zval *) obj)->point_type = MYSQLND_POINTS_INT_BUFFER;
-					}
 				}
 				/*
 				  IS_UNICODE should not be specially handled. In unicode mode
 				  the buffers are not referenced - everything is copied.
 				*/
-			} else 
+			} else
 #if PHP_MAJOR_VERSION < 6
 			{
 				ZVAL_STRINGL(*current_field, (char *)p, len, 0);
-				if (allocated == FALSE) {
-					((mysqlnd_zval *) obj)->point_type = MYSQLND_POINTS_INT_BUFFER;
-				}
 			}
 #else
 			/*
@@ -1682,10 +1372,6 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
 			  Also the destruction of the zvals should not call zval_copy_ctor()
 			  because then we will leak.
 
-			  I suppose we can use UG(unicode) in mysqlnd.c/mysqlnd_palloc.c when
-			  freeing a result set
-			  to check if we need to call copy_ctor().
-
 			  XXX: Keep in mind that up there there is an open `else` in
 				   #ifdef MYSQLND_STRING_TO_INT_CONVERSION
 				   which will make with this `if` an `else if`.
@@ -1699,20 +1385,6 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
 			} else {
 				ZVAL_UTF8_STRINGL(*current_field, (char *)p, len, 0);
 			}
-			if (allocated == FALSE) {
-				/*
-				  The zval cache will check and see that the type is IS_STRING.
-				  In this case it will call copy_ctor(). This is valid when
-				  allocated == TRUE . In this case we can't upcast. Thus for non-PS
-				  point_type doesn't matter much, as the valuable information is
-				  in the type of result set. Still good to set it.
-				*/
-				if (Z_TYPE_P(*current_field) == IS_STRING) {
-					((mysqlnd_zval *) obj)->point_type = MYSQLND_POINTS_INT_BUFFER;
-				} else {
-					((mysqlnd_zval *) obj)->point_type = MYSQLND_POINTS_EXT_BUFFER;
-				}
-			}
 #endif
 			p += len;
 			last_field_was_string = TRUE;
@@ -1730,17 +1402,17 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
 
 /* {{{ php_mysqlnd_rowp_read */
 /*
-  if normal statements => packet->fields is created by this function, 
+  if normal statements => packet->fields is created by this function,
   if PS => packet->fields is passed from outside
 */
 static enum_func_status
 php_mysqlnd_rowp_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 {
-	MYSQLND_NET *net = &conn->net;
+	MYSQLND_NET *net = conn->net;
 	zend_uchar *p;
 	enum_func_status ret = PASS;
 	size_t old_chunk_size = net->stream->chunk_size;
-	php_mysql_packet_row *packet= (php_mysql_packet_row *) _packet;
+	MYSQLND_PACKET_ROW *packet= (MYSQLND_PACKET_ROW *) _packet;
 	size_t post_alloc_for_bit_fields = 0;
 	uint64_t data_size = 0;
 
@@ -1752,13 +1424,13 @@ php_mysqlnd_rowp_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 			packet->bit_fields_total_len + packet->bit_fields_count;
 	}
 
-	ret = php_mysqlnd_read_row_ex(conn, &packet->row_buffer, &data_size,
+	ret = php_mysqlnd_read_row_ex(conn, packet->result_set_memory_pool, &packet->row_buffer, &data_size,
 								  packet->persistent_alloc, post_alloc_for_bit_fields
 								  TSRMLS_CC);
 	if (FAIL == ret) {
 		goto end;
 	}
-	MYSQLND_INC_CONN_STATISTIC_W_VALUE2(&conn->stats, packet_type_to_statistic_byte_count[PROT_ROW_PACKET],
+	MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn->stats, packet_type_to_statistic_byte_count[PROT_ROW_PACKET],
 										MYSQLND_HEADER_SIZE + packet->header.size,
 										packet_type_to_statistic_packet_count[PROT_ROW_PACKET],
 										1);
@@ -1767,7 +1439,7 @@ php_mysqlnd_rowp_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 	packet->header.size = data_size;
 	packet->row_buffer->app = data_size;
 
-	if ((*(p = packet->row_buffer->ptr)) == 0xFF) {
+	if (ERROR_MARKER == (*(p = packet->row_buffer->ptr))) {
 		/*
 		   Error message as part of the result set,
 		   not good but we should not hang. See:
@@ -1780,7 +1452,7 @@ php_mysqlnd_rowp_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 										 &packet->error_info.error_no,
 										 packet->error_info.sqlstate
 										 TSRMLS_CC);
-	} else if (*p == 0xFE && data_size < 8) { /* EOF */
+	} else if (EODATA_MARKER == *p && data_size < 8) { /* EOF */
 		packet->eof = TRUE;
 		p++;
 		if (data_size > 1) {
@@ -1792,7 +1464,7 @@ php_mysqlnd_rowp_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 						packet->server_status, packet->warning_count);
 		}
 	} else {
-		MYSQLND_INC_CONN_STATISTIC(&conn->stats,
+		MYSQLND_INC_CONN_STATISTIC(conn->stats,
 									packet->binary_protocol? STAT_ROWS_FETCHED_FROM_SERVER_PS:
 															 STAT_ROWS_FETCHED_FROM_SERVER_NORMAL);
 
@@ -1816,7 +1488,7 @@ php_mysqlnd_rowp_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 														packet->persistent_alloc);
 			}
 		} else {
-			MYSQLND_INC_CONN_STATISTIC(&conn->stats,
+			MYSQLND_INC_CONN_STATISTIC(conn->stats,
 										packet->binary_protocol? STAT_ROWS_SKIPPED_PS:
 																 STAT_ROWS_SKIPPED_NORMAL);
 		}
@@ -1833,10 +1505,10 @@ end:
 static
 void php_mysqlnd_rowp_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
-	php_mysql_packet_row *p;
+	MYSQLND_PACKET_ROW *p;
 
 	DBG_ENTER("php_mysqlnd_rowp_free_mem");
-	p = (php_mysql_packet_row *) _packet;
+	p = (MYSQLND_PACKET_ROW *) _packet;
 	if (p->row_buffer) {
 		p->row_buffer->free_chunk(p->row_buffer, TRUE TSRMLS_CC);
 		p->row_buffer = NULL;
@@ -1857,17 +1529,17 @@ void php_mysqlnd_rowp_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 /* }}} */
 
 
-
 /* {{{ php_mysqlnd_stats_read */
 static enum_func_status
 php_mysqlnd_stats_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 {
-	zend_uchar buf[1024];
-	php_mysql_packet_stats *packet= (php_mysql_packet_stats *) _packet;
+	MYSQLND_PACKET_STATS *packet= (MYSQLND_PACKET_STATS *) _packet;
+	size_t buf_len = conn->net->cmd_buffer.length;
+	zend_uchar *buf = (zend_uchar *) conn->net->cmd_buffer.buffer;
 
 	DBG_ENTER("php_mysqlnd_stats_read");
 
-	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "statistics", PROT_STATS_PACKET);
+	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_len, "statistics", PROT_STATS_PACKET);
 
 	packet->message = mnd_emalloc(packet->header.size + 1);
 	memcpy(packet->message, buf, packet->header.size);
@@ -1883,7 +1555,7 @@ php_mysqlnd_stats_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 static
 void php_mysqlnd_stats_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
-	php_mysql_packet_stats *p= (php_mysql_packet_stats *) _packet;
+	MYSQLND_PACKET_STATS *p= (MYSQLND_PACKET_STATS *) _packet;
 	if (p->message) {
 		mnd_efree(p->message);
 		p->message = NULL;
@@ -1904,21 +1576,22 @@ static enum_func_status
 php_mysqlnd_prepare_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 {
 	/* In case of an error, we should have place to put it */
-	zend_uchar buf[1024];
+	size_t buf_len = conn->net->cmd_buffer.length;
+	zend_uchar *buf = (zend_uchar *) conn->net->cmd_buffer.buffer;
 	zend_uchar *p = buf;
 	zend_uchar *begin = buf;
 	unsigned int data_size;
-	php_mysql_packet_prepare_response *packet= (php_mysql_packet_prepare_response *) _packet;
+	MYSQLND_PACKET_PREPARE_RESPONSE *packet= (MYSQLND_PACKET_PREPARE_RESPONSE *) _packet;
 
 	DBG_ENTER("php_mysqlnd_prepare_read");
 
-	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "prepare", PROT_PREPARE_RESP_PACKET);
-	
+	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_len, "prepare", PROT_PREPARE_RESP_PACKET);
+
 	data_size = packet->header.size;
 	packet->error_code = uint1korr(p);
 	p++;
 
-	if (0xFF == packet->error_code) {
+	if (ERROR_MARKER == packet->error_code) {
 		php_mysqlnd_read_error_from_line(p, data_size - 1,
 										 packet->error_info.error,
 										 sizeof(packet->error_info.error),
@@ -1971,7 +1644,7 @@ php_mysqlnd_prepare_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 static
 void php_mysqlnd_prepare_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
-	php_mysql_packet_prepare_response *p= (php_mysql_packet_prepare_response *) _packet;
+	MYSQLND_PACKET_PREPARE_RESPONSE *p= (MYSQLND_PACKET_PREPARE_RESPONSE *) _packet;
 	if (!alloca) {
 		mnd_pefree(p, p->header.persistent);
 	}
@@ -1984,31 +1657,31 @@ static enum_func_status
 php_mysqlnd_chg_user_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 {
 	/* There could be an error message */
-	zend_uchar buf[1024];
+	size_t buf_len = conn->net->cmd_buffer.length;
+	zend_uchar *buf = (zend_uchar *) conn->net->cmd_buffer.buffer;
 	zend_uchar *p = buf;
 	zend_uchar *begin = buf;
-	php_mysql_packet_chg_user_resp *packet= (php_mysql_packet_chg_user_resp *) _packet;
+	MYSQLND_PACKET_CHG_USER_RESPONSE *packet= (MYSQLND_PACKET_CHG_USER_RESPONSE *) _packet;
 
 	DBG_ENTER("php_mysqlnd_chg_user_read");
 
-	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "change user response", PROT_CHG_USER_PACKET);
+	PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_len, "change user response", PROT_CHG_USER_RESP_PACKET);
 
 	/*
-	  Don't increment. First byte is 0xFF on error, but otherwise is starting byte
+	  Don't increment. First byte is ERROR_MARKER on error, but otherwise is starting byte
 	  of encoded sequence for length.
 	*/
 
-	/* Should be always 0x0 or 0xFF for error */
+	/* Should be always 0x0 or ERROR_MARKER for error */
 	packet->field_count= uint1korr(p);
 	p++;
 
-	if (packet->header.size == 1 && buf[0] == 0xFE &&
-		packet->server_capabilities & CLIENT_SECURE_CONNECTION) {
+	if (packet->header.size == 1 && buf[0] == EODATA_MARKER && packet->server_capabilities & CLIENT_SECURE_CONNECTION) {
 		/* We don't handle 3.23 authentication */
 		DBG_RETURN(FAIL);
 	}
 
-	if (0xFF == packet->field_count) {
+	if (ERROR_MARKER == packet->field_count) {
 		php_mysqlnd_read_error_from_line(p, packet->header.size - 1,
 										 packet->error_info.error,
 										 sizeof(packet->error_info.error),
@@ -2032,86 +1705,288 @@ static
 void php_mysqlnd_chg_user_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 {
 	if (!alloca) {
-		mnd_pefree(_packet, ((php_mysql_packet_chg_user_resp *)_packet)->header.persistent);
+		mnd_pefree(_packet, ((MYSQLND_PACKET_CHG_USER_RESPONSE *)_packet)->header.persistent);
 	}
 }
 /* }}} */
 
 
-/* {{{ packet_methods 
+/* {{{ packet_methods
  */
+static
 mysqlnd_packet_methods packet_methods[PROT_LAST] =
 {
 	{
-		sizeof(php_mysql_packet_greet),
+		sizeof(MYSQLND_PACKET_GREET),
 		php_mysqlnd_greet_read,
 		NULL, /* write */
 		php_mysqlnd_greet_free_mem,
 	}, /* PROT_GREET_PACKET */
 	{
-		sizeof(php_mysql_packet_auth),
+		sizeof(MYSQLND_PACKET_AUTH),
 		NULL, /* read */
 		php_mysqlnd_auth_write,
 		php_mysqlnd_auth_free_mem,
 	}, /* PROT_AUTH_PACKET */
 	{
-		sizeof(php_mysql_packet_ok),
+		sizeof(MYSQLND_PACKET_OK),
 		php_mysqlnd_ok_read, /* read */
 		NULL, /* write */
 		php_mysqlnd_ok_free_mem,
 	}, /* PROT_OK_PACKET */
 	{
-		sizeof(php_mysql_packet_eof),
+		sizeof(MYSQLND_PACKET_EOF),
 		php_mysqlnd_eof_read, /* read */
 		NULL, /* write */
 		php_mysqlnd_eof_free_mem,
 	}, /* PROT_EOF_PACKET */
 	{
-		sizeof(php_mysql_packet_command),
+		sizeof(MYSQLND_PACKET_COMMAND),
 		NULL, /* read */
 		php_mysqlnd_cmd_write, /* write */
 		php_mysqlnd_cmd_free_mem,
 	}, /* PROT_CMD_PACKET */
 	{
-		sizeof(php_mysql_packet_rset_header),
+		sizeof(MYSQLND_PACKET_RSET_HEADER),
 		php_mysqlnd_rset_header_read, /* read */
 		NULL, /* write */
 		php_mysqlnd_rset_header_free_mem,
 	}, /* PROT_RSET_HEADER_PACKET */
 	{
-		sizeof(php_mysql_packet_res_field),
+		sizeof(MYSQLND_PACKET_RES_FIELD),
 		php_mysqlnd_rset_field_read, /* read */
 		NULL, /* write */
 		php_mysqlnd_rset_field_free_mem,
 	}, /* PROT_RSET_FLD_PACKET */
 	{
-		sizeof(php_mysql_packet_row),
+		sizeof(MYSQLND_PACKET_ROW),
 		php_mysqlnd_rowp_read, /* read */
 		NULL, /* write */
 		php_mysqlnd_rowp_free_mem,
 	}, /* PROT_ROW_PACKET */
 	{
-		sizeof(php_mysql_packet_stats),
+		sizeof(MYSQLND_PACKET_STATS),
 		php_mysqlnd_stats_read, /* read */
 		NULL, /* write */
 		php_mysqlnd_stats_free_mem,
 	}, /* PROT_STATS_PACKET */
 	{
-		sizeof(php_mysql_packet_prepare_response),
+		sizeof(MYSQLND_PACKET_PREPARE_RESPONSE),
 		php_mysqlnd_prepare_read, /* read */
 		NULL, /* write */
 		php_mysqlnd_prepare_free_mem,
 	}, /* PROT_PREPARE_RESP_PACKET */
 	{
-		sizeof(php_mysql_packet_chg_user_resp),
+		sizeof(MYSQLND_PACKET_CHG_USER_RESPONSE),
 		php_mysqlnd_chg_user_read, /* read */
 		NULL, /* write */
 		php_mysqlnd_chg_user_free_mem,
-	} /* PROT_CHG_USER_PACKET */
+	} /* PROT_CHG_USER_RESP_PACKET */
 };
 /* }}} */
 
 
+
+/* {{{ mysqlnd_protocol::get_greet_packet */
+static struct st_mysqlnd_packet_greet *
+MYSQLND_METHOD(mysqlnd_protocol, get_greet_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_greet * packet = pecalloc(1, packet_methods[PROT_GREET_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_greet_packet");
+	packet->header.m = &packet_methods[PROT_GREET_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol::get_auth_packet */
+static struct st_mysqlnd_packet_auth *
+MYSQLND_METHOD(mysqlnd_protocol, get_auth_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_auth * packet = pecalloc(1, packet_methods[PROT_AUTH_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_auth_packet");
+	packet->header.m = &packet_methods[PROT_AUTH_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol::get_ok_packet */
+static struct st_mysqlnd_packet_ok *
+MYSQLND_METHOD(mysqlnd_protocol, get_ok_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_ok * packet = pecalloc(1, packet_methods[PROT_OK_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_ok_packet");
+	packet->header.m = &packet_methods[PROT_OK_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol::get_eof_packet */
+static struct st_mysqlnd_packet_eof *
+MYSQLND_METHOD(mysqlnd_protocol, get_eof_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_eof * packet = pecalloc(1, packet_methods[PROT_EOF_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_eof_packet");
+	packet->header.m = &packet_methods[PROT_EOF_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol::get_command_packet */
+static struct st_mysqlnd_packet_command *
+MYSQLND_METHOD(mysqlnd_protocol, get_command_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_command * packet = pecalloc(1, packet_methods[PROT_CMD_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_command_packet");
+	packet->header.m = &packet_methods[PROT_CMD_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol::get_rset_packet */
+static struct st_mysqlnd_packet_rset_header *
+MYSQLND_METHOD(mysqlnd_protocol, get_rset_header_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_rset_header * packet = pecalloc(1, packet_methods[PROT_RSET_HEADER_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_rset_header_packet");
+	packet->header.m = &packet_methods[PROT_RSET_HEADER_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol::get_result_field_packet */
+static struct st_mysqlnd_packet_res_field *
+MYSQLND_METHOD(mysqlnd_protocol, get_result_field_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_res_field * packet = pecalloc(1, packet_methods[PROT_RSET_FLD_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_result_field_packet");
+	packet->header.m = &packet_methods[PROT_RSET_FLD_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol::get_row_packet */
+static struct st_mysqlnd_packet_row *
+MYSQLND_METHOD(mysqlnd_protocol, get_row_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_row * packet = pecalloc(1, packet_methods[PROT_ROW_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_row_packet");
+	packet->header.m = &packet_methods[PROT_ROW_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol::get_stats_packet */
+static struct st_mysqlnd_packet_stats *
+MYSQLND_METHOD(mysqlnd_protocol, get_stats_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_stats * packet = pecalloc(1, packet_methods[PROT_STATS_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_stats_packet");
+	packet->header.m = &packet_methods[PROT_STATS_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol::get_prepare_response_packet */
+static struct st_mysqlnd_packet_prepare_response *
+MYSQLND_METHOD(mysqlnd_protocol, get_prepare_response_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_prepare_response * packet = pecalloc(1, packet_methods[PROT_PREPARE_RESP_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_prepare_response_packet");
+	packet->header.m = &packet_methods[PROT_PREPARE_RESP_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol::get_change_user_response_packet */
+static struct st_mysqlnd_packet_chg_user_resp*
+MYSQLND_METHOD(mysqlnd_protocol, get_change_user_response_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)
+{
+	struct st_mysqlnd_packet_chg_user_resp * packet = pecalloc(1, packet_methods[PROT_CHG_USER_RESP_PACKET].struct_size, persistent);
+	DBG_ENTER("mysqlnd_protocol::get_change_user_response_packet");
+	packet->header.m = &packet_methods[PROT_CHG_USER_RESP_PACKET];
+	packet->header.persistent = persistent;
+	DBG_RETURN(packet);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol_init */
+PHPAPI MYSQLND_PROTOCOL *
+mysqlnd_protocol_init(zend_bool persistent TSRMLS_DC)
+{
+	size_t alloc_size = sizeof(MYSQLND_PROTOCOL) + mysqlnd_plugin_count() * sizeof(void *);
+	MYSQLND_PROTOCOL *ret = mnd_pecalloc(1, alloc_size, persistent);
+
+	DBG_ENTER("mysqlnd_protocol_init");
+	DBG_INF_FMT("persistent=%d", persistent);
+	ret->persistent = persistent;
+
+	ret->m.get_greet_packet = MYSQLND_METHOD(mysqlnd_protocol, get_greet_packet);
+	ret->m.get_auth_packet = MYSQLND_METHOD(mysqlnd_protocol, get_auth_packet);
+	ret->m.get_ok_packet = MYSQLND_METHOD(mysqlnd_protocol, get_ok_packet);
+	ret->m.get_command_packet = MYSQLND_METHOD(mysqlnd_protocol, get_command_packet);
+	ret->m.get_eof_packet = MYSQLND_METHOD(mysqlnd_protocol, get_eof_packet);
+	ret->m.get_rset_header_packet = MYSQLND_METHOD(mysqlnd_protocol, get_rset_header_packet);
+	ret->m.get_result_field_packet = MYSQLND_METHOD(mysqlnd_protocol, get_result_field_packet);
+	ret->m.get_row_packet = MYSQLND_METHOD(mysqlnd_protocol, get_row_packet);
+	ret->m.get_stats_packet = MYSQLND_METHOD(mysqlnd_protocol, get_stats_packet);
+	ret->m.get_prepare_response_packet = MYSQLND_METHOD(mysqlnd_protocol, get_prepare_response_packet);
+	ret->m.get_change_user_response_packet = MYSQLND_METHOD(mysqlnd_protocol, get_change_user_response_packet);
+
+	DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_protocol_free */
+PHPAPI void
+mysqlnd_protocol_free(MYSQLND_PROTOCOL * const protocol TSRMLS_DC)
+{
+	zend_bool pers = protocol->persistent;
+
+	DBG_ENTER("mysqlnd_protocol_free");
+
+	if (protocol) {
+		mnd_pefree(protocol, pers);
+	}
+	DBG_VOID_RETURN;
+}
+/* }}} */
+
+
+/* {{{ _mysqlnd_plugin_get_plugin_protocol_data */
+PHPAPI void ** _mysqlnd_plugin_get_plugin_protocol_data(const MYSQLND_PROTOCOL * protocol, unsigned int plugin_id TSRMLS_DC)
+{
+	DBG_ENTER("_mysqlnd_plugin_get_plugin_protocol_data");
+	DBG_INF_FMT("plugin_id=%u", plugin_id);
+	if (!protocol || plugin_id >= mysqlnd_plugin_count()) {
+		return NULL;
+	}
+	DBG_RETURN((void *)((char *)protocol + sizeof(MYSQLND_PROTOCOL) + plugin_id * sizeof(void *)));
+}
+/* }}} */
+
+
 /*
  * Local variables:
  * tab-width: 4
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.h b/ext/mysqlnd/mysqlnd_wireprotocol.h
index df813fd..29116e0 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.h
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.h
@@ -18,28 +18,24 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_wireprotocol.h 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysqlnd_wireprotocol.h 293779 2010-01-20 17:09:28Z johannes $ */
 
 #ifndef MYSQLND_WIREPROTOCOL_H
 #define MYSQLND_WIREPROTOCOL_H
 
+#include "mysqlnd_net.h"
+
 #define MYSQLND_HEADER_SIZE 4
+#define COMPRESSED_HEADER_SIZE 3
 
 #define MYSQLND_NULL_LENGTH	(unsigned long) ~0
 
 /* Used in mysqlnd_debug.c */
-extern char * mysqlnd_read_header_name;
-extern char * mysqlnd_read_body_name;
+PHPAPI extern const char mysqlnd_read_header_name[];
+PHPAPI extern const char mysqlnd_read_body_name[];
 
 
 /* Packet handling */
-#define PACKET_INIT(packet, enum_type, c_type, pers)  \
-	{ \
-		packet = (c_type) pecalloc(1, packet_methods[(enum_type)].struct_size, (pers)); \
-		((c_type) (packet))->header.m = &packet_methods[(enum_type)]; \
-		((c_type) (packet))->header.persistent = (pers); \
-		DBG_INF_FMT("PACKET_INIT(%p, %d, %d)", packet, (int) enum_type, (int) pers); \
-	}
 #define PACKET_WRITE(packet, conn)	((packet)->header.m->write_to_net((packet), (conn) TSRMLS_CC))
 #define PACKET_READ(packet, conn)	((packet)->header.m->read_from_net((packet), (conn) TSRMLS_CC))
 #define PACKET_FREE(packet) \
@@ -48,69 +44,7 @@ extern char * mysqlnd_read_body_name;
 		((packet)->header.m->free_mem((packet), FALSE TSRMLS_CC)); \
 	} while (0);
 
-#define PACKET_INIT_ALLOCA(packet, enum_type)  \
-	{ \
-		memset(&(packet), 0, packet_methods[enum_type].struct_size); \
-		(packet).header.m = &packet_methods[enum_type]; \
-	}
-#define PACKET_WRITE_ALLOCA(packet, conn)	PACKET_WRITE(&(packet), (conn))
-#define PACKET_READ_ALLOCA(packet, conn)	PACKET_READ(&(packet), (conn))
-#define PACKET_FREE_ALLOCA(packet)			(packet.header.m->free_mem(&(packet), TRUE TSRMLS_CC))
-
-/* Enums */
-enum php_mysql_packet_type
-{
-	PROT_GREET_PACKET= 0,
-	PROT_AUTH_PACKET,
-	PROT_OK_PACKET,
-	PROT_EOF_PACKET,
-	PROT_CMD_PACKET,
-	PROT_RSET_HEADER_PACKET,
-	PROT_RSET_FLD_PACKET,
-	PROT_ROW_PACKET,
-	PROT_STATS_PACKET,
-	PROT_PREPARE_RESP_PACKET,
-	PROT_CHG_USER_PACKET,
-	PROT_LAST, /* should always be last */
-};
-
-
-enum php_mysqlnd_server_command
-{
-	COM_SLEEP = 0,
-	COM_QUIT,
-	COM_INIT_DB,
-	COM_QUERY,
-	COM_FIELD_LIST,
-	COM_CREATE_DB,
-	COM_DROP_DB,
-	COM_REFRESH,
-	COM_SHUTDOWN,
-	COM_STATISTICS,
-	COM_PROCESS_INFO,
-	COM_CONNECT,
-	COM_PROCESS_KILL,
-	COM_DEBUG,
-	COM_PING,
-	COM_TIME = 15,
-	COM_DELAYED_INSERT,
-	COM_CHANGE_USER,
-	COM_BINLOG_DUMP,
-	COM_TABLE_DUMP,
-	COM_CONNECT_OUT = 20,
-	COM_REGISTER_SLAVE,
-	COM_STMT_PREPARE = 22,
-	COM_STMT_EXECUTE = 23,
-	COM_STMT_SEND_LONG_DATA = 24,
-	COM_STMT_CLOSE = 25,
-	COM_STMT_RESET = 26,
-	COM_SET_OPTION = 27,
-	COM_STMT_FETCH = 28,
-	COM_DAEMON,
-	COM_END
-};
-
-extern const char * const mysqlnd_command_to_text[COM_END];
+PHPAPI extern const char * const mysqlnd_command_to_text[COM_END];
 
 /* Low-level extraction functionality */
 typedef struct st_mysqlnd_packet_methods {
@@ -120,19 +54,17 @@ typedef struct st_mysqlnd_packet_methods {
 	void				(*free_mem)(void *packet, zend_bool alloca TSRMLS_DC);
 } mysqlnd_packet_methods;
 
-extern mysqlnd_packet_methods packet_methods[];
-
 
 typedef struct st_mysqlnd_packet_header {
 	size_t		size;
 	mysqlnd_packet_methods *m;
 	zend_uchar	packet_no;
 	zend_bool	persistent;
-} mysqlnd_packet_header;
+} MYSQLND_PACKET_HEADER;
 
 /* Server greets the client */
-typedef struct st_php_mysql_packet_greet {
-	mysqlnd_packet_header		header;
+typedef struct st_mysqlnd_packet_greet {
+	MYSQLND_PACKET_HEADER		header;
 	uint8_t		protocol_version;
 	char		*server_version;
 	uint32_t	thread_id;
@@ -147,12 +79,12 @@ typedef struct st_php_mysql_packet_greet {
 	char 		error[MYSQLND_ERRMSG_SIZE+1];
 	char 		sqlstate[MYSQLND_SQLSTATE_LENGTH + 1];
 	unsigned int 	error_no;
-} php_mysql_packet_greet;
+} MYSQLND_PACKET_GREET;
 
 
 /* Client authenticates */
-typedef struct st_php_mysql_packet_auth {
-	mysqlnd_packet_header		header;
+typedef struct st_mysqlnd_packet_auth {
+	MYSQLND_PACKET_HEADER		header;
 	uint32_t	client_flags;
 	uint32_t	max_packet_size;
 	uint8_t	charset_no;
@@ -167,11 +99,11 @@ typedef struct st_php_mysql_packet_auth {
 	/* +1 for \0 because of scramble() */
 	unsigned char	*server_scramble_buf;
 	size_t			db_len;
-} php_mysql_packet_auth;
+} MYSQLND_PACKET_AUTH;
 
 /* OK packet */
-typedef struct st_php_mysql_packet_ok {
-	mysqlnd_packet_header		header;
+typedef struct st_mysqlnd_packet_ok {
+	MYSQLND_PACKET_HEADER		header;
 	uint8_t		field_count; /* always 0x0 */
 	uint64_t	affected_rows;
 	uint64_t	last_insert_id;
@@ -183,21 +115,21 @@ typedef struct st_php_mysql_packet_ok {
 	char 		error[MYSQLND_ERRMSG_SIZE+1];
 	char 		sqlstate[MYSQLND_SQLSTATE_LENGTH + 1];
 	unsigned int 	error_no;
-} php_mysql_packet_ok;
+} MYSQLND_PACKET_OK;
 
 
 /* Command packet */
-typedef struct st_php_mysql_packet_command {
-	mysqlnd_packet_header			header;
+typedef struct st_mysqlnd_packet_command {
+	MYSQLND_PACKET_HEADER			header;
 	enum php_mysqlnd_server_command	command;
 	const char						*argument;
 	size_t							arg_len;
-} php_mysql_packet_command;
+} MYSQLND_PACKET_COMMAND;
 
 
 /* EOF packet */
-typedef struct st_php_mysql_packet_eof {
-	mysqlnd_packet_header		header;
+typedef struct st_mysqlnd_packet_eof {
+	MYSQLND_PACKET_HEADER		header;
 	uint8_t		field_count; /* 0xFE */
 	uint16_t	warning_count;
 	uint16_t	server_status;
@@ -205,13 +137,13 @@ typedef struct st_php_mysql_packet_eof {
 	char 		error[MYSQLND_ERRMSG_SIZE+1];
 	char 		sqlstate[MYSQLND_SQLSTATE_LENGTH + 1];
 	unsigned int 	error_no;
-} php_mysql_packet_eof;
+} MYSQLND_PACKET_EOF;
 /* EOF packet */
 
 
 /* Result Set header*/
-typedef struct st_php_mysql_packet_rset_header {
-	mysqlnd_packet_header		header;
+typedef struct st_mysqlnd_packet_rset_header {
+	MYSQLND_PACKET_HEADER		header;
 	/*
 	  0x00 => ok
 	  ~0   => LOAD DATA LOCAL
@@ -231,25 +163,25 @@ typedef struct st_php_mysql_packet_rset_header {
 	char		*info_or_local_file;
 	size_t		info_or_local_file_len;
 	/* If error packet, we use these */
-	mysqlnd_error_info	error_info;
-} php_mysql_packet_rset_header;
+	MYSQLND_ERROR_INFO	error_info;
+} MYSQLND_PACKET_RSET_HEADER;
 
 
 /* Result set field packet */
-typedef struct st_php_mysql_packet_res_field {
-	mysqlnd_packet_header	header;
+typedef struct st_mysqlnd_packet_res_field {
+	MYSQLND_PACKET_HEADER	header;
 	MYSQLND_FIELD			*metadata;
 	/* For table definitions, empty for result sets */
 	zend_bool				skip_parsing;
 	zend_bool				stupid_list_fields_eof;
 
-	mysqlnd_error_info		error_info;
-} php_mysql_packet_res_field;
+	MYSQLND_ERROR_INFO		error_info;
+} MYSQLND_PACKET_RES_FIELD;
 
 
 /* Row packet */
-struct st_php_mysql_packet_row {
-	mysqlnd_packet_header	header;
+typedef struct st_mysqlnd_packet_row {
+	MYSQLND_PACKET_HEADER	header;
 	zval		**fields;
 	uint32_t	field_count;
 	zend_bool	eof;
@@ -261,6 +193,7 @@ struct st_php_mysql_packet_row {
 	uint16_t	server_status;
 
 	struct st_mysqlnd_memory_pool_chunk	*row_buffer;
+	MYSQLND_MEMORY_POOL * result_set_memory_pool;
 
 	zend_bool		skip_extraction;
 	zend_bool		binary_protocol;
@@ -271,22 +204,22 @@ struct st_php_mysql_packet_row {
 	size_t			bit_fields_total_len; /* trailing \0 not counted */
 
 	/* If error packet, we use these */
-	mysqlnd_error_info	error_info;
-};
+	MYSQLND_ERROR_INFO	error_info;
+} MYSQLND_PACKET_ROW;
 
 
 /* Statistics packet */
-typedef struct st_php_mysql_packet_stats {
-	mysqlnd_packet_header	header;
+typedef struct st_mysqlnd_packet_stats {
+	MYSQLND_PACKET_HEADER	header;
 	char *message;
 	/* message_len is not part of the packet*/
 	size_t message_len;
-} php_mysql_packet_stats;
+} MYSQLND_PACKET_STATS;
 
 
 /* COM_PREPARE response packet */
-typedef struct st_php_mysql_packet_prepare_response {
-	mysqlnd_packet_header	header;
+typedef struct st_mysqlnd_packet_prepare_response {
+	MYSQLND_PACKET_HEADER	header;
 	/* also known as field_count 0x00=OK , 0xFF=error */
 	unsigned char	error_code;
 	unsigned long	stmt_id;
@@ -295,42 +228,47 @@ typedef struct st_php_mysql_packet_prepare_response {
 	unsigned int	warning_count;
 
 	/* present in case of error */
-	mysqlnd_error_info	error_info;
-} php_mysql_packet_prepare_response;
+	MYSQLND_ERROR_INFO	error_info;
+} MYSQLND_PACKET_PREPARE_RESPONSE;
 
 
 /* Statistics packet */
-typedef struct st_php_mysql_packet_chg_user_resp {
-	mysqlnd_packet_header	header;
+typedef struct st_mysqlnd_packet_chg_user_resp {
+	MYSQLND_PACKET_HEADER	header;
 	uint32_t			field_count;
-	
+
 	/* message_len is not part of the packet*/
 	uint16_t			server_capabilities;
 	/* If error packet, we use these */
-	mysqlnd_error_info	error_info;
-} php_mysql_packet_chg_user_resp;
-
-
-size_t mysqlnd_stream_write(MYSQLND * const conn, char * const buf, size_t count TSRMLS_DC);
-size_t mysqlnd_stream_write_w_header(MYSQLND * const conn, char * const buf, size_t count TSRMLS_DC);
+	MYSQLND_ERROR_INFO	error_info;
+} MYSQLND_PACKET_CHG_USER_RESPONSE;
 
-#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND
-size_t php_mysqlnd_consume_uneaten_data(MYSQLND * const conn, enum php_mysqlnd_server_command cmd TSRMLS_DC);
-#endif
 
-void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const pass);
+PHPAPI void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const pass);
 
 unsigned long	php_mysqlnd_net_field_length(zend_uchar **packet);
 zend_uchar *	php_mysqlnd_net_store_length(zend_uchar *packet, uint64_t length);
 
-extern char * const mysqlnd_empty_string;
+PHPAPI extern char * const mysqlnd_empty_string;
 
 
 void php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields,
-										   unsigned int field_count, MYSQLND_FIELD *fields_metadata, MYSQLND *conn TSRMLS_DC);
+										 unsigned int field_count, MYSQLND_FIELD *fields_metadata,
+										 zend_bool persistent,
+										 zend_bool as_unicode, zend_bool as_int_or_float,
+										 MYSQLND_STATS * stats TSRMLS_DC);
+
 
 void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields,
-										 unsigned int field_count, MYSQLND_FIELD *fields_metadata, MYSQLND *conn TSRMLS_DC);
+										 unsigned int field_count, MYSQLND_FIELD *fields_metadata,
+										 zend_bool persistent,
+										 zend_bool as_unicode, zend_bool as_int_or_float,
+										 MYSQLND_STATS * stats TSRMLS_DC);
+
+
+PHPAPI MYSQLND_PROTOCOL * mysqlnd_protocol_init(zend_bool persistent TSRMLS_DC);
+PHPAPI void mysqlnd_protocol_free(MYSQLND_PROTOCOL * net TSRMLS_DC);
+
 
 #endif /* MYSQLND_WIREPROTOCOL_H */
 
diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c
index 1a5f929..8362a00 100644
--- a/ext/mysqlnd/php_mysqlnd.c
+++ b/ext/mysqlnd/php_mysqlnd.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_mysqlnd.c 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: php_mysqlnd.c 293779 2010-01-20 17:09:28Z johannes $ */
 #include "php.h"
 #include "php_ini.h"
 #include "mysqlnd.h"
@@ -45,14 +45,14 @@ PHPAPI void mysqlnd_minfo_print_hash(zval *values)
 
 	zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values);
 	while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values),
-										(void **)&values_entry, &pos_values) == SUCCESS) {
-		TSRMLS_FETCH();
+		(void **)&values_entry, &pos_values) == SUCCESS) {
 		zstr	string_key;
 		uint	string_key_len;
 		ulong	num_key;
 		int     s_len;
 		char 	*s = NULL;
 
+		TSRMLS_FETCH();
 		zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, &string_key_len, &num_key, 0, &pos_values);
 
 		convert_to_string(*values_entry);
@@ -69,7 +69,7 @@ PHPAPI void mysqlnd_minfo_print_hash(zval *values)
 	}
 }
 #else
-void mysqlnd_minfo_print_hash(zval *values)
+PHPAPI void mysqlnd_minfo_print_hash(zval *values)
 {
 	zval **values_entry;
 	HashPosition pos_values;
@@ -102,6 +102,12 @@ PHP_MINFO_FUNCTION(mysqlnd)
 	php_info_print_table_start();
 	php_info_print_table_header(2, "mysqlnd", "enabled");
 	php_info_print_table_row(2, "Version", mysqlnd_get_client_info());
+	php_info_print_table_row(2, "Compression",
+#ifdef MYSQLND_COMPRESSION_ENABLED
+								"supported");
+#else
+								"not supported");
+#endif
 	snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_cmd_buffer_size));
 	php_info_print_table_row(2, "Command buffer size", buf);
 	snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_buffer_size));
@@ -192,14 +198,14 @@ static PHP_MSHUTDOWN_FUNCTION(mysqlnd)
 /* }}} */
 
 
-#if defined(PHP_DEBUG) || defined(MYSQLND_THREADED)
+#if defined(PHP_DEBUG)
 /* {{{ PHP_RINIT_FUNCTION
  */
 static PHP_RINIT_FUNCTION(mysqlnd)
 {
 #if defined(PHP_DEBUG)
 	if (MYSQLND_G(debug)) {
-		MYSQLND_DEBUG *dbg = mysqlnd_debug_init(TSRMLS_C);
+		MYSQLND_DEBUG *dbg = mysqlnd_debug_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC);
 		if (!dbg) {
 			return FAILURE;
 		}
@@ -207,9 +213,6 @@ static PHP_RINIT_FUNCTION(mysqlnd)
 		MYSQLND_G(dbg) = dbg;
 	}
 #endif
-#ifdef MYSQLND_THREADED
-	MYSQLND_G(thread_id) = tsrm_thread_id();
-#endif
 	return SUCCESS;
 }
 /* }}} */
@@ -234,15 +237,23 @@ static PHP_RSHUTDOWN_FUNCTION(mysqlnd)
 #endif
 
 
+
+static const zend_module_dep mysqlnd_deps[] = {
+	ZEND_MOD_REQUIRED("standard")
+	{NULL, NULL, NULL}
+};
+
 /* {{{ mysqlnd_module_entry
  */
 zend_module_entry mysqlnd_module_entry = {
-	STANDARD_MODULE_HEADER,
+	STANDARD_MODULE_HEADER_EX,
+	NULL,
+	mysqlnd_deps,
 	"mysqlnd",
 	mysqlnd_functions,
 	PHP_MINIT(mysqlnd),
 	PHP_MSHUTDOWN(mysqlnd),
-#if defined(PHP_DEBUG) || defined(MYSQLND_THREADED)
+#if defined(PHP_DEBUG)
 	PHP_RINIT(mysqlnd),
 #else
 	NULL,
diff --git a/ext/mysqlnd/php_mysqlnd.h b/ext/mysqlnd/php_mysqlnd.h
index 44d0087..11232af 100644
--- a/ext/mysqlnd/php_mysqlnd.h
+++ b/ext/mysqlnd/php_mysqlnd.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 6                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Ulf Wendel <uw at php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: php_mysqlnd.h 272370 2008-12-31 11:15:49Z sebastian $ 
+  $Id: php_mysqlnd.h 293036 2010-01-03 09:23:27Z sebastian $ 
 */
 
 #ifndef PHP_MYSQLND_H
diff --git a/ext/oci8/README b/ext/oci8/README
index e725a30..037d549 100644
--- a/ext/oci8/README
+++ b/ext/oci8/README
@@ -1,454 +1,12 @@
-Installing OCI8
----------------
+The OCI8 Extension
+------------------
 
-0. Overview
-1. Common requirements
-2. Installing as a shared extension
-3. Installing as a statically compiled extension
-4. Installing from PECL to an existing PHP
-5. Testing OCI8
-6. Oracle DRCP and FAN Support
+The OCI8 extension allows PHP to access Oracle databases.  It can be
+built using Oracle 9.2, 10, or 11 client libraries. It allows Oracle's
+standard cross-version connectivity, for example PHP using Oracle 10.2
+libraries can connect to Oracle Database 9.2 onwards.
 
+This release of OCI8 can be used with PHP versions 4.3.9 to 5.x.
 
-0. Overview
------------
-
-The OCI8 extension allows you to access Oracle databases.  It can be
-built using Oracle 9.2, 10.2 or 11.1 client libraries, and allows
-Oracle's standard cross-version connectivity.  This release can be
-used with PHP versions 4.3.9 to 5.x.
-
-The OCI8 extension is not related to, or used by, PDO_OCI, the PHP
-Data Objects (PDO) extension for Oracle.
-
-1. Common requirements
-----------------------
-
-This version of PHP OCI8:
-
-  - Will build with Oracle 9.2 (or more recent) client libraries.  The
-    same (or more recent) version of Oracle libraries used when
-    building OCI8 must also be used at runtime.
-
-  - Can be used with PHP versions 4.3.9 to 5.x.
-
-If you build PHP with the "ORACLE_HOME" Oracle database or full Oracle
-client libraries:
-
-  - you MUST set at least the ORACLE_HOME environment variable and
-    make it visible for your web server BEFORE it starts.
-
-  - the Oracle software must be readable by the web server.  With
-    Oracle 10.2, see the $ORACLE_HOME/install/changePerm.sh script
-    included in patch releases.
-
-If you build PHP with Oracle Instant Client libraries from
-http://www.oracle.com/technology/tech/oci/instantclient/index.html
-
-  - either the "basic" or "basic-lite" package is required.
-
-  - the "devel" package is required.
-
-  - you don't have to set ORACLE_HOME and many of the other
-    environment variables to build PHP with OCI8 support.
-
-For both ORACLE_HOME and Instant Client installs you may have to set:
-
-  - LD_LIBRARY_PATH: it must include the $ORACLE_HOME/lib or Instant
-    Client library directory
-
-  - NLS_LANG: if you want to change the default encoding used during
-    interaction with Oracle servers
-
-The most appropriate places to add the environment variables are:
-
-  /etc/profile
-  /etc/profile.local
-  /etc/profile.d
-
-
-2. Installing as a shared extension
------------------------------------
-
-Configure OCI8 using one of the the following configure options:
-
-  a) if you use an Oracle server or Oracle Client installation:
-
-      ./configure --with-oci8=shared,$ORACLE_HOME
-
-  b) with Oracle Instant Client:
-
-      ./configure --with-oci8=shared,instantclient,/path/to/instant/client/lib
-
-    If you use an RPM-based installation of Oracle Instant Client,
-    your configure line will look like this:
-
-      ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/<version>/client/lib
-
-Follow the usual building procedure, e.g. "make install".  The OCI8
-shared extension oci8.so will be created.  It may need to be manually
-moved to the PHP extension directory, specified by the extension_dir
-option in your php.ini file.
-
-Edit php.ini file and add the line:
-
-  extension=oci8.so
-
-
-3. Installing as a statically compiled extension
-------------------------------------------------
-
-Configure OCI8 using one of the the following configure options:
-
-  a) with a common Oracle server or full Oracle client installation
-
-      ./configure --with-oci8=$ORACLE_HOME
-
-  b) with Oracle Instant Client
-
-      ./configure --with-oci8=instantclient,/path/to/instant/client/lib
-
-Run "make install".
-
-After successful compile, you do not need to add oci8.so to php.ini.
-The module will be usable without any additional actions.
-
-
-4. Installing from PECL to an existing PHP
-------------------------------------------
-
-The OCI8 extension is also available as a PECL module on
-http://pecl.php.net/package/oci8.
-
-Install using either (a) or (b) below.
-
-  a) Do an automated download and install:
-
-    Set PEARs proxy, if necessary:
-
-      pear config-set http_proxy http://my-proxy.example.com:80/
-
-    Run
-
-      pecl install oci8
-
-    When prompted, enter either the value of $ORACLE_HOME, or
-    "instantclient,/path/to/instant/client/lib" (without quotes).
-
-  b) Alternatively, manually download the PECL package, e.g. oci8-1.3.5.tgz
-
-     Extract the package:
-
-       tar -zxf oci8-1.3.5.tgz
-       cd oci8-1.3.5
-
-     Prepare the package:
-
-       phpize
-
-     Configure the package, either using $ORACLE_HOME or Instant Client
-
-       ./configure -with-oci8=shared,$ORACLE_HOME
-
-       or
-
-       ./configure -with-oci8=shared,instantclient,/path/to/instant/client/lib
-
-    Install the package:
-
-       make install
-
-After either install, edit your php.ini file, e.g. /etc/php.ini, and
-add the line:
-
-  extension=oci8.so
-
-Make sure php.ini's "extension_dir" includes the directory that
-oci8.so was installed in.
-
-
-5. Testing OCI8
----------------
-
-OCI8 tests are in ext/oci8/tests.  When OCI8 tests are run this
-directory will contain logs of any failures.
-
-5.1. Running OCI8 tests on Linux
-
-5.1.1. Edit ext/oci8/tests/details.inc
-
-  Set the username, password and connection string for the database.
-  Most tests have been developed using the SYSTEM account: some tests
-  might fail unless the user has permissions to create necessary
-  tables, views, procedures etc.
-
-  If the database is on the same machine as PHP, set
-  $oracle_on_localhost to TRUE.
-
-  If Oracle 11g Database Resident Connection Pooling is being tested,
-  set $test_drcp to TRUE and ensure the connection string uses an
-  appropriate pooled server (see section 6.2.2).
-
-  An alternative to editing details.inc is the set the environment
-  variables
-
-    PHP_OCI8_TEST_USER
-    PHP_OCI8_TEST_PASS
-    PHP_OCI8_TEST_DB
-    PHP_OCI8_TEST_DB_ON_LOCALHOST
-    PHP_OCI8_TEST_DRCP
-
-  for example:
-
-    $ export PHP_OCI8_TEST_USER=system
-    $ export PHP_OCI8_TEST_PASS=oracle
-    $ export PHP_OCI8_TEST_DB=localhost/XE
-    $ export PHP_OCI8_TEST_DB_ON_LOCALHOST=TRUE
-    $ export PHP_OCI8_TEST_DRCP=FALSE
-
-5.1.2. Set any necessary environment variables for the Oracle
-    database.  With Oracle 10g XE do:
-
-    $ . /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh
-
-  For other versions of the Oracle database do:
-
-    $ . /usr/local/bin/oraenv
-
-5.1.3. Check your php.ini has E in the variables_order parameter, for
-    example:
-
-    variables_order = "EGPCS"
-
-5.1.4. Run the tests:
-
-    $ cd <your php src directory>
-    $ make test TESTS=ext/oci8
-
-5.2. The tests execute rapidly.  On fast machines with a local
-  database configured for light load (e.g. Oracle 10g XE) you might
-  see random tests fail with ORA-12516 or ORA-12520 errors.  To
-  prevent this, increase the database PROCESSES parameter using the
-  following steps.
-
-5.2.1. Connect as the oracle software owner:
-
-    $ su - oracle
-
-5.2.2. Set the necessary environment variables as in 5.1.2.
-
-5.2.3. Start the SQL*Plus command line tool and increase PROCESSES
-
-    $ sqlplus / as sysdba
-    SQL> alter system set processes=100 scope=spfile
-
-5.2.4. Restart the database:
-
-    SQL> startup force
-
-
-6. Oracle DRCP and FAN Support
-------------------------------
-
-The PHP OCI8 extension has support for the Oracle Database Resident
-Connection Pool (DRCP) and Fast Application Notification (FAN).
-
-Questions and issues can be raised on the Oracle OTN forum (free
-registration required):
-http://www.oracle.com/technology/forums/php.html
-
-
-6.1. Oracle Version Compatibility
-
-The OCI8 extension will compile with Oracle libraries from version
-9iR2 onwards.  However, full functionality (e.g. DRCP support) is only
-available when Oracle 11g is used.
-
-For general database functionality the version of the Oracle libraries
-used by PHP does not necessarily have to match the version of the
-database.
-
-
-6.2. Database Resident Connection Pooling (DRCP)
-
-DRCP allows more efficient use of database machine memory and provides
-high scalability.
-
-For DRCP to be available in OCI8, Oracle client libraries used by PHP
-and the version of the Oracle Database must both be 11g.
-
-Documentation on DRCP is found in several Oracle manuals. For example,
-see "Configuring Database Resident Connection Pooling" in the Oracle
-Database Administrator's Guide 11g Release 1 (11.1)
-http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/manproc004.htm#CHDGIDBA
-for usage information.  A whitepaper
-http://www.oracle.com/technology/tech/oci/pdf/oracledrcp11g.pdf
-contains background information on DRCP.
-
-After building PHP with the OCI8 extension and 11g libraries, follow
-these steps:
-
-6.2.0 Important: if Oracle Database 11.1.0.6 with DRCP connections is
-    used, then the Oracle database patch for bug 6474441 must be
-    applied (see section 6.5).  Without this patch, "ORA-01000:
-    maximum open cursors exceeded", "ORA-01001 invalid cursor" or
-    "ORA-01002 fetch out of sequence" errors may occur.
-
-    If the Oracle 11.1.0.6 database patch cannot be applied, one of
-    the following three workarounds can be used to disable statement
-    caching instead:
-
-    (i) Connect using Oracle dedicated or shared servers instead of DRCP.
-
-    (ii) Set PHP's oci8.statement_cache_size to 0.
-
-    (iii) Set an event in the database initialization parameter file:
-    event="56699 trace name context forever, level 128".
-
-
-6.2.1. As a privileged database administrator, use a program like
-       SQL*Plus to start the connection pool in the database:
-
-        SQL> execute dbms_connection_pool.start_pool;
-
-     Optional settings control the size and characteristics of the
-     pool.
-
-6.2.2. For PHP applications that currently connect using a Network Alias
-       like:
-
-          $c = oci_pconnect("myuser", "mypassword", "MYDB");
-
-       Modify your tnsnames.ora file and add the "(SERVER=POOLED)"
-       clause, for example:
-
-          MYDB = (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=myhost.dom.com)
-                 (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales)
-                 (SERVER=POOLED)))
-
-     Alternatively, modify the Easy Connect syntax in PHP and add
-     ":POOLED" after the service name:
-
-          $c = oci_pconnect("myuser", "mypassword",
-                            "myhost.dom.com:1521/sales:POOLED");
-
-6.2.3. Edit php.ini and choose a connection class name.  This name
-       indicates a logical division of the connection pool and can be
-       used to isolate pooling for separate applications.  Any PHP
-       instance with the same connection class value will share
-       connections in the pool.
-
-          oci8.connection_class = "MY_APPLICATION_NAME"
-
-6.2.4. Run your application, connecting to the 11g database.
-
-
-6.3. Fast Application Notification (FAN) Support
-
-FAN support gives fast connection failover, a high availability
-feature.  This allows PHP OCI8 scripts to be notified when a database
-machine or database instance becomes unavailable.  Without FAN, OCI8
-can hang until a TCP timeout occurs and an error is returned, which
-might be several minutes.  Enabling FAN in OCI8 can allow your
-applications to detect errors and re-connect to an available database
-instance without the web user being aware of an outage.
-
-FAN support is available when the Oracle client libraries that PHP
-links with and the Oracle Database are either version 10gR2 or 11g.
-
-FAN benefits users of Oracle's clustering technology (RAC) because
-connections to surviving database instances can be immediately made.
-Users of Oracle's Data Guard with a broker will see the FAN events
-generated when the standby database goes online.  Standalone databases
-will send FAN events when the database restarts.
-
-For active connections, when a machine or database instance becomes
-unavailable, a connection failure error will be returned by the OCI8
-extension function currently being called.  On a subsequent PHP script
-re-connect, a connection to a surviving database instance will be
-established.  The OCI8 extension also transparently cleans up any idle
-connections affected by a database machine or instance failure so PHP
-connect calls will establish a fresh connection without the script
-being aware of any service disruption.
-
-When oci8.events is On, it is suggested to set oci8.ping_interval to
--1 to disable pinging, since enabling FAN events provide pro-active
-connection management of idle connections made invalid by a service
-disruption.
-
-To enable FAN support in PHP, after building PHP with Oracle 10gR2 or
-11g libraries follow these steps:
-
-6.3.1. As a privileged database administrator, use a program like
-       SQL*Plus to enable the database service to post FAN events, for
-       example:
-
-          SQL> execute dbms_service.modify_service(
-                 SERVICE_NAME        => 'sales',
-                 AQ_HA_NOTIFICATIONS => TRUE);
-
-6.3.2. Edit php.ini and add
-
-          oci8.events = On
-
-6.3.3. If your application does not already handle OCI8 error
-       conditions, modify it to detect failures and take appropriate
-       action.  This may include re-connecting and re-executing
-       statements.
-
-6.3.4. Run your application, connecting to a 10gR2 or 11g database.
-
-
-6.4. Recommendations and Known Limitations
-
-6.4.1 Changing Password for DRCP connections
-
-Changing a password over DRCP connections will fail with the error
-"ORA-56609: Usage not supported with DRCP".  This is an documented
-restriction of Oracle Database 11g.
-
-6.4.2 Closing Connections
-
-With the PHP OCI8 extension, persistent connections can now be closed
-by the user, allowing greater control over connection resource usage.
-Persistent connections will now also be closed automatically when
-there is no PHP variable referencing them, such as at the end of scope
-of a PHP user function.  This will rollback any uncommitted
-transaction.  These changes to persistent connections make them behave
-similarly to non-persistent connections, simplifying the interface,
-allowing for greater application consistency and predictability.  Use
-oci8.old_oci_close_semantics=1 to retain the historical behavior.
-
-6.4.3 LOGON Triggers can be used to set session properties
-
-The patch for Oracle Database 11.1.0.6 bug 6474441 (see section 6.5)
-allows PHP applications with DRCP connection to use a database LOGON
-trigger to set session properties at the time of session creation.
-Examples of such settings are the NLS language and the date format.
-
-If the Oracle 11.1.0.6 database patch cannot be applied, one of the
-following workarounds can be used:
-
-(i) After logon, explicitly set the session properties using PHP
-application code.
-
-(ii) Connect using Oracle dedicated or shared servers instead of DRCP.
-
-With DRCP there is an connection management relationship between (i)
-DRCP's automatic pool expansion and reduction, (ii) PHP's persistent
-connection caching, (iii) with the way LOGON triggers fire with DRCP
-authentication.  Because of this interplay, LOGON triggers in PHP
-(when DRCP is used) are only recommended for setting session
-attributes and not for per-PHP connection events.
-
-
-6.5. Patching Oracle Database 11g
-
-The patch for bug 6474441 is available from Oracle Support's Metalink
-system.
-
-The bug is specific to Oracle 11.1.0.6 with DRCP connections.  The
-issues it fixes do not affect connections using Oracle's dedicated
-(the default connection mode) or shared servers.  They do not affect
-earlier versions of Oracle.  The bug is intended to be fixed in Oracle
-Database 11.1.0.7 (as yet unreleased).
+OCI8 installation instructions and documentation is available at
+http://www.php.net/oci8
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index ec0ebdf..589b5fd 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -26,7 +26,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8.c 289423 2009-10-09 14:44:43Z pajoye $ */
+/* $Id: oci8.c 294447 2010-02-03 20:08:42Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -91,7 +91,7 @@ zend_class_entry *oci_coll_class_entry_ptr;
 #define SQLT_CFILEE 115
 #endif
 
-#define PHP_OCI_ERRBUF_LEN 512
+#define PHP_OCI_ERRBUF_LEN 1024
 
 #if ZEND_MODULE_API_NO > 20020429
 #define ONUPDATELONGFUNC OnUpdateLong
@@ -407,6 +407,30 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_prefetch, 0, 0, 2)
 	ZEND_ARG_INFO(0, number_of_rows)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_client_identifier, 0, 0, 2)
+	ZEND_ARG_INFO(0, connection_resource)
+	ZEND_ARG_INFO(0, client_identifier)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_edition, 0, 0, 1)
+	ZEND_ARG_INFO(0, edition_name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_module_name, 0, 0, 2)
+	ZEND_ARG_INFO(0, connection_resource)
+	ZEND_ARG_INFO(0, module_name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_action, 0, 0, 2)
+	ZEND_ARG_INFO(0, connection_resource)
+	ZEND_ARG_INFO(0, action)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_client_info, 0, 0, 2)
+	ZEND_ARG_INFO(0, connection_resource)
+	ZEND_ARG_INFO(0, client_information)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_password_change, 0, 0, 4)
 	ZEND_ARG_INFO(0, connection_resource_or_connection_string)
 	ZEND_ARG_INFO(0, username)
@@ -649,6 +673,11 @@ static unsigned char arginfo_oci_bind_array_by_name[] = { 3, BYREF_NONE, BYREF_N
 #define arginfo_oci_num_fields							NULL
 #define arginfo_oci_parse								NULL
 #define arginfo_oci_set_prefetch						NULL
+#define arginfo_oci_set_client_identifier				NULL
+#define arginfo_oci_set_edition							NULL
+#define arginfo_oci_set_module_name						NULL
+#define arginfo_oci_set_action							NULL
+#define arginfo_oci_set_client_info						NULL
 #define arginfo_oci_password_change						NULL
 #define arginfo_oci_new_cursor							NULL
 #define arginfo_oci_result								NULL
@@ -736,6 +765,11 @@ PHP_FUNCTION(oci_server_version);
 PHP_FUNCTION(oci_statement_type);
 PHP_FUNCTION(oci_num_rows);
 PHP_FUNCTION(oci_set_prefetch);
+PHP_FUNCTION(oci_set_client_identifier);
+PHP_FUNCTION(oci_set_edition);
+PHP_FUNCTION(oci_set_module_name);
+PHP_FUNCTION(oci_set_action);
+PHP_FUNCTION(oci_set_client_info);
 PHP_FUNCTION(oci_password_change);
 PHP_FUNCTION(oci_lob_save);
 PHP_FUNCTION(oci_lob_import);
@@ -834,6 +868,11 @@ zend_function_entry php_oci_functions[] = {
 	PHP_FE(oci_rollback,				arginfo_oci_rollback)
 	PHP_FE(oci_new_descriptor,			arginfo_oci_new_descriptor)
 	PHP_FE(oci_set_prefetch,			arginfo_oci_set_prefetch)
+	PHP_FE(oci_set_client_identifier,	arginfo_oci_set_client_identifier)
+	PHP_FE(oci_set_edition,				arginfo_oci_set_edition)
+	PHP_FE(oci_set_module_name,			arginfo_oci_set_module_name)
+	PHP_FE(oci_set_action,				arginfo_oci_set_action)
+	PHP_FE(oci_set_client_info,			arginfo_oci_set_client_info)
 	PHP_FE(oci_password_change,			arginfo_oci_password_change)
 	PHP_FE(oci_free_collection,			arginfo_oci_free_collection)
 	PHP_FE(oci_collection_append,		arginfo_oci_collection_append)
@@ -1128,6 +1167,7 @@ PHP_MINIT_FUNCTION(oci)
 	REGISTER_LONG_CONSTANT("OCI_CRED_EXT",PHP_OCI_CRED_EXT, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("OCI_DESCRIBE_ONLY",OCI_DESCRIBE_ONLY, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("OCI_COMMIT_ON_SUCCESS",OCI_COMMIT_ON_SUCCESS, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("OCI_NO_AUTO_COMMIT",OCI_DEFAULT, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("OCI_EXACT_FETCH",OCI_EXACT_FETCH, CONST_CS | CONST_PERSISTENT);
 
 /* for $LOB->seek() */
@@ -1210,6 +1250,7 @@ PHP_RINIT_FUNCTION(oci)
 	OCI_G(debug_mode) = 0; /* start "fresh" */
 	OCI_G(num_links) = OCI_G(num_persistent);
 	OCI_G(errcode) = 0;
+	OCI_G(edition) = NULL;
 
 	return SUCCESS;
 }
@@ -1238,6 +1279,10 @@ PHP_RSHUTDOWN_FUNCTION(oci)
 	 */
 	zend_hash_apply(&EG(persistent_list), (apply_func_t) php_oci_persistent_helper TSRMLS_CC);
 
+	if (OCI_G(edition)) {
+		efree(OCI_G(edition));
+	}
+
 	return SUCCESS;
 }
 
@@ -1248,7 +1293,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: 289423 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 294447 $");
 
 	snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent));
 	php_info_print_table_row(2, "Active Persistent Connections", buf);
@@ -1485,23 +1530,21 @@ void php_oci_descriptor_flush_hash_dtor(void *data)
 }
 /* }}} */
 
-/* {{{ php_oci_descriptor_delete_from_hash()
+/* }}} */
+
+/* {{{ php_oci_connection_descriptors_free()
  *
- * Delete descriptor from the hash
+ * Free descriptors for a connection
  */
-int php_oci_descriptor_delete_from_hash(void *data, void *id TSRMLS_DC)
+void php_oci_connection_descriptors_free(php_oci_connection *connection TSRMLS_DC)
 {
-	php_oci_descriptor *descriptor = *(php_oci_descriptor **)data;
-	int *desc_id = (int *) id;
-
-	if (descriptor && desc_id && descriptor->id == *desc_id) {
-		return 1;
-	}
-	return 0;
+	zend_hash_destroy(connection->descriptors);
+	efree(connection->descriptors);
+	connection->descriptors = NULL;
+	connection->descriptor_count = 0;
 }
 /* }}} */
 
-/* }}} */
 
 /* {{{ php_oci_error()
  *
@@ -1571,8 +1614,6 @@ sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC)
 	sb4 error_code = 0;
 	text err_buf[PHP_OCI_ERRBUF_LEN];
 
-	err_buf[0] = '\0';
-
 	memset(err_buf, 0, sizeof(err_buf));
 	PHP_OCI_CALL(OCIErrorGet, (error_handle, (ub4)1, NULL, &error_code, err_buf, (ub4)PHP_OCI_ERRBUF_LEN, (ub4)OCI_HTYPE_ERROR));
 
@@ -1735,6 +1776,12 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
 	}
 	smart_str_appendl_ex(&hashed_details, "**", sizeof("**") - 1, 0);
 
+	/* Add edition attribute to the hash */
+	if (OCI_G(edition)){
+		smart_str_appendl_ex(&hashed_details, OCI_G(edition), strlen(OCI_G(edition)), 0);
+	}
+	smart_str_appendl_ex(&hashed_details, "**", sizeof("**") - 1, 0);
+
 	if (password_len) {
 		ulong password_hash;
 		password_hash = zend_inline_hash_func(password, password_len);
@@ -2220,9 +2267,7 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC)
 	}
 
 	if (connection->descriptors) {
-		zend_hash_destroy(connection->descriptors);
-		efree(connection->descriptors);
-		connection->descriptors = NULL;
+		php_oci_connection_descriptors_free(connection TSRMLS_CC);
 	}
 
 	if (connection->svc) {
@@ -2555,6 +2600,7 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
 	php_oci_spool *session_pool = NULL;
 	zend_bool iserror = 0;
 	ub4 poolmode = OCI_DEFAULT;	/* Mode to be passed to OCISessionPoolCreate */
+	OCIAuthInfo *spoolAuth = NULL;
 
 	/*Allocate sessionpool out of persistent memory */
 	session_pool = (php_oci_spool *) calloc(1, sizeof(php_oci_spool));
@@ -2598,6 +2644,46 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
 	poolmode = OCI_SPC_HOMOGENEOUS;
 #endif
 
+#if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2)))
+	/* Allocate auth handle for session pool {{{ */
+	PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (session_pool->env, (dvoid **)&(spoolAuth), OCI_HTYPE_AUTHINFO, 0, NULL));
+
+	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 edition attribute on the auth handle {{{ */
+	if (OCI_G(edition)) {
+		PHP_OCI_CALL_RETURN(OCI_G(errcode),OCIAttrSet, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) OCI_G(edition), (ub4)(strlen(OCI_G(edition))), (ub4)OCI_ATTR_EDITION, 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;
+		}
+	} /* }}} */
+
+	/* Set the driver name attribute on the auth handle {{{ */
+	PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) PHP_OCI8_DRIVER_NAME, (ub4) sizeof(PHP_OCI8_DRIVER_NAME)-1, (ub4) OCI_ATTR_DRIVER_NAME, 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;
+	} /* }}} */
+
+	/* Set the auth handle on the session pool {{{ */
+	PHP_OCI_CALL_RETURN(OCI_G(errcode),OCIAttrSet, ((dvoid *) (session_pool->poolh),(ub4) OCI_HTYPE_SPOOL, (dvoid *) spoolAuth, (ub4)0, (ub4)OCI_ATTR_SPOOL_AUTH, 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;
+	} /* }}} */
+#endif
+
 	/* Create the homogeneous session pool - We have different session pools for every different
 	 * username, password, charset and dbname.
 	 */
@@ -2628,6 +2714,10 @@ exit_create_spool:
 		session_pool = NULL;
 	}
 
+	if (spoolAuth) {
+		PHP_OCI_CALL(OCIHandleFree, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO));
+	}
+
 	if (OCI_G(debug_mode)) {
 		php_printf ("OCI8 DEBUG L1: create_spool: (%p) at (%s:%d) \n", session_pool, __FILE__, __LINE__);
 	}
@@ -2652,6 +2742,11 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char *
 	smart_str_appendl_ex(&spool_hashed_details, "oci8spool***", sizeof("oci8spool***") - 1, 0);
 	smart_str_appendl_ex(&spool_hashed_details, username, username_len, 0);
 	smart_str_appendl_ex(&spool_hashed_details, "**", sizeof("**") - 1, 0);
+	/* Add edition attribute to the hash */
+	if (OCI_G(edition)){
+		smart_str_appendl_ex(&spool_hashed_details, OCI_G(edition), strlen(OCI_G(edition)), 0);
+	}
+	smart_str_appendl_ex(&spool_hashed_details, "**", sizeof("**") - 1, 0);
 	if (password_len) {
 		ulong password_hash;
 		password_hash = zend_inline_hash_func(password, password_len);
@@ -2666,7 +2761,7 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char *
 
 	smart_str_append_unsigned_ex(&spool_hashed_details, charsetid, 0);
 
-	/* Session Pool Hash Key : oci8spool***username**hashedpassword**dbname**charset */
+	/* Session Pool Hash Key : oci8spool***username**edition**hashedpassword**dbname**charset */
 
 	smart_str_0(&spool_hashed_details);
 	php_strtolower(spool_hashed_details.c, spool_hashed_details.len);
@@ -2803,6 +2898,28 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna
 		}
 	}/* }}} */
 
+	/* Set the edition attribute on the session handle {{{ */
+#if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2)))
+	if (OCI_G(edition)) {
+		PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) OCI_G(edition), (ub4) (strlen(OCI_G(edition))), (ub4) OCI_ATTR_EDITION, OCI_G(err)));
+
+		if (OCI_G(errcode) != OCI_SUCCESS) {
+			php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+			return 1;
+		}
+	}
+#endif /* }}} */
+
+	/* Set the driver name attribute on the session handle {{{ */
+#if (OCI_MAJOR_VERSION >= 11)
+	PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) PHP_OCI8_DRIVER_NAME, (ub4) sizeof(PHP_OCI8_DRIVER_NAME)-1, (ub4) OCI_ATTR_DRIVER_NAME, OCI_G(err)));
+
+	if (OCI_G(errcode) != OCI_SUCCESS) {
+		php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+		return 1;
+	}
+#endif /* }}} */
+
 	/* Set the server handle in the service handle {{{ */
 	PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, (connection->svc, OCI_HTYPE_SVCCTX, connection->server, 0, OCI_ATTR_SERVER, OCI_G(err)));
 
diff --git a/ext/oci8/oci8_collection.c b/ext/oci8/oci8_collection.c
index 7e514df..a06b61b 100644
--- a/ext/oci8/oci8_collection.c
+++ b/ext/oci8/oci8_collection.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8_collection.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: oci8_collection.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 
 
diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c
index b5ed501..1c20b84 100644
--- a/ext/oci8/oci8_interface.c
+++ b/ext/oci8/oci8_interface.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8_interface.c 276933 2009-03-09 20:20:07Z sixd $ */
+/* $Id: oci8_interface.c 294441 2010-02-03 19:37:35Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1066,9 +1066,7 @@ PHP_FUNCTION(oci_rollback)
 	PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
 
 	if (connection->descriptors) {
-		zend_hash_destroy(connection->descriptors);
-		efree(connection->descriptors);
-		connection->descriptors = NULL;
+		php_oci_connection_descriptors_free(connection TSRMLS_CC);
 	}
 
 	if (php_oci_connection_rollback(connection TSRMLS_CC)) {
@@ -1092,9 +1090,7 @@ PHP_FUNCTION(oci_commit)
 	PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
 
 	if (connection->descriptors) {
-		zend_hash_destroy(connection->descriptors);
-		efree(connection->descriptors);
-		connection->descriptors = NULL;
+		php_oci_connection_descriptors_free(connection TSRMLS_CC);
 	}
 	
 	if (php_oci_connection_commit(connection TSRMLS_CC)) {
@@ -1584,7 +1580,7 @@ PHP_FUNCTION(oci_pconnect)
    Return the last error of stmt|connection|global. If no error happened returns false. */
 PHP_FUNCTION(oci_error)
 {
-	zval *arg;
+	zval *arg = NULL;
 	php_oci_statement *statement;
 	php_oci_connection *connection;
 	text *errbuf;
@@ -1716,12 +1712,162 @@ PHP_FUNCTION(oci_set_prefetch)
 }
 /* }}} */
 
+/* {{{ proto bool oci_set_client_identifier(resource connection, string value)
+  Sets the client identifier attribute on the connection */
+PHP_FUNCTION(oci_set_client_identifier)
+{
+	zval *z_connection;
+	php_oci_connection *connection;
+	char *client_id;
+	long client_id_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_id, &client_id_len) == FAILURE) {
+		return;
+	}
+
+	PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
+
+	PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_id, (ub4) client_id_len, (ub4) OCI_ATTR_CLIENT_IDENTIFIER, OCI_G(err)));
+
+	if (OCI_G(errcode) != OCI_SUCCESS) {
+		php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+		RETURN_FALSE;
+	}
+
+	RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_edition(string value)
+  Sets the edition attribute for all subsequent connections created */
+PHP_FUNCTION(oci_set_edition)
+{
+#if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2)))
+	char *edition;
+	long edition_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &edition, &edition_len) == FAILURE) {
+		return;
+	}
+
+	if (OCI_G(edition)) {
+		efree(OCI_G(edition));
+		OCI_G(edition) = NULL;
+	}
+
+	if (edition) {
+		OCI_G(edition) = (char *)safe_emalloc(edition_len+1, sizeof(text), 0);
+		memcpy(OCI_G(edition), edition, edition_len);
+		OCI_G(edition)[edition_len] = '\0';
+	}
+
+	RETURN_TRUE;
+#else
+	php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
+	RETURN_FALSE;
+#endif
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_module_name(resource connection, string value)
+  Sets the module attribute on the connection */
+PHP_FUNCTION(oci_set_module_name)
+{
+#if (OCI_MAJOR_VERSION >= 10)
+	zval *z_connection;
+	php_oci_connection *connection;
+	char *module;
+	long module_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &module, &module_len) == FAILURE) {
+		return;
+	}
+
+	PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
+
+	PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) module, (ub4) module_len, (ub4) OCI_ATTR_MODULE, OCI_G(err)));
+
+	if (OCI_G(errcode) != OCI_SUCCESS) {
+		php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+		RETURN_FALSE;
+	}
+
+	RETURN_TRUE;
+#else
+	php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
+	RETURN_FALSE;
+#endif
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_action(resource connection, string value)
+  Sets the action attribute on the connection */
+PHP_FUNCTION(oci_set_action)
+{
+#if (OCI_MAJOR_VERSION >= 10)
+	zval *z_connection;
+	php_oci_connection *connection;
+	char *action;
+	long action_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &action, &action_len) == FAILURE) {
+		return;
+	}
+
+	PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
+
+	PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) action, (ub4) action_len, (ub4) OCI_ATTR_ACTION, OCI_G(err)));
+
+	if (OCI_G(errcode) != OCI_SUCCESS) {
+		php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+		RETURN_FALSE;
+	}
+
+	RETURN_TRUE;
+#else
+	php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
+	RETURN_FALSE;
+#endif
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_client_info(resource connection, string value)
+  Sets the client info attribute on the connection */
+PHP_FUNCTION(oci_set_client_info)
+{
+#if (OCI_MAJOR_VERSION >= 10)
+	zval *z_connection;
+	php_oci_connection *connection;
+	char *client_info;
+	long client_info_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_info, &client_info_len) == FAILURE) {
+		return;
+	}
+
+	PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
+
+	PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_info, (ub4) client_info_len, (ub4) OCI_ATTR_CLIENT_INFO, OCI_G(err)));
+
+	if (OCI_G(errcode) != OCI_SUCCESS) {
+		php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+		RETURN_FALSE;
+	}
+
+	RETURN_TRUE;
+#else
+	php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
+	RETURN_FALSE;
+#endif
+}
+/* }}} */
+
 /* {{{ proto bool oci_password_change(resource connection, string username, string old_password, string new_password)
   Changes the password of an account */
 PHP_FUNCTION(oci_password_change)
 {
 	zval *z_connection;
-	text *user, *pass_old, *pass_new, *dbname;
+	char *user, *pass_old, *pass_new, *dbname;
 	int user_len, pass_old_len, pass_new_len, dbname_len;
 	php_oci_connection *connection;
 
@@ -1747,7 +1893,7 @@ PHP_FUNCTION(oci_password_change)
 			RETURN_FALSE;
 		}
 
-		if (php_oci_password_change(connection, (char *)user, user_len, (char *)pass_old, pass_old_len, (char *)pass_new, pass_new_len TSRMLS_CC)) {
+		if (php_oci_password_change(connection, user, user_len, pass_old, pass_old_len, pass_new, pass_new_len TSRMLS_CC)) {
 			RETURN_FALSE;
 		}
 		RETURN_TRUE;
@@ -1766,7 +1912,7 @@ PHP_FUNCTION(oci_password_change)
 			RETURN_FALSE;
 		}
 
-		connection = php_oci_do_connect_ex((char *)user, user_len, (char *)pass_old, pass_old_len, (char *)pass_new, pass_new_len, (char *)dbname, dbname_len, NULL, OCI_DEFAULT, 0, 0 TSRMLS_CC);
+		connection = php_oci_do_connect_ex(user, user_len, pass_old, pass_old_len, pass_new, pass_new_len, dbname, dbname_len, NULL, OCI_DEFAULT, 0, 0 TSRMLS_CC);
 		if (!connection) {
 			RETURN_FALSE;
 		}
diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c
index 5211740..6388e85 100644
--- a/ext/oci8/oci8_lob.c
+++ b/ext/oci8/oci8_lob.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8_lob.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: oci8_lob.c 294441 2010-02-03 19:37:35Z pajoye $ */
 
 
 
@@ -95,9 +95,17 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ
 		if (!connection->descriptors) {
 			ALLOC_HASHTABLE(connection->descriptors);
 			zend_hash_init(connection->descriptors, 0, NULL, php_oci_descriptor_flush_hash_dtor, 0);
+			connection->descriptor_count = 0;
+		}
+		
+		descriptor->index = (connection->descriptor_count)++;
+		if (connection->descriptor_count == LONG_MAX) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Internal descriptor counter has reached limit");
+			php_oci_connection_descriptors_free(connection TSRMLS_CC);
+			return NULL;
 		}
 
-		zend_hash_next_index_insert(connection->descriptors,&descriptor,sizeof(php_oci_descriptor *),NULL);
+		zend_hash_index_update(connection->descriptors,descriptor->index,&descriptor,sizeof(php_oci_descriptor *),NULL);
 	}
 	return descriptor;
 
@@ -669,7 +677,25 @@ void php_oci_lob_free (php_oci_descriptor *descriptor TSRMLS_DC)
 
 	if (descriptor->connection->descriptors) {
 		/* delete descriptor from the hash */
-		zend_hash_apply_with_argument(descriptor->connection->descriptors, php_oci_descriptor_delete_from_hash, (void *)&descriptor->id TSRMLS_CC);
+		zend_hash_index_del(descriptor->connection->descriptors, descriptor->index);
+		if (zend_hash_num_elements(descriptor->connection->descriptors) == 0) {
+			descriptor->connection->descriptor_count = 0;
+		} else {
+			if (descriptor->index + 1 == descriptor->connection->descriptor_count) {
+				/* If the descriptor being freed is the end-most one
+				 * allocated, then the descriptor_count is reduced so
+				 * a future descriptor can reuse the hash table index.
+				 * This can prevent the hash index range increasing in
+				 * the common case that each descriptor is
+				 * allocated/used/freed before another descriptor is
+				 * needed.  However it is possible that a script frees
+				 * descriptors in arbitrary order which would prevent
+				 * descriptor_count ever being reduced to zero until
+				 * zend_hash_num_elements() returns 0.
+				 */
+				descriptor->connection->descriptor_count--;
+			}
+		}
 	}
 	
 	/* flushing Lobs & Files with buffering enabled */
diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c
index 00c6079..bdba6dc 100644
--- a/ext/oci8/oci8_statement.c
+++ b/ext/oci8/oci8_statement.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8_statement.c 277003 2009-03-11 16:47:14Z sixd $ */
+/* $Id: oci8_statement.c 294441 2010-02-03 19:37:35Z pajoye $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -93,10 +93,11 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha
 
 	statement->connection = connection;
 	statement->has_data = 0;
+	statement->has_descr = 0;
 	statement->parent_stmtid = 0;
 	zend_list_addref(statement->connection->rsrc_id);
 
-	if (OCI_G(default_prefetch) > 0) {
+	if (OCI_G(default_prefetch) >= 0) {
 		php_oci_statement_set_prefetch(statement, OCI_G(default_prefetch) TSRMLS_CC);
 	}
 	
@@ -114,8 +115,8 @@ int php_oci_statement_set_prefetch(php_oci_statement *statement, long size TSRML
 {
 	ub4 prefetch = size;
 
-	if (size < 1) {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of rows has to be greater than or equal to 1");
+	if (size < 0) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of rows to be prefetched has to be greater than or equal to 0");
 		return 1;
 	}
 	
@@ -131,6 +132,40 @@ int php_oci_statement_set_prefetch(php_oci_statement *statement, long size TSRML
 }
 /* }}} */
 
+/* {{{ php_oci_cleanup_pre_fetch()
+   Helper function to cleanup ref-cursors and descriptors from the previous row */
+int php_oci_cleanup_pre_fetch(void *data TSRMLS_DC)
+{
+	php_oci_out_column *outcol = data;
+
+	if (!outcol->is_descr && !outcol->is_cursor)
+		return ZEND_HASH_APPLY_KEEP;
+
+	switch(outcol->data_type) {
+		case SQLT_CLOB:
+		case SQLT_BLOB:
+		case SQLT_RDD:
+		case SQLT_BFILE:
+			if (outcol->descid) {
+				zend_list_delete(outcol->descid);
+				outcol->descid = 0;
+			}
+			break;
+		case SQLT_RSET:
+			if (outcol->stmtid) {
+				zend_list_delete(outcol->stmtid);
+				outcol->stmtid = 0;
+				outcol->nested_statement = NULL;
+			}
+			break;
+		default:
+			break;
+	}
+	return ZEND_HASH_APPLY_KEEP;
+
+} /* }}} */
+
+
 /* {{{ php_oci_statement_fetch()
  Fetch a row from the statement */
 int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC)
@@ -143,6 +178,10 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC)
 
 	php_oci_out_column *column;
 
+	if (statement->has_descr && statement->columns) {
+		zend_hash_apply(statement->columns, (apply_func_t) php_oci_cleanup_pre_fetch TSRMLS_CC);
+    }
+
 	PHP_OCI_CALL_RETURN(statement->errcode, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT));
 
 	if ( statement->errcode == OCI_NO_DATA || nrows == 0 ) {
@@ -413,7 +452,11 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
 		   we don't want to execute!!! */
 
 		if (statement->binds) {
-			zend_hash_apply(statement->binds, (apply_func_t) php_oci_bind_pre_exec TSRMLS_CC);
+			int result = 0;
+			zend_hash_apply_with_argument(statement->binds, (apply_func_arg_t) php_oci_bind_pre_exec, (void *)&result TSRMLS_CC);
+			if (result) {
+				return 1;
+			}
 		}
 
 		/* execute statement */
@@ -566,6 +609,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
 
 					define_type = SQLT_RSET;
 					outcol->is_cursor = 1;
+					outcol->statement->has_descr = 1;
 					outcol->storage_size4 = -1;
 					outcol->retlen = -1;
 					dynamic = OCI_DYNAMIC_FETCH;
@@ -579,6 +623,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
 
 					define_type = outcol->data_type;
 					outcol->is_descr = 1;
+					outcol->statement->has_descr = 1;
 					outcol->storage_size4 = -1;
 					dynamic = OCI_DYNAMIC_FETCH;
 					break;
@@ -763,10 +808,51 @@ void php_oci_statement_free(php_oci_statement *statement TSRMLS_DC)
 
 /* {{{ php_oci_bind_pre_exec()
  Helper function */
-int php_oci_bind_pre_exec(void *data TSRMLS_DC)
+int php_oci_bind_pre_exec(void *data, void *result TSRMLS_DC)
 {
 	php_oci_bind *bind = (php_oci_bind *) data;
+	*(int *)result = 0;
 
+	switch (bind->type) {
+		case SQLT_NTY:
+		case SQLT_BFILEE:
+		case SQLT_CFILEE:
+		case SQLT_CLOB:
+		case SQLT_BLOB:
+		case SQLT_RDD:
+			if (Z_TYPE_P(bind->zval) != IS_OBJECT) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+				*(int *)result = 1;
+			}
+			break;
+			
+		case SQLT_INT:
+		case SQLT_NUM:
+			if (Z_TYPE_P(bind->zval) == IS_RESOURCE || Z_TYPE_P(bind->zval) == IS_OBJECT) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+				*(int *)result = 1;
+			}
+			break;
+			
+		case SQLT_LBI:
+		case SQLT_BIN:
+		case SQLT_LNG:
+		case SQLT_AFC:
+		case SQLT_CHR:
+			if (Z_TYPE_P(bind->zval) == IS_RESOURCE || Z_TYPE_P(bind->zval) == IS_OBJECT) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+				*(int *)result = 1;
+			}
+			break;
+
+		case SQLT_RSET:
+			if (Z_TYPE_P(bind->zval) != IS_RESOURCE) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+				*(int *)result = 1;
+			}
+			break;
+	}
+	
 	/* reset all bind stuff to a normal state..-. */
 
 	bind->indicator = 0;
@@ -942,6 +1028,10 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
 			
 		case SQLT_INT:
 		case SQLT_NUM:
+			if (Z_TYPE_P(var) == IS_RESOURCE || Z_TYPE_P(var) == IS_OBJECT) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+				return 1;
+			}
 			convert_to_long(var);
 			bind_data = (ub4 *)&Z_LVAL_P(var);
 			value_sz = sizeof(ub4);
@@ -953,6 +1043,10 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
 		case SQLT_LNG:
 		case SQLT_AFC:
 		case SQLT_CHR: /* SQLT_CHR is the default value when type was not specified */
+			if (Z_TYPE_P(var) == IS_RESOURCE || Z_TYPE_P(var) == IS_OBJECT) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+				return 1;
+			}
 			if (Z_TYPE_P(var) != IS_NULL) {
 				convert_to_string(var);
 			}
@@ -964,6 +1058,10 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
 			break;
 
 		case SQLT_RSET:
+			if (Z_TYPE_P(var) != IS_RESOURCE) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+				return 1;
+			}
 			PHP_OCI_ZVAL_TO_STATEMENT_EX(var, bind_statement);
 			value_sz = sizeof(void*);
 
@@ -1003,6 +1101,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
 	bindp->statement = oci_stmt;
 	bindp->parent_statement = statement;
 	bindp->zval = var;
+	bindp->type = type;
 	zval_add_ref(&var);
 	
 	PHP_OCI_CALL_RETURN(statement->errcode,
diff --git a/ext/oci8/package.xml b/ext/oci8/package.xml
index 329d143..92faa15 100644
--- a/ext/oci8/package.xml
+++ b/ext/oci8/package.xml
@@ -6,7 +6,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
  <name>oci8</name>
  <channel>pecl.php.net</channel>
  <summary>Extension for Oracle Database</summary>
- <description>This extension allows you to access Oracle databases using the Oracle Call Interface (OCI8). It can be built with PHP 4.3.9 to 5.x.  It can be linked with Oracle 9.2, 10.2 or 11.1 client libraries.
+ <description>This extension allows you to access Oracle databases using the Oracle Call Interface (OCI8). It can be built with PHP 4.3.9 to 5.x.  It can be linked with Oracle 9.2, 10.2, 11.1, or 11.2 client libraries.
  </description>
  <lead>
   <name>Christopher Jones</name>
@@ -33,25 +33,21 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <active>no</active>
  </lead>
 
- <date>2009-03-16</date>
- <time>10:00:00</time>
+ <date>2010-??-??</date>
+ <time>15:00:00</time>
 
  <version>
-  <release>1.3.5</release>
-  <api>1.3.4</api>
+  <release>1.4.1</release>
+  <api>1.4.1</api>
  </version>
  <stability>
   <release>stable</release>
   <api>stable</api>
  </stability>
  <license uri="http://www.php.net/license">PHP</license>
- <notes>Fixed Bug #47243 (Crash at end of request shutdown on Windows)
-Fixed Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure)
-Fixed Bug #46623 (phpinfo doesn't show compile time ORACLE_HOME with phpize)
-Fixed bug #45458 (Numeric keys for associative arrays are not handled properly) Note: not fixed when building with PHP 4 due to lack of PHP internal helper.
-Fixed PECL Bug #16035 (oci_connect without ORACLE_HOME defined causes segfault)
-Fixed PECL Bug #15988 (sqlnet.ora isn't read with older Oracle libraries)
-Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Instant Client RPM install)
+ <notes>
+Fixed bug #49560 (Using LOBs causes slow PHP shutdown)
+Fixed bug #47281 ($php_errormsg is limited in size of characters)
  </notes>
  <contents>
   <dir name="/">
@@ -86,6 +82,7 @@ Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Inst
     <file name="bind_char_3.phpt" role="test" />
     <file name="bind_char_4.phpt" role="test" />
     <file name="bind_empty.phpt" role="test" />
+    <file name="bind_error.phpt" role="test" />
     <file name="bind_long.phpt" role="test" />
     <file name="bind_long_raw.phpt" role="test" />
     <file name="bind_raw.phpt" role="test" />
@@ -98,6 +95,7 @@ Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Inst
     <file name="bug35973.phpt" role="test" />
     <file name="bug36010.phpt" role="test" />
     <file name="bug36096.phpt" role="test" />
+    <file name="bug36403.phpt" role="test" />
     <file name="bug37220.phpt" role="test" />
     <file name="bug37581.phpt" role="test" />
     <file name="bug38161.phpt" role="test" />
@@ -120,6 +118,7 @@ Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Inst
     <file name="bug45458.phpt" role="test" />
     <file name="bug46994.phpt" role="test" />
     <file name="bug47189.phpt" role="test" />
+    <file name="bug47281.phpt" role="test" />
     <file name="bug6109.phpt" role="test" />
     <file name="close.phpt" role="test" />
     <file name="coll_001.phpt" role="test" />
@@ -156,6 +155,12 @@ Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Inst
     <file name="coll_019.phpt" role="test" />
     <file name="commit_old.phpt" role="test" />
     <file name="commit.phpt" role="test" />
+    <file name="conn_attr_1.phpt" role="test" />
+    <file name="conn_attr_2.phpt" role="test" />
+    <file name="conn_attr_3.phpt" role="test" />
+    <file name="conn_attr_4.phpt" role="test" />
+    <file name="conn_attr_5.phpt" role="test" />
+    <file name="conn_attr.inc" role="test" />
     <file name="connect_1_old.phpt" role="test" />
     <file name="connect_1.phpt" role="test" />
     <file name="connect.inc" role="test" />
@@ -207,8 +212,11 @@ Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Inst
     <file name="drcp_scope3.phpt" role="test" />
     <file name="drcp_scope4.phpt" role="test" />
     <file name="drcp_scope5.phpt" role="test" />
+    <file name="driver_name.phpt" role="test" />
     <file name="drop_table.inc" role="test" />
     <file name="drop_type.inc" role="test" />
+    <file name="edition_1.phpt" role="test" />
+    <file name="edition_2.phpt" role="test" />
     <file name="error1.phpt" role="test" />
     <file name="error2.phpt" role="test" />
     <file name="error_old.phpt" role="test" />
@@ -221,12 +229,15 @@ Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Inst
     <file name="extauth_04.phpt" role="test" />
     <file name="fetch_all2.phpt" role="test" />
     <file name="fetch_all3.phpt" role="test" />
+    <file name="fetch_all4.phpt" role="test" />
+    <file name="fetch_all5.phpt" role="test" />
     <file name="fetch_all.phpt" role="test" />
     <file name="fetch_array.phpt" role="test" />
     <file name="fetch_assoc.phpt" role="test" />
     <file name="fetch_into1.phpt" role="test" />
     <file name="fetch_into2.phpt" role="test" />
     <file name="fetch_into.phpt" role="test" />
+    <file name="fetch_object_2.phpt" role="test" />
     <file name="fetch_object.phpt" role="test" />
     <file name="fetch.phpt" role="test" />
     <file name="fetch_row.phpt" role="test" />
@@ -278,6 +289,7 @@ Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Inst
     <file name="lob_040.phpt" role="test" />
     <file name="lob_041.phpt" role="test" />
     <file name="lob_042.phpt" role="test" />
+    <file name="lob_043.phpt" role="test" />
     <file name="lob_aliases.phpt" role="test" />
     <file name="lob_null.phpt" role="test" />
     <file name="lob_temp1.phpt" role="test" />
@@ -297,12 +309,16 @@ Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Inst
     <file name="pecl_bug10194_blob.phpt" role="test" />
     <file name="pecl_bug10194.phpt" role="test" />
     <file name="pecl_bug16035.phpt" role="test" />
+    <file name="pecl_bug16842.phpt" role="test" />
     <file name="pecl_bug8816.phpt" role="test" />
     <file name="persistent.phpt" role="test" />
     <file name="prefetch_old.phpt" role="test" />
     <file name="prefetch.phpt" role="test" />
     <file name="privileged_connect1.phpt" role="test" />
     <file name="privileged_connect.phpt" role="test" />
+    <file name="refcur_prefetch_1.phpt" role="test" />
+    <file name="refcur_prefetch_2.phpt" role="test" />
+    <file name="refcur_prefetch_3.phpt" role="test" />
     <file name="reflection1.phpt" role="test" />
     <file name="reflection2.phpt" role="test" />
     <file name="rowid_bind.phpt" role="test" />
@@ -317,6 +333,7 @@ Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Inst
     <file name="test.txt" role="test" />
     <file name="uncommitted.phpt" role="test" />
     <file name="xmltype_01.phpt" role="test" />
+    <file name="xmltype_02.phpt" role="test" />
    </dir> <!-- //tests -->
    <file name="config.m4" role="src" />
    <file name="config.w32" role="src" />
@@ -352,6 +369,77 @@ Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Inst
 
 <release>
  <version>
+  <release>1.4.0</release>
+  <api>1.4.0</api>
+ </version>
+ <stability>
+  <release>alpha</release>
+  <api>alpha</api>
+ </stability>
+ <license uri="http://www.php.net/license">PHP</license>
+ <notes>
+    1. Introduce connection attribute functions:
+
+         oci_set_module_name
+         oci_set_action
+         oci_set_client_info
+         oci_set_client_identifier
+      
+       These set values that are visible/used by the database.  They
+       are useful for tracing, authentication and auditing.
+
+    2. Introduce connection attribute function:
+
+         oci_set_edition
+
+       Oracle 11g R2 "editions" allow multiple versions of DB objects
+       to exist at one time.  By setting different editions, two
+       different versions of an application can run concurrently,
+       making upgrading easier and faster.
+
+    3. Set the DRIVER_NAME attribute of Oracle Database 11gR2
+       connections to aid application tracing.  The value used is to
+       "PHP OCI8" followed by the OCI8 version number.  Note the
+       version number may get truncated in DB views such as
+       v$session_connect_info.
+
+    4. Allow the oci_set_prefetch value to be 0.  This is important in
+       some cases using REF CURSORS in Oracle 11gR2.
+
+    5. Introduce OCI_NO_AUTO_COMMIT as an alias for the OCI_DEFAULT
+       constant (which is not the default value) used by oci_execute().
+
+    6. Generate an error if an invalid resource type is used in
+       oci_bind_by_name
+
+    7. Bug fixes:
+       PECL bug #16842 (oci_error returns false when NO_DATA_FOUND is raised) 
+ </notes>
+</release>
+
+<release>
+ <version>
+  <release>1.3.5</release>
+  <api>1.3.4</api>
+ </version>
+ <stability>
+  <release>stable</release>
+  <api>stable</api>
+ </stability>
+ <license uri="http://www.php.net/license">PHP</license>
+ <notes>
+Fixed bug #47243 (Crash at end of request shutdown on Windows)
+Fixed bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure)
+Fixed bug #46623 (phpinfo doesn't show compile time ORACLE_HOME with phpize)
+Fixed bug #45458 (Numeric keys for associative arrays are not handled properly) Note: not fixed when building with PHP 4 due to lack of PHP internal helper.
+Fixed PECL bug #16035 (oci_connect without ORACLE_HOME defined causes segfault)
+Fixed PECL bug #15988 (sqlnet.ora isn't read with older Oracle libraries)
+Fixed PECL bug #14268 (Allow "pecl install oci8" command to "autodetect" an Instant Client RPM install)
+ </notes>
+</release>
+
+<release>
+ <version>
   <release>1.3.4</release>
   <api>1.3.4</api>
  </version>
diff --git a/ext/oci8/php_oci8.h b/ext/oci8/php_oci8.h
index bb4cfea..dfc6672 100644
--- a/ext/oci8/php_oci8.h
+++ b/ext/oci8/php_oci8.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_oci8.h 277243 2009-03-16 05:44:49Z sixd $ */
+/* $Id: php_oci8.h 294445 2010-02-03 20:00:49Z pajoye $ */
 
 #if HAVE_OCI8
 # ifndef PHP_OCI8_H
@@ -46,7 +46,7 @@
  */
 #undef PHP_OCI8_VERSION
 #endif
-#define PHP_OCI8_VERSION "1.3.5"
+#define PHP_OCI8_VERSION "1.4.1"
 
 extern zend_module_entry oci8_module_entry;
 #define phpext_oci8_ptr &oci8_module_entry
diff --git a/ext/oci8/php_oci8_int.h b/ext/oci8/php_oci8_int.h
index 6e8d565..eb59439 100644
--- a/ext/oci8/php_oci8_int.h
+++ b/ext/oci8/php_oci8_int.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_oci8_int.h 276935 2009-03-09 20:58:51Z sixd $ */
+/* $Id: php_oci8_int.h 294441 2010-02-03 19:37:35Z pajoye $ */
 
 #if HAVE_OCI8
 # ifndef PHP_OCI8_INT_H
@@ -101,6 +101,12 @@ extern zend_class_entry *oci_coll_class_entry_ptr;
 #error Invalid value for PHP_OCI_CRED_EXT
 #endif
 
+/*
+ * Name passed to Oracle for tracing.  Note some DB views only show
+ * the first nine characters of the driver name.
+ */
+#define PHP_OCI8_DRIVER_NAME "PHP OCI8 " PHP_OCI8_VERSION
+
 /* }}} */
 
 typedef struct { /* php_oci_spool {{{ */
@@ -124,6 +130,7 @@ typedef struct { /* php_oci_connection {{{ */
 	sword			errcode;					/* last errcode */
 
 	HashTable	   *descriptors;				/* descriptors hash, used to flush all the LOBs using this connection on commit */
+	ulong			descriptor_count;			/* used to index the descriptors hash table.  Not an accurate count */
 	unsigned		is_open:1;					/* hels to determine if the connection is dead or not */
 	unsigned		is_attached:1;				/* hels to determine if we should detach from the server when closing/freeing the connection */
 	unsigned		is_persistent:1;			/* self-descriptive */
@@ -140,6 +147,7 @@ typedef struct { /* php_oci_connection {{{ */
 
 typedef struct { /* php_oci_descriptor {{{ */
 	int					 id;
+	ulong				 index;		            /* descriptors hash table index */
 	php_oci_connection	*connection;			/* parent connection handle */
 	dvoid				*descriptor;			/* OCI descriptor handle */
 	ub4					 type;					/* descriptor type (FILE/LOB) */
@@ -191,6 +199,7 @@ typedef struct { /* php_oci_statement {{{ */
 	int					 ncolumns;				/* number of columns in the result */
 	unsigned			 executed:1;			/* statement executed flag */
 	unsigned			 has_data:1;			/* statement has more data flag */
+	unsigned			 has_descr:1;			/* statement has at least one descriptor or cursor column */
 	ub2					 stmttype;				/* statement type */
 } php_oci_statement; /* }}} */
 
@@ -200,6 +209,7 @@ typedef struct { /* php_oci_bind {{{ */
 	dvoid				*descriptor;			/* used for binding of LOBS etc */
 	OCIStmt				*statement;				/* used for binding REFCURSORs */
 	php_oci_statement	*parent_statement;		/* pointer to the parent statement */
+	ub2 type;						/* bind type */
 	struct {
 		void	*elements;
 		sb2		*indicators;
@@ -360,7 +370,8 @@ void php_oci_column_hash_dtor (void *data);
 void php_oci_define_hash_dtor (void *data);
 void php_oci_bind_hash_dtor (void *data);
 void php_oci_descriptor_flush_hash_dtor (void *data);
-int php_oci_descriptor_delete_from_hash(void *data, void *id TSRMLS_DC);
+
+void php_oci_connection_descriptors_free(php_oci_connection *connection TSRMLS_DC);
 
 sb4 php_oci_error (OCIError *, sword TSRMLS_DC);
 sb4 php_oci_fetch_errmsg(OCIError *, text ** TSRMLS_DC);
@@ -439,12 +450,13 @@ php_oci_out_column * php_oci_statement_get_column (php_oci_statement *, long, ch
 int php_oci_statement_execute (php_oci_statement *, ub4 TSRMLS_DC);
 int php_oci_statement_cancel (php_oci_statement * TSRMLS_DC);
 void php_oci_statement_free (php_oci_statement * TSRMLS_DC);
-int php_oci_bind_pre_exec(void *data TSRMLS_DC);
+int php_oci_bind_pre_exec(void *data, void *result TSRMLS_DC);
 int php_oci_bind_post_exec(void *data TSRMLS_DC);
 int php_oci_bind_by_name(php_oci_statement *, char *, int, zval*, long, ub2 TSRMLS_DC);
 sb4 php_oci_bind_in_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 *, ub1 *, dvoid **);
 sb4 php_oci_bind_out_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 **, ub1 *, dvoid **, ub2 **);
 php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAMETERS, int need_data);
+int php_oci_cleanup_pre_fetch(void *data TSRMLS_DC);
 
 int php_oci_statement_get_type(php_oci_statement *, ub2 * TSRMLS_DC);
 int php_oci_statement_get_numrows(php_oci_statement *, ub4 * TSRMLS_DC);
@@ -480,6 +492,7 @@ ZEND_BEGIN_MODULE_GLOBALS(oci) /* {{{ */
 	zend_bool	 in_call;
 	char		*connection_class;
 	zend_bool	 events;
+	char		*edition;
 ZEND_END_MODULE_GLOBALS(oci) /* }}} */
 
 #ifdef ZTS
diff --git a/ext/oci8/tests/bind_char_1.phpt b/ext/oci8/tests/bind_char_1.phpt
index d2dddc9..36574db 100644
--- a/ext/oci8/tests/bind_char_1.phpt
+++ b/ext/oci8/tests/bind_char_1.phpt
@@ -5,9 +5,9 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR
 if (!extension_loaded('oci8')) die ("skip no oci8 extension");
 require(dirname(__FILE__)."/connect.inc");
 $sv = oci_server_version($c);
-$sv = preg_match('/11.1/', $sv, $matches);
+$sv = preg_match('/Release 1[12]\./', $sv, $matches);
 if ($sv !== 1) {
-	die ("skip expected output only valid when using Oracle 11g database");
+	die ("skip expected output only valid when using Oracle 11g+ database");
 }
 ?>
 --FILE--
diff --git a/ext/oci8/tests/bind_char_2.phpt b/ext/oci8/tests/bind_char_2.phpt
index 183c09a..f0f4166 100644
--- a/ext/oci8/tests/bind_char_2.phpt
+++ b/ext/oci8/tests/bind_char_2.phpt
@@ -5,9 +5,9 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates
 if (!extension_loaded('oci8')) die ("skip no oci8 extension");
 require(dirname(__FILE__)."/connect.inc");
 $sv = oci_server_version($c);
-$sv = preg_match('/11.1/', $sv, $matches);
+$sv = preg_match('/Release 1[12]\./', $sv, $matches);
 if ($sv !== 1) {
-	die ("skip expected output only valid when using Oracle 11g database");
+	die ("skip expected output only valid when using Oracle 11g+ database");
 }
 ?>
 --FILE--
diff --git a/ext/oci8/tests/bind_char_3.phpt b/ext/oci8/tests/bind_char_3.phpt
index f1e6a93..6d1b311 100644
--- a/ext/oci8/tests/bind_char_3.phpt
+++ b/ext/oci8/tests/bind_char_3.phpt
@@ -5,9 +5,9 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter
 if (!extension_loaded('oci8')) die ("skip no oci8 extension");
 require(dirname(__FILE__)."/connect.inc");
 $sv = oci_server_version($c);
-$sv = preg_match('/11.1/', $sv, $matches);
+$sv = preg_match('/Release 1[12]\./', $sv, $matches);
 if ($sv !== 1) {
-	die ("skip expected output only valid when using Oracle 11g database");
+	die ("skip expected output only valid when using Oracle 11g+ database");
 }
 ?>
 --FILE--
diff --git a/ext/oci8/tests/bind_char_4.phpt b/ext/oci8/tests/bind_char_4.phpt
index ddd07dc..7377604 100644
--- a/ext/oci8/tests/bind_char_4.phpt
+++ b/ext/oci8/tests/bind_char_4.phpt
@@ -5,9 +5,9 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to VARCHAR2 parameter
 if (!extension_loaded('oci8')) die ("skip no oci8 extension");
 require(dirname(__FILE__)."/connect.inc");
 $sv = oci_server_version($c);
-$sv = preg_match('/11.1/', $sv, $matches);
+$sv = preg_match('/Release 1[12]\./', $sv, $matches);
 if ($sv !== 1) {
-	die ("skip expected output only valid when using Oracle 11g database");
+	die ("skip expected output only valid when using Oracle 11g+ database");
 }
 ?>
 --FILE--
diff --git a/ext/oci8/tests/bind_error.phpt b/ext/oci8/tests/bind_error.phpt
new file mode 100644
index 0000000..ad66ad5
--- /dev/null
+++ b/ext/oci8/tests/bind_error.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Test some oci_bind_by_name error conditions
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+$drop = "drop table bind_test";
+$statement = oci_parse($c, $drop);
+ at oci_execute($statement);
+
+$create = "create table bind_test(name varchar(10))";
+$statement = oci_parse($c, $create);
+oci_execute($statement);
+
+
+echo "Insert value\n";
+
+$name = 'abc';
+$stmt = oci_parse($c, "insert into bind_test values (:name)");
+oci_bind_by_name($stmt, ":name", $name, 10, SQLT_CHR);
+var_dump(oci_execute($stmt));
+
+echo "Test 1 - Assign a resource to the bind variable and execute \n";
+$name=$c;
+var_dump(oci_execute($stmt));
+
+echo "Test 2 - Re-bind a resource\n";
+oci_bind_by_name($stmt, ":name", $c);
+var_dump(oci_execute($stmt));
+var_dump($c);
+
+// Use a connection resource instead of a ROWID.
+echo "Test 3 - Resource mismatch !!\n";
+$stmt = oci_parse($c, "update bind_test set name='xyz' returning rowid into :r_id");
+oci_bind_by_name($stmt, ":r_id", $c);
+var_dump(oci_execute($stmt));
+
+// Clean up
+
+$drop = "drop table bind_test";
+$statement = oci_parse($c, $drop);
+ at oci_execute($statement);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Insert value
+bool(true)
+Test 1 - Assign a resource to the bind variable and execute 
+
+Warning: oci_execute(): Invalid variable used for bind in %s on line %d
+bool(false)
+Test 2 - Re-bind a resource
+
+Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
+
+Warning: oci_execute(): Invalid variable used for bind in %s on line %d
+bool(false)
+resource(%d) of type (oci8 connection)
+Test 3 - Resource mismatch !!
+
+Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
+
+Warning: oci_execute(): ORA-01008: %s on line %d
+bool(false)
+Done
diff --git a/ext/oci8/tests/bug26133.phpt b/ext/oci8/tests/bug26133.phpt
index df319fe..2463e70 100644
--- a/ext/oci8/tests/bug26133.phpt
+++ b/ext/oci8/tests/bug26133.phpt
@@ -5,30 +5,58 @@ Bug #26133 (ocifreedesc() segfault)
 --FILE--
 <?php
 
-    require dirname(__FILE__).'/connect.inc';
-    require dirname(__FILE__).'/create_table.inc';
-
-    if ($c) {
-        $ora_sql = "INSERT INTO 
-                               ".$schema.$table_name." (id, value) 
-                         VALUES ('1','1')
-                      RETURNING 
-                               ROWID 
-                           INTO :v_rowid ";
-                      
-        $statement = OCIParse($c,$ora_sql);
-        $rowid = OCINewDescriptor($c,OCI_D_ROWID);
-        OCIBindByName($statement,":v_rowid", $rowid,-1,OCI_B_ROWID);
-        if (OCIExecute($statement)) {
-            OCICommit($c);
-        }
-        OCIFreeStatement($statement);
-        $rowid->free();
-    }
-
-    require dirname(__FILE__).'/drop_table.inc';
-    
-    echo "Done\n";
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialize
+
+$stmtarray = array(
+    "drop table bug26133_tab",
+    "create table bug26133_tab (id number, value number)",
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
+// Run Test
+
+$ora_sql = "INSERT INTO bug26133_tab (id, value) VALUES ('1','1') RETURNING ROWID INTO :v_rowid ";
+
+$statement = OCIParse($c,$ora_sql);
+$rowid = OCINewDescriptor($c,OCI_D_ROWID);
+OCIBindByName($statement,":v_rowid", $rowid,-1,OCI_B_ROWID);
+if (OCIExecute($statement)) {
+    OCICommit($c);
+}
+OCIFreeStatement($statement);
+$rowid->free();
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table bug26133_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+                         
+echo "Done\n";
 ?>
 --EXPECT--
 Done
diff --git a/ext/oci8/tests/bug27303.phpt b/ext/oci8/tests/bug27303.phpt
index 2cc63d6..4dce844 100644
--- a/ext/oci8/tests/bug27303.phpt
+++ b/ext/oci8/tests/bug27303.phpt
@@ -5,9 +5,9 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters)
 if (!extension_loaded('oci8')) die ("skip no oci8 extension");
 require(dirname(__FILE__)."/connect.inc");
 $sv = oci_server_version($c);
-$sv = preg_match('/11.1/', $sv, $matches);
+$sv = preg_match('/Release 1[12]\./', $sv, $matches);
 if ($sv !== 1) {
-	die ("skip expected output only valid when using Oracle 11g database");
+	die ("skip expected output only valid when using Oracle 11g+ database");
 }
 ?>
 --FILE--
diff --git a/ext/oci8/tests/bug27303_2.phpt b/ext/oci8/tests/bug27303_2.phpt
index 3520b1e..63200ed 100644
--- a/ext/oci8/tests/bug27303_2.phpt
+++ b/ext/oci8/tests/bug27303_2.phpt
@@ -5,9 +5,9 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters)
 if (!extension_loaded('oci8')) die ("skip no oci8 extension");
 require(dirname(__FILE__)."/connect.inc");
 $sv = oci_server_version($c);
-$sv = preg_match('/11.1/', $sv, $matches);
+$sv = preg_match('/Release 1[12]\./', $sv, $matches);
 if ($sv !== 1) {
-	die ("skip expected output only valid when using Oracle 11g database");
+	die ("skip expected output only valid when using Oracle 11g+ database");
 }
 ?>
 --FILE--
diff --git a/ext/oci8/tests/bug27303_4.phpt b/ext/oci8/tests/bug27303_4.phpt
index f0c960e..031f0d1 100644
--- a/ext/oci8/tests/bug27303_4.phpt
+++ b/ext/oci8/tests/bug27303_4.phpt
@@ -5,9 +5,9 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters)
 if (!extension_loaded('oci8')) die ("skip no oci8 extension");
 require(dirname(__FILE__)."/connect.inc");
 $sv = oci_server_version($c);
-$sv = preg_match('/11.1/', $sv, $matches);
+$sv = preg_match('/Release 1[12]\./', $sv, $matches);
 if ($sv !== 1) {
-	die ("skip expected output only valid when using Oracle 11g database");
+	die ("skip expected output only valid when using Oracle 11g+ database");
 }
 ?>
 --FILE--
diff --git a/ext/oci8/tests/bug32325.phpt b/ext/oci8/tests/bug32325.phpt
index 00054f5..257c697 100644
--- a/ext/oci8/tests/bug32325.phpt
+++ b/ext/oci8/tests/bug32325.phpt
@@ -1,21 +1,37 @@
 --TEST--
-Bug #32325 (Can't retrieve collection using OCI8)
+Bug #32325 (Cannot retrieve collection using OCI8)
 --SKIPIF--
 <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
 --FILE--
 <?php
 
-require dirname(__FILE__).'/connect.inc';
-require dirname(__FILE__).'/create_table.inc';
-			
-$create_stmt = oci_parse($c, "create or replace type ut_num_list_t as table of number");
-oci_execute($create_stmt);
-
-$collection = oci_new_collection($c, "UT_NUM_LIST_T");
-
-$sql  = "
-        begin
-		select ut_num_list_t(1,2,3,4) into :list from dual;
+require(dirname(__FILE__).'/connect.inc');
+		
+// Initialize
+
+$stmtarray = array(
+    "create or replace type bug32325_t as table of number"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+				))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+// Run test
+	
+$collection = oci_new_collection($c, "BUG32325_T");
+
+$sql = "begin
+		select bug32325_t(1,2,3,4) into :list from dual;
 		end;";
 
 $stmt = oci_parse($c, $sql);
@@ -27,12 +43,20 @@ var_dump($collection->size());
 var_dump($collection->getelem(1));
 var_dump($collection->getelem(2));
 
-$drop_stmt = oci_parse($c, "drop type ut_num_list_t");
-oci_execute($drop_stmt);
+// Cleanup
+
+$stmtarray = array(
+    "drop type bug32325_t"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 echo "Done\n";
 ?>
---EXPECTF--	
+--EXPECT--	
 int(4)
 float(2)
 float(3)
diff --git a/ext/oci8/tests/bug36403.phpt b/ext/oci8/tests/bug36403.phpt
new file mode 100644
index 0000000..68c5f7b
--- /dev/null
+++ b/ext/oci8/tests/bug36403.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Bug #36403 (oci_execute no longer supports OCI_DESCRIBE_ONLY)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialization
+
+$stmtarray = array(
+	"drop table bug36403_tab",
+	"create table bug36403_tab (c1 number, col2 number, column3 number, col4 number)"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+				942 // table or view does not exist
+			,  2289 // sequence does not exist
+			,  4080 // trigger does not exist
+			, 38802 // edition does not exist
+				))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+// Run Test
+
+echo "Test 1\n";
+
+$s = oci_parse($c, "select * from bug36403_tab");
+oci_execute($s, OCI_DESCRIBE_ONLY);
+for ($i = oci_num_fields($s); $i > 0; $i--) {
+	echo oci_field_name($s, $i) . "\n";
+}
+
+echo "Test 2\n";
+
+// Should generate an error: ORA-24338: statement handle not executed
+// since the statement handle was only described and not executed
+$row = oci_fetch_array($s);
+
+// Clean up
+
+//require(dirname(__FILE__).'/drop_table.inc');
+
+$stmtarray = array(
+	"drop table bug36403_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1
+COL4
+COLUMN3
+COL2
+C1
+Test 2
+
+Warning: oci_fetch_array(): ORA-24338: %sbug36403.php on line %d
+===DONE===
diff --git a/ext/oci8/tests/bug43497.phpt b/ext/oci8/tests/bug43497.phpt
index 0fc6a97..1ea46b4 100644
--- a/ext/oci8/tests/bug43497.phpt
+++ b/ext/oci8/tests/bug43497.phpt
@@ -157,7 +157,7 @@ for ($i = 1; $i <= 10; $i++) {
     readxmltab_im($c);
 }
 
-echo "\nExplicit LOB with no free (i.e. a temp lob leak)\n";
+echo "\nExplicit LOB with no free\n";
 for ($i = 1; $i <= 10; $i++) {
     echo "\nRun              = " . $i . "\n";
     echo "Temporary LOBs   = " . templobs($c, $sid) . "\n";
@@ -259,45 +259,45 @@ Run              = 10
 Temporary LOBs   = 0
 Loop count check = 100
 
-Explicit LOB with no free (i.e. a temp lob leak)
+Explicit LOB with no free
 
 Run              = 1
 Temporary LOBs   = 0
 Loop count check = 100
 
 Run              = 2
-Temporary LOBs   = 99
+Temporary LOBs   = 0
 Loop count check = 100
 
 Run              = 3
-Temporary LOBs   = 198
+Temporary LOBs   = 0
 Loop count check = 100
 
 Run              = 4
-Temporary LOBs   = 297
+Temporary LOBs   = 0
 Loop count check = 100
 
 Run              = 5
-Temporary LOBs   = 396
+Temporary LOBs   = 0
 Loop count check = 100
 
 Run              = 6
-Temporary LOBs   = 495
+Temporary LOBs   = 0
 Loop count check = 100
 
 Run              = 7
-Temporary LOBs   = 594
+Temporary LOBs   = 0
 Loop count check = 100
 
 Run              = 8
-Temporary LOBs   = 693
+Temporary LOBs   = 0
 Loop count check = 100
 
 Run              = 9
-Temporary LOBs   = 792
+Temporary LOBs   = 0
 Loop count check = 100
 
 Run              = 10
-Temporary LOBs   = 891
+Temporary LOBs   = 0
 Loop count check = 100
 Done
diff --git a/ext/oci8/tests/bug47281.phpt b/ext/oci8/tests/bug47281.phpt
new file mode 100644
index 0000000..7102467
--- /dev/null
+++ b/ext/oci8/tests/bug47281.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Bug #47281 ($php_errormsg is limited in size of characters)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--ENV--
+NLS_LANG=.AL32UTF8
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialization
+
+$stmtarray = array(
+    "create or replace procedure bug47281_sp as
+    begin
+    raise_application_error(-20000, 
+        'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccDeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeFggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhIjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjKlllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllM');
+    end;"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+				942 // table or view does not exist
+			,  2289 // sequence does not exist
+			,  4080 // trigger does not exist
+			, 38802 // edition does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+// Run Test
+
+echo "Test 1\n";
+
+$s = oci_parse($c, 'begin bug47281_sp; end;');
+$r = @oci_execute($s);
+
+if (!$r) {
+    $m = oci_error($s);
+    echo $m['message'], "\n";
+}
+
+echo "Test 2\n";
+
+echo $php_errormsg. "\n";
+
+// Clean up
+
+$stmtarray = array(
+	"drop procedure bug47281_sp"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1
+ORA-20000: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccDeeeeeeeeeeee
+Test 2
+oci_execute(): ORA-20000: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+===DONE===
diff --git a/ext/oci8/tests/commit.phpt b/ext/oci8/tests/commit.phpt
index 3bef318..836d2cd 100644
--- a/ext/oci8/tests/commit.phpt
+++ b/ext/oci8/tests/commit.phpt
@@ -1,28 +1,36 @@
 --TEST--
-oci_commit()/oci_rollback()
+Test OCI_NO_AUTO_COMMIT constant
 --SKIPIF--
 <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
+require(dirname(__FILE__).'/create_table.inc');
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+$insert_sql = "insert into ".$schema.$table_name." (id, value) values (1,1)";
 
 if (!($s = oci_parse($c, $insert_sql))) {
 	die("oci_parse(insert) failed!\n");
 }
 
+/* check with OCI_NO_AUTO_COMMIT mode  */
+for ($i = 0; $i<3; $i++) {
+	if (!oci_execute($s, OCI_NO_AUTO_COMMIT)) {
+		die("oci_execute(insert) failed!\n");
+	}
+}
+
 for ($i = 0; $i<3; $i++) {
 	if (!oci_execute($s, OCI_DEFAULT)) {
 		die("oci_execute(insert) failed!\n");
 	}
 }
 
+
 var_dump(oci_rollback($c));
 
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+$select_sql = "select * from ".$schema.$table_name."";
 
 if (!($select = oci_parse($c, $select_sql))) {
 	die("oci_parse(select) failed!\n");
@@ -40,7 +48,7 @@ if (!oci_execute($s)) {
 	die("oci_execute(select) failed!\n");
 }
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+$insert_sql = "insert into ".$schema.$table_name." (id, value) values (1,1)";
 
 if (!($s = oci_parse($c, $insert_sql))) {
     die("oci_parse(insert) failed!\n");
@@ -62,56 +70,56 @@ var_dump(oci_fetch_all($select, $all));
 var_dump($all);
 
 
-require dirname(__FILE__).'/drop_table.inc';
+require(dirname(__FILE__).'/drop_table.inc');
 	
 echo "Done\n";
 ?>
---EXPECT--
+--EXPECTF--
 bool(true)
 int(0)
 array(5) {
-  ["ID"]=>
+  [%u|b%"ID"]=>
   array(0) {
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(0) {
   }
-  ["BLOB"]=>
+  [%u|b%"BLOB"]=>
   array(0) {
   }
-  ["CLOB"]=>
+  [%u|b%"CLOB"]=>
   array(0) {
   }
-  ["STRING"]=>
+  [%u|b%"STRING"]=>
   array(0) {
   }
 }
 bool(true)
 int(4)
 array(5) {
-  ["ID"]=>
+  [%u|b%"ID"]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %string|unicode%(1) "1"
     [1]=>
-    string(1) "1"
+    %string|unicode%(1) "1"
     [2]=>
-    string(1) "1"
+    %string|unicode%(1) "1"
     [3]=>
-    string(1) "1"
+    %string|unicode%(1) "1"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %string|unicode%(1) "1"
     [1]=>
-    string(1) "1"
+    %string|unicode%(1) "1"
     [2]=>
-    string(1) "1"
+    %string|unicode%(1) "1"
     [3]=>
-    string(1) "1"
+    %string|unicode%(1) "1"
   }
-  ["BLOB"]=>
+  [%u|b%"BLOB"]=>
   array(4) {
     [0]=>
     NULL
@@ -122,7 +130,7 @@ array(5) {
     [3]=>
     NULL
   }
-  ["CLOB"]=>
+  [%u|b%"CLOB"]=>
   array(4) {
     [0]=>
     NULL
@@ -133,7 +141,7 @@ array(5) {
     [3]=>
     NULL
   }
-  ["STRING"]=>
+  [%u|b%"STRING"]=>
   array(4) {
     [0]=>
     NULL
diff --git a/ext/oci8/tests/conn_attr.inc b/ext/oci8/tests/conn_attr.inc
new file mode 100644
index 0000000..2c086b1
--- /dev/null
+++ b/ext/oci8/tests/conn_attr.inc
@@ -0,0 +1,151 @@
+<?php
+
+require(dirname(__FILE__)."/connect.inc");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11\.2|12)\./', $sv, $matches);
+if ($sv == 1) {
+    // Server is Oracle 11.2+
+    $stmtarray = array(
+        "drop user testuser cascade",
+        "create user testuser identified by testuser",
+        "grant connect,resource,dba to testuser",
+        "alter user testuser enable editions",
+        "drop edition myedition1",
+        "drop edition myedition",
+        "grant create any edition to testuser",
+        "create edition myedition",
+        "create edition myedition1 as child of myedition",
+        "grant use on edition myedition to testuser",
+        "grant use on edition myedition1 to testuser",
+    );
+}
+else {
+    // Server is Pre 11.2 
+    $stmtarray = array(
+        "drop user testuser cascade",
+        "create user testuser identified by testuser",
+        "grant connect,resource,dba to testuser",
+    );
+}
+
+foreach ($stmtarray as $stmt) {
+    $s = oci_parse($c, $stmt);
+    $r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                        942 // table or view does not exist
+                     , 1918 // user does not exist 
+                     , 2289 // sequence does not exist
+                     , 4080 // trigger does not exist
+                    , 38802 // edition does not exist
+                ))) {
+			echo "Error:" . $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+            if ($m['code'] == 38807) {
+                echo "You appear to already have an edition in use that prevents this PHP test from running.  Query DBA_EDITIONS to see existing editions.". PHP_EOL;
+            }
+            die;
+		}
+	}
+}
+
+function get_attr($conn,$attr)
+{
+    $sel_stmt="select " .$attr. " from v\$session where sid = 
+	(select sid from v\$session where audsid = 
+	sys_context('userenv','sessionid')) order by 1";
+    $s2 = oci_parse($conn,$sel_stmt);
+    oci_execute($s2,OCI_DEFAULT);
+    while (oci_fetch($s2)) {
+        echo "The value of ".$attr ." is ".oci_result($s2,1)."\n";
+    }
+}
+
+/* Pass $conn_type=1 for a connection with oci_connect() 
+   Pass $conn_type=2 for ooci_pconnect 
+   Default will give a oci_new_connect */
+
+function get_conn($conn_type)
+{
+	$user = 'testuser';
+	$password = 'testuser';
+	$dbase = $GLOBALS['dbase'];
+	switch($conn_type) {
+        case 1:
+            echo "Testing with oci_connect()\n";
+            return(oci_connect($user,$password,$dbase));
+            break;
+        case 2:
+            echo "Testing with oci_pconnect()\n";
+            return(oci_pconnect($user,$password,$dbase));
+            break;
+        default:
+            echo "Testing with oci_new_connect()\n";
+            return(oci_new_connect($user,$password,$dbase));
+            break;
+	}
+}
+
+function set_attr($conn,$attr,$sufix)
+{
+	if (!strcmp($attr,'MODULE')) 
+		$r = oci_set_module_name($conn,'PHP TEST'.$sufix);
+	else if (!strcmp($attr,'ACTION')) 
+        $r = oci_set_action($conn,'TASK'.$sufix);
+	else if (!strcmp($attr,'CLIENT_INFO')) 
+        $r = oci_set_client_info($conn,'INFO1'.$sufix);
+	else if (!strcmp($attr,'CLIENT_IDENTIFIER')) 
+        $r = oci_set_client_identifier($conn,'ID00'.$sufix);
+	else
+		echo "Pass one of the above four attibutes!!!\n";
+	if ($r) {
+		echo "Value of $attr has been set successfully\n";
+    }
+    
+	//Do a round-trip here
+	oci_server_version($conn);
+	return $r;    
+}
+
+function set_edit_attr($value)
+{
+	$r = oci_set_edition($value);
+    if ($r) {
+		echo " The value of edition has been successfully set\n";
+    }
+	return $r;
+}
+
+function get_edit_attr ($conn) {
+	$sel_stmt = "select sys_context('USERENV', 'CURRENT_EDITION_NAME') from dual";
+    $s2 = oci_parse($conn,$sel_stmt);
+    oci_execute($s2,OCI_DEFAULT);
+    while (oci_fetch($s2)) {
+        echo "The value of current EDITION is ".oci_result($s2,1)."\n";
+    }
+}
+
+function get_sys_attr($conn,$attr)
+{
+	$sel_stmt="select " .$attr. " from v\$session where sid = 
+	(select sid from v\$session where audsid = sys_context('userenv','sessionid')) order by 1";
+    $s2 = oci_parse($conn,$sel_stmt);
+    oci_execute($s2,OCI_DEFAULT);
+    while (oci_fetch($s2)) {
+        echo "The value of ".$attr ." is ".oci_result($s2,1)."\n";
+    }
+}
+
+function clean_up($c) {
+	$stmtarray = array(
+        "drop user testuser cascade",
+        "drop edition myedition1",
+        "drop edition myedition",
+	);
+    
+	foreach ($stmtarray as $stmt) {
+        $s = oci_parse($c, $stmt);
+        @oci_execute($s);
+	}
+}
diff --git a/ext/oci8/tests/conn_attr_1.phpt b/ext/oci8/tests/conn_attr_1.phpt
new file mode 100644
index 0000000..c7c1b87
--- /dev/null
+++ b/ext/oci8/tests/conn_attr_1.phpt
@@ -0,0 +1,104 @@
+--TEST--
+Set and get of connection attributes with all types of connections.
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys"))
+    die("skip needs to be run as a DBA user");
+if ($test_drcp) die("skip output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 10g or greater client ");
+    }
+}
+else {
+    die ("skip test expected to work only with Oracle 10g or greater server");
+}
+
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/conn_attr.inc");
+
+$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER');
+
+echo"**Test 1.1 - Default values for the attributes **************\n";
+$c = get_conn(1);
+foreach($attr_array as $attr) {
+        get_attr($c,$attr);
+}
+
+echo"**Test 1.2 - Set and get values for the attributes **************\n";
+
+// With oci_connect, oci_pconnect, oci_new_connect
+
+$conn1 = get_conn(1); //oci_connect()
+foreach($attr_array as $attr) {
+	set_attr($conn1,$attr,1);
+    get_attr($conn1,$attr);
+}
+
+$conn2 = get_conn(2); //oci_pconnect()
+foreach($attr_array as $attr) {
+	set_attr($conn2,$attr,2);
+    get_attr($conn2,$attr);
+}
+
+$conn3 = get_conn(3); //oci_new_connect()
+foreach($attr_array as $attr) {
+	set_attr($conn3,$attr,3);
+    get_attr($conn3,$attr);
+}
+
+// clean up
+oci_close($conn1);
+oci_close($conn2);
+oci_close($conn3);
+clean_up($c);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+**Test 1.1 - Default values for the attributes **************
+Testing with oci_connect()
+The value of MODULE is %s
+The value of ACTION is 
+The value of CLIENT_INFO is 
+The value of CLIENT_IDENTIFIER is 
+**Test 1.2 - Set and get values for the attributes **************
+Testing with oci_connect()
+Value of MODULE has been set successfully
+The value of MODULE is PHP TEST1
+Value of ACTION has been set successfully
+The value of ACTION is TASK1
+Value of CLIENT_INFO has been set successfully
+The value of CLIENT_INFO is INFO11
+Value of CLIENT_IDENTIFIER has been set successfully
+The value of CLIENT_IDENTIFIER is ID001
+Testing with oci_pconnect()
+Value of MODULE has been set successfully
+The value of MODULE is PHP TEST2
+Value of ACTION has been set successfully
+The value of ACTION is TASK2
+Value of CLIENT_INFO has been set successfully
+The value of CLIENT_INFO is INFO12
+Value of CLIENT_IDENTIFIER has been set successfully
+The value of CLIENT_IDENTIFIER is ID002
+Testing with oci_new_connect()
+Value of MODULE has been set successfully
+The value of MODULE is PHP TEST3
+Value of ACTION has been set successfully
+The value of ACTION is TASK3
+Value of CLIENT_INFO has been set successfully
+The value of CLIENT_INFO is INFO13
+Value of CLIENT_IDENTIFIER has been set successfully
+The value of CLIENT_IDENTIFIER is ID003
+Done
diff --git a/ext/oci8/tests/conn_attr_2.phpt b/ext/oci8/tests/conn_attr_2.phpt
new file mode 100644
index 0000000..4765d5e
--- /dev/null
+++ b/ext/oci8/tests/conn_attr_2.phpt
@@ -0,0 +1,111 @@
+--TEST--
+Set and get of connection attributes across persistent connections and sysdba connection.
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
+if ($test_drcp) die("skip output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 10g or greater version of client");
+    }
+}
+else {
+    die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--INI--
+oci8.privileged_connect = On
+--FILE--
+
+<?php
+require(dirname(__FILE__)."/conn_attr.inc");
+$user='testuser';
+$password='testuser';
+$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER');
+
+echo"**Set values using pconnect-1**\n";
+
+var_dump($pc1 = oci_pconnect($user,$password,$dbase));
+foreach($attr_array as $attr) {
+	set_attr($pc1,$attr,100);
+}
+
+//  using pc1 again
+echo"\n**Get values using pconnect-2**\n";
+var_dump($pc3 = oci_pconnect($user,$password,$dbase));
+foreach($attr_array as $attr) {
+	get_attr($pc3,$attr);
+}
+
+// Get with different pconnect
+echo"\n**Get values using pconnect-3**\n";
+var_dump($pc2 = oci_pconnect($user,$password,$dbase,'UTF8'));
+foreach($attr_array as $attr) {
+	get_attr($pc2,$attr);
+}
+
+oci_close($pc1);
+oci_close($pc2);
+oci_close($pc3);
+
+// Re-open a persistent connection and check for the attr values.
+echo "\n**Re-open a pconnect()**\n";
+var_dump($pc4 = oci_pconnect($user,$password,$dbase));
+foreach($attr_array as $attr) {
+	get_attr($pc4,$attr);
+}
+oci_close($pc4);
+
+// Test with SYSDBA connection.
+var_dump($sys_c1 = oci_pconnect($user,$password,$dbase,false,OCI_SYSDBA));
+if ($sys_c1) {
+	set_attr($sys_c1,'ACTION',10);
+	get_sys_attr($sys_c1,'ACTION');
+	get_attr($pc2,'ACTION');
+	oci_close($sys_c1);
+}
+
+clean_up($c);
+
+echo "Done\n";
+?>
+--EXPECTF--
+**Set values using pconnect-1**
+resource(%d) of type (oci8 persistent connection)
+Value of MODULE has been set successfully
+Value of ACTION has been set successfully
+Value of CLIENT_INFO has been set successfully
+Value of CLIENT_IDENTIFIER has been set successfully
+
+**Get values using pconnect-2**
+resource(%d) of type (oci8 persistent connection)
+The value of MODULE is PHP TEST100
+The value of ACTION is TASK100
+The value of CLIENT_INFO is INFO1100
+The value of CLIENT_IDENTIFIER is ID00100
+
+**Get values using pconnect-3**
+resource(%d) of type (oci8 persistent connection)
+The value of MODULE is %s
+The value of ACTION is 
+The value of CLIENT_INFO is 
+The value of CLIENT_IDENTIFIER is 
+
+**Re-open a pconnect()**
+resource(%d) of type (oci8 persistent connection)
+The value of MODULE is PHP TEST100
+The value of ACTION is TASK100
+The value of CLIENT_INFO is INFO1100
+The value of CLIENT_IDENTIFIER is ID00100
+
+Warning: oci_pconnect(): ORA-01031: %s on line %d
+bool(false)
+Done
diff --git a/ext/oci8/tests/conn_attr_3.phpt b/ext/oci8/tests/conn_attr_3.phpt
new file mode 100644
index 0000000..8b6d921
--- /dev/null
+++ b/ext/oci8/tests/conn_attr_3.phpt
@@ -0,0 +1,94 @@
+--TEST--
+Set and get of connection attributes with oci_close().
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
+if ($test_drcp) die("skip output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 10g or greater version of client");
+    }
+}
+else {
+    die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/conn_attr.inc");
+
+echo"**Test Set and get values for  the attributes with oci_close() ************\n";
+// With oci_connect ,oci_pconnect ,oci_new_connect
+
+var_dump($conn1 = get_conn(1)); //oci_connect()
+set_attr($conn1,'ACTION',1);
+get_attr($conn1,'ACTION');
+oci_close($conn1);
+
+// Open another connect and verify the value.
+var_dump($conn1 = get_conn(1)); //oci_connect()
+get_attr($conn1,'ACTION');
+oci_close($conn1);
+
+var_dump($pconn1 = get_conn(2)); //oci_pconnect()
+set_attr($pconn1,'MODULE',2);
+get_attr($pconn1,'MODULE');
+oci_close($pconn1);
+
+// Open another connect and verify the value.
+var_dump($pconn1 = get_conn(2)); //oci_pconnect()
+get_attr($pconn1,'MODULE');
+oci_close($pconn1);
+
+var_dump($nconn1 = get_conn(3)); //oci_new_connect()
+set_attr($nconn1,'CLIENT_INFO',3);
+set_attr($nconn1,'CLIENT_IDENTIFIER',3);
+get_attr($nconn1,'CLIENT_INFO');
+get_attr($nconn1,'CLIENT_IDENTIFIER');
+oci_close($nconn1);
+
+// Open another connect and verify the value.
+var_dump($nconn1 = get_conn(3)); //oci_new_connect()
+get_attr($nconn1,'CLIENT_INFO');
+get_attr($nconn1,'CLIENT_IDENTIFIER');
+oci_close($nconn1);
+
+clean_up($c);
+echo "Done\n";
+
+?>
+--EXPECTF--
+**Test Set and get values for  the attributes with oci_close() ************
+Testing with oci_connect()
+resource(%d) of type (oci8 connection)
+Value of ACTION has been set successfully
+The value of ACTION is TASK1
+Testing with oci_connect()
+resource(%d) of type (oci8 connection)
+The value of ACTION is 
+Testing with oci_pconnect()
+resource(%d) of type (oci8 persistent connection)
+Value of MODULE has been set successfully
+The value of MODULE is PHP TEST2
+Testing with oci_pconnect()
+resource(%d) of type (oci8 persistent connection)
+The value of MODULE is PHP TEST2
+Testing with oci_new_connect()
+resource(%d) of type (oci8 connection)
+Value of CLIENT_INFO has been set successfully
+Value of CLIENT_IDENTIFIER has been set successfully
+The value of CLIENT_INFO is INFO13
+The value of CLIENT_IDENTIFIER is ID003
+Testing with oci_new_connect()
+resource(%d) of type (oci8 connection)
+The value of CLIENT_INFO is 
+The value of CLIENT_IDENTIFIER is 
+Done
diff --git a/ext/oci8/tests/conn_attr_4.phpt b/ext/oci8/tests/conn_attr_4.phpt
new file mode 100644
index 0000000..2ef2673
--- /dev/null
+++ b/ext/oci8/tests/conn_attr_4.phpt
@@ -0,0 +1,121 @@
+--TEST--
+Set and get of connection attributes with errors.
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
+if ($test_drcp) die("skip output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 10g or greater version of client");
+    }
+}
+else {
+    die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/conn_attr.inc");
+
+$user='testuser';
+$password='testuser';
+$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER');
+
+echo"**Test  Negative cases************\n";
+
+echo "\nInvalid Connection resource\n";
+$nc1=NULL;
+// Invalid connection handle.
+var_dump(oci_set_action($nc1,$nc1));
+
+// Variable instead of a connection resource.
+echo "\nInvalid Connection resource 2\n";
+$str1= 'not a conn';
+var_dump(oci_set_client_info($str1,$str1));
+
+// Setting an Invalid value.
+echo "\nInvalid Value \n";
+$c1=oci_connect($user,$password,$dbase);
+var_dump(oci_set_action($c1,$c1));
+
+// Setting values multiple times.
+echo "\nSet Values multiple times \n";
+var_dump(oci_set_action($c1,'ACTION1'));
+var_dump(oci_set_action($c1,'ACTION1'));
+var_dump(oci_set_action($c1,'ACTION2'));
+var_dump(oci_set_action($c1,'ACTION1'));
+get_attr($c1,'ACTION');
+
+// Testing with different types of values
+echo "\nSetting to different values \n";
+$values_array = array(1000,NULL,'this is a very huge string with a length  > 64 !!!!!this is a very huge string with a length  > 64 !!!!!this is a very huge string with a length  > 64 !!!!!this is a very huge string with a length  > 64 !!!!!');
+
+foreach($values_array as $val ) {
+	oci_set_module_name($c1,$val);
+	oci_set_client_identifier($c1,$val);
+	oci_set_client_info($c1,$val);
+	$r = oci_set_action($c1,$val);	
+	if ($r) {
+		echo "Values set succesfully to $val\n";
+		foreach($attr_array as $attr) {
+            get_attr($c1,$attr);
+        }
+	}
+}
+
+clean_up($c);
+echo "Done\n";
+?>
+--EXPECTF--
+**Test  Negative cases************
+
+Invalid Connection resource
+
+Warning: oci_set_action() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Invalid Connection resource 2
+
+Warning: oci_set_client_info() expects parameter 1 to be resource, %s given in %s on line %d
+NULL
+
+Invalid Value 
+
+Warning: oci_set_action() expects parameter 2 to be %s, resource given in %s on line %d
+NULL
+
+Set Values multiple times 
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+The value of ACTION is ACTION1
+
+Setting to different values 
+Values set succesfully to 1000
+The value of MODULE is 1000
+The value of ACTION is 1000
+The value of CLIENT_INFO is 1000
+The value of CLIENT_IDENTIFIER is 1000
+Values set succesfully to 
+The value of MODULE is 
+The value of ACTION is 
+The value of CLIENT_INFO is 
+The value of CLIENT_IDENTIFIER is 
+
+Warning: oci_set_module_name(): ORA-24960: %s OCI_ATTR_MODULE %s on line %d
+
+Warning: oci_set_client_identifier(): ORA-24960: %s OCI_ATTR_CLIENT_IDENTIFIER %s on line %d
+
+Warning: oci_set_client_info(): ORA-24960: %s OCI_ATTR_CLIENT_INFO %s on line %d
+
+Warning: oci_set_action(): ORA-24960: %s OCI_ATTR_ACTION %s on line %d
+Done
diff --git a/ext/oci8/tests/conn_attr_5.phpt b/ext/oci8/tests/conn_attr_5.phpt
new file mode 100644
index 0000000..9f6b6c7
--- /dev/null
+++ b/ext/oci8/tests/conn_attr_5.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Set and get connection attributes with scope end.
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
+if ($test_drcp) die("skip output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 10g or greater version of client");
+    }
+}
+else {
+    die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/conn_attr.inc");
+
+echo"**Test - Set and get values for the attributes with scope end ************\n";
+
+// Set the attributes in one scope and verify the values from another scope.
+set_scope();
+
+echo "Get the Values from a different scope \n";
+get_scope();
+
+function set_scope() {
+    $conn1 = get_conn(1);
+    set_attr($conn1,'CLIENT_INFO',50);
+    set_attr($conn1,'CLIENT_IDENTIFIER',50);
+    $conn2 = get_conn(3);
+    set_attr($conn2,'ACTION',50);
+    $conn3 = get_conn(2);
+    set_attr($conn3,'MODULE',50);
+    
+}
+
+function get_scope() {
+    $conn1 = get_conn(1);
+    get_attr($conn1,'CLIENT_INFO');
+    get_attr($conn1,'CLIENT_IDENTIFIER');
+    $conn2 = get_conn(3);
+    get_attr($conn2,'ACTION');
+    $conn3 = get_conn(2);
+    get_attr($conn3,'MODULE');
+}
+clean_up($c);
+echo "Done";
+?>
+--EXPECTF--
+**Test - Set and get values for the attributes with scope end ************
+Testing with oci_connect()
+Value of CLIENT_INFO has been set successfully
+Value of CLIENT_IDENTIFIER has been set successfully
+Testing with oci_new_connect()
+Value of ACTION has been set successfully
+Testing with oci_pconnect()
+Value of MODULE has been set successfully
+Get the Values from a different scope 
+Testing with oci_connect()
+The value of CLIENT_INFO is 
+The value of CLIENT_IDENTIFIER is 
+Testing with oci_new_connect()
+The value of ACTION is 
+Testing with oci_pconnect()
+The value of MODULE is PHP TEST50
+Done
diff --git a/ext/oci8/tests/cursor_bind_err.phpt b/ext/oci8/tests/cursor_bind_err.phpt
index 267c4d9..33bd04b 100644
--- a/ext/oci8/tests/cursor_bind_err.phpt
+++ b/ext/oci8/tests/cursor_bind_err.phpt
@@ -5,26 +5,39 @@ binding a cursor (with errors)
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__)."/create_table.inc";
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table cursor_bind_err_tab",
+    "create table cursor_bind_err_tab (id number, value number)",
+    "insert into cursor_bind_err_tab (id, value) values (1,1)",
+    "insert into cursor_bind_err_tab (id, value) values (1,1)",
+    "insert into cursor_bind_err_tab (id, value) values (1,1)",
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-$sql = "select CURSOR(select * from ".$schema.$table_name.") into :cursor from dual";
+// Run Test
+
+$sql = "select cursor(select * from cursor_bind_err_tab) into :cursor from dual";
 $stmt = oci_parse($c, $sql);
 
 $cursor = oci_new_cursor($c);
@@ -35,14 +48,23 @@ oci_execute($stmt);
 oci_execute($cursor);
 var_dump(oci_fetch_assoc($cursor));
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table cursor_bind_err_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
 --EXPECTF--
-Warning: oci_bind_by_name(): ORA-01036: illegal variable name/number in %s on line %d
+Warning: oci_bind_by_name(): ORA-01036: %s in %s on line %d
 
-Warning: oci_fetch_assoc(): ORA-24338: statement handle not executed in %s on line %d
+Warning: oci_fetch_assoc(): ORA-24338: %s in %s on line %d
 bool(false)
 Done
diff --git a/ext/oci8/tests/cursors_old.phpt b/ext/oci8/tests/cursors_old.phpt
index cf3b5f9..73447c8 100644
--- a/ext/oci8/tests/cursors_old.phpt
+++ b/ext/oci8/tests/cursors_old.phpt
@@ -5,26 +5,39 @@ fetching cursor from a statement
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__)."/create_table.inc";
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+// Initialize
 
-if (!($s = ociparse($c, $insert_sql))) {
-	die("ociparse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table cursors_old_tab",
+    "create table cursors_old_tab (id number, value number)",
+    "insert into cursors_old_tab (id, value) values (1,1)",
+    "insert into cursors_old_tab (id, value) values (1,1)",
+    "insert into cursors_old_tab (id, value) values (1,1)",
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!ociexecute($s)) {
-		die("ociexecute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                        942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!ocicommit($c)) {
-	die("ocicommit() failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-$sql = "select CURSOR(select * from ".$schema.$table_name.") as curs FROM dual";
+// Run Test
+
+$sql = "select cursor(select * from cursors_old_tab) as curs from dual";
 $stmt = ociparse($c, $sql);
 
 ociexecute($stmt);
@@ -39,26 +52,35 @@ while ($result = ocifetchinto($stmt, $data, OCI_ASSOC)) {
 	var_dump(ocicancel($data["CURS"]));
 }
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table cursors_old_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
 --EXPECTF--
 array(2) {
-  ["ID"]=>
-  string(1) "1"
-  ["VALUE"]=>
-  string(1) "1"
+  [%u|b%"ID"]=>
+  %unicode|string%(1) "1"
+  [%u|b%"VALUE"]=>
+  %unicode|string%(1) "1"
 }
 bool(true)
 
-Warning: ocifetchinto():%sORA-01002: fetch out of sequence in %scursors_old.php on line %d
+Warning: ocifetchinto():%sORA-01002: %s in %scursors_old.php on line %d
 array(2) {
-  ["ID"]=>
-  string(1) "1"
-  ["VALUE"]=>
-  string(1) "1"
+  [%u|b%"ID"]=>
+  %unicode|string%(1) "1"
+  [%u|b%"VALUE"]=>
+  %unicode|string%(1) "1"
 }
 bool(true)
 Done
diff --git a/ext/oci8/tests/debug.phpt b/ext/oci8/tests/debug.phpt
index cdd56a0..49e3d4c 100644
--- a/ext/oci8/tests/debug.phpt
+++ b/ext/oci8/tests/debug.phpt
@@ -6,9 +6,9 @@ if (!extension_loaded('oci8')) die("skip no oci8 extension");
 ob_start();
 phpinfo(INFO_MODULES);
 $phpinfo = ob_get_clean();
-$iv = preg_match('/Oracle .*Version => 11/', $phpinfo);
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
 if ($iv !== 1) {
-	die ("skip expected output only valid when using Oracle 11g client libraries");
+   	die ("skip expected output only valid when using Oracle 11gR2+ client libraries");
 }
 ?>
 --FILE--
@@ -34,8 +34,12 @@ 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) 
@@ -44,7 +48,7 @@ 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: (%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) 
diff --git a/ext/oci8/tests/default_prefetch.phpt b/ext/oci8/tests/default_prefetch.phpt
index cc02b6a..47191c8 100644
--- a/ext/oci8/tests/default_prefetch.phpt
+++ b/ext/oci8/tests/default_prefetch.phpt
@@ -7,26 +7,39 @@ oci8.default_prefetch=20
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table default_prefetch_tab",
+    "create table default_prefetch_tab (id number, value number)",
+    "insert into default_prefetch_tab (id, value) values (1,1)",
+    "insert into default_prefetch_tab (id, value) values (1,1)",
+    "insert into default_prefetch_tab (id, value) values (1,1)",
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+// Run Test
+
+$select_sql = "select * from default_prefetch_tab";
 
 if (!($s = oci_parse($c, $select_sql))) {
 	die("oci_parse(select) failed!\n");
@@ -40,7 +53,17 @@ var_dump(oci_fetch($s));
 
 var_dump(oci_num_rows($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+// Cleanup
+
+$stmtarray = array(
+    "drop table default_prefetch_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+	
 	
 echo "Done\n";
 ?>
diff --git a/ext/oci8/tests/default_prefetch1.phpt b/ext/oci8/tests/default_prefetch1.phpt
index aa130e9..bcd66fa 100644
--- a/ext/oci8/tests/default_prefetch1.phpt
+++ b/ext/oci8/tests/default_prefetch1.phpt
@@ -7,26 +7,39 @@ oci8.default_prefetch=100
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table default_prefetch1_tab",
+    "create table default_prefetch1_tab (id number, value number)",
+    "insert into default_prefetch1_tab (id, value) values (1,1)",
+    "insert into default_prefetch1_tab (id, value) values (1,1)",
+    "insert into default_prefetch1_tab (id, value) values (1,1)",
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                        942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+// Run Test
+
+$select_sql = "select * from default_prefetch1_tab";
 
 if (!($s = oci_parse($c, $select_sql))) {
 	die("oci_parse(select) failed!\n");
@@ -37,10 +50,19 @@ if (!oci_execute($s)) {
 }
 
 var_dump(oci_fetch($s));
-
 var_dump(oci_num_rows($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table default_prefetch1_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 	
 echo "Done\n";
 ?>
diff --git a/ext/oci8/tests/default_prefetch2.phpt b/ext/oci8/tests/default_prefetch2.phpt
index ac623a2..7b3f29f 100644
--- a/ext/oci8/tests/default_prefetch2.phpt
+++ b/ext/oci8/tests/default_prefetch2.phpt
@@ -7,26 +7,39 @@ oci8.default_prefetch=100
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table default_prefetch2_tab",
+    "create table default_prefetch2_tab (id number, value number)",
+    "insert into default_prefetch2_tab (id, value) values (1,1)",
+    "insert into default_prefetch2_tab (id, value) values (1,1)",
+    "insert into default_prefetch2_tab (id, value) values (1,1)",
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+// Run Test
+
+$select_sql = "select * from default_prefetch2_tab";
 
 if (!($s = oci_parse($c, $select_sql))) {
 	die("oci_parse(select) failed!\n");
@@ -39,10 +52,18 @@ if (!oci_execute($s)) {
 }
 
 var_dump(oci_fetch($s));
-
 var_dump(oci_num_rows($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+// Cleanup
+
+$stmtarray = array(
+    "drop table default_prefetch2_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 	
 echo "Done\n";
 ?>
diff --git a/ext/oci8/tests/define.phpt b/ext/oci8/tests/define.phpt
index c76f360..d99bc7e 100644
--- a/ext/oci8/tests/define.phpt
+++ b/ext/oci8/tests/define.phpt
@@ -5,24 +5,36 @@ oci_define_by_name()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__)."/create_table.inc";
-
-$insert_sql = "INSERT INTO ".$schema.$table_name." (string) VALUES ('some')";
-
-if (!($s = oci_parse($c, $insert_sql))) {
-        die("oci_parse(insert) failed!\n");
+require(dirname(__FILE__)."/connect.inc");
+
+// Initialize
+
+$stmtarray = array(
+    "drop table define_tab",
+    "create table define_tab (string varchar(10))",
+    "insert into define_tab (string) values ('some')",
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+				))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
 }
 
-if (!oci_execute($s)) {
-        die("oci_execute(insert) failed!\n");
-}
+// Run test
 
-$stmt = oci_parse($c, "SELECT string FROM ".$table_name."");
+$stmt = oci_parse($c, "select string from define_tab");
 
 /* the define MUST be done BEFORE ociexecute! */
 
-$strong = '';
+$string = '';
 oci_define_by_name($stmt, "STRING", $string, 20);
 
 oci_execute($stmt);
@@ -31,11 +43,20 @@ while (oci_fetch($stmt)) {
 	var_dump($string);
 }
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table define_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
---EXPECT--
-string(4) "some"
+--EXPECTF--
+%unicode|string%(%d) "some"
 Done
diff --git a/ext/oci8/tests/define1.phpt b/ext/oci8/tests/define1.phpt
index f6e04cc..341bc9e 100644
--- a/ext/oci8/tests/define1.phpt
+++ b/ext/oci8/tests/define1.phpt
@@ -5,24 +5,36 @@ oci_define_by_name()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__)."/create_table.inc";
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (string) VALUES ('some')";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-        die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table define1_tab",
+    "create table define1_tab (string varchar(10))",
+    "insert into define1_tab (string) values ('some')",
+);
 
-if (!oci_execute($s)) {
-        die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+				942 // table or view does not exist
+				))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
 }
 
-$stmt = oci_parse($c, "SELECT string FROM ".$table_name."");
+// Run test
+
+$stmt = oci_parse($c, "select string from define1_tab");
 
 /* the define MUST be done BEFORE ociexecute! */
 
-$strong = '';
+$string = '';
 var_dump(oci_define_by_name($stmt, "STRING", $string, 20));
 var_dump(oci_define_by_name($stmt, "STRING", $string, 20));
 var_dump(oci_define_by_name($stmt, "", $string, 20));
@@ -34,7 +46,16 @@ while (oci_fetch($stmt)) {
 	var_dump($string);
 }
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table define1_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 echo "Done\n";
 
@@ -48,5 +69,5 @@ bool(false)
 
 Warning: oci_define_by_name() expects at least 3 parameters, 2 given in %s on line %d
 NULL
-string(4) "some"
+%unicode|string%(4) "some"
 Done
diff --git a/ext/oci8/tests/define4.phpt b/ext/oci8/tests/define4.phpt
index 6fd9f5b..8d83f73 100644
--- a/ext/oci8/tests/define4.phpt
+++ b/ext/oci8/tests/define4.phpt
@@ -5,20 +5,32 @@ oci_define_by_name() on partial number of columns
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__)."/create_table.inc";
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (value, string) VALUES (1234, 'some')";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-        die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table define4_tab",
+    "create table define4_tab (value number, string varchar(10))",
+    "insert into define4_tab (value, string) values (1234, 'some')",
+);
 
-if (!oci_execute($s)) {
-        die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+				))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
 }
 
-$stmt = oci_parse($c, "SELECT value, string FROM ".$table_name."");
+// Run test
+
+$stmt = oci_parse($c, "select value, string from define4_tab");
 
 echo "Test 1\n";
 // Only one of the two columns is defined
@@ -42,7 +54,16 @@ var_dump(oci_free_statement($stmt));
 var_dump($string);
 var_dump(oci_result($stmt, 'STRING'));
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table define4_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 echo "Done\n";
 
@@ -51,15 +72,15 @@ echo "Done\n";
 Test 1
 bool(true)
 Test 2
-string(4) "1234"
-string(4) "some"
-string(4) "some"
-string(4) "some"
-string(4) "1234"
-string(4) "some"
+%unicode|string%(4) "1234"
+%unicode|string%(4) "some"
+%unicode|string%(4) "some"
+%unicode|string%(4) "some"
+%unicode|string%(4) "1234"
+%unicode|string%(4) "some"
 Test 3
 bool(true)
-string(4) "some"
+%unicode|string%(4) "some"
 
 Warning: oci_result(): %d is not a valid oci8 statement resource in %s on line %d
 bool(false)
diff --git a/ext/oci8/tests/define5.phpt b/ext/oci8/tests/define5.phpt
index c439b1d..63541ce 100644
--- a/ext/oci8/tests/define5.phpt
+++ b/ext/oci8/tests/define5.phpt
@@ -5,19 +5,34 @@ oci_define_by_name() for statement re-execution
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__)."/create_table.inc";
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, string) VALUES (1, 'some')";
-$s = oci_parse($c, $insert_sql);
-var_dump(oci_execute($s));
+// Initialize
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, string) VALUES (2, 'thing')";
-$s = oci_parse($c, $insert_sql);
-var_dump(oci_execute($s));
+$stmtarray = array(
+    "drop table define5_tab",
+    "create table define5_tab (id number, string varchar(10))",
+    "insert into define5_tab (id, string) values (1, 'some')",
+    "insert into define5_tab (id, string) values (2, 'thing')",
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+				))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+// Run test
 
 echo "Test 1 - must do define before execute\n";
-$stmt = oci_parse($c, "SELECT string FROM ".$table_name." where id = 1");
+$stmt = oci_parse($c, "select string from define5_tab where id = 1");
 oci_execute($stmt);
 var_dump(oci_define_by_name($stmt, "STRING", $string));
 while (oci_fetch($stmt)) {
@@ -26,7 +41,7 @@ while (oci_fetch($stmt)) {
 }
 
 echo "Test 2 - normal define order\n";
-$stmt = oci_parse($c, "SELECT string FROM ".$table_name." where id = 1");
+$stmt = oci_parse($c, "select string from define5_tab where id = 1");
 var_dump(oci_define_by_name($stmt, "STRING", $string));
 oci_execute($stmt);
 
@@ -35,30 +50,37 @@ while (oci_fetch($stmt)) {
 }
 
 echo "Test 3 - no new define done\n";
-$stmt = oci_parse($c, "SELECT string FROM ".$table_name." where id = 2");
+$stmt = oci_parse($c, "select string from define5_tab where id = 2");
 oci_execute($stmt);
 while (oci_fetch($stmt)) {
 	var_dump($string); // not updated with new value
 	var_dump(oci_result($stmt, 'STRING'));
 }
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table define5_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
---EXPECT--
-bool(true)
-bool(true)
+--EXPECTF--
 Test 1 - must do define before execute
 bool(true)
 NULL
-string(4) "some"
+%unicode|string%(4) "some"
 Test 2 - normal define order
 bool(true)
-string(4) "some"
+%unicode|string%(4) "some"
 Test 3 - no new define done
-string(4) "some"
-string(5) "thing"
+%unicode|string%(4) "some"
+%unicode|string%(5) "thing"
 Done
 
diff --git a/ext/oci8/tests/define_old.phpt b/ext/oci8/tests/define_old.phpt
index da52e61..618f9d5 100644
--- a/ext/oci8/tests/define_old.phpt
+++ b/ext/oci8/tests/define_old.phpt
@@ -5,24 +5,36 @@ ocidefinebyname()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__)."/create_table.inc";
-
-$insert_sql = "INSERT INTO ".$schema.$table_name." (string) VALUES ('some')";
-
-if (!($s = ociparse($c, $insert_sql))) {
-        die("oci_parse(insert) failed!\n");
+require(dirname(__FILE__)."/connect.inc");
+
+// Initialize
+
+$stmtarray = array(
+    "drop table define_old_tab",
+    "create table define_old_tab (string varchar(10))",
+    "insert into define_old_tab (string) values ('some')",
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+				))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
 }
 
-if (!ociexecute($s)) {
-        die("oci_execute(insert) failed!\n");
-}
+// Run test
 
-$stmt = ociparse($c, "SELECT string FROM ".$table_name."");
+$stmt = ociparse($c, "select string from define_old_tab");
 
 /* the define MUST be done BEFORE ociexecute! */
 
-$strong = '';
+$string = '';
 ocidefinebyname($stmt, "STRING", $string, 20);
 
 ociexecute($stmt);
@@ -31,11 +43,21 @@ while (ocifetch($stmt)) {
 	var_dump($string);
 }
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table define_old_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
 
 echo "Done\n";
 
 ?>
---EXPECT--
-string(4) "some"
+--EXPECTF--
+%unicode|string%(4) "some"
 Done
diff --git a/ext/oci8/tests/driver_name.phpt b/ext/oci8/tests/driver_name.phpt
new file mode 100644
index 0000000..187d7e1
--- /dev/null
+++ b/ext/oci8/tests/driver_name.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Verify that the Driver Name attribute is set
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
+
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
+if ($test_drcp) die("skip as Output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11.2|12)/', $sv, $matches);
+
+if ($sv == 1) {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => (11.2|12)/', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 11g or greater version of client");
+    }
+}
+else {
+    die ("skip test expected to work only with Oracle 11g or greater version of server");
+}
+
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/connect.inc");
+
+echo"**Test 1.1 - Default values for the attribute **************\n";
+get_attr($c);
+oci_close($c);
+
+echo"\n***Test 1.2 - Get the values from different connections **************\n";
+// with oci_pconnect() 
+echo "Testing with oci_pconnect()\n";
+$pc1=oci_pconnect($user,$password,$dbase);
+get_attr($pc1);
+oci_close($pc1);
+
+echo "Testing with oci_new_connect()\n";
+$nc1=oci_new_connect($user,$password,$dbase);
+get_attr($nc1);
+oci_close($nc1);
+echo "Done\n";
+
+function get_attr($conn)
+{
+	$sel_stmt = "select client_driver 
+        from v\$session_connect_info sci, v\$session s 
+        where sci.client_driver is not null 
+          and sci.sid = s.sid 
+          and s.audsid = userenv('SESSIONID')";
+    $s2 = oci_parse($conn,$sel_stmt);
+    oci_execute($s2,OCI_DEFAULT);
+    oci_fetch($s2);
+    echo "The value of DRIVER_NAME is ".oci_result($s2,1)."\n";
+}
+
+?>
+--EXPECT--
+**Test 1.1 - Default values for the attribute **************
+The value of DRIVER_NAME is PHP OCI8
+
+***Test 1.2 - Get the values from different connections **************
+Testing with oci_pconnect()
+The value of DRIVER_NAME is PHP OCI8
+Testing with oci_new_connect()
+The value of DRIVER_NAME is PHP OCI8
+Done
diff --git a/ext/oci8/tests/drop_table.inc b/ext/oci8/tests/drop_table.inc
index ffd99f5..592a95a 100644
--- a/ext/oci8/tests/drop_table.inc
+++ b/ext/oci8/tests/drop_table.inc
@@ -1,12 +1,7 @@
 <?php
-
-    if ($c) {
-        $ora_sql = "DROP TABLE
-                                ".$schema.$table_name."
-                   ";
-                      
-        $statement = OCIParse($c,$ora_sql);
-        OCIExecute($statement);
-    }
-
+if ($c) {
+    $ora_sql = "DROP TABLE ".$schema.$table_name;                      
+    $statement = oci_parse($c,$ora_sql);
+    oci_execute($statement);
+}
 ?>
diff --git a/ext/oci8/tests/drop_type.inc b/ext/oci8/tests/drop_type.inc
index 047968e..98542a8 100644
--- a/ext/oci8/tests/drop_type.inc
+++ b/ext/oci8/tests/drop_type.inc
@@ -1,12 +1,7 @@
 <?php
-
-    if ($c) {
-        $ora_sql = "DROP TYPE
-                                ".$type_name."
-                   ";
-                      
-        $statement = OCIParse($c,$ora_sql);
-        OCIExecute($statement);
-    }
-
+if ($c) {
+    $ora_sql = "DROP TYPE ".$type_name;
+    $statement = oci_parse($c,$ora_sql);
+    oci_execute($statement);
+}
 ?>
diff --git a/ext/oci8/tests/edition_1.phpt b/ext/oci8/tests/edition_1.phpt
new file mode 100644
index 0000000..9a4b0f3
--- /dev/null
+++ b/ext/oci8/tests/edition_1.phpt
@@ -0,0 +1,156 @@
+--TEST--
+Basic test for setting Oracle 11gR2 "edition" attribute
+--SKIPIF--
+<?php 
+if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys")) 
+    die("skip needs to be run as a DBA user");
+if ($test_drcp) 
+    die("skip as Output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11\.2|12)/', $sv, $matches);
+if ($sv == 1) {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $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");
+    }
+}
+else {
+    die ("skip tests a feature that works only with Oracle 11gR2 or greater version of server");
+}
+
+?>
+--FILE--
+<?php
+
+/* In 11.2, there can only be one child edition.  So this test will
+ * fail to create the necessary editions if a child edition exists
+ * already 
+ */
+
+require(dirname(__FILE__)."/conn_attr.inc");
+
+function select_fn($conn) {
+	$s = oci_parse($conn,"select * from view_ed");
+	oci_execute($s);
+	while ($row = oci_fetch_row($s)) {
+		var_dump($row);
+	}
+}
+/* Create a editon MYEDITION 
+   create a view view_ed in MYEDITION1.
+   create the same view 'view_ed' with a different definition in MYEDITION.
+   select from both the editions and verify the contents. */
+
+set_edit_attr('MYEDITION');
+$conn = oci_connect('testuser','testuser',$dbase); 
+if ($conn === false) {
+    $m = oci_error();
+    die("Error:" . $m['message']);
+}
+    
+$stmtarray = array(
+    "drop table edit_tab",
+    "create table edit_tab (name varchar2(10),age number,job varchar2(50), salary number)",
+    "insert into edit_tab values('mike',30,'Senior engineer',200)",
+    "insert into edit_tab values('juan',25,'engineer',100)",
+    "create or replace editioning view view_ed as select name,age,job from edit_tab",
+);
+
+foreach ($stmtarray as $stmt) {
+    $s = oci_parse($conn, $stmt);
+    @oci_execute($s);
+}
+
+// Check the current edition of the DB and the contents of view_ed.
+get_edit_attr($conn);
+select_fn($conn);
+
+// Create a different version of view_ed in MYEDITION1.
+set_edit_attr('MYEDITION1');
+$conn2 = oci_new_connect('testuser','testuser',$dbase); 
+$stmt = "create or replace editioning view view_ed as select name,age,job,salary from edit_tab";
+$s = oci_parse($conn2, $stmt);
+oci_execute($s);
+
+// Check the current edition of the DB and the contents of view_ed.
+get_edit_attr($conn2);
+select_fn($conn2);
+
+// Verify the contents in MYEDITION EDITION.
+echo "version of view_ed in MYEDITION \n";
+get_edit_attr($conn);
+select_fn($conn);
+
+clean_up($c);
+
+oci_close($conn);
+oci_close($conn2);
+echo "Done\n";
+
+?>
+--EXPECTF--
+The value of edition has been successfully set
+The value of current EDITION is MYEDITION
+array(3) {
+  [0]=>
+  %unicode|string%(%d) "mike"
+  [1]=>
+  %unicode|string%(%d) "30"
+  [2]=>
+  %unicode|string%(%d) "Senior engineer"
+}
+array(3) {
+  [0]=>
+  %unicode|string%(%d) "juan"
+  [1]=>
+  %unicode|string%(%d) "25"
+  [2]=>
+  %unicode|string%(%d) "engineer"
+}
+ The value of edition has been successfully set
+The value of current EDITION is MYEDITION1
+array(4) {
+  [0]=>
+  %unicode|string%(%d) "mike"
+  [1]=>
+  %unicode|string%(%d) "30"
+  [2]=>
+  %unicode|string%(%d) "Senior engineer"
+  [3]=>
+  %unicode|string%(%d) "200"
+}
+array(4) {
+  [0]=>
+  %unicode|string%(%d) "juan"
+  [1]=>
+  %unicode|string%(%d) "25"
+  [2]=>
+  %unicode|string%(%d) "engineer"
+  [3]=>
+  %unicode|string%(%d) "100"
+}
+version of view_ed in MYEDITION 
+The value of current EDITION is MYEDITION
+array(3) {
+  [0]=>
+  %unicode|string%(%d) "mike"
+  [1]=>
+  %unicode|string%(%d) "30"
+  [2]=>
+  %unicode|string%(%d) "Senior engineer"
+}
+array(3) {
+  [0]=>
+  %unicode|string%(%d) "juan"
+  [1]=>
+  %unicode|string%(%d) "25"
+  [2]=>
+  %unicode|string%(%d) "engineer"
+}
+Done
diff --git a/ext/oci8/tests/edition_2.phpt b/ext/oci8/tests/edition_2.phpt
new file mode 100644
index 0000000..f7ab979
--- /dev/null
+++ b/ext/oci8/tests/edition_2.phpt
@@ -0,0 +1,248 @@
+--TEST--
+Set and check Oracle 11gR2 "edition" attribute
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys"))
+    die("skip needs to be run as a DBA user");
+if ($test_drcp)
+    die("skip as Output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11\.2|12)/', $sv, $matches);
+if ($sv == 1) {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $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");
+    }
+}
+else {
+    die ("skip tests a feature that works only with Oracle 11gR2 or greater version of server");
+}
+
+?>
+--FILE--
+<?php
+
+/* In 11.2, there can only be one child edition.  So this test will
+ * fail to create the necessary editions if a child edition exists
+ * already
+ */
+
+require(dirname(__FILE__)."/conn_attr.inc");
+
+$user = 'testuser';
+$password = 'testuser';
+
+echo"**Test 1.1 - Default value for  the attribute **************\n";
+get_edit_attr($c);
+
+echo"\n\n**Test 1.2 - Set a value and get the same with different connections *********\n";
+set_edit_attr('MYEDITION');
+
+// With oci_connect, oci_pconnect, oci_new_connect
+$conn1 = get_conn(1);
+get_edit_attr($conn1);
+
+//pconnect
+$conn2 = get_conn(2);
+get_edit_attr($conn2);
+
+//new_connect
+$conn3 = get_conn(3);
+get_edit_attr($conn3);
+
+oci_close($conn1);
+
+// With a oci_pconnect with a different charset.
+$pc1 = oci_pconnect($user,$password,$dbase,"utf8");
+get_edit_attr($pc1);
+oci_close($pc1);
+
+
+echo"\n\n**Test 1.3 change the value and verify with existing conenctions.*********\n";
+set_edit_attr('MYEDITION1');
+get_edit_attr($conn2);
+get_edit_attr($conn3); // Old value
+oci_close($conn2);
+oci_close($conn3);
+
+//open a new connection and get the edition value . This will have the updated value.
+$c3 = get_conn(3); //oci_new_connect()
+get_edit_attr($c3);
+
+$c4 = get_conn(2); //oci_pconnect()
+get_edit_attr($c4);
+
+$c5 = get_conn(1); //oci_connect()
+get_edit_attr($c5);
+
+oci_close($c3);
+oci_close($c4);
+oci_close($c5);
+
+echo "\n\n**Test 1.4 - with different type of values *********\n";
+$values_array = array(123,NULL,'NO EDITION','edition name which has more than thirty chars!!!edition name which has more than thirty chars!!!');
+foreach ($values_array as $val ) {
+	set_edit_attr($val);
+	$c1 = get_conn(1); //oci_connect()
+	if ($c1) {
+		get_edit_attr($c1);
+		oci_close($c1);
+	}	
+}
+
+echo "\n\n**Test 1.5 - Negative case with an invalid string value. *********\n";
+$c1 = get_conn(3);
+$r = set_edit_attr($c1);
+
+echo"\n\n**Test 1.6 - Set Multiple times.*****\n";
+set_edit_attr('MYEDITION');
+set_edit_attr('MYEDITION1');
+$c1 = get_conn(1);
+get_edit_attr($c1);
+oci_close($c1);
+
+echo "\n\n**Test 1.7 - Test with ALTER SESSION statement to change the edition *******\n";
+// Set the edition value to MYEDITION. open a conn .get the value.
+// execute the alter system set edition ='MYEDITION' .get the value .
+// set it back to MYEDITION using oci_set_edition. and get the value.
+
+set_edit_attr('MYEDITION');
+$c1 = get_conn(3);
+echo "get the value set to MYEDITION with oci_set_edition \n";
+get_edit_attr($c1);
+
+$alter_stmt = "alter session set edition = MYEDITION1";
+$s = oci_parse($c1,$alter_stmt);
+oci_execute($s);
+oci_commit($c1);
+echo "Get the value set to MYEDITION1 with alter session\n";
+get_edit_attr($c1);
+
+echo " Get the value with a new connection \n";
+$c2 = get_conn(1);
+get_edit_attr($c2);
+
+echo " Set the value back using oci-set_edition\n";
+set_edit_attr('MYEDITION');
+get_edit_attr($c2);
+
+echo " Get the value with a new conenction \n";
+$c3 = get_conn(1);
+get_edit_attr($c3);
+
+oci_close($c1);
+oci_close($c2);
+oci_close($c3);
+
+
+echo "\n\n**Test 1.8 - Test setting the attribute with scope ends*******\n";
+set_scope();
+get_scope();
+
+clean_up($c);
+echo "Done\n";
+
+
+function set_scope() {
+	$r = set_edit_attr('MYEDITION1');
+}
+
+function get_scope() {
+    $sc1 = oci_connect($GLOBALS['user'],$GLOBALS['password'],$GLOBALS['dbase']);
+    if ($sc1 === false) {
+        $m = oci_error();
+        die("Error:" . $m['message']);
+    }
+	get_edit_attr($sc1);
+	oci_close($sc1);
+}
+?>
+--EXPECTF--
+**Test 1.1 - Default value for  the attribute **************
+The value of current EDITION is ORA$BASE
+
+
+**Test 1.2 - Set a value and get the same with different connections *********
+ The value of edition has been successfully set
+Testing with oci_connect()
+The value of current EDITION is MYEDITION
+Testing with oci_pconnect()
+The value of current EDITION is MYEDITION
+Testing with oci_new_connect()
+The value of current EDITION is MYEDITION
+The value of current EDITION is MYEDITION
+
+
+**Test 1.3 change the value and verify with existing conenctions.*********
+ The value of edition has been successfully set
+The value of current EDITION is MYEDITION
+The value of current EDITION is MYEDITION
+Testing with oci_new_connect()
+The value of current EDITION is MYEDITION1
+Testing with oci_pconnect()
+The value of current EDITION is MYEDITION1
+Testing with oci_connect()
+The value of current EDITION is MYEDITION1
+
+
+**Test 1.4 - with different type of values *********
+ The value of edition has been successfully set
+Testing with oci_connect()
+
+Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
+ The value of edition has been successfully set
+Testing with oci_connect()
+The value of current EDITION is ORA$BASE
+ The value of edition has been successfully set
+Testing with oci_connect()
+
+Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
+ The value of edition has been successfully set
+Testing with oci_connect()
+
+Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
+
+
+**Test 1.5 - Negative case with an invalid string value. *********
+Testing with oci_new_connect()
+
+Warning: oci_new_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
+ The value of edition has been successfully set
+
+
+**Test 1.6 - Set Multiple times.*****
+ The value of edition has been successfully set
+ The value of edition has been successfully set
+Testing with oci_connect()
+The value of current EDITION is MYEDITION1
+
+
+**Test 1.7 - Test with ALTER SESSION statement to change the edition *******
+ The value of edition has been successfully set
+Testing with oci_new_connect()
+get the value set to MYEDITION with oci_set_edition 
+The value of current EDITION is MYEDITION
+Get the value set to MYEDITION1 with alter session
+The value of current EDITION is MYEDITION1
+ Get the value with a new connection 
+Testing with oci_connect()
+The value of current EDITION is MYEDITION
+ Set the value back using oci-set_edition
+ The value of edition has been successfully set
+The value of current EDITION is MYEDITION
+ Get the value with a new conenction 
+Testing with oci_connect()
+The value of current EDITION is MYEDITION
+
+
+**Test 1.8 - Test setting the attribute with scope ends*******
+ The value of edition has been successfully set
+The value of current EDITION is MYEDITION1
+Done
+
diff --git a/ext/oci8/tests/extauth_01.phpt b/ext/oci8/tests/extauth_01.phpt
index e054a22..30250ec 100644
--- a/ext/oci8/tests/extauth_01.phpt
+++ b/ext/oci8/tests/extauth_01.phpt
@@ -139,12 +139,12 @@ bool(false)
 bool(false)
 Test 7
 
-Warning: oci_connect(): ORA-12154: TNS:could not resolve the connect identifier specified in %s on line %d
+Warning: oci_connect(): ORA-12154: %s in %s on line %d
 array(4) {
   [%u|b%"code"]=>
   int(12154)
   [%u|b%"message"]=>
-  %unicode|string%(65) "ORA-12154: %s"
+  %unicode|string%(%d) "ORA-12154: %s"
   [%u|b%"offset"]=>
   int(0)
   [%u|b%"sqltext"]=>
@@ -153,12 +153,12 @@ array(4) {
 bool(false)
 Test 8
 
-Warning: oci_connect(): ORA-12154: TNS:could not resolve the connect identifier specified in %s on line %d
+Warning: oci_connect(): ORA-12154: %s in %s on line %d
 array(4) {
   [%u|b%"code"]=>
   int(12154)
   [%u|b%"message"]=>
-  %unicode|string%(65) "ORA-12154: %s"
+  %unicode|string%(%d) "ORA-12154: %s"
   [%u|b%"offset"]=>
   int(0)
   [%u|b%"sqltext"]=>
diff --git a/ext/oci8/tests/extauth_02.phpt b/ext/oci8/tests/extauth_02.phpt
index b275229..d648eef 100644
--- a/ext/oci8/tests/extauth_02.phpt
+++ b/ext/oci8/tests/extauth_02.phpt
@@ -139,12 +139,12 @@ bool(false)
 bool(false)
 Test 7
 
-Warning: oci_new_connect(): ORA-12154: TNS:could not resolve the connect identifier specified in %s on line %d
+Warning: oci_new_connect(): ORA-12154: %s in %s on line %d
 array(4) {
   [%u|b%"code"]=>
   int(12154)
   [%u|b%"message"]=>
-  %unicode|string%(65) "ORA-12154: %s"
+  %unicode|string%(%d) "ORA-12154: %s"
   [%u|b%"offset"]=>
   int(0)
   [%u|b%"sqltext"]=>
@@ -153,12 +153,12 @@ array(4) {
 bool(false)
 Test 8
 
-Warning: oci_new_connect(): ORA-12154: TNS:could not resolve the connect identifier specified in %s on line %d
+Warning: oci_new_connect(): ORA-12154: %s in %s on line %d
 array(4) {
   [%u|b%"code"]=>
   int(12154)
   [%u|b%"message"]=>
-  %unicode|string%(65) "ORA-12154: %s"
+  %unicode|string%(%d) "ORA-12154: %s"
   [%u|b%"offset"]=>
   int(0)
   [%u|b%"sqltext"]=>
diff --git a/ext/oci8/tests/extauth_03.phpt b/ext/oci8/tests/extauth_03.phpt
index 50be0e7..021492f 100644
--- a/ext/oci8/tests/extauth_03.phpt
+++ b/ext/oci8/tests/extauth_03.phpt
@@ -139,12 +139,12 @@ bool(false)
 bool(false)
 Test 7
 
-Warning: oci_pconnect(): ORA-12154: TNS:could not resolve the connect identifier specified in %s on line %d
+Warning: oci_pconnect(): ORA-12154: %s in %s on line %d
 array(4) {
   [%u|b%"code"]=>
   int(12154)
   [%u|b%"message"]=>
-  %unicode|string%(65) "ORA-12154: %s"
+  %unicode|string%(%d) "ORA-12154: %s"
   [%u|b%"offset"]=>
   int(0)
   [%u|b%"sqltext"]=>
@@ -153,12 +153,12 @@ array(4) {
 bool(false)
 Test 8
 
-Warning: oci_pconnect(): ORA-12154: TNS:could not resolve the connect identifier specified in %s on line %d
+Warning: oci_pconnect(): ORA-12154: %s in %s on line %d
 array(4) {
   [%u|b%"code"]=>
   int(12154)
   [%u|b%"message"]=>
-  %unicode|string%(65) "ORA-12154: %s"
+  %unicode|string%(%d) "ORA-12154: %s"
   [%u|b%"offset"]=>
   int(0)
   [%u|b%"sqltext"]=>
diff --git a/ext/oci8/tests/fetch.phpt b/ext/oci8/tests/fetch.phpt
index 33cba65..5206324 100644
--- a/ext/oci8/tests/fetch.phpt
+++ b/ext/oci8/tests/fetch.phpt
@@ -5,28 +5,39 @@ ocifetch() & ociresult()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table fetch_tab",
+    "create table fetch_tab (id number, value number)",
+    "insert into fetch_tab (id, value) values (1,1)",
+    "insert into fetch_tab (id, value) values (1,1)",
+    "insert into fetch_tab (id, value) values (1,1)",
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+// Run Test
 
-if (!($s = oci_parse($c, $select_sql))) {
+if (!($s = oci_parse($c, "select * from fetch_tab"))) {
 	die("oci_parse(select) failed!\n");
 }
 
@@ -35,22 +46,31 @@ if (!oci_execute($s)) {
 }
 
 while(ocifetch($s)) {
-	$i = 1;
-	while ($row = ociresult($s, $i)) {
-		$i++;
+		$row = ociresult($s, 1);
+		$row1 = ociresult($s, 2);
 		var_dump($row);
-	}
+		var_dump($row1);
+}
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table fetch_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-require dirname(__FILE__).'/drop_table.inc';
 	
 echo "Done\n";
 ?>
---EXPECT--
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
+--EXPECTF--
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
 Done
diff --git a/ext/oci8/tests/fetch_all.phpt b/ext/oci8/tests/fetch_all.phpt
index 5d3738b..a007bac 100644
--- a/ext/oci8/tests/fetch_all.phpt
+++ b/ext/oci8/tests/fetch_all.phpt
@@ -5,28 +5,32 @@ oci_fetch_all()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table fetch_all_tab",
+    "create table fetch_all_tab (id number, value number)",
+    "insert into fetch_all_tab (id, value) values (1,1)",
+    "insert into fetch_all_tab (id, value) values (1,1)",
+    "insert into fetch_all_tab (id, value) values (1,1)"
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
-}
-
-$select_sql = "SELECT * FROM ".$schema."".$table_name."";
-
-if (!($s = oci_parse($c, $select_sql))) {
+if (!($s = oci_parse($c, "select * from fetch_all_tab"))) {
 	die("oci_parse(select) failed!\n");
 }
 
@@ -45,105 +49,60 @@ if (!oci_execute($s)) {
 var_dump(ocifetchstatement($s, $all));
 var_dump($all);
 
-require dirname(__FILE__).'/drop_table.inc';
+// Cleanup
+
+$stmtarray = array(
+    "drop table fetch_all_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 	
 echo "Done\n";
 ?>
---EXPECT--
+--EXPECTF--
 int(3)
-array(5) {
-  ["ID"]=>
+array(2) {
+  [%u|b%"ID"]=>
   array(3) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [2]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(3) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [2]=>
-    string(1) "1"
-  }
-  ["BLOB"]=>
-  array(3) {
-    [0]=>
-    NULL
-    [1]=>
-    NULL
-    [2]=>
-    NULL
-  }
-  ["CLOB"]=>
-  array(3) {
-    [0]=>
-    NULL
-    [1]=>
-    NULL
-    [2]=>
-    NULL
-  }
-  ["STRING"]=>
-  array(3) {
-    [0]=>
-    NULL
-    [1]=>
-    NULL
-    [2]=>
-    NULL
+    %unicode|string%(1) "1"
   }
 }
 int(3)
-array(5) {
-  ["ID"]=>
-  array(3) {
-    [0]=>
-    string(1) "1"
-    [1]=>
-    string(1) "1"
-    [2]=>
-    string(1) "1"
-  }
-  ["VALUE"]=>
-  array(3) {
-    [0]=>
-    string(1) "1"
-    [1]=>
-    string(1) "1"
-    [2]=>
-    string(1) "1"
-  }
-  ["BLOB"]=>
-  array(3) {
-    [0]=>
-    NULL
-    [1]=>
-    NULL
-    [2]=>
-    NULL
-  }
-  ["CLOB"]=>
+array(2) {
+  [%u|b%"ID"]=>
   array(3) {
     [0]=>
-    NULL
+    %unicode|string%(1) "1"
     [1]=>
-    NULL
+    %unicode|string%(1) "1"
     [2]=>
-    NULL
+    %unicode|string%(1) "1"
   }
-  ["STRING"]=>
+  [%u|b%"VALUE"]=>
   array(3) {
     [0]=>
-    NULL
+    %unicode|string%(1) "1"
     [1]=>
-    NULL
+    %unicode|string%(1) "1"
     [2]=>
-    NULL
+    %unicode|string%(1) "1"
   }
 }
 Done
diff --git a/ext/oci8/tests/fetch_all3.phpt b/ext/oci8/tests/fetch_all3.phpt
index 503e5dd..42fe617 100644
--- a/ext/oci8/tests/fetch_all3.phpt
+++ b/ext/oci8/tests/fetch_all3.phpt
@@ -5,11 +5,34 @@ oci_fetch_all() - all combinations of flags
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (:idbv,:vbv)";
+// Initialize
 
+$stmtarray = array(
+    "drop table fetch_all3_tab",
+    "create table fetch_all3_tab (id number, value number)",
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                        942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
+$insert_sql = "insert into fetch_all3_tab (id, value) values (:idbv,:vbv)";
 $s = oci_parse($c, $insert_sql);
 oci_bind_by_name($s, ":idbv", $idbv, SQLT_INT);
 oci_bind_by_name($s, ":vbv", $vbv, SQLT_INT);
@@ -22,7 +45,9 @@ for ($i = 1; $i <= 4; $i++) {
 
 oci_commit($c);
 
-$select_sql = "SELECT ID, VALUE FROM ".$schema."".$table_name." order by id";
+// Run Test
+
+$select_sql = "select id, value from fetch_all3_tab order by id";
 
 $s = oci_parse($c, $select_sql);
 
@@ -105,113 +130,123 @@ echo "OCI_NUM|OCI_ASSOC\n";
 oci_execute($s);
 var_dump(oci_fetch_all($s, $all, 0, -1, OCI_NUM|OCI_ASSOC));
 var_dump($all);
-require dirname(__FILE__).'/drop_table.inc';
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table fetch_all3_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
     
 echo "Done\n";
 ?>
---EXPECT--
+--EXPECTF--
 None
 int(4)
 array(2) {
-  ["ID"]=>
+  [%u|b%"ID"]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_ASSOC
 int(4)
 array(2) {
-  ["ID"]=>
+  [%u|b%"ID"]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_COLUMN
 int(4)
 array(2) {
-  ["ID"]=>
+  [%u|b%"ID"]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC
 int(4)
 array(2) {
-  ["ID"]=>
+  [%u|b%"ID"]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM
@@ -220,24 +255,24 @@ array(2) {
   [0]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
   [1]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC
@@ -246,24 +281,24 @@ array(2) {
   [0]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
   [1]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW
@@ -271,31 +306,31 @@ int(4)
 array(4) {
   [0]=>
   array(2) {
-    ["ID"]=>
-    string(1) "1"
-    ["VALUE"]=>
-    string(2) "-1"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
-    ["ID"]=>
-    string(1) "2"
-    ["VALUE"]=>
-    string(2) "-2"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
-    ["ID"]=>
-    string(1) "3"
-    ["VALUE"]=>
-    string(2) "-3"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
-    ["ID"]=>
-    string(1) "4"
-    ["VALUE"]=>
-    string(2) "-4"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "4"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC
@@ -303,31 +338,31 @@ int(4)
 array(4) {
   [0]=>
   array(2) {
-    ["ID"]=>
-    string(1) "1"
-    ["VALUE"]=>
-    string(2) "-1"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
-    ["ID"]=>
-    string(1) "2"
-    ["VALUE"]=>
-    string(2) "-2"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
-    ["ID"]=>
-    string(1) "3"
-    ["VALUE"]=>
-    string(2) "-3"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
-    ["ID"]=>
-    string(1) "4"
-    ["VALUE"]=>
-    string(2) "-4"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "4"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN
@@ -335,31 +370,31 @@ int(4)
 array(4) {
   [0]=>
   array(2) {
-    ["ID"]=>
-    string(1) "1"
-    ["VALUE"]=>
-    string(2) "-1"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
-    ["ID"]=>
-    string(1) "2"
-    ["VALUE"]=>
-    string(2) "-2"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
-    ["ID"]=>
-    string(1) "3"
-    ["VALUE"]=>
-    string(2) "-3"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
-    ["ID"]=>
-    string(1) "4"
-    ["VALUE"]=>
-    string(2) "-4"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "4"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC
@@ -367,31 +402,31 @@ int(4)
 array(4) {
   [0]=>
   array(2) {
-    ["ID"]=>
-    string(1) "1"
-    ["VALUE"]=>
-    string(2) "-1"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
-    ["ID"]=>
-    string(1) "2"
-    ["VALUE"]=>
-    string(2) "-2"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
-    ["ID"]=>
-    string(1) "3"
-    ["VALUE"]=>
-    string(2) "-3"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
-    ["ID"]=>
-    string(1) "4"
-    ["VALUE"]=>
-    string(2) "-4"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "4"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM
@@ -400,30 +435,30 @@ array(4) {
   [0]=>
   array(2) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
     [0]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
     [0]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [1]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
     [0]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
     [1]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC
@@ -432,30 +467,30 @@ array(4) {
   [0]=>
   array(2) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
     [0]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
     [0]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [1]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
     [0]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
     [1]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM
@@ -464,30 +499,30 @@ array(4) {
   [0]=>
   array(2) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
     [0]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
     [0]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [1]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
     [0]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
     [1]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC
@@ -496,30 +531,30 @@ array(4) {
   [0]=>
   array(2) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
     [0]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
     [0]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [1]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
     [0]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
     [1]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_NUM
@@ -528,24 +563,24 @@ array(2) {
   [0]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
   [1]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_NUM|OCI_ASSOC
@@ -554,24 +589,24 @@ array(2) {
   [0]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
   [1]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 Done
diff --git a/ext/oci8/tests/fetch_all4.phpt b/ext/oci8/tests/fetch_all4.phpt
new file mode 100644
index 0000000..9b82262
--- /dev/null
+++ b/ext/oci8/tests/fetch_all4.phpt
@@ -0,0 +1,82 @@
+--TEST--
+Test oci_fetch_* array overwriting when query returns no rows
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialization
+
+$stmtarray = array(
+	"drop table fetch_all4_tab",
+	"create table fetch_all4_tab (mycol1 number, mycol2 varchar2(20))",
+	"insert into fetch_all4_tab values (1, 'abc')"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+			    942 // table or view does not exist
+			,  2289 // sequence does not exist
+			,  4080 // trigger does not exist
+                        , 38802 // edition does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+// Run Test
+
+echo "Test 1\n";
+
+$s = oci_parse($c, "select * from fetch_all4_tab where 1 = 0");
+oci_execute($s);
+$res = array(1,2,3);  // this array is replaced as a result of the query
+$r = oci_fetch_all($s, $res);
+var_dump($r);
+var_dump($res);
+
+echo "Test 2\n";
+
+$s = oci_parse($c, "select * from fetch_all4_tab where 1 = 0");
+oci_execute($s);
+$row = array(1,2,3);  // this array is replaced as a result of the query
+$row = oci_fetch_array($s);
+var_dump($row);
+
+// Clean up
+
+$stmtarray = array(
+	"drop table fetch_all4_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1
+int(0)
+array(2) {
+  [%u|b%"MYCOL1"]=>
+  array(0) {
+  }
+  [%u|b%"MYCOL2"]=>
+  array(0) {
+  }
+}
+Test 2
+bool(false)
+===DONE===
diff --git a/ext/oci8/tests/fetch_all5.phpt b/ext/oci8/tests/fetch_all5.phpt
new file mode 100644
index 0000000..bb9061a
--- /dev/null
+++ b/ext/oci8/tests/fetch_all5.phpt
@@ -0,0 +1,127 @@
+--TEST--
+Test oci_fetch_all with 0 and -1 skip & maxrows
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialization
+
+$stmtarray = array(
+	"drop table fetch_all5_tab",
+	"create table fetch_all5_tab (mycol1 number, mycol2 varchar2(20))",
+	"insert into fetch_all5_tab values (1, 'abc')",
+	"insert into fetch_all5_tab values (2, 'def')",
+	"insert into fetch_all5_tab values (3, 'ghi')"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+			    942 // table or view does not exist
+			,  2289 // sequence does not exist
+			,  4080 // trigger does not exist
+                        , 38802 // edition does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+// Run Test
+
+echo "Test 1\n";
+
+$s = oci_parse($c, "select * from fetch_all5_tab order by 1");
+oci_execute($s);
+$r = oci_fetch_all($s, $res, 0, -1);
+var_dump($r);
+var_dump($res);
+
+echo "Test 1\n";
+
+$s = oci_parse($c, "select * from fetch_all5_tab order by 1");
+oci_execute($s);
+$r = oci_fetch_all($s, $res, 0, 0);
+var_dump($r);
+var_dump($res);
+
+echo "Test 3\n";
+
+$s = oci_parse($c, "select * from fetch_all5_tab order by 1");
+oci_execute($s);
+$r = oci_fetch_all($s, $res, -1, 0);
+var_dump($r);
+var_dump($res);
+
+// Clean up
+
+$stmtarray = array(
+	"drop table fetch_all5_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1
+int(3)
+array(2) {
+  [%u|b%"MYCOL1"]=>
+  array(3) {
+    [0]=>
+    %unicode|string%(1) "1"
+    [1]=>
+    %unicode|string%(1) "2"
+    [2]=>
+    %unicode|string%(1) "3"
+  }
+  [%u|b%"MYCOL2"]=>
+  array(3) {
+    [0]=>
+    %unicode|string%(3) "abc"
+    [1]=>
+    %unicode|string%(3) "def"
+    [2]=>
+    %unicode|string%(3) "ghi"
+  }
+}
+Test 1
+int(3)
+array(2) {
+  [%u|b%"MYCOL1"]=>
+  array(3) {
+    [0]=>
+    %unicode|string%(1) "1"
+    [1]=>
+    %unicode|string%(1) "2"
+    [2]=>
+    %unicode|string%(1) "3"
+  }
+  [%u|b%"MYCOL2"]=>
+  array(3) {
+    [0]=>
+    %unicode|string%(3) "abc"
+    [1]=>
+    %unicode|string%(3) "def"
+    [2]=>
+    %unicode|string%(3) "ghi"
+  }
+}
+Test 3
+int(0)
+array(0) {
+}
+===DONE===
diff --git a/ext/oci8/tests/fetch_into.phpt b/ext/oci8/tests/fetch_into.phpt
index 379f5fc..17e06e1 100644
--- a/ext/oci8/tests/fetch_into.phpt
+++ b/ext/oci8/tests/fetch_into.phpt
@@ -5,78 +5,86 @@ ocifetchinto()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table fetch_into_tab",
+    "create table fetch_into_tab (id number, value number)",
+    "insert into fetch_into_tab (id, value) values (1,1)",
+    "insert into fetch_into_tab (id, value) values (1,1)",
+    "insert into fetch_into_tab (id, value) values (1,1)",
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                        942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-$select_sql = "SELECT * FROM ".$schema."".$table_name."";
+// Run Test
 
-if (!($s = oci_parse($c, $select_sql))) {
+if (!($s = oci_parse($c, "select * from fetch_into_tab"))) {
 	die("oci_parse(select) failed!\n");
 }
 
-/* oci_fetch_all */
+/* ocifetchinto */
 if (!oci_execute($s)) {
 	die("oci_execute(select) failed!\n");
 }
 var_dump(ocifetchinto($s, $all));
 var_dump($all);
 
-/* oci_fetch_all */
+/* ocifetchinto */
 if (!oci_execute($s)) {
 	die("oci_execute(select) failed!\n");
 }
 var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS));
 var_dump($all);
 
-require dirname(__FILE__).'/drop_table.inc';
+// Cleanup
+
+$stmtarray = array(
+    "drop table fetch_into_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 	
 echo "Done\n";
 ?>
---EXPECT--
-int(5)
+--EXPECTF--
+int(2)
 array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
 }
-int(5)
-array(10) {
+int(2)
+array(4) {
   [0]=>
-  string(1) "1"
-  ["ID"]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
+  [%u|b%"ID"]=>
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
-  ["VALUE"]=>
-  string(1) "1"
-  [2]=>
-  NULL
-  ["BLOB"]=>
-  NULL
-  [3]=>
-  NULL
-  ["CLOB"]=>
-  NULL
-  [4]=>
-  NULL
-  ["STRING"]=>
-  NULL
+  %unicode|string%(1) "1"
+  [%u|b%"VALUE"]=>
+  %unicode|string%(1) "1"
 }
 Done
diff --git a/ext/oci8/tests/fetch_object.phpt b/ext/oci8/tests/fetch_object.phpt
index 57b7fc0..674a88f 100644
--- a/ext/oci8/tests/fetch_object.phpt
+++ b/ext/oci8/tests/fetch_object.phpt
@@ -5,78 +5,133 @@ oci_fetch_object()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__).'/connect.inc');
 
-$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
+// Initialization
 
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+	"drop table fetch_object_tab",
+	"create table fetch_object_tab (\"caseSensitive\" number, secondcol varchar2(20), anothercol char(15))",
+	"insert into fetch_object_tab values (123, '1st row col2 string', '1 more text')",
+	"insert into fetch_object_tab values (456, '2nd row col2 string', '2 more text')",
+	"insert into fetch_object_tab values (789, '3rd row col2 string', '3 more text')",
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+                ,  2289 // sequence does not exist
+                ,  4080 // trigger does not exist
+                , 38802 // edition does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
-}
+// Run Test
 
-$select_sql = "SELECT * FROM ".$schema."".$table_name."";
+echo "Test 1\n";
 
-if (!($s = oci_parse($c, $select_sql))) {
+if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) {
 	die("oci_parse(select) failed!\n");
 }
 
 if (!oci_execute($s)) {
 	die("oci_execute(select) failed!\n");
 }
+
 while ($row = oci_fetch_object($s)) {
 	var_dump($row);
 }
 
-require dirname(__FILE__).'/drop_table.inc';
+echo "Test 2\n";
+
+if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) {
+	die("oci_parse(select) failed!\n");
+}
+
+if (!oci_execute($s)) {
+	die("oci_execute(select) failed!\n");
+}
 
-echo "Done\n";
+while ($row = oci_fetch_object($s)) {
+    echo $row->caseSensitive . "\n";
+    echo $row->SECONDCOL . "\n";
+    echo $row->ANOTHERCOL . "\n";
+}
+
+echo "Test 3\n";
+
+if (!($s = oci_parse($c, 'select * from fetch_object_tab where rownum < 2 order by "caseSensitive"'))) {
+	die("oci_parse(select) failed!\n");
+}
+
+if (!oci_execute($s)) {
+	die("oci_execute(select) failed!\n");
+}
+
+$row = oci_fetch_object($s);
+echo $row->caseSensitive . "\n";
+echo $row->CASESENSITIVE . "\n";
+
+// Clean up
+
+$stmtarray = array(
+	"drop table fetch_object_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 ?>
+===DONE===
+<?php exit(0); ?>
 --EXPECTF--
-object(stdClass)#%d (5) {
-  ["ID"]=>
-  string(1) "1"
-  ["VALUE"]=>
-  string(1) "1"
-  ["BLOB"]=>
-  NULL
-  ["CLOB"]=>
-  NULL
-  ["STRING"]=>
-  NULL
+Test 1
+object(stdClass)#1 (3) {
+  [%u|b%"caseSensitive"]=>
+  %unicode|string%(3) "123"
+  [%u|b%"SECONDCOL"]=>
+  %unicode|string%(19) "1st row col2 string"
+  [%u|b%"ANOTHERCOL"]=>
+  %unicode|string%(15) "1 more text    "
 }
-object(stdClass)#%d (5) {
-  ["ID"]=>
-  string(1) "1"
-  ["VALUE"]=>
-  string(1) "1"
-  ["BLOB"]=>
-  NULL
-  ["CLOB"]=>
-  NULL
-  ["STRING"]=>
-  NULL
+object(stdClass)#2 (3) {
+  [%u|b%"caseSensitive"]=>
+  %unicode|string%(3) "456"
+  [%u|b%"SECONDCOL"]=>
+  %unicode|string%(19) "2nd row col2 string"
+  [%u|b%"ANOTHERCOL"]=>
+  %unicode|string%(15) "2 more text    "
 }
-object(stdClass)#%d (5) {
-  ["ID"]=>
-  string(1) "1"
-  ["VALUE"]=>
-  string(1) "1"
-  ["BLOB"]=>
-  NULL
-  ["CLOB"]=>
-  NULL
-  ["STRING"]=>
-  NULL
+object(stdClass)#1 (3) {
+  [%u|b%"caseSensitive"]=>
+  %unicode|string%(3) "789"
+  [%u|b%"SECONDCOL"]=>
+  %unicode|string%(19) "3rd row col2 string"
+  [%u|b%"ANOTHERCOL"]=>
+  %unicode|string%(15) "3 more text    "
 }
-Done
+Test 2
+123
+1st row col2 string
+1 more text    
+456
+2nd row col2 string
+2 more text    
+789
+3rd row col2 string
+3 more text    
+Test 3
+123
+
+Notice: Undefined property: stdClass::$CASESENSITIVE in %sfetch_object.php on line %d
+
+===DONE===
diff --git a/ext/oci8/tests/fetch_object_2.phpt b/ext/oci8/tests/fetch_object_2.phpt
new file mode 100644
index 0000000..342503d
--- /dev/null
+++ b/ext/oci8/tests/fetch_object_2.phpt
@@ -0,0 +1,127 @@
+--TEST--
+oci_fetch_object() with CLOB and NULL
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialization
+
+$stmtarray = array(
+	"drop table fetch_object_2_tab",
+	"create table fetch_object_2_tab (col1 number, col2 CLOB, col3 varchar2(15))",
+	"insert into fetch_object_2_tab values (123, '1st row col2 string', '1 more text')",
+	"insert into fetch_object_2_tab values (456, '2nd row col2 string', NULL)",
+	"insert into fetch_object_2_tab values (789, '3rd row col2 string', '3 more text')",
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+                ,  2289 // sequence does not exist
+                ,  4080 // trigger does not exist
+                , 38802 // edition does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+// Run Test
+
+echo "Test 1\n";
+
+if (!($s = oci_parse($c, 'select * from fetch_object_2_tab order by 1'))) {
+	die("oci_parse(select) failed!\n");
+}
+
+if (!oci_execute($s)) {
+	die("oci_execute(select) failed!\n");
+}
+
+while ($row = oci_fetch_object($s)) {
+	var_dump($row);
+}
+
+echo "Test 2\n";
+
+if (!($s = oci_parse($c, 'select * from fetch_object_2_tab order by 1'))) {
+	die("oci_parse(select) failed!\n");
+}
+
+if (!oci_execute($s)) {
+	die("oci_execute(select) failed!\n");
+}
+
+while ($row = oci_fetch_object($s)) {
+    echo $row->COL1 . "\n";
+    echo $row->COL2->load(100) . "\n";
+    echo $row->COL3 . "\n";
+}
+
+// Clean up
+
+$stmtarray = array(
+	"drop table fetch_object_2_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1
+object(stdClass)#%d (3) {
+  [%u|b%"COL1"]=>
+  %unicode|string%(3) "123"
+  [%u|b%"COL2"]=>
+  object(OCI-Lob)#%d (1) {
+    [%u|b%"descriptor"]=>
+    resource(15) of type (oci8 descriptor)
+  }
+  [%u|b%"COL3"]=>
+  %unicode|string%(11) "1 more text"
+}
+object(stdClass)#%d (3) {
+  [%u|b%"COL1"]=>
+  %unicode|string%(3) "456"
+  [%u|b%"COL2"]=>
+  object(OCI-Lob)#%d (1) {
+    [%u|b%"descriptor"]=>
+    resource(16) of type (oci8 descriptor)
+  }
+  [%u|b%"COL3"]=>
+  NULL
+}
+object(stdClass)#%d (3) {
+  [%u|b%"COL1"]=>
+  %unicode|string%(3) "789"
+  [%u|b%"COL2"]=>
+  object(OCI-Lob)#%d (1) {
+    [%u|b%"descriptor"]=>
+    resource(17) of type (oci8 descriptor)
+  }
+  [%u|b%"COL3"]=>
+  %unicode|string%(11) "3 more text"
+}
+Test 2
+123
+1st row col2 string
+1 more text
+456
+2nd row col2 string
+
+789
+3rd row col2 string
+3 more text
+===DONE===
diff --git a/ext/oci8/tests/fetch_row.phpt b/ext/oci8/tests/fetch_row.phpt
index a637ecc..c6084d4 100644
--- a/ext/oci8/tests/fetch_row.phpt
+++ b/ext/oci8/tests/fetch_row.phpt
@@ -5,28 +5,39 @@ oci_fetch_row()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table fetch_row_tab",
+    "create table fetch_row_tab (id number, value number)",
+    "insert into fetch_row_tab (id, value) values (1,1)",
+    "insert into fetch_row_tab (id, value) values (1,1)",
+    "insert into fetch_row_tab (id, value) values (1,1)",
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-$select_sql = "SELECT * FROM ".$schema."".$table_name."";
+// Run Test
 
-if (!($s = oci_parse($c, $select_sql))) {
+if (!($s = oci_parse($c, "select * from fetch_row_tab"))) {
 	die("oci_parse(select) failed!\n");
 }
 
@@ -37,46 +48,37 @@ while ($row = oci_fetch_row($s)) {
 	var_dump($row);
 }
 
-require dirname(__FILE__).'/drop_table.inc';
+// Cleanup
+
+$stmtarray = array(
+    "drop table fetch_row_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
---EXPECT--
-array(5) {
+--EXPECTF--
+array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
-  [2]=>
-  NULL
-  [3]=>
-  NULL
-  [4]=>
-  NULL
+  %unicode|string%(1) "1"
 }
-array(5) {
+array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
-  [2]=>
-  NULL
-  [3]=>
-  NULL
-  [4]=>
-  NULL
+  %unicode|string%(1) "1"
 }
-array(5) {
+array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
-  [2]=>
-  NULL
-  [3]=>
-  NULL
-  [4]=>
-  NULL
+  %unicode|string%(1) "1"
 }
 Done
diff --git a/ext/oci8/tests/field_funcs1.phpt b/ext/oci8/tests/field_funcs1.phpt
index b41e743..0b4ad76 100644
--- a/ext/oci8/tests/field_funcs1.phpt
+++ b/ext/oci8/tests/field_funcs1.phpt
@@ -5,28 +5,39 @@ oci_field_*() family
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
-
-$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
-
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
-
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+require(dirname(__FILE__)."/connect.inc");
+
+// Initialize
+
+$stmtarray = array(
+    "drop table field_funcs1_tab",
+    "create table field_funcs1_tab (id number, value number)",
+    "insert into field_funcs1_tab (id, value) values (1,1)",
+    "insert into field_funcs1_tab (id, value) values (1,1)",
+    "insert into field_funcs1_tab (id, value) values (1,1)",
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                        942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-$select_sql = "SELECT * FROM ".$schema."".$table_name."";
+// Run Test
 
-if (!($s = oci_parse($c, $select_sql))) {
+if (!($s = oci_parse($c, "select * from field_funcs1_tab"))) {
 	die("oci_parse(select) failed!\n");
 }
 
@@ -71,23 +82,27 @@ var_dump(oci_field_size($s, array()));
 
 var_dump(oci_field_size($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table field_funcs1_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
 --EXPECTF--
-array(5) {
+array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
-  [2]=>
-  NULL
-  [3]=>
-  NULL
-  [4]=>
-  NULL
+  %unicode|string%(1) "1"
 }
 
 Warning: oci_field_is_null(): Invalid column index "-1" in %s on line %d
diff --git a/ext/oci8/tests/field_funcs2.phpt b/ext/oci8/tests/field_funcs2.phpt
index 9b8d3e5..502d079 100644
--- a/ext/oci8/tests/field_funcs2.phpt
+++ b/ext/oci8/tests/field_funcs2.phpt
@@ -5,10 +5,9 @@ Bug #41917 (invalid scale and precision)
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$s = oci_parse($c, 'drop table b41917t');
+$s = oci_parse($c, 'drop table field_funcs2_tab');
 @oci_execute($s);
 
 $t = array("C01" => "NUMBER",
@@ -29,7 +28,7 @@ $t = array("C01" => "NUMBER",
 		   "C16" => "REAL",
 		   );
 
-$stmt = "create table b41917t (\n";
+$stmt = "create table field_funcs2_tab (\n";
 foreach ($t as $colname => $type) {
 	$stmt .= "$colname $type,\n";
 }
@@ -38,7 +37,7 @@ $stmt[strlen($stmt)-2] = ")";
 $s = oci_parse($c, $stmt);
 oci_execute($s);
 
-$s = oci_parse($c, "select * from b41917t");
+$s = oci_parse($c, "select * from field_funcs2_tab");
 oci_execute($s);
 
 for ($i = 1; $i <= oci_num_fields($s); $i++) {
@@ -67,4 +66,4 @@ C13 FLOAT: precision 126, scale -127
 C14 FLOAT(9): precision 9, scale -127
 C15 DOUBLE PRECISION: precision 126, scale -127
 C16 REAL: precision 63, scale -127
-Done
\ No newline at end of file
+Done
diff --git a/ext/oci8/tests/lob_043.phpt b/ext/oci8/tests/lob_043.phpt
new file mode 100644
index 0000000..5ae2d45
--- /dev/null
+++ b/ext/oci8/tests/lob_043.phpt
@@ -0,0 +1,101 @@
+--TEST--
+Bug #49560 (LOB resource destructor and refcount test)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialization
+
+$stmtarray = array(
+	"drop table lob_043_tab",
+	"create table lob_043_tab(id number, c1 clob)",
+	"begin 
+       for i in 1..50000 loop
+         insert into lob_043_tab (id, c1) values (i, i || ' abcdefghijklmnopq');
+      end loop;
+     end;",
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+			    942 // table or view does not exist
+			,  2289 // sequence does not exist
+			,  4080 // trigger does not exist
+                        , 38802 // edition does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+// Run Test
+
+function f1($c)
+{
+    $s = oci_parse($c, 'select id, c1 from lob_043_tab order by id');
+    oci_execute($s);
+    $r = array();
+    while (($row = oci_fetch_array($s, OCI_RETURN_NULLS+OCI_ASSOC+OCI_RETURN_LOBS)) !== false) {
+        $r[] = $row['C1'];
+    }
+    echo "f1 ended\n";
+    return $r;
+}
+
+function f2($c)
+{
+    $s = oci_parse($c, 'select id, c1 from lob_043_tab order by id');
+    oci_execute($s);
+    $r = array();
+    while (($row = oci_fetch_array($s, OCI_RETURN_NULLS+OCI_ASSOC)) !== false) {
+        $r[] = $row['C1'];
+    }
+    echo "f2 ended\n";
+    return $r;
+}
+
+echo "Test 1\n";
+$r = f1($c);
+/*
+  foreach ($r as $v) {
+  echo $v, "\n";
+  }
+*/
+
+echo "Test 2\n";
+$r = f2($c);
+/*
+  foreach ($r as $v) {
+  echo $v->load(), "\n";
+  }
+*/
+
+// Clean up
+
+$stmtarray = array(
+	"drop table lob_043_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1
+f1 ended
+Test 2
+f2 ended
+===DONE===
diff --git a/ext/oci8/tests/num.phpt b/ext/oci8/tests/num.phpt
index 458e377..e9dc6a8 100644
--- a/ext/oci8/tests/num.phpt
+++ b/ext/oci8/tests/num.phpt
@@ -5,8 +5,34 @@ oci_num_*() family
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
+
+// Initialize
+
+$stmtarray = array(
+    "drop table num_tab",
+    "create table num_tab (id number, value number)",
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                        942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
+// Run Test
 
 echo "Test 1\n";
 var_dump(ocirowcount());
@@ -14,13 +40,12 @@ var_dump(oci_num_rows());
 var_dump(ocinumcols());
 var_dump(oci_num_fields());
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
-
+echo "Test 2\n";
+$insert_sql = "insert into num_tab (id, value) values (1,1)";
 if (!($s = oci_parse($c, $insert_sql))) {
-  die("oci_parse(insert) failed!\n");
+    die("oci_parse(insert) failed!\n");
 }
 
-echo "Test 2\n";
 var_dump(ocirowcount($s));
 var_dump(oci_num_rows($s));
 var_dump(ocinumcols($s));
@@ -49,7 +74,7 @@ var_dump(ocinumcols($s));
 var_dump(oci_num_fields($s));
 
 // All rows
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+$select_sql = "select * from num_tab";
 
 if (!($s = oci_parse($c, $select_sql))) {
   die("oci_parse(select) failed!\n");
@@ -83,7 +108,7 @@ var_dump(ocinumcols($s));
 var_dump(oci_num_fields($s));
 
 // One row
-$select_sql = "SELECT id, value FROM ".$schema.$table_name." WHERE ROWNUM < 2";
+$select_sql = "SELECT id, value FROM num_tab WHERE ROWNUM < 2";
 
 if (!($s = oci_parse($c, $select_sql))) {
   die("oci_parse(select) failed!\n");
@@ -104,7 +129,7 @@ var_dump(ocinumcols($s));
 var_dump(oci_num_fields($s));
 
 // No rows
-$select_sql = "SELECT id FROM ".$schema.$table_name." WHERE 1=0";
+$select_sql = "select id from num_tab where 1=0";
 
 if (!($s = oci_parse($c, $select_sql))) {
   die("oci_parse(select) failed!\n");
@@ -124,7 +149,7 @@ var_dump(oci_num_rows($s));
 var_dump(ocinumcols($s));
 var_dump(oci_num_fields($s));
 
-$delete_sql = "DELETE FROM ".$schema.$table_name."";
+$delete_sql = "delete from num_tab";
 
 if (!($s = oci_parse($c, $delete_sql))) {
     die("oci_parse(delete) failed!\n");
@@ -149,7 +174,17 @@ var_dump(oci_num_rows($s));
 var_dump(ocinumcols($s));
 var_dump(oci_num_fields($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table num_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
 
 echo "Done\n";
 
@@ -191,13 +226,13 @@ int(0)
 Test 5b
 int(0)
 int(0)
-int(5)
-int(5)
+int(2)
+int(2)
 Test 5c
 int(3)
 int(3)
-int(5)
-int(5)
+int(2)
+int(2)
 Test 6
 int(1)
 int(1)
diff --git a/ext/oci8/tests/oci8safemode.phpt b/ext/oci8/tests/oci8safemode.phpt
index 112e544..1c62f36 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--
-PHP Warning:  Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+%sarning:%sDirective '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/oci8/tests/password_new.phpt b/ext/oci8/tests/password_new.phpt
index e8642ab..ba6baa9 100644
--- a/ext/oci8/tests/password_new.phpt
+++ b/ext/oci8/tests/password_new.phpt
@@ -3,21 +3,21 @@ oci_password_change()
 --SKIPIF--
 <?php
 if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
-require dirname(__FILE__)."/connect.inc";
+require(dirname(__FILE__)."/connect.inc");
 if (empty($dbase)) die ("skip requires database connection string be set");
 if ($test_drcp) die("skip password change not supported in DRCP Mode");
 
-// This test is known to fail with Oracle 10g client libraries
-// connecting to Oracle Database 11.1.0.6 (Oracle bug 6277160)
+// This test is known to fail with Oracle 10.2.0.4 client libraries
+// connecting to Oracle Database 11 (Oracle bug 6277160, fixed 10.2.0.5)
 $sv = oci_server_version($c);
-$sv = preg_match('/11.1/', $sv, $matches);
+$sv = preg_match('/Release (11|12)\./', $sv, $matches);
 if ($sv === 1) {
 	ob_start();
 	phpinfo(INFO_MODULES);
 	$phpinfo = ob_get_clean();
 	$iv = preg_match('/Oracle .*Version => 10/', $phpinfo);
 	if ($iv === 1) {
-		die ("skip test known to fail using Oracle 10gR2 client libs connecting to Oracle 11.1 (6277160)");
+		die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)");
 	}
 }
 ?>
diff --git a/ext/oci8/tests/password_old.phpt b/ext/oci8/tests/password_old.phpt
index 157bdeb..abcaeb1 100644
--- a/ext/oci8/tests/password_old.phpt
+++ b/ext/oci8/tests/password_old.phpt
@@ -3,21 +3,21 @@ ocipasswordchange()
 --SKIPIF--
 <?php
 if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
-require dirname(__FILE__)."/connect.inc";
+require(dirname(__FILE__)."/connect.inc");
 if (empty($dbase)) die ("skip requires database connection string be set");
 if ($test_drcp) die("skip password change not supported in DRCP Mode");
 
-// This test is known to fail with Oracle 10g client libraries
-// connecting to Oracle Database 11.1.0.6 (Oracle bug 6277160)
+// This test is known to fail with Oracle 10.2.0.4 client libraries
+// connecting to Oracle Database 11 (Oracle bug 6277160, fixed 10.2.0.5)
 $sv = oci_server_version($c);
-$sv = preg_match('/11.1/', $sv, $matches);
+$sv = preg_match('/Release (11|12)\./', $sv, $matches);
 if ($sv === 1) {
 	ob_start();
 	phpinfo(INFO_MODULES);
 	$phpinfo = ob_get_clean();
 	$iv = preg_match('/Oracle .*Version => 10/', $phpinfo);
 	if ($iv === 1) {
-		die ("skip test known to fail using Oracle 10gR2 client libs connecting to Oracle 11.1 (6277160)");
+		die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)");
 	}
 }
 ?>
diff --git a/ext/oci8/tests/prefetch.phpt b/ext/oci8/tests/prefetch.phpt
index fa4b8fd..2676260 100644
--- a/ext/oci8/tests/prefetch.phpt
+++ b/ext/oci8/tests/prefetch.phpt
@@ -5,26 +5,39 @@ oci_set_prefetch()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-	die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table prefetch_tab",
+    "create table prefetch_tab (id number, value number)",
+    "insert into prefetch_tab (id, value) values (1,1)",
+    "insert into prefetch_tab (id, value) values (1,1)",
+    "insert into prefetch_tab (id, value) values (1,1)",
+);
 
-for ($i = 0; $i<3; $i++) {
-	if (!oci_execute($s)) {
-		die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+                        942 // table or view does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
 	}
 }
 
-if (!oci_commit($c)) {
-	die("oci_commit() failed!\n");
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+// Run Test
+
+$select_sql = "select * from prefetch_tab";
 
 if (!($s = oci_parse($c, $select_sql))) {
 	die("oci_parse(select) failed!\n");
@@ -37,11 +50,19 @@ if (!oci_execute($s)) {
 }
 
 var_dump(oci_fetch($s));
-
 var_dump(oci_num_rows($s));
 
-require dirname(__FILE__).'/drop_table.inc';
-	
+// Cleanup
+
+$stmtarray = array(
+    "drop table prefetch_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
 echo "Done\n";
 ?>
 --EXPECT--
diff --git a/ext/oci8/tests/prefetch_old.phpt b/ext/oci8/tests/prefetch_old.phpt
index cb9cb39..c2ac8fe 100644
--- a/ext/oci8/tests/prefetch_old.phpt
+++ b/ext/oci8/tests/prefetch_old.phpt
@@ -5,26 +5,41 @@ ocisetprefetch()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+$stmtarray = array(
+    "drop table prefetch_old_tab",
+    "create table prefetch_old_tab (id number, value number)",
+    "insert into prefetch_old_tab (id, value) values (1,1)",
+    "insert into prefetch_old_tab (id, value) values (1,1)",
+    "insert into prefetch_old_tab (id, value) values (1,1)",
+);
 
-if (!($s = ociparse($c, $insert_sql))) {
-	die("ociparse(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+    $s = oci_parse($c, $stmt);
+    $r = @oci_execute($s);
+    if (!$r) {
+        $m = oci_error($s);
+        if (!in_array($m['code'], array(   // ignore expected errors
+                    942 // table or view does not exist
+                ))) {
+            echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+        }
+    }
 }
 
-for ($i = 0; $i<3; $i++) {
-	if (!ociexecute($s)) {
-		die("ociexecute(insert) failed!\n");
-	}
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
 }
 
+// Run Test
+
 if (!ocicommit($c)) {
 	die("ocicommit() failed!\n");
 }
 
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+$select_sql = "select * from prefetch_old_tab";
 
 if (!($s = ociparse($c, $select_sql))) {
 	die("ociparse(select) failed!\n");
@@ -37,10 +52,19 @@ if (!ociexecute($s)) {
 }
 
 var_dump(ocifetch($s));
-
 var_dump(ocirowcount($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table prefetch_old_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+    $s = oci_parse($c, $stmt);
+    oci_execute($s);
+}
 	
 echo "Done\n";
 ?>
diff --git a/ext/oci8/tests/refcur_prefetch_1.phpt b/ext/oci8/tests/refcur_prefetch_1.phpt
new file mode 100644
index 0000000..c603fdd
--- /dev/null
+++ b/ext/oci8/tests/refcur_prefetch_1.phpt
@@ -0,0 +1,256 @@
+--TEST--
+Prefetch with REF cursor. Test different values for prefetch with oci_set_prefetch().
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.inc");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
+if ($iv == 1) {
+	$sv = oci_server_version($c);
+	$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+	if ($sv != 1) {
+        die ("skip expected output only valid when using Oracle 10g or greater server");
+	}
+}
+else {
+    die ("skip expected output only valid when using Oracle 11.2 or greater client");
+}
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/connect.inc");
+
+// Creates the necessary package and tables. 
+$stmtarray = array(
+	   "DROP TABLE refcurtest",
+	   "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))",
+           "CREATE or REPLACE PACKAGE refcurpkg is
+           type refcursortype is ref cursor;
+           procedure open_ref_cur(cur1 out refcursortype);
+           procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,c2 out varchar2);
+           end refcurpkg;",
+          "CREATE or REPLACE PACKAGE body refcurpkg is
+  	    procedure open_ref_cur(cur1 out refcursortype) is
+              begin
+	        open cur1 for select * from refcurtest order by c1;
+	      end open_ref_cur;
+  	     procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,
+		c2 out varchar2) is
+  	      begin
+	    	fetch cur1 into c1,c2;
+	    end fetch_ref_cur;
+         end refcurpkg;"
+	);
+
+foreach($stmtarray as $stmt) {
+	$s = oci_parse($c,$stmt);
+	$r = @oci_execute($s);
+    if (!$r) {
+		$msg = oci_error($s);
+		if ($msg['code'] != 942) {
+            echo $msg['message'],"\n";
+		}
+	}
+}
+
+// Insert 500 rows into the table.
+$insert_sql = "INSERT INTO refcurtest (c1, c2) VALUES (:c1,:c2)";
+if (!($s = oci_parse($c, $insert_sql))) {
+    die("oci_parse(insert) failed!\n");
+}
+
+for ($i = 0; $i<=500; $i++) {
+    $val2 = 'test'.$i;
+    oci_bind_by_name($s,':c1',$i);
+    oci_bind_by_name($s,':c2',$val2);
+    if (!oci_execute($s)) {
+        die("oci_execute(insert) failed!\n");
+    }
+}
+
+// Various values for prefetch
+$pref = array(0,1,501,499,250,12345,-12345,-1);
+foreach($pref as $value) {
+    echo"-----------------------------------------------\n";
+    echo "Test with Prefetch value set to $value \n";
+    echo"-----------------------------------------------\n";
+    $cur1 = oci_new_cursor($c);
+    fetch_frm_php($c,$cur1,$value);
+    fetch_frm_plsql($c,$cur1);
+}
+
+
+// This function sets the prefetch count to the given $value and fetches one row .
+
+function fetch_frm_php($c,$cur1,$value) {
+    $sql1 = "begin refcurpkg.open_ref_cur(:cur1); end;";
+    $s1 = oci_parse($c,$sql1);
+    if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
+        die("oci_bind_by_name(sql1) failed!\n");
+    }
+    oci_execute($s1);
+    oci_set_prefetch($cur1,$value);
+    oci_execute($cur1);
+    echo "Fetch Row  from PHP\n";
+    var_dump(oci_fetch_row($cur1));
+}
+ 
+// This function calls the fetch_ref_cur procedure to get the values from the REF cur.
+
+function fetch_frm_plsql($c,$cur1) {
+    $sql2 = "begin refcurpkg.fetch_ref_cur(:curs1,:c1,:c2); end;";
+    $s2 = oci_parse($c,$sql2);
+    if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
+        die("oci_bind_by_name(sql2) failed!\n");
+    }
+    if (!oci_bind_by_name($s2,":c1",$c1,SQLT_INT)) {
+        die("oci_bind_by_name(sql2) failed!\n");
+    }
+    if (!oci_bind_by_name($s2,":c2",$c2,SQLT_AFC)) {
+        die("oci_bind_by_name(sql2) failed!\n");
+    }
+    oci_execute($s2);
+    echo "Fetch Row  from PL/SQL\n";
+    var_dump($c1);
+    var_dump($c2);
+}
+
+// Clean up  here
+
+$stmtarray = array(
+    "drop package refcurpkg",
+    "drop table refcurtest"
+);
+
+foreach($stmtarray as $stmt) {
+    $s = oci_parse($c,$stmt);
+    $r = @oci_execute($s);
+    if (!$r) {
+        $msg = oci_error($s);
+        echo $msg['message'],"\n";
+    }
+}
+oci_close($c);
+echo "Done\n";
+?>
+--EXPECTF--
+-----------------------------------------------
+Test with Prefetch value set to 0 
+-----------------------------------------------
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+Fetch Row  from PL/SQL
+%unicode|string%(%d) "1"
+%unicode|string%(%d) "test1"
+-----------------------------------------------
+Test with Prefetch value set to 1 
+-----------------------------------------------
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+Fetch Row  from PL/SQL
+%unicode|string%(%d) "2"
+%unicode|string%(%d) "test2"
+-----------------------------------------------
+Test with Prefetch value set to 501 
+-----------------------------------------------
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+
+Warning: oci_execute(): ORA-01002: %s
+ORA-06512: at "SYSTEM.REFCURPKG", line %d
+ORA-06512: at line %d in %s on line %d
+Fetch Row  from PL/SQL
+NULL
+NULL
+-----------------------------------------------
+Test with Prefetch value set to 499 
+-----------------------------------------------
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+Fetch Row  from PL/SQL
+%unicode|string%(%d) "500"
+%unicode|string%(%d) "test500"
+-----------------------------------------------
+Test with Prefetch value set to 250 
+-----------------------------------------------
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+Fetch Row  from PL/SQL
+%unicode|string%(%d) "251"
+%unicode|string%(%d) "test251"
+-----------------------------------------------
+Test with Prefetch value set to 12345 
+-----------------------------------------------
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+
+Warning: oci_execute(): ORA-01002: %s
+ORA-06512: at "SYSTEM.REFCURPKG", line %d
+ORA-06512: at line %d in %s on line %d
+Fetch Row  from PL/SQL
+NULL
+NULL
+-----------------------------------------------
+Test with Prefetch value set to -12345 
+-----------------------------------------------
+
+Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+Fetch Row  from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+-----------------------------------------------
+Test with Prefetch value set to -1 
+-----------------------------------------------
+
+Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+Fetch Row  from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+Done
diff --git a/ext/oci8/tests/refcur_prefetch_2.phpt b/ext/oci8/tests/refcur_prefetch_2.phpt
new file mode 100644
index 0000000..751ffa7
--- /dev/null
+++ b/ext/oci8/tests/refcur_prefetch_2.phpt
@@ -0,0 +1,317 @@
+--TEST--
+Prefetch with REF cursor. Test No 2
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.inc");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
+if ($iv == 1) {
+    $sv = oci_server_version($c);
+    $sv = preg_match('/Release 1[012]\./', $sv, $matches);
+    if ($sv != 1) {
+        die ("skip expected output only valid when using Oracle 10g or greater server");
+    }
+}
+else {
+    die ("skip expected output only valid when using  Oracle 11.1 or greater client");
+}
+?>
+--FILE--
+<?php
+require dirname(__FILE__)."/connect.inc";
+
+// Creates the necessary package and tables. 
+$stmtarray = array(
+	   "DROP TABLE refcurtest",
+	   "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))",
+           "CREATE or REPLACE PACKAGE refcurpkg is
+           type refcursortype is ref cursor;
+           procedure open_ref_cur(cur1 out refcursortype);
+           procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,c2 out varchar2);
+           end refcurpkg;",
+          "CREATE or REPLACE PACKAGE body refcurpkg is
+  	    procedure open_ref_cur(cur1 out refcursortype) is
+              begin
+	        open cur1 for select * from refcurtest order by c1;
+	      end open_ref_cur;
+  	     procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,
+		c2 out varchar2) is
+  	      begin
+	    	fetch cur1 into c1,c2;
+	    end fetch_ref_cur;
+         end refcurpkg;"
+	);
+
+foreach($stmtarray as $stmt) {
+	$s = oci_parse($c,$stmt);
+	$r = @oci_execute($s);
+    if (!$r) {
+		$msg = oci_error($s);
+		if ($msg['code'] != 942) {
+            echo $msg['message'],"\n";
+		}
+	}
+}
+
+// Insert 500 rows into the table.
+$insert_sql = "INSERT INTO refcurtest (c1, c2) VALUES (:c1,:c2)";
+if (!($s = oci_parse($c, $insert_sql))) {
+    die("oci_parse(insert) failed!\n");
+}
+
+for ($i = 0; $i <= 500; $i++) {
+    $val2 = 'test'.$i;
+    oci_bind_by_name($s,':c1',$i);
+    oci_bind_by_name($s,':c2',$val2);
+    if (!oci_execute($s)) {
+        die("oci_execute(insert) failed!\n");
+    }
+}
+
+// Steps to Fetch from PHP . For every sub-test,the cursor is bound and then executed.
+
+$sql1 = "begin refcurpkg.open_ref_cur(:cur1); end;";
+$s1 = oci_parse($c,$sql1);
+$cur1 = oci_new_cursor($c);
+if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
+    die("oci_bind_by_name(sql1) failed!\n");
+}
+
+
+// Steps to Fetch from PL/SQL . For every sub-test,the cursor is bound and then executed.
+
+$sql2 = "begin refcurpkg.fetch_ref_cur(:curs1,:c1,:c2); end;";
+$s2 = oci_parse($c,$sql2);
+if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
+    die("oci_bind_by_name(sql2) failed!\n");
+}
+if (!oci_bind_by_name($s2,":c1",$c1,SQLT_INT)) {
+    die("oci_bind_by_name(sql2) failed!\n");
+}
+if (!oci_bind_by_name($s2,":c2",$c2,SQLT_AFC)) {
+    die("oci_bind_by_name(sql2) failed!\n");
+}
+
+
+echo "------Test 1- Check Roundtrips with  prefetch 0 and 5 -----------\n";
+oci_execute($s1);
+oci_execute($cur1);
+$initial_rt = print_roundtrips($c);
+oci_set_prefetch($cur1,0);
+for ($i = 0;$i<5;$i++) {
+    var_dump(oci_fetch_row($cur1));
+}
+
+$cnt = (print_roundtrips($c) - $initial_rt);
+echo "Number of roundtrips made with prefetch count 0 for 5 rows is  $cnt\n";
+
+$initial_rt = print_roundtrips($c);
+oci_set_prefetch($cur1,5);
+for ($i = 0;$i<5;$i++) {
+    var_dump(oci_fetch_row($cur1));
+}
+
+$cnt = (print_roundtrips($c) - $initial_rt );
+echo "Number of roundtrips made with prefetch count 5 for 5 rows is  $cnt\n";
+
+echo "------Test 2 - Set Prefetch before PL/SQL fetch ----------\n";
+// Fetch from PHP
+$cur1 = oci_new_cursor($c);
+if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
+    die("oci_bind_by_name(sql1) failed!\n");
+}
+
+echo "Fetch Row  from PHP\n";
+oci_execute($s1);
+oci_execute($cur1);
+var_dump(oci_fetch_row($cur1));
+oci_set_prefetch($cur1,5);
+
+// Fetch from PL/SQL 
+if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
+    die("oci_bind_by_name(sql2) failed!\n");
+}
+oci_execute($s2);
+echo "Fetch Row  from PL/SQL\n";
+var_dump($c1);
+var_dump($c2);
+
+echo "------Test 3 - Set Prefetch after PL/SQL fetch ----------\n";
+$cur1 = oci_new_cursor($c);
+// Fetch from PL/SQL 
+if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
+    die("oci_bind_by_name(sql2) failed!\n");
+}
+oci_execute($s2);
+echo "Fetch Row  from PL/SQL\n";
+var_dump($c1);
+var_dump($c2);
+
+// Fetch from PHP
+echo "Fetch Row  from PHP\n";
+if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
+    die("oci_bind_by_name(sql1) failed!\n");
+}
+oci_set_prefetch($cur1,5);
+oci_execute($s1);
+oci_execute($cur1);
+var_dump(oci_fetch_row($cur1));
+
+echo "------Test 4- Overwrite prefetch-----------\n";
+// Fetch from PHP
+$cur1 = oci_new_cursor($c);
+if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
+    die("oci_bind_by_name(sql1) failed!\n");
+}
+echo "Fetch Row  from PHP\n";
+oci_execute($s1);
+oci_execute($cur1);
+var_dump(oci_fetch_row($cur1));
+oci_set_prefetch($cur1,5);
+oci_set_prefetch($cur1,0);
+oci_set_prefetch($cur1,100);
+
+// Fetch from PL/SQL
+if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
+    die("oci_bind_by_name(sql2) failed!\n");
+}
+oci_execute($s2);
+echo "Fetch Row  from PL/SQL\n";
+var_dump($c1);
+var_dump($c2);
+
+
+function  print_roundtrips($c) {
+    $sql_stmt = "select value from v\$mystat a,v\$statname c where
+	 a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'";
+    $s = oci_parse($c,$sql_stmt);
+    oci_define_by_name($s,"VALUE",$value);
+    oci_execute($s);
+    oci_fetch($s);
+    return $value;
+}
+
+// Clean up  here
+
+$stmtarray = array(
+    "drop package refcurpkg",
+    "drop table refcurtest"
+);
+
+foreach($stmtarray as $stmt) {
+    $s = oci_parse($c,$stmt);
+    $r = @oci_execute($s);
+    if (!$r) {
+        $msg = oci_error($s);
+        echo $msg['message'],"\n";
+    }
+}
+
+oci_close($c);
+echo "Done\n";
+?>
+--EXPECTF--
+------Test 1- Check Roundtrips with  prefetch 0 and 5 -----------
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "1"
+  [1]=>
+  %unicode|string%(%d) "test1"
+}
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "2"
+  [1]=>
+  %unicode|string%(%d) "test2"
+}
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "3"
+  [1]=>
+  %unicode|string%(%d) "test3"
+}
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "4"
+  [1]=>
+  %unicode|string%(%d) "test4"
+}
+Number of roundtrips made with prefetch count 0 for 5 rows is  6
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "5"
+  [1]=>
+  %unicode|string%(%d) "test5"
+}
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "6"
+  [1]=>
+  %unicode|string%(%d) "test6"
+}
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "7"
+  [1]=>
+  %unicode|string%(%d) "test7"
+}
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "8"
+  [1]=>
+  %unicode|string%(%d) "test8"
+}
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "9"
+  [1]=>
+  %unicode|string%(%d) "test9"
+}
+Number of roundtrips made with prefetch count 5 for 5 rows is  2
+------Test 2 - Set Prefetch before PL/SQL fetch ----------
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+Fetch Row  from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+------Test 3 - Set Prefetch after PL/SQL fetch ----------
+
+Warning: oci_execute(): ORA-01001: %s
+ORA-06512: at "SYSTEM.REFCURPKG", line %d
+ORA-06512: at line %d in %s on line %d
+Fetch Row  from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+------Test 4- Overwrite prefetch-----------
+Fetch Row  from PHP
+array(2) {
+  [0]=>
+  %unicode|string%(%d) "0"
+  [1]=>
+  %unicode|string%(%d) "test0"
+}
+Fetch Row  from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+Done
diff --git a/ext/oci8/tests/refcur_prefetch_3.phpt b/ext/oci8/tests/refcur_prefetch_3.phpt
new file mode 100644
index 0000000..0666a96
--- /dev/null
+++ b/ext/oci8/tests/refcur_prefetch_3.phpt
@@ -0,0 +1,161 @@
+--TEST--
+Prefetch with Nested cursors with INI setting.
+--INI--
+oci8.default_prefetch=5
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.inc");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
+if ($iv == 1) {
+    $sv = oci_server_version($c);
+    $sv = preg_match('/Release (11\.2|12\.)/', $sv, $matches);
+    if ($sv != 1) {
+        die ("skip expected output only valid when using Oracle 11.2 or greater server");
+    }
+}
+else {
+    die ("skip expected output only valid when using Oracle 11.2 or greater client");
+}
+
+?>
+--FILE--
+<?php
+require dirname(__FILE__)."/connect.inc";
+
+//Create tables here
+$stmtarray = array(
+    "drop table nescurtest",
+    "create table nescurtest(c1 varchar2(10))"
+);
+
+foreach($stmtarray as $stmt) {
+    $s = oci_parse($c,$stmt);
+    $r = @oci_execute($s);
+    if (!$r) {
+        $msg = oci_error($s);
+		if ($msg['code'] !=942) {
+            echo $msg['message'],"\n";
+		}
+    }
+}
+// Insert 500 rows into the table.
+$insert_sql = "INSERT INTO nescurtest (c1) VALUES (:c1)";
+if (!($s = oci_parse($c, $insert_sql))) {
+    die("oci_parse(insert) failed!\n");
+}
+
+for ($i = 0; $i<=500; $i++) {
+    $val2 = 'test'.$i;
+    oci_bind_by_name($s,':c1',$val2);
+    if (!oci_execute($s)) {
+        die("oci_execute(insert) failed!\n");
+    }
+}
+
+echo"-----------------------------------------------\n";
+echo "Test with Nested Cursors\n";
+echo"-----------------------------------------------\n";
+$cur1 = oci_new_cursor($c);
+$sqlstmt = "select cursor(select * from nescurtest) curs1 from dual";
+$s = oci_parse($c,$sqlstmt);
+oci_execute($s);
+$data = oci_fetch_array($s);
+oci_execute($data['CURS1']);
+
+// Calculate round-trips 
+$initial_rt = print_roundtrips($c);
+for ($i = 0;$i<10;$i++) {
+    echo "Fetch Row using Nested cursor Query\n";
+    var_dump(oci_fetch_row($data['CURS1']));
+}
+
+$cnt = (print_roundtrips($c) - $initial_rt);
+echo "Number of roundtrips made with prefetch count 5 for 10 rows is  $cnt\n";
+
+function  print_roundtrips($c) {
+    $sql_stmt = "select value from v\$mystat a,v\$statname c where
+         a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'";
+    $s = oci_parse($c,$sql_stmt);
+    oci_define_by_name($s,"VALUE",$value);
+    oci_execute($s);
+    oci_fetch($s);
+    return $value;
+}
+
+// Clean up  here
+
+$stmtarray = array(
+    "drop table nescurtest"
+);
+
+foreach($stmtarray as $stmt) {
+    $s = oci_parse($c,$stmt);
+    $r = @oci_execute($s);
+    if (!$r) {
+        $msg = oci_error($s);
+        echo $msg['message'],"\n";
+    }
+}
+oci_close($c);
+echo "Done\n";
+?>
+--EXPECTF--
+-----------------------------------------------
+Test with Nested Cursors
+-----------------------------------------------
+Fetch Row using Nested cursor Query
+array(1) {
+  [0]=>
+  %unicode|string%(%d) "test0"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+  [0]=>
+  %unicode|string%(%d) "test1"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+  [0]=>
+  %unicode|string%(%d) "test2"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+  [0]=>
+  %unicode|string%(%d) "test3"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+  [0]=>
+  %unicode|string%(%d) "test4"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+  [0]=>
+  %unicode|string%(%d) "test5"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+  [0]=>
+  %unicode|string%(%d) "test6"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+  [0]=>
+  %unicode|string%(%d) "test7"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+  [0]=>
+  %unicode|string%(%d) "test8"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+  [0]=>
+  %unicode|string%(%d) "test9"
+}
+Number of roundtrips made with prefetch count 5 for 10 rows is  3
+Done
diff --git a/ext/oci8/tests/reflection1.phpt b/ext/oci8/tests/reflection1.phpt
index 62ee02b..5f2e73d 100644
--- a/ext/oci8/tests/reflection1.phpt
+++ b/ext/oci8/tests/reflection1.phpt
@@ -121,6 +121,11 @@ reflection::export(new reflectionfunction('ocicollassignelem'));
 reflection::export(new reflectionfunction('ocicollsize'));
 reflection::export(new reflectionfunction('ocicollmax'));
 reflection::export(new reflectionfunction('ocicolltrim'));
+reflection::export(new reflectionfunction('oci_set_edition'));
+reflection::export(new reflectionfunction('oci_set_module_name'));
+reflection::export(new reflectionfunction('oci_set_action'));
+reflection::export(new reflectionfunction('oci_set_client_info'));
+reflection::export(new reflectionfunction('oci_set_client_identifier'));
 
 ?>
 ===DONE===
@@ -1049,4 +1054,43 @@ Function [ <internal%s> function ocicolltrim ] {
   }
 }
 
+Function [ <internal%s> function oci_set_edition ] {
+
+  - Parameters [1] {
+    Parameter #0 [ <required> $edition_name ]
+  }
+}
+
+Function [ <internal%s> function oci_set_module_name ] {
+
+  - Parameters [2] {
+    Parameter #0 [ <required> $connection_resource ]
+    Parameter #1 [ <required> $module_name ]
+  }
+}
+
+Function [ <internal%s> function oci_set_action ] {
+
+  - Parameters [2] {
+    Parameter #0 [ <required> $connection_resource ]
+    Parameter #1 [ <required> $action ]
+  }
+}
+
+Function [ <internal%s> function oci_set_client_info ] {
+
+  - Parameters [2] {
+    Parameter #0 [ <required> $connection_resource ]
+    Parameter #1 [ <required> $client_information ]
+  }
+}
+
+Function [ <internal%s> function oci_set_client_identifier ] {
+
+  - Parameters [2] {
+    Parameter #0 [ <required> $connection_resource ]
+    Parameter #1 [ <required> $client_identifier ]
+  }
+}
+
 ===DONE===
diff --git a/ext/oci8/tests/xmltype_02.phpt b/ext/oci8/tests/xmltype_02.phpt
new file mode 100644
index 0000000..9b6fa8a
--- /dev/null
+++ b/ext/oci8/tests/xmltype_02.phpt
@@ -0,0 +1,197 @@
+--TEST--
+Basic XMLType test #2
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialization
+
+$stmtarray = array(
+	"drop table xmltype_02_tab",
+	"create table xmltype_02_tab (warehouse_id number, warehouse_spec xmltype)",
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	$r = @oci_execute($s);
+	if (!$r) {
+		$m = oci_error($s);
+		if (!in_array($m['code'], array(   // ignore expected errors
+			   942 // table or view does not exist
+			, 2289 // sequence does not exist
+			, 4080 // trigger does not exist
+                ))) {
+			echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+		}
+	}
+}
+
+// Run Test
+
+
+$id = 1;
+
+// Delete any current entry
+$s = oci_parse($c, "delete from xmltype_02_tab where warehouse_id = :id");
+oci_bind_by_name($s, ':id', $id);
+oci_execute($s);
+
+// XML data to be inserted
+$xml =<<<EOF
+<?xml version="1.0"?>
+<Warehouse>
+<WarehouseId>1</WarehouseId>
+<WarehouseName>Southlake, Texas</WarehouseName>
+<Building>Owned</Building>
+<Area>25000</Area>
+<Docks>2</Docks>
+<DockType>Rear load</DockType>
+<WaterAccess>true</WaterAccess>
+<RailAccess>N</RailAccess>
+<Parking>Street</Parking>
+<VClearance>10</VClearance>
+</Warehouse>
+EOF;
+
+echo "Test 1 Insert new XML data using a temporary CLOB\n";
+$s = oci_parse($c, 
+    "insert into xmltype_02_tab (warehouse_id, warehouse_spec) 
+     values (:id, XMLType(:clob))");
+oci_bind_by_name($s, ':id', $id);
+$lob = oci_new_descriptor($c, OCI_D_LOB);
+oci_bind_by_name($s, ':clob', $lob, -1, OCI_B_CLOB);
+$lob->writeTemporary($xml);
+oci_execute($s);
+$lob->close();
+
+// Query the row back
+$s = oci_parse($c, 'select xmltype.getclobval(warehouse_spec)
+                    from xmltype_02_tab where warehouse_id = :id');
+$r = oci_bind_by_name($s, ':id', $id);
+oci_execute($s);
+$row = oci_fetch_array($s, OCI_NUM);
+
+var_dump($row);
+
+echo "Test 2 Manipulate the data using SimpleXML\n";
+
+$sx = simplexml_load_string((binary)$row[0]->load());
+$row[0]->free();
+var_dump($sx);
+
+$sx->Docks -= 1;  // change the data
+
+var_dump($sx);
+
+echo "Test 3: Update changes using a temporary CLOB\n";
+
+$s = oci_parse($c, 'update xmltype_02_tab
+                    set warehouse_spec = XMLType(:clob)
+                    where warehouse_id = :id');
+oci_bind_by_name($s, ':id', $id);
+$lob = oci_new_descriptor($c, OCI_D_LOB);
+oci_bind_by_name($s, ':clob', $lob, -1, OCI_B_CLOB);
+$lob->writeTemporary($sx->asXml());
+oci_execute($s);
+$lob->close();
+
+// Query the changed row back and print it
+$s = oci_parse($c, 'select xmltype.getclobval(warehouse_spec)
+                    from xmltype_02_tab where warehouse_id = :id');
+$r = oci_bind_by_name($s, ':id', $id);
+oci_execute($s);
+$row = oci_fetch_array($s, OCI_NUM);
+var_dump($row[0]->load());
+$row[0]->free();
+
+// Clean up
+
+//require(dirname(__FILE__).'/drop_table.inc');
+
+$stmtarray = array(
+	"drop table xmltype_02_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+	$s = oci_parse($c, $stmt);
+	oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1 Insert new XML data using a temporary CLOB
+array(1) {
+  [0]=>
+  object(OCI-Lob)#%d (1) {
+    [%u|b%"descriptor"]=>
+    resource(%d) of type (oci8 descriptor)
+  }
+}
+Test 2 Manipulate the data using SimpleXML
+object(SimpleXMLElement)#%d (10) {
+  [%u|b%"WarehouseId"]=>
+  %unicode|string%(1) "1"
+  [%u|b%"WarehouseName"]=>
+  %unicode|string%(16) "Southlake, Texas"
+  [%u|b%"Building"]=>
+  %unicode|string%(5) "Owned"
+  [%u|b%"Area"]=>
+  %unicode|string%(5) "25000"
+  [%u|b%"Docks"]=>
+  %unicode|string%(1) "2"
+  [%u|b%"DockType"]=>
+  %unicode|string%(9) "Rear load"
+  [%u|b%"WaterAccess"]=>
+  %unicode|string%(4) "true"
+  [%u|b%"RailAccess"]=>
+  %unicode|string%(1) "N"
+  [%u|b%"Parking"]=>
+  %unicode|string%(6) "Street"
+  [%u|b%"VClearance"]=>
+  %unicode|string%(2) "10"
+}
+object(SimpleXMLElement)#%d (10) {
+  [%u|b%"WarehouseId"]=>
+  %unicode|string%(1) "1"
+  [%u|b%"WarehouseName"]=>
+  %unicode|string%(16) "Southlake, Texas"
+  [%u|b%"Building"]=>
+  %unicode|string%(5) "Owned"
+  [%u|b%"Area"]=>
+  %unicode|string%(5) "25000"
+  [%u|b%"Docks"]=>
+  %unicode|string%(1) "1"
+  [%u|b%"DockType"]=>
+  %unicode|string%(9) "Rear load"
+  [%u|b%"WaterAccess"]=>
+  %unicode|string%(4) "true"
+  [%u|b%"RailAccess"]=>
+  %unicode|string%(1) "N"
+  [%u|b%"Parking"]=>
+  %unicode|string%(6) "Street"
+  [%u|b%"VClearance"]=>
+  %unicode|string%(2) "10"
+}
+Test 3: Update changes using a temporary CLOB
+%unicode|string%(331) "<?xml version="1.0"?>
+<Warehouse>
+<WarehouseId>1</WarehouseId>
+<WarehouseName>Southlake, Texas</WarehouseName>
+<Building>Owned</Building>
+<Area>25000</Area>
+<Docks>1</Docks>
+<DockType>Rear load</DockType>
+<WaterAccess>true</WaterAccess>
+<RailAccess>N</RailAccess>
+<Parking>Street</Parking>
+<VClearance>10</VClearance>
+</Warehouse>
+"
+===DONE===
\ No newline at end of file
diff --git a/ext/odbc/birdstep.c b/ext/odbc/birdstep.c
index 6f778a7..3f04d21 100644
--- a/ext/odbc/birdstep.c
+++ b/ext/odbc/birdstep.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: birdstep.c 281742 2009-06-06 02:40:49Z mattwil $ */
+/* $Id: birdstep.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
  * TODO:
diff --git a/ext/odbc/php_birdstep.h b/ext/odbc/php_birdstep.h
index 791cfb1..778e399 100644
--- a/ext/odbc/php_birdstep.h
+++ b/ext/odbc/php_birdstep.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_birdstep.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_birdstep.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_BIRDSTEP_H
 #define PHP_BIRDSTEP_H
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 4d74b29..631b10e 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_odbc.c 280531 2009-05-14 17:24:42Z felipe $ */
+/* $Id: php_odbc.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -981,6 +981,10 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
 									NULL, 0, NULL, &displaysize);
 				displaysize = displaysize <= result->longreadlen ? displaysize : 
 								result->longreadlen;
+				/* Workaround for Oracle ODBC Driver bug (#50162) when fetching TIMESTAMP column */
+				if (result->values[i].coltype == SQL_TIMESTAMP) {
+					displaysize += 3;
+				}
 				result->values[i].value = (char *)emalloc(displaysize + 1);
 				rc = SQLBindCol(result->stmt, (SQLUSMALLINT)(i+1), SQL_C_CHAR, result->values[i].value,
 							displaysize + 1, &result->values[i].vallen);
@@ -1176,13 +1180,7 @@ PHP_FUNCTION(odbc_prepare)
 			/* Try to set CURSOR_TYPE to dynamic. Driver will replace this with other
 			   type if not possible.
 			*/
-			int cursortype = ODBCG(default_cursortype);
-			if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, cursortype) == SQL_ERROR) {
-				odbc_sql_error(conn, result->stmt, " SQLSetStmtOption");
-				SQLFreeStmt(result->stmt, SQL_DROP);
-				efree(result);
-				RETURN_FALSE;
-			}
+			SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, ODBCG(default_cursortype));
 		}
 	} else {
 		result->fetch_abs = 0;
@@ -1572,13 +1570,7 @@ PHP_FUNCTION(odbc_exec)
 			/* Try to set CURSOR_TYPE to dynamic. Driver will replace this with other
 			   type if not possible.
 			 */
-			int cursortype = ODBCG(default_cursortype);
-			if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, cursortype) == SQL_ERROR) {
-				odbc_sql_error(conn, result->stmt, " SQLSetStmtOption");
-				SQLFreeStmt(result->stmt, SQL_DROP);
-				efree(result);
-				RETURN_FALSE;
-			}
+			SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, ODBCG(default_cursortype));
 		}
 	} else {
 		result->fetch_abs = 0;
diff --git a/ext/odbc/php_odbc.h b/ext/odbc/php_odbc.h
index e215756..9045d75 100644
--- a/ext/odbc/php_odbc.h
+++ b/ext/odbc/php_odbc.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_odbc.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_odbc.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_ODBC_H
 #define PHP_ODBC_H
diff --git a/ext/odbc/php_odbc_includes.h b/ext/odbc/php_odbc_includes.h
index fce92f1..fd87efe 100644
--- a/ext/odbc/php_odbc_includes.h
+++ b/ext/odbc/php_odbc_includes.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_odbc_includes.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_odbc_includes.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_ODBC_INCLUDES_H
 #define PHP_ODBC_INCLUDES_H
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index d3e425e..8df0d9d 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: openssl.c 289443 2009-10-09 19:08:56Z pajoye $ */
+/* $Id: openssl.c 294508 2010-02-04 09:23:22Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -51,13 +51,19 @@
 /* Common */
 #include <time.h>
 
+#ifdef NETWARE
+#define timezone _timezone	/* timezone is called _timezone in LibC */
+#endif
+
 #define DEFAULT_KEY_LENGTH	512
 #define MIN_KEY_LENGTH		384
 
 #define OPENSSL_ALGO_SHA1 	1
 #define OPENSSL_ALGO_MD5	2
 #define OPENSSL_ALGO_MD4	3
+#ifdef HAVE_OPENSSL_MD2_H
 #define OPENSSL_ALGO_MD2	4
+#endif
 #define OPENSSL_ALGO_DSS1	5
 
 #define DEBUG_SMIME	0
@@ -913,9 +919,11 @@ static EVP_MD * php_openssl_get_evp_md_from_algo(long algo) { /* {{{ */
 		case OPENSSL_ALGO_MD4:
 			mdtype = (EVP_MD *) EVP_md4();
 			break;
+#ifdef HAVE_OPENSSL_MD2_H
 		case OPENSSL_ALGO_MD2:
 			mdtype = (EVP_MD *) EVP_md2();
 			break;
+#endif
 		case OPENSSL_ALGO_DSS1:
 			mdtype = (EVP_MD *) EVP_dss1();
 			break;
@@ -997,7 +1005,9 @@ PHP_MINIT_FUNCTION(openssl)
 	REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA1", OPENSSL_ALGO_SHA1, CONST_CS|CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD5", OPENSSL_ALGO_MD5, CONST_CS|CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD4", OPENSSL_ALGO_MD4, CONST_CS|CONST_PERSISTENT);
+#ifdef HAVE_OPENSSL_MD2_H
 	REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD2", OPENSSL_ALGO_MD2, CONST_CS|CONST_PERSISTENT);
+#endif
 	REGISTER_LONG_CONSTANT("OPENSSL_ALGO_DSS1", OPENSSL_ALGO_DSS1, CONST_CS|CONST_PERSISTENT);
 
 	/* flags for S/MIME */
@@ -1037,6 +1047,11 @@ PHP_MINIT_FUNCTION(openssl)
 	REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_EC", OPENSSL_KEYTYPE_EC, CONST_CS|CONST_PERSISTENT);
 #endif
 
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+	/* SNI support included in OpenSSL >= 0.9.8j */
+	REGISTER_LONG_CONSTANT("OPENSSL_TLSEXT_SERVER_NAME", 1, CONST_CS|CONST_PERSISTENT);
+#endif
+
 	/* Determine default SSL configuration file */
 	config_filename = getenv("OPENSSL_CONF");
 	if (config_filename == NULL) {
@@ -1738,18 +1753,18 @@ PHP_FUNCTION(openssl_pkcs12_export_to_file)
 	int filename_len;
 	char * pass;
 	int pass_len;
-	zval *zcert = NULL, *zpkey = NULL, *args = NULL;
+	zval **zcert = NULL, *zpkey = NULL, *args = NULL;
 	EVP_PKEY *priv_key = NULL;
 	long certresource, keyresource;
 	zval ** item;
 	STACK_OF(X509) *ca = NULL;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zszs|a", &zcert, &filename, &filename_len, &zpkey, &pass, &pass_len, &args) == FAILURE)
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zszs|a", &zcert, &filename, &filename_len, &zpkey, &pass, &pass_len, &args) == FAILURE)
 		return;
 
 	RETVAL_FALSE;
 	
-	cert = php_openssl_x509_from_zval(&zcert, 0, &certresource TSRMLS_CC);
+	cert = php_openssl_x509_from_zval(zcert, 0, &certresource TSRMLS_CC);
 	if (cert == NULL) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get cert from parameter 1");
 		return;
diff --git a/ext/openssl/php_openssl.h b/ext/openssl/php_openssl.h
index 1aa8adf..bddd8e7 100644
--- a/ext/openssl/php_openssl.h
+++ b/ext/openssl/php_openssl.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_openssl.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_openssl.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_OPENSSL_H
 #define PHP_OPENSSL_H
diff --git a/ext/openssl/tests/bug48182.phpt b/ext/openssl/tests/bug48182.phpt
index 0af04e1..7471c4c 100644
--- a/ext/openssl/tests/bug48182.phpt
+++ b/ext/openssl/tests/bug48182.phpt
@@ -28,12 +28,12 @@ function ssl_server($port) {
 	$r = array($link);
 	$w = array();
 	$e = array();
-	if (stream_select($r, $w, $e, 0, 1000) != 0)
+	if (stream_select($r, $w, $e, 1, 0) != 0)
 		$data .= fread($link, 8192);
 
 	$r = array();
 	$w = array($link);
-	if (stream_select($r, $w, $e, 0, 1000) != 0)
+	if (stream_select($r, $w, $e, 1, 0) != 0)
 		$wrote = fwrite($link, $data, strlen($data));
 
 	// close stuff
@@ -59,7 +59,7 @@ function ssl_async_client($port) {
 	$r = array($socket);
 	$w = array();
 	$e = array();
-	if (stream_select($r, $w, $e, 0, 10) != 0) 
+	if (stream_select($r, $w, $e, 1, 0) != 0) 
 	{
 		$data .= fread($socket, 1024);
 	}
diff --git a/ext/openssl/tests/sni_001.phpt b/ext/openssl/tests/sni_001.phpt
new file mode 100644
index 0000000..3d7798c
--- /dev/null
+++ b/ext/openssl/tests/sni_001.phpt
@@ -0,0 +1,178 @@
+--TEST--
+SNI 001
+--SKIPIF--
+<?php
+	if (!extension_loaded('openssl')) die("skip openssl extension not available");
+	if (!getenv('SNI_TESTS')) die("skip Set SNI_TESTS to enable this test (uses remote resources)");
+?>
+--FILE--
+<?php
+/* Server Name Indication (SNI) tests
+ * 
+ * This test relies on https://sni.velox.ch/ and thus is disabled by default.
+ *
+ * sni.velox.ch uses 3 certificates :
+ * - CN=alice.sni.velox.ch (sent in response to server_name = alice.sni.velox.ch or not set)
+ * - CN=bob.sni.velox.ch (sent in response to server_name = bob.sni.velox.ch)
+ * - CN=*.sni.velox.ch (sent in response to server_name = mallory.sni.velox.ch or *.sni.velox.ch or sni.velox.ch)
+ *
+ * The test sends requests to the server, sending different names, and checks which certificate
+ * the server returned.
+ */
+
+function context() {
+	return stream_context_create(array(
+		'ssl' => array(
+			'capture_peer_cert' => true,
+		),
+	));
+}
+
+function get_CN($context) {
+
+	$ary = stream_context_get_options($context);
+	assert($ary);
+
+	$cert = $ary['ssl']['peer_certificate'];
+	assert($cert);
+
+	$cert_ary = openssl_x509_parse($cert);
+	return $cert_ary['subject']['CN'];
+}
+
+function do_http_test($url, $context) {
+
+	$fh = fopen($url, 'r', false, $context);
+	assert($fh);
+
+	var_dump(get_CN($context));
+}
+
+function do_ssl_test($url, $context) {
+
+	$fh = stream_socket_client($url, $errno, $errstr, 
+			ini_get("default_socket_timeout"), STREAM_CLIENT_CONNECT, $context);
+	assert($fh);
+
+	var_dump(get_CN($context));
+}
+
+function do_enable_crypto_test($url, $context) {
+
+	$fh = stream_socket_client($url, $errno, $errstr,
+		ini_get("default_socket_timeout"), STREAM_CLIENT_CONNECT, $context);
+	assert($fh);
+
+	$r = stream_socket_enable_crypto($fh, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+	assert($r);
+
+	var_dump(get_CN($context));
+}
+
+/* Test https:// streams */
+
+echo "-- auto host name (1) --\n";
+do_http_test('https://alice.sni.velox.ch/', context());
+
+echo "-- auto host name (2) --\n";
+do_http_test('https://bob.sni.velox.ch/', context());
+
+echo "-- auto host name (3) --\n";
+do_http_test('https://bob.sni.velox.ch./', context());
+
+echo "-- user supplied server name --\n";
+
+$context = context();
+stream_context_set_option($context, 'ssl', 'SNI_server_name', 'bob.sni.velox.ch');
+stream_context_set_option($context, 'http', 'header', b'Host: bob.sni.velox.ch');
+do_http_test('https://alice.sni.velox.ch/', $context);
+
+echo "-- sni disabled --\n";
+
+$context = context();
+stream_context_set_option($context, 'ssl', 'SNI_enabled', false);
+do_http_test('https://bob.sni.velox.ch/', $context);
+
+/* Test ssl:// socket streams */
+
+echo "-- raw SSL stream (1) --\n";
+do_ssl_test('ssl://bob.sni.velox.ch:443', context());
+
+echo "-- raw SSL stream (2) --\n";
+do_ssl_test('ssl://mallory.sni.velox.ch:443', context());
+
+echo "-- raw SSL stream with user supplied sni --\n";
+
+$context = context();
+stream_context_set_option($context, 'ssl', 'SNI_server_name', 'bob.sni.velox.ch');
+
+do_ssl_test('ssl://mallory.sni.velox.ch:443', $context);
+
+echo "-- raw SSL stream with sni disabled --\n";
+
+$context = context();
+stream_context_set_option($context, 'ssl', 'SNI_enabled', false);
+
+do_ssl_test('ssl://mallory.sni.velox.ch:443', $context);
+
+/* Test tcp:// socket streams with SSL enabled */
+
+echo "-- stream_socket_enable_crypto (1) --\n";
+
+do_enable_crypto_test('tcp://bob.sni.velox.ch:443', context());
+
+echo "-- stream_socket_enable_crypto (2) --\n";
+
+do_enable_crypto_test('tcp://mallory.sni.velox.ch:443', context());
+
+echo "-- stream_socket_enable_crypto with user supplied sni --\n";
+
+$context = context();
+stream_context_set_option($context, 'ssl', 'SNI_server_name', 'bob.sni.velox.ch');
+
+do_enable_crypto_test('tcp://mallory.sni.velox.ch:443', $context);
+
+echo "-- stream_socket_enable_crypto with sni disabled --\n";
+
+$context = context();
+stream_context_set_option($context, 'ssl', 'SNI_enabled', false);
+
+do_enable_crypto_test('tcp://mallory.sni.velox.ch:443', $context);
+
+echo "-- stream_socket_enable_crypto with long name --\n";
+
+$context = context();
+stream_context_set_option($context, 'ssl', 'SNI_server_name', str_repeat('a.', 500) . '.sni.velox.ch');
+
+do_enable_crypto_test('tcp://mallory.sni.velox.ch:443', $context);
+
+?>
+--EXPECTF--
+-- auto host name (1) --
+%unicode|string%(18) "alice.sni.velox.ch"
+-- auto host name (2) --
+%unicode|string%(16) "bob.sni.velox.ch"
+-- auto host name (3) --
+%unicode|string%(16) "bob.sni.velox.ch"
+-- user supplied server name --
+%unicode|string%(16) "bob.sni.velox.ch"
+-- sni disabled --
+%unicode|string%(18) "alice.sni.velox.ch"
+-- raw SSL stream (1) --
+%unicode|string%(16) "bob.sni.velox.ch"
+-- raw SSL stream (2) --
+%unicode|string%(14) "*.sni.velox.ch"
+-- raw SSL stream with user supplied sni --
+%unicode|string%(16) "bob.sni.velox.ch"
+-- raw SSL stream with sni disabled --
+%unicode|string%(18) "alice.sni.velox.ch"
+-- stream_socket_enable_crypto (1) --
+%unicode|string%(16) "bob.sni.velox.ch"
+-- stream_socket_enable_crypto (2) --
+%unicode|string%(14) "*.sni.velox.ch"
+-- stream_socket_enable_crypto with user supplied sni --
+%unicode|string%(16) "bob.sni.velox.ch"
+-- stream_socket_enable_crypto with sni disabled --
+%unicode|string%(18) "alice.sni.velox.ch"
+-- stream_socket_enable_crypto with long name --
+%unicode|string%(18) "alice.sni.velox.ch"
diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c
index 9462e0f..212c003 100644
--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,10 +16,11 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: xp_ssl.c 289416 2009-10-09 14:20:17Z pajoye $ */
+/* $Id: xp_ssl.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "ext/standard/file.h"
+#include "ext/standard/url.h"
 #include "streams/php_streams_int.h"
 #include "ext/standard/php_smart_str.h"
 #include "php_network.h"
@@ -54,6 +55,7 @@ typedef struct _php_openssl_netstream_data_t {
 	int is_client;
 	int ssl_active;
 	php_stream_xport_crypt_method_t method;
+	char *sni;
 	unsigned state_set:1;
 	unsigned _spare:31;
 } php_openssl_netstream_data_t;
@@ -283,6 +285,9 @@ static int php_openssl_sockop_close(php_stream *stream, int close_handle TSRMLS_
 		}
 	}
 
+	if (sslsock->sni) {
+		pefree(sslsock->sni, php_stream_is_persistent(stream));
+	}
 	pefree(sslsock, php_stream_is_persistent(stream));
 	
 	return 0;
@@ -393,6 +398,12 @@ static inline int php_openssl_enable_crypto(php_stream *stream,
 		float timeout = sslsock->connect_timeout.tv_sec + sslsock->connect_timeout.tv_usec / 1000000;
 		int blocked = sslsock->s.is_blocked;
 
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+		if (sslsock->is_client && sslsock->sni) {
+			SSL_set_tlsext_host_name(sslsock->ssl_handle, sslsock->sni);
+		}
+#endif
+
 		if (!sslsock->state_set) {
 			if (sslsock->is_client) {
 				SSL_set_connect_state(sslsock->ssl_handle);
@@ -759,6 +770,52 @@ php_stream_ops php_openssl_socket_ops = {
 	php_openssl_sockop_set_option,
 };
 
+static char * get_sni(php_stream_context *ctx, char *resourcename, long resourcenamelen, int is_persistent TSRMLS_DC) {
+
+	php_url *url;
+
+	if (ctx) {
+		zval **val = NULL;
+
+		if (php_stream_context_get_option(ctx, "ssl", "SNI_enabled", &val) == SUCCESS && !zend_is_true(*val)) {
+			return NULL;
+		}
+		if (php_stream_context_get_option(ctx, "ssl", "SNI_server_name", &val) == SUCCESS) {
+			convert_to_string_ex(val);
+			return pestrdup(Z_STRVAL_PP(val), is_persistent);
+		}
+	}
+
+	if (!resourcename) {
+		return NULL;
+	}
+
+	url = php_url_parse_ex(resourcename, resourcenamelen);
+	if (!url) {
+		return NULL;
+	}
+
+	if (url->host) {
+		const char * host = url->host;
+		char * sni = NULL;
+		size_t len = strlen(host);
+
+		/* skip trailing dots */
+		while (len && host[len-1] == '.') {
+			--len;
+		}
+
+		if (len) {
+			sni = pestrndup(host, len, is_persistent);
+		}
+
+		php_url_free(url);
+		return sni;
+	}
+
+	php_url_free(url);
+	return NULL;
+}
 
 php_stream *php_openssl_ssl_socket_factory(const char *proto, long protolen,
 		char *resourcename, long resourcenamelen,
@@ -795,6 +852,8 @@ php_stream *php_openssl_ssl_socket_factory(const char *proto, long protolen,
 		return NULL;
 	}
 
+	sslsock->sni = get_sni(context, resourcename, resourcenamelen, !!persistent_id TSRMLS_CC);
+	
 	if (strncmp(proto, "ssl", protolen) == 0) {
 		sslsock->enable_on_connect = 1;
 		sslsock->method = STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index eec6aaa..458e1ad 100755
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: pcntl.c 281177 2009-05-26 14:01:39Z lbarnaud $ */
+/* $Id: pcntl.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define PCNTL_DEBUG 0
 
@@ -727,16 +727,19 @@ PHP_FUNCTION(pcntl_exec)
 			if (return_val == HASH_KEY_IS_LONG) efree(key);
 		}
 		*(pair) = NULL;
-	}
-	
-	if (execve(path, argv, envp) == -1) {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occured: (errno %d) %s", errno, strerror(errno));
-	}
+
+		if (execve(path, argv, envp) == -1) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occured: (errno %d) %s", errno, strerror(errno));
+		}
 	
-	/* Cleanup */
-	if (envp != NULL) {
+		/* Cleanup */
 		for (pair = envp; *pair != NULL; pair++) efree(*pair);
 		efree(envp);
+	} else {
+
+		if (execv(path, argv) == -1) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occured: (errno %d) %s", errno, strerror(errno));
+		}
 	}
 
 	efree(argv);
diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h
index 6bd45b2..8b7a1f1 100644
--- a/ext/pcntl/php_pcntl.h
+++ b/ext/pcntl/php_pcntl.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcntl.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pcntl.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PCNTL_H
 #define PHP_PCNTL_H
diff --git a/ext/pcntl/php_signal.c b/ext/pcntl/php_signal.c
index 4396c05..c025296 100644
--- a/ext/pcntl/php_signal.c
+++ b/ext/pcntl/php_signal.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_signal.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_signal.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_signal.h"
 
diff --git a/ext/pcntl/php_signal.h b/ext/pcntl/php_signal.h
index 73a395c..e97cf08 100644
--- a/ext/pcntl/php_signal.h
+++ b/ext/pcntl/php_signal.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_signal.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_signal.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <signal.h>
 #ifndef PHP_SIGNAL_H
diff --git a/ext/pcre/pcrelib/ChangeLog b/ext/pcre/pcrelib/ChangeLog
index 93a5415..40600b8 100644
--- a/ext/pcre/pcrelib/ChangeLog
+++ b/ext/pcre/pcrelib/ChangeLog
@@ -1,6 +1,170 @@
 ChangeLog for PCRE
 ------------------
 
+Version 8.00 19-Oct-09
+----------------------
+
+1.  The table for translating pcre_compile() error codes into POSIX error codes
+    was out-of-date, and there was no check on the pcre_compile() error code
+    being within the table. This could lead to an OK return being given in
+    error.
+
+2.  Changed the call to open a subject file in pcregrep from fopen(pathname,
+    "r") to fopen(pathname, "rb"), which fixed a problem with some of the tests
+    in a Windows environment.
+
+3.  The pcregrep --count option prints the count for each file even when it is
+    zero, as does GNU grep. However, pcregrep was also printing all files when
+    --files-with-matches was added. Now, when both options are given, it prints
+    counts only for those files that have at least one match. (GNU grep just
+    prints the file name in this circumstance, but including the count seems
+    more useful - otherwise, why use --count?) Also ensured that the
+    combination -clh just lists non-zero counts, with no names.
+
+4.  The long form of the pcregrep -F option was incorrectly implemented as
+    --fixed_strings instead of --fixed-strings. This is an incompatible change,
+    but it seems right to fix it, and I didn't think it was worth preserving
+    the old behaviour.
+
+5.  The command line items --regex=pattern and --regexp=pattern were not
+    recognized by pcregrep, which required --regex pattern or --regexp pattern
+    (with a space rather than an '='). The man page documented the '=' forms,
+    which are compatible with GNU grep; these now work.
+
+6.  No libpcreposix.pc file was created for pkg-config; there was just
+    libpcre.pc and libpcrecpp.pc. The omission has been rectified.
+
+7.  Added #ifndef SUPPORT_UCP into the pcre_ucd.c module, to reduce its size
+    when UCP support is not needed, by modifying the Python script that
+    generates it from Unicode data files. This should not matter if the module
+    is correctly used as a library, but I received one complaint about 50K of
+    unwanted data. My guess is that the person linked everything into his
+    program rather than using a library. Anyway, it does no harm.
+
+8.  A pattern such as /\x{123}{2,2}+/8 was incorrectly compiled; the trigger
+    was a minimum greater than 1 for a wide character in a possessive
+    repetition. The same bug could also affect patterns like /(\x{ff}{0,2})*/8
+    which had an unlimited repeat of a nested, fixed maximum repeat of a wide
+    character. Chaos in the form of incorrect output or a compiling loop could
+    result.
+
+9.  The restrictions on what a pattern can contain when partial matching is
+    requested for pcre_exec() have been removed. All patterns can now be
+    partially matched by this function. In addition, if there are at least two
+    slots in the offset vector, the offset of the earliest inspected character
+    for the match and the offset of the end of the subject are set in them when
+    PCRE_ERROR_PARTIAL is returned.
+
+10. Partial matching has been split into two forms: PCRE_PARTIAL_SOFT, which is
+    synonymous with PCRE_PARTIAL, for backwards compatibility, and
+    PCRE_PARTIAL_HARD, which causes a partial match to supersede a full match,
+    and may be more useful for multi-segment matching.
+
+11. Partial matching with pcre_exec() is now more intuitive. A partial match
+    used to be given if ever the end of the subject was reached; now it is
+    given only if matching could not proceed because another character was
+    needed. This makes a difference in some odd cases such as Z(*FAIL) with the
+    string "Z", which now yields "no match" instead of "partial match". In the
+    case of pcre_dfa_exec(), "no match" is given if every matching path for the
+    final character ended with (*FAIL).
+
+12. Restarting a match using pcre_dfa_exec() after a partial match did not work
+    if the pattern had a "must contain" character that was already found in the
+    earlier partial match, unless partial matching was again requested. For
+    example, with the pattern /dog.(body)?/, the "must contain" character is
+    "g". If the first part-match was for the string "dog", restarting with
+    "sbody" failed. This bug has been fixed.
+
+13. The string returned by pcre_dfa_exec() after a partial match has been
+    changed so that it starts at the first inspected character rather than the
+    first character of the match. This makes a difference only if the pattern
+    starts with a lookbehind assertion or \b or \B (\K is not supported by
+    pcre_dfa_exec()). It's an incompatible change, but it makes the two
+    matching functions compatible, and I think it's the right thing to do.
+
+14. Added a pcredemo man page, created automatically from the pcredemo.c file,
+    so that the demonstration program is easily available in environments where
+    PCRE has not been installed from source.
+
+15. Arranged to add -DPCRE_STATIC to cflags in libpcre.pc, libpcreposix.cp,
+    libpcrecpp.pc and pcre-config when PCRE is not compiled as a shared
+    library.
+
+16. Added REG_UNGREEDY to the pcreposix interface, at the request of a user.
+    It maps to PCRE_UNGREEDY. It is not, of course, POSIX-compatible, but it
+    is not the first non-POSIX option to be added. Clearly some people find
+    these options useful.
+
+17. If a caller to the POSIX matching function regexec() passes a non-zero
+    value for nmatch with a NULL value for pmatch, the value of
+    nmatch is forced to zero.
+
+18. RunGrepTest did not have a test for the availability of the -u option of
+    the diff command, as RunTest does. It now checks in the same way as
+    RunTest, and also checks for the -b option.
+
+19. If an odd number of negated classes containing just a single character
+    interposed, within parentheses, between a forward reference to a named
+    subpattern and the definition of the subpattern, compilation crashed with
+    an internal error, complaining that it could not find the referenced
+    subpattern. An example of a crashing pattern is /(?&A)(([^m])(?<A>))/.
+    [The bug was that it was starting one character too far in when skipping
+    over the character class, thus treating the ] as data rather than
+    terminating the class. This meant it could skip too much.]
+
+20. Added PCRE_NOTEMPTY_ATSTART in order to be able to correctly implement the
+    /g option in pcretest when the pattern contains \K, which makes it possible
+    to have an empty string match not at the start, even when the pattern is
+    anchored. Updated pcretest and pcredemo to use this option.
+
+21. If the maximum number of capturing subpatterns in a recursion was greater
+    than the maximum at the outer level, the higher number was returned, but
+    with unset values at the outer level. The correct (outer level) value is
+    now given.
+
+22. If (*ACCEPT) appeared inside capturing parentheses, previous releases of
+    PCRE did not set those parentheses (unlike Perl). I have now found a way to
+    make it do so. The string so far is captured, making this feature
+    compatible with Perl.
+
+23. The tests have been re-organized, adding tests 11 and 12, to make it
+    possible to check the Perl 5.10 features against Perl 5.10.
+
+24. Perl 5.10 allows subroutine calls in lookbehinds, as long as the subroutine
+    pattern matches a fixed length string. PCRE did not allow this; now it
+    does. Neither allows recursion.
+
+25. I finally figured out how to implement a request to provide the minimum
+    length of subject string that was needed in order to match a given pattern.
+    (It was back references and recursion that I had previously got hung up
+    on.) This code has now been added to pcre_study(); it finds a lower bound
+    to the length of subject needed. It is not necessarily the greatest lower
+    bound, but using it to avoid searching strings that are too short does give
+    some useful speed-ups. The value is available to calling programs via
+    pcre_fullinfo().
+
+26. While implementing 25, I discovered to my embarrassment that pcretest had
+    not been passing the result of pcre_study() to pcre_dfa_exec(), so the
+    study optimizations had never been tested with that matching function.
+    Oops. What is worse, even when it was passed study data, there was a bug in
+    pcre_dfa_exec() that meant it never actually used it. Double oops. There
+    were also very few tests of studied patterns with pcre_dfa_exec().
+
+27. If (?| is used to create subpatterns with duplicate numbers, they are now
+    allowed to have the same name, even if PCRE_DUPNAMES is not set. However,
+    on the other side of the coin, they are no longer allowed to have different
+    names, because these cannot be distinguished in PCRE, and this has caused
+    confusion. (This is a difference from Perl.)
+
+28. When duplicate subpattern names are present (necessarily with different
+    numbers, as required by 27 above), and a test is made by name in a
+    conditional pattern, either for a subpattern having been matched, or for
+    recursion in such a pattern, all the associated numbered subpatterns are
+    tested, and the overall condition is true if the condition is true for any
+    one of them. This is the way Perl works, and is also more like the way
+    testing by number works.
+
+
 Version 7.9 11-Apr-09
 ---------------------
 
diff --git a/ext/pcre/pcrelib/HACKING b/ext/pcre/pcrelib/HACKING
index 1f30d4c..8c6a42d 100644
--- a/ext/pcre/pcrelib/HACKING
+++ b/ext/pcre/pcrelib/HACKING
@@ -67,22 +67,22 @@ many tests of the mode that might slow it down. So I re-factored the compiling
 functions to work this way. This got rid of about 600 lines of source. It
 should make future maintenance and development easier. As this was such a major 
 change, I never released 6.8, instead upping the number to 7.0 (other quite 
-major changes are also present in the 7.0 release).
+major changes were also present in the 7.0 release).
 
-A side effect of this work is that the previous limit of 200 on the nesting
+A side effect of this work was that the previous limit of 200 on the nesting
 depth of parentheses was removed. However, there is a downside: pcre_compile()
 runs more slowly than before (30% or more, depending on the pattern) because it
-is doing a full analysis of the pattern. My hope is that this is not a big
-issue.
+is doing a full analysis of the pattern. My hope was that this would not be a
+big issue, and in the event, nobody has commented on it.
 
 Traditional matching function
 -----------------------------
 
 The "traditional", and original, matching function is called pcre_exec(), and 
 it implements an NFA algorithm, similar to the original Henry Spencer algorithm 
-and the way that Perl works. Not surprising, since it is intended to be as 
-compatible with Perl as possible. This is the function most users of PCRE will 
-use most of the time.
+and the way that Perl works. This is not surprising, since it is intended to be
+as compatible with Perl as possible. This is the function most users of PCRE
+will use most of the time.
 
 Supplementary matching function
 -------------------------------
@@ -119,6 +119,7 @@ quantifiers) are always just two bytes long.
 
 A list of the opcodes follows:
 
+
 Opcodes with no following data
 ------------------------------
 
@@ -150,12 +151,12 @@ These items are all just one byte long
   OP_EXTUNI              match an extended Unicode character 
   OP_ANYNL               match any Unicode newline sequence 
   
-  OP_ACCEPT              )
-  OP_COMMIT              ) 
-  OP_FAIL                ) These are Perl 5.10's "backtracking     
-  OP_PRUNE               ) control verbs".                         
-  OP_SKIP                )
-  OP_THEN                )
+  OP_ACCEPT              ) These are Perl 5.10's "backtracking    
+  OP_COMMIT              ) control verbs". If OP_ACCEPT is inside
+  OP_FAIL                ) capturing parentheses, it may be preceded 
+  OP_PRUNE               ) by one or more OP_CLOSE, followed by a 2-byte 
+  OP_SKIP                ) number, indicating which parentheses must be
+  OP_THEN                ) closed.
   
 
 Repeating single characters
@@ -372,12 +373,15 @@ These are like other subpatterns, but they start with the opcode OP_COND, or
 OP_SCOND for one that might match an empty string in an unbounded repeat. If
 the condition is a back reference, this is stored at the start of the
 subpattern using the opcode OP_CREF followed by two bytes containing the
-reference number. If the condition is "in recursion" (coded as "(?(R)"), or "in
-recursion of group x" (coded as "(?(Rx)"), the group number is stored at the
-start of the subpattern using the opcode OP_RREF, and a value of zero for "the
-whole pattern". For a DEFINE condition, just the single byte OP_DEF is used (it
-has no associated data). Otherwise, a conditional subpattern always starts with
-one of the assertions.
+reference number. OP_NCREF is used instead if the reference was generated by 
+name (so that the runtime code knows to check for duplicate names).
+
+If the condition is "in recursion" (coded as "(?(R)"), or "in recursion of
+group x" (coded as "(?(Rx)"), the group number is stored at the start of the
+subpattern using the opcode OP_RREF or OP_NRREF (cf OP_NCREF), and a value of
+zero for "the whole pattern". For a DEFINE condition, just the single byte
+OP_DEF is used (it has no associated data). Otherwise, a conditional subpattern
+always starts with one of the assertions.
 
 
 Recursion
@@ -415,4 +419,4 @@ at compile time, and so does not cause anything to be put into the compiled
 data.
 
 Philip Hazel
-April 2008
+October 2009
diff --git a/ext/pcre/pcrelib/LICENCE b/ext/pcre/pcrelib/LICENCE
index ff443a9..73f8cde 100644
--- a/ext/pcre/pcrelib/LICENCE
+++ b/ext/pcre/pcrelib/LICENCE
@@ -4,7 +4,7 @@ PCRE LICENCE
 PCRE is a library of functions to support regular expressions whose syntax
 and semantics are as close as possible to those of the Perl 5 language.
 
-Release 7 of PCRE is distributed under the terms of the "BSD" licence, as
+Release 8 of PCRE is distributed under the terms of the "BSD" licence, as
 specified below. The documentation for PCRE, supplied in the "doc"
 directory, is distributed under the same terms as the software itself.
 
diff --git a/ext/pcre/pcrelib/NEWS b/ext/pcre/pcrelib/NEWS
index 2b26fcc..71cba37 100644
--- a/ext/pcre/pcrelib/NEWS
+++ b/ext/pcre/pcrelib/NEWS
@@ -1,6 +1,21 @@
 News about PCRE releases
 ------------------------
 
+Release 8.00 19-Oct-09
+----------------------
+
+Bugs have been fixed in the library and in pcregrep. There are also some
+enhancements. Restrictions on patterns used for partial matching have been
+removed, extra information is given for partial matches, the partial matching
+process has been improved, and an option to make a partial match override a
+full match is available. The "study" process has been enhanced by finding a
+lower bound matching length. Groups with duplicate numbers may now have
+duplicated names without the use of PCRE_DUPNAMES. However, they may not have
+different names. The documentation has been revised to reflect these changes.
+The version number has been expanded to 3 digits as it is clear that the rate
+of change is not slowing down.
+
+
 Release 7.9 11-Apr-09
 ---------------------
 
diff --git a/ext/pcre/pcrelib/NON-UNIX-USE b/ext/pcre/pcrelib/NON-UNIX-USE
index 803e73e..aca81bd 100644
--- a/ext/pcre/pcrelib/NON-UNIX-USE
+++ b/ext/pcre/pcrelib/NON-UNIX-USE
@@ -12,9 +12,10 @@ This document contains the following sections:
   Comments about Win32 builds
   Building PCRE on Windows with CMake
   Use of relative paths with CMake on Windows
-  Testing with runtest.bat
+  Testing with RunTest.bat
   Building under Windows with BCC5.5
   Building PCRE on OpenVMS
+  Building PCRE on Stratus OpenVOS
 
 
 GENERAL
@@ -36,10 +37,10 @@ wrapper functions are a separate issue (see below).
 
 The PCRE distribution includes a "configure" file for use by the Configure/Make
 build system, as found in many Unix-like environments. There is also support
-support for CMake, which some users prefer, in particular in Windows
-environments. There are some instructions for CMake under Windows in the
-section entitled "Building PCRE with CMake" below. CMake can also be used to
-build PCRE in Unix-like systems.
+support for CMake, which some users prefer, especially in Windows environments.
+There are some instructions for CMake under Windows in the section entitled
+"Building PCRE with CMake" below. CMake can also be used to build PCRE in
+Unix-like systems.
 
 
 GENERIC INSTRUCTIONS FOR THE PCRE C LIBRARY
@@ -278,40 +279,42 @@ things in this area in future.
 
 BUILDING PCRE ON WINDOWS WITH CMAKE
 
-CMake is an alternative build facility that can be used instead of the
-traditional Unix "configure". CMake version 2.4.7 supports Borland makefiles,
-MinGW makefiles, MSYS makefiles, NMake makefiles, UNIX makefiles, Visual Studio
-6, Visual Studio 7, Visual Studio 8, and Watcom W8. The following instructions
+CMake is an alternative configuration facility that can be used instead of the
+traditional Unix "configure". CMake creates project files (make files, solution
+files, etc.) tailored to numerous development environments, including Visual
+Studio, Borland, Msys, MinGW, NMake, and Unix. The following instructions
 were contributed by a PCRE user.
 
-1.  Download CMake 2.4.7 or above from http://www.cmake.org/, install and ensure
-    that cmake\bin is on your path.
+1.  Install the latest CMake version available from http://www.cmake.org/, and
+    ensure that cmake\bin is on your path.
 
 2.  Unzip (retaining folder structure) the PCRE source tree into a source
     directory such as C:\pcre.
 
-3.  Create a new, empty build directory: C:\pcre\build\
+3.  Create a new, empty build directory, for example C:\pcre\build\
 
-4.  Run CMakeSetup from the Shell envirornment of your build tool, e.g., Msys
-    for Msys/MinGW or Visual Studio Command Prompt for VC/VC++
+4.  Run cmake-gui from the Shell envirornment of your build tool, for example,
+    Msys for Msys/MinGW or Visual Studio Command Prompt for VC/VC++.
 
 5.  Enter C:\pcre\pcre-xx and C:\pcre\build for the source and build
-    directories, respectively
+    directories, respectively.
 
 6.  Hit the "Configure" button.
 
-7.  Select the particular IDE / build tool that you are using (Visual Studio,
-    MSYS makefiles, MinGW makefiles, etc.)
+7.  Select the particular IDE / build tool that you are using (Visual
+    Studio, MSYS makefiles, MinGW makefiles, etc.)
 
-8.  The GUI will then list several configuration options. This is where you can
-    enable UTF-8 support, etc.
+8.  The GUI will then list several configuration options. This is where
+    you can enable UTF-8 support or other PCRE optional features.
 
-9.  Hit "Configure" again. The adjacent "OK" button should now be active.
+9.  Hit "Configure" again. The adjacent "Generate" button should now be
+    active.
 
-10. Hit "OK".
+10. Hit "Generate".
 
 11. The build directory should now contain a usable build system, be it a
-    solution file for Visual Studio, makefiles for MinGW, etc.
+    solution file for Visual Studio, makefiles for MinGW, etc. Exit from
+    cmake-gui and use the generated build system with your compiler or IDE.
 
 
 USE OF RELATIVE PATHS WITH CMAKE ON WINDOWS
@@ -444,5 +447,52 @@ $!   Locale could not be set to fr
 $!
 =========================
 
-Last Updated: 17 March 2009
+
+BUILDING PCRE ON STRATUS OPENVOS
+
+These notes on the port of PCRE to VOS (lightly edited) were supplied by
+Ashutosh Warikoo, whose email address has the local part awarikoo and the
+domain nse.co.in. The port was for version 7.9 in August 2009.
+
+1.   Building PCRE
+
+I built pcre on OpenVOS Release 17.0.1at using GNU Tools 3.4a without any
+problems. I used the following packages to build PCRE:
+
+  ftp://ftp.stratus.com/pub/vos/posix/ga/posix.save.evf.gz
+
+Please read and follow the instructions that come with these packages. To start
+the build of pcre, from the root of the package type:
+
+  ./build.sh
+
+2. Installing PCRE
+
+Once you have successfully built PCRE, login to the SysAdmin group, switch to
+the root user, and type
+
+  [ !create_dir (master_disk)>usr   --if needed ]
+  [ !create_dir (master_disk)>usr>local   --if needed ]
+    !gmake install
+
+This installs PCRE and its man pages into /usr/local. You can add
+(master_disk)>usr>local>bin to your command search paths, or if you are in
+BASH, add /usr/local/bin to the PATH environment variable.
+
+4. Restrictions
+
+This port requires readline library optionally. However during the build I
+faced some yet unexplored errors while linking with readline. As it was an
+optional component I chose to disable it.
+
+5. Known Problems
+
+I ran a the test suite, but you will have to be your own judge of whether this
+command, and this port, suits your purposes. If you find any problems that
+appear to be related to the port itself, please let me know. Please see the
+build.log file in the root of the package also.
+
+
+=========================
+Last Updated: 05 October 2009
 ****
diff --git a/ext/pcre/pcrelib/README b/ext/pcre/pcrelib/README
index 6b7c83f..c6156e2 100644
--- a/ext/pcre/pcrelib/README
+++ b/ext/pcre/pcrelib/README
@@ -24,6 +24,7 @@ The contents of this README file are:
   Shared libraries on Unix-like systems
   Cross-compiling on Unix-like systems
   Using HP's ANSI C++ compiler (aCC)
+  Using PCRE from MySQL
   Making new tarballs
   Testing PCRE
   Character tables
@@ -111,8 +112,8 @@ Building PCRE on non-Unix systems
 For a non-Unix system, please read the comments in the file NON-UNIX-USE,
 though if your system supports the use of "configure" and "make" you may be
 able to build PCRE in the same way as for Unix-like systems. PCRE can also be
-configured in many platform environments using the GUI facility of CMake's
-CMakeSetup. It creates Makefiles, solution files, etc.
+configured in many platform environments using the GUI facility provided by
+CMake's cmake-gui command. This creates Makefiles, solution files, etc.
 
 PCRE has been compiled on many different operating systems. It should be
 straightforward to build PCRE on any system that has a Standard C compiler and
@@ -478,6 +479,26 @@ running the "configure" script:
   CXXLDFLAGS="-lstd_v2 -lCsup_v2"
 
 
+Using Sun's compilers for Solaris
+---------------------------------
+
+A user reports that the following configurations work on Solaris 9 sparcv9 and
+Solaris 9 x86 (32-bit):
+
+  Solaris 9 sparcv9: ./configure --disable-cpp CC=/bin/cc CFLAGS="-m64 -g"
+  Solaris 9 x86:     ./configure --disable-cpp CC=/bin/cc CFLAGS="-g"
+
+
+Using PCRE from MySQL
+---------------------
+
+On systems where both PCRE and MySQL are installed, it is possible to make use
+of PCRE from within MySQL, as an alternative to the built-in pattern matching.
+There is a web page that tells you how to do this:
+
+  http://www.mysqludf.org/lib_mysqludf_preg/index.php
+
+
 Making new tarballs
 -------------------
 
@@ -553,22 +574,32 @@ document entitled NON-UNIX-USE.]
 
 The fourth test checks the UTF-8 support. It is not run automatically unless
 PCRE is built with UTF-8 support. To do this you must set --enable-utf8 when
-running "configure". This file can be also fed directly to the perltest script,
-provided you are running Perl 5.8 or higher. (For Perl 5.6, a small patch,
-commented in the script, can be be used.)
+running "configure". This file can be also fed directly to the perltest.pl
+script, provided you are running Perl 5.8 or higher.
 
 The fifth test checks error handling with UTF-8 encoding, and internal UTF-8
 features of PCRE that are not relevant to Perl.
 
-The sixth test checks the support for Unicode character properties. It it not
-run automatically unless PCRE is built with Unicode property support. To to
-this you must set --enable-unicode-properties when running "configure".
+The sixth test (which is Perl-5.10 compatible) checks the support for Unicode
+character properties. It it not run automatically unless PCRE is built with
+Unicode property support. To to this you must set --enable-unicode-properties
+when running "configure".
 
 The seventh, eighth, and ninth tests check the pcre_dfa_exec() alternative
 matching function, in non-UTF-8 mode, UTF-8 mode, and UTF-8 mode with Unicode
 property support, respectively. The eighth and ninth tests are not run
 automatically unless PCRE is build with the relevant support.
 
+The tenth test checks some internal offsets and code size features; it is run
+only when the default "link size" of 2 is set (in other cases the sizes
+change).
+
+The eleventh test checks out features that are new in Perl 5.10, and the
+twelfth test checks a number internals and non-Perl features concerned with
+Unicode property support. It it not run automatically unless PCRE is built with
+Unicode property support. To to this you must set --enable-unicode-properties
+when running "configure".
+
 
 Character tables
 ----------------
@@ -712,7 +743,7 @@ The distribution should contain the following files:
                           )   "configure" and config.h
   depcomp                 ) script to find program dependencies, generated by
                           )   automake
-  doc/*.3                 man page sources for the PCRE functions
+  doc/*.3                 man page sources for PCRE
   doc/*.1                 man page sources for pcregrep and pcretest
   doc/index.html.src      the base HTML page
   doc/html/*              HTML documentation
@@ -721,6 +752,7 @@ The distribution should contain the following files:
   doc/perltest.txt        plain text documentation of Perl test program
   install-sh              a shell script for installing files
   libpcre.pc.in           template for libpcre.pc for pkg-config
+  libpcreposix.pc.in      template for libpcreposix.pc for pkg-config
   libpcrecpp.pc.in        template for libpcrecpp.pc for pkg-config
   ltmain.sh               file used to build a libtool script
   missing                 ) common stub for a few missing GNU programs while
@@ -764,4 +796,4 @@ The distribution should contain the following files:
 Philip Hazel
 Email local part: ph10
 Email domain: cam.ac.uk
-Last updated: 21 March 2009
+Last updated: 19 October 2009
diff --git a/ext/pcre/pcrelib/config.h b/ext/pcre/pcrelib/config.h
index 8133d97..949a0a2 100644
--- a/ext/pcre/pcrelib/config.h
+++ b/ext/pcre/pcrelib/config.h
@@ -196,6 +196,12 @@ them both to 0; an emulation function will be used. */
 #define LINK_SIZE 2
 #endif
 
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#ifndef LT_OBJDIR
+#define LT_OBJDIR ".libs/"
+#endif
+
 /* The value of MATCH_LIMIT determines the default number of times the
    internal match() function can be called during a single execution of
    pcre_exec(). There is a runtime interface for setting a different limit.
@@ -262,13 +268,13 @@ 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 7.9"
+#define PACKAGE_STRING "PCRE 8.00"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "pcre"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "7.9"
+#define PACKAGE_VERSION "8.00"
 
 
 /* If you are compiling for a system other than a Unix-like system or
@@ -324,7 +330,7 @@ them both to 0; an emulation function will be used. */
 
 /* Version number of package */
 #ifndef VERSION
-#define VERSION "7.9"
+#define VERSION "8.00"
 #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 9a2ce31..2ccc7bb 100644
--- a/ext/pcre/pcrelib/doc/pcre.txt
+++ b/ext/pcre/pcrelib/doc/pcre.txt
@@ -2,8 +2,9 @@
 This file contains a concatenation of the PCRE man pages, converted to plain
 text format for ease of searching with a text editor, or for use on systems
 that do not have a man page processor. The small individual files that give
-synopses of each function in the library have not been included. There are
-separate text files for the pcregrep and pcretest commands.
+synopses of each function in the library have not been included. Neither has
+the pcredemo program. There are separate text files for the pcregrep and
+pcretest commands.
 -----------------------------------------------------------------------------
 
 
@@ -18,23 +19,23 @@ INTRODUCTION
 
        The  PCRE  library is a set of functions that implement regular expres-
        sion pattern matching using the same syntax and semantics as Perl, with
-       just  a  few  differences. Certain features that appeared in Python and
-       PCRE before they appeared in Perl are also available using  the  Python
-       syntax.  There is also some support for certain .NET and Oniguruma syn-
-       tax items, and there is an option for  requesting  some  minor  changes
-       that give better JavaScript compatibility.
-
-       The  current  implementation of PCRE (release 7.x) corresponds approxi-
-       mately 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 explicitly enabled; it is not the default. The Unicode tables
-       correspond to Unicode release 5.1.
+       just  a few differences. Some features that appeared in Python and PCRE
+       before they appeared in Perl are also available using the  Python  syn-
+       tax,  there  is  some  support for one or two .NET and Oniguruma syntax
+       items, and there is an option for requesting some  minor  changes  that
+       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
+       explicitly enabled; it is not the default. The  Unicode  tables  corre-
+       spond to Unicode release 5.1.
 
        In  addition to the Perl-compatible matching function, PCRE contains an
-       alternative matching function that matches the same  compiled  patterns
-       in  a different way. In certain circumstances, the alternative function
-       has some advantages. For a discussion of the two  matching  algorithms,
-       see the pcrematching page.
+       alternative function that matches the same compiled patterns in a  dif-
+       ferent way. In certain circumstances, the alternative function has some
+       advantages.  For a discussion of the two matching algorithms,  see  the
+       pcrematching page.
 
        PCRE  is  written  in C and released as a C library. A number of people
        have written wrappers and interfaces of various kinds.  In  particular,
@@ -54,8 +55,8 @@ INTRODUCTION
        library is built. The pcre_config() function makes it  possible  for  a
        client  to  discover  which  features are available. The features them-
        selves are described in the pcrebuild page. Documentation about  build-
-       ing  PCRE for various operating systems can be found in the README file
-       in the source distribution.
+       ing  PCRE  for various operating systems can be found in the README and
+       NON-UNIX-USE files in the source distribution.
 
        The library contains a number of undocumented  internal  functions  and
        data  tables  that  are  used by more than one of the exported external
@@ -71,8 +72,9 @@ USER DOCUMENTATION
        The user documentation for PCRE comprises a number  of  different  sec-
        tions.  In the "man" format, each of these is a separate "man page". In
        the HTML format, each is a separate page, linked from the  index  page.
-       In  the  plain text format, all the sections are concatenated, for ease
-       of searching. The sections are as follows:
+       In  the  plain  text format, all the sections, except the pcredemo sec-
+       tion, are concatenated, for ease of searching. The sections are as fol-
+       lows:
 
          pcre              this document
          pcre-config       show PCRE installation configuration information
@@ -81,34 +83,35 @@ USER DOCUMENTATION
          pcrecallout       details of the callout feature
          pcrecompat        discussion of Perl compatibility
          pcrecpp           details of the C++ wrapper
+         pcredemo          a demonstration C program that uses PCRE
          pcregrep          description of the pcregrep command
          pcrematching      discussion of the two matching algorithms
          pcrepartial       details of the partial matching facility
          pcrepattern       syntax and semantics of supported
                              regular expressions
-         pcresyntax        quick syntax reference
          pcreperform       discussion of performance issues
          pcreposix         the POSIX-compatible C API
          pcreprecompile    details of saving and re-using precompiled patterns
-         pcresample        discussion of the sample program
+         pcresample        discussion of the pcredemo program
          pcrestack         discussion of stack usage
+         pcresyntax        quick syntax reference
          pcretest          description of the pcretest testing command
 
-       In addition, in the "man" and HTML formats, there is a short  page  for
+       In  addition,  in the "man" and HTML formats, there is a short page for
        each C library function, listing its arguments and results.
 
 
 LIMITATIONS
 
-       There  are some size limitations in PCRE but it is hoped that they will
+       There are some size limitations in PCRE but it is hoped that they  will
        never in practice be relevant.
 
-       The maximum length of a compiled pattern is 65539 (sic) bytes  if  PCRE
+       The  maximum  length of a compiled pattern is 65539 (sic) bytes if PCRE
        is compiled with the default internal linkage size of 2. If you want to
-       process regular expressions that are truly enormous,  you  can  compile
-       PCRE  with  an  internal linkage size of 3 or 4 (see the README file in
-       the source distribution and the pcrebuild documentation  for  details).
-       In  these  cases the limit is substantially larger.  However, the speed
+       process  regular  expressions  that are truly enormous, you can compile
+       PCRE with an internal linkage size of 3 or 4 (see the  README  file  in
+       the  source  distribution and the pcrebuild documentation for details).
+       In these cases the limit is substantially larger.  However,  the  speed
        of execution is slower.
 
        All values in repeating quantifiers must be less than 65536.
@@ -119,131 +122,131 @@ LIMITATIONS
        The maximum length of name for a named subpattern is 32 characters, and
        the maximum number of named subpatterns is 10000.
 
-       The maximum length of a subject string is the largest  positive  number
-       that  an integer variable can hold. However, when using the traditional
+       The  maximum  length of a subject string is the largest positive number
+       that an integer variable can hold. However, when using the  traditional
        matching function, PCRE uses recursion to handle subpatterns and indef-
-       inite  repetition.  This means that the available stack space may limit
+       inite repetition.  This means that the available stack space may  limit
        the size of a subject string that can be processed by certain patterns.
        For a discussion of stack issues, see the pcrestack documentation.
 
 
 UTF-8 AND UNICODE PROPERTY SUPPORT
 
-       From  release  3.3,  PCRE  has  had  some support for character strings
-       encoded in the UTF-8 format. For release 4.0 this was greatly  extended
-       to  cover  most common requirements, and in release 5.0 additional sup-
+       From release 3.3, PCRE has  had  some  support  for  character  strings
+       encoded  in the UTF-8 format. For release 4.0 this was greatly extended
+       to cover most common requirements, and in release 5.0  additional  sup-
        port for Unicode general category properties was added.
 
-       In order process UTF-8 strings, you must build PCRE  to  include  UTF-8
-       support  in  the  code,  and, in addition, you must call pcre_compile()
-       with the PCRE_UTF8 option flag, or the  pattern  must  start  with  the
-       sequence  (*UTF8).  When  either of these is the case, both the pattern
-       and any subject strings that are matched  against  it  are  treated  as
-       UTF-8 strings instead of just strings of bytes.
+       In  order  process  UTF-8 strings, you must build PCRE to include UTF-8
+       support in the code, and, in addition,  you  must  call  pcre_compile()
+       with  the  PCRE_UTF8  option  flag,  or the pattern must start with the
+       sequence (*UTF8). When either of these is the case,  both  the  pattern
+       and  any  subject  strings  that  are matched against it are treated as
+       UTF-8 strings instead of strings of 1-byte characters.
 
-       If  you compile PCRE with UTF-8 support, but do not use it at run time,
-       the library will be a bit bigger, but the additional run time  overhead
+       If you compile PCRE with UTF-8 support, but do not use it at run  time,
+       the  library will be a bit bigger, but the additional run time overhead
        is limited to testing the PCRE_UTF8 flag occasionally, so should not be
        very big.
 
        If PCRE is built with Unicode character property support (which implies
-       UTF-8  support),  the  escape sequences \p{..}, \P{..}, and \X are sup-
+       UTF-8 support), the escape sequences \p{..}, \P{..}, and  \X  are  sup-
        ported.  The available properties that can be tested are limited to the
-       general  category  properties such as Lu for an upper case letter or Nd
-       for a decimal number, the Unicode script names such as Arabic  or  Han,
-       and  the  derived  properties  Any  and L&. A full list is given in the
+       general category properties such as Lu for an upper case letter  or  Nd
+       for  a  decimal number, the Unicode script names such as Arabic or Han,
+       and the derived properties Any and L&. A full  list  is  given  in  the
        pcrepattern documentation. Only the short names for properties are sup-
-       ported.  For example, \p{L} matches a letter. Its Perl synonym, \p{Let-
-       ter}, is not supported.  Furthermore,  in  Perl,  many  properties  may
-       optionally  be  prefixed by "Is", for compatibility with Perl 5.6. PCRE
+       ported. For example, \p{L} matches a letter. Its Perl synonym,  \p{Let-
+       ter},  is  not  supported.   Furthermore,  in Perl, many properties may
+       optionally be prefixed by "Is", for compatibility with Perl  5.6.  PCRE
        does not support this.
 
    Validity of UTF-8 strings
 
-       When you set the PCRE_UTF8 flag, the strings  passed  as  patterns  and
+       When  you  set  the  PCRE_UTF8 flag, the strings passed as patterns and
        subjects are (by default) checked for validity on entry to the relevant
-       functions. From release 7.3 of PCRE, the check is according  the  rules
-       of  RFC  3629, which are themselves derived from the Unicode specifica-
-       tion. Earlier releases of PCRE followed the rules of  RFC  2279,  which
-       allows  the  full range of 31-bit values (0 to 0x7FFFFFFF). The current
+       functions.  From  release 7.3 of PCRE, the check is according the rules
+       of RFC 3629, which are themselves derived from the  Unicode  specifica-
+       tion.  Earlier  releases  of PCRE followed the rules of RFC 2279, which
+       allows the full range of 31-bit values (0 to 0x7FFFFFFF).  The  current
        check allows only values in the range U+0 to U+10FFFF, excluding U+D800
        to U+DFFF.
 
-       The  excluded  code  points are the "Low Surrogate Area" of Unicode, of
-       which the Unicode Standard says this: "The Low Surrogate Area does  not
-       contain  any  character  assignments,  consequently  no  character code
+       The excluded code points are the "Low Surrogate Area"  of  Unicode,  of
+       which  the Unicode Standard says this: "The Low Surrogate Area does not
+       contain any  character  assignments,  consequently  no  character  code
        charts or namelists are provided for this area. Surrogates are reserved
-       for  use  with  UTF-16 and then must be used in pairs." The code points
-       that are encoded by UTF-16 pairs  are  available  as  independent  code
-       points  in  the  UTF-8  encoding.  (In other words, the whole surrogate
+       for use with UTF-16 and then must be used in pairs."  The  code  points
+       that  are  encoded  by  UTF-16  pairs are available as independent code
+       points in the UTF-8 encoding. (In  other  words,  the  whole  surrogate
        thing is a fudge for UTF-16 which unfortunately messes up UTF-8.)
 
-       If an  invalid  UTF-8  string  is  passed  to  PCRE,  an  error  return
+       If  an  invalid  UTF-8  string  is  passed  to  PCRE,  an  error return
        (PCRE_ERROR_BADUTF8) is given. In some situations, you may already know
        that your strings are valid, and therefore want to skip these checks in
        order to improve performance. If you set the PCRE_NO_UTF8_CHECK flag at
-       compile time or at run time, PCRE assumes that the pattern  or  subject
-       it  is  given  (respectively)  contains only valid UTF-8 codes. In this
+       compile  time  or at run time, PCRE assumes that the pattern or subject
+       it is given (respectively) contains only valid  UTF-8  codes.  In  this
        case, it does not diagnose an invalid UTF-8 string.
 
-       If you pass an invalid UTF-8 string  when  PCRE_NO_UTF8_CHECK  is  set,
-       what  happens  depends on why the string is invalid. If the string con-
+       If  you  pass  an  invalid UTF-8 string when PCRE_NO_UTF8_CHECK is set,
+       what happens depends on why the string is invalid. If the  string  con-
        forms to the "old" definition of UTF-8 (RFC 2279), it is processed as a
-       string  of  characters  in  the  range 0 to 0x7FFFFFFF. In other words,
+       string of characters in the range 0  to  0x7FFFFFFF.  In  other  words,
        apart from the initial validity test, PCRE (when in UTF-8 mode) handles
-       strings  according  to  the more liberal rules of RFC 2279. However, if
-       the string does not even conform to RFC 2279, the result is  undefined.
+       strings according to the more liberal rules of RFC  2279.  However,  if
+       the  string does not even conform to RFC 2279, the result is undefined.
        Your program may crash.
 
-       If  you  want  to  process  strings  of  values  in the full range 0 to
-       0x7FFFFFFF, encoded in a UTF-8-like manner as per the old RFC, you  can
+       If you want to process strings  of  values  in  the  full  range  0  to
+       0x7FFFFFFF,  encoded in a UTF-8-like manner as per the old RFC, you can
        set PCRE_NO_UTF8_CHECK to bypass the more restrictive test. However, in
        this situation, you will have to apply your own validity check.
 
    General comments about UTF-8 mode
 
-       1. An unbraced hexadecimal escape sequence (such  as  \xb3)  matches  a
+       1.  An  unbraced  hexadecimal  escape sequence (such as \xb3) matches a
        two-byte UTF-8 character if the value is greater than 127.
 
-       2.  Octal  numbers  up to \777 are recognized, and match two-byte UTF-8
+       2. Octal numbers up to \777 are recognized, and  match  two-byte  UTF-8
        characters for values greater than \177.
 
-       3. Repeat quantifiers apply to complete UTF-8 characters, not to  indi-
+       3.  Repeat quantifiers apply to complete UTF-8 characters, not to indi-
        vidual bytes, for example: \x{100}{3}.
 
-       4.  The dot metacharacter matches one UTF-8 character instead of a sin-
+       4. The dot metacharacter matches one UTF-8 character instead of a  sin-
        gle byte.
 
-       5. The escape sequence \C can be used to match a single byte  in  UTF-8
-       mode,  but  its  use can lead to some strange effects. This facility is
+       5.  The  escape sequence \C can be used to match a single byte in UTF-8
+       mode, but its use can lead to some strange effects.  This  facility  is
        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
+       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
+       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.
 
-       7. Similarly, characters that match the POSIX named  character  classes
+       7.  Similarly,  characters that match the POSIX named character classes
        are all low-valued characters.
 
-       8.  However,  the Perl 5.10 horizontal and vertical whitespace matching
+       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.
 
-       9.  Case-insensitive  matching  applies only to characters whose values
-       are less than 128, unless PCRE is built with Unicode property  support.
-       Even  when  Unicode  property support is available, PCRE still uses its
-       own character tables when checking the case of  low-valued  characters,
-       so  as not to degrade performance.  The Unicode property information is
+       9. Case-insensitive matching applies only to  characters  whose  values
+       are  less than 128, unless PCRE is built with Unicode property support.
+       Even when Unicode property support is available, PCRE  still  uses  its
+       own  character  tables when checking the case of low-valued characters,
+       so as not to degrade performance.  The Unicode property information  is
        used only for characters with higher values. Even when Unicode property
        support is available, PCRE supports case-insensitive matching only when
-       there is a one-to-one mapping between a letter's  cases.  There  are  a
-       small  number  of  many-to-one  mappings in Unicode; these are not sup-
+       there  is  a  one-to-one  mapping between a letter's cases. There are a
+       small number of many-to-one mappings in Unicode;  these  are  not  sup-
        ported by PCRE.
 
 
@@ -253,14 +256,14 @@ AUTHOR
        University Computing Service
        Cambridge CB2 3QH, England.
 
-       Putting an actual email address here seems to have been a spam  magnet,
-       so  I've  taken  it away. If you want to email me, use my two initials,
+       Putting  an actual email address here seems to have been a spam magnet,
+       so I've taken it away. If you want to email me, use  my  two  initials,
        followed by the two digits 10, at the domain cam.ac.uk.
 
 
 REVISION
 
-       Last updated: 11 April 2009
+       Last updated: 28 September 2009
        Copyright (c) 1997-2009 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -279,20 +282,25 @@ PCRE BUILD-TIME OPTIONS
        script,  where the optional features are selected or deselected by pro-
        viding options to configure before running the make  command.  However,
        the  same  options  can be selected in both Unix-like and non-Unix-like
-       environments using the GUI facility of  CMakeSetup  if  you  are  using
-       CMake instead of configure to build PCRE.
+       environments using the GUI facility of cmake-gui if you are using CMake
+       instead of configure to build PCRE.
+
+       There  is  a  lot more information about building PCRE in non-Unix-like
+       environments in the file called NON_UNIX_USE, which is part of the PCRE
+       distribution.  You  should consult this file as well as the README file
+       if you are building in a non-Unix-like environment.
 
        The complete list of options for configure (which includes the standard
-       ones such as the  selection  of  the  installation  directory)  can  be
+       ones  such  as  the  selection  of  the  installation directory) can be
        obtained by running
 
          ./configure --help
 
-       The  following  sections  include  descriptions  of options whose names
+       The following sections include  descriptions  of  options  whose  names
        begin with --enable or --disable. These settings specify changes to the
-       defaults  for  the configure command. Because of the way that configure
-       works, --enable and --disable always come in pairs, so  the  complemen-
-       tary  option always exists as well, but as it specifies the default, it
+       defaults for the configure command. Because of the way  that  configure
+       works,  --enable  and --disable always come in pairs, so the complemen-
+       tary option always exists as well, but as it specifies the default,  it
        is not described.
 
 
@@ -313,46 +321,46 @@ UTF-8 SUPPORT
 
          --enable-utf8
 
-       to the configure command. Of itself, this  does  not  make  PCRE  treat
-       strings  as UTF-8. As well as compiling PCRE with this option, you also
-       have have to set the PCRE_UTF8 option when you call the  pcre_compile()
-       function.
+       to  the  configure  command.  Of  itself, this does not make PCRE treat
+       strings as UTF-8. As well as compiling PCRE with this option, you  also
+       have  have to set the PCRE_UTF8 option when you call the pcre_compile()
+       or pcre_compile2() functions.
 
-       If  you set --enable-utf8 when compiling in an EBCDIC environment, PCRE
+       If you set --enable-utf8 when compiling in an EBCDIC environment,  PCRE
        expects its input to be either ASCII or UTF-8 (depending on the runtime
-       option).  It  is not possible to support both EBCDIC and UTF-8 codes in
-       the same  version  of  the  library.  Consequently,  --enable-utf8  and
+       option). It is not possible to support both EBCDIC and UTF-8  codes  in
+       the  same  version  of  the  library.  Consequently,  --enable-utf8 and
        --enable-ebcdic are mutually exclusive.
 
 
 UNICODE CHARACTER PROPERTY SUPPORT
 
-       UTF-8  support allows PCRE to process character values greater than 255
-       in the strings that it handles. On its own, however, it does  not  pro-
+       UTF-8 support allows PCRE to process character values greater than  255
+       in  the  strings that it handles. On its own, however, it does not pro-
        vide any facilities for accessing the properties of such characters. If
-       you want to be able to use the pattern escapes \P, \p,  and  \X,  which
+       you  want  to  be able to use the pattern escapes \P, \p, and \X, which
        refer to Unicode character properties, you must add
 
          --enable-unicode-properties
 
-       to  the configure command. This implies UTF-8 support, even if you have
+       to the configure command. This implies UTF-8 support, even if you  have
        not explicitly requested it.
 
-       Including Unicode property support adds around 30K  of  tables  to  the
-       PCRE  library.  Only  the general category properties such as Lu and Nd
+       Including  Unicode  property  support  adds around 30K of tables to the
+       PCRE library. Only the general category properties such as  Lu  and  Nd
        are supported. Details are given in the pcrepattern documentation.
 
 
 CODE VALUE OF NEWLINE
 
-       By default, PCRE interprets the linefeed (LF) character  as  indicating
-       the  end  of  a line. This is the normal newline character on Unix-like
-       systems. You can compile PCRE to use carriage return (CR)  instead,  by
+       By  default,  PCRE interprets the linefeed (LF) character as indicating
+       the end of a line. This is the normal newline  character  on  Unix-like
+       systems.  You  can compile PCRE to use carriage return (CR) instead, by
        adding
 
          --enable-newline-is-cr
 
-       to  the  configure  command.  There  is  also  a --enable-newline-is-lf
+       to the  configure  command.  There  is  also  a  --enable-newline-is-lf
        option, which explicitly specifies linefeed as the newline character.
 
        Alternatively, you can specify that line endings are to be indicated by
@@ -364,35 +372,35 @@ CODE VALUE OF NEWLINE
 
          --enable-newline-is-anycrlf
 
-       which  causes  PCRE  to recognize any of the three sequences CR, LF, or
+       which causes PCRE to recognize any of the three sequences  CR,  LF,  or
        CRLF as indicating a line ending. Finally, a fifth option, specified by
 
          --enable-newline-is-any
 
        causes PCRE to recognize any Unicode newline sequence.
 
-       Whatever line ending convention is selected when PCRE is built  can  be
-       overridden  when  the library functions are called. At build time it is
+       Whatever  line  ending convention is selected when PCRE is built can be
+       overridden when the library functions are called. At build time  it  is
        conventional to use the standard for your operating system.
 
 
 WHAT \R MATCHES
 
-       By default, the sequence \R in a pattern matches  any  Unicode  newline
-       sequence,  whatever  has  been selected as the line ending sequence. If
+       By  default,  the  sequence \R in a pattern matches any Unicode newline
+       sequence, whatever has been selected as the line  ending  sequence.  If
        you specify
 
          --enable-bsr-anycrlf
 
-       the default is changed so that \R matches only CR, LF, or  CRLF.  What-
-       ever  is selected when PCRE is built can be overridden when the library
+       the  default  is changed so that \R matches only CR, LF, or CRLF. What-
+       ever is selected when PCRE is built can be overridden when the  library
        functions are called.
 
 
 BUILDING SHARED AND STATIC LIBRARIES
 
-       The PCRE building process uses libtool to build both shared and  static
-       Unix  libraries by default. You can suppress one of these by adding one
+       The  PCRE building process uses libtool to build both shared and static
+       Unix libraries by default. You can suppress one of these by adding  one
        of
 
          --disable-shared
@@ -404,9 +412,9 @@ BUILDING SHARED AND STATIC LIBRARIES
 POSIX MALLOC USAGE
 
        When PCRE is called through the POSIX interface (see the pcreposix doc-
-       umentation),  additional  working  storage  is required for holding the
-       pointers to capturing substrings, because PCRE requires three  integers
-       per  substring,  whereas  the POSIX interface provides only two. If the
+       umentation), additional working storage is  required  for  holding  the
+       pointers  to capturing substrings, because PCRE requires three integers
+       per substring, whereas the POSIX interface provides only  two.  If  the
        number of expected substrings is small, the wrapper function uses space
        on the stack, because this is faster than using malloc() for each call.
        The default threshold above which the stack is no longer used is 10; it
@@ -419,50 +427,49 @@ POSIX MALLOC USAGE
 
 HANDLING VERY LARGE PATTERNS
 
-       Within  a  compiled  pattern,  offset values are used to point from one
-       part to another (for example, from an opening parenthesis to an  alter-
-       nation  metacharacter).  By default, two-byte values are used for these
-       offsets, leading to a maximum size for a  compiled  pattern  of  around
-       64K.  This  is sufficient to handle all but the most gigantic patterns.
-       Nevertheless, some people do want to process enormous patterns,  so  it
-       is  possible  to compile PCRE to use three-byte or four-byte offsets by
-       adding a setting such as
+       Within a compiled pattern, offset values are used  to  point  from  one
+       part  to another (for example, from an opening parenthesis to an alter-
+       nation metacharacter). By default, two-byte values are used  for  these
+       offsets,  leading  to  a  maximum size for a compiled pattern of around
+       64K. This is sufficient to handle all but the most  gigantic  patterns.
+       Nevertheless,  some  people do want to process truyl enormous patterns,
+       so it is possible to compile PCRE to use three-byte or  four-byte  off-
+       sets by adding a setting such as
 
          --with-link-size=3
 
-       to the configure command. The value given must be 2,  3,  or  4.  Using
-       longer  offsets slows down the operation of PCRE because it has to load
+       to  the  configure  command.  The value given must be 2, 3, or 4. Using
+       longer offsets slows down the operation of PCRE because it has to  load
        additional bytes when handling them.
 
 
 AVOIDING EXCESSIVE STACK USAGE
 
        When matching with the pcre_exec() function, PCRE implements backtrack-
-       ing  by  making recursive calls to an internal function called match().
-       In environments where the size of the stack is limited,  this  can  se-
-       verely  limit  PCRE's operation. (The Unix environment does not usually
+       ing by making recursive calls to an internal function  called  match().
+       In  environments  where  the size of the stack is limited, this can se-
+       verely limit PCRE's operation. (The Unix environment does  not  usually
        suffer from this problem, but it may sometimes be necessary to increase
-       the  maximum  stack size.  There is a discussion in the pcrestack docu-
-       mentation.) An alternative approach to recursion that uses memory  from
-       the  heap  to remember data, instead of using recursive function calls,
-       has been implemented to work round the problem of limited  stack  size.
+       the maximum stack size.  There is a discussion in the  pcrestack  docu-
+       mentation.)  An alternative approach to recursion that uses memory from
+       the heap to remember data, instead of using recursive  function  calls,
+       has  been  implemented to work round the problem of limited stack size.
        If you want to build a version of PCRE that works this way, add
 
          --disable-stack-for-recursion
 
-       to  the  configure  command. With this configuration, PCRE will use the
-       pcre_stack_malloc and pcre_stack_free variables to call memory  manage-
-       ment  functions. By default these point to malloc() and free(), but you
-       can replace the pointers so that your own functions are used.
+       to the configure command. With this configuration, PCRE  will  use  the
+       pcre_stack_malloc  and pcre_stack_free variables to call memory manage-
+       ment functions. By default these point to malloc() and free(), but  you
+       can replace the pointers so that your own functions are used instead.
 
-       Separate functions are  provided  rather  than  using  pcre_malloc  and
-       pcre_free  because  the  usage  is  very  predictable:  the block sizes
-       requested are always the same, and  the  blocks  are  always  freed  in
-       reverse  order.  A calling program might be able to implement optimized
-       functions that perform better  than  malloc()  and  free().  PCRE  runs
+       Separate  functions  are  provided  rather  than  using pcre_malloc and
+       pcre_free because the  usage  is  very  predictable:  the  block  sizes
+       requested  are  always  the  same,  and  the blocks are always freed in
+       reverse order. A calling program might be able to  implement  optimized
+       functions  that  perform  better  than  malloc()  and free(). PCRE runs
        noticeably more slowly when built in this way. This option affects only
-       the  pcre_exec()  function;  it   is   not   relevant   for   the   the
-       pcre_dfa_exec() function.
+       the pcre_exec() function; it is not relevant for pcre_dfa_exec().
 
 
 LIMITING PCRE RESOURCE USAGE
@@ -551,7 +558,7 @@ PCRETEST OPTION FOR LIBREADLINE SUPPORT
        to  the  configure  command,  pcretest  is  linked with the libreadline
        library, and when its input is from a terminal, it reads it  using  the
        readline() function. This provides line-editing and history facilities.
-       Note that libreadline is GPL-licenced, so if you distribute a binary of
+       Note that libreadline is GPL-licensed, so if you distribute a binary of
        pcretest linked in this way, there may be licensing issues.
 
        Setting  this  option  causes  the -lreadline option to be added to the
@@ -587,7 +594,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 17 March 2009
+       Last updated: 29 September 2009
        Copyright (c) 1997-2009 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -675,13 +682,19 @@ THE ALTERNATIVE MATCHING ALGORITHM
        though  it is not implemented as a traditional finite state machine (it
        keeps multiple states active simultaneously).
 
+       Although the general principle of this matching algorithm  is  that  it
+       scans  the subject string only once, without backtracking, there is one
+       exception: when a lookaround assertion is encountered,  the  characters
+       following  or  preceding  the  current  point  have to be independently
+       inspected.
+
        The scan continues until either the end of the subject is  reached,  or
        there  are  no more unterminated paths. At this point, terminated paths
        represent the different matching possibilities (if there are none,  the
        match  has  failed).   Thus,  if there is more than one possible match,
        this algorithm finds all of them, and in particular, it finds the long-
-       est.  In PCRE, there is an option to stop the algorithm after the first
-       match (which is necessarily the shortest) has been found.
+       est.  There  is  an  option to stop the algorithm after the first match
+       (which is necessarily the shortest) is found.
 
        Note that all the matches that are found start at the same point in the
        subject. If the pattern
@@ -751,24 +764,19 @@ ADVANTAGES OF THE ALTERNATIVE ALGORITHM
        more than one match using the standard algorithm, you have to do kludgy
        things with callouts.
 
-       2.  There is much better support for partial matching. The restrictions
-       on the content of the pattern that apply when using the standard  algo-
-       rithm  for  partial matching do not apply to the alternative algorithm.
-       For non-anchored patterns, the starting position of a partial match  is
-       available.
-
-       3.  Because  the  alternative  algorithm  scans the subject string just
+       2.  Because  the  alternative  algorithm  scans the subject string just
        once, and never needs to backtrack, it is possible to  pass  very  long
        subject  strings  to  the matching function in several pieces, checking
-       for partial matching each time.
+       for partial matching each time.  The  pcrepartial  documentation  gives
+       details of partial matching.
 
 
 DISADVANTAGES OF THE ALTERNATIVE ALGORITHM
 
        The alternative algorithm suffers from a number of disadvantages:
 
-       1. It is substantially slower than  the  standard  algorithm.  This  is
-       partly  because  it has to search for all possible matches, but is also
+       1.  It  is  substantially  slower  than the standard algorithm. This is
+       partly because it has to search for all possible matches, but  is  also
        because it is less susceptible to optimization.
 
        2. Capturing parentheses and back references are not supported.
@@ -786,8 +794,8 @@ AUTHOR
 
 REVISION
 
-       Last updated: 19 April 2008
-       Copyright (c) 1997-2008 University of Cambridge.
+       Last updated: 29 September 2009
+       Copyright (c) 1997-2009 University of Cambridge.
 ------------------------------------------------------------------------------
 
 
@@ -898,16 +906,18 @@ PCRE API OVERVIEW
        pcre_exec() are used for compiling and matching regular expressions  in
        a  Perl-compatible  manner. A sample program that demonstrates the sim-
        plest way of using them is provided in the file  called  pcredemo.c  in
-       the  source distribution. The pcresample documentation describes how to
-       compile and run it.
+       the PCRE source distribution. A listing of this program is given in the
+       pcredemo documentation, and the pcresample documentation describes  how
+       to compile and run it.
 
        A second matching function, pcre_dfa_exec(), which is not Perl-compati-
-       ble,  is  also provided. This uses a different algorithm for the match-
-       ing. The alternative algorithm finds all possible matches (at  a  given
-       point  in  the subject), and scans the subject just once. However, this
-       algorithm does not return captured substrings. A description of the two
-       matching  algorithms and their advantages and disadvantages is given in
-       the pcrematching documentation.
+       ble, is also provided. This uses a different algorithm for  the  match-
+       ing.  The  alternative algorithm finds all possible matches (at a given
+       point in the subject), and scans the subject just  once  (unless  there
+       are  lookbehind  assertions).  However,  this algorithm does not return
+       captured substrings. A description of the two matching  algorithms  and
+       their  advantages  and disadvantages is given in the pcrematching docu-
+       mentation.
 
        In addition to the main compiling and  matching  functions,  there  are
        convenience functions for extracting captured substrings from a subject
@@ -1117,7 +1127,9 @@ COMPILING A PATTERN
        Either of the functions pcre_compile() or pcre_compile2() can be called
        to compile a pattern into an internal form. The only difference between
        the  two interfaces is that pcre_compile2() has an additional argument,
-       errorcodeptr, via which a numerical error code can be returned.
+       errorcodeptr, via which a numerical error  code  can  be  returned.  To
+       avoid  too  much repetition, we refer just to pcre_compile() below, but
+       the information applies equally to pcre_compile2().
 
        The pattern is a C string terminated by a binary zero, and is passed in
        the  pattern  argument.  A  pointer to a single block of memory that is
@@ -1135,22 +1147,24 @@ COMPILING A PATTERN
        The options argument contains various bit settings that affect the com-
        pilation. It should be zero if no options are required.  The  available
        options  are  described  below. Some of them (in particular, those that
-       are compatible with Perl, but also some others) can  also  be  set  and
+       are compatible with Perl, but some others as well) can also be set  and
        unset  from  within  the  pattern  (see the detailed description in the
        pcrepattern documentation). For those options that can be different  in
        different  parts  of  the pattern, the contents of the options argument
-       specifies their initial settings at the start of compilation and execu-
-       tion.  The PCRE_ANCHORED and PCRE_NEWLINE_xxx options can be set at the
-       time of matching as well as at compile time.
+       specifies their settings at the start of compilation and execution. The
+       PCRE_ANCHORED, PCRE_BSR_xxx, and PCRE_NEWLINE_xxx options can be set at
+       the time of matching as well as at compile time.
 
        If errptr is NULL, pcre_compile() returns NULL immediately.  Otherwise,
        if  compilation  of  a  pattern fails, pcre_compile() returns NULL, and
        sets the variable pointed to by errptr to point to a textual error mes-
        sage. This is a static string that is part of the library. You must not
-       try to free it. The offset from the start of the pattern to the charac-
-       ter where the error was discovered is placed in the variable pointed to
-       by erroffset, which must not be NULL. If it is, an immediate  error  is
-       given.
+       try to free it. The byte offset from the start of the  pattern  to  the
+       character  that  was  being  processed when the error was discovered is
+       placed in the variable pointed to by erroffset, which must not be NULL.
+       If  it  is,  an  immediate error is given. Some errors are not detected
+       until checks are carried out when the whole pattern has  been  scanned;
+       in this case the offset is set to the end of the pattern.
 
        If  pcre_compile2()  is  used instead of pcre_compile(), and the error-
        codeptr argument is not NULL, a non-zero error code number is  returned
@@ -1480,14 +1494,14 @@ STUDYING A PATTERN
        the results of the study.
 
        The  returned  value  from  pcre_study()  can  be  passed  directly  to
-       pcre_exec(). However, a pcre_extra block  also  contains  other  fields
-       that  can  be  set  by the caller before the block is passed; these are
-       described below in the section on matching a pattern.
+       pcre_exec() or pcre_dfa_exec(). However, a pcre_extra block  also  con-
+       tains  other  fields  that can be set by the caller before the block is
+       passed; these are described below in the section on matching a pattern.
 
-       If studying the pattern does not  produce  any  additional  information
+       If studying the  pattern  does  not  produce  any  useful  information,
        pcre_study() returns NULL. In that circumstance, if the calling program
-       wants to pass any of the other fields to pcre_exec(), it  must  set  up
-       its own pcre_extra block.
+       wants  to  pass  any  of   the   other   fields   to   pcre_exec()   or
+       pcre_dfa_exec(), it must set up its own pcre_extra block.
 
        The  second  argument of pcre_study() contains option bits. At present,
        no options are defined, and this argument should always be zero.
@@ -1507,63 +1521,72 @@ STUDYING A PATTERN
            0,              /* no options exist */
            &error);        /* set to NULL or points to a message */
 
-       At present, studying a pattern is useful only for non-anchored patterns
-       that do not have a single fixed starting character. A bitmap of  possi-
-       ble starting bytes is created.
+       Studying a pattern does two things: first, a lower bound for the length
+       of subject string that is needed to match the pattern is computed. This
+       does not mean that there are any strings of that length that match, but
+       it does guarantee that no shorter strings match. The value is  used  by
+       pcre_exec()  and  pcre_dfa_exec()  to  avoid  wasting time by trying to
+       match strings that are shorter than the lower bound. You can  find  out
+       the value in a calling program via the pcre_fullinfo() function.
+
+       Studying a pattern is also useful for non-anchored patterns that do not
+       have a single fixed starting character. A bitmap of  possible  starting
+       bytes  is  created. This speeds up finding a position in the subject at
+       which to start matching.
 
 
 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
+       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 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.
 
@@ -1573,15 +1596,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
@@ -1589,9 +1612,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;
@@ -1602,111 +1625,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
+       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-
-       sponding name, zero terminated. The names are  in  alphabetical  order.
-       When PCRE_DUPNAMES is set, duplicate names are in order of their paren-
-       theses numbers. For example, consider  the  following  pattern  (assume
-       PCRE_EXTENDED  is  set,  so  white  space  -  including  newlines  - is
-       ignored):
+       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 (?|
+       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;
+       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-
+       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 ??:
 
@@ -1715,29 +1758,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, otherwise 0.
-       The fourth argument should point to an int  variable.  The  pcrepartial
-       documentation  lists  the restrictions that apply to patterns when par-
-       tial matching is used.
+       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
@@ -1751,7 +1796,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.
@@ -1759,9 +1804,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(). 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.
 
 
@@ -1817,7 +1863,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
 
        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
-       has been studied, the result of the study should be passed in the extra
+       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-
@@ -1876,8 +1922,8 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
        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  the  use of nested unlimited
-       repeats.
+       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
@@ -1910,8 +1956,8 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
        PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in  the  flags  field.  If  the
        limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT.
 
-       The  pcre_callout  field is used in conjunction with the "callout" fea-
-       ture, which is described in the pcrecallout documentation.
+       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
@@ -1928,22 +1974,23 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
 
        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_NO_START_OPTIMIZE,
-       PCRE_NO_UTF8_CHECK and PCRE_PARTIAL.
+       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
@@ -1952,76 +1999,83 @@ 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 the
-       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".
 
-       Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a spe-
-       cial  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 offset with PCRE_NOTEMPTY and PCRE_ANCHORED, and then
-       if  that  fails by advancing the starting offset (see below) and trying
-       an ordinary match again. There is some code that demonstrates how to do
-       this in the pcredemo.c sample program.
+         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
+       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
+       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
+       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
+       in the pcredemo sample program.
 
          PCRE_NO_START_OPTIMIZE
 
@@ -2056,128 +2110,132 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
        value  of startoffset that does not point to the start of a UTF-8 char-
        acter, is undefined. Your program may crash.
 
-         PCRE_PARTIAL
-
-       This option turns on the  partial  matching  feature.  If  the  subject
-       string  fails to match the pattern, but at some point during the match-
-       ing process the end of the subject was reached (that  is,  the  subject
-       partially  matches  the  pattern and the failure to match occurred only
-       because there were not enough subject characters), pcre_exec()  returns
-       PCRE_ERROR_PARTIAL  instead of PCRE_ERROR_NOMATCH. When PCRE_PARTIAL is
-       used, there are restrictions on what may appear in the  pattern.  These
-       are discussed in the pcrepartial documentation.
+         PCRE_PARTIAL_HARD
+         PCRE_PARTIAL_SOFT
+
+       These options turn on the partial matching feature. For backwards  com-
+       patibility,  PCRE_PARTIAL is a synonym for PCRE_PARTIAL_SOFT. A partial
+       match occurs if the end of the subject string is reached  successfully,
+       but  there  are not enough subject characters to complete the match. If
+       this happens when PCRE_PARTIAL_HARD  is  set,  pcre_exec()  immediately
+       returns  PCRE_ERROR_PARTIAL.  Otherwise,  if  PCRE_PARTIAL_SOFT is set,
+       matching continues by testing any other alternatives. Only if they  all
+       fail  is  PCRE_ERROR_PARTIAL  returned (instead of PCRE_ERROR_NOMATCH).
+       The portion of the string that was inspected when the partial match was
+       found  is  set  as  the first matching string. There is a more detailed
+       discussion in the pcrepartial documentation.
 
    The string to be matched by pcre_exec()
 
-       The  subject string is passed to pcre_exec() as a pointer in subject, a
+       The subject string is passed to pcre_exec() as a pointer in subject,  a
        length (in bytes) in length, and a starting byte offset in startoffset.
        In UTF-8 mode, the byte offset must point to the start of a UTF-8 char-
-       acter. Unlike the pattern string, the subject may contain  binary  zero
-       bytes.  When the starting offset is zero, the search for a match starts
-       at the beginning of the subject, and this is by  far  the  most  common
+       acter.  Unlike  the pattern string, the subject may contain binary zero
+       bytes. When the starting offset is zero, the search for a match  starts
+       at  the  beginning  of  the subject, and this is by far the most common
        case.
 
-       A  non-zero  starting offset is useful when searching for another match
-       in the same subject by calling pcre_exec() again after a previous  suc-
-       cess.   Setting  startoffset differs from just passing over a shortened
-       string and setting PCRE_NOTBOL in the case of  a  pattern  that  begins
+       A non-zero starting offset is useful when searching for  another  match
+       in  the same subject by calling pcre_exec() again after a previous suc-
+       cess.  Setting startoffset differs from just passing over  a  shortened
+       string  and  setting  PCRE_NOTBOL  in the case of a pattern that begins
        with any kind of lookbehind. For example, consider the pattern
 
          \Biss\B
 
-       which  finds  occurrences  of "iss" in the middle of words. (\B matches
-       only if the current position in the subject is not  a  word  boundary.)
-       When  applied  to the string "Mississipi" the first call to pcre_exec()
-       finds the first occurrence. If pcre_exec() is called  again  with  just
-       the  remainder  of  the  subject,  namely  "issipi", it does not match,
+       which finds occurrences of "iss" in the middle of  words.  (\B  matches
+       only  if  the  current position in the subject is not a word boundary.)
+       When applied to the string "Mississipi" the first call  to  pcre_exec()
+       finds  the  first  occurrence. If pcre_exec() is called again with just
+       the remainder of the subject,  namely  "issipi",  it  does  not  match,
        because \B is always false at the start of the subject, which is deemed
-       to  be  a  word  boundary. However, if pcre_exec() is passed the entire
+       to be a word boundary. However, if pcre_exec()  is  passed  the  entire
        string again, but with startoffset set to 4, it finds the second occur-
-       rence  of "iss" because it is able to look behind the starting point to
+       rence of "iss" because it is able to look behind the starting point  to
        discover that it is preceded by a letter.
 
-       If a non-zero starting offset is passed when the pattern  is  anchored,
+       If  a  non-zero starting offset is passed when the pattern is anchored,
        one attempt to match at the given offset is made. This can only succeed
-       if the pattern does not require the match to be at  the  start  of  the
+       if  the  pattern  does  not require the match to be at the start of the
        subject.
 
    How pcre_exec() returns captured substrings
 
-       In  general, a pattern matches a certain portion of the subject, and in
-       addition, further substrings from the subject  may  be  picked  out  by
-       parts  of  the  pattern.  Following the usage in Jeffrey Friedl's book,
-       this is called "capturing" in what follows, and the  phrase  "capturing
-       subpattern"  is  used for a fragment of a pattern that picks out a sub-
-       string. PCRE supports several other kinds of  parenthesized  subpattern
+       In general, a pattern matches a certain portion of the subject, and  in
+       addition,  further  substrings  from  the  subject may be picked out by
+       parts of the pattern. Following the usage  in  Jeffrey  Friedl's  book,
+       this  is  called "capturing" in what follows, and the phrase "capturing
+       subpattern" is used for a fragment of a pattern that picks out  a  sub-
+       string.  PCRE  supports several other kinds of parenthesized subpattern
        that do not cause substrings to be captured.
 
        Captured substrings are returned to the caller via a vector of integers
-       whose address is passed in ovector. The number of elements in the  vec-
-       tor  is  passed in ovecsize, which must be a non-negative number. Note:
+       whose  address is passed in ovector. The number of elements in the vec-
+       tor is passed in ovecsize, which must be a non-negative  number.  Note:
        this argument is NOT the size of ovector in bytes.
 
-       The first two-thirds of the vector is used to pass back  captured  sub-
-       strings,  each  substring using a pair of integers. The remaining third
-       of the vector is used as workspace by pcre_exec() while  matching  cap-
-       turing  subpatterns, and is not available for passing back information.
-       The number passed in ovecsize should always be a multiple of three.  If
+       The  first  two-thirds of the vector is used to pass back captured sub-
+       strings, each substring using a pair of integers. The  remaining  third
+       of  the  vector is used as workspace by pcre_exec() while matching cap-
+       turing subpatterns, and is not available for passing back  information.
+       The  number passed in ovecsize should always be a multiple of three. If
        it is not, it is rounded down.
 
-       When  a  match  is successful, information about captured substrings is
-       returned in pairs of integers, starting at the  beginning  of  ovector,
-       and  continuing  up  to two-thirds of its length at the most. The first
-       element of each pair is set to the byte offset of the  first  character
-       in  a  substring, and the second is set to the byte offset of the first
-       character after the end of a substring. Note: these values  are  always
+       When a match is successful, information about  captured  substrings  is
+       returned  in  pairs  of integers, starting at the beginning of ovector,
+       and continuing up to two-thirds of its length at the  most.  The  first
+       element  of  each pair is set to the byte offset of the first character
+       in a substring, and the second is set to the byte offset of  the  first
+       character  after  the end of a substring. Note: these values are always
        byte offsets, even in UTF-8 mode. They are not character counts.
 
-       The  first  pair  of  integers, ovector[0] and ovector[1], identify the
-       portion of the subject string matched by the entire pattern.  The  next
-       pair  is  used for the first capturing subpattern, and so on. The value
+       The first pair of integers, ovector[0]  and  ovector[1],  identify  the
+       portion  of  the subject string matched by the entire pattern. The next
+       pair is used for the first capturing subpattern, and so on.  The  value
        returned by pcre_exec() is one more than the highest numbered pair that
-       has  been  set.  For example, if two substrings have been captured, the
-       returned value is 3. If there are no capturing subpatterns, the  return
+       has been set.  For example, if two substrings have been  captured,  the
+       returned  value is 3. If there are no capturing subpatterns, the return
        value from a successful match is 1, indicating that just the first pair
        of offsets has been set.
 
        If a capturing subpattern is matched repeatedly, it is the last portion
        of the string that it matched that is returned.
 
-       If  the vector is too small to hold all the captured substring offsets,
+       If the vector is too small to hold all the captured substring  offsets,
        it is used as far as possible (up to two-thirds of its length), and the
-       function  returns  a value of zero. If the substring offsets are not of
-       interest, pcre_exec() may be called with ovector  passed  as  NULL  and
-       ovecsize  as zero. However, if the pattern contains back references and
-       the ovector is not big enough to remember the related substrings,  PCRE
-       has  to  get additional memory for use during matching. Thus it is usu-
+       function returns a value of zero. If the substring offsets are  not  of
+       interest,  pcre_exec()  may  be  called with ovector passed as NULL and
+       ovecsize as zero. However, if the pattern contains back references  and
+       the  ovector is not big enough to remember the related substrings, PCRE
+       has to get additional memory for use during matching. Thus it  is  usu-
        ally advisable to supply an ovector.
 
-       The pcre_info() function can be used to find  out  how  many  capturing
-       subpatterns  there  are  in  a  compiled pattern. The smallest size for
-       ovector that will allow for n captured substrings, in addition  to  the
+       The pcre_fullinfo() function can be used to find out how many capturing
+       subpatterns there are in a compiled  pattern.  The  smallest  size  for
+       ovector  that  will allow for n captured substrings, in addition to the
        offsets of the substring matched by the whole pattern, is (n+1)*3.
 
-       It  is  possible for capturing subpattern number n+1 to match some part
+       It is possible for capturing subpattern number n+1 to match  some  part
        of the subject when subpattern n has not been used at all. For example,
-       if  the  string  "abc"  is  matched against the pattern (a|(z))(bc) the
+       if the string "abc" is matched  against  the  pattern  (a|(z))(bc)  the
        return from the function is 4, and subpatterns 1 and 3 are matched, but
-       2  is  not.  When  this happens, both values in the offset pairs corre-
+       2 is not. When this happens, both values in  the  offset  pairs  corre-
        sponding to unused subpatterns are set to -1.
 
-       Offset values that correspond to unused subpatterns at the end  of  the
-       expression  are  also  set  to  -1. For example, if the string "abc" is
-       matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are  not
-       matched.  The  return  from the function is 2, because the highest used
+       Offset  values  that correspond to unused subpatterns at the end of the
+       expression are also set to -1. For example,  if  the  string  "abc"  is
+       matched  against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not
+       matched. The return from the function is 2, because  the  highest  used
        capturing subpattern number is 1. However, you can refer to the offsets
-       for  the  second  and third capturing subpatterns if you wish (assuming
+       for the second and third capturing subpatterns if  you  wish  (assuming
        the vector is large enough, of course).
 
-       Some convenience functions are provided  for  extracting  the  captured
+       Some  convenience  functions  are  provided for extracting the captured
        substrings as separate strings. These are described below.
 
    Error return values from pcre_exec()
 
-       If  pcre_exec()  fails, it returns a negative number. The following are
+       If pcre_exec() fails, it returns a negative number. The  following  are
        defined in the header file:
 
          PCRE_ERROR_NOMATCH        (-1)
@@ -2186,7 +2244,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
 
          PCRE_ERROR_NULL           (-2)
 
-       Either code or subject was passed as NULL,  or  ovector  was  NULL  and
+       Either  code  or  subject  was  passed as NULL, or ovector was NULL and
        ovecsize was not zero.
 
          PCRE_ERROR_BADOPTION      (-3)
@@ -2195,65 +2253,66 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
 
          PCRE_ERROR_BADMAGIC       (-4)
 
-       PCRE  stores a 4-byte "magic number" at the start of the compiled code,
+       PCRE stores a 4-byte "magic number" at the start of the compiled  code,
        to catch the case when it is passed a junk pointer and to detect when a
        pattern that was compiled in an environment of one endianness is run in
-       an environment with the other endianness. This is the error  that  PCRE
+       an  environment  with the other endianness. This is the error that PCRE
        gives when the magic number is not present.
 
          PCRE_ERROR_UNKNOWN_OPCODE (-5)
 
        While running the pattern match, an unknown item was encountered in the
-       compiled pattern. This error could be caused by a bug  in  PCRE  or  by
+       compiled  pattern.  This  error  could be caused by a bug in PCRE or by
        overwriting of the compiled pattern.
 
          PCRE_ERROR_NOMEMORY       (-6)
 
-       If  a  pattern contains back references, but the ovector that is passed
+       If a pattern contains back references, but the ovector that  is  passed
        to pcre_exec() is not big enough to remember the referenced substrings,
-       PCRE  gets  a  block of memory at the start of matching to use for this
-       purpose. If the call via pcre_malloc() fails, this error is given.  The
+       PCRE gets a block of memory at the start of matching to  use  for  this
+       purpose.  If the call via pcre_malloc() fails, this error is given. The
        memory is automatically freed at the end of matching.
 
          PCRE_ERROR_NOSUBSTRING    (-7)
 
-       This  error is used by the pcre_copy_substring(), pcre_get_substring(),
+       This error is used by the pcre_copy_substring(),  pcre_get_substring(),
        and  pcre_get_substring_list()  functions  (see  below).  It  is  never
        returned by pcre_exec().
 
          PCRE_ERROR_MATCHLIMIT     (-8)
 
-       The  backtracking  limit,  as  specified  by the match_limit field in a
-       pcre_extra structure (or defaulted) was reached.  See  the  description
+       The backtracking limit, as specified by  the  match_limit  field  in  a
+       pcre_extra  structure  (or  defaulted) was reached. See the description
        above.
 
          PCRE_ERROR_CALLOUT        (-9)
 
        This error is never generated by pcre_exec() itself. It is provided for
-       use by callout functions that want to yield a distinctive  error  code.
+       use  by  callout functions that want to yield a distinctive error code.
        See the pcrecallout documentation for details.
 
          PCRE_ERROR_BADUTF8        (-10)
 
-       A  string  that contains an invalid UTF-8 byte sequence was passed as a
+       A string that contains an invalid UTF-8 byte sequence was passed  as  a
        subject.
 
          PCRE_ERROR_BADUTF8_OFFSET (-11)
 
        The UTF-8 byte sequence that was passed as a subject was valid, but the
-       value  of startoffset did not point to the beginning of a UTF-8 charac-
+       value of startoffset did not point to the beginning of a UTF-8  charac-
        ter.
 
          PCRE_ERROR_PARTIAL        (-12)
 
-       The subject string did not match, but it did match partially.  See  the
+       The  subject  string did not match, but it did match partially. See the
        pcrepartial documentation for details of partial matching.
 
          PCRE_ERROR_BADPARTIAL     (-13)
 
-       The  PCRE_PARTIAL  option  was  used with a compiled pattern containing
-       items that are not supported for partial matching. See the  pcrepartial
-       documentation for details of partial matching.
+       This code is no longer in  use.  It  was  formerly  returned  when  the
+       PCRE_PARTIAL  option  was used with a compiled pattern containing items
+       that were  not  supported  for  partial  matching.  From  release  8.00
+       onwards, there are no restrictions on partial matching.
 
          PCRE_ERROR_INTERNAL       (-14)
 
@@ -2412,10 +2471,13 @@ EXTRACTING CAPTURED SUBSTRINGS BY NAME
        ate.  NOTE:  If PCRE_DUPNAMES is set and there are duplicate names, the
        behaviour may not be what you want (see the next section).
 
-       Warning: If the pattern uses the "(?|" feature to set up multiple  sub-
-       patterns  with  the  same  number,  you cannot use names to distinguish
-       them, because names are not included in the compiled code. The matching
-       process uses only numbers.
+       Warning: If the pattern uses the (?| feature to set up multiple subpat-
+       terns  with  the  same number, as described in the section on duplicate
+       subpattern numbers in the pcrepattern page, you  cannot  use  names  to
+       distinguish  the  different subpatterns, because names are not included
+       in the compiled code. The matching process uses only numbers. For  this
+       reason,  the  use of different names for subpatterns of the same number
+       causes an error at compile time.
 
 
 DUPLICATE SUBPATTERN NAMES
@@ -2423,47 +2485,51 @@ DUPLICATE SUBPATTERN NAMES
        int pcre_get_stringtable_entries(const pcre *code,
             const char *name, char **first, char **last);
 
-       When  a  pattern  is  compiled with the PCRE_DUPNAMES option, names for
-       subpatterns are not required to  be  unique.  Normally,  patterns  with
-       duplicate  names  are such that in any one match, only one of the named
-       subpatterns participates. An example is shown in the pcrepattern  docu-
-       mentation.
+       When a pattern is compiled with the  PCRE_DUPNAMES  option,  names  for
+       subpatterns  are not required to be unique. (Duplicate names are always
+       allowed for subpatterns with the same number, created by using the  (?|
+       feature.  Indeed,  if  such subpatterns are named, they are required to
+       use the same names.)
+
+       Normally, patterns with duplicate names are such that in any one match,
+       only  one of the named subpatterns participates. An example is shown in
+       the pcrepattern documentation.
 
-       When    duplicates   are   present,   pcre_copy_named_substring()   and
-       pcre_get_named_substring() return the first substring corresponding  to
-       the  given  name  that  is set. If none are set, PCRE_ERROR_NOSUBSTRING
-       (-7) is returned; no  data  is  returned.  The  pcre_get_stringnumber()
-       function  returns one of the numbers that are associated with the name,
+       When   duplicates   are   present,   pcre_copy_named_substring()    and
+       pcre_get_named_substring()  return the first substring corresponding to
+       the given name that is set. If  none  are  set,  PCRE_ERROR_NOSUBSTRING
+       (-7)  is  returned;  no  data  is returned. The pcre_get_stringnumber()
+       function returns one of the numbers that are associated with the  name,
        but it is not defined which it is.
 
-       If you want to get full details of all captured substrings for a  given
-       name,  you  must  use  the pcre_get_stringtable_entries() function. The
+       If  you want to get full details of all captured substrings for a given
+       name, you must use  the  pcre_get_stringtable_entries()  function.  The
        first argument is the compiled pattern, and the second is the name. The
-       third  and  fourth  are  pointers to variables which are updated by the
+       third and fourth are pointers to variables which  are  updated  by  the
        function. After it has run, they point to the first and last entries in
-       the  name-to-number  table  for  the  given  name.  The function itself
-       returns the length of each entry,  or  PCRE_ERROR_NOSUBSTRING  (-7)  if
-       there  are none. The format of the table is described above in the sec-
-       tion entitled Information about a  pattern.   Given  all  the  relevant
-       entries  for the name, you can extract each of their numbers, and hence
+       the name-to-number table  for  the  given  name.  The  function  itself
+       returns  the  length  of  each entry, or PCRE_ERROR_NOSUBSTRING (-7) if
+       there are none. The format of the table is described above in the  sec-
+       tion  entitled  Information  about  a  pattern.  Given all the relevant
+       entries for the name, you can extract each of their numbers, and  hence
        the captured data, if any.
 
 
 FINDING ALL POSSIBLE MATCHES
 
-       The traditional matching function uses a  similar  algorithm  to  Perl,
+       The  traditional  matching  function  uses a similar algorithm to Perl,
        which stops when it finds the first match, starting at a given point in
-       the subject. If you want to find all possible matches, or  the  longest
-       possible  match,  consider using the alternative matching function (see
-       below) instead. If you cannot use the alternative function,  but  still
-       need  to  find all possible matches, you can kludge it up by making use
+       the  subject.  If you want to find all possible matches, or the longest
+       possible match, consider using the alternative matching  function  (see
+       below)  instead.  If you cannot use the alternative function, but still
+       need to find all possible matches, you can kludge it up by  making  use
        of the callout facility, which is described in the pcrecallout documen-
        tation.
 
        What you have to do is to insert a callout right at the end of the pat-
-       tern.  When your callout function is called, extract and save the  cur-
-       rent  matched  substring.  Then  return  1, which forces pcre_exec() to
-       backtrack and try other alternatives. Ultimately, when it runs  out  of
+       tern.   When your callout function is called, extract and save the cur-
+       rent matched substring. Then return  1,  which  forces  pcre_exec()  to
+       backtrack  and  try other alternatives. Ultimately, when it runs out of
        matches, pcre_exec() will yield PCRE_ERROR_NOMATCH.
 
 
@@ -2474,14 +2540,15 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
             int options, int *ovector, int ovecsize,
             int *workspace, int wscount);
 
-       The  function  pcre_dfa_exec()  is  called  to  match  a subject string
-       against a compiled pattern, using a matching algorithm that  scans  the
-       subject  string  just  once, and does not backtrack. This has different
-       characteristics to the normal algorithm, and  is  not  compatible  with
-       Perl.  Some  of the features of PCRE patterns are not supported. Never-
-       theless, there are times when this kind of matching can be useful.  For
-       a discussion of the two matching algorithms, see the pcrematching docu-
-       mentation.
+       The function pcre_dfa_exec()  is  called  to  match  a  subject  string
+       against  a  compiled pattern, using a matching algorithm that scans the
+       subject string just once, and does not backtrack.  This  has  different
+       characteristics  to  the  normal  algorithm, and is not compatible with
+       Perl. Some of the features of PCRE patterns are not  supported.  Never-
+       theless,  there are times when this kind of matching can be useful. For
+       a discussion of the two matching algorithms, and  a  list  of  features
+       that  pcre_dfa_exec() does not support, see the pcrematching documenta-
+       tion.
 
        The arguments for the pcre_dfa_exec() function  are  the  same  as  for
        pcre_exec(), plus two extras. The ovector argument is used in a differ-
@@ -2516,38 +2583,43 @@ 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_NO_UTF8_CHECK,
-       PCRE_PARTIAL, PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last
-       three of these are the same as for pcre_exec(), so their description is
-       not repeated here.
-
-         PCRE_PARTIAL
-
-       This  has  the  same general effect as it does for pcre_exec(), but the
-       details  are  slightly  different.  When  PCRE_PARTIAL   is   set   for
-       pcre_dfa_exec(),  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 pos-
-       sibility. The portion of the string that provided the partial match  is
-       set as the first matching string.
+       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
+       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
+       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
+       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()  is  called  with  the  PCRE_PARTIAL  option,  and
-       returns  a  partial  match, it is possible to call it again, with addi-
-       tional 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.
+       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
+       after a partial match. There is more discussion of this facility in the
+       pcrepartial documentation.
 
    Successful returns from pcre_dfa_exec()
 
@@ -2636,7 +2708,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 11 April 2009
+       Last updated: 03 October 2009
        Copyright (c) 1997-2009 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -2666,10 +2738,10 @@ PCRE CALLOUTS
 
          (?C1)abc(?C2)def
 
-       If  the  PCRE_AUTO_CALLOUT  option  bit  is  set when pcre_compile() is
-       called, PCRE automatically  inserts  callouts,  all  with  number  255,
-       before  each  item in the pattern. For example, if PCRE_AUTO_CALLOUT is
-       used with the pattern
+       If  the  PCRE_AUTO_CALLOUT  option  bit  is  set when pcre_compile() or
+       pcre_compile2() is called, PCRE  automatically  inserts  callouts,  all
+       with  number  255,  before  each  item  in the pattern. For example, if
+       PCRE_AUTO_CALLOUT is used with the pattern
 
          A(\d{2}|--)
 
@@ -2698,18 +2770,23 @@ MISSING CALLOUTS
        ever  start,  and  the  callout is never reached. However, with "abyd",
        though the result is still no match, the callout is obeyed.
 
-       You can disable these optimizations by passing the  PCRE_NO_START_OPTI-
-       MIZE  option  to  pcre_exec()  or  pcre_dfa_exec(). This slows down the
-       matching process, but does ensure that callouts  such  as  the  example
+       If the pattern is studied, PCRE knows the minimum length of a  matching
+       string,  and will immediately give a "no match" return without actually
+       running a match if the subject is not long enough, or,  for  unanchored
+       patterns, if it has been scanned far enough.
+
+       You  can disable these optimizations by passing the PCRE_NO_START_OPTI-
+       MIZE option to pcre_exec() or  pcre_dfa_exec().  This  slows  down  the
+       matching  process,  but  does  ensure that callouts such as the example
        above are obeyed.
 
 
 THE CALLOUT INTERFACE
 
-       During  matching, when PCRE reaches a callout point, the external func-
-       tion defined by pcre_callout is called (if it is set). This applies  to
-       both  the  pcre_exec()  and the pcre_dfa_exec() matching functions. The
-       only argument to the callout function is a pointer  to  a  pcre_callout
+       During matching, when PCRE reaches a callout point, the external  func-
+       tion  defined by pcre_callout is called (if it is set). This applies to
+       both the pcre_exec() and the pcre_dfa_exec()  matching  functions.  The
+       only  argument  to  the callout function is a pointer to a pcre_callout
        block. This structure contains the following fields:
 
          int          version;
@@ -2725,81 +2802,81 @@ THE CALLOUT INTERFACE
          int          pattern_position;
          int          next_item_length;
 
-       The  version  field  is an integer containing the version number of the
-       block format. The initial version was 0; the current version is 1.  The
-       version  number  will  change  again in future if additional fields are
+       The version field is an integer containing the version  number  of  the
+       block  format. The initial version was 0; the current version is 1. The
+       version number will change again in future  if  additional  fields  are
        added, but the intention is never to remove any of the existing fields.
 
-       The callout_number field contains the number of the  callout,  as  com-
-       piled  into  the pattern (that is, the number after ?C for manual call-
+       The  callout_number  field  contains the number of the callout, as com-
+       piled into the pattern (that is, the number after ?C for  manual  call-
        outs, and 255 for automatically generated callouts).
 
-       The offset_vector field is a pointer to the vector of offsets that  was
-       passed   by   the   caller  to  pcre_exec()  or  pcre_dfa_exec().  When
-       pcre_exec() is used, the contents can be inspected in order to  extract
-       substrings  that  have  been  matched  so  far,  in the same way as for
-       extracting substrings after a match has completed. For  pcre_dfa_exec()
+       The  offset_vector field is a pointer to the vector of offsets that was
+       passed  by  the  caller  to  pcre_exec()   or   pcre_dfa_exec().   When
+       pcre_exec()  is used, the contents can be inspected in order to extract
+       substrings that have been matched so  far,  in  the  same  way  as  for
+       extracting  substrings after a match has completed. For pcre_dfa_exec()
        this field is not useful.
 
        The subject and subject_length fields contain copies of the values that
        were passed to pcre_exec().
 
-       The start_match field normally contains the offset within  the  subject
-       at  which  the  current  match  attempt started. However, if the escape
-       sequence \K has been encountered, this value is changed to reflect  the
-       modified  starting  point.  If the pattern is not anchored, the callout
+       The  start_match  field normally contains the offset within the subject
+       at which the current match attempt  started.  However,  if  the  escape
+       sequence  \K has been encountered, this value is changed to reflect the
+       modified starting point. If the pattern is not  anchored,  the  callout
        function may be called several times from the same point in the pattern
        for different starting points in the subject.
 
-       The  current_position  field  contains the offset within the subject of
+       The current_position field contains the offset within  the  subject  of
        the current match pointer.
 
-       When the pcre_exec() function is used, the capture_top  field  contains
-       one  more than the number of the highest numbered captured substring so
-       far. If no substrings have been captured, the value of  capture_top  is
-       one.  This  is always the case when pcre_dfa_exec() is used, because it
+       When  the  pcre_exec() function is used, the capture_top field contains
+       one more than the number of the highest numbered captured substring  so
+       far.  If  no substrings have been captured, the value of capture_top is
+       one. This is always the case when pcre_dfa_exec() is used,  because  it
        does not support captured substrings.
 
-       The capture_last field contains the number of the  most  recently  cap-
-       tured  substring. If no substrings have been captured, its value is -1.
+       The  capture_last  field  contains the number of the most recently cap-
+       tured substring. If no substrings have been captured, its value is  -1.
        This is always the case when pcre_dfa_exec() is used.
 
-       The callout_data field contains a value that is passed  to  pcre_exec()
-       or  pcre_dfa_exec() specifically so that it can be passed back in call-
-       outs. It is passed in the pcre_callout field  of  the  pcre_extra  data
-       structure.  If  no such data was passed, the value of callout_data in a
-       pcre_callout block is NULL. There is a description  of  the  pcre_extra
+       The  callout_data  field contains a value that is passed to pcre_exec()
+       or pcre_dfa_exec() specifically so that it can be passed back in  call-
+       outs.  It  is  passed  in the pcre_callout field of the pcre_extra data
+       structure. If no such data was passed, the value of callout_data  in  a
+       pcre_callout  block  is  NULL. There is a description of the pcre_extra
        structure in the pcreapi documentation.
 
-       The  pattern_position field is present from version 1 of the pcre_call-
+       The pattern_position field is present from version 1 of the  pcre_call-
        out structure. It contains the offset to the next item to be matched in
        the pattern string.
 
-       The  next_item_length field is present from version 1 of the pcre_call-
+       The next_item_length field is present from version 1 of the  pcre_call-
        out structure. It contains the length of the next item to be matched in
-       the  pattern  string. When the callout immediately precedes an alterna-
-       tion bar, a closing parenthesis, or the end of the pattern, the  length
-       is  zero.  When the callout precedes an opening parenthesis, the length
+       the pattern string. When the callout immediately precedes  an  alterna-
+       tion  bar, a closing parenthesis, or the end of the pattern, the length
+       is zero. When the callout precedes an opening parenthesis,  the  length
        is that of the entire subpattern.
 
-       The pattern_position and next_item_length fields are intended  to  help
-       in  distinguishing between different automatic callouts, which all have
+       The  pattern_position  and next_item_length fields are intended to help
+       in distinguishing between different automatic callouts, which all  have
        the same callout number. However, they are set for all callouts.
 
 
 RETURN VALUES
 
-       The external callout function returns an integer to PCRE. If the  value
-       is  zero,  matching  proceeds  as  normal. If the value is greater than
-       zero, matching fails at the current point, but  the  testing  of  other
+       The  external callout function returns an integer to PCRE. If the value
+       is zero, matching proceeds as normal. If  the  value  is  greater  than
+       zero,  matching  fails  at  the current point, but the testing of other
        matching possibilities goes ahead, just as if a lookahead assertion had
-       failed. If the value is less than zero, the  match  is  abandoned,  and
-       pcre_exec() (or pcre_dfa_exec()) returns the negative value.
+       failed.  If  the  value  is less than zero, the match is abandoned, and
+       pcre_exec() or pcre_dfa_exec() returns the negative value.
 
-       Negative   values   should   normally   be   chosen  from  the  set  of
+       Negative  values  should  normally  be   chosen   from   the   set   of
        PCRE_ERROR_xxx values. In particular, PCRE_ERROR_NOMATCH forces a stan-
-       dard  "no  match"  failure.   The  error  number  PCRE_ERROR_CALLOUT is
-       reserved for use by callout functions; it will never be  used  by  PCRE
+       dard "no  match"  failure.   The  error  number  PCRE_ERROR_CALLOUT  is
+       reserved  for  use  by callout functions; it will never be used by PCRE
        itself.
 
 
@@ -2812,7 +2889,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 15 March 2009
+       Last updated: 29 September 2009
        Copyright (c) 1997-2009 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -2827,46 +2904,49 @@ NAME
 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  mainly
-       with  respect  to  Perl 5.8, though PCRE versions 7.0 and later contain
-       some features that are expected to be in the forthcoming Perl 5.10.
+       handle regular expressions. The differences  described  here  are  with
+       respect to Perl 5.10.
 
-       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
+       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
        main pcre page.
 
        2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl
-       permits  them,  but they do not mean what you might think. For example,
+       permits them, but they do not mean what you might think.  For  example,
        (?!a){3} does not assert that the next three characters are not "a". It
        just asserts that the next character is not "a" three times.
 
-       3.  Capturing  subpatterns  that occur inside negative lookahead asser-
-       tions are counted, but their entries in the offsets  vector  are  never
-       set.  Perl sets its numerical variables from any such patterns that are
+       3. Capturing subpatterns that occur inside  negative  lookahead  asser-
+       tions  are  counted,  but their entries in the offsets vector are never
+       set. Perl sets its numerical variables from any such patterns that  are
        matched before the assertion fails to match something (thereby succeed-
-       ing),  but  only  if the negative lookahead assertion contains just one
+       ing), but only if the negative lookahead assertion  contains  just  one
        branch.
 
-       4. Though binary zero characters are supported in the  subject  string,
+       4.  Though  binary zero characters are supported in the subject string,
        they are not allowed in a pattern string because it is passed as a nor-
        mal C string, terminated by zero. The escape sequence \0 can be used in
        the pattern to represent a binary zero.
 
-       5.  The  following Perl escape sequences are not supported: \l, \u, \L,
+       5. The following Perl escape sequences are not supported: \l,  \u,  \L,
        \U, and \N. In fact these are implemented by Perl's general string-han-
-       dling  and are not part of its pattern matching engine. If any of these
+       dling and are not part of its pattern matching engine. If any of  these
        are encountered by PCRE, an error is generated.
 
-       6. The Perl escape sequences \p, \P, and \X are supported only if  PCRE
-       is  built  with Unicode character property support. The properties that
-       can be tested with \p and \P are limited to the general category  prop-
-       erties  such  as  Lu and Nd, script names such as Greek or Han, and the
-       derived properties Any and L&.
+       6.  The Perl escape sequences \p, \P, and \X are supported only if PCRE
+       is built with Unicode character property support. The  properties  that
+       can  be tested with \p and \P are limited to the general category prop-
+       erties such as Lu and Nd, script names such as Greek or  Han,  and  the
+       derived  properties  Any  and  L&. PCRE does support the Cs (surrogate)
+       property, which Perl does not; the  Perl  documentation  says  "Because
+       Perl hides the need for the user to understand the internal representa-
+       tion of Unicode characters, there is no need to implement the  somewhat
+       messy concept of surrogates."
 
        7. PCRE does support the \Q...\E escape for quoting substrings. Charac-
-       ters  in  between  are  treated as literals. This is slightly different
-       from Perl in that $ and @ are  also  handled  as  literals  inside  the
-       quotes.  In Perl, they cause variable interpolation (but of course PCRE
+       ters in between are treated as literals.  This  is  slightly  different
+       from  Perl  in  that  $  and  @ are also handled as literals inside the
+       quotes. In Perl, they cause variable interpolation (but of course  PCRE
        does not have variables). Note the following examples:
 
            Pattern            PCRE matches      Perl matches
@@ -2876,55 +2956,68 @@ DIFFERENCES BETWEEN PCRE AND PERL
            \Qabc\$xyz\E       abc\$xyz          abc\$xyz
            \Qabc\E\$\Qxyz\E   abc$xyz           abc$xyz
 
-       The \Q...\E sequence is recognized both inside  and  outside  character
+       The  \Q...\E  sequence  is recognized both inside and outside character
        classes.
 
        8. Fairly obviously, PCRE does not support the (?{code}) and (??{code})
-       constructions. However, there is support for recursive  patterns.  This
-       is  not available in Perl 5.8, but will be in Perl 5.10. Also, the PCRE
-       "callout" feature allows an external function to be called during  pat-
+       constructions.  However,  there is support for recursive patterns. This
+       is not available in Perl 5.8, but it is in Perl 5.10.  Also,  the  PCRE
+       "callout"  feature allows an external function to be called during pat-
        tern matching. See the pcrecallout documentation for details.
 
-       9.  Subpatterns  that  are  called  recursively or as "subroutines" are
-       always treated as atomic groups in  PCRE.  This  is  like  Python,  but
-       unlike Perl.
+       9. Subpatterns that are called  recursively  or  as  "subroutines"  are
+       always  treated  as  atomic  groups  in  PCRE. This is like Python, but
+       unlike Perl. There is a discussion of an example that explains this  in
+       more  detail  in  the section on recursion differences from Perl in the
+       pcrepattern page.
 
-       10.  There are some differences that are concerned with the settings of
-       captured strings when part of  a  pattern  is  repeated.  For  example,
-       matching  "aba"  against  the  pattern  /^(a(b)?)+$/  in Perl leaves $2
+       10. There are some differences that are concerned with the settings  of
+       captured  strings  when  part  of  a  pattern is repeated. For example,
+       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).  If
-       (*ACCEPT)  is within capturing parentheses, PCRE does not set that cap-
-       ture group; this is different to Perl.
-
-       12. PCRE provides some extensions to the Perl regular expression facil-
-       ities.   Perl  5.10  will  include new features that are not in earlier
-       versions, some of which (such as named parentheses) have been  in  PCRE
-       for some time. This list is with respect to Perl 5.10:
-
-       (a)  Although  lookbehind  assertions  must match fixed length strings,
-       each alternative branch of a lookbehind assertion can match a different
-       length of string. Perl requires them all to have the same length.
+       (*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-
+       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
+       such  as  (?|(?<a>A)|(?<b)B),  where the two capturing parentheses have
+       the same number but different names, is not supported,  and  causes  an
+       error  at compile time. If it were allowed, it would not be possible to
+       distinguish which parentheses matched, because both names map  to  cap-
+       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-
+       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:
+
+       (a)  Although  lookbehind  assertions  in  PCRE must match fixed length
+       strings, each alternative branch of a lookbehind assertion can match  a
+       different  length  of  string.  Perl requires them all to have the same
+       length.
 
-       (b)  If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $
+       (b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the  $
        meta-character matches only at the very end of the string.
 
        (c) If PCRE_EXTRA is set, a backslash followed by a letter with no spe-
        cial meaning is faulted. Otherwise, like Perl, the backslash is quietly
        ignored.  (Perl can be made to issue a warning.)
 
-       (d) If PCRE_UNGREEDY is set, the greediness of the  repetition  quanti-
+       (d)  If  PCRE_UNGREEDY is set, the greediness of the repetition quanti-
        fiers is inverted, that is, by default they are not greedy, but if fol-
        lowed by a question mark they are.
 
        (e) PCRE_ANCHORED can be used at matching time to force a pattern to be
        tried only at the first matching position in the subject string.
 
-       (f)  The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, and PCRE_NO_AUTO_CAP-
-       TURE options for pcre_exec() have no Perl equivalents.
+       (f) The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NOTEMPTY_ATSTART,
+       and  PCRE_NO_AUTO_CAPTURE  options for pcre_exec() have no Perl equiva-
+       lents.
 
        (g) The \R escape sequence can be restricted to match only CR,  LF,  or
        CRLF by the PCRE_BSR_ANYCRLF option.
@@ -2953,8 +3046,8 @@ AUTHOR
 
 REVISION
 
-       Last updated: 11 September 2007
-       Copyright (c) 1997-2007 University of Cambridge.
+       Last updated: 04 October 2009
+       Copyright (c) 1997-2009 University of Cambridge.
 ------------------------------------------------------------------------------
 
 
@@ -2984,9 +3077,9 @@ PCRE REGULAR EXPRESSION DETAILS
 
        The original operation of PCRE was on strings of  one-byte  characters.
        However,  there is now also support for UTF-8 character strings. To use
-       this, you must build PCRE to  include  UTF-8  support,  and  then  call
-       pcre_compile()  with  the  PCRE_UTF8  option.  There  is also a special
-       sequence that can be given at the start of a pattern:
+       this, PCRE must be built to include UTF-8 support, and  you  must  call
+       pcre_compile()  or  pcre_compile2() with the PCRE_UTF8 option. There is
+       also a special sequence that can be given at the start of a pattern:
 
          (*UTF8)
 
@@ -3024,9 +3117,9 @@ NEWLINE CONVENTIONS
          (*ANYCRLF)   any of the three above
          (*ANY)       all Unicode newline sequences
 
-       These override the default and the options given to pcre_compile(). For
-       example, on a Unix system where LF is the default newline sequence, the
-       pattern
+       These  override  the default and the options given to pcre_compile() or
+       pcre_compile2(). For example, on a Unix system where LF is the  default
+       newline sequence, the pattern
 
          (*CR)a.b
 
@@ -3143,7 +3236,7 @@ BACKSLASH
        acters  in patterns in a visible manner. There is no restriction on the
        appearance of non-printing characters, apart from the binary zero  that
        terminates  a  pattern,  but  when  a pattern is being prepared by text
-       editing, it is usually easier  to  use  one  of  the  following  escape
+       editing, it is  often  easier  to  use  one  of  the  following  escape
        sequences than the binary character it represents:
 
          \a        alarm, that is, the BEL character (hex 07)
@@ -3355,13 +3448,13 @@ BACKSLASH
          (*BSR_ANYCRLF)   CR, LF, or CRLF only
          (*BSR_UNICODE)   any Unicode newline sequence
 
-       These override the default and the options given to pcre_compile(), but
-       they can be overridden by options given to pcre_exec(). Note that these
-       special settings, which 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:
+       These override the default and the options given to  pcre_compile()  or
+       pcre_compile2(),  but  they  can  be  overridden  by  options  given to
+       pcre_exec() or pcre_dfa_exec(). Note that these special settings, which
+       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:
 
          (*ANY)(*BSR_ANYCRLF)
 
@@ -3472,9 +3565,9 @@ BACKSLASH
        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
-       the pcreapi page).
+       the pcreapi page). Perl does not support the Cs property.
 
-       The  long  synonyms  for  these  properties that Perl supports (such as
+       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".
 
@@ -3544,34 +3637,37 @@ BACKSLASH
        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.
+       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-
+       quence.  However,  whatever follows \b normally determines which it is.
+       For example, the fragment \ba matches "a" at the start of a word.
 
-       The  \A,  \Z,  and \z assertions differ from the traditional circumflex
+       The \A, \Z, and \z assertions differ from  the  traditional  circumflex
        and dollar (described in the next section) in that they only ever match
-       at  the  very start and end of the subject string, whatever options are
-       set. Thus, they are independent of multiline mode. These  three  asser-
+       at the very start and end of the subject string, whatever  options  are
+       set.  Thus,  they are independent of multiline mode. These three asser-
        tions are not affected by the PCRE_NOTBOL or PCRE_NOTEOL options, which
-       affect only the behaviour of the circumflex and dollar  metacharacters.
-       However,  if the startoffset argument of pcre_exec() is non-zero, indi-
+       affect  only the behaviour of the circumflex and dollar metacharacters.
+       However, if the startoffset argument of pcre_exec() is non-zero,  indi-
        cating that matching is to start at a point other than the beginning of
-       the  subject,  \A  can never match. The difference between \Z and \z is
+       the subject, \A can never match. The difference between \Z  and  \z  is
        that \Z matches before a newline at the end of the string as well as at
        the very end, whereas \z matches only at the end.
 
-       The  \G assertion is true only when the current matching position is at
-       the start point of the match, as specified by the startoffset  argument
-       of  pcre_exec().  It  differs  from \A when the value of startoffset is
-       non-zero. By calling pcre_exec() multiple times with appropriate  argu-
+       The \G assertion is true only when the current matching position is  at
+       the  start point of the match, as specified by the startoffset argument
+       of pcre_exec(). It differs from \A when the  value  of  startoffset  is
+       non-zero.  By calling pcre_exec() multiple times with appropriate argu-
        ments, you can mimic Perl's /g option, and it is in this kind of imple-
        mentation where \G can be useful.
 
-       Note, however, that PCRE's interpretation of \G, as the  start  of  the
+       Note,  however,  that  PCRE's interpretation of \G, as the start of the
        current match, is subtly different from Perl's, which defines it as the
-       end of the previous match. In Perl, these can  be  different  when  the
-       previously  matched  string was empty. Because PCRE does just one match
+       end  of  the  previous  match. In Perl, these can be different when the
+       previously matched string was empty. Because PCRE does just  one  match
        at a time, it cannot reproduce this behaviour.
 
-       If all the alternatives of a pattern begin with \G, the  expression  is
+       If  all  the alternatives of a pattern begin with \G, the expression is
        anchored to the starting match position, and the "anchored" flag is set
        in the compiled regular expression.
 
@@ -3579,90 +3675,90 @@ BACKSLASH
 CIRCUMFLEX AND DOLLAR
 
        Outside a character class, in the default matching mode, the circumflex
-       character  is  an  assertion  that is true only if the current matching
-       point is at the start of the subject string. If the  startoffset  argu-
-       ment  of  pcre_exec()  is  non-zero,  circumflex can never match if the
-       PCRE_MULTILINE option is unset. Inside a  character  class,  circumflex
+       character is an assertion that is true only  if  the  current  matching
+       point  is  at the start of the subject string. If the startoffset argu-
+       ment of pcre_exec() is non-zero, circumflex  can  never  match  if  the
+       PCRE_MULTILINE  option  is  unset. Inside a character class, circumflex
        has an entirely different meaning (see below).
 
-       Circumflex  need  not be the first character of the pattern if a number
-       of alternatives are involved, but it should be the first thing in  each
-       alternative  in  which  it appears if the pattern is ever to match that
-       branch. If all possible alternatives start with a circumflex, that  is,
-       if  the  pattern  is constrained to match only at the start of the sub-
-       ject, it is said to be an "anchored" pattern.  (There  are  also  other
+       Circumflex need not be the first character of the pattern if  a  number
+       of  alternatives are involved, but it should be the first thing in each
+       alternative in which it appears if the pattern is ever  to  match  that
+       branch.  If all possible alternatives start with a circumflex, that is,
+       if the pattern is constrained to match only at the start  of  the  sub-
+       ject,  it  is  said  to be an "anchored" pattern. (There are also other
        constructs that can cause a pattern to be anchored.)
 
-       A  dollar  character  is  an assertion that is true only if the current
-       matching point is at the end of  the  subject  string,  or  immediately
+       A dollar character is an assertion that is true  only  if  the  current
+       matching  point  is  at  the  end of the subject string, or immediately
        before a newline at the end of the string (by default). Dollar need not
-       be the last character of the pattern if a number  of  alternatives  are
-       involved,  but  it  should  be  the last item in any branch in which it
+       be  the  last  character of the pattern if a number of alternatives are
+       involved, but it should be the last item in  any  branch  in  which  it
        appears. Dollar has no special meaning in a character class.
 
-       The meaning of dollar can be changed so that it  matches  only  at  the
-       very  end  of  the string, by setting the PCRE_DOLLAR_ENDONLY option at
+       The  meaning  of  dollar  can be changed so that it matches only at the
+       very end of the string, by setting the  PCRE_DOLLAR_ENDONLY  option  at
        compile time. This does not affect the \Z assertion.
 
        The meanings of the circumflex and dollar characters are changed if the
-       PCRE_MULTILINE  option  is  set.  When  this  is the case, a circumflex
-       matches immediately after internal newlines as well as at the start  of
-       the  subject  string.  It  does not match after a newline that ends the
-       string. A dollar matches before any newlines in the string, as well  as
-       at  the very end, when PCRE_MULTILINE is set. When newline is specified
-       as the two-character sequence CRLF, isolated CR and  LF  characters  do
+       PCRE_MULTILINE option is set. When  this  is  the  case,  a  circumflex
+       matches  immediately after internal newlines as well as at the start of
+       the subject string. It does not match after a  newline  that  ends  the
+       string.  A dollar matches before any newlines in the string, as well as
+       at the very end, when PCRE_MULTILINE is set. When newline is  specified
+       as  the  two-character  sequence CRLF, isolated CR and LF characters do
        not indicate newlines.
 
-       For  example, the pattern /^abc$/ matches the subject string "def\nabc"
-       (where \n represents a newline) in multiline mode, but  not  otherwise.
-       Consequently,  patterns  that  are anchored in single line mode because
-       all branches start with ^ are not anchored in  multiline  mode,  and  a
-       match  for  circumflex  is  possible  when  the startoffset argument of
-       pcre_exec() is non-zero. The PCRE_DOLLAR_ENDONLY option is  ignored  if
+       For example, the pattern /^abc$/ matches the subject string  "def\nabc"
+       (where  \n  represents a newline) in multiline mode, but not otherwise.
+       Consequently, patterns that are anchored in single  line  mode  because
+       all  branches  start  with  ^ are not anchored in multiline mode, and a
+       match for circumflex is  possible  when  the  startoffset  argument  of
+       pcre_exec()  is  non-zero. The PCRE_DOLLAR_ENDONLY option is ignored if
        PCRE_MULTILINE is set.
 
-       Note  that  the sequences \A, \Z, and \z can be used to match the start
-       and end of the subject in both modes, and if all branches of a  pattern
-       start  with  \A it is always anchored, whether or not PCRE_MULTILINE is
+       Note that the sequences \A, \Z, and \z can be used to match  the  start
+       and  end of the subject in both modes, and if all branches of a pattern
+       start with \A it is always anchored, whether or not  PCRE_MULTILINE  is
        set.
 
 
 FULL STOP (PERIOD, DOT)
 
        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-
-       fies the end of a line. In UTF-8 mode, the  matched  character  may  be
+       ter in the subject string except (by default) a character  that  signi-
+       fies  the  end  of  a line. In UTF-8 mode, the matched character may be
        more than one byte long.
 
-       When  a line ending is defined as a single character, dot never matches
-       that character; when the two-character sequence CRLF is used, dot  does
-       not  match  CR  if  it  is immediately followed by LF, but otherwise it
-       matches all characters (including isolated CRs and LFs). When any  Uni-
-       code  line endings are being recognized, dot does not match CR or LF or
+       When a line ending is defined as a single character, dot never  matches
+       that  character; when the two-character sequence CRLF is used, dot does
+       not match CR if it is immediately followed  by  LF,  but  otherwise  it
+       matches  all characters (including isolated CRs and LFs). When any Uni-
+       code line endings are being recognized, dot does not match CR or LF  or
        any of the other line ending characters.
 
-       The behaviour of dot with regard to newlines can  be  changed.  If  the
-       PCRE_DOTALL  option  is  set,  a dot matches any one character, without
+       The  behaviour  of  dot  with regard to newlines can be changed. If the
+       PCRE_DOTALL option is set, a dot matches  any  one  character,  without
        exception. If the two-character sequence CRLF is present in the subject
        string, it takes two dots to match it.
 
-       The  handling of dot is entirely independent of the handling of circum-
-       flex and dollar, the only relationship being  that  they  both  involve
+       The handling of dot is entirely independent of the handling of  circum-
+       flex  and  dollar,  the  only relationship being that they both involve
        newlines. Dot has no special meaning in a character class.
 
 
 MATCHING A SINGLE BYTE
 
        Outside a character class, the escape sequence \C matches any one byte,
-       both in and out of UTF-8 mode. Unlike a  dot,  it  always  matches  any
-       line-ending  characters.  The  feature  is provided in Perl in order to
-       match individual bytes in UTF-8 mode. Because it breaks up UTF-8  char-
-       acters  into individual bytes, what remains in the string may be a mal-
-       formed UTF-8 string. For this reason, the \C escape  sequence  is  best
+       both  in  and  out  of  UTF-8 mode. Unlike a dot, it always matches any
+       line-ending characters. The feature is provided in  Perl  in  order  to
+       match  individual bytes in UTF-8 mode. Because it breaks up UTF-8 char-
+       acters into individual bytes, what remains in the string may be a  mal-
+       formed  UTF-8  string.  For this reason, the \C escape sequence is best
        avoided.
 
-       PCRE  does  not  allow \C to appear in lookbehind assertions (described
-       below), because in UTF-8 mode this would make it impossible  to  calcu-
+       PCRE does not allow \C to appear in  lookbehind  assertions  (described
+       below),  because  in UTF-8 mode this would make it impossible to calcu-
        late the length of the lookbehind.
 
 
@@ -3670,97 +3766,99 @@ SQUARE BRACKETS AND CHARACTER CLASSES
 
        An opening square bracket introduces a character class, terminated by a
        closing square bracket. A closing square bracket on its own is not spe-
-       cial. If a closing square bracket is required as a member of the class,
-       it should be the first data character in the class  (after  an  initial
-       circumflex, if present) or escaped with a backslash.
-
-       A  character  class matches a single character in the subject. In UTF-8
-       mode, the character may occupy more than one byte. A matched  character
+       cial by default.  However, if the PCRE_JAVASCRIPT_COMPAT option is set,
+       a lone closing square bracket causes a compile-time error. If a closing
+       square bracket is required as a member of the class, it should  be  the
+       first  data  character  in  the  class (after an initial circumflex, if
+       present) or escaped with a backslash.
+
+       A character class matches a single character in the subject.  In  UTF-8
+       mode, the character may be more than one byte long. A matched character
        must be in the set of characters defined by the class, unless the first
-       character in the class definition is a circumflex, in  which  case  the
-       subject  character  must  not  be in the set defined by the class. If a
-       circumflex is actually required as a member of the class, ensure it  is
+       character  in  the  class definition is a circumflex, in which case the
+       subject character must not be in the set defined by  the  class.  If  a
+       circumflex  is actually required as a member of the class, ensure it is
        not the first character, or escape it with a backslash.
 
-       For  example, the character class [aeiou] matches any lower case vowel,
-       while [^aeiou] matches any character that is not a  lower  case  vowel.
+       For example, the character class [aeiou] matches any lower case  vowel,
+       while  [^aeiou]  matches  any character that is not a lower case vowel.
        Note that a circumflex is just a convenient notation for specifying the
-       characters that are in the class by enumerating those that are  not.  A
-       class  that starts with a circumflex is not an assertion: it still con-
-       sumes a character from the subject string, and therefore  it  fails  if
+       characters  that  are in the class by enumerating those that are not. A
+       class that starts with a circumflex is not an assertion; it still  con-
+       sumes  a  character  from the subject string, and therefore it fails if
        the current pointer is at the end of the string.
 
-       In  UTF-8 mode, characters with values greater than 255 can be included
-       in a class as a literal string of bytes, or by using the  \x{  escaping
+       In UTF-8 mode, characters with values greater than 255 can be  included
+       in  a  class as a literal string of bytes, or by using the \x{ escaping
        mechanism.
 
-       When  caseless  matching  is set, any letters in a class represent both
-       their upper case and lower case versions, so for  example,  a  caseless
-       [aeiou]  matches  "A"  as well as "a", and a caseless [^aeiou] does not
-       match "A", whereas a caseful version would. In UTF-8 mode, PCRE  always
-       understands  the  concept  of case for characters whose values are less
-       than 128, so caseless matching is always possible. For characters  with
-       higher  values,  the  concept  of case is supported if PCRE is compiled
-       with Unicode property support, but not otherwise.  If you want  to  use
-       caseless  matching  for  characters 128 and above, you must ensure that
-       PCRE is compiled with Unicode property support as well  as  with  UTF-8
-       support.
-
-       Characters  that  might  indicate  line breaks are never treated in any
-       special way  when  matching  character  classes,  whatever  line-ending
-       sequence  is  in  use,  and  whatever  setting  of  the PCRE_DOTALL and
+       When caseless matching is set, any letters in a  class  represent  both
+       their  upper  case  and lower case versions, so for example, a caseless
+       [aeiou] matches "A" as well as "a", and a caseless  [^aeiou]  does  not
+       match  "A", whereas a caseful version would. In UTF-8 mode, PCRE always
+       understands the concept of case for characters whose  values  are  less
+       than  128, so caseless matching is always possible. For characters with
+       higher values, the concept of case is supported  if  PCRE  is  compiled
+       with  Unicode  property support, but not otherwise.  If you want to use
+       caseless matching in UTF8-mode for characters 128 and above,  you  must
+       ensure  that  PCRE is compiled with Unicode property support as well as
+       with UTF-8 support.
+
+       Characters that might indicate line breaks are  never  treated  in  any
+       special  way  when  matching  character  classes,  whatever line-ending
+       sequence is in  use,  and  whatever  setting  of  the  PCRE_DOTALL  and
        PCRE_MULTILINE options is used. A class such as [^a] always matches one
        of these characters.
 
-       The  minus (hyphen) character can be used to specify a range of charac-
-       ters in a character  class.  For  example,  [d-m]  matches  any  letter
-       between  d  and  m,  inclusive.  If  a minus character is required in a
-       class, it must be escaped with a backslash  or  appear  in  a  position
-       where  it cannot be interpreted as indicating a range, typically as the
+       The minus (hyphen) character can be used to specify a range of  charac-
+       ters  in  a  character  class.  For  example,  [d-m] matches any letter
+       between d and m, inclusive. If a  minus  character  is  required  in  a
+       class,  it  must  be  escaped  with a backslash or appear in a position
+       where it cannot be interpreted as indicating a range, typically as  the
        first or last character in the class.
 
        It is not possible to have the literal character "]" as the end charac-
-       ter  of a range. A pattern such as [W-]46] is interpreted as a class of
-       two characters ("W" and "-") followed by a literal string "46]", so  it
-       would  match  "W46]"  or  "-46]". However, if the "]" is escaped with a
-       backslash it is interpreted as the end of range, so [W-\]46] is  inter-
-       preted  as a class containing a range followed by two other characters.
-       The octal or hexadecimal representation of "]" can also be used to  end
+       ter of a range. A pattern such as [W-]46] is interpreted as a class  of
+       two  characters ("W" and "-") followed by a literal string "46]", so it
+       would match "W46]" or "-46]". However, if the "]"  is  escaped  with  a
+       backslash  it is interpreted as the end of range, so [W-\]46] is inter-
+       preted as a class containing a range followed by two other  characters.
+       The  octal or hexadecimal representation of "]" can also be used to end
        a range.
 
-       Ranges  operate in the collating sequence of character values. They can
-       also  be  used  for  characters  specified  numerically,  for   example
-       [\000-\037].  In UTF-8 mode, ranges can include characters whose values
+       Ranges operate in the collating sequence of character values. They  can
+       also   be  used  for  characters  specified  numerically,  for  example
+       [\000-\037]. In UTF-8 mode, ranges can include characters whose  values
        are greater than 255, for example [\x{100}-\x{2ff}].
 
        If a range that includes letters is used when caseless matching is set,
        it matches the letters in either case. For example, [W-c] is equivalent
-       to [][\\^_`wxyzabc], matched caselessly,  and  in  non-UTF-8  mode,  if
-       character  tables  for  a French locale are in use, [\xc8-\xcb] matches
-       accented E characters in both cases. In UTF-8 mode, PCRE  supports  the
-       concept  of  case for characters with values greater than 128 only when
+       to  [][\\^_`wxyzabc],  matched  caselessly,  and  in non-UTF-8 mode, if
+       character tables for a French locale are in  use,  [\xc8-\xcb]  matches
+       accented  E  characters in both cases. In UTF-8 mode, PCRE supports the
+       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
+       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,
+       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 only metacharacters that are recognized in  character  classes  are
-       backslash,  hyphen  (only  where  it can be interpreted as specifying a
-       range), circumflex (only at the start), opening  square  bracket  (only
-       when  it can be interpreted as introducing a POSIX class name - see the
-       next section), and the terminating  closing  square  bracket.  However,
+       The  only  metacharacters  that are recognized in character classes are
+       backslash, hyphen (only where it can be  interpreted  as  specifying  a
+       range),  circumflex  (only  at the start), opening square bracket (only
+       when it can be interpreted as introducing a POSIX class name - see  the
+       next  section),  and  the  terminating closing square bracket. However,
        escaping other non-alphanumeric characters does no harm.
 
 
 POSIX CHARACTER CLASSES
 
        Perl supports the POSIX notation for character classes. This uses names
-       enclosed by [: and :] within the enclosing square brackets.  PCRE  also
+       enclosed  by  [: and :] within the enclosing square brackets. PCRE also
        supports this notation. For example,
 
          [01[:alpha:]%]
@@ -3783,18 +3881,18 @@ POSIX CHARACTER CLASSES
          word     "word" characters (same as \w)
          xdigit   hexadecimal digits
 
-       The "space" characters are HT (9), LF (10), VT (11), FF (12), CR  (13),
-       and  space  (32). Notice that this list includes the VT character (code
+       The  "space" characters are HT (9), LF (10), VT (11), FF (12), CR (13),
+       and space (32). Notice that this list includes the VT  character  (code
        11). This makes "space" different to \s, which does not include VT (for
        Perl compatibility).
 
-       The  name  "word"  is  a Perl extension, and "blank" is a GNU extension
-       from Perl 5.8. Another Perl extension is negation, which  is  indicated
+       The name "word" is a Perl extension, and "blank"  is  a  GNU  extension
+       from  Perl  5.8. Another Perl extension is negation, which is indicated
        by a ^ character after the colon. For example,
 
          [12[:^digit:]]
 
-       matches  "1", "2", or any non-digit. PCRE (and Perl) also recognize the
+       matches "1", "2", or any non-digit. PCRE (and Perl) also recognize  the
        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.
 
@@ -3804,24 +3902,24 @@ POSIX CHARACTER CLASSES
 
 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
@@ -3831,46 +3929,46 @@ 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
+       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.
 
 
@@ -3883,18 +3981,18 @@ SUBPATTERNS
 
          cat(aract|erpillar|)
 
-       matches one of the words "cat", "cataract", or  "caterpillar".  Without
-       the  parentheses,  it  would  match  "cataract", "erpillar" or an empty
+       matches  one  of the words "cat", "cataract", or "caterpillar". Without
+       the parentheses, it would match  "cataract",  "erpillar"  or  an  empty
        string.
 
-       2. It sets up the subpattern as  a  capturing  subpattern.  This  means
-       that,  when  the  whole  pattern  matches,  that portion of the subject
+       2.  It  sets  up  the  subpattern as a capturing subpattern. This means
+       that, when the whole pattern  matches,  that  portion  of  the  subject
        string that matched the subpattern is passed back to the caller via the
-       ovector  argument  of pcre_exec(). Opening parentheses are counted from
-       left to right (starting from 1) to obtain  numbers  for  the  capturing
+       ovector argument of pcre_exec(). Opening parentheses are  counted  from
+       left  to  right  (starting  from 1) to obtain numbers for the capturing
        subpatterns.
 
-       For  example,  if the string "the red king" is matched against the pat-
+       For example, if the string "the red king" is matched against  the  pat-
        tern
 
          the ((red|white) (king|queen))
@@ -3902,12 +4000,12 @@ SUBPATTERNS
        the captured substrings are "red king", "red", and "king", and are num-
        bered 1, 2, and 3, respectively.
 
-       The  fact  that  plain  parentheses  fulfil two functions is not always
-       helpful.  There are often times when a grouping subpattern is  required
-       without  a capturing requirement. If an opening parenthesis is followed
-       by a question mark and a colon, the subpattern does not do any  captur-
-       ing,  and  is  not  counted when computing the number of any subsequent
-       capturing subpatterns. For example, if the string "the white queen"  is
+       The fact that plain parentheses fulfil  two  functions  is  not  always
+       helpful.   There are often times when a grouping subpattern is required
+       without a capturing requirement. If an opening parenthesis is  followed
+       by  a question mark and a colon, the subpattern does not do any captur-
+       ing, and is not counted when computing the  number  of  any  subsequent
+       capturing  subpatterns. For example, if the string "the white queen" is
        matched against the pattern
 
          the ((?:red|white) (king|queen))
@@ -3915,46 +4013,59 @@ SUBPATTERNS
        the captured substrings are "white queen" and "queen", and are numbered
        1 and 2. The maximum number of capturing subpatterns is 65535.
 
-       As a convenient shorthand, if any option settings are required  at  the
-       start  of  a  non-capturing  subpattern,  the option letters may appear
+       As  a  convenient shorthand, if any option settings are required at the
+       start of a non-capturing subpattern,  the  option  letters  may  appear
        between the "?" and the ":". Thus the two patterns
 
          (?i:saturday|sunday)
          (?:(?i)saturday|sunday)
 
        match exactly the same set of strings. Because alternative branches are
-       tried  from  left  to right, and options are not reset until the end of
-       the subpattern is reached, an option setting in one branch does  affect
-       subsequent  branches,  so  the above patterns match "SUNDAY" as well as
+       tried from left to right, and options are not reset until  the  end  of
+       the  subpattern is reached, an option setting in one branch does affect
+       subsequent branches, so the above patterns match "SUNDAY"  as  well  as
        "Saturday".
 
 
 DUPLICATE SUBPATTERN NUMBERS
 
        Perl 5.10 introduced a feature whereby each alternative in a subpattern
-       uses  the same numbers for its capturing parentheses. Such a subpattern
-       starts with (?| and is itself a non-capturing subpattern. For  example,
+       uses the same numbers for its capturing parentheses. Such a  subpattern
+       starts  with (?| and is itself a non-capturing subpattern. For example,
        consider this pattern:
 
          (?|(Sat)ur|(Sun))day
 
-       Because  the two alternatives are inside a (?| group, both sets of cap-
-       turing parentheses are numbered one. Thus, when  the  pattern  matches,
-       you  can  look  at captured substring number one, whichever alternative
-       matched. This construct is useful when you want to  capture  part,  but
+       Because the two alternatives are inside a (?| group, both sets of  cap-
+       turing  parentheses  are  numbered one. Thus, when the pattern matches,
+       you can look at captured substring number  one,  whichever  alternative
+       matched.  This  construct  is useful when you want to capture part, but
        not all, of one of a number of alternatives. Inside a (?| group, paren-
-       theses are numbered as usual, but the number is reset at the  start  of
-       each  branch. The numbers of any capturing buffers that follow the sub-
-       pattern start after the highest number used in any branch. The  follow-
-       ing  example  is taken from the Perl documentation.  The numbers under-
+       theses  are  numbered as usual, but the number is reset at the start of
+       each branch. The numbers of any capturing buffers that follow the  sub-
+       pattern  start after the highest number used in any branch. The follow-
+       ing example is taken from the Perl documentation.  The  numbers  under-
        neath show in which buffer the captured content will be stored.
 
          # before  ---------------branch-reset----------- after
          / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
          # 1            2         2  3        2     3     4
 
-       A backreference or a recursive call to  a  numbered  subpattern  always
-       refers to the first one in the pattern with the given number.
+       A  backreference  to  a  numbered subpattern uses the most recent value
+       that is set for that number by any subpattern.  The  following  pattern
+       matches "abcabc" or "defdef":
+
+         /(?|(abc)|(def))\1/
+
+       In  contrast, a recursive or "subroutine" call to a numbered subpattern
+       always refers to the first one in the pattern with  the  given  number.
+       The following pattern matches "abcabc" or "defabc":
+
+         /(?|(abc)|(def))(?1)/
+
+       If  a condition test for a subpattern's having matched refers to a non-
+       unique number, the test is true if any of the subpatterns of that  num-
+       ber have matched.
 
        An  alternative approach to using this "branch reset" feature is to use
        duplicate named subpatterns, as described in the next section.
@@ -3969,26 +4080,29 @@ NAMED SUBPATTERNS
        patterns. This feature was not added to Perl until release 5.10. Python
        had  the  feature earlier, and PCRE introduced it at release 4.0, using
        the Python syntax. PCRE now supports both the Perl and the Python  syn-
-       tax.
+       tax.  Perl  allows  identically  numbered subpatterns to have different
+       names, but PCRE does not.
 
-       In  PCRE,  a subpattern can be named in one of three ways: (?<name>...)
-       or (?'name'...) as in Perl, or (?P<name>...) as in  Python.  References
+       In PCRE, a subpattern can be named in one of three  ways:  (?<name>...)
+       or  (?'name'...)  as in Perl, or (?P<name>...) as in Python. References
        to capturing parentheses from other parts of the pattern, such as back-
-       references, recursion, and conditions, can be made by name as  well  as
+       references,  recursion,  and conditions, can be made by name as well as
        by number.
 
-       Names  consist  of  up  to  32 alphanumeric characters and underscores.
-       Named capturing parentheses are still  allocated  numbers  as  well  as
-       names,  exactly as if the names were not present. The PCRE API provides
+       Names consist of up to  32  alphanumeric  characters  and  underscores.
+       Named  capturing  parentheses  are  still  allocated numbers as well as
+       names, exactly as if the names were not present. The PCRE API  provides
        function calls for extracting the name-to-number translation table from
        a compiled pattern. There is also a convenience function for extracting
        a captured substring by name.
 
-       By default, a name must be unique within a pattern, but it is  possible
+       By  default, a name must be unique within a pattern, but it is possible
        to relax this constraint by setting the PCRE_DUPNAMES option at compile
-       time. This can be useful for patterns where only one  instance  of  the
-       named  parentheses  can  match. Suppose you want to match the name of a
-       weekday, either as a 3-letter abbreviation or as the full name, and  in
+       time.  (Duplicate  names are also always permitted for subpatterns with
+       the same number, set up as described in the previous  section.)  Dupli-
+       cate  names  can  be useful for patterns where only one instance of the
+       named parentheses can match. Suppose you want to match the  name  of  a
+       weekday,  either as a 3-letter abbreviation or as the full name, and in
        both cases you want to extract the abbreviation. This pattern (ignoring
        the line breaks) does the job:
 
@@ -3998,26 +4112,38 @@ NAMED SUBPATTERNS
          (?<DN>Thu)(?:rsday)?|
          (?<DN>Sat)(?:urday)?
 
-       There are five capturing substrings, but only one is ever set  after  a
+       There  are  five capturing substrings, but only one is ever set after a
        match.  (An alternative way of solving this problem is to use a "branch
        reset" subpattern, as described in the previous section.)
 
-       The convenience function for extracting the data by  name  returns  the
-       substring  for  the first (and in this example, the only) subpattern of
-       that name that matched. This saves searching  to  find  which  numbered
-       subpattern  it  was. If you make a reference to a non-unique named sub-
-       pattern from elsewhere in the pattern, the one that corresponds to  the
-       lowest  number  is used. For further details of the interfaces for han-
-       dling named subpatterns, see the pcreapi documentation.
+       The  convenience  function  for extracting the data by name returns the
+       substring for the first (and in this example, the only)  subpattern  of
+       that  name  that  matched.  This saves searching to find which numbered
+       subpattern it was.
+
+       If you make a backreference to a non-unique named subpattern from else-
+       where  in the pattern, the one that corresponds to the first occurrence
+       of the name is used. In the absence of duplicate numbers (see the  pre-
+       vious  section)  this  is  the one with the lowest number. If you use a
+       named reference in a condition test (see the section  about  conditions
+       below),  either  to check whether a subpattern has matched, or to check
+       for recursion, all subpatterns with the same name are  tested.  If  the
+       condition  is  true for any one of them, the overall condition is true.
+       This is the same behaviour as testing by number. For further details of
+       the interfaces for handling named subpatterns, see the pcreapi documen-
+       tation.
 
        Warning: You cannot use different names to distinguish between two sub-
-       patterns  with  the same number (see the previous section) because PCRE
-       uses only the numbers when matching.
+       patterns  with  the same number because PCRE uses only the numbers when
+       matching. For this reason, an error is given at compile time if differ-
+       ent  names  are given to subpatterns with the same number. However, you
+       can give the same name to subpatterns with the same number,  even  when
+       PCRE_DUPNAMES is not set.
 
 
 REPETITION
 
-       Repetition is specified by quantifiers, which can  follow  any  of  the
+       Repetition  is  specified  by  quantifiers, which can follow any of the
        following items:
 
          a literal data character
@@ -4029,18 +4155,19 @@ REPETITION
          a character class
          a back reference (see next section)
          a parenthesized subpattern (unless it is an assertion)
+         a recursive or "subroutine" call to a subpattern
 
-       The  general repetition quantifier specifies a minimum and maximum num-
-       ber of permitted matches, by giving the two numbers in  curly  brackets
-       (braces),  separated  by  a comma. The numbers must be less than 65536,
+       The general repetition quantifier specifies a minimum and maximum  num-
+       ber  of  permitted matches, by giving the two numbers in curly brackets
+       (braces), separated by a comma. The numbers must be  less  than  65536,
        and the first must be less than or equal to the second. For example:
 
          z{2,4}
 
-       matches "zz", "zzz", or "zzzz". A closing brace on its  own  is  not  a
-       special  character.  If  the second number is omitted, but the comma is
-       present, there is no upper limit; if the second number  and  the  comma
-       are  both omitted, the quantifier specifies an exact number of required
+       matches  "zz",  "zzz",  or  "zzzz". A closing brace on its own is not a
+       special character. If the second number is omitted, but  the  comma  is
+       present,  there  is  no upper limit; if the second number and the comma
+       are both omitted, the quantifier specifies an exact number of  required
        matches. Thus
 
          [aeiou]{3,}
@@ -4049,49 +4176,49 @@ REPETITION
 
          \d{8}
 
-       matches exactly 8 digits. An opening curly bracket that  appears  in  a
-       position  where a quantifier is not allowed, or one that does not match
-       the syntax of a quantifier, is taken as a literal character. For  exam-
+       matches  exactly  8  digits. An opening curly bracket that appears in a
+       position where a quantifier is not allowed, or one that does not  match
+       the  syntax of a quantifier, is taken as a literal character. For exam-
        ple, {,6} is not a quantifier, but a literal string of four characters.
 
-       In  UTF-8  mode,  quantifiers  apply to UTF-8 characters rather than to
+       In UTF-8 mode, quantifiers apply to UTF-8  characters  rather  than  to
        individual bytes. Thus, for example, \x{100}{2} matches two UTF-8 char-
        acters, each of which is represented by a two-byte sequence. Similarly,
        when Unicode property support is available, \X{3} matches three Unicode
-       extended  sequences,  each of which may be several bytes long (and they
+       extended sequences, each of which may be several bytes long  (and  they
        may be of different lengths).
 
        The quantifier {0} is permitted, causing the expression to behave as if
        the previous item and the quantifier were not present. This may be use-
-       ful for subpatterns that are referenced as subroutines  from  elsewhere
+       ful  for  subpatterns that are referenced as subroutines from elsewhere
        in the pattern. Items other than subpatterns that have a {0} quantifier
        are omitted from the compiled pattern.
 
-       For convenience, the three most common quantifiers have  single-charac-
+       For  convenience, the three most common quantifiers have single-charac-
        ter abbreviations:
 
          *    is equivalent to {0,}
          +    is equivalent to {1,}
          ?    is equivalent to {0,1}
 
-       It  is  possible  to construct infinite loops by following a subpattern
+       It is possible to construct infinite loops by  following  a  subpattern
        that can match no characters with a quantifier that has no upper limit,
        for example:
 
          (a?)*
 
        Earlier versions of Perl and PCRE used to give an error at compile time
-       for such patterns. However, because there are cases where this  can  be
-       useful,  such  patterns  are now accepted, but if any repetition of the
-       subpattern does in fact match no characters, the loop is forcibly  bro-
+       for  such  patterns. However, because there are cases where this can be
+       useful, such patterns are now accepted, but if any  repetition  of  the
+       subpattern  does in fact match no characters, the loop is forcibly bro-
        ken.
 
-       By  default,  the quantifiers are "greedy", that is, they match as much
-       as possible (up to the maximum  number  of  permitted  times),  without
-       causing  the  rest of the pattern to fail. The classic example of where
+       By default, the quantifiers are "greedy", that is, they match  as  much
+       as  possible  (up  to  the  maximum number of permitted times), without
+       causing the rest of the pattern to fail. The classic example  of  where
        this gives problems is in trying to match comments in C programs. These
-       appear  between  /*  and  */ and within the comment, individual * and /
-       characters may appear. An attempt to match C comments by  applying  the
+       appear between /* and */ and within the comment,  individual  *  and  /
+       characters  may  appear. An attempt to match C comments by applying the
        pattern
 
          /\*.*\*/
@@ -4100,19 +4227,19 @@ REPETITION
 
          /* first comment */  not comment  /* second comment */
 
-       fails,  because it matches the entire string owing to the greediness of
+       fails, because it matches the entire string owing to the greediness  of
        the .*  item.
 
-       However, if a quantifier is followed by a question mark, it  ceases  to
+       However,  if  a quantifier is followed by a question mark, it ceases to
        be greedy, and instead matches the minimum number of times possible, so
        the pattern
 
          /\*.*?\*/
 
-       does the right thing with the C comments. The meaning  of  the  various
-       quantifiers  is  not  otherwise  changed,  just the preferred number of
-       matches.  Do not confuse this use of question mark with its  use  as  a
-       quantifier  in its own right. Because it has two uses, it can sometimes
+       does  the  right  thing with the C comments. The meaning of the various
+       quantifiers is not otherwise changed,  just  the  preferred  number  of
+       matches.   Do  not  confuse this use of question mark with its use as a
+       quantifier in its own right. Because it has two uses, it can  sometimes
        appear doubled, as in
 
          \d??\d
@@ -4120,36 +4247,36 @@ REPETITION
        which matches one digit by preference, but can match two if that is the
        only way the rest of the pattern matches.
 
-       If  the PCRE_UNGREEDY option is set (an option that is not available in
-       Perl), the quantifiers are not greedy by default, but  individual  ones
-       can  be  made  greedy  by following them with a question mark. In other
+       If the PCRE_UNGREEDY option is set (an option that is not available  in
+       Perl),  the  quantifiers are not greedy by default, but individual ones
+       can be made greedy by following them with a  question  mark.  In  other
        words, it inverts the default behaviour.
 
-       When a parenthesized subpattern is quantified  with  a  minimum  repeat
-       count  that is greater than 1 or with a limited maximum, more memory is
-       required for the compiled pattern, in proportion to  the  size  of  the
+       When  a  parenthesized  subpattern  is quantified with a minimum repeat
+       count that is greater than 1 or with a limited maximum, more memory  is
+       required  for  the  compiled  pattern, in proportion to the size of the
        minimum or maximum.
 
        If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equiv-
-       alent to Perl's /s) is set, thus allowing the dot  to  match  newlines,
-       the  pattern  is  implicitly anchored, because whatever follows will be
-       tried against every character position in the subject string, so  there
-       is  no  point  in  retrying the overall match at any position after the
-       first. PCRE normally treats such a pattern as though it  were  preceded
+       alent  to  Perl's  /s) is set, thus allowing the dot to match newlines,
+       the pattern is implicitly anchored, because whatever  follows  will  be
+       tried  against every character position in the subject string, so there
+       is no point in retrying the overall match at  any  position  after  the
+       first.  PCRE  normally treats such a pattern as though it were preceded
        by \A.
 
-       In  cases  where  it  is known that the subject string contains no new-
-       lines, it is worth setting PCRE_DOTALL in order to  obtain  this  opti-
+       In cases where it is known that the subject  string  contains  no  new-
+       lines,  it  is  worth setting PCRE_DOTALL in order to obtain this opti-
        mization, or alternatively using ^ to indicate anchoring explicitly.
 
-       However,  there is one situation where the optimization cannot be used.
-       When .*  is inside capturing parentheses that  are  the  subject  of  a
-       backreference  elsewhere  in the pattern, a match at the start may fail
+       However, there is one situation where the optimization cannot be  used.
+       When  .*   is  inside  capturing  parentheses that are the subject of a
+       backreference elsewhere in the pattern, a match at the start  may  fail
        where a later one succeeds. Consider, for example:
 
          (.*)abc\1
 
-       If the subject is "xyz123abc123" the match point is the fourth  charac-
+       If  the subject is "xyz123abc123" the match point is the fourth charac-
        ter. For this reason, such a pattern is not implicitly anchored.
 
        When a capturing subpattern is repeated, the value captured is the sub-
@@ -4158,8 +4285,8 @@ REPETITION
          (tweedle[dume]{3}\s*)+
 
        has matched "tweedledum tweedledee" the value of the captured substring
-       is  "tweedledee".  However,  if there are nested capturing subpatterns,
-       the corresponding captured values may have been set in previous  itera-
+       is "tweedledee". However, if there are  nested  capturing  subpatterns,
+       the  corresponding captured values may have been set in previous itera-
        tions. For example, after
 
          /(a|(b))+/
@@ -4169,53 +4296,53 @@ REPETITION
 
 ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS
 
-       With  both  maximizing ("greedy") and minimizing ("ungreedy" or "lazy")
-       repetition, failure of what follows normally causes the  repeated  item
-       to  be  re-evaluated to see if a different number of repeats allows the
-       rest of the pattern to match. Sometimes it is useful to  prevent  this,
-       either  to  change the nature of the match, or to cause it fail earlier
-       than it otherwise might, when the author of the pattern knows there  is
+       With both maximizing ("greedy") and minimizing ("ungreedy"  or  "lazy")
+       repetition,  failure  of what follows normally causes the repeated item
+       to be re-evaluated to see if a different number of repeats  allows  the
+       rest  of  the pattern to match. Sometimes it is useful to prevent this,
+       either to change the nature of the match, or to cause it  fail  earlier
+       than  it otherwise might, when the author of the pattern knows there is
        no point in carrying on.
 
-       Consider,  for  example, the pattern \d+foo when applied to the subject
+       Consider, for example, the pattern \d+foo when applied to  the  subject
        line
 
          123456bar
 
        After matching all 6 digits and then failing to match "foo", the normal
-       action  of  the matcher is to try again with only 5 digits matching the
-       \d+ item, and then with  4,  and  so  on,  before  ultimately  failing.
-       "Atomic  grouping"  (a  term taken from Jeffrey Friedl's book) provides
-       the means for specifying that once a subpattern has matched, it is  not
+       action of the matcher is to try again with only 5 digits  matching  the
+       \d+  item,  and  then  with  4,  and  so on, before ultimately failing.
+       "Atomic grouping" (a term taken from Jeffrey  Friedl's  book)  provides
+       the  means for specifying that once a subpattern has matched, it is not
        to be re-evaluated in this way.
 
-       If  we  use atomic grouping for the previous example, the matcher gives
-       up immediately on failing to match "foo" the first time.  The  notation
+       If we use atomic grouping for the previous example, the  matcher  gives
+       up  immediately  on failing to match "foo" the first time. The notation
        is a kind of special parenthesis, starting with (?> as in this example:
 
          (?>\d+)foo
 
-       This  kind  of  parenthesis "locks up" the  part of the pattern it con-
-       tains once it has matched, and a failure further into  the  pattern  is
-       prevented  from  backtracking into it. Backtracking past it to previous
+       This kind of parenthesis "locks up" the  part of the  pattern  it  con-
+       tains  once  it  has matched, and a failure further into the pattern is
+       prevented from backtracking into it. Backtracking past it  to  previous
        items, however, works as normal.
 
-       An alternative description is that a subpattern of  this  type  matches
-       the  string  of  characters  that an identical standalone pattern would
+       An  alternative  description  is that a subpattern of this type matches
+       the string of characters that an  identical  standalone  pattern  would
        match, if anchored at the current point in the subject string.
 
        Atomic grouping subpatterns are not capturing subpatterns. Simple cases
        such as the above example can be thought of as a maximizing repeat that
-       must swallow everything it can. So, while both \d+ and  \d+?  are  pre-
-       pared  to  adjust  the number of digits they match in order to make the
+       must  swallow  everything  it can. So, while both \d+ and \d+? are pre-
+       pared to adjust the number of digits they match in order  to  make  the
        rest of the pattern match, (?>\d+) can only match an entire sequence of
        digits.
 
-       Atomic  groups in general can of course contain arbitrarily complicated
-       subpatterns, and can be nested. However, when  the  subpattern  for  an
+       Atomic groups in general can of course contain arbitrarily  complicated
+       subpatterns,  and  can  be  nested. However, when the subpattern for an
        atomic group is just a single repeated item, as in the example above, a
-       simpler notation, called a "possessive quantifier" can  be  used.  This
-       consists  of  an  additional  + character following a quantifier. Using
+       simpler  notation,  called  a "possessive quantifier" can be used. This
+       consists of an additional + character  following  a  quantifier.  Using
        this notation, the previous example can be rewritten as
 
          \d++foo
@@ -4225,45 +4352,45 @@ ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS
 
          (abc|xyz){2,3}+
 
-       Possessive   quantifiers   are   always  greedy;  the  setting  of  the
+       Possessive  quantifiers  are  always  greedy;  the   setting   of   the
        PCRE_UNGREEDY option is ignored. They are a convenient notation for the
-       simpler  forms  of atomic group. However, there is no difference in the
-       meaning of a possessive quantifier and  the  equivalent  atomic  group,
-       though  there  may  be a performance difference; possessive quantifiers
+       simpler forms of atomic group. However, there is no difference  in  the
+       meaning  of  a  possessive  quantifier and the equivalent atomic group,
+       though there may be a performance  difference;  possessive  quantifiers
        should be slightly faster.
 
-       The possessive quantifier syntax is an extension to the Perl  5.8  syn-
-       tax.   Jeffrey  Friedl  originated the idea (and the name) in the first
+       The  possessive  quantifier syntax is an extension to the Perl 5.8 syn-
+       tax.  Jeffrey Friedl originated the idea (and the name)  in  the  first
        edition of his book. Mike McCloskey liked it, so implemented it when he
-       built  Sun's Java package, and PCRE copied it from there. It ultimately
+       built Sun's Java package, and PCRE copied it from there. It  ultimately
        found its way into Perl at release 5.10.
 
        PCRE has an optimization that automatically "possessifies" certain sim-
-       ple  pattern  constructs.  For  example, the sequence A+B is treated as
-       A++B because there is no point in backtracking into a sequence  of  A's
+       ple pattern constructs. For example, the sequence  A+B  is  treated  as
+       A++B  because  there is no point in backtracking into a sequence of A's
        when B must follow.
 
-       When  a  pattern  contains an unlimited repeat inside a subpattern that
-       can itself be repeated an unlimited number of  times,  the  use  of  an
-       atomic  group  is  the  only way to avoid some failing matches taking a
+       When a pattern contains an unlimited repeat inside  a  subpattern  that
+       can  itself  be  repeated  an  unlimited number of times, the use of an
+       atomic group is the only way to avoid some  failing  matches  taking  a
        very long time indeed. The pattern
 
          (\D+|<\d+>)*[!?]
 
-       matches an unlimited number of substrings that either consist  of  non-
-       digits,  or  digits  enclosed in <>, followed by either ! or ?. When it
+       matches  an  unlimited number of substrings that either consist of non-
+       digits, or digits enclosed in <>, followed by either ! or  ?.  When  it
        matches, it runs quickly. However, if it is applied to
 
          aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
-       it takes a long time before reporting  failure.  This  is  because  the
-       string  can be divided between the internal \D+ repeat and the external
-       * repeat in a large number of ways, and all  have  to  be  tried.  (The
-       example  uses  [!?]  rather than a single character at the end, because
-       both PCRE and Perl have an optimization that allows  for  fast  failure
-       when  a single character is used. They remember the last single charac-
-       ter that is required for a match, and fail early if it is  not  present
-       in  the  string.)  If  the pattern is changed so that it uses an atomic
+       it  takes  a  long  time  before reporting failure. This is because the
+       string can be divided between the internal \D+ repeat and the  external
+       *  repeat  in  a  large  number of ways, and all have to be tried. (The
+       example uses [!?] rather than a single character at  the  end,  because
+       both  PCRE  and  Perl have an optimization that allows for fast failure
+       when a single character is used. They remember the last single  charac-
+       ter  that  is required for a match, and fail early if it is not present
+       in the string.) If the pattern is changed so that  it  uses  an  atomic
        group, like this:
 
          ((?>\D+)|<\d+>)*[!?]
@@ -4275,37 +4402,37 @@ BACK REFERENCES
 
        Outside a character class, a backslash followed by a digit greater than
        0 (and possibly further digits) is a back reference to a capturing sub-
-       pattern earlier (that is, to its left) in the pattern,  provided  there
+       pattern  earlier  (that is, to its left) in the pattern, provided there
        have been that many previous capturing left parentheses.
 
        However, if the decimal number following the backslash is less than 10,
-       it is always taken as a back reference, and causes  an  error  only  if
-       there  are  not that many capturing left parentheses in the entire pat-
-       tern. In other words, the parentheses that are referenced need  not  be
-       to  the left of the reference for numbers less than 10. A "forward back
-       reference" of this type can make sense when a  repetition  is  involved
-       and  the  subpattern to the right has participated in an earlier itera-
+       it  is  always  taken  as a back reference, and causes an error only if
+       there are not that many capturing left parentheses in the  entire  pat-
+       tern.  In  other words, the parentheses that are referenced need not be
+       to the left of the reference for numbers less than 10. A "forward  back
+       reference"  of  this  type can make sense when a repetition is involved
+       and the subpattern to the right has participated in an  earlier  itera-
        tion.
 
-       It is not possible to have a numerical "forward back  reference"  to  a
-       subpattern  whose  number  is  10  or  more using this syntax because a
-       sequence such as \50 is interpreted as a character  defined  in  octal.
+       It  is  not  possible to have a numerical "forward back reference" to a
+       subpattern whose number is 10 or  more  using  this  syntax  because  a
+       sequence  such  as  \50 is interpreted as a character defined in octal.
        See the subsection entitled "Non-printing characters" above for further
-       details of the handling of digits following a backslash.  There  is  no
-       such  problem  when named parentheses are used. A back reference to any
+       details  of  the  handling of digits following a backslash. There is no
+       such problem when named parentheses are used. A back reference  to  any
        subpattern is possible using named parentheses (see below).
 
-       Another way of avoiding the ambiguity inherent in  the  use  of  digits
+       Another  way  of  avoiding  the ambiguity inherent in the use of digits
        following a backslash is to use the \g escape sequence, which is a fea-
-       ture introduced in Perl 5.10.  This  escape  must  be  followed  by  an
-       unsigned  number  or  a negative number, optionally enclosed in braces.
+       ture  introduced  in  Perl  5.10.  This  escape  must be followed by an
+       unsigned number or a negative number, optionally  enclosed  in  braces.
        These examples are all identical:
 
          (ring), \1
          (ring), \g1
          (ring), \g{1}
 
-       An unsigned number specifies an absolute reference without the  ambigu-
+       An  unsigned number specifies an absolute reference without the ambigu-
        ity that is present in the older syntax. It is also useful when literal
        digits follow the reference. A negative number is a relative reference.
        Consider this example:
@@ -4313,33 +4440,33 @@ BACK REFERENCES
          (abc(def)ghi)\g{-1}
 
        The sequence \g{-1} is a reference to the most recently started captur-
-       ing subpattern before \g, that is, is it equivalent to  \2.  Similarly,
+       ing  subpattern  before \g, that is, is it equivalent to \2. Similarly,
        \g{-2} would be equivalent to \1. The use of relative references can be
-       helpful in long patterns, and also in  patterns  that  are  created  by
+       helpful  in  long  patterns,  and  also in patterns that are created by
        joining together fragments that contain references within themselves.
 
-       A  back  reference matches whatever actually matched the capturing sub-
-       pattern in the current subject string, rather  than  anything  matching
+       A back reference matches whatever actually matched the  capturing  sub-
+       pattern  in  the  current subject string, rather than anything matching
        the subpattern itself (see "Subpatterns as subroutines" below for a way
        of doing that). So the pattern
 
          (sens|respons)e and \1ibility
 
-       matches "sense and sensibility" and "response and responsibility",  but
-       not  "sense and responsibility". If caseful matching is in force at the
-       time of the back reference, the case of letters is relevant. For  exam-
+       matches  "sense and sensibility" and "response and responsibility", but
+       not "sense and responsibility". If caseful matching is in force at  the
+       time  of the back reference, the case of letters is relevant. For exam-
        ple,
 
          ((?i)rah)\s+\1
 
-       matches  "rah  rah"  and  "RAH RAH", but not "RAH rah", even though the
+       matches "rah rah" and "RAH RAH", but not "RAH  rah",  even  though  the
        original capturing subpattern is matched caselessly.
 
-       There are several different ways of writing back  references  to  named
-       subpatterns.  The  .NET syntax \k{name} and the Perl syntax \k<name> or
-       \k'name' are supported, as is the Python syntax (?P=name). Perl  5.10's
+       There  are  several  different ways of writing back references to named
+       subpatterns. The .NET syntax \k{name} and the Perl syntax  \k<name>  or
+       \k'name'  are supported, as is the Python syntax (?P=name). Perl 5.10's
        unified back reference syntax, in which \g can be used for both numeric
-       and named references, is also supported. We  could  rewrite  the  above
+       and  named  references,  is  also supported. We could rewrite the above
        example in any of the following ways:
 
          (?<p1>(?i)rah)\s+\k<p1>
@@ -4347,22 +4474,25 @@ BACK REFERENCES
          (?P<p1>(?i)rah)\s+(?P=p1)
          (?<p1>(?i)rah)\s+\g{p1}
 
-       A  subpattern  that  is  referenced  by  name may appear in the pattern
+       A subpattern that is referenced by  name  may  appear  in  the  pattern
        before or after the reference.
 
-       There may be more than one back reference to the same subpattern. If  a
-       subpattern  has  not actually been used in a particular match, any back
-       references to it always fail. For example, the pattern
+       There  may be more than one back reference to the same subpattern. If a
+       subpattern has not actually been used in a particular match,  any  back
+       references to it always fail by default. For example, the pattern
 
          (a|(bc))\2
 
-       always fails if it starts to match "a" rather than "bc". Because  there
-       may  be  many  capturing parentheses in a pattern, all digits following
-       the backslash are taken as part of a potential back  reference  number.
-       If the pattern continues with a digit character, some delimiter must be
-       used to terminate the back reference. If the  PCRE_EXTENDED  option  is
-       set,  this  can  be  whitespace.  Otherwise an empty comment (see "Com-
-       ments" below) can be used.
+       always  fails  if  it starts to match "a" rather than "bc". However, if
+       the PCRE_JAVASCRIPT_COMPAT option is set at compile time, a back refer-
+       ence to an unset value matches an empty string.
+
+       Because  there may be many capturing parentheses in a pattern, all dig-
+       its following a backslash are taken as part of a potential back  refer-
+       ence  number.   If  the  pattern continues with a digit character, some
+       delimiter must  be  used  to  terminate  the  back  reference.  If  the
+       PCRE_EXTENDED option is set, this can be whitespace. Otherwise, the \g{
+       syntax or an empty comment (see "Comments" below) can be used.
 
        A back reference that occurs inside the parentheses to which it  refers
        fails  when  the subpattern is first used, so, for example, (a\1) never
@@ -4425,19 +4555,20 @@ ASSERTIONS
        If you want to force a matching failure at some point in a pattern, the
        most convenient way to do it is  with  (?!)  because  an  empty  string
        always  matches, so an assertion that requires there not to be an empty
-       string must always fail.
+       string must always fail.   The  Perl  5.10  backtracking  control  verb
+       (*FAIL) or (*F) is essentially a synonym for (?!).
 
    Lookbehind assertions
 
-       Lookbehind assertions start with (?<= for positive assertions and  (?<!
+       Lookbehind  assertions start with (?<= for positive assertions and (?<!
        for negative assertions. For example,
 
          (?<!foo)bar
 
-       does  find  an  occurrence  of "bar" that is not preceded by "foo". The
-       contents of a lookbehind assertion are restricted  such  that  all  the
+       does find an occurrence of "bar" that is not  preceded  by  "foo".  The
+       contents  of  a  lookbehind  assertion are restricted such that all the
        strings it matches must have a fixed length. However, if there are sev-
-       eral top-level alternatives, they do not all  have  to  have  the  same
+       eral  top-level  alternatives,  they  do  not all have to have the same
        fixed length. Thus
 
          (?<=bullock|donkey)
@@ -4446,23 +4577,22 @@ ASSERTIONS
 
          (?<!dogs?|cats?)
 
-       causes  an  error at compile time. Branches that match different length
-       strings are permitted only at the top level of a lookbehind  assertion.
-       This  is  an  extension  compared  with  Perl (at least for 5.8), which
-       requires all branches to match the same length of string. An  assertion
-       such as
+       causes an error at compile time. Branches that match  different  length
+       strings  are permitted only at the top level of a lookbehind assertion.
+       This is an extension compared with Perl (5.8 and 5.10), which  requires
+       all branches to match the same length of string. An assertion such as
 
          (?<=ab(c|de))
 
        is  not  permitted,  because  its single top-level branch can match two
-       different lengths, but it is acceptable if rewritten to  use  two  top-
-       level branches:
+       different lengths, but it is acceptable to PCRE if rewritten to use two
+       top-level branches:
 
          (?<=abc|abde)
 
        In some cases, the Perl 5.10 escape sequence \K (see above) can be used
-       instead of a lookbehind assertion; this is not restricted to  a  fixed-
-       length.
+       instead of  a  lookbehind  assertion  to  get  round  the  fixed-length
+       restriction.
 
        The  implementation  of lookbehind assertions is, for each alternative,
        to temporarily move the current position back by the fixed  length  and
@@ -4474,9 +4604,13 @@ ASSERTIONS
        ble to calculate the length of the lookbehind. The \X and  \R  escapes,
        which can match different numbers of bytes, are also not permitted.
 
+       "Subroutine"  calls  (see below) such as (?2) or (?&X) are permitted in
+       lookbehinds, as long as the subpattern matches a  fixed-length  string.
+       Recursion, however, is not supported.
+
        Possessive  quantifiers  can  be  used  in  conjunction with lookbehind
-       assertions to specify efficient matching at  the  end  of  the  subject
-       string. Consider a simple pattern such as
+       assertions to specify efficient matching of fixed-length strings at the
+       end of subject strings. Consider a simple pattern such as
 
          abcd$
 
@@ -4539,9 +4673,9 @@ CONDITIONAL SUBPATTERNS
 
        It  is possible to cause the matching process to obey a subpattern con-
        ditionally or to choose between two alternative subpatterns,  depending
-       on  the result of an assertion, or whether a previous capturing subpat-
-       tern matched or not. The two possible forms of  conditional  subpattern
-       are
+       on  the result of an assertion, or whether a specific capturing subpat-
+       tern has already been matched. The two possible  forms  of  conditional
+       subpattern are:
 
          (?(condition)yes-pattern)
          (?(condition)yes-pattern|no-pattern)
@@ -4556,138 +4690,144 @@ CONDITIONAL SUBPATTERNS
    Checking for a used subpattern by number
 
        If the text between the parentheses consists of a sequence  of  digits,
-       the  condition  is  true if the capturing subpattern of that number has
-       previously matched. An alternative notation is to  precede  the  digits
-       with a plus or minus sign. In this case, the subpattern number is rela-
-       tive rather than absolute.  The most recently opened parentheses can be
-       referenced  by  (?(-1),  the  next most recent by (?(-2), and so on. In
-       looping constructs it can also make sense to refer to subsequent groups
-       with constructs such as (?(+2).
-
-       Consider  the  following  pattern, which contains non-significant white
+       the condition is true if a capturing subpattern of that number has pre-
+       viously matched. If there is more than one  capturing  subpattern  with
+       the  same  number  (see  the earlier section about duplicate subpattern
+       numbers), the condition is true if any of them have been set. An alter-
+       native  notation is to precede the digits with a plus or minus sign. In
+       this case, the subpattern number is relative rather than absolute.  The
+       most  recently opened parentheses can be referenced by (?(-1), the next
+       most recent by (?(-2), and so on. In looping  constructs  it  can  also
+       make  sense  to  refer  to  subsequent  groups  with constructs such as
+       (?(+2).
+
+       Consider the following pattern, which  contains  non-significant  white
        space to make it more readable (assume the PCRE_EXTENDED option) and to
        divide it into three parts for ease of discussion:
 
          ( \( )?    [^()]+    (?(1) \) )
 
-       The  first  part  matches  an optional opening parenthesis, and if that
+       The first part matches an optional opening  parenthesis,  and  if  that
        character is present, sets it as the first captured substring. The sec-
-       ond  part  matches one or more characters that are not parentheses. The
+       ond part matches one or more characters that are not  parentheses.  The
        third part is a conditional subpattern that tests whether the first set
        of parentheses matched or not. If they did, that is, if subject started
        with an opening parenthesis, the condition is true, and so the yes-pat-
-       tern  is  executed  and  a  closing parenthesis is required. Otherwise,
-       since no-pattern is not present, the  subpattern  matches  nothing.  In
-       other  words,  this  pattern  matches  a  sequence  of non-parentheses,
+       tern is executed and a  closing  parenthesis  is  required.  Otherwise,
+       since  no-pattern  is  not  present, the subpattern matches nothing. In
+       other words,  this  pattern  matches  a  sequence  of  non-parentheses,
        optionally enclosed in parentheses.
 
-       If you were embedding this pattern in a larger one,  you  could  use  a
+       If  you  were  embedding  this pattern in a larger one, you could use a
        relative reference:
 
          ...other stuff... ( \( )?    [^()]+    (?(-1) \) ) ...
 
-       This  makes  the  fragment independent of the parentheses in the larger
+       This makes the fragment independent of the parentheses  in  the  larger
        pattern.
 
    Checking for a used subpattern by name
 
-       Perl uses the syntax (?(<name>)...) or (?('name')...)  to  test  for  a
-       used  subpattern  by  name.  For compatibility with earlier versions of
-       PCRE, which had this facility before Perl, the syntax  (?(name)...)  is
-       also  recognized. However, there is a possible ambiguity with this syn-
-       tax, because subpattern names may  consist  entirely  of  digits.  PCRE
-       looks  first for a named subpattern; if it cannot find one and the name
-       consists entirely of digits, PCRE looks for a subpattern of  that  num-
-       ber,  which must be greater than zero. Using subpattern names that con-
+       Perl  uses  the  syntax  (?(<name>)...) or (?('name')...) to test for a
+       used subpattern by name. For compatibility  with  earlier  versions  of
+       PCRE,  which  had this facility before Perl, the syntax (?(name)...) is
+       also recognized. However, there is a possible ambiguity with this  syn-
+       tax,  because  subpattern  names  may  consist entirely of digits. PCRE
+       looks first for a named subpattern; if it cannot find one and the  name
+       consists  entirely  of digits, PCRE looks for a subpattern of that num-
+       ber, which must be greater than zero. Using subpattern names that  con-
        sist entirely of digits is not recommended.
 
        Rewriting the above example to use a named subpattern gives this:
 
          (?<OPEN> \( )?    [^()]+    (?(<OPEN>) \) )
 
+       If  the  name used in a condition of this kind is a duplicate, the test
+       is applied to all subpatterns of the same name, and is true if any  one
+       of them has matched.
 
    Checking for pattern recursion
 
        If the condition is the string (R), and there is no subpattern with the
-       name  R, the condition is true if a recursive call to the whole pattern
+       name R, the condition is true if a recursive call to the whole  pattern
        or any subpattern has been made. If digits or a name preceded by amper-
        sand follow the letter R, for example:
 
          (?(R3)...) or (?(R&name)...)
 
-       the  condition is true if the most recent recursion is into the subpat-
-       tern whose number or name is given. This condition does not  check  the
-       entire recursion stack.
+       the condition is true if the most recent recursion is into a subpattern
+       whose number or name is given. This condition does not check the entire
+       recursion stack. If the name used in a condition  of  this  kind  is  a
+       duplicate, the test is applied to all subpatterns of the same name, and
+       is true if any one of them is the most recent recursion.
 
-       At  "top  level", all these recursion test conditions are false. Recur-
-       sive patterns are described below.
+       At "top level", all these recursion test  conditions  are  false.   The
+       syntax for recursive patterns is described below.
 
    Defining subpatterns for use by reference only
 
-       If the condition is the string (DEFINE), and  there  is  no  subpattern
-       with  the  name  DEFINE,  the  condition is always false. In this case,
-       there may be only one alternative  in  the  subpattern.  It  is  always
-       skipped  if  control  reaches  this  point  in the pattern; the idea of
-       DEFINE is that it can be used to define "subroutines" that can be  ref-
-       erenced  from elsewhere. (The use of "subroutines" is described below.)
-       For example, a pattern to match an IPv4 address could be  written  like
+       If  the  condition  is  the string (DEFINE), and there is no subpattern
+       with the name DEFINE, the condition is  always  false.  In  this  case,
+       there  may  be  only  one  alternative  in the subpattern. It is always
+       skipped if control reaches this point  in  the  pattern;  the  idea  of
+       DEFINE  is that it can be used to define "subroutines" that can be ref-
+       erenced from elsewhere. (The use of "subroutines" is described  below.)
+       For  example,  a pattern to match an IPv4 address could be written like
        this (ignore whitespace and line breaks):
 
          (?(DEFINE) (?<byte> 2[0-4]\d | 25[0-5] | 1\d\d | [1-9]?\d) )
          \b (?&byte) (\.(?&byte)){3} \b
 
-       The  first part of the pattern is a DEFINE group inside which a another
-       group named "byte" is defined. This matches an individual component  of
-       an  IPv4  address  (a number less than 256). When matching takes place,
-       this part of the pattern is skipped because DEFINE acts  like  a  false
-       condition.
-
-       The rest of the pattern uses references to the named group to match the
-       four dot-separated components of an IPv4 address, insisting on  a  word
-       boundary at each end.
+       The first part of the pattern is a DEFINE group inside which a  another
+       group  named "byte" is defined. This matches an individual component of
+       an IPv4 address (a number less than 256). When  matching  takes  place,
+       this  part  of  the pattern is skipped because DEFINE acts like a false
+       condition. The rest of the pattern uses references to the  named  group
+       to  match the four dot-separated components of an IPv4 address, insist-
+       ing on a word boundary at each end.
 
    Assertion conditions
 
-       If  the  condition  is  not  in any of the above formats, it must be an
-       assertion.  This may be a positive or negative lookahead or  lookbehind
-       assertion.  Consider  this  pattern,  again  containing non-significant
+       If the condition is not in any of the above  formats,  it  must  be  an
+       assertion.   This may be a positive or negative lookahead or lookbehind
+       assertion. Consider  this  pattern,  again  containing  non-significant
        white space, and with the two alternatives on the second line:
 
          (?(?=[^a-z]*[a-z])
          \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} )
 
-       The condition  is  a  positive  lookahead  assertion  that  matches  an
-       optional  sequence of non-letters followed by a letter. In other words,
-       it tests for the presence of at least one letter in the subject.  If  a
-       letter  is found, the subject is matched against the first alternative;
-       otherwise it is  matched  against  the  second.  This  pattern  matches
-       strings  in  one  of the two forms dd-aaa-dd or dd-dd-dd, where aaa are
+       The  condition  is  a  positive  lookahead  assertion  that  matches an
+       optional sequence of non-letters followed by a letter. In other  words,
+       it  tests  for the presence of at least one letter in the subject. If a
+       letter is found, the subject is matched against the first  alternative;
+       otherwise  it  is  matched  against  the  second.  This pattern matches
+       strings in one of the two forms dd-aaa-dd or dd-dd-dd,  where  aaa  are
        letters and dd are digits.
 
 
 COMMENTS
 
-       The sequence (?# marks the start of a comment that continues up to  the
-       next  closing  parenthesis.  Nested  parentheses are not permitted. The
-       characters that make up a comment play no part in the pattern  matching
+       The  sequence (?# marks the start of a comment that continues up to the
+       next closing parenthesis. Nested parentheses  are  not  permitted.  The
+       characters  that make up a comment play no part in the pattern matching
        at all.
 
-       If  the PCRE_EXTENDED option is set, an unescaped # character outside a
-       character class introduces a  comment  that  continues  to  immediately
+       If the PCRE_EXTENDED option is set, an unescaped # character outside  a
+       character  class  introduces  a  comment  that continues to immediately
        after the next newline in the pattern.
 
 
 RECURSIVE PATTERNS
 
-       Consider  the problem of matching a string in parentheses, allowing for
-       unlimited nested parentheses. Without the use of  recursion,  the  best
-       that  can  be  done  is  to use a pattern that matches up to some fixed
-       depth of nesting. It is not possible to  handle  an  arbitrary  nesting
+       Consider the problem of matching a string in parentheses, allowing  for
+       unlimited  nested  parentheses.  Without the use of recursion, the best
+       that can be done is to use a pattern that  matches  up  to  some  fixed
+       depth  of  nesting.  It  is not possible to handle an arbitrary nesting
        depth.
 
        For some time, Perl has provided a facility that allows regular expres-
-       sions to recurse (amongst other things). It does this by  interpolating
-       Perl  code in the expression at run time, and the code can refer to the
+       sions  to recurse (amongst other things). It does this by interpolating
+       Perl code in the expression at run time, and the code can refer to  the
        expression itself. A Perl pattern using code interpolation to solve the
        parentheses problem can be created like this:
 
@@ -4697,44 +4837,41 @@ RECURSIVE PATTERNS
        refers recursively to the pattern in which it appears.
 
        Obviously, PCRE cannot support the interpolation of Perl code. Instead,
-       it  supports  special  syntax  for recursion of the entire pattern, and
-       also for individual subpattern recursion.  After  its  introduction  in
-       PCRE  and  Python,  this  kind of recursion was introduced into Perl at
-       release 5.10.
+       it supports special syntax for recursion of  the  entire  pattern,  and
+       also  for  individual  subpattern  recursion. After its introduction in
+       PCRE and Python, this kind of  recursion  was  subsequently  introduced
+       into Perl at release 5.10.
 
-       A special item that consists of (? followed by a  number  greater  than
+       A  special  item  that consists of (? followed by a number greater than
        zero and a closing parenthesis is a recursive call of the subpattern of
-       the given number, provided that it occurs inside that  subpattern.  (If
-       not,  it  is  a  "subroutine" call, which is described in the next sec-
-       tion.) The special item (?R) or (?0) is a recursive call of the  entire
+       the  given  number, provided that it occurs inside that subpattern. (If
+       not, it is a "subroutine" call, which is described  in  the  next  sec-
+       tion.)  The special item (?R) or (?0) is a recursive call of the entire
        regular expression.
 
-       In  PCRE (like Python, but unlike Perl), a recursive subpattern call is
-       always treated as an atomic group. That is, once it has matched some of
-       the subject string, it is never re-entered, even if it contains untried
-       alternatives and there is a subsequent matching failure.
-
        This PCRE pattern solves the nested  parentheses  problem  (assume  the
        PCRE_EXTENDED option is set so that white space is ignored):
 
-         \( ( (?>[^()]+) | (?R) )* \)
+         \( ( [^()]++ | (?R) )* \)
 
        First  it matches an opening parenthesis. Then it matches any number of
        substrings which can either be a  sequence  of  non-parentheses,  or  a
        recursive  match  of the pattern itself (that is, a correctly parenthe-
-       sized substring).  Finally there is a closing parenthesis.
+       sized substring).  Finally there is a closing parenthesis. Note the use
+       of a possessive quantifier to avoid backtracking into sequences of non-
+       parentheses.
 
        If this were part of a larger pattern, you would not  want  to  recurse
        the entire pattern, so instead you could use this:
 
-         ( \( ( (?>[^()]+) | (?1) )* \) )
+         ( \( ( [^()]++ | (?1) )* \) )
 
        We  have  put the pattern into parentheses, and caused the recursion to
        refer to them instead of the whole pattern.
 
        In a larger pattern,  keeping  track  of  parenthesis  numbers  can  be
-       tricky.  This is made easier by the use of relative references. (A Perl
-       5.10 feature.)  Instead of (?1) in the  pattern  above  you  can  write
+       tricky.  This  is made easier by the use of relative references (a Perl
+       5.10 feature).  Instead of (?1) in the  pattern  above  you  can  write
        (?-2) to refer to the second most recently opened parentheses preceding
        the recursion. In other  words,  a  negative  number  counts  capturing
        parentheses leftwards from the point at which it is encountered.
@@ -4749,46 +4886,40 @@ RECURSIVE PATTERNS
        syntax for this is (?&name); PCRE's earlier syntax  (?P>name)  is  also
        supported. We could rewrite the above example as follows:
 
-         (?<pn> \( ( (?>[^()]+) | (?&pn) )* \) )
+         (?<pn> \( ( [^()]++ | (?&pn) )* \) )
 
        If  there  is more than one subpattern with the same name, the earliest
        one is used.
 
        This particular example pattern that we have been looking  at  contains
-       nested  unlimited repeats, and so the use of atomic grouping for match-
-       ing strings of non-parentheses is important when applying  the  pattern
-       to strings that do not match. For example, when this pattern is applied
-       to
+       nested unlimited repeats, and so the use of a possessive quantifier for
+       matching strings of non-parentheses is important when applying the pat-
+       tern  to  strings  that do not match. For example, when this pattern is
+       applied to
 
          (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
 
-       it yields "no match" quickly. However, if atomic grouping is not  used,
-       the  match  runs  for a very long time indeed because there are so many
-       different ways the + and * repeats can carve up the  subject,  and  all
-       have to be tested before failure can be reported.
+       it yields "no match" quickly. However, if a  possessive  quantifier  is
+       not  used, the match runs for a very long time indeed because there are
+       so many different ways the + and * repeats can carve  up  the  subject,
+       and all have to be tested before failure can be reported.
 
-       At the end of a match, the values set for any capturing subpatterns are
-       those from the outermost level of the recursion at which the subpattern
-       value  is  set.   If  you want to obtain intermediate values, a callout
-       function can be used (see below and the pcrecallout documentation).  If
-       the pattern above is matched against
+       At  the  end  of a match, the values of capturing parentheses are those
+       from the outermost level. If you want to obtain intermediate values,  a
+       callout  function can be used (see below and the pcrecallout documenta-
+       tion). If the pattern above is matched against
 
          (ab(cd)ef)
 
-       the  value  for  the  capturing  parentheses is "ef", which is the last
-       value taken on at the top level. If additional parentheses  are  added,
-       giving
-
-         \( ( ( (?>[^()]+) | (?R) )* ) \)
-            ^                        ^
-            ^                        ^
+       the value for the inner capturing parentheses  (numbered  2)  is  "ef",
+       which  is the last value taken on at the top level. If a capturing sub-
+       pattern is not matched at the top level, its final value is unset, even
+       if it is (temporarily) set at a deeper level.
 
-       the  string  they  capture is "ab(cd)ef", the contents of the top level
-       parentheses. If there are more than 15 capturing parentheses in a  pat-
-       tern, PCRE has to obtain extra memory to store data during a recursion,
-       which it does by using pcre_malloc, freeing  it  via  pcre_free  after-
-       wards.  If  no  memory  can  be  obtained,  the  match  fails  with the
-       PCRE_ERROR_NOMEMORY error.
+       If  there are more than 15 capturing parentheses in a pattern, PCRE has
+       to obtain extra memory to store data during a recursion, which it  does
+       by using pcre_malloc, freeing it via pcre_free afterwards. If no memory
+       can be obtained, the match fails with the PCRE_ERROR_NOMEMORY error.
 
        Do not confuse the (?R) item with the condition (R),  which  tests  for
        recursion.   Consider  this pattern, which matches text in angle brack-
@@ -4802,6 +4933,80 @@ RECURSIVE PATTERNS
        two  different  alternatives for the recursive and non-recursive cases.
        The (?R) item is the actual recursive call.
 
+   Recursion difference from Perl
+
+       In PCRE (like Python, but unlike Perl), a recursive subpattern call  is
+       always treated as an atomic group. That is, once it has matched some of
+       the subject string, it is never re-entered, even if it contains untried
+       alternatives  and  there  is a subsequent matching failure. This can be
+       illustrated by the following pattern, which purports to match a  palin-
+       dromic  string  that contains an odd number of characters (for example,
+       "a", "aba", "abcba", "abcdcba"):
+
+         ^(.|(.)(?1)\2)$
+
+       The idea is that it either matches a single character, or two identical
+       characters  surrounding  a sub-palindrome. In Perl, this pattern works;
+       in PCRE it does not if the pattern is  longer  than  three  characters.
+       Consider the subject string "abcba":
+
+       At  the  top level, the first character is matched, but as it is not at
+       the end of the string, the first alternative fails; the second alterna-
+       tive is taken and the recursion kicks in. The recursive call to subpat-
+       tern 1 successfully matches the next character ("b").  (Note  that  the
+       beginning and end of line tests are not part of the recursion).
+
+       Back  at  the top level, the next character ("c") is compared with what
+       subpattern 2 matched, which was "a". This fails. Because the  recursion
+       is  treated  as  an atomic group, there are now no backtracking points,
+       and so the entire match fails. (Perl is able, at  this  point,  to  re-
+       enter  the  recursion  and try the second alternative.) However, if the
+       pattern is written with the alternatives in the other order, things are
+       different:
+
+         ^((.)(?1)\2|.)$
+
+       This  time,  the recursing alternative is tried first, and continues to
+       recurse until it runs out of characters, at which point  the  recursion
+       fails.  But  this  time  we  do  have another alternative to try at the
+       higher level. That is the big difference:  in  the  previous  case  the
+       remaining alternative is at a deeper recursion level, which PCRE cannot
+       use.
+
+       To change the pattern so that matches all palindromic strings, not just
+       those  with  an  odd number of characters, it is tempting to change the
+       pattern to this:
+
+         ^((.)(?1)\2|.?)$
+
+       Again, this works in Perl, but not in PCRE, and for  the  same  reason.
+       When  a  deeper  recursion has matched a single character, it cannot be
+       entered again in order to match an empty string.  The  solution  is  to
+       separate  the two cases, and write out the odd and even cases as alter-
+       natives at the higher level:
+
+         ^(?:((.)(?1)\2|)|((.)(?3)\4|.))
+
+       If you want to match typical palindromic phrases, the  pattern  has  to
+       ignore all non-word characters, which can be done like this:
+
+         ^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$
+
+       If run with the PCRE_CASELESS option, this pattern matches phrases such
+       as "A man, a plan, a canal: Panama!" and it works well in both PCRE and
+       Perl.  Note the use of the possessive quantifier *+ to avoid backtrack-
+       ing into sequences of non-word characters. Without this, PCRE  takes  a
+       great  deal  longer  (ten  times or more) to match typical phrases, and
+       Perl takes so long that you think it has gone into a loop.
+
+       WARNING: The palindrome-matching patterns above work only if  the  sub-
+       ject  string  does not start with a palindrome that is shorter than the
+       entire string.  For example, although "abcba" is correctly matched,  if
+       the  subject  is "ababa", PCRE finds the palindrome "aba" at the start,
+       then fails at top level because the end of the string does not  follow.
+       Once  again, it cannot jump back into the recursion to try other alter-
+       natives, so the entire match fails.
+
 
 SUBPATTERNS AS SUBROUTINES
 
@@ -4828,10 +5033,12 @@ SUBPATTERNS AS SUBROUTINES
        two strings. Another example is  given  in  the  discussion  of  DEFINE
        above.
 
-       Like recursive subpatterns, a "subroutine" call is always treated as an
+       Like  recursive  subpatterns, a subroutine call is always treated as an
        atomic group. That is, once it has matched some of the subject  string,
        it  is  never  re-entered, even if it contains untried alternatives and
-       there is a subsequent matching failure.
+       there is a subsequent matching failure. Any capturing parentheses  that
+       are  set  during  the  subroutine  call revert to their previous values
+       afterwards.
 
        When a subpattern is used as a subroutine, processing options  such  as
        case-independence are fixed when the subpattern is defined. They cannot
@@ -4914,6 +5121,12 @@ BACKTRACKING CONTROL
        (*FAIL), which behaves like a failing negative assertion, they cause an
        error if encountered by pcre_dfa_exec().
 
+       If any of these verbs are used in an assertion or subroutine subpattern
+       (including recursive subpatterns), their effect  is  confined  to  that
+       subpattern;  it  does  not extend to the surrounding pattern. Note that
+       such subpatterns are processed as anchored at the point where they  are
+       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
@@ -4928,14 +5141,14 @@ BACKTRACKING CONTROL
 
        This  verb causes the match to end successfully, skipping the remainder
        of the pattern. When inside a recursion, only the innermost pattern  is
-       ended  immediately.  PCRE  differs  from  Perl  in  what happens if the
-       (*ACCEPT) is inside capturing parentheses. In Perl, the data so far  is
-       captured: in PCRE no data is captured. For example:
+       ended  immediately.  If  (*ACCEPT) is inside capturing parentheses, the
+       data so far is captured. (This feature was added  to  PCRE  at  release
+       8.00.) For example:
 
-         A(A|B(*ACCEPT)|C)D
+         A((?:A|B(*ACCEPT)|C)D)
 
-       This  matches  "AB", "AAD", or "ACD", but when it matches "AB", no data
-       is captured.
+       This  matches  "AB", "AAD", or "ACD"; when it matches "AB", "B" is cap-
+       tured by the outer parentheses.
 
          (*FAIL) or (*F)
 
@@ -4962,9 +5175,9 @@ BACKTRACKING CONTROL
 
        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 start 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:
+       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
 
@@ -4996,7 +5209,7 @@ BACKTRACKING CONTROL
        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 in this example; although it would
+       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".
@@ -5019,7 +5232,7 @@ BACKTRACKING CONTROL
 
 SEE ALSO
 
-       pcreapi(3), pcrecallout(3), pcrematching(3), pcre(3).
+       pcreapi(3), pcrecallout(3), pcrematching(3), pcresyntax(3), pcre(3).
 
 
 AUTHOR
@@ -5031,7 +5244,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 11 April 2009
+       Last updated: 18 October 2009
        Copyright (c) 1997-2009 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -5412,77 +5625,182 @@ PARTIAL MATCHING IN PCRE
 
        If the application sees the user's keystrokes one by one, and can check
        that what has been typed so far is potentially valid,  it  is  able  to
-       raise  an  error as soon as a mistake is made, possibly beeping and not
-       reflecting the character that has been typed. This  immediate  feedback
-       is  likely  to  be a better user interface than a check that is delayed
-       until the entire string has been entered.
-
-       PCRE supports the concept of partial matching by means of the PCRE_PAR-
-       TIAL   option,   which   can   be   set  when  calling  pcre_exec()  or
-       pcre_dfa_exec(). When this flag is set for pcre_exec(), the return code
-       PCRE_ERROR_NOMATCH  is converted into PCRE_ERROR_PARTIAL if at any time
-       during the matching process the last part of the subject string matched
-       part  of  the  pattern. Unfortunately, for non-anchored matching, it is
-       not possible to obtain the position of the start of the partial  match.
-       No captured data is set when PCRE_ERROR_PARTIAL is returned.
+       raise  an  error  as  soon  as  a  mistake  is made, by beeping and not
+       reflecting the character that has been typed, for example. This immedi-
+       ate  feedback is likely to be a better user interface than a check that
+       is delayed until the entire string has been entered.  Partial  matching
+       can  also  sometimes be useful when the subject string is very long and
+       is not all available at once.
+
+       PCRE supports partial matching by means of  the  PCRE_PARTIAL_SOFT  and
+       PCRE_PARTIAL_HARD options, which can be set when calling pcre_exec() or
+       pcre_dfa_exec(). For backwards compatibility, PCRE_PARTIAL is a synonym
+       for PCRE_PARTIAL_SOFT. The essential difference between the two options
+       is whether or not a partial match is preferred to an  alternative  com-
+       plete  match,  though the details differ between the two matching func-
+       tions. If both options are set, PCRE_PARTIAL_HARD takes precedence.
+
+       Setting a partial matching option disables two of PCRE's optimizations.
+       PCRE  remembers the last literal byte in a pattern, and abandons match-
+       ing immediately if such a byte is not present in  the  subject  string.
+       This  optimization cannot be used for a subject string that might match
+       only partially. If the pattern was  studied,  PCRE  knows  the  minimum
+       length  of  a  matching string, and does not bother to run the matching
+       function on shorter strings. This optimization  is  also  disabled  for
+       partial matching.
+
+
+PARTIAL MATCHING USING pcre_exec()
+
+       A partial match occurs during a call to pcre_exec() whenever the end of
+       the subject string is reached successfully, but  matching  cannot  con-
+       tinue because more characters are needed. However, at least one charac-
+       ter must have been matched. (In other words, a partial match can  never
+       be an empty string.)
+
+       If  PCRE_PARTIAL_SOFT  is  set,  the  partial  match is remembered, but
+       matching continues as normal, and other alternatives in the pattern are
+       tried.   If  no  complete  match  can  be  found,  pcre_exec()  returns
+       PCRE_ERROR_PARTIAL instead of PCRE_ERROR_NOMATCH. If there are at least
+       two slots in the offsets vector, the first of them is set to the offset
+       of the earliest character that was inspected when the partial match was
+       found.  For  convenience,  the  second  offset points to the end of the
+       string so that a substring can easily be identified.
+
+       For the majority of patterns, the first offset identifies the start  of
+       the  partially matched string. However, for patterns that contain look-
+       behind assertions, or \K, or begin with \b or  \B,  earlier  characters
+       have been inspected while carrying out the match. For example:
+
+         /(?<=abc)123/
+
+       This pattern matches "123", but only if it is preceded by "abc". If the
+       subject string is "xyzabc12", the offsets after a partial match are for
+       the  substring  "abc12",  because  all  these  characters are needed if
+       another match is tried with extra characters added.
+
+       If there is more than one partial match, the first one that  was  found
+       provides the data that is returned. Consider this pattern:
+
+         /123\w+X|dogY/
+
+       If  this is matched against the subject string "abc123dog", both alter-
+       natives fail to match, but the end of the  subject  is  reached  during
+       matching,    so    PCRE_ERROR_PARTIAL    is    returned    instead   of
+       PCRE_ERROR_NOMATCH. The  offsets  are  set  to  3  and  9,  identifying
+       "123dog"  as  the first partial match that was found. (In this example,
+       there are two partial matches,  because  "dog"  on  its  own  partially
+       matches the second alternative.)
+
+       If PCRE_PARTIAL_HARD is set for pcre_exec(), it returns PCRE_ERROR_PAR-
+       TIAL as soon as a partial match is found, without continuing to  search
+       for  possible  complete matches. The difference between the two options
+       can be illustrated by a pattern such as:
+
+         /dog(sbody)?/
+
+       This matches either "dog" or "dogsbody", greedily (that is, it  prefers
+       the  longer  string  if  possible). If it is matched against the string
+       "dog" with PCRE_PARTIAL_SOFT, it yields a  complete  match  for  "dog".
+       However, if PCRE_PARTIAL_HARD is set, the result is PCRE_ERROR_PARTIAL.
+       On the other hand, if the pattern is made ungreedy the result  is  dif-
+       ferent:
+
+         /dog(sbody)??/
+
+       In  this case the result is always a complete match because pcre_exec()
+       finds that first, and it never continues  after  finding  a  match.  It
+       might  be easier to follow this explanation by thinking of the two pat-
+       terns like this:
+
+         /dog(sbody)?/    is the same as  /dogsbody|dog/
+         /dog(sbody)??/   is the same as  /dog|dogsbody/
+
+       The second pattern will never  match  "dogsbody"  when  pcre_exec()  is
+       used, because it will always find the shorter match first.
+
+
+PARTIAL MATCHING USING pcre_dfa_exec()
+
+       The  pcre_dfa_exec()  function moves along the subject string character
+       by character, without backtracking, searching for all possible  matches
+       simultaneously.  If the end of the subject is reached before the end of
+       the pattern, there is the possibility of a partial  match,  again  pro-
+       vided that at least one character has matched.
+
+       When  PCRE_PARTIAL_SOFT  is set, PCRE_ERROR_PARTIAL is returned only if
+       there have been no complete matches. Otherwise,  the  complete  matches
+       are  returned.   However,  if PCRE_PARTIAL_HARD is set, a partial match
+       takes precedence over any complete matches. The portion of  the  string
+       that  was  inspected when the longest partial match was found is set as
+       the first matching string, provided there are at least two slots in the
+       offsets vector.
+
+       Because  pcre_dfa_exec()  always searches for all possible matches, and
+       there is no difference between greedy and ungreedy repetition, its  be-
+       haviour is different from pcre_exec when PCRE_PARTIAL_HARD is set. Con-
+       sider the string "dog"  matched  against  the  ungreedy  pattern  shown
+       above:
 
-       When   PCRE_PARTIAL   is  set  for  pcre_dfa_exec(),  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 provided the partial match is set as the first matching string.
+         /dog(sbody)??/
 
-       Using PCRE_PARTIAL disables one of PCRE's optimizations. PCRE remembers
-       the last literal byte in a pattern, and abandons  matching  immediately
-       if  such a byte is not present in the subject string. This optimization
-       cannot be used for a subject string that might match only partially.
+       Whereas  pcre_exec()  stops  as soon as it finds the complete match for
+       "dog", pcre_dfa_exec() also finds the partial match for "dogsbody", and
+       so returns that when PCRE_PARTIAL_HARD is set.
 
 
-RESTRICTED PATTERNS FOR PCRE_PARTIAL
+PARTIAL MATCHING AND WORD BOUNDARIES
 
-       Because of the way certain internal optimizations  are  implemented  in
-       the  pcre_exec()  function, the PCRE_PARTIAL option cannot be used with
-       all patterns. These restrictions do not apply when  pcre_dfa_exec()  is
-       used.  For pcre_exec(), repeated single characters such as
+       If  a  pattern ends with one of sequences \b or \B, which test for word
+       boundaries, partial matching with PCRE_PARTIAL_SOFT can  give  counter-
+       intuitive results. Consider this pattern:
 
-         a{2,4}
+         /\bcat\b/
 
-       and repeated single metasequences such as
+       This matches "cat", provided there is a word boundary at either end. If
+       the subject string is "the cat", the comparison of the final "t" with a
+       following  character  cannot  take  place, so a partial match is found.
+       However, pcre_exec() carries on with normal matching, which matches  \b
+       at  the  end  of  the subject when the last character is a letter, thus
+       finding a complete match. The result, therefore, is not PCRE_ERROR_PAR-
+       TIAL.  The  same  thing  happens  with pcre_dfa_exec(), because it also
+       finds the complete match.
 
-         \d+
+       Using PCRE_PARTIAL_HARD in this  case  does  yield  PCRE_ERROR_PARTIAL,
+       because then the partial match takes precedence.
 
-       are  not permitted if the maximum number of occurrences is greater than
-       one.  Optional items such as \d? (where the maximum is one) are permit-
-       ted.   Quantifiers  with any values are permitted after parentheses, so
-       the invalid examples above can be coded thus:
 
-         (a){2,4}
-         (\d)+
+FORMERLY RESTRICTED PATTERNS
 
-       These constructions run more slowly, but for the kinds  of  application
-       that  are  envisaged  for this facility, this is not felt to be a major
-       restriction.
+       For releases of PCRE prior to 8.00, because of the way certain internal
+       optimizations  were  implemented  in  the  pcre_exec()  function,   the
+       PCRE_PARTIAL  option  (predecessor  of  PCRE_PARTIAL_SOFT) could not be
+       used with all patterns. From release 8.00 onwards, the restrictions  no
+       longer  apply,  and  partial matching with pcre_exec() can be requested
+       for any pattern.
 
-       If PCRE_PARTIAL is set for a pattern  that  does  not  conform  to  the
-       restrictions,  pcre_exec() returns the error code PCRE_ERROR_BADPARTIAL
-       (-13).  You can use the PCRE_INFO_OKPARTIAL call to pcre_fullinfo()  to
-       find out if a compiled pattern can be used for partial matching.
+       Items that were formerly restricted were repeated single characters and
+       repeated  metasequences. If PCRE_PARTIAL was set for a pattern that did
+       not conform to the restrictions, pcre_exec() returned  the  error  code
+       PCRE_ERROR_BADPARTIAL  (-13).  This error code is no longer in use. The
+       PCRE_INFO_OKPARTIAL call to pcre_fullinfo() to find out if  a  compiled
+       pattern can be used for partial matching now always returns 1.
 
 
 EXAMPLE OF PARTIAL MATCHING USING PCRETEST
 
        If  the  escape  sequence  \P  is  present in a pcretest data line, the
-       PCRE_PARTIAL flag is used for the match. Here is a run of pcretest that
-       uses the date example quoted above:
+       PCRE_PARTIAL_SOFT option is used for  the  match.  Here  is  a  run  of
+       pcretest that uses the date example quoted above:
 
            re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
          data> 25jun04\P
           0: 25jun04
           1: jun
          data> 25dec3\P
-         Partial match
+         Partial match: 23dec3
          data> 3ju\P
-         Partial match
+         Partial match: 3ju
          data> 3juj\P
          No match
          data> j\P
@@ -5490,36 +5808,23 @@ EXAMPLE OF PARTIAL MATCHING USING PCRETEST
 
        The  first  data  string  is  matched completely, so pcretest shows the
        matched substrings. The remaining four strings do not  match  the  com-
-       plete  pattern,  but  the first two are partial matches. The same test,
-       using pcre_dfa_exec() matching (by means of the  \D  escape  sequence),
-       produces the following output:
+       plete pattern, but the first two are partial matches. Similar output is
+       obtained when pcre_dfa_exec() is used.
 
-           re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
-         data> 25jun04\P\D
-          0: 25jun04
-         data> 23dec3\P\D
-         Partial match: 23dec3
-         data> 3ju\P\D
-         Partial match: 3ju
-         data> 3juj\P\D
-         No match
-         data> j\P\D
-         No match
-
-       Notice  that in this case the portion of the string that was matched is
-       made available.
+       If the escape sequence \P is present more than once in a pcretest  data
+       line, the PCRE_PARTIAL_HARD option is set for the match.
 
 
 MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
 
        When a partial match has been found using pcre_dfa_exec(), it is possi-
-       ble  to  continue  the  match  by providing additional subject data and
-       calling pcre_dfa_exec() again with the same  compiled  regular  expres-
-       sion, this time setting the PCRE_DFA_RESTART option. You must also pass
-       the same working space as before, because this is where details of  the
-       previous  partial  match are stored. Here is an example using pcretest,
-       using the \R escape sequence to set the PCRE_DFA_RESTART option (\P and
-       \D are as above):
+       ble to continue the match by  providing  additional  subject  data  and
+       calling  pcre_dfa_exec()  again  with the same compiled regular expres-
+       sion, this time setting the PCRE_DFA_RESTART option. You must pass  the
+       same working space as before, because this is where details of the pre-
+       vious partial match are stored. Here  is  an  example  using  pcretest,
+       using  the  \R  escape  sequence to set the PCRE_DFA_RESTART option (\D
+       specifies the use of pcre_dfa_exec()):
 
            re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
          data> 23ja\P\D
@@ -5527,38 +5832,77 @@ MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
          data> n05\R\D
           0: n05
 
-       The  first  call has "23ja" as the subject, and requests partial match-
-       ing; the second call  has  "n05"  as  the  subject  for  the  continued
-       (restarted)  match.   Notice  that when the match is complete, only the
-       last part is shown; PCRE does  not  retain  the  previously  partially-
-       matched  string. It is up to the calling program to do that if it needs
+       The first call has "23ja" as the subject, and requests  partial  match-
+       ing;  the  second  call  has  "n05"  as  the  subject for the continued
+       (restarted) match.  Notice that when the match is  complete,  only  the
+       last  part  is  shown;  PCRE  does not retain the previously partially-
+       matched string. It is up to the calling program to do that if it  needs
        to.
 
-       You can set PCRE_PARTIAL  with  PCRE_DFA_RESTART  to  continue  partial
-       matching over multiple segments. This facility can be used to pass very
-       long subject strings to pcre_dfa_exec(). However, some care  is  needed
-       for certain types of pattern.
+       You  can  set  the  PCRE_PARTIAL_SOFT or PCRE_PARTIAL_HARD options with
+       PCRE_DFA_RESTART to continue partial matching over  multiple  segments.
+       This  facility  can  be  used  to  pass  very  long  subject strings to
+       pcre_dfa_exec().
 
-       1.  If  the  pattern contains tests for the beginning or end of a line,
-       you need to pass the PCRE_NOTBOL or PCRE_NOTEOL options,  as  appropri-
-       ate,  when  the subject string for any call does not contain the begin-
-       ning or end of a line.
 
-       2. If the pattern contains backward assertions (including  \b  or  \B),
-       you  need  to  arrange for some overlap in the subject strings to allow
-       for this. For example, you could pass the subject in  chunks  that  are
-       500  bytes long, but in a buffer of 700 bytes, with the starting offset
-       set to 200 and the previous 200 bytes at the start of the buffer.
+MULTI-SEGMENT MATCHING WITH pcre_exec()
+
+       From release 8.00, pcre_exec() can also be  used  to  do  multi-segment
+       matching.  Unlike  pcre_dfa_exec(),  it  is not possible to restart the
+       previous match with a new segment of data. Instead, new  data  must  be
+       added  to  the  previous  subject  string, and the entire match re-run,
+       starting from the point where the partial match occurred. Earlier  data
+       can be discarded.  Consider an unanchored pattern that matches dates:
+
+           re> /\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d/
+         data> The date is 23ja\P
+         Partial match: 23ja
+
+       At  this stage, an application could discard the text preceding "23ja",
+       add on text from the next segment, and call pcre_exec()  again.  Unlike
+       pcre_dfa_exec(),  the  entire matching string must always be available,
+       and the complete matching process occurs for each call, so more  memory
+       and more processing time is needed.
 
-       3. Matching a subject string that is split into multiple segments  does
-       not  always produce exactly the same result as matching over one single
-       long string.  The difference arises when there  are  multiple  matching
-       possibilities,  because a partial match result is given only when there
-       are no completed matches in a call to pcre_dfa_exec(). This means  that
-       as  soon  as  the  shortest match has been found, continuation to a new
-       subject segment is no longer possible.  Consider this pcretest example:
+       Note:  If  the pattern contains lookbehind assertions, or \K, or starts
+       with \b or \B, the string that is returned for  a  partial  match  will
+       include  characters  that  precede the partially matched string itself,
+       because these must be retained when adding on  more  characters  for  a
+       subsequent matching attempt.
+
+
+ISSUES WITH MULTI-SEGMENT MATCHING
+
+       Certain types of pattern may give problems with multi-segment matching,
+       whichever matching function is used.
+
+       1. If the pattern contains tests for the beginning or end  of  a  line,
+       you  need  to pass the PCRE_NOTBOL or PCRE_NOTEOL options, as appropri-
+       ate, when the subject string for any call does not contain  the  begin-
+       ning or end of a line.
+
+       2.  Lookbehind  assertions at the start of a pattern are catered for in
+       the offsets that are returned for a partial match. However, in  theory,
+       a  lookbehind assertion later in the pattern could require even earlier
+       characters to be inspected, and it might not have been reached  when  a
+       partial  match occurs. This is probably an extremely unlikely case; you
+       could guard against it to a certain extent by  always  including  extra
+       characters at the start.
+
+       3.  Matching  a subject string that is split into multiple segments may
+       not always produce exactly the same result as matching over one  single
+       long  string,  especially  when  PCRE_PARTIAL_SOFT is used. The section
+       "Partial Matching and Word Boundaries" above describes  an  issue  that
+       arises  if  the  pattern ends with \b or \B. Another kind of difference
+       may occur when there are multiple  matching  possibilities,  because  a
+       partial match result is given only when there are no completed matches.
+       This means that as soon as the shortest match has been found, continua-
+       tion  to  a  new subject segment is no longer possible.  Consider again
+       this pcretest example:
 
            re> /dog(sbody)?/
+         data> dogsb\P
+          0: dog
          data> do\P\D
          Partial match: do
          data> gsb\R\P\D
@@ -5567,33 +5911,63 @@ MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
           0: dogsbody
           1: dog
 
-       The pattern matches the words "dog" or "dogsbody". When the subject  is
-       presented  in  several  parts  ("do" and "gsb" being the first two) the
-       match stops when "dog" has been found, and it is not possible  to  con-
-       tinue.  On  the  other  hand,  if  "dogsbody"  is presented as a single
-       string, both matches are found.
+       The first data line passes the string "dogsb" to  pcre_exec(),  setting
+       the  PCRE_PARTIAL_SOFT  option.  Although the string is a partial match
+       for "dogsbody", the  result  is  not  PCRE_ERROR_PARTIAL,  because  the
+       shorter  string  "dog" is a complete match. Similarly, when the subject
+       is presented to pcre_dfa_exec() in several parts ("do" and "gsb"  being
+       the first two) the match stops when "dog" has been found, and it is not
+       possible to continue. On the other hand, if "dogsbody" is presented  as
+       a single string, pcre_dfa_exec() finds both matches.
+
+       Because of these problems, it is probably best to use PCRE_PARTIAL_HARD
+       when matching multi-segment data. The example above then  behaves  dif-
+       ferently:
+
+           re> /dog(sbody)?/
+         data> dogsb\P\P
+         Partial match: dogsb
+         data> do\P\D
+         Partial match: do
+         data> gsb\R\P\P\D
+         Partial match: gsb
 
-       Because of this phenomenon, it does not usually make  sense  to  end  a
-       pattern that is going to be matched in this way with a variable repeat.
 
        4. Patterns that contain alternatives at the top level which do not all
-       start with the same pattern item may not work as expected. For example,
-       consider this pattern:
+       start with the  same  pattern  item  may  not  work  as  expected  when
+       PCRE_DFA_RESTART  is  used  with pcre_dfa_exec(). For example, consider
+       this pattern:
 
          1234|3789
 
-       If  the  first  part of the subject is "ABC123", a partial match of the
-       first alternative is found at offset 3. There is no partial  match  for
+       If the first part of the subject is "ABC123", a partial  match  of  the
+       first  alternative  is found at offset 3. There is no partial match for
        the second alternative, because such a match does not start at the same
-       point in the subject string. Attempting to  continue  with  the  string
-       "789" does not yield a match because only those alternatives that match
-       at one point in the subject are remembered. The problem arises  because
-       the  start  of the second alternative matches within the first alterna-
-       tive. There is no problem with anchored patterns or patterns such as:
+       point  in  the  subject  string. Attempting to continue with the string
+       "7890" does not yield a match  because  only  those  alternatives  that
+       match  at  one  point in the subject are remembered. The problem arises
+       because the start of the second alternative matches  within  the  first
+       alternative.  There  is  no  problem with anchored patterns or patterns
+       such as:
 
          1234|ABCD
 
-       where no string can be a partial match for both alternatives.
+       where no string can be a partial match for both alternatives.  This  is
+       not  a  problem if pcre_exec() is used, because the entire match has to
+       be rerun each time:
+
+           re> /1234|3789/
+         data> ABC123\P
+         Partial match: 123
+         data> 1237890
+          0: 3789
+
+       Of course, instead of using PCRE_DFA_PARTIAL, the same technique of re-
+       running the entire match can also be used with pcre_dfa_exec(). Another
+       possibility is to work with two buffers. If a partial match at offset n
+       in  the first buffer is followed by "no match" when PCRE_DFA_RESTART is
+       used on the second buffer, you can then try a  new  match  starting  at
+       offset n+1 in the first buffer.
 
 
 AUTHOR
@@ -5605,8 +5979,8 @@ AUTHOR
 
 REVISION
 
-       Last updated: 04 June 2007
-       Copyright (c) 1997-2007 University of Cambridge.
+       Last updated: 19 October 2009
+       Copyright (c) 1997-2009 University of Cambridge.
 ------------------------------------------------------------------------------
 
 
@@ -5927,6 +6301,10 @@ DESCRIPTION
        easier to slot in PCRE as a replacement library.  Other  POSIX  options
        are not even defined.
 
+       There  are also some other options that are not defined by POSIX. These
+       have been added at the request of users who want to make use of certain
+       PCRE-specific features via the POSIX calling interface.
+
        When  PCRE  is  called  via these functions, it is only the API that is
        POSIX-like in style. The syntax and semantics of  the  regular  expres-
        sions  themselves  are  still  those of Perl, subject to the setting of
@@ -5981,6 +6359,12 @@ COMPILING A PATTERN
        ing,  the  nmatch  and  pmatch  arguments  are ignored, and no captured
        strings are returned.
 
+         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
+       part of the POSIX standard.
+
          REG_UTF8
 
        The PCRE_UTF8 option is set when the regular expression is  passed  for
@@ -5993,7 +6377,7 @@ COMPILING A PATTERN
        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  aren't)  or
+       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
@@ -6001,6 +6385,10 @@ COMPILING A PATTERN
        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
+       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.
+
 
 MATCHING NEWLINE CHARACTERS
 
@@ -6076,36 +6464,39 @@ MATCHING A PATTERN
        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
+       about any matched strings is returned.
+
        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.
 
 
@@ -6118,7 +6509,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 11 March 2009
+       Last updated: 02 September 2009
        Copyright (c) 1997-2009 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -6474,53 +6865,56 @@ NAME
 PCRE SAMPLE PROGRAM
 
        A simple, complete demonstration program, to get you started with using
-       PCRE, is supplied in the file pcredemo.c in the PCRE distribution.
+       PCRE, is supplied in the file pcredemo.c in the  PCRE  distribution.  A
+       listing  of this program is given in the pcredemo documentation. If you
+       do not have a copy of the PCRE distribution, you can save this  listing
+       to re-create pcredemo.c.
 
        The program compiles the regular expression that is its first argument,
-       and  matches  it  against the subject string in its second argument. No
-       PCRE options are set, and default character tables are used. If  match-
-       ing  succeeds,  the  program  outputs  the  portion of the subject that
+       and matches it against the subject string in its  second  argument.  No
+       PCRE  options are set, and default character tables are used. If match-
+       ing succeeds, the program outputs  the  portion  of  the  subject  that
        matched, together with the contents of any captured substrings.
 
        If the -g option is given on the command line, the program then goes on
        to check for further matches of the same regular expression in the same
-       subject string. The logic is a little bit tricky because of the  possi-
-       bility  of  matching an empty string. Comments in the code explain what
+       subject  string. The logic is a little bit tricky because of the possi-
+       bility of matching an empty string. Comments in the code  explain  what
        is going on.
 
-       If PCRE is installed in the standard include  and  library  directories
-       for  your  system, you should be able to compile the demonstration pro-
-       gram using this command:
+       If  PCRE  is  installed in the standard include and library directories
+       for your operating system, you should be able to compile the demonstra-
+       tion program using this command:
 
          gcc -o pcredemo pcredemo.c -lpcre
 
-       If PCRE is installed elsewhere, you may need to add additional  options
-       to  the  command line. For example, on a Unix-like system that has PCRE
-       installed in /usr/local, you  can  compile  the  demonstration  program
+       If  PCRE is installed elsewhere, you may need to add additional options
+       to the command line. For example, on a Unix-like system that  has  PCRE
+       installed  in  /usr/local,  you  can  compile the demonstration program
        using a command like this:
 
          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
+       Once you have compiled 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'
 
-       Note that there is a  much  more  comprehensive  test  program,  called
-       pcretest,  which  supports  many  more  facilities  for testing regular
+       Note  that  there  is  a  much  more comprehensive test program, called
+       pcretest, which supports  many  more  facilities  for  testing  regular
        expressions and the PCRE library. The pcredemo program is provided as a
        simple coding example.
 
-       On some operating systems (e.g. Solaris), when PCRE is not installed in
-       the standard library directory, you may get an error like this when you
-       try to run pcredemo:
+       When you try to run pcredemo when PCRE is not installed in the standard
+       library  directory,  you  may  get an error like this on some operating
+       systems (e.g. Solaris):
 
-         ld.so.1:  a.out:  fatal:  libpcre.so.0:  open failed: No such file or
+         ld.so.1: a.out: fatal: libpcre.so.0: open failed:  No  such  file  or
        directory
 
-       This is caused by the way shared library support works  on  those  sys-
+       This  is  caused  by the way shared library support works on those sys-
        tems. You need to add
 
          -R/usr/local/lib
@@ -6537,8 +6931,8 @@ AUTHOR
 
 REVISION
 
-       Last updated: 23 January 2008
-       Copyright (c) 1997-2008 University of Cambridge.
+       Last updated: 30 September 2009
+       Copyright (c) 1997-2009 University of Cambridge.
 ------------------------------------------------------------------------------
 PCRESTACK(3)                                                      PCRESTACK(3)
 
diff --git a/ext/pcre/pcrelib/pcre.h b/ext/pcre/pcrelib/pcre.h
index c5fc4c1..93dff10 100644
--- a/ext/pcre/pcrelib/pcre.h
+++ b/ext/pcre/pcrelib/pcre.h
@@ -41,10 +41,10 @@ POSSIBILITY OF SUCH DAMAGE.
 
 /* The current PCRE version information. */
 
-#define PCRE_MAJOR          7
-#define PCRE_MINOR          9
+#define PCRE_MAJOR          8
+#define PCRE_MINOR          00
 #define PCRE_PRERELEASE     
-#define PCRE_DATE           2009-04-11
+#define PCRE_DATE           2009-10-19
 
 /* 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
@@ -113,7 +113,8 @@ both, so we keep them all distinct. */
 #define PCRE_NO_AUTO_CAPTURE    0x00001000
 #define PCRE_NO_UTF8_CHECK      0x00002000
 #define PCRE_AUTO_CALLOUT       0x00004000
-#define PCRE_PARTIAL            0x00008000
+#define PCRE_PARTIAL_SOFT       0x00008000
+#define PCRE_PARTIAL            0x00008000  /* Backwards compatible synonym */
 #define PCRE_DFA_SHORTEST       0x00010000
 #define PCRE_DFA_RESTART        0x00020000
 #define PCRE_FIRSTLINE          0x00040000
@@ -128,6 +129,8 @@ both, so we keep them all distinct. */
 #define PCRE_JAVASCRIPT_COMPAT  0x02000000
 #define PCRE_NO_START_OPTIMIZE  0x04000000
 #define PCRE_NO_START_OPTIMISE  0x04000000
+#define PCRE_PARTIAL_HARD       0x08000000
+#define PCRE_NOTEMPTY_ATSTART   0x10000000
 
 /* Exec-time and get/set-time error codes */
 
@@ -174,6 +177,7 @@ both, so we keep them all distinct. */
 #define PCRE_INFO_OKPARTIAL         12
 #define PCRE_INFO_JCHANGED          13
 #define PCRE_INFO_HASCRORLF         14
+#define PCRE_INFO_MINLENGTH         15
 
 /* Request types for pcre_config(). Do not re-arrange, in order to remain
 compatible. */
diff --git a/ext/pcre/pcrelib/pcre_compile.c b/ext/pcre/pcrelib/pcre_compile.c
index 1e0672c..b197c1b 100644
--- a/ext/pcre/pcrelib/pcre_compile.c
+++ b/ext/pcre/pcrelib/pcre_compile.c
@@ -339,7 +339,9 @@ static const char error_texts[] =
   "number is too big\0"
   "subpattern name expected\0"
   "digit expected after (?+\0"
-  "] is an invalid data character in JavaScript compatibility mode";
+  "] is an invalid data character in JavaScript compatibility mode\0"
+  /* 65 */
+  "different names for subpatterns of the same number are not allowed";
 
 
 /* Table to identify digits and hex digits. This is used when compiling
@@ -1098,6 +1100,7 @@ if (ptr[0] == CHAR_LEFT_PARENTHESIS)
       if (name != NULL && lorn == ptr - thisname &&
           strncmp((const char *)name, (const char *)thisname, lorn) == 0)
         return *count;
+      term++;
       }
     }
   }
@@ -1132,19 +1135,21 @@ for (; *ptr != 0; ptr++)
     BOOL negate_class = FALSE;
     for (;;)
       {
-      int c = *(++ptr);
-      if (c == CHAR_BACKSLASH)
+      if (ptr[1] == CHAR_BACKSLASH)
         {
-        if (ptr[1] == CHAR_E)
-          ptr++;
-        else if (strncmp((const char *)ptr+1,
+        if (ptr[2] == CHAR_E)
+          ptr+= 2;
+        else if (strncmp((const char *)ptr+2,
                  STR_Q STR_BACKSLASH STR_E, 3) == 0)
-          ptr += 3;
+          ptr += 4;
         else
           break;
         }
-      else if (!negate_class && c == CHAR_CIRCUMFLEX_ACCENT)
+      else if (!negate_class && ptr[1] == CHAR_CIRCUMFLEX_ACCENT)
+        {
         negate_class = TRUE;
+        ptr++;
+        }
       else break;
       }
 
@@ -1310,7 +1315,9 @@ for (;;)
 
     case OP_CALLOUT:
     case OP_CREF:
+    case OP_NCREF:
     case OP_RREF:
+    case OP_NRREF:
     case OP_DEF:
     code += _pcre_OP_lengths[*code];
     break;
@@ -1326,23 +1333,34 @@ for (;;)
 
 
 /*************************************************
-*        Find the fixed length of a pattern      *
+*        Find the fixed length of a branch       *
 *************************************************/
 
-/* Scan a pattern and compute the fixed length of subject that will match it,
+/* Scan a branch and compute the fixed length of subject that will match it,
 if the length is fixed. This is needed for dealing with backward assertions.
-In UTF8 mode, the result is in characters rather than bytes.
+In UTF8 mode, the result is in characters rather than bytes. The branch is
+temporarily terminated with OP_END when this function is called.
+
+This function is called when a backward assertion is encountered, so that if it
+fails, the error message can point to the correct place in the pattern.
+However, we cannot do this when the assertion contains subroutine calls,
+because they can be forward references. We solve this by remembering this case
+and doing the check at the end; a flag specifies which mode we are running in.
 
 Arguments:
   code     points to the start of the pattern (the bracket)
   options  the compiling options
+  atend    TRUE if called when the pattern is complete
+  cd       the "compile data" structure
 
-Returns:   the fixed length, or -1 if there is no fixed length,
+Returns:   the fixed length,
+             or -1 if there is no fixed length,
              or -2 if \C was encountered
+             or -3 if an OP_RECURSE item was encountered and atend is FALSE
 */
 
 static int
-find_fixedlength(uschar *code, int options)
+find_fixedlength(uschar *code, int options, BOOL atend, compile_data *cd)
 {
 int length = -1;
 
@@ -1355,6 +1373,7 @@ branch, check the length against that of the other branches. */
 for (;;)
   {
   int d;
+  uschar *ce, *cs;
   register int op = *cc;
   switch (op)
     {
@@ -1362,7 +1381,7 @@ for (;;)
     case OP_BRA:
     case OP_ONCE:
     case OP_COND:
-    d = find_fixedlength(cc + ((op == OP_CBRA)? 2:0), options);
+    d = find_fixedlength(cc + ((op == OP_CBRA)? 2:0), options, atend, cd);
     if (d < 0) return d;
     branchlength += d;
     do cc += GET(cc, 1); while (*cc == OP_ALT);
@@ -1385,6 +1404,21 @@ for (;;)
     branchlength = 0;
     break;
 
+    /* A true recursion implies not fixed length, but a subroutine call may
+    be OK. If the subroutine is a forward reference, we can't deal with
+    it until the end of the pattern, so return -3. */
+
+    case OP_RECURSE:
+    if (!atend) return -3;
+    cs = ce = (uschar *)cd->start_code + GET(cc, 1);  /* Start subpattern */
+    do ce += GET(ce, 1); while (*ce == OP_ALT);       /* End subpattern */
+    if (cc > cs && cc < ce) return -1;                /* Recursion */
+    d = find_fixedlength(cs + 2, options, atend, cd);
+    if (d < 0) return d;
+    branchlength += d;
+    cc += 1 + LINK_SIZE;
+    break;
+
     /* Skip over assertive subpatterns */
 
     case OP_ASSERT:
@@ -1398,7 +1432,9 @@ for (;;)
 
     case OP_REVERSE:
     case OP_CREF:
+    case OP_NCREF:
     case OP_RREF:
+    case OP_NRREF:
     case OP_DEF:
     case OP_OPT:
     case OP_CALLOUT:
@@ -1421,10 +1457,8 @@ for (;;)
     branchlength++;
     cc += 2;
 #ifdef SUPPORT_UTF8
-    if ((options & PCRE_UTF8) != 0)
-      {
-      while ((*cc & 0xc0) == 0x80) cc++;
-      }
+    if ((options & PCRE_UTF8) != 0 && cc[-1] >= 0xc0)
+      cc += _pcre_utf8_table4[cc[-1] & 0x3f];
 #endif
     break;
 
@@ -1435,10 +1469,8 @@ for (;;)
     branchlength += GET2(cc,1);
     cc += 4;
 #ifdef SUPPORT_UTF8
-    if ((options & PCRE_UTF8) != 0)
-      {
-      while((*cc & 0x80) == 0x80) cc++;
-      }
+    if ((options & PCRE_UTF8) != 0 && cc[-1] >= 0xc0)
+      cc += _pcre_utf8_table4[cc[-1] & 0x3f];
 #endif
     break;
 
@@ -1517,22 +1549,25 @@ for (;;)
 
 
 /*************************************************
-*    Scan compiled regex for numbered bracket    *
+*    Scan compiled regex for specific bracket    *
 *************************************************/
 
 /* This little function scans through a compiled pattern until it finds a
-capturing bracket with the given number.
+capturing bracket with the given number, or, if the number is negative, an
+instance of OP_REVERSE for a lookbehind. The function is global in the C sense
+so that it can be called from pcre_study() when finding the minimum matching
+length.
 
 Arguments:
   code        points to start of expression
   utf8        TRUE in UTF-8 mode
-  number      the required bracket number
+  number      the required bracket number or negative to find a lookbehind
 
 Returns:      pointer to the opcode for the bracket, or NULL if not found
 */
 
-static const uschar *
-find_bracket(const uschar *code, BOOL utf8, int number)
+const uschar *
+_pcre_find_bracket(const uschar *code, BOOL utf8, int number)
 {
 for (;;)
   {
@@ -1545,6 +1580,14 @@ for (;;)
 
   if (c == OP_XCLASS) code += GET(code, 1);
 
+  /* Handle recursion */
+
+  else if (c == OP_REVERSE)
+    {
+    if (number < 0) return (uschar *)code;
+    code += _pcre_OP_lengths[c];
+    }
+
   /* Handle capturing bracket */
 
   else if (c == OP_CBRA)
@@ -1910,10 +1953,13 @@ for (code = first_significant_code(code + _pcre_OP_lengths[*code], NULL, 0, TRUE
     case OP_QUERY:
     case OP_MINQUERY:
     case OP_POSQUERY:
+    if (utf8 && code[1] >= 0xc0) code += _pcre_utf8_table4[code[1] & 0x3f];
+    break;
+
     case OP_UPTO:
     case OP_MINUPTO:
     case OP_POSUPTO:
-    if (utf8) while ((code[2] & 0xc0) == 0x80) code++;
+    if (utf8 && code[3] >= 0xc0) code += _pcre_utf8_table4[code[3] & 0x3f];
     break;
 #endif
     }
@@ -3867,10 +3913,15 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
 
       if (repeat_max == 0) goto END_REPEAT;
 
+      /*--------------------------------------------------------------------*/
+      /* This code is obsolete from release 8.00; the restriction was finally
+      removed: */
+
       /* All real repeats make it impossible to handle partial matching (maybe
       one day we will be able to remove this restriction). */
 
-      if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL;
+      /* if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL; */
+      /*--------------------------------------------------------------------*/
 
       /* Combine the op_type with the repeat_type */
 
@@ -4017,10 +4068,15 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
         goto END_REPEAT;
         }
 
+      /*--------------------------------------------------------------------*/
+      /* This code is obsolete from release 8.00; the restriction was finally
+      removed: */
+
       /* All real repeats make it impossible to handle partial matching (maybe
       one day we will be able to remove this restriction). */
 
-      if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL;
+      /* if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL; */
+      /*--------------------------------------------------------------------*/
 
       if (repeat_min == 0 && repeat_max == -1)
         *code++ = OP_CRSTAR + repeat_type;
@@ -4335,11 +4391,20 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
     if (possessive_quantifier)
       {
       int len;
-      if (*tempcode == OP_EXACT || *tempcode == OP_TYPEEXACT ||
-          *tempcode == OP_NOTEXACT)
+
+      if (*tempcode == OP_TYPEEXACT)
         tempcode += _pcre_OP_lengths[*tempcode] +
-          ((*tempcode == OP_TYPEEXACT &&
-             (tempcode[3] == OP_PROP || tempcode[3] == OP_NOTPROP))? 2:0);
+          ((tempcode[3] == OP_PROP || tempcode[3] == OP_NOTPROP)? 2 : 0);
+
+      else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)
+        {
+        tempcode += _pcre_OP_lengths[*tempcode];
+#ifdef SUPPORT_UTF8
+        if (utf8 && tempcode[-1] >= 0xc0)
+          tempcode += _pcre_utf8_table4[tempcode[-1] & 0x3f];
+#endif
+        }
+
       len = code - tempcode;
       if (len > 0) switch (*tempcode)
         {
@@ -4417,8 +4482,19 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
         if (namelen == verbs[i].len &&
             strncmp((char *)name, vn, namelen) == 0)
           {
-          *code = verbs[i].op;
-          if (*code++ == OP_ACCEPT) cd->had_accept = TRUE;
+          /* Check for open captures before ACCEPT */
+
+          if (verbs[i].op == OP_ACCEPT)
+            {
+            open_capitem *oc;
+            cd->had_accept = TRUE;
+            for (oc = cd->open_caps; oc != NULL; oc = oc->next)
+              {
+              *code++ = OP_CLOSE;
+              PUT2INC(code, 0, oc->number);
+              }
+            }
+          *code++ = verbs[i].op;
           break;
           }
         vn += verbs[i].len + 1;
@@ -4580,7 +4656,10 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
           }
 
         /* Otherwise (did not start with "+" or "-"), start by looking for the
-        name. */
+        name. If we find a name, add one to the opcode to change OP_CREF or
+        OP_RREF into OP_NCREF or OP_NRREF. These behave exactly the same,
+        except they record that the reference was originally to a name. The
+        information is used to check duplicate names. */
 
         slot = cd->name_table;
         for (i = 0; i < cd->names_found; i++)
@@ -4595,6 +4674,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
           {
           recno = GET2(slot, 0);
           PUT2(code, 2+LINK_SIZE, recno);
+          code[1+LINK_SIZE]++;
           }
 
         /* Search the pattern for a forward reference */
@@ -4603,6 +4683,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
                         (options & PCRE_EXTENDED) != 0)) > 0)
           {
           PUT2(code, 2+LINK_SIZE, i);
+          code[1+LINK_SIZE]++;
           }
 
         /* If terminator == 0 it means that the name followed directly after
@@ -4795,11 +4876,24 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
               }
             }
 
-          /* In the real compile, create the entry in the table */
+          /* In the real compile, create the entry in the table, maintaining
+          alphabetical order. Duplicate names for different numbers are
+          permitted only if PCRE_DUPNAMES is set. Duplicate names for the same
+          number are always OK. (An existing number can be re-used if (?|
+          appears in the pattern.) In either event, a duplicate name results in
+          a duplicate entry in the table, even if the number is the same. This
+          is because the number of names, and hence the table size, is computed
+          in the pre-compile, and it affects various numbers and pointers which
+          would all have to be modified, and the compiled code moved down, if
+          duplicates with the same number were omitted from the table. This
+          doesn't seem worth the hassle. However, *different* names for the
+          same number are not permitted. */
 
           else
             {
+            BOOL dupname = FALSE;
             slot = cd->name_table;
+
             for (i = 0; i < cd->names_found; i++)
               {
               int crc = memcmp(name, slot+2, namelen);
@@ -4807,33 +4901,66 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
                 {
                 if (slot[2+namelen] == 0)
                   {
-                  if ((options & PCRE_DUPNAMES) == 0)
+                  if (GET2(slot, 0) != cd->bracount + 1 &&
+                      (options & PCRE_DUPNAMES) == 0)
                     {
                     *errorcodeptr = ERR43;
                     goto FAILED;
                     }
+                  else dupname = TRUE;
                   }
-                else crc = -1;      /* Current name is substring */
+                else crc = -1;      /* Current name is a substring */
                 }
+
+              /* Make space in the table and break the loop for an earlier
+              name. For a duplicate or later name, carry on. We do this for
+              duplicates so that in the simple case (when ?(| is not used) they
+              are in order of their numbers. */
+
               if (crc < 0)
                 {
                 memmove(slot + cd->name_entry_size, slot,
                   (cd->names_found - i) * cd->name_entry_size);
                 break;
                 }
+
+              /* Continue the loop for a later or duplicate name */
+
               slot += cd->name_entry_size;
               }
 
+            /* For non-duplicate names, check for a duplicate number before
+            adding the new name. */
+
+            if (!dupname)
+              {
+              uschar *cslot = cd->name_table;
+              for (i = 0; i < cd->names_found; i++)
+                {
+                if (cslot != slot)
+                  {
+                  if (GET2(cslot, 0) == cd->bracount + 1)
+                    {
+                    *errorcodeptr = ERR65;
+                    goto FAILED;
+                    }
+                  }
+                else i--;
+                cslot += cd->name_entry_size;
+                }
+              }
+
             PUT2(slot, 0, cd->bracount + 1);
             memcpy(slot + 2, name, namelen);
             slot[2+namelen] = 0;
             }
           }
 
-        /* In both cases, count the number of names we've encountered. */
+        /* In both pre-compile and compile, count the number of names we've
+        encountered. */
 
-        ptr++;                    /* Move past > or ' */
         cd->names_found++;
+        ptr++;                    /* Move past > or ' */
         goto NUMBERED_GROUP;
 
 
@@ -5002,7 +5129,8 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
           if (lengthptr == NULL)
             {
             *code = OP_END;
-            if (recno != 0) called = find_bracket(cd->start_code, utf8, recno);
+            if (recno != 0)
+              called = _pcre_find_bracket(cd->start_code, utf8, recno);
 
             /* Forward reference */
 
@@ -5646,6 +5774,8 @@ uschar *code = *codeptr;
 uschar *last_branch = code;
 uschar *start_bracket = code;
 uschar *reverse_count = NULL;
+open_capitem capitem;
+int capnumber = 0;
 int firstbyte, reqbyte;
 int branchfirstbyte, branchreqbyte;
 int length;
@@ -5672,6 +5802,17 @@ the code that abstracts option settings at the start of the pattern and makes
 them global. It tests the value of length for (2 + 2*LINK_SIZE) in the
 pre-compile phase to find out whether anything has yet been compiled or not. */
 
+/* If this is a capturing subpattern, add to the chain of open capturing items
+so that we can detect them if (*ACCEPT) is encountered. */
+
+if (*code == OP_CBRA)
+  {
+  capnumber = GET2(code, 1 + LINK_SIZE);
+  capitem.number = capnumber;
+  capitem.next = cd->open_caps;
+  cd->open_caps = &capitem;
+  }
+
 /* Offset is set zero to mark that this bracket is still open */
 
 PUT(code, 1, 0);
@@ -5766,21 +5907,29 @@ for (;;)
 
     /* If lookbehind, check that this branch matches a fixed-length string, and
     put the length into the OP_REVERSE item. Temporarily mark the end of the
-    branch with OP_END. */
+    branch with OP_END. If the branch contains OP_RECURSE, the result is -3
+    because there may be forward references that we can't check here. Set a
+    flag to cause another lookbehind check at the end. Why not do it all at the
+    end? Because common, erroneous checks are picked up here and the offset of
+    the problem can be shown. */
 
     if (lookbehind)
       {
       int fixed_length;
       *code = OP_END;
-      fixed_length = find_fixedlength(last_branch, options);
+      fixed_length = find_fixedlength(last_branch, options, FALSE, cd);
       DPRINTF(("fixed length = %d\n", fixed_length));
-      if (fixed_length < 0)
+      if (fixed_length == -3)
+        {
+        cd->check_lookbehind = TRUE;
+        }
+      else if (fixed_length < 0)
         {
         *errorcodeptr = (fixed_length == -2)? ERR36 : ERR25;
         *ptrptr = ptr;
         return FALSE;
         }
-      PUT(reverse_count, 0, fixed_length);
+      else { PUT(reverse_count, 0, fixed_length); }
       }
     }
 
@@ -5808,6 +5957,10 @@ for (;;)
       while (branch_length > 0);
       }
 
+    /* If it was a capturing subpattern, remove it from the chain. */
+
+    if (capnumber > 0) cd->open_caps = cd->open_caps->next;
+
     /* Fill in the ket */
 
     *code = OP_KET;
@@ -6010,7 +6163,9 @@ do {
      switch (*scode)
        {
        case OP_CREF:
+       case OP_NCREF:
        case OP_RREF:
+       case OP_NRREF:
        case OP_DEF:
        return FALSE;
 
@@ -6179,9 +6334,7 @@ int length = 1;  /* For final END opcode */
 int firstbyte, reqbyte, newline;
 int errorcode = 0;
 int skipatstart = 0;
-#ifdef SUPPORT_UTF8
-BOOL utf8;
-#endif
+BOOL utf8 = (options & PCRE_UTF8) != 0;
 size_t size;
 uschar *code;
 const uschar *codestart;
@@ -6278,7 +6431,6 @@ while (ptr[skipatstart] == CHAR_LEFT_PARENTHESIS &&
 /* Can't support UTF8 unless PCRE has been compiled to include the code. */
 
 #ifdef SUPPORT_UTF8
-utf8 = (options & PCRE_UTF8) != 0;
 if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0 &&
      (*erroroffset = _pcre_valid_utf8((uschar *)pattern, -1)) >= 0)
   {
@@ -6286,7 +6438,7 @@ if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0 &&
   goto PCRE_EARLY_ERROR_RETURN2;
   }
 #else
-if ((options & PCRE_UTF8) != 0)
+if (utf8)
   {
   errorcode = ERR32;
   goto PCRE_EARLY_ERROR_RETURN;
@@ -6375,6 +6527,7 @@ cd->end_pattern = (const uschar *)(pattern + strlen(pattern));
 cd->req_varyopt = 0;
 cd->external_options = options;
 cd->external_flags = 0;
+cd->open_caps = NULL;
 
 /* Now do the pre-compile. On error, errorcode will be set non-zero, so we
 don't need to look at the result of the function here. The initial options have
@@ -6449,6 +6602,8 @@ cd->start_code = codestart;
 cd->hwm = cworkspace;
 cd->req_varyopt = 0;
 cd->had_accept = FALSE;
+cd->check_lookbehind = FALSE;
+cd->open_caps = NULL;
 
 /* Set up a starting, non-extracting bracket, then compile the expression. On
 error, errorcode will be set non-zero, so we don't need to look at the result
@@ -6487,7 +6642,7 @@ while (errorcode == 0 && cd->hwm > cworkspace)
   cd->hwm -= LINK_SIZE;
   offset = GET(cd->hwm, 0);
   recno = GET(codestart, offset);
-  groupptr = find_bracket(codestart, (re->options & PCRE_UTF8) != 0, recno);
+  groupptr = _pcre_find_bracket(codestart, utf8, recno);
   if (groupptr == NULL) errorcode = ERR53;
     else PUT(((uschar *)codestart), offset, groupptr - codestart);
   }
@@ -6497,6 +6652,47 @@ subpattern. */
 
 if (errorcode == 0 && re->top_backref > re->top_bracket) errorcode = ERR15;
 
+/* If there were any lookbehind assertions that contained OP_RECURSE
+(recursions or subroutine calls), a flag is set for them to be checked here,
+because they may contain forward references. Actual recursions can't be fixed
+length, but subroutine calls can. It is done like this so that those without
+OP_RECURSE that are not fixed length get a diagnosic with a useful offset. The
+exceptional ones forgo this. We scan the pattern to check that they are fixed
+length, and set their lengths. */
+
+if (cd->check_lookbehind)
+  {
+  uschar *cc = (uschar *)codestart;
+
+  /* Loop, searching for OP_REVERSE items, and process those that do not have
+  their length set. (Actually, it will also re-process any that have a length
+  of zero, but that is a pathological case, and it does no harm.) When we find
+  one, we temporarily terminate the branch it is in while we scan it. */
+
+  for (cc = (uschar *)_pcre_find_bracket(codestart, utf8, -1);
+       cc != NULL;
+       cc = (uschar *)_pcre_find_bracket(cc, utf8, -1))
+    {
+    if (GET(cc, 1) == 0)
+      {
+      int fixed_length;
+      uschar *be = cc - 1 - LINK_SIZE + GET(cc, -LINK_SIZE);
+      int end_op = *be;
+      *be = OP_END;
+      fixed_length = find_fixedlength(cc, re->options, TRUE, cd);
+      *be = end_op;
+      DPRINTF(("fixed length = %d\n", fixed_length));
+      if (fixed_length < 0)
+        {
+        errorcode = (fixed_length == -2)? ERR36 : ERR25;
+        break;
+        }
+      PUT(cc, 1, fixed_length);
+      }
+    cc += 1 + LINK_SIZE;
+    }
+  }
+
 /* Failed to compile, or error while post-processing */
 
 if (errorcode != 0)
diff --git a/ext/pcre/pcrelib/pcre_exec.c b/ext/pcre/pcrelib/pcre_exec.c
index 073cf24..ca3079b 100644
--- a/ext/pcre/pcrelib/pcre_exec.c
+++ b/ext/pcre/pcrelib/pcre_exec.c
@@ -396,10 +396,32 @@ typedef struct heapframe {
 
 /* This function is called recursively in many circumstances. Whenever it
 returns a negative (error) response, the outer incarnation must also return the
-same response.
+same response. */
 
-Performance note: It might be tempting to extract commonly used fields from the
-md structure (e.g. utf8, end_subject) into individual variables to improve
+/* These macros pack up tests that are used for partial matching, and which
+appears several times in the code. We set the "hit end" flag if the pointer is
+at the end of the subject and also past the start of the subject (i.e.
+something has been matched). For hard partial matching, we then return
+immediately. The second one is used when we already know we are past the end of
+the subject. */
+
+#define CHECK_PARTIAL()\
+  if (md->partial != 0 && eptr >= md->end_subject && eptr > mstart)\
+    {\
+    md->hitend = TRUE;\
+    if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\
+    }
+
+#define SCHECK_PARTIAL()\
+  if (md->partial != 0 && eptr > mstart)\
+    {\
+    md->hitend = TRUE;\
+    if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\
+    }
+
+
+/* Performance note: It might be tempting to extract commonly used fields from
+the md structure (e.g. utf8, end_subject) into individual variables to improve
 performance. Tests using gcc on a SPARC disproved this; in the first case, it
 made performance worse.
 
@@ -640,14 +662,6 @@ for (;;)
   minimize = possessive = FALSE;
   op = *ecode;
 
-  /* For partial matching, remember if we ever hit the end of the subject after
-  matching at least one subject character. */
-
-  if (md->partial &&
-      eptr >= md->end_subject &&
-      eptr > mstart)
-    md->hitend = TRUE;
-
   switch(op)
     {
     case OP_FAIL:
@@ -823,18 +837,139 @@ for (;;)
 
     /* Now see what the actual condition is */
 
-    if (condcode == OP_RREF)         /* Recursion test */
+    if (condcode == OP_RREF || condcode == OP_NRREF)    /* Recursion test */
       {
-      offset = GET2(ecode, LINK_SIZE + 2);     /* Recursion group number*/
-      condition = md->recursive != NULL &&
-        (offset == RREF_ANY || offset == md->recursive->group_num);
-      ecode += condition? 3 : GET(ecode, 1);
+      if (md->recursive == NULL)                /* Not recursing => FALSE */
+        {
+        condition = FALSE;
+        ecode += GET(ecode, 1);
+        }
+      else
+        {
+        int recno = GET2(ecode, LINK_SIZE + 2);   /* Recursion group number*/
+        condition =  (recno == RREF_ANY || recno == md->recursive->group_num);
+
+        /* If the test is for recursion into a specific subpattern, and it is
+        false, but the test was set up by name, scan the table to see if the
+        name refers to any other numbers, and test them. The condition is true
+        if any one is set. */
+
+        if (!condition && condcode == OP_NRREF && recno != RREF_ANY)
+          {
+          uschar *slotA = md->name_table;
+          for (i = 0; i < md->name_count; i++)
+            {
+            if (GET2(slotA, 0) == recno) break;
+            slotA += md->name_entry_size;
+            }
+
+          /* Found a name for the number - there can be only one; duplicate
+          names for different numbers are allowed, but not vice versa. First
+          scan down for duplicates. */
+
+          if (i < md->name_count)
+            {
+            uschar *slotB = slotA;
+            while (slotB > md->name_table)
+              {
+              slotB -= md->name_entry_size;
+              if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)
+                {
+                condition = GET2(slotB, 0) == md->recursive->group_num;
+                if (condition) break;
+                }
+              else break;
+              }
+
+            /* Scan up for duplicates */
+
+            if (!condition)
+              {
+              slotB = slotA;
+              for (i++; i < md->name_count; i++)
+                {
+                slotB += md->name_entry_size;
+                if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)
+                  {
+                  condition = GET2(slotB, 0) == md->recursive->group_num;
+                  if (condition) break;
+                  }
+                else break;
+                }
+              }
+            }
+          }
+
+        /* Chose branch according to the condition */
+
+        ecode += condition? 3 : GET(ecode, 1);
+        }
       }
 
-    else if (condcode == OP_CREF)    /* Group used test */
+    else if (condcode == OP_CREF || condcode == OP_NCREF)  /* Group used test */
       {
       offset = GET2(ecode, LINK_SIZE+2) << 1;  /* Doubled ref number */
       condition = offset < offset_top && md->offset_vector[offset] >= 0;
+
+      /* If the numbered capture is unset, but the reference was by name,
+      scan the table to see if the name refers to any other numbers, and test
+      them. The condition is true if any one is set. This is tediously similar
+      to the code above, but not close enough to try to amalgamate. */
+
+      if (!condition && condcode == OP_NCREF)
+        {
+        int refno = offset >> 1;
+        uschar *slotA = md->name_table;
+
+        for (i = 0; i < md->name_count; i++)
+          {
+          if (GET2(slotA, 0) == refno) break;
+          slotA += md->name_entry_size;
+          }
+
+        /* Found a name for the number - there can be only one; duplicate names
+        for different numbers are allowed, but not vice versa. First scan down
+        for duplicates. */
+
+        if (i < md->name_count)
+          {
+          uschar *slotB = slotA;
+          while (slotB > md->name_table)
+            {
+            slotB -= md->name_entry_size;
+            if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)
+              {
+              offset = GET2(slotB, 0) << 1;
+              condition = offset < offset_top &&
+                md->offset_vector[offset] >= 0;
+              if (condition) break;
+              }
+            else break;
+            }
+
+          /* Scan up for duplicates */
+
+          if (!condition)
+            {
+            slotB = slotA;
+            for (i++; i < md->name_count; i++)
+              {
+              slotB += md->name_entry_size;
+              if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)
+                {
+                offset = GET2(slotB, 0) << 1;
+                condition = offset < offset_top &&
+                  md->offset_vector[offset] >= 0;
+                if (condition) break;
+                }
+              else break;
+              }
+            }
+          }
+        }
+
+      /* Chose branch according to the condition */
+
       ecode += condition? 3 : GET(ecode, 1);
       }
 
@@ -895,6 +1030,30 @@ for (;;)
     break;
 
 
+    /* Before OP_ACCEPT there may be any number of OP_CLOSE opcodes,
+    to close any currently open capturing brackets. */
+
+    case OP_CLOSE:
+    number = GET2(ecode, 1);
+    offset = number << 1;
+
+#ifdef DEBUG
+      printf("end bracket %d at *ACCEPT", number);
+      printf("\n");
+#endif
+
+    md->capture_last = number;
+    if (offset >= md->offset_max) md->offset_overflow = TRUE; else
+      {
+      md->offset_vector[offset] =
+        md->offset_vector[md->offset_end - number];
+      md->offset_vector[offset+1] = eptr - md->start_subject;
+      if (offset_top <= offset) offset_top = offset + 2;
+      }
+    ecode += 3;
+    break;
+
+
     /* End of the pattern, either real or forced. If we are in a top-level
     recursion, we should restore the offsets appropriately and continue from
     after the call. */
@@ -908,16 +1067,26 @@ for (;;)
       md->recursive = rec->prevrec;
       memmove(md->offset_vector, rec->offset_save,
         rec->saved_max * sizeof(int));
+      offset_top = rec->save_offset_top;
       mstart = rec->save_start;
       ims = original_ims;
       ecode = rec->after_call;
       break;
       }
 
-    /* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty
-    string - backtracking will then try other alternatives, if any. */
+    /* Otherwise, if we have matched an empty string, fail if PCRE_NOTEMPTY is
+    set, or if PCRE_NOTEMPTY_ATSTART is set and we have matched at the start of
+    the subject. In both cases, backtracking will then try other alternatives,
+    if any. */
+
+    if (eptr == mstart &&
+        (md->notempty ||
+          (md->notempty_atstart &&
+            mstart == md->start_subject + md->start_offset)))
+      RRETURN(MATCH_NOMATCH);
+
+    /* Otherwise, we have a match. */
 
-    if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH);
     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) */
@@ -1008,8 +1177,9 @@ for (;;)
       if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
       }
 
-    /* Skip to next op code */
+    /* Save the earliest consulted character, then skip to next op code */
 
+    if (eptr < md->start_used_ptr) md->start_used_ptr = eptr;
     ecode += 1 + LINK_SIZE;
     break;
 
@@ -1089,6 +1259,7 @@ for (;;)
       memcpy(new_recursive.offset_save, md->offset_vector,
             new_recursive.saved_max * sizeof(int));
       new_recursive.save_start = mstart;
+      new_recursive.save_offset_top = offset_top;
       mstart = eptr;
 
       /* OK, now we can do the recursion. For each top-level alternative we
@@ -1313,6 +1484,7 @@ for (;;)
         mstart = rec->save_start;
         memcpy(md->offset_vector, rec->offset_save,
           rec->saved_max * sizeof(int));
+        offset_top = rec->save_offset_top;
         ecode = rec->after_call;
         ims = original_ims;
         break;
@@ -1452,7 +1624,8 @@ for (;;)
 
       /* Find out if the previous and current characters are "word" characters.
       It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to
-      be "non-word" characters. */
+      be "non-word" characters. Remember the earliest consulted character for
+      partial matching. */
 
 #ifdef SUPPORT_UTF8
       if (utf8)
@@ -1461,10 +1634,16 @@ for (;;)
           {
           USPTR lastptr = eptr - 1;
           while((*lastptr & 0xc0) == 0x80) lastptr--;
+          if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
           GETCHAR(c, lastptr);
           prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
           }
-        if (eptr >= md->end_subject) cur_is_word = FALSE; else
+        if (eptr >= md->end_subject)
+          {
+          SCHECK_PARTIAL();
+          cur_is_word = FALSE;
+          }
+        else
           {
           GETCHAR(c, eptr);
           cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
@@ -1473,13 +1652,20 @@ for (;;)
       else
 #endif
 
-      /* More streamlined when not in UTF-8 mode */
+      /* Not in UTF-8 mode */
 
         {
-        prev_is_word = (eptr != md->start_subject) &&
-          ((md->ctypes[eptr[-1]] & ctype_word) != 0);
-        cur_is_word = (eptr < md->end_subject) &&
-          ((md->ctypes[*eptr] & ctype_word) != 0);
+        if (eptr == md->start_subject) prev_is_word = FALSE; else
+          {
+          if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;
+          prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);
+          }
+        if (eptr >= md->end_subject)
+          {
+          SCHECK_PARTIAL();
+          cur_is_word = FALSE;
+          }
+        else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);
         }
 
       /* Now see if the situation is what we want */
@@ -1497,7 +1683,11 @@ for (;;)
     /* Fall through */
 
     case OP_ALLANY:
-    if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr++ >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
     ecode++;
     break;
@@ -1506,12 +1696,20 @@ for (;;)
     any byte, even newline, independent of the setting of PCRE_DOTALL. */
 
     case OP_ANYBYTE:
-    if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr++ >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     ecode++;
     break;
 
     case OP_NOT_DIGIT:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     if (
 #ifdef SUPPORT_UTF8
@@ -1524,7 +1722,11 @@ for (;;)
     break;
 
     case OP_DIGIT:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     if (
 #ifdef SUPPORT_UTF8
@@ -1537,7 +1739,11 @@ for (;;)
     break;
 
     case OP_NOT_WHITESPACE:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     if (
 #ifdef SUPPORT_UTF8
@@ -1550,7 +1756,11 @@ for (;;)
     break;
 
     case OP_WHITESPACE:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     if (
 #ifdef SUPPORT_UTF8
@@ -1563,7 +1773,11 @@ for (;;)
     break;
 
     case OP_NOT_WORDCHAR:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     if (
 #ifdef SUPPORT_UTF8
@@ -1576,7 +1790,11 @@ for (;;)
     break;
 
     case OP_WORDCHAR:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     if (
 #ifdef SUPPORT_UTF8
@@ -1589,7 +1807,11 @@ for (;;)
     break;
 
     case OP_ANYNL:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     switch(c)
       {
@@ -1613,7 +1835,11 @@ for (;;)
     break;
 
     case OP_NOT_HSPACE:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     switch(c)
       {
@@ -1643,7 +1869,11 @@ for (;;)
     break;
 
     case OP_HSPACE:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     switch(c)
       {
@@ -1673,7 +1903,11 @@ for (;;)
     break;
 
     case OP_NOT_VSPACE:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     switch(c)
       {
@@ -1691,7 +1925,11 @@ for (;;)
     break;
 
     case OP_VSPACE:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
     switch(c)
       {
@@ -1714,7 +1952,11 @@ for (;;)
 
     case OP_PROP:
     case OP_NOTPROP:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
       {
       const ucd_record *prop = GET_UCD(c);
@@ -1759,7 +2001,11 @@ for (;;)
     is in the binary; otherwise a compile-time error occurs. */
 
     case OP_EXTUNI:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     GETCHARINCTEST(c, eptr);
       {
       int category = UCD_CATEGORY(c);
@@ -1839,7 +2085,11 @@ for (;;)
         break;
 
         default:               /* No repeat follows */
-        if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH);
+        if (!match_ref(offset, eptr, length, md, ims))
+          {
+          CHECK_PARTIAL();
+          RRETURN(MATCH_NOMATCH);
+          }
         eptr += length;
         continue;              /* With the main loop */
         }
@@ -1855,7 +2105,11 @@ for (;;)
 
       for (i = 1; i <= min; i++)
         {
-        if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH);
+        if (!match_ref(offset, eptr, length, md, ims))
+          {
+          CHECK_PARTIAL();
+          RRETURN(MATCH_NOMATCH);
+          }
         eptr += length;
         }
 
@@ -1872,8 +2126,12 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max || !match_ref(offset, eptr, length, md, ims))
+          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (!match_ref(offset, eptr, length, md, ims))
+            {
+            CHECK_PARTIAL();
             RRETURN(MATCH_NOMATCH);
+            }
           eptr += length;
           }
         /* Control never gets here */
@@ -1886,7 +2144,11 @@ for (;;)
         pp = eptr;
         for (i = min; i < max; i++)
           {
-          if (!match_ref(offset, eptr, length, md, ims)) break;
+          if (!match_ref(offset, eptr, length, md, ims))
+            {
+            CHECK_PARTIAL();
+            break;
+            }
           eptr += length;
           }
         while (eptr >= pp)
@@ -1900,8 +2162,6 @@ for (;;)
       }
     /* Control never gets here */
 
-
-
     /* Match a bit-mapped character class, possibly repeatedly. This op code is
     used when all the characters in the class have values in the range 0-255,
     and either the matching is caseful, or the characters are in the range
@@ -1956,7 +2216,11 @@ for (;;)
         {
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINC(c, eptr);
           if (c > 255)
             {
@@ -1974,7 +2238,11 @@ for (;;)
         {
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           c = *eptr++;
           if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
           }
@@ -1998,7 +2266,12 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINC(c, eptr);
             if (c > 255)
               {
@@ -2018,7 +2291,12 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             c = *eptr++;
             if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
             }
@@ -2039,7 +2317,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             if (c > 255)
               {
@@ -2065,7 +2347,11 @@ for (;;)
           {
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             c = *eptr;
             if ((data[c/8] & (1 << (c&7))) == 0) break;
             eptr++;
@@ -2127,7 +2413,11 @@ for (;;)
 
       for (i = 1; i <= min; i++)
         {
-        if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+        if (eptr >= md->end_subject)
+          {
+          SCHECK_PARTIAL();
+          RRETURN(MATCH_NOMATCH);
+          }
         GETCHARINCTEST(c, eptr);
         if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);
         }
@@ -2146,7 +2436,12 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINCTEST(c, eptr);
           if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);
           }
@@ -2161,7 +2456,11 @@ for (;;)
         for (i = min; i < max; i++)
           {
           int len = 1;
-          if (eptr >= md->end_subject) break;
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            break;
+            }
           GETCHARLENTEST(c, eptr, len);
           if (!_pcre_xclass(c, data)) break;
           eptr += len;
@@ -2189,7 +2488,11 @@ for (;;)
       length = 1;
       ecode++;
       GETCHARLEN(fc, ecode, length);
-      if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
+      if (length > md->end_subject - eptr)
+        {
+        CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
+        RRETURN(MATCH_NOMATCH);
+        }
       while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);
       }
     else
@@ -2197,7 +2500,11 @@ for (;;)
 
     /* Non-UTF-8 mode */
       {
-      if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);
+      if (md->end_subject - eptr < 1)
+        {
+        SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
+        RRETURN(MATCH_NOMATCH);
+        }
       if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);
       ecode += 2;
       }
@@ -2213,7 +2520,11 @@ for (;;)
       ecode++;
       GETCHARLEN(fc, ecode, length);
 
-      if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
+      if (length > md->end_subject - eptr)
+        {
+        CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
+        RRETURN(MATCH_NOMATCH);
+        }
 
       /* If the pattern character's value is < 128, we have only one byte, and
       can use the fast lookup table. */
@@ -2248,7 +2559,11 @@ for (;;)
 
     /* Non-UTF-8 mode */
       {
-      if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);
+      if (md->end_subject - eptr < 1)
+        {
+        SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
+        RRETURN(MATCH_NOMATCH);
+        }
       if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
       ecode += 2;
       }
@@ -2302,13 +2617,12 @@ for (;;)
     case OP_MINQUERY:
     c = *ecode++ - OP_STAR;
     minimize = (c & 1) != 0;
+
     min = rep_min[c];                 /* Pick up values from tables; */
     max = rep_max[c];                 /* zero for max => infinity */
     if (max == 0) max = INT_MAX;
 
-    /* Common code for all repeated single-character matches. We can give
-    up quickly if there are fewer than the minimum number of characters left in
-    the subject. */
+    /* Common code for all repeated single-character matches. */
 
     REPEATCHAR:
 #ifdef SUPPORT_UTF8
@@ -2317,7 +2631,6 @@ for (;;)
       length = 1;
       charptr = ecode;
       GETCHARLEN(fc, ecode, length);
-      if (min * length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
       ecode += length;
 
       /* Handle multibyte character matching specially here. There is
@@ -2335,18 +2648,18 @@ for (;;)
 
         for (i = 1; i <= min; i++)
           {
-          if (memcmp(eptr, charptr, length) == 0) eptr += length;
+          if (eptr <= md->end_subject - length &&
+            memcmp(eptr, charptr, length) == 0) eptr += length;
 #ifdef SUPPORT_UCP
-          /* Need braces because of following else */
-          else if (oclength == 0) { RRETURN(MATCH_NOMATCH); }
+          else if (oclength > 0 &&
+                   eptr <= md->end_subject - oclength &&
+                   memcmp(eptr, occhars, oclength) == 0) eptr += oclength;
+#endif  /* SUPPORT_UCP */
           else
             {
-            if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH);
-            eptr += oclength;
+            CHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
             }
-#else   /* without SUPPORT_UCP */
-          else { RRETURN(MATCH_NOMATCH); }
-#endif  /* SUPPORT_UCP */
           }
 
         if (min == max) continue;
@@ -2357,19 +2670,19 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
-            if (memcmp(eptr, charptr, length) == 0) eptr += length;
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr <= md->end_subject - length &&
+              memcmp(eptr, charptr, length) == 0) eptr += length;
 #ifdef SUPPORT_UCP
-            /* Need braces because of following else */
-            else if (oclength == 0) { RRETURN(MATCH_NOMATCH); }
+            else if (oclength > 0 &&
+                     eptr <= md->end_subject - oclength &&
+                     memcmp(eptr, occhars, oclength) == 0) eptr += oclength;
+#endif  /* SUPPORT_UCP */
             else
               {
-              if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH);
-              eptr += oclength;
+              CHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
               }
-#else   /* without SUPPORT_UCP */
-            else { RRETURN (MATCH_NOMATCH); }
-#endif  /* SUPPORT_UCP */
             }
           /* Control never gets here */
           }
@@ -2379,33 +2692,34 @@ for (;;)
           pp = eptr;
           for (i = min; i < max; i++)
             {
-            if (eptr > md->end_subject - length) break;
-            if (memcmp(eptr, charptr, length) == 0) eptr += length;
+            if (eptr <= md->end_subject - length &&
+                memcmp(eptr, charptr, length) == 0) eptr += length;
 #ifdef SUPPORT_UCP
-            else if (oclength == 0) break;
+            else if (oclength > 0 &&
+                     eptr <= md->end_subject - oclength &&
+                     memcmp(eptr, occhars, oclength) == 0) eptr += oclength;
+#endif  /* SUPPORT_UCP */
             else
               {
-              if (memcmp(eptr, occhars, oclength) != 0) break;
-              eptr += oclength;
+              CHECK_PARTIAL();
+              break;
               }
-#else   /* without SUPPORT_UCP */
-            else break;
-#endif  /* SUPPORT_UCP */
             }
 
           if (possessive) continue;
+
           for(;;)
-           {
-           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23);
-           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-           if (eptr == pp) RRETURN(MATCH_NOMATCH);
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (eptr == pp) { RRETURN(MATCH_NOMATCH); }
 #ifdef SUPPORT_UCP
-           eptr--;
-           BACKCHAR(eptr);
+            eptr--;
+            BACKCHAR(eptr);
 #else   /* without SUPPORT_UCP */
-           eptr -= length;
+            eptr -= length;
 #endif  /* SUPPORT_UCP */
-           }
+            }
           }
         /* Control never gets here */
         }
@@ -2418,10 +2732,8 @@ for (;;)
 #endif  /* SUPPORT_UTF8 */
 
     /* When not in UTF-8 mode, load a single-byte character. */
-      {
-      if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
-      fc = *ecode++;
-      }
+
+    fc = *ecode++;
 
     /* The value of fc at this point is always less than 256, though we may or
     may not be in UTF-8 mode. The code is duplicated for the caseless and
@@ -2439,7 +2751,14 @@ for (;;)
       {
       fc = md->lcc[fc];
       for (i = 1; i <= min; i++)
+        {
+        if (eptr >= md->end_subject)
+          {
+          SCHECK_PARTIAL();
+          RRETURN(MATCH_NOMATCH);
+          }
         if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+        }
       if (min == max) continue;
       if (minimize)
         {
@@ -2447,9 +2766,13 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max || eptr >= md->end_subject ||
-              fc != md->lcc[*eptr++])
+          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
             RRETURN(MATCH_NOMATCH);
+            }
+          if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
           }
         /* Control never gets here */
         }
@@ -2458,10 +2781,17 @@ for (;;)
         pp = eptr;
         for (i = min; i < max; i++)
           {
-          if (eptr >= md->end_subject || fc != md->lcc[*eptr]) break;
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            break;
+            }
+          if (fc != md->lcc[*eptr]) break;
           eptr++;
           }
+
         if (possessive) continue;
+
         while (eptr >= pp)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25);
@@ -2477,16 +2807,31 @@ for (;;)
 
     else
       {
-      for (i = 1; i <= min; i++) if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
+      for (i = 1; i <= min; i++)
+        {
+        if (eptr >= md->end_subject)
+          {
+          SCHECK_PARTIAL();
+          RRETURN(MATCH_NOMATCH);
+          }
+        if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
+        }
+
       if (min == max) continue;
+
       if (minimize)
         {
         for (fi = min;; fi++)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max || eptr >= md->end_subject || fc != *eptr++)
+          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
             RRETURN(MATCH_NOMATCH);
+            }
+          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
           }
         /* Control never gets here */
         }
@@ -2495,10 +2840,16 @@ for (;;)
         pp = eptr;
         for (i = min; i < max; i++)
           {
-          if (eptr >= md->end_subject || fc != *eptr) break;
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            break;
+            }
+          if (fc != *eptr) break;
           eptr++;
           }
         if (possessive) continue;
+
         while (eptr >= pp)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27);
@@ -2514,7 +2865,11 @@ for (;;)
     checking can be multibyte. */
 
     case OP_NOT:
-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr >= md->end_subject)
+      {
+      SCHECK_PARTIAL();
+      RRETURN(MATCH_NOMATCH);
+      }
     ecode++;
     GETCHARINCTEST(c, eptr);
     if ((ims & PCRE_CASELESS) != 0)
@@ -2591,12 +2946,9 @@ for (;;)
     max = rep_max[c];                 /* zero for max => infinity */
     if (max == 0) max = INT_MAX;
 
-    /* Common code for all repeated single-byte matches. We can give up quickly
-    if there are fewer than the minimum number of bytes left in the
-    subject. */
+    /* Common code for all repeated single-byte matches. */
 
     REPEATNOTCHAR:
-    if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
     fc = *ecode++;
 
     /* The code is duplicated for the caseless and caseful cases, for speed,
@@ -2621,6 +2973,11 @@ for (;;)
         register unsigned int d;
         for (i = 1; i <= min; i++)
           {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINC(d, eptr);
           if (d < 256) d = md->lcc[d];
           if (fc == d) RRETURN(MATCH_NOMATCH);
@@ -2632,7 +2989,14 @@ for (;;)
       /* Not UTF-8 mode */
         {
         for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+          }
         }
 
       if (min == max) continue;
@@ -2648,11 +3012,15 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINC(d, eptr);
             if (d < 256) d = md->lcc[d];
             if (fc == d) RRETURN(MATCH_NOMATCH);
-
             }
           }
         else
@@ -2663,8 +3031,13 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++])
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
               RRETURN(MATCH_NOMATCH);
+              }
+            if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
             }
           }
         /* Control never gets here */
@@ -2684,7 +3057,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(d, eptr, len);
             if (d < 256) d = md->lcc[d];
             if (fc == d) break;
@@ -2705,7 +3082,12 @@ for (;;)
           {
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
+            if (fc == md->lcc[*eptr]) break;
             eptr++;
             }
           if (possessive) continue;
@@ -2733,6 +3115,11 @@ for (;;)
         register unsigned int d;
         for (i = 1; i <= min; i++)
           {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINC(d, eptr);
           if (fc == d) RRETURN(MATCH_NOMATCH);
           }
@@ -2742,7 +3129,14 @@ for (;;)
       /* Not UTF-8 mode */
         {
         for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
+          }
         }
 
       if (min == max) continue;
@@ -2758,7 +3152,12 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINC(d, eptr);
             if (fc == d) RRETURN(MATCH_NOMATCH);
             }
@@ -2771,8 +3170,13 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject || fc == *eptr++)
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
               RRETURN(MATCH_NOMATCH);
+              }
+            if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
             }
           }
         /* Control never gets here */
@@ -2792,7 +3196,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(d, eptr, len);
             if (fc == d) break;
             eptr += len;
@@ -2812,7 +3220,12 @@ for (;;)
           {
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject || fc == *eptr) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
+            if (fc == *eptr) break;
             eptr++;
             }
           if (possessive) continue;
@@ -2906,13 +3319,10 @@ for (;;)
 
     /* First, ensure the minimum number of matches are present. Use inline
     code for maximizing the speed, and do the type test once at the start
-    (i.e. keep it out of the loop). Also we can test that there are at least
-    the minimum number of bytes before we start. This isn't as effective in
-    UTF-8 mode, but it does no harm. Separate the UTF-8 code completely as that
+    (i.e. keep it out of the loop). Separate the UTF-8 code completely as that
     is tidier. Also separate the UCP code, which can be the same for both UTF-8
     and single-bytes. */
 
-    if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
     if (min > 0)
       {
 #ifdef SUPPORT_UCP
@@ -2924,7 +3334,11 @@ for (;;)
           if (prop_fail_result) RRETURN(MATCH_NOMATCH);
           for (i = 1; i <= min; i++)
             {
-            if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINCTEST(c, eptr);
             }
           break;
@@ -2932,7 +3346,11 @@ for (;;)
           case PT_LAMP:
           for (i = 1; i <= min; i++)
             {
-            if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINCTEST(c, eptr);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == ucp_Lu ||
@@ -2945,7 +3363,11 @@ for (;;)
           case PT_GC:
           for (i = 1; i <= min; i++)
             {
-            if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINCTEST(c, eptr);
             prop_category = UCD_CATEGORY(c);
             if ((prop_category == prop_value) == prop_fail_result)
@@ -2956,7 +3378,11 @@ for (;;)
           case PT_PC:
           for (i = 1; i <= min; i++)
             {
-            if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINCTEST(c, eptr);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == prop_value) == prop_fail_result)
@@ -2967,7 +3393,11 @@ for (;;)
           case PT_SC:
           for (i = 1; i <= min; i++)
             {
-            if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINCTEST(c, eptr);
             prop_script = UCD_SCRIPT(c);
             if ((prop_script == prop_value) == prop_fail_result)
@@ -2987,16 +3417,19 @@ for (;;)
         {
         for (i = 1; i <= min; i++)
           {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINCTEST(c, eptr);
           prop_category = UCD_CATEGORY(c);
           if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);
           while (eptr < md->end_subject)
             {
             int len = 1;
-            if (!utf8) c = *eptr; else
-              {
-              GETCHARLEN(c, eptr, len);
-              }
+            if (!utf8) c = *eptr;
+              else { GETCHARLEN(c, eptr, len); }
             prop_category = UCD_CATEGORY(c);
             if (prop_category != ucp_M) break;
             eptr += len;
@@ -3015,8 +3448,12 @@ for (;;)
         case OP_ANY:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject || IS_NEWLINE(eptr))
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
             RRETURN(MATCH_NOMATCH);
+            }
+          if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
           eptr++;
           while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
           }
@@ -3025,20 +3462,29 @@ for (;;)
         case OP_ALLANY:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           eptr++;
           while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
           }
         break;
 
         case OP_ANYBYTE:
+        if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);
         eptr += min;
         break;
 
         case OP_ANYNL:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINC(c, eptr);
           switch(c)
             {
@@ -3064,7 +3510,11 @@ for (;;)
         case OP_NOT_HSPACE:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINC(c, eptr);
           switch(c)
             {
@@ -3096,7 +3546,11 @@ for (;;)
         case OP_HSPACE:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINC(c, eptr);
           switch(c)
             {
@@ -3128,7 +3582,11 @@ for (;;)
         case OP_NOT_VSPACE:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINC(c, eptr);
           switch(c)
             {
@@ -3148,7 +3606,11 @@ for (;;)
         case OP_VSPACE:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINC(c, eptr);
           switch(c)
             {
@@ -3168,7 +3630,11 @@ for (;;)
         case OP_NOT_DIGIT:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINC(c, eptr);
           if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)
             RRETURN(MATCH_NOMATCH);
@@ -3178,8 +3644,12 @@ for (;;)
         case OP_DIGIT:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject ||
-             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
+          if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)
             RRETURN(MATCH_NOMATCH);
           /* No need to skip more bytes - we know it's a 1-byte character */
           }
@@ -3188,8 +3658,12 @@ for (;;)
         case OP_NOT_WHITESPACE:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject ||
-             (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0))
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
+          if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)
             RRETURN(MATCH_NOMATCH);
           while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
           }
@@ -3198,8 +3672,12 @@ for (;;)
         case OP_WHITESPACE:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject ||
-             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
+          if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)
             RRETURN(MATCH_NOMATCH);
           /* No need to skip more bytes - we know it's a 1-byte character */
           }
@@ -3218,8 +3696,12 @@ for (;;)
         case OP_WORDCHAR:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject ||
-             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
+          if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)
             RRETURN(MATCH_NOMATCH);
           /* No need to skip more bytes - we know it's a 1-byte character */
           }
@@ -3233,34 +3715,49 @@ for (;;)
 #endif     /* SUPPORT_UTF8 */
 
       /* Code for the non-UTF-8 case for minimum matching of operators other
-      than OP_PROP and OP_NOTPROP. We can assume that there are the minimum
-      number of bytes present, as this was tested above. */
+      than OP_PROP and OP_NOTPROP. */
 
       switch(ctype)
         {
         case OP_ANY:
         for (i = 1; i <= min; i++)
           {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
           eptr++;
           }
         break;
 
         case OP_ALLANY:
+        if (eptr > md->end_subject - min)
+          {
+          SCHECK_PARTIAL();
+          RRETURN(MATCH_NOMATCH);
+          }
         eptr += min;
         break;
 
         case OP_ANYBYTE:
+        if (eptr > md->end_subject - min)
+          {
+          SCHECK_PARTIAL();
+          RRETURN(MATCH_NOMATCH);
+          }
         eptr += min;
         break;
 
-        /* Because of the CRLF case, we can't assume the minimum number of
-        bytes are present in this case. */
-
         case OP_ANYNL:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           switch(*eptr++)
             {
             default: RRETURN(MATCH_NOMATCH);
@@ -3282,7 +3779,11 @@ for (;;)
         case OP_NOT_HSPACE:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           switch(*eptr++)
             {
             default: break;
@@ -3297,7 +3798,11 @@ for (;;)
         case OP_HSPACE:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           switch(*eptr++)
             {
             default: RRETURN(MATCH_NOMATCH);
@@ -3312,7 +3817,11 @@ for (;;)
         case OP_NOT_VSPACE:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           switch(*eptr++)
             {
             default: break;
@@ -3329,7 +3838,11 @@ for (;;)
         case OP_VSPACE:
         for (i = 1; i <= min; i++)
           {
-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           switch(*eptr++)
             {
             default: RRETURN(MATCH_NOMATCH);
@@ -3345,34 +3858,76 @@ for (;;)
 
         case OP_NOT_DIGIT:
         for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
+          }
         break;
 
         case OP_DIGIT:
         for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);
+          }
         break;
 
         case OP_NOT_WHITESPACE:
         for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);
+          }
         break;
 
         case OP_WHITESPACE:
         for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);
+          }
         break;
 
         case OP_NOT_WORDCHAR:
         for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           if ((md->ctypes[*eptr++] & ctype_word) != 0)
             RRETURN(MATCH_NOMATCH);
+          }
         break;
 
         case OP_WORDCHAR:
         for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           if ((md->ctypes[*eptr++] & ctype_word) == 0)
             RRETURN(MATCH_NOMATCH);
+          }
         break;
 
         default:
@@ -3400,7 +3955,12 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINC(c, eptr);
             if (prop_fail_result) RRETURN(MATCH_NOMATCH);
             }
@@ -3411,7 +3971,12 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINC(c, eptr);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == ucp_Lu ||
@@ -3426,7 +3991,12 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINC(c, eptr);
             prop_category = UCD_CATEGORY(c);
             if ((prop_category == prop_value) == prop_fail_result)
@@ -3439,7 +4009,12 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINC(c, eptr);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == prop_value) == prop_fail_result)
@@ -3452,7 +4027,12 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              RRETURN(MATCH_NOMATCH);
+              }
             GETCHARINC(c, eptr);
             prop_script = UCD_SCRIPT(c);
             if ((prop_script == prop_value) == prop_fail_result)
@@ -3474,17 +4054,20 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
           GETCHARINCTEST(c, eptr);
           prop_category = UCD_CATEGORY(c);
           if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);
           while (eptr < md->end_subject)
             {
             int len = 1;
-            if (!utf8) c = *eptr; else
-              {
-              GETCHARLEN(c, eptr, len);
-              }
+            if (!utf8) c = *eptr;
+              else { GETCHARLEN(c, eptr, len); }
             prop_category = UCD_CATEGORY(c);
             if (prop_category != ucp_M) break;
             eptr += len;
@@ -3503,10 +4086,14 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max || eptr >= md->end_subject ||
-               (ctype == OP_ANY && IS_NEWLINE(eptr)))
+          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
+          if (ctype == OP_ANY && IS_NEWLINE(eptr))
             RRETURN(MATCH_NOMATCH);
-
           GETCHARINC(c, eptr);
           switch(ctype)
             {
@@ -3662,10 +4249,14 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max || eptr >= md->end_subject ||
-               (ctype == OP_ANY && IS_NEWLINE(eptr)))
+          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            RRETURN(MATCH_NOMATCH);
+            }
+          if (ctype == OP_ANY && IS_NEWLINE(eptr))
             RRETURN(MATCH_NOMATCH);
-
           c = *eptr++;
           switch(ctype)
             {
@@ -3790,7 +4381,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             if (prop_fail_result) break;
             eptr+= len;
@@ -3801,7 +4396,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == ucp_Lu ||
@@ -3816,7 +4415,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             prop_category = UCD_CATEGORY(c);
             if ((prop_category == prop_value) == prop_fail_result)
@@ -3829,7 +4432,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == prop_value) == prop_fail_result)
@@ -3842,7 +4449,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             prop_script = UCD_SCRIPT(c);
             if ((prop_script == prop_value) == prop_fail_result)
@@ -3871,7 +4482,11 @@ for (;;)
         {
         for (i = min; i < max; i++)
           {
-          if (eptr >= md->end_subject) break;
+          if (eptr >= md->end_subject)
+            {
+            SCHECK_PARTIAL();
+            break;
+            }
           GETCHARINCTEST(c, eptr);
           prop_category = UCD_CATEGORY(c);
           if (prop_category == ucp_M) break;
@@ -3891,6 +4506,7 @@ for (;;)
         /* eptr is now past the end of the maximum run */
 
         if (possessive) continue;
+
         for(;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45);
@@ -3926,7 +4542,12 @@ for (;;)
             {
             for (i = min; i < max; i++)
               {
-              if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
+              if (eptr >= md->end_subject)
+                {
+                SCHECK_PARTIAL();
+                break;
+                }
+              if (IS_NEWLINE(eptr)) break;
               eptr++;
               while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
               }
@@ -3938,7 +4559,12 @@ for (;;)
             {
             for (i = min; i < max; i++)
               {
-              if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
+              if (eptr >= md->end_subject)
+                {
+                SCHECK_PARTIAL();
+                break;
+                }
+              if (IS_NEWLINE(eptr)) break;
               eptr++;
               while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
               }
@@ -3950,7 +4576,11 @@ for (;;)
             {
             for (i = min; i < max; i++)
               {
-              if (eptr >= md->end_subject) break;
+              if (eptr >= md->end_subject)
+                {
+                SCHECK_PARTIAL();
+                break;
+                }
               eptr++;
               while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
               }
@@ -3963,15 +4593,22 @@ for (;;)
           case OP_ANYBYTE:
           c = max - min;
           if (c > (unsigned int)(md->end_subject - eptr))
-            c = md->end_subject - eptr;
-          eptr += c;
+            {
+            eptr = md->end_subject;
+            SCHECK_PARTIAL();
+            }
+          else eptr += c;
           break;
 
           case OP_ANYNL:
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             if (c == 0x000d)
               {
@@ -3996,7 +4633,11 @@ for (;;)
             {
             BOOL gotspace;
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             switch(c)
               {
@@ -4034,7 +4675,11 @@ for (;;)
             {
             BOOL gotspace;
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             switch(c)
               {
@@ -4058,7 +4703,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break;
             eptr+= len;
@@ -4069,7 +4718,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break;
             eptr+= len;
@@ -4080,7 +4733,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break;
             eptr+= len;
@@ -4091,7 +4748,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break;
             eptr+= len;
@@ -4102,7 +4763,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break;
             eptr+= len;
@@ -4113,7 +4778,11 @@ for (;;)
           for (i = min; i < max; i++)
             {
             int len = 1;
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             GETCHARLEN(c, eptr, len);
             if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break;
             eptr+= len;
@@ -4145,7 +4814,12 @@ for (;;)
           case OP_ANY:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
+            if (IS_NEWLINE(eptr)) break;
             eptr++;
             }
           break;
@@ -4154,14 +4828,21 @@ for (;;)
           case OP_ANYBYTE:
           c = max - min;
           if (c > (unsigned int)(md->end_subject - eptr))
-            c = md->end_subject - eptr;
-          eptr += c;
+            {
+            eptr = md->end_subject;
+            SCHECK_PARTIAL();
+            }
+          else eptr += c;
           break;
 
           case OP_ANYNL:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             c = *eptr;
             if (c == 0x000d)
               {
@@ -4182,7 +4863,11 @@ for (;;)
           case OP_NOT_HSPACE:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             c = *eptr;
             if (c == 0x09 || c == 0x20 || c == 0xa0) break;
             eptr++;
@@ -4192,7 +4877,11 @@ for (;;)
           case OP_HSPACE:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             c = *eptr;
             if (c != 0x09 && c != 0x20 && c != 0xa0) break;
             eptr++;
@@ -4202,7 +4891,11 @@ for (;;)
           case OP_NOT_VSPACE:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             c = *eptr;
             if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85)
               break;
@@ -4213,7 +4906,11 @@ for (;;)
           case OP_VSPACE:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject) break;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
             c = *eptr;
             if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85)
               break;
@@ -4224,8 +4921,12 @@ for (;;)
           case OP_NOT_DIGIT:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0)
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
               break;
+              }
+            if ((md->ctypes[*eptr] & ctype_digit) != 0) break;
             eptr++;
             }
           break;
@@ -4233,8 +4934,12 @@ for (;;)
           case OP_DIGIT:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0)
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
               break;
+              }
+            if ((md->ctypes[*eptr] & ctype_digit) == 0) break;
             eptr++;
             }
           break;
@@ -4242,8 +4947,12 @@ for (;;)
           case OP_NOT_WHITESPACE:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0)
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
               break;
+              }
+            if ((md->ctypes[*eptr] & ctype_space) != 0) break;
             eptr++;
             }
           break;
@@ -4251,8 +4960,12 @@ for (;;)
           case OP_WHITESPACE:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0)
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
               break;
+              }
+            if ((md->ctypes[*eptr] & ctype_space) == 0) break;
             eptr++;
             }
           break;
@@ -4260,8 +4973,12 @@ for (;;)
           case OP_NOT_WORDCHAR:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0)
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
               break;
+              }
+            if ((md->ctypes[*eptr] & ctype_word) != 0) break;
             eptr++;
             }
           break;
@@ -4269,8 +4986,12 @@ for (;;)
           case OP_WORDCHAR:
           for (i = min; i < max; i++)
             {
-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0)
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
               break;
+              }
+            if ((md->ctypes[*eptr] & ctype_word) == 0) break;
             eptr++;
             }
           break;
@@ -4448,6 +5169,7 @@ const uschar *tables;
 const uschar *start_bits = NULL;
 USPTR start_match = (USPTR)subject + start_offset;
 USPTR end_subject;
+USPTR start_partial = NULL;
 USPTR req_byte_ptr = start_match - 1;
 
 pcre_study_data internal_study;
@@ -4464,6 +5186,13 @@ if (re == NULL || subject == NULL ||
    (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;
 if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
 
+/* This information is for finding all the numbers associated with a given
+name, for condition testing. */
+
+md->name_table = (uschar *)re + re->name_table_offset;
+md->name_count = re->name_count;
+md->name_entry_size = re->name_entry_size;
+
 /* Fish out the optional data from the extra_data structure, first setting
 the default values. */
 
@@ -4531,7 +5260,9 @@ md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
 md->notbol = (options & PCRE_NOTBOL) != 0;
 md->noteol = (options & PCRE_NOTEOL) != 0;
 md->notempty = (options & PCRE_NOTEMPTY) != 0;
-md->partial = (options & PCRE_PARTIAL) != 0;
+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->recursive = NULL;                   /* No recursion at top level */
@@ -4605,8 +5336,9 @@ else
     }
   }
 
-/* Partial matching is supported only for a restricted set of regexes at the
-moment. */
+/* Partial matching was originally supported only for a restricted set of
+regexes; from release 8.00 there are no restrictions, but the bits are still
+defined (though never set). So there's no harm in leaving this code. */
 
 if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0)
   return PCRE_ERROR_BADPARTIAL;
@@ -4693,7 +5425,7 @@ if (!anchored)
     }
   else
     if (!startline && study != NULL &&
-      (study->options & PCRE_STUDY_MAPPED) != 0)
+      (study->flags & PCRE_STUDY_MAPPED) != 0)
         start_bits = study->start_bits;
   }
 
@@ -4820,79 +5552,94 @@ for(;;)
 
   end_subject = save_end_subject;
 
-#ifdef DEBUG  /* Sigh. Some compilers never learn. */
-  printf(">>>> Match against: ");
-  pchars(start_match, end_subject - start_match, TRUE, md);
-  printf("\n");
-#endif
-
-  /* If req_byte is set, we know that that character must appear in the
-  subject for the match to succeed. If the first character is set, req_byte
-  must be later in the subject; otherwise the test starts at the match point.
-  This optimization can save a huge amount of backtracking in patterns with
-  nested unlimited repeats that aren't going to match. Writing separate code
-  for cased/caseless versions makes it go faster, as does using an
-  autoincrement and backing off on a match.
-
-  HOWEVER: when the subject string is very, very long, searching to its end
-  can take a long time, and give bad performance on quite ordinary patterns.
-  This showed up when somebody was matching something like /^\d+C/ on a
-  32-megabyte string... so we don't do this when the string is sufficiently
-  long.
-
-  ALSO: this processing is disabled when partial matching is requested, or if
+  /* The following two optimizations are disabled for partial matching or if
   disabling is explicitly requested. */
 
-  if ((options & PCRE_NO_START_OPTIMIZE) == 0 &&
-      req_byte >= 0 &&
-      end_subject - start_match < REQ_BYTE_MAX &&
-      !md->partial)
+  if ((options & PCRE_NO_START_OPTIMIZE) == 0 && !md->partial)
     {
-    register USPTR p = start_match + ((first_byte >= 0)? 1 : 0);
+    /* If the pattern was studied, a minimum subject length may be set. This is
+    a lower bound; no actual string of that length may actually match the
+    pattern. Although the value is, strictly, in characters, we treat it as
+    bytes to avoid spending too much time in this optimization. */
 
-    /* We don't need to repeat the search if we haven't yet reached the
-    place we found it at last time. */
+    if (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0 &&
+        end_subject - start_match < study->minlength)
+      {
+      rc = MATCH_NOMATCH;
+      break;
+      }
 
-    if (p > req_byte_ptr)
+    /* If req_byte is set, we know that that character must appear in the
+    subject for the match to succeed. If the first character is set, req_byte
+    must be later in the subject; otherwise the test starts at the match point.
+    This optimization can save a huge amount of backtracking in patterns with
+    nested unlimited repeats that aren't going to match. Writing separate code
+    for cased/caseless versions makes it go faster, as does using an
+    autoincrement and backing off on a match.
+
+    HOWEVER: when the subject string is very, very long, searching to its end
+    can take a long time, and give bad performance on quite ordinary patterns.
+    This showed up when somebody was matching something like /^\d+C/ on a
+    32-megabyte string... so we don't do this when the string is sufficiently
+    long. */
+
+    if (req_byte >= 0 && end_subject - start_match < REQ_BYTE_MAX)
       {
-      if (req_byte_caseless)
+      register USPTR p = start_match + ((first_byte >= 0)? 1 : 0);
+
+      /* We don't need to repeat the search if we haven't yet reached the
+      place we found it at last time. */
+
+      if (p > req_byte_ptr)
         {
-        while (p < end_subject)
+        if (req_byte_caseless)
           {
-          register int pp = *p++;
-          if (pp == req_byte || pp == req_byte2) { p--; break; }
+          while (p < end_subject)
+            {
+            register int pp = *p++;
+            if (pp == req_byte || pp == req_byte2) { p--; break; }
+            }
           }
-        }
-      else
-        {
-        while (p < end_subject)
+        else
           {
-          if (*p++ == req_byte) { p--; break; }
+          while (p < end_subject)
+            {
+            if (*p++ == req_byte) { p--; break; }
+            }
           }
-        }
 
-      /* If we can't find the required character, break the matching loop,
-      forcing a match failure. */
+        /* If we can't find the required character, break the matching loop,
+        forcing a match failure. */
 
-      if (p >= end_subject)
-        {
-        rc = MATCH_NOMATCH;
-        break;
-        }
+        if (p >= end_subject)
+          {
+          rc = MATCH_NOMATCH;
+          break;
+          }
 
-      /* If we have found the required character, save the point where we
-      found it, so that we don't search again next time round the loop if
-      the start hasn't passed this character yet. */
+        /* If we have found the required character, save the point where we
+        found it, so that we don't search again next time round the loop if
+        the start hasn't passed this character yet. */
 
-      req_byte_ptr = p;
+        req_byte_ptr = p;
+        }
       }
     }
 
-  /* OK, we can now run the match. */
+#ifdef DEBUG  /* Sigh. Some compilers never learn. */
+  printf(">>>> Match against: ");
+  pchars(start_match, end_subject - start_match, TRUE, md);
+  printf("\n");
+#endif
+
+  /* OK, we can now run the match. If "hitend" is set afterwards, remember the
+  first starting point for which a partial match was found. */
 
   md->start_match_ptr = start_match;
+  md->start_used_ptr = start_match;
   md->match_call_count = 0;
   rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0);
+  if (md->hitend && start_partial == NULL) start_partial = md->start_used_ptr;
 
   switch(rc)
     {
@@ -4922,7 +5669,7 @@ for(;;)
     rc = MATCH_NOMATCH;
     goto ENDLOOP;
 
-    /* Any other return is some kind of error. */
+    /* Any other return is either a match, or some kind of error. */
 
     default:
     goto ENDLOOP;
@@ -5028,14 +5775,19 @@ if (using_temporary_offsets)
   (pcre_free)(md->offset_vector);
   }
 
-if (rc != MATCH_NOMATCH)
+if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL)
   {
   DPRINTF((">>>> error: returning %d\n", rc));
   return rc;
   }
-else if (md->partial && md->hitend)
+else if (start_partial != NULL)
   {
   DPRINTF((">>>> returning PCRE_ERROR_PARTIAL\n"));
+  if (offsetcount > 1)
+    {
+    offsets[0] = start_partial - (USPTR)subject;
+    offsets[1] = end_subject - (USPTR)subject;
+    }
   return PCRE_ERROR_PARTIAL;
   }
 else
diff --git a/ext/pcre/pcrelib/pcre_fullinfo.c b/ext/pcre/pcrelib/pcre_fullinfo.c
index 44fa91b..6725ad7 100644
--- a/ext/pcre/pcrelib/pcre_fullinfo.c
+++ b/ext/pcre/pcrelib/pcre_fullinfo.c
@@ -117,10 +117,16 @@ switch (what)
 
   case PCRE_INFO_FIRSTTABLE:
   *((const uschar **)where) =
-    (study != NULL && (study->options & PCRE_STUDY_MAPPED) != 0)?
+    (study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)?
       ((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;
   break;
 
+  case PCRE_INFO_MINLENGTH:
+  *((int *)where) =
+    (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)?
+      study->minlength : -1;
+  break;
+
   case PCRE_INFO_LASTLITERAL:
   *((int *)where) =
     ((re->flags & PCRE_REQCHSET) != 0)? re->req_byte : -1;
@@ -142,6 +148,9 @@ switch (what)
   *((const uschar **)where) = (const uschar *)(_pcre_default_tables);
   break;
 
+  /* From release 8.00 this will always return TRUE because NOPARTIAL is
+  no longer ever set (the restrictions have been removed). */
+
   case PCRE_INFO_OKPARTIAL:
   *((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0;
   break;
diff --git a/ext/pcre/pcrelib/pcre_internal.h b/ext/pcre/pcrelib/pcre_internal.h
index e168f39..de09614 100644
--- a/ext/pcre/pcrelib/pcre_internal.h
+++ b/ext/pcre/pcrelib/pcre_internal.h
@@ -535,7 +535,9 @@ Standard C system should have one. */
 
 /* Private flags containing information about the compiled regex. They used to
 live at the top end of the options word, but that got almost full, so now they
-are in a 16-bit flags word. */
+are in a 16-bit flags word. From release 8.00, PCRE_NOPARTIAL is unused, as
+the restrictions on partial matching have been lifted. It remains for backwards
+compatibility. */
 
 #define PCRE_NOPARTIAL     0x0001  /* can't use partial with this regex */
 #define PCRE_FIRSTSET      0x0002  /* first_byte is set */
@@ -547,6 +549,7 @@ are in a 16-bit flags word. */
 /* Options for the "extra" block produced by pcre_study(). */
 
 #define PCRE_STUDY_MAPPED   0x01     /* a map of starting chars exists */
+#define PCRE_STUDY_MINLEN   0x02     /* a minimum length field exists */
 
 /* Masks for identifying the public options that are permitted at compile
 time, run time, or study time, respectively. */
@@ -562,14 +565,15 @@ time, run time, or study time, respectively. */
    PCRE_JAVASCRIPT_COMPAT)
 
 #define PUBLIC_EXEC_OPTIONS \
-  (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
-   PCRE_PARTIAL|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
-   PCRE_NO_START_OPTIMIZE)
+  (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \
+   PCRE_NO_UTF8_CHECK|PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT|PCRE_NEWLINE_BITS| \
+   PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE|PCRE_NO_START_OPTIMIZE)
 
 #define PUBLIC_DFA_EXEC_OPTIONS \
-  (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
-   PCRE_PARTIAL|PCRE_DFA_SHORTEST|PCRE_DFA_RESTART|PCRE_NEWLINE_BITS| \
-   PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE|PCRE_NO_START_OPTIMIZE)
+  (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \
+   PCRE_NO_UTF8_CHECK|PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT|PCRE_DFA_SHORTEST| \
+   PCRE_DFA_RESTART|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
+   PCRE_NO_START_OPTIMIZE)
 
 #define PUBLIC_STUDY_OPTIONS 0   /* None defined */
 
@@ -1206,8 +1210,8 @@ enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
 OP_EOD must correspond in order to the list of escapes immediately above.
 
 *** NOTE NOTE NOTE *** Whenever this list is updated, the two macro definitions
-that follow must also be updated to match. There is also a table called
-"coptable" in pcre_dfa_exec.c that must be updated. */
+that follow must also be updated to match. There are also tables called
+"coptable" and "poptable" in pcre_dfa_exec.c that must be updated. */
 
 enum {
   OP_END,            /* 0 End of pattern */
@@ -1343,30 +1347,39 @@ enum {
   OP_SCBRA,          /* 98 Start of capturing bracket, check empty */
   OP_SCOND,          /* 99 Conditional group, check empty */
 
+  /* The next two pairs must (respectively) be kept together. */
+
   OP_CREF,           /* 100 Used to hold a capture number as condition */
-  OP_RREF,           /* 101 Used to hold a recursion number as condition */
-  OP_DEF,            /* 102 The DEFINE condition */
+  OP_NCREF,          /* 101 Same, but generaged by a name reference*/
+  OP_RREF,           /* 102 Used to hold a recursion number as condition */
+  OP_NRREF,          /* 103 Same, but generaged by a name reference*/
+  OP_DEF,            /* 104 The DEFINE condition */
 
-  OP_BRAZERO,        /* 103 These two must remain together and in this */
-  OP_BRAMINZERO,     /* 104 order. */
+  OP_BRAZERO,        /* 105 These two must remain together and in this */
+  OP_BRAMINZERO,     /* 106 order. */
 
   /* These are backtracking control verbs */
 
-  OP_PRUNE,          /* 105 */
-  OP_SKIP,           /* 106 */
-  OP_THEN,           /* 107 */
-  OP_COMMIT,         /* 108 */
+  OP_PRUNE,          /* 107 */
+  OP_SKIP,           /* 108 */
+  OP_THEN,           /* 109 */
+  OP_COMMIT,         /* 110 */
 
   /* These are forced failure and success verbs */
 
-  OP_FAIL,           /* 109 */
-  OP_ACCEPT,         /* 110 */
+  OP_FAIL,           /* 111 */
+  OP_ACCEPT,         /* 112 */
+  OP_CLOSE,          /* 113 Used before OP_ACCEPT to close open captures */
 
   /* This is used to skip a subpattern with a {0} quantifier */
 
-  OP_SKIPZERO        /* 111 */
+  OP_SKIPZERO        /* 114 */
 };
 
+/* *** 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. */
+
 
 /* This macro defines textual names for all the opcodes. These are used only
 for debugging. The macro is referenced only in pcre_printint.c. */
@@ -1388,9 +1401,10 @@ for debugging. The macro is referenced only in pcre_printint.c. */
   "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",     \
   "AssertB", "AssertB not", "Reverse",                            \
   "Once", "Bra", "CBra", "Cond", "SBra", "SCBra", "SCond",        \
-  "Cond ref", "Cond rec", "Cond def", "Brazero", "Braminzero",    \
+  "Cond ref", "Cond nref", "Cond rec", "Cond nrec", "Cond def",   \
+  "Brazero", "Braminzero",                                        \
   "*PRUNE", "*SKIP", "*THEN", "*COMMIT", "*FAIL", "*ACCEPT",      \
-  "Skip zero"
+  "Close", "Skip zero"
 
 
 /* This macro defines the length of fixed length operations in the compiled
@@ -1450,15 +1464,16 @@ in UTF-8 mode. The code that uses this table must know about such things. */
   1+LINK_SIZE,                   /* SBRA                                   */ \
   3+LINK_SIZE,                   /* SCBRA                                  */ \
   1+LINK_SIZE,                   /* SCOND                                  */ \
-  3,                             /* CREF                                   */ \
-  3,                             /* RREF                                   */ \
+  3, 3,                          /* CREF, NCREF                            */ \
+  3, 3,                          /* RREF, NRREF                            */ \
   1,                             /* DEF                                    */ \
   1, 1,                          /* BRAZERO, BRAMINZERO                    */ \
   1, 1, 1, 1,                    /* PRUNE, SKIP, THEN, COMMIT,             */ \
-  1, 1, 1                        /* FAIL, ACCEPT, SKIPZERO                 */
+  1, 1, 3, 1                     /* FAIL, ACCEPT, CLOSE, SKIPZERO          */
 
 
-/* A magic value for OP_RREF to indicate the "any recursion" condition. */
+/* A magic value for OP_RREF and OP_NRREF to indicate the "any recursion"
+condition. */
 
 #define RREF_ANY  0xffff
 
@@ -1471,7 +1486,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 };
+       ERR60, ERR61, ERR62, ERR63, ERR64, ERR65 };
 
 /* 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
@@ -1487,7 +1502,7 @@ Because people can now save and re-use compiled patterns, any additions to this
 structure should be made at the end, and something earlier (e.g. a new
 flag in the options or one of the dummy fields) should indicate that the new
 fields are present. Currently PCRE always sets the dummy fields to zero.
-NOTE NOTE NOTE:
+NOTE NOTE NOTE
 */
 
 typedef struct real_pcre {
@@ -1514,10 +1529,20 @@ remark (see NOTE above) about extending this structure applies. */
 
 typedef struct pcre_study_data {
   pcre_uint32 size;               /* Total that was malloced */
-  pcre_uint32 options;
-  uschar start_bits[32];
+  pcre_uint32 flags;              /* Private flags */
+  uschar start_bits[32];          /* Starting char bits */
+  pcre_uint32 minlength;          /* Minimum subject length */
 } pcre_study_data;
 
+/* Structure for building a chain of open capturing subpatterns during
+compiling, so that instructions to close them can be compiled when (*ACCEPT) is
+encountered. */
+
+typedef struct open_capitem {
+  struct open_capitem *next;    /* Chain link */
+  pcre_uint16 number;           /* Capture number */
+} open_capitem;
+
 /* Structure for passing "static" information around between the functions
 doing the compiling, so that they are thread-safe. */
 
@@ -1530,6 +1555,7 @@ typedef struct compile_data {
   const uschar *start_code;     /* The start of the compiled code */
   const uschar *start_pattern;  /* The start of the pattern */
   const uschar *end_pattern;    /* The end of the pattern */
+  open_capitem *open_caps;      /* Chain of open capture items */
   uschar *hwm;                  /* High watermark of workspace */
   uschar *name_table;           /* The name/number table */
   int  names_found;             /* Number of entries so far */
@@ -1542,6 +1568,7 @@ typedef struct compile_data {
   int  external_flags;          /* External flag bits to be set */
   int  req_varyopt;             /* "After variable item" flag for reqbyte */
   BOOL had_accept;              /* (*ACCEPT) encountered */
+  BOOL check_lookbehind;        /* Lookbehinds need later checking */
   int  nltype;                  /* Newline type */
   int  nllen;                   /* Newline string length */
   uschar nl[4];                 /* Newline string when fixed length */
@@ -1565,6 +1592,7 @@ typedef struct recursion_info {
   USPTR save_start;             /* Old value of mstart */
   int *offset_save;             /* Pointer to start of saved offsets */
   int saved_max;                /* Number of saved offsets */
+  int save_offset_top;          /* Current value of offset_top */
 } recursion_info;
 
 /* Structure for building a chain of data for holding the values of the subject
@@ -1589,6 +1617,9 @@ typedef struct match_data {
   int    offset_max;            /* The maximum usable for return data */
   int    nltype;                /* Newline type */
   int    nllen;                 /* Newline string length */
+  int    name_count;            /* Number of names in name table */
+  int    name_entry_size;       /* Size of entry in names table */
+  uschar *name_table;           /* Table of names */
   uschar nl[4];                 /* Newline string when fixed */
   const uschar *lcc;            /* Points to lower casing table */
   const uschar *ctypes;         /* Points to table of type maps */
@@ -1599,7 +1630,7 @@ typedef struct match_data {
   BOOL   jscript_compat;        /* JAVASCRIPT_COMPAT flag */
   BOOL   endonly;               /* Dollar not before final \n */
   BOOL   notempty;              /* Empty string match not wanted */
-  BOOL   partial;               /* PARTIAL flag */
+  BOOL   notempty_atstart;      /* Empty string match at start not wanted */
   BOOL   hitend;                /* Hit the end of the subject at some point */
   BOOL   bsr_anycrlf;           /* \R is just any CRLF, not full Unicode */
   const uschar *start_code;     /* For use when recursing */
@@ -1607,6 +1638,8 @@ typedef struct match_data {
   USPTR  end_subject;           /* End of the subject string */
   USPTR  start_match_ptr;       /* Start of matched string */
   USPTR  end_match_ptr;         /* Subject position at end match */
+  USPTR  start_used_ptr;        /* Earliest consulted character */
+  int    partial;               /* PARTIAL options */
   int    end_offset_top;        /* Highwater mark at end of match */
   int    capture_last;          /* Most recent capture number */
   int    start_offset;          /* The start offset value */
@@ -1623,7 +1656,9 @@ typedef struct dfa_match_data {
   const uschar *start_code;     /* Start of the compiled pattern */
   const uschar *start_subject;  /* Start of the subject string */
   const uschar *end_subject;    /* End of subject string */
+  const uschar *start_used_ptr; /* Earliest consulted character */
   const uschar *tables;         /* Character tables */
+  int   start_offset;           /* The start offset value */
   int   moptions;               /* Match options */
   int   poptions;               /* Pattern options */
   int    nltype;                /* Newline type */
@@ -1702,15 +1737,16 @@ extern const uschar _pcre_OP_lengths[];
 one of the exported public functions. They have to be "external" in the C
 sense, but are not part of the PCRE public API. */
 
-extern BOOL         _pcre_is_newline(const uschar *, int, const uschar *,
-                      int *, BOOL);
-extern int          _pcre_ord2utf8(int, uschar *);
-extern real_pcre   *_pcre_try_flipped(const real_pcre *, real_pcre *,
-                      const pcre_study_data *, pcre_study_data *);
-extern int          _pcre_valid_utf8(const uschar *, int);
-extern BOOL         _pcre_was_newline(const uschar *, int, const uschar *,
-                      int *, BOOL);
-extern BOOL         _pcre_xclass(int, const uschar *);
+extern const uschar *_pcre_find_bracket(const uschar *, BOOL, int);
+extern BOOL          _pcre_is_newline(const uschar *, int, const uschar *,
+                       int *, BOOL);
+extern int           _pcre_ord2utf8(int, uschar *);
+extern real_pcre    *_pcre_try_flipped(const real_pcre *, real_pcre *,
+                       const pcre_study_data *, pcre_study_data *);
+extern int           _pcre_valid_utf8(const uschar *, int);
+extern BOOL          _pcre_was_newline(const uschar *, int, const uschar *,
+                       int *, BOOL);
+extern BOOL          _pcre_xclass(int, const uschar *);
 
 
 /* Unicode character database (UCD) */
diff --git a/ext/pcre/pcrelib/pcre_printint.src b/ext/pcre/pcrelib/pcre_printint.src
index 5f45fc1..acfc4ca 100644
--- a/ext/pcre/pcrelib/pcre_printint.src
+++ b/ext/pcre/pcrelib/pcre_printint.src
@@ -246,7 +246,12 @@ for(;;)
     fprintf(f, "%s", OP_names[*code]);
     break;
 
+    case OP_CLOSE:
+    fprintf(f, "    %s %d", OP_names[*code], GET2(code, 1));
+    break;
+
     case OP_CREF:
+    case OP_NCREF:
     fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);
     break;
 
@@ -258,6 +263,14 @@ for(;;)
       fprintf(f, "    Cond recurse %d", c);
     break;
 
+    case OP_NRREF:
+    c = GET2(code, 1);
+    if (c == RREF_ANY)
+      fprintf(f, "    Cond nrecurse any");
+    else
+      fprintf(f, "    Cond nrecurse %d", c);
+    break;
+
     case OP_DEF:
     fprintf(f, "    Cond def");
     break;
diff --git a/ext/pcre/pcrelib/pcre_study.c b/ext/pcre/pcrelib/pcre_study.c
index 226cc65..a2e9f44 100644
--- a/ext/pcre/pcrelib/pcre_study.c
+++ b/ext/pcre/pcrelib/pcre_study.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-2008 University of Cambridge
+           Copyright (c) 1997-2009 University of Cambridge
 
 -----------------------------------------------------------------------------
 Redistribution and use in source and binary forms, with or without
@@ -52,6 +52,364 @@ supporting functions. */
 enum { SSB_FAIL, SSB_DONE, SSB_CONTINUE };
 
 
+
+/*************************************************
+*   Find the minimum subject length for a group  *
+*************************************************/
+
+/* Scan a parenthesized group and compute the minimum length of subject that
+is needed to match it. This is a lower bound; it does not mean there is a
+string of that length that matches. In UTF8 mode, the result is in characters
+rather than bytes.
+
+Arguments:
+  code       pointer to start of group (the bracket)
+  startcode  pointer to start of the whole pattern
+  options    the compiling options
+
+Returns:   the minimum length
+           -1 if \C was encountered
+           -2 internal error (missing capturing bracket)
+*/
+
+static int
+find_minlength(const uschar *code, const uschar *startcode, int options)
+{
+int length = -1;
+BOOL utf8 = (options & PCRE_UTF8) != 0;
+BOOL had_recurse = FALSE;
+register int branchlength = 0;
+register uschar *cc = (uschar *)code + 1 + LINK_SIZE;
+
+if (*code == OP_CBRA || *code == OP_SCBRA) cc += 2;
+
+/* Scan along the opcodes for this branch. If we get to the end of the
+branch, check the length against that of the other branches. */
+
+for (;;)
+  {
+  int d, min;
+  uschar *cs, *ce;
+  register int op = *cc;
+
+  switch (op)
+    {
+    case OP_CBRA:
+    case OP_SCBRA:
+    case OP_BRA:
+    case OP_SBRA:
+    case OP_ONCE:
+    case OP_COND:
+    case OP_SCOND:
+    d = find_minlength(cc, startcode, options);
+    if (d < 0) return d;
+    branchlength += d;
+    do cc += GET(cc, 1); while (*cc == OP_ALT);
+    cc += 1 + LINK_SIZE;
+    break;
+
+    /* Reached end of a branch; if it's a ket it is the end of a nested
+    call. If it's ALT it is an alternation in a nested call. If it is
+    END it's the end of the outer call. All can be handled by the same code. */
+
+    case OP_ALT:
+    case OP_KET:
+    case OP_KETRMAX:
+    case OP_KETRMIN:
+    case OP_END:
+    if (length < 0 || (!had_recurse && branchlength < length))
+      length = branchlength;
+    if (*cc != OP_ALT) return length;
+    cc += 1 + LINK_SIZE;
+    branchlength = 0;
+    had_recurse = FALSE;
+    break;
+
+    /* Skip over assertive subpatterns */
+
+    case OP_ASSERT:
+    case OP_ASSERT_NOT:
+    case OP_ASSERTBACK:
+    case OP_ASSERTBACK_NOT:
+    do cc += GET(cc, 1); while (*cc == OP_ALT);
+    /* Fall through */
+
+    /* Skip over things that don't match chars */
+
+    case OP_REVERSE:
+    case OP_CREF:
+    case OP_NCREF:
+    case OP_RREF:
+    case OP_NRREF:
+    case OP_DEF:
+    case OP_OPT:
+    case OP_CALLOUT:
+    case OP_SOD:
+    case OP_SOM:
+    case OP_EOD:
+    case OP_EODN:
+    case OP_CIRC:
+    case OP_DOLL:
+    case OP_NOT_WORD_BOUNDARY:
+    case OP_WORD_BOUNDARY:
+    cc += _pcre_OP_lengths[*cc];
+    break;
+
+    /* Skip over a subpattern that has a {0} or {0,x} quantifier */
+
+    case OP_BRAZERO:
+    case OP_BRAMINZERO:
+    case OP_SKIPZERO:
+    cc += _pcre_OP_lengths[*cc];
+    do cc += GET(cc, 1); while (*cc == OP_ALT);
+    cc += 1 + LINK_SIZE;
+    break;
+
+    /* Handle literal characters and + repetitions */
+
+    case OP_CHAR:
+    case OP_CHARNC:
+    case OP_NOT:
+    case OP_PLUS:
+    case OP_MINPLUS:
+    case OP_POSPLUS:
+    case OP_NOTPLUS:
+    case OP_NOTMINPLUS:
+    case OP_NOTPOSPLUS:
+    branchlength++;
+    cc += 2;
+#ifdef SUPPORT_UTF8
+    if (utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];
+#endif
+    break;
+
+    case OP_TYPEPLUS:
+    case OP_TYPEMINPLUS:
+    case OP_TYPEPOSPLUS:
+    branchlength++;
+    cc += (cc[1] == OP_PROP || cc[1] == OP_NOTPROP)? 4 : 2;
+    break;
+
+    /* Handle exact repetitions. The count is already in characters, but we
+    need to skip over a multibyte character in UTF8 mode.  */
+
+    case OP_EXACT:
+    case OP_NOTEXACT:
+    branchlength += GET2(cc,1);
+    cc += 4;
+#ifdef SUPPORT_UTF8
+    if (utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];
+#endif
+    break;
+
+    case OP_TYPEEXACT:
+    branchlength += GET2(cc,1);
+    cc += (cc[3] == OP_PROP || cc[3] == OP_NOTPROP)? 6 : 4;
+    break;
+
+    /* Handle single-char non-literal matchers */
+
+    case OP_PROP:
+    case OP_NOTPROP:
+    cc += 2;
+    /* Fall through */
+
+    case OP_NOT_DIGIT:
+    case OP_DIGIT:
+    case OP_NOT_WHITESPACE:
+    case OP_WHITESPACE:
+    case OP_NOT_WORDCHAR:
+    case OP_WORDCHAR:
+    case OP_ANY:
+    case OP_ALLANY:
+    case OP_EXTUNI:
+    case OP_HSPACE:
+    case OP_NOT_HSPACE:
+    case OP_VSPACE:
+    case OP_NOT_VSPACE:
+    branchlength++;
+    cc++;
+    break;
+
+    /* "Any newline" might match two characters */
+
+    case OP_ANYNL:
+    branchlength += 2;
+    cc++;
+    break;
+
+    /* The single-byte matcher means we can't proceed in UTF-8 mode */
+
+    case OP_ANYBYTE:
+#ifdef SUPPORT_UTF8
+    if (utf8) return -1;
+#endif
+    branchlength++;
+    cc++;
+    break;
+
+    /* For repeated character types, we have to test for \p and \P, which have
+    an extra two bytes of parameters. */
+
+    case OP_TYPESTAR:
+    case OP_TYPEMINSTAR:
+    case OP_TYPEQUERY:
+    case OP_TYPEMINQUERY:
+    case OP_TYPEPOSSTAR:
+    case OP_TYPEPOSQUERY:
+    if (cc[1] == OP_PROP || cc[1] == OP_NOTPROP) cc += 2;
+    cc += _pcre_OP_lengths[op];
+    break;
+
+    case OP_TYPEUPTO:
+    case OP_TYPEMINUPTO:
+    case OP_TYPEPOSUPTO:
+    if (cc[3] == OP_PROP || cc[3] == OP_NOTPROP) cc += 2;
+    cc += _pcre_OP_lengths[op];
+    break;
+
+    /* Check a class for variable quantification */
+
+#ifdef SUPPORT_UTF8
+    case OP_XCLASS:
+    cc += GET(cc, 1) - 33;
+    /* Fall through */
+#endif
+
+    case OP_CLASS:
+    case OP_NCLASS:
+    cc += 33;
+
+    switch (*cc)
+      {
+      case OP_CRPLUS:
+      case OP_CRMINPLUS:
+      branchlength++;
+      /* Fall through */
+
+      case OP_CRSTAR:
+      case OP_CRMINSTAR:
+      case OP_CRQUERY:
+      case OP_CRMINQUERY:
+      cc++;
+      break;
+
+      case OP_CRRANGE:
+      case OP_CRMINRANGE:
+      branchlength += GET2(cc,1);
+      cc += 5;
+      break;
+
+      default:
+      branchlength++;
+      break;
+      }
+    break;
+
+    /* Backreferences and subroutine calls are treated in the same way: we find
+    the minimum length for the subpattern. A recursion, however, causes an
+    a flag to be set that causes the length of this branch to be ignored. The
+    logic is that a recursion can only make sense if there is another
+    alternation that stops the recursing. That will provide the minimum length
+    (when no recursion happens). A backreference within the group that it is
+    referencing behaves in the same way.
+
+    If PCRE_JAVASCRIPT_COMPAT is set, a backreference to an unset bracket
+    matches an empty string (by default it causes a matching failure), so in
+    that case we must set the minimum length to zero. */
+
+    case OP_REF:
+    if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)
+      {
+      ce = cs = (uschar *)_pcre_find_bracket(startcode, utf8, GET2(cc, 1));
+      if (cs == NULL) return -2;
+      do ce += GET(ce, 1); while (*ce == OP_ALT);
+      if (cc > cs && cc < ce)
+        {
+        d = 0;
+        had_recurse = TRUE;
+        }
+      else d = find_minlength(cs, startcode, options);
+      }
+    else d = 0;
+    cc += 3;
+
+    /* Handle repeated back references */
+
+    switch (*cc)
+      {
+      case OP_CRSTAR:
+      case OP_CRMINSTAR:
+      case OP_CRQUERY:
+      case OP_CRMINQUERY:
+      min = 0;
+      cc++;
+      break;
+
+      case OP_CRRANGE:
+      case OP_CRMINRANGE:
+      min = GET2(cc, 1);
+      cc += 5;
+      break;
+
+      default:
+      min = 1;
+      break;
+      }
+
+    branchlength += min * d;
+    break;
+
+    case OP_RECURSE:
+    cs = ce = (uschar *)startcode + GET(cc, 1);
+    if (cs == NULL) return -2;
+    do ce += GET(ce, 1); while (*ce == OP_ALT);
+    if (cc > cs && cc < ce)
+      had_recurse = TRUE;
+    else
+      branchlength += find_minlength(cs, startcode, options);
+    cc += 1 + LINK_SIZE;
+    break;
+
+    /* Anything else does not or need not match a character. We can get the
+    item's length from the table, but for those that can match zero occurrences
+    of a character, we must take special action for UTF-8 characters. */
+
+    case OP_UPTO:
+    case OP_NOTUPTO:
+    case OP_MINUPTO:
+    case OP_NOTMINUPTO:
+    case OP_POSUPTO:
+    case OP_STAR:
+    case OP_MINSTAR:
+    case OP_NOTMINSTAR:
+    case OP_POSSTAR:
+    case OP_NOTPOSSTAR:
+    case OP_QUERY:
+    case OP_MINQUERY:
+    case OP_NOTMINQUERY:
+    case OP_POSQUERY:
+    case OP_NOTPOSQUERY:
+    cc += _pcre_OP_lengths[op];
+#ifdef SUPPORT_UTF8
+    if (utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];
+#endif
+    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. */
+
+    default:
+    cc += _pcre_OP_lengths[op];
+    break;
+    }
+  }
+/* Control never gets here */
+}
+
+
+
 /*************************************************
 *      Set a bit and maybe its alternate case    *
 *************************************************/
@@ -498,13 +856,15 @@ Arguments:
             set NULL unless error
 
 Returns:    pointer to a pcre_extra block, with study_data filled in and the
-              appropriate flag set;
+              appropriate flags set;
             NULL on error or if no optimization possible
 */
 
 PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION
 pcre_study(const pcre *external_re, int options, const char **errorptr)
 {
+int min;
+BOOL bits_set = FALSE;
 uschar start_bits[32];
 pcre_extra *extra;
 pcre_study_data *study;
@@ -531,30 +891,39 @@ code = (uschar *)re + re->name_table_offset +
   (re->name_count * re->name_entry_size);
 
 /* For an anchored pattern, or an unanchored pattern that has a first char, or
-a multiline pattern that matches only at "line starts", no further processing
-at present. */
+a multiline pattern that matches only at "line starts", there is no point in
+seeking a list of starting bytes. */
 
-if ((re->options & PCRE_ANCHORED) != 0 ||
-    (re->flags & (PCRE_FIRSTSET|PCRE_STARTLINE)) != 0)
-  return NULL;
+if ((re->options & PCRE_ANCHORED) == 0 &&
+    (re->flags & (PCRE_FIRSTSET|PCRE_STARTLINE)) == 0)
+  {
+  /* Set the character tables in the block that is passed around */
 
-/* Set the character tables in the block that is passed around */
+  tables = re->tables;
+  if (tables == NULL)
+    (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
+    (void *)(&tables));
 
-tables = re->tables;
-if (tables == NULL)
-  (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
-  (void *)(&tables));
+  compile_block.lcc = tables + lcc_offset;
+  compile_block.fcc = tables + fcc_offset;
+  compile_block.cbits = tables + cbits_offset;
+  compile_block.ctypes = tables + ctypes_offset;
 
-compile_block.lcc = tables + lcc_offset;
-compile_block.fcc = tables + fcc_offset;
-compile_block.cbits = tables + cbits_offset;
-compile_block.ctypes = tables + ctypes_offset;
+  /* See if we can find a fixed set of initial characters for the pattern. */
+
+  memset(start_bits, 0, 32 * sizeof(uschar));
+  bits_set = set_start_bits(code, start_bits,
+    (re->options & PCRE_CASELESS) != 0, (re->options & PCRE_UTF8) != 0,
+    &compile_block) == SSB_DONE;
+  }
 
-/* See if we can find a fixed set of initial characters for the pattern. */
+/* Find the minimum length of subject string. */
 
-memset(start_bits, 0, 32 * sizeof(uschar));
-if (set_start_bits(code, start_bits, (re->options & PCRE_CASELESS) != 0,
-  (re->options & PCRE_UTF8) != 0, &compile_block) != SSB_DONE) return NULL;
+min = find_minlength(code, code, re->options);
+
+/* Return NULL if no optimization is possible. */
+
+if (!bits_set && min < 0) return NULL;
 
 /* Get a pcre_extra block and a pcre_study_data block. The study data is put in
 the latter, which is pointed to by the former, which may also get additional
@@ -577,8 +946,19 @@ extra->flags = PCRE_EXTRA_STUDY_DATA;
 extra->study_data = study;
 
 study->size = sizeof(pcre_study_data);
-study->options = PCRE_STUDY_MAPPED;
-memcpy(study->start_bits, start_bits, sizeof(start_bits));
+study->flags = 0;
+
+if (bits_set)
+  {
+  study->flags |= PCRE_STUDY_MAPPED;
+  memcpy(study->start_bits, start_bits, sizeof(start_bits));
+  }
+
+if (min >= 0)
+  {
+  study->flags |= PCRE_STUDY_MINLEN;
+  study->minlength = min;
+  }
 
 return extra;
 }
diff --git a/ext/pcre/pcrelib/pcre_try_flipped.c b/ext/pcre/pcrelib/pcre_try_flipped.c
index 5e67943..91ec76a 100644
--- a/ext/pcre/pcrelib/pcre_try_flipped.c
+++ b/ext/pcre/pcrelib/pcre_try_flipped.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-2008 University of Cambridge
+           Copyright (c) 1997-2009 University of Cambridge
 
 -----------------------------------------------------------------------------
 Redistribution and use in source and binary forms, with or without
@@ -126,7 +126,9 @@ if (study != NULL)
   {
   *internal_study = *study;   /* To copy other fields */
   internal_study->size = byteflip(study->size, sizeof(study->size));
-  internal_study->options = byteflip(study->options, sizeof(study->options));
+  internal_study->flags = byteflip(study->flags, sizeof(study->flags));
+  internal_study->minlength = byteflip(study->minlength,
+    sizeof(study->minlength));
   }
 
 return internal_re;
diff --git a/ext/pcre/pcrelib/pcre_ucd.c b/ext/pcre/pcrelib/pcre_ucd.c
index 33394a0..0e4a422 100644
--- a/ext/pcre/pcrelib/pcre_ucd.c
+++ b/ext/pcre/pcrelib/pcre_ucd.c
@@ -1,9 +1,26 @@
 #include "config.h"
+
 #include "pcre_internal.h"
 
 /* Unicode character database. */
 /* This file was autogenerated by the MultiStage2.py script. */
 /* Total size: 52808 bytes, block size: 128. */
+
+/* The tables herein are needed only when UCP support is built */
+/* into PCRE. This module should not be referenced otherwise, so */
+/* it should not matter whether it is compiled or not. However */
+/* a comment was received about space saving - maybe the guy linked */
+/* all the modules rather than using a library - so we include a */
+/* condition to cut out the tables when not needed. But don't leave */
+/* a totally empty module because some compilers barf at that. */
+/* Instead, just supply small dummy tables. */
+
+#ifndef SUPPORT_UCP
+const ucd_record _pcre_ucd_records[] = {{0,0,0 }};
+const uschar _pcre_ucd_stage1[] = {0};
+const pcre_uint16 _pcre_ucd_stage2[] = {0};
+#else
+
 /* When recompiling tables with a new Unicode version,
 please check types in the structure definition from pcre_internal.h:
 typedef struct {
@@ -2606,3 +2623,4 @@ const pcre_uint16 _pcre_ucd_stage2[] = { /* 40448 bytes, block = 128 */
 #if UCD_BLOCK_SIZE != 128
 #error Please correct UCD_BLOCK_SIZE in pcre_internal.h
 #endif
+#endif  /* SUPPORT_UCP */
diff --git a/ext/pcre/pcrelib/pcredemo.c b/ext/pcre/pcrelib/pcredemo.c
index 3647568..c6ba56e 100644
--- a/ext/pcre/pcrelib/pcredemo.c
+++ b/ext/pcre/pcrelib/pcredemo.c
@@ -223,12 +223,12 @@ if (namecount <= 0) printf("No named substrings\n"); else
 *                                                                        *
 * If the previous match WAS for an empty string, we can't do that, as it *
 * would lead to an infinite loop. Instead, a special call of pcre_exec() *
-* is made with the PCRE_NOTEMPTY and PCRE_ANCHORED flags set. The first  *
-* of these tells PCRE that an empty string is not a valid match; other   *
-* possibilities must be tried. The second flag restricts PCRE to one     *
-* match attempt at the initial string position. If this match succeeds,  *
-* an alternative to the empty string match has been found, and we can    *
-* proceed round the loop.                                                *
+* is made with the PCRE_NOTEMPTY_ATSTART and PCRE_ANCHORED flags set.    *
+* The first of these tells PCRE that an empty string at the start of the *
+* subject is not a valid match; other possibilities must be tried. The   *
+* second flag restricts PCRE to one match attempt at the initial string  *
+* position. If this match succeeds, an alternative to the empty string   *
+* match has been found, and we can proceed round the loop.               *
 *************************************************************************/
 
 if (!find_all)
@@ -251,7 +251,7 @@ for (;;)
   if (ovector[0] == ovector[1])
     {
     if (ovector[0] == subject_length) break;
-    options = PCRE_NOTEMPTY | PCRE_ANCHORED;
+    options = PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED;
     }
 
   /* Run the next matching operation */
diff --git a/ext/pcre/pcrelib/pcreposix.c b/ext/pcre/pcrelib/pcreposix.c
index 645e060..1cc063d 100644
--- a/ext/pcre/pcrelib/pcreposix.c
+++ b/ext/pcre/pcrelib/pcreposix.c
@@ -68,64 +68,80 @@ static const int eint[] = {
   REG_EESCAPE, /* \c at end of pattern */
   REG_EESCAPE, /* unrecognized character follows \ */
   REG_BADBR,   /* numbers out of order in {} quantifier */
+  /* 5 */
   REG_BADBR,   /* number too big in {} quantifier */
   REG_EBRACK,  /* missing terminating ] for character class */
   REG_ECTYPE,  /* invalid escape sequence in character class */
   REG_ERANGE,  /* range out of order in character class */
   REG_BADRPT,  /* nothing to repeat */
+  /* 10 */
   REG_BADRPT,  /* operand of unlimited repeat could match the empty string */
   REG_ASSERT,  /* internal error: unexpected repeat */
   REG_BADPAT,  /* unrecognized character after (? */
   REG_BADPAT,  /* POSIX named classes are supported only within a class */
   REG_EPAREN,  /* missing ) */
+  /* 15 */
   REG_ESUBREG, /* reference to non-existent subpattern */
   REG_INVARG,  /* erroffset passed as NULL */
   REG_INVARG,  /* unknown option bit(s) set */
   REG_EPAREN,  /* missing ) after comment */
   REG_ESIZE,   /* parentheses nested too deeply */
+  /* 20 */
   REG_ESIZE,   /* regular expression too large */
   REG_ESPACE,  /* failed to get memory */
-  REG_EPAREN,  /* unmatched brackets */
+  REG_EPAREN,  /* unmatched parentheses */
   REG_ASSERT,  /* internal error: code overflow */
   REG_BADPAT,  /* unrecognized character after (?< */
+  /* 25 */
   REG_BADPAT,  /* lookbehind assertion is not fixed length */
   REG_BADPAT,  /* malformed number or name after (?( */
   REG_BADPAT,  /* conditional group contains more than two branches */
   REG_BADPAT,  /* assertion expected after (?( */
   REG_BADPAT,  /* (?R or (?[+-]digits must be followed by ) */
+  /* 30 */
   REG_ECTYPE,  /* unknown POSIX class name */
   REG_BADPAT,  /* POSIX collating elements are not supported */
   REG_INVARG,  /* this version of PCRE is not compiled with PCRE_UTF8 support */
   REG_BADPAT,  /* spare error */
   REG_BADPAT,  /* character value in \x{...} sequence is too large */
+  /* 35 */
   REG_BADPAT,  /* invalid condition (?(0) */
   REG_BADPAT,  /* \C not allowed in lookbehind assertion */
   REG_EESCAPE, /* PCRE does not support \L, \l, \N, \U, or \u */
   REG_BADPAT,  /* number after (?C is > 255 */
   REG_BADPAT,  /* closing ) for (?C expected */
+  /* 40 */
   REG_BADPAT,  /* recursive call could loop indefinitely */
   REG_BADPAT,  /* unrecognized character after (?P */
   REG_BADPAT,  /* syntax error in subpattern name (missing terminator) */
   REG_BADPAT,  /* two named subpatterns have the same name */
   REG_BADPAT,  /* invalid UTF-8 string */
+  /* 45 */
   REG_BADPAT,  /* support for \P, \p, and \X has not been compiled */
   REG_BADPAT,  /* malformed \P or \p sequence */
   REG_BADPAT,  /* unknown property name after \P or \p */
   REG_BADPAT,  /* subpattern name is too long (maximum 32 characters) */
   REG_BADPAT,  /* too many named subpatterns (maximum 10,000) */
+  /* 50 */
   REG_BADPAT,  /* repeated subpattern is too long */
   REG_BADPAT,  /* octal value is greater than \377 (not in UTF-8 mode) */
   REG_BADPAT,  /* internal error: overran compiling workspace */
   REG_BADPAT,  /* internal error: previously-checked referenced subpattern not found */
   REG_BADPAT,  /* DEFINE group contains more than one branch */
+  /* 55 */
   REG_BADPAT,  /* repeating a DEFINE group is not allowed */
   REG_INVARG,  /* inconsistent NEWLINE options */
   REG_BADPAT,  /* \g is not followed followed by an (optionally braced) non-zero number */
-  REG_BADPAT,  /* (?+ or (?- must be followed by a non-zero number */
+  REG_BADPAT,  /* a numbered reference must not be zero */
+  REG_BADPAT,  /* (*VERB) with an argument is not supported */
+  /* 60 */
+  REG_BADPAT,  /* (*VERB) not recognized */
   REG_BADPAT,  /* number is too big */
   REG_BADPAT,  /* subpattern name expected */
   REG_BADPAT,  /* digit expected after (?+ */
-  REG_BADPAT   /* ] is an invalid data character in JavaScript compatibility mode */
+  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 */
 };
 
 /* Table of texts corresponding to POSIX error codes */
@@ -224,17 +240,25 @@ int erroffset;
 int errorcode;
 int options = 0;
 
-if ((cflags & REG_ICASE) != 0)   options |= PCRE_CASELESS;
-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_ICASE) != 0)    options |= PCRE_CASELESS;
+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_UNGREEDY) != 0) options |= PCRE_UNGREEDY;
 
 preg->re_pcre = pcre_compile2(pattern, options, &errorcode, &errorptr,
   &erroffset, NULL);
 preg->re_erroffset = erroffset;
 
-if (preg->re_pcre == NULL) return eint[errorcode];
+/* Safety: if the error code is too big for the translation vector (which
+should not happen, but we all make mistakes), return REG_BADPAT. */
+
+if (preg->re_pcre == NULL)
+  {
+  return (errorcode < sizeof(eint)/sizeof(const int))?
+    eint[errorcode] : REG_BADPAT;
+  }
 
 preg->re_nsub = pcre_info((const pcre *)preg->re_pcre, NULL, NULL);
 return 0;
@@ -276,10 +300,11 @@ if ((eflags & REG_NOTEMPTY) != 0) options |= PCRE_NOTEMPTY;
 
 ((regex_t *)preg)->re_erroffset = (size_t)(-1);  /* Only has meaning after compile */
 
-/* When no string data is being returned, ensure that nmatch is zero.
-Otherwise, ensure the vector for holding the return data is large enough. */
+/* When no string data is being returned, or no vector has been passed in which
+to put it, ensure that nmatch is zero. Otherwise, ensure the vector for holding
+the return data is large enough. */
 
-if (nosub) nmatch = 0;
+if (nosub || pmatch == NULL) nmatch = 0;
 
 else if (nmatch > 0)
   {
diff --git a/ext/pcre/pcrelib/pcreposix.h b/ext/pcre/pcrelib/pcreposix.h
index 7c5af72..8ad58f5 100644
--- a/ext/pcre/pcrelib/pcreposix.h
+++ b/ext/pcre/pcrelib/pcreposix.h
@@ -50,17 +50,18 @@ POSSIBILITY OF SUCH DAMAGE.
 extern "C" {
 #endif
 
-/* Options, mostly defined by POSIX, but with a couple of extras. */
-
-#define REG_ICASE     0x0001
-#define REG_NEWLINE   0x0002
-#define REG_NOTBOL    0x0004
-#define REG_NOTEOL    0x0008
-#define REG_DOTALL    0x0010   /* NOT defined by POSIX. */
-#define REG_NOSUB     0x0020
-#define REG_UTF8      0x0040   /* NOT defined by POSIX. */
+/* Options, mostly defined by POSIX, but with some extras. */
+
+#define REG_ICASE     0x0001   /* Maps to PCRE_CASELESS */
+#define REG_NEWLINE   0x0002   /* Maps to PCRE_MULTILINE */
+#define REG_NOTBOL    0x0004   /* Maps to PCRE_NOTBOL */
+#define REG_NOTEOL    0x0008   /* Maps to PCRE_NOTEOL */
+#define REG_DOTALL    0x0010   /* NOT defined by POSIX; maps to PCRE_DOTALL */
+#define REG_NOSUB     0x0020   /* Maps to PCRE_NO_AUTO_CAPTURE */
+#define REG_UTF8      0x0040   /* NOT defined by POSIX; maps to PCRE_UTF8 */
 #define REG_STARTEND  0x0080   /* BSD feature: pass subject string by so,eo */
-#define REG_NOTEMPTY  0x0100   /* NOT defined by POSIX. */
+#define REG_NOTEMPTY  0x0100   /* NOT defined by POSIX; maps to PCRE_NOTEMPTY */
+#define REG_UNGREEDY  0x0200   /* NOT defined by POSIX; maps to PCRE_UNGREEDY */
 
 /* 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/grepoutput b/ext/pcre/pcrelib/testdata/grepoutput
index 882344e..da7a370 100644
--- a/ext/pcre/pcrelib/testdata/grepoutput
+++ b/ext/pcre/pcrelib/testdata/grepoutput
@@ -423,3 +423,27 @@ This time it jumps and jumps and jumps.
 Here is the pattern again.
 That time it was on a line by itself.
 This line contains pattern not on a line by itself.
+---------------------------- Test 55 -----------------------------
+./testdata/grepinput:456
+./testdata/grepinput8:0
+./testdata/grepinputv:1
+./testdata/grepinputx:0
+---------------------------- Test 56 -----------------------------
+./testdata/grepinput:456
+./testdata/grepinputv:1
+---------------------------- Test 57 -----------------------------
+PATTERN at the start of a line.
+In the middle of a line, PATTERN appears.
+Check up on PATTERN near the end.
+---------------------------- Test 58 -----------------------------
+PATTERN at the start of a line.
+In the middle of a line, PATTERN appears.
+Check up on PATTERN near the end.
+---------------------------- Test 59 -----------------------------
+PATTERN at the start of a line.
+In the middle of a line, PATTERN appears.
+Check up on PATTERN near the end.
+---------------------------- Test 60 -----------------------------
+PATTERN at the start of a line.
+In the middle of a line, PATTERN appears.
+Check up on PATTERN near the end.
diff --git a/ext/pcre/pcrelib/testdata/testinput1 b/ext/pcre/pcrelib/testdata/testinput1
index 8b0caa4..6cacbb5 100644
--- a/ext/pcre/pcrelib/testdata/testinput1
+++ b/ext/pcre/pcrelib/testdata/testinput1
@@ -1,3 +1,6 @@
+/-- This set of tests is for features that are compatible with all versions of
+    Perl 5, in non-UTF-8 mode. --/
+
 /the quick brown fox/
     the quick brown fox
     The quick brown FOX
@@ -4064,4 +4067,4 @@
 /^%((?(?=[a])[^%])|b)*%$/
     %ab%
 
-/ End of testinput1 /
+/-- End of testinput1 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput10 b/ext/pcre/pcrelib/testdata/testinput10
index 726a389..420c274 100644
--- a/ext/pcre/pcrelib/testdata/testinput10
+++ b/ext/pcre/pcrelib/testdata/testinput10
@@ -121,4 +121,4 @@ are all themselves checked in other tests. --/
 
 /[^\xaa]/8BM
 
-/ End of testinput10 /
+/-- End of testinput10 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput2 b/ext/pcre/pcrelib/testdata/testinput2
index beca157..3319bb7 100644
--- a/ext/pcre/pcrelib/testdata/testinput2
+++ b/ext/pcre/pcrelib/testdata/testinput2
@@ -1,3 +1,14 @@
+/-- This set of tests is not Perl-compatible. It checks on special features
+    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 
+    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. --/   
+
 /(a)b|/I
 
 /abc/I
@@ -123,38 +134,38 @@
     defabc
     \Zdefabc
 
-/abc/IP
+/abc/P
     abc
     *** Failers
 
-/^abc|def/IP
+/^abc|def/P
     abcdef
     abcdef\B
 
-/.*((abc)$|(def))/IP
+/.*((abc)$|(def))/P
     defabc
     \Zdefabc
 
-/the quick brown fox/IP
+/the quick brown fox/P
     the quick brown fox
     *** Failers
     The Quick Brown Fox
 
-/the quick brown fox/IPi
+/the quick brown fox/Pi
     the quick brown fox
     The Quick Brown Fox
 
-/abc.def/IP
+/abc.def/P
     *** Failers
     abc\ndef
 
-/abc$/IP
+/abc$/P
     abc
     abc\n
 
-/(abc)\2/IP
+/(abc)\2/P
 
-/(abc\1)/IP
+/(abc\1)/P
     abc
 
 /)/
@@ -593,7 +604,7 @@
     *** Failers
     \Nabc
 
-/a*(b+)(z)(z)/IP
+/a*(b+)(z)(z)/P
     aaaabbbbzzzz
     aaaabbbbzzzz\O0
     aaaabbbbzzzz\O1
@@ -1122,14 +1133,6 @@
 
 /(a(?1)+b)/DZ
 
-/^\W*(?:((.)\W*(?1)\W*\2|)|((.)\W*(?3)\W*\4|\W*.\W*))\W*$/Ii
-    1221
-    Satan, oscillate my metallic sonatas!
-    A man, a plan, a canal: Panama!
-    Able was I ere I saw Elba.
-    *** Failers
-    The quick brown fox
-
 /^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/I
     12
     (((2+2)*-3)-7)
@@ -1419,13 +1422,13 @@
     ** Failers
     line one\nthis is a line\nbreak in the second line
 
-/ab.cd/IP
+/ab.cd/P
     ab-cd
     ab=cd
     ** Failers
     ab\ncd
 
-/ab.cd/IPs
+/ab.cd/Ps
     ab-cd
     ab=cd
     ab\ncd
@@ -1480,10 +1483,10 @@
     (this)
     ((this))
 
-/a(b)c/IPN
+/a(b)c/PN
     abc
 
-/a(?P<name>b)c/IPN
+/a(?P<name>b)c/PN
     abc
 
 /\x{100}/I
@@ -1915,13 +1918,6 @@ a random value. /Ix
 /(?=(?'abc'\w+))\k<abc>:/I
     abcd:
 
-/(?'abc'\w+):\k<abc>{2}/
-    a:aaxyz
-    ab:ababxyz
-    ** Failers
-    a:axyz
-    ab:abxyz
-
 /(?'abc'a|b)(?<abc>d|e)\k<abc>{2}/J
     adaa
     ** Failers
@@ -1934,10 +1930,6 @@ a random value. /Ix
     ** Failers
     bddd
 
-/^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
-    abd
-    ce
-
 /(?(<bc))/
 
 /(?(''))/
@@ -1955,16 +1947,6 @@ a random value. /Ix
 /(?<1> (?'B' abc (?(R) (?(R&1)1) (?(R&B)2) X  |  (?1)  (?2)   (?R) ))) /x
     abcabc1Xabc2XabcXabcabc
 
-/^(?(DEFINE) (?<A> a) (?<B> b) )  (?&A) (?&B) /x
-    abcd
-
-/(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
-  (?(DEFINE)
-  (?<NAME_PAT>[a-z]+)
-  (?<ADDRESS_PAT>\d+)
-  )/x
-    metcalfe 33
-
 /^(?(DEFINE) abc | xyz ) /x
 
 /(?(DEFINE) abc) xyz/xI
@@ -2053,22 +2035,6 @@ a random value. /Ix
 /(?1)X(?<abc>P)/I
     abcPXP123
 
-/(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
-    1.2.3.4
-    131.111.10.206
-    10.0.0.0
-    ** Failers
-    10.6
-    455.3.4.5
-
-/\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
-    1.2.3.4
-    131.111.10.206
-    10.0.0.0
-    ** Failers
-    10.6
-    455.3.4.5
-
 /(?:a(?&abc)b)*(?<abc>x)/
     123axbaxbaxbx456
     123axbaxbaxb456
@@ -2090,9 +2056,6 @@ a random value. /Ix
    defabcabcxyz
    DEFabcABCXYZ
 
-/^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-02}Z/
-    ababababbbabZXXXX
-
 /^(a)\g-2/
 
 /^(a)\g/
@@ -2191,26 +2154,12 @@ a random value. /Ix
 /^(?(+1)X|Y)(.)/BZ
     Y!
 
-/(foo)\Kbar/
-    foobar
-   
-/(foo)(\Kbar|baz)/
-    foobar
-    foobaz 
-
-/(foo\Kbar)baz/
-    foobarbaz
-
 /(?<A>tom|bon)-\k{A}/
     tom-tom
     bon-bon 
     ** Failers
     tom-bon  
 
-/(?<A>tom|bon)-\g{A}/
-    tom-tom
-    bon-bon 
-    
 /\g{A/ 
 
 /(?|(abc)|(xyz))/BZ
@@ -2225,50 +2174,6 @@ a random value. /Ix
     xabcpqrx
     xxyzx 
 
-/(?|(abc)|(xyz))\1/
-    abcabc
-    xyzxyz 
-    ** Failers
-    abcxyz
-    xyzabc   
-    
-/(?|(abc)|(xyz))(?1)/
-    abcabc
-    xyzabc 
-    ** Failers 
-    xyzxyz 
- 
-/\H\h\V\v/
-    X X\x0a
-    X\x09X\x0b
-    ** Failers
-    \xa0 X\x0a   
-    
-/\H*\h+\V?\v{3,4}/ 
-    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
-    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
-    \x09\x20\xa0\x0a\x0b\x0c
-    ** Failers 
-    \x09\x20\xa0\x0a\x0b
-     
-/\H{3,4}/
-    XY  ABCDE
-    XY  PQR ST 
-    
-/.\h{3,4}./
-    XY  AB    PQRS
-
-/\h*X\h?\H+Y\H?Z/
-    >XNNNYZ
-    >  X NYQZ
-    ** Failers
-    >XYZ   
-    >  X NY Z
-
-/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
-    >XY\x0aZ\x0aA\x0bNN\x0c
-    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
-
 /[\h]/BZ
     >\x09<
 
@@ -2341,49 +2246,6 @@ a random value. /Ix
 
 /A(*PRUNE)B(*SKIP)C(*THEN)D(*COMMIT)E(*F)F(*FAIL)G(?!)H(*ACCEPT)I/BZ
 
-/^a+(*FAIL)/
-    aaaaaa
-    
-/a+b?c+(*FAIL)/
-    aaabccc
-
-/a+b?(*PRUNE)c+(*FAIL)/
-    aaabccc
-
-/a+b?(*COMMIT)c+(*FAIL)/
-    aaabccc
-    
-/a+b?(*SKIP)c+(*FAIL)/
-    aaabcccaaabccc
-
-/^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
-    aaaxxxxxx
-    aaa++++++ 
-    bbbxxxxx
-    bbb+++++ 
-    cccxxxx
-    ccc++++ 
-    dddddddd   
-
-/^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
-    aaaxxxxxx
-    aaa++++++ 
-    bbbxxxxx
-    bbb+++++ 
-    cccxxxx
-    ccc++++ 
-    dddddddd   
-
-/a+b?(*THEN)c+(*FAIL)/
-    aaabccc
-
-/(A (A|B(*ACCEPT)|C) D)(E)/x
-    ABX
-    AADE
-    ACDE
-    ** Failers
-    AD 
-        
 /^a+(*FAIL)/C
     aaaaaa
     
@@ -2589,66 +2451,8 @@ a random value. /Ix
 
 /[[:a\dz:]]/
 
-/^(?<name>a|b\g<name>c)/
-    aaaa
-    bacxxx
-    bbaccxxx 
-    bbbacccxx
-
-/^(?<name>a|b\g'name'c)/
-    aaaa
-    bacxxx
-    bbaccxxx 
-    bbbacccxx
-
-/^(a|b\g<1>c)/
-    aaaa
-    bacxxx
-    bbaccxxx 
-    bbbacccxx
-
-/^(a|b\g'1'c)/
-    aaaa
-    bacxxx
-    bbaccxxx 
-    bbbacccxx
-
-/^(a|b\g'-1'c)/
-    aaaa
-    bacxxx
-    bbaccxxx 
-    bbbacccxx
-
-/(^(a|b\g<-1>c))/
-    aaaa
-    bacxxx
-    bbaccxxx 
-    bbbacccxx
-
 /(^(a|b\g<-1'c))/
 
-/(^(a|b\g{-1}))/
-    bacxxx
-
-/(?-i:\g<name>)(?i:(?<name>a))/
-    XaaX
-    XAAX 
-
-/(?i:\g<name>)(?-i:(?<name>a))/
-    XaaX
-    ** Failers 
-    XAAX 
-
-/(?-i:\g<+1>)(?i:(a))/
-    XaaX
-    XAAX 
-
-/(?=(?<regex>(?#simplesyntax)\$(?<name>[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(?:\[(?<index>[a-zA-Z0-9_\x{7f}-\x{ff}]+|\$\g<name>)\]|->\g<name>(\(.*?\))?)?|(?#simple syntax withbraces)\$\{(?:\g<name>(?<indices>\[(?:\g<index>|'(?:\\.|[^'\\])*'|"(?:\g<regex>|\\.|[^"\\])*")\])?|\g<complex>|\$\{\g<complex>\})\}|(?#complexsyntax)\{(?<complex>\$(?<segment>\g<name>(\g<indices>*|\(.*?\))?)(?:->\g<segment>)*|\$\g<complex>|\$\{\g<complex>\})\}))\{/
-
-/(?<n>a|b|c)\g<n>*/
-   abc
-   accccbbb 
-
 /^(?+1)(?<a>x|y){0}z/
     xzxx
     yzyy 
@@ -2755,22 +2559,614 @@ a random value. /Ix
 /^"((?(?=[a])[^"])|b)*"$/
     "ab"
 
-/^X(?5)(a)(?|(b)|(q))(c)(d)(Y)/
-    XYabcdY
-
 /^X(?5)(a)(?|(b)|(q))(c)(d)Y/
     XYabcdY
 
 /^X(?&N)(a)(?|(b)|(q))(c)(d)(?<N>Y)/
     XYabcdY
  
+/Xa{2,4}b/
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/Xa{2,4}?b/
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/Xa{2,4}+b/
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X\d{2,4}b/
+    X\P
+    X3\P
+    X33\P 
+    X333\P
+    X3333\P 
+    
+/X\d{2,4}?b/
+    X\P
+    X3\P
+    X33\P 
+    X333\P
+    X3333\P 
+    
+/X\d{2,4}+b/
+    X\P
+    X3\P
+    X33\P 
+    X333\P
+    X3333\P 
+    
+/X\D{2,4}b/
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X\D{2,4}?b/
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X\D{2,4}+b/
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X[abc]{2,4}b/
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X[abc]{2,4}?b/
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X[abc]{2,4}+b/
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X[^a]{2,4}b/
+    X\P
+    Xz\P
+    Xzz\P 
+    Xzzz\P
+    Xzzzz\P 
+    
+/X[^a]{2,4}?b/
+    X\P
+    Xz\P
+    Xzz\P 
+    Xzzz\P
+    Xzzzz\P 
+    
+/X[^a]{2,4}+b/
+    X\P
+    Xz\P
+    Xzz\P 
+    Xzzz\P
+    Xzzzz\P 
+    
+/(Y)X\1{2,4}b/
+    YX\P
+    YXY\P
+    YXYY\P 
+    YXYYY\P
+    YXYYYY\P 
+    
+/(Y)X\1{2,4}?b/
+    YX\P
+    YXY\P
+    YXYY\P 
+    YXYYY\P
+    YXYYYY\P 
+    
+/(Y)X\1{2,4}+b/
+    YX\P
+    YXY\P
+    YXYY\P 
+    YXYYY\P
+    YXYYYY\P 
+    
+/\++\KZ|\d+X|9+Y/
+    ++++123999\P
+    ++++123999Y\P
+    ++++Z1234\P 
+
+/Z(*F)/
+    Z\P
+    ZA\P 
+    
+/Z(?!)/
+    Z\P 
+    ZA\P 
+
+/dog(sbody)?/
+    dogs\P
+    dogs\P\P 
+    
+/dog(sbody)??/
+    dogs\P
+    dogs\P\P 
+
+/dog|dogsbody/
+    dogs\P
+    dogs\P\P 
+ 
+/dogsbody|dog/
+    dogs\P
+    dogs\P\P 
+
+/\bthe cat\b/
+    the cat\P
+    the cat\P\P
+
+/abc/
+   abc\P
+   abc\P\P
+   
+/\w+A/P
+   CDAAAAB 
+
+/\w+A/PU
+   CDAAAAB 
+
+/abc\K123/
+    xyzabc123pqr
+    xyzabc12\P
+    xyzabc12\P\P
+    
+/(?<=abc)123/
+    xyzabc123pqr 
+    xyzabc12\P
+    xyzabc12\P\P
+
+/\babc\b/
+    +++abc+++
+    +++ab\P
+    +++ab\P\P  
+
+/(?&word)(?&element)(?(DEFINE)(?<element><[^m][^>]>[^<])(?<word>\w*+))/BZ
+
+/(?&word)(?&element)(?(DEFINE)(?<element><[^\d][^>]>[^<])(?<word>\w*+))/BZ
+
+/(ab)(x(y)z(cd(*ACCEPT)))pq/BZ
+
+/abc\K/+
+    abcdef
+    abcdef\N\N
+    xyzabcdef\N\N
+    ** Failers
+    abcdef\N 
+    xyzabcdef\N
+    
+/^(?:(?=abc)|abc\K)/+
+    abcdef
+    abcdef\N\N 
+    ** Failers 
+    abcdef\N 
+
+/a?b?/+
+    xyz
+    xyzabc
+    xyzabc\N
+    xyzabc\N\N
+    xyz\N\N    
+    ** Failers 
+    xyz\N 
+
+/^a?b?/+
+    xyz
+    xyzabc
+    ** Failers 
+    xyzabc\N
+    xyzabc\N\N
+    xyz\N\N    
+    xyz\N 
+    
+/^(?<name>a|b\g<name>c)/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/^(?<name>a|b\g'name'c)/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/^(a|b\g<1>c)/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/^(a|b\g'1'c)/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/^(a|b\g'-1'c)/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/(^(a|b\g<-1>c))/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/(?-i:\g<name>)(?i:(?<name>a))/
+    XaaX
+    XAAX 
+
+/(?i:\g<name>)(?-i:(?<name>a))/
+    XaaX
+    ** Failers 
+    XAAX 
+
+/(?-i:\g<+1>)(?i:(a))/
+    XaaX
+    XAAX 
+
+/(?=(?<regex>(?#simplesyntax)\$(?<name>[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(?:\[(?<index>[a-zA-Z0-9_\x{7f}-\x{ff}]+|\$\g<name>)\]|->\g<name>(\(.*?\))?)?|(?#simple syntax withbraces)\$\{(?:\g<name>(?<indices>\[(?:\g<index>|'(?:\\.|[^'\\])*'|"(?:\g<regex>|\\.|[^"\\])*")\])?|\g<complex>|\$\{\g<complex>\})\}|(?#complexsyntax)\{(?<complex>\$(?<segment>\g<name>(\g<indices>*|\(.*?\))?)(?:->\g<segment>)*|\$\g<complex>|\$\{\g<complex>\})\}))\{/
+
+/(?<n>a|b|c)\g<n>*/
+   abc
+   accccbbb 
+
 /^X(?7)(a)(?|(b)|(q)(r)(s))(c)(d)(Y)/
     XYabcdY
 
-/^X(?7)(a)(?|(b|(r)(s))|(q))(c)(d)(Y)/
-    XYabcdY
+/(?<=b(?1)|zzz)(a)/
+    xbaax
+    xzzzax 
+
+/(a)(?<=b\1)/
+
+/(a)(?<=b+(?1))/
+
+/(a+)(?<=b(?1))/
+
+/(a(?<=b(?1)))/
+
+/(?<=b(?1))xyz/
+
+/(?<=b(?1))xyz(b+)pqrstuvew/
+
+/(a|bc)\1/SI
+
+/(a|bc)\1{2,3}/SI
+
+/(a|bc)(?1)/SI
+
+/(a|b\1)(a|b\1)/SI
+
+/(a|b\1){2}/SI
+
+/(a|bbbb\1)(a|bbbb\1)/SI
+
+/(a|bbbb\1){2}/SI
+
+/^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/SI
+
+/  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                          # optional leading comment
+(?:    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+# address
+|                     #  or
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)             # one word, optionally followed by....
+(?:
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]  |  # atom and space parts, or...
+\(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)       |  # comments, or...
+
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+# quoted strings
+)*
+<  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                     # leading <
+(?:  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  ,  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+)* # further okay, if led by comma
+:                                # closing colon
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  )? #       optional route
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+#       address spec
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  > #                  trailing >
+# name and address
+)  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                       # optional trailing comment
+/xSI
+
+/<tr([\w\W\s\d][^<>]{0,})><TD([\w\W\s\d][^<>]{0,})>([\d]{0,}\.)(.*)((<BR>([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/isIS
+
+"(?>.*/)foo"SI
+
+/(?(?=[^a-z]+[a-z])  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} ) /xSI
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/iSI
+
+/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/SI
+
+/<a[\s]+href[\s]*=[\s]*          # find <a href=
+ ([\"\'])?                       # find single or double quote
+ (?(1) (.*?)\1 | ([^\s]+))       # if quote found, match up to next matching
+                                 # quote, otherwise match up to next space
+/isxSI
+
+/^(?!:)                       # colon disallowed at start
+  (?:                         # start of item
+    (?: [0-9a-f]{1,4} |       # 1-4 hex digits or
+    (?(1)0 | () ) )           # if null previously matched, fail; else null
+    :                         # followed by colon
+  ){1,7}                      # end item; 1-7 of them required               
+  [0-9a-f]{1,4} $             # final hex number at end of string
+  (?(1)|.)                    # check that there was an empty component
+  /xiIS
+
+/(?|(?<a>A)|(?<a>B))/I
+    AB\Ca
+    BA\Ca
+
+/(?|(?<a>A)|(?<b>B))/ 
+
+/(?:a(?<quote> (?<apostrophe>')|(?<realquote>")) |
+    b(?<quote> (?<apostrophe>')|(?<realquote>")) ) 
+    (?('quote')[a-z]+|[0-9]+)/JIx
+    a"aaaaa
+    b"aaaaa 
+    ** Failers 
+    b"11111
+    a"11111 
+    
+/^(?|(a)(b)(c)(?<D>d)|(?<D>e)) (?('D')X|Y)/JDZx
+    abcdX
+    eX
+    ** Failers
+    abcdY
+    ey     
+    
+/(?<A>a) (b)(c)  (?<A>d  (?(R&A)$ | (?4)) )/JDZx
+    abcdd
+    ** Failers
+    abcdde  
+
+/abcd*/
+    xxxxabcd\P
+    xxxxabcd\P\P
+
+/abcd*/i
+    xxxxabcd\P
+    xxxxabcd\P\P
+    XXXXABCD\P
+    XXXXABCD\P\P
+
+/abc\d*/
+    xxxxabc1\P
+    xxxxabc1\P\P
+
+/(a)bc\1*/
+    xxxxabca\P
+    xxxxabca\P\P
+
+/abc[de]*/
+    xxxxabcde\P
+    xxxxabcde\P\P
+
+/-- This is not in the Perl 5.10 test because Perl seems currently to be broken
+    and not behaving as specified in that it *does* bumpalong after hitting
+    (*COMMIT). --/ 
+
+/(?1)(A(*COMMIT)|B)D/
+    ABD
+    XABD
+    BAD
+    ABXABD  
+    ** Failers 
+    ABX 
+    BAXBAD  
 
-/^X(?7)(a)(?|(b|(?|(r)|(t))(s))|(q))(c)(d)(Y)/
-    XYabcdY
+/(\3)(\1)(a)/<JS>
+    cat
+
+/(\3)(\1)(a)/SI<JS>
+    cat
+
+/(\3)(\1)(a)/SI
+    cat
 
-/ End of testinput2 /
+/-- End of testinput2 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput3 b/ext/pcre/pcrelib/testdata/testinput3
index 1376c21..6fea2f5 100644
--- a/ext/pcre/pcrelib/testdata/testinput3
+++ b/ext/pcre/pcrelib/testdata/testinput3
@@ -1,3 +1,7 @@
+/-- This set of tests checks local-specific features, using the fr_FR locale. 
+    It is not Perl-compatible. There is different version called wintestinput3
+  f  or use on Windows, where the locale is called "french". --/
+
 /^[\w]+/
     *** Failers
     École
@@ -88,4 +92,4 @@
     
 /[[:alpha:]][[:lower:]][[:upper:]]/DZLfr_FR 
 
-/ End of testinput3 /
+/-- End of testinput3 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput4 b/ext/pcre/pcrelib/testdata/testinput4
index e5f6194..12f4c7e 100644
--- a/ext/pcre/pcrelib/testdata/testinput4
+++ b/ext/pcre/pcrelib/testdata/testinput4
@@ -1,7 +1,6 @@
-/-- Do not use the \x{} construct except with patterns that have the --/
-/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/
-/-- that option is set. However, the latest Perls recognize them always. --/
-
+/-- This set of tests if for UTF-8 support, excluding Unicode properties. It is
+    compatible with all versions of Perl 5. --/
+   
 /a.b/8
     acb
     a\x7fb
@@ -623,4 +622,22 @@
 
 /(?i)[\xc3\xa9\xc3\xbd]|[\xc3\xa9\xc3\xbdA]/8
 
-/ End of testinput4 /
+/^[a\x{c0}]b/8
+    \x{c0}b
+    
+/^([a\x{c0}]*?)aa/8
+    a\x{c0}aaaa/ 
+
+/^([a\x{c0}]*?)aa/8
+    a\x{c0}aaaa/ 
+    a\x{c0}a\x{c0}aaa/ 
+
+/^([a\x{c0}]*)aa/8
+    a\x{c0}aaaa/ 
+    a\x{c0}a\x{c0}aaa/ 
+
+/^([a\x{c0}]*)a\x{c0}/8
+    a\x{c0}aaaa/ 
+    a\x{c0}a\x{c0}aaa/ 
+
+/-- End of testinput4 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput5 b/ext/pcre/pcrelib/testdata/testinput5
index 38e22b8..82818d7 100644
--- a/ext/pcre/pcrelib/testdata/testinput5
+++ b/ext/pcre/pcrelib/testdata/testinput5
@@ -1,3 +1,6 @@
+/-- This set of tests checks the API, internals, and non-Perl stuff for UTF-8
+    support, excluding Unicode properties. --/
+
 /\x{100}/8DZ
 
 /\x{1000}/8DZ
@@ -53,30 +56,6 @@
 /.{3,5}?/DZ8
     \x{212ab}\x{212ab}\x{212ab}\x{861}
 
-/-- These tests are here rather than in testinput4 because Perl 5.6 has some
-problems with UTF-8 support, in the area of \x{..} where the value is < 255. 
-It grumbles about invalid UTF-8 strings. --/
-
-/^[a\x{c0}]b/8
-    \x{c0}b
-    
-/^([a\x{c0}]*?)aa/8
-    a\x{c0}aaaa/ 
-
-/^([a\x{c0}]*?)aa/8
-    a\x{c0}aaaa/ 
-    a\x{c0}a\x{c0}aaa/ 
-
-/^([a\x{c0}]*)aa/8
-    a\x{c0}aaaa/ 
-    a\x{c0}a\x{c0}aaa/ 
-
-/^([a\x{c0}]*)a\x{c0}/8
-    a\x{c0}aaaa/ 
-    a\x{c0}a\x{c0}aaa/ 
-    
-/-- --/ 
-    
 /(?<=\C)X/8
     Should produce an error diagnostic
     
@@ -485,4 +464,282 @@ can't tell the difference.) --/
 
 /(*CRLF)(*UTF8)(*BSR_UNICODE)a\Rb/I
 
-/ End of testinput5 /
+/Xa{2,4}b/8
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/Xa{2,4}?b/8
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/Xa{2,4}+b/8
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X\x{123}{2,4}b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/X\x{123}{2,4}?b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/X\x{123}{2,4}+b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/X\x{123}{2,4}b/8
+    Xx\P
+    X\x{123}x\P
+    X\x{123}\x{123}x\P 
+    X\x{123}\x{123}\x{123}x\P
+    X\x{123}\x{123}\x{123}\x{123}x\P 
+    
+/X\x{123}{2,4}?b/8
+    Xx\P
+    X\x{123}x\P
+    X\x{123}\x{123}x\P 
+    X\x{123}\x{123}\x{123}x\P
+    X\x{123}\x{123}\x{123}\x{123}x\P 
+    
+/X\x{123}{2,4}+b/8
+    Xx\P
+    X\x{123}x\P
+    X\x{123}\x{123}x\P 
+    X\x{123}\x{123}\x{123}x\P
+    X\x{123}\x{123}\x{123}\x{123}x\P 
+    
+/X\d{2,4}b/8
+    X\P
+    X3\P
+    X33\P 
+    X333\P
+    X3333\P 
+    
+/X\d{2,4}?b/8
+    X\P
+    X3\P
+    X33\P 
+    X333\P
+    X3333\P 
+    
+/X\d{2,4}+b/8
+    X\P
+    X3\P
+    X33\P 
+    X333\P
+    X3333\P 
+
+/X\D{2,4}b/8
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X\D{2,4}?b/8
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X\D{2,4}+b/8
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+
+/X\D{2,4}b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/X\D{2,4}?b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/X\D{2,4}+b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+
+/X[abc]{2,4}b/8
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X[abc]{2,4}?b/8
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+    
+/X[abc]{2,4}+b/8
+    X\P
+    Xa\P
+    Xaa\P 
+    Xaaa\P
+    Xaaaa\P 
+
+/X[abc\x{123}]{2,4}b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/X[abc\x{123}]{2,4}?b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/X[abc\x{123}]{2,4}+b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+
+/X[^a]{2,4}b/8
+    X\P
+    Xz\P
+    Xzz\P 
+    Xzzz\P
+    Xzzzz\P 
+    
+/X[^a]{2,4}?b/8
+    X\P
+    Xz\P
+    Xzz\P 
+    Xzzz\P
+    Xzzzz\P 
+    
+/X[^a]{2,4}+b/8
+    X\P
+    Xz\P
+    Xzz\P 
+    Xzzz\P
+    Xzzzz\P 
+
+/X[^a]{2,4}b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/X[^a]{2,4}?b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/X[^a]{2,4}+b/8
+    X\P
+    X\x{123}\P
+    X\x{123}\x{123}\P 
+    X\x{123}\x{123}\x{123}\P
+    X\x{123}\x{123}\x{123}\x{123}\P 
+
+/(Y)X\1{2,4}b/8
+    YX\P
+    YXY\P
+    YXYY\P 
+    YXYYY\P
+    YXYYYY\P 
+    
+/(Y)X\1{2,4}?b/8
+    YX\P
+    YXY\P
+    YXYY\P 
+    YXYYY\P
+    YXYYYY\P 
+    
+/(Y)X\1{2,4}+b/8
+    YX\P
+    YXY\P
+    YXYY\P 
+    YXYYY\P
+    YXYYYY\P 
+
+/(\x{123})X\1{2,4}b/8
+    \x{123}X\P
+    \x{123}X\x{123}\P
+    \x{123}X\x{123}\x{123}\P 
+    \x{123}X\x{123}\x{123}\x{123}\P
+    \x{123}X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/(\x{123})X\1{2,4}?b/8
+    \x{123}X\P
+    \x{123}X\x{123}\P
+    \x{123}X\x{123}\x{123}\P 
+    \x{123}X\x{123}\x{123}\x{123}\P
+    \x{123}X\x{123}\x{123}\x{123}\x{123}\P 
+    
+/(\x{123})X\1{2,4}+b/8
+    \x{123}X\P
+    \x{123}X\x{123}\P
+    \x{123}X\x{123}\x{123}\P 
+    \x{123}X\x{123}\x{123}\x{123}\P
+    \x{123}X\x{123}\x{123}\x{123}\x{123}\P 
+
+/\bthe cat\b/8
+    the cat\P
+    the cat\P\P
+
+/abcd*/8
+    xxxxabcd\P
+    xxxxabcd\P\P
+
+/abcd*/i8
+    xxxxabcd\P
+    xxxxabcd\P\P
+    XXXXABCD\P
+    XXXXABCD\P\P
+
+/abc\d*/8
+    xxxxabc1\P
+    xxxxabc1\P\P
+
+/(a)bc\1*/8
+    xxxxabca\P
+    xxxxabca\P\P
+
+/abc[de]*/8
+    xxxxabcde\P
+    xxxxabcde\P\P
+
+/-- End of testinput5 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput6 b/ext/pcre/pcrelib/testdata/testinput6
index 628646d..f4249da 100644
--- a/ext/pcre/pcrelib/testdata/testinput6
+++ b/ext/pcre/pcrelib/testdata/testinput6
@@ -1,3 +1,7 @@
+/-- This set of tests is for Unicode property support. It is compatible with
+    Perl 5.10, but not 5.8 because it tests some extra properties that are
+    not in the earlier release. --/ 
+
 /^\pC\pL\pM\pN\pP\pS\pZ</8
     \x7f\x{c0}\x{30f}\x{660}\x{66c}\x{f01}\x{1680}<
     \np\x{300}9!\$ < 
@@ -60,11 +64,6 @@
     ** Failers
     \x{09f} 
   
-/^\p{Cs}/8
-    \?\x{dfff}
-    ** Failers
-    \x{09f} 
-  
 /^\p{Ll}/8
     a
     ** Failers 
@@ -199,13 +198,6 @@
     }
     \x{f3b}
   
-/^\p{Sc}+/8
-    $\x{a2}\x{a3}\x{a4}\x{a5}\x{a6}
-    \x{9f2}
-    ** Failers
-    X
-    \x{2c2}
-  
 /^\p{Sk}/8
     \x{2c2}
     ** Failers
@@ -237,17 +229,6 @@
     X
     \x{2028}
   
-/^\p{Zs}/8
-    \ \
-    \x{a0}
-    \x{1680}
-    \x{180e}
-    \x{2000}
-    \x{2001}     
-    ** Failers
-    \x{2028}
-    \x{200d} 
-  
 /\p{Nd}+(..)/8
       \x{660}\x{661}\x{662}ABC
   
@@ -291,23 +272,6 @@
       ** Failers
       \x{660}\x{661}\x{662}ABC
   
-/\p{Lu}/8i
-    A
-    a\x{10a0}B 
-    ** Failers 
-    a
-    \x{1d00}  
-
-/\p{^Lu}/8i
-    1234
-    ** Failers
-    ABC 
-
-/\P{Lu}/8i
-    1234
-    ** Failers
-    ABC 
-
 /(?<=A\p{Nd})XYZ/8
     A2XYZ
     123A5XYZPQR
@@ -323,26 +287,6 @@
     ** Failers
     WXYZ 
 
-/[\p{L}]/DZ
-
-/[\p{^L}]/DZ
-
-/[\P{L}]/DZ
-
-/[\P{^L}]/DZ
-
-/[abc\p{L}\x{0660}]/8DZ
-
-/[\p{Nd}]/8DZ
-    1234
-
-/[\p{Nd}+-]+/8DZ
-    1234
-    12-34
-    12+\x{661}-34  
-    ** Failers
-    abcd  
-
 /[\P{Nd}]+/8
     abcd
     ** Failers
@@ -394,20 +338,6 @@
     ** Failers
     ABC   
 
-/\p{Ll}/8i 
-    a
-    Az
-    ** Failers
-    ABC   
-
-/^\x{c0}$/8i
-    \x{c0}
-    \x{e0} 
-
-/^\x{e0}$/8i
-    \x{c0}
-    \x{e0} 
-
 /A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8
     A\x{391}\x{10427}\x{ff3a}\x{1fb0}
     ** Failers
@@ -425,14 +355,6 @@
     A\x{391}\x{10427}\x{ff5a}\x{1fb0}
     A\x{391}\x{10427}\x{ff3a}\x{1fb8}
 
-/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iDZ
-
-/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8DZ
-
-/AB\x{1fb0}/8DZ
-
-/AB\x{1fb0}/8DZi
-
 /\x{391}+/8i
     \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
 
@@ -448,35 +370,6 @@
     \x{3b1}
     \x{ff5a}   
     
-/[\x{c0}\x{391}]/8i
-    \x{c0}
-    \x{e0} 
-
-/[\x{105}-\x{109}]/8iDZ
-    \x{104}
-    \x{105}
-    \x{109}  
-    ** Failers
-    \x{100}
-    \x{10a} 
-    
-/[z-\x{100}]/8iDZ 
-    Z
-    z
-    \x{39c}
-    \x{178}
-    |
-    \x{80}
-    \x{ff}
-    \x{100}
-    \x{101} 
-    ** Failers
-    \x{102}
-    Y
-    y           
-
-/[z-\x{100}]/8DZi
-
 /^\X/8
     A
     A\x{300}BC 
@@ -747,31 +640,9 @@
 /([\pL]=(abc))*X/
     L=abcX
 
-/The next two should be Perl-compatible, but it fails to match \x{e0}. PCRE
-will match it only with UCP support, because without that it has no notion
-of case for anything other than the ASCII letters. / 
-
-/((?i)[\x{c0}])/8
-    \x{c0}
-    \x{e0} 
-
-/(?i:[\x{c0}])/8
-    \x{c0}
-    \x{e0} 
-    
 /^\p{Balinese}\p{Cuneiform}\p{Nko}\p{Phags_Pa}\p{Phoenician}/8
     \x{1b00}\x{12000}\x{7c0}\x{a840}\x{10900}
 
-/The next two are special cases where the lengths of the different cases of the 
-same character differ. The first went wrong with heap frame storage; the 2nd
-was broken in all cases./
-
-/^\x{023a}+?(\x{0130}+)/8i
-  \x{023a}\x{2c65}\x{0130}
-  
-/^\x{023a}+([^X])/8i
-  \x{023a}\x{2c65}X
-
 /Check property support in non-UTF-8 mode/
  
 /\p{L}{4}/
@@ -790,48 +661,6 @@ was broken in all cases./
 /[\PPP\x8a]{1,}\x80/
     A\x80
 
-/(?:[\PPa*]*){8,}/
-
-/[\P{Any}]/BZ
-
-/[\P{Any}\E]/BZ
-
-/(\P{Yi}+\277)/
-
-/(\P{Yi}+\277)?/
-
-/(?<=\P{Yi}{3}A)X/
-
-/\p{Yi}+(\P{Yi}+)(?1)/
-
-/(\P{Yi}{2}\277)?/
-
-/[\P{Yi}A]/
-
-/[\P{Yi}\P{Yi}\P{Yi}A]/
-
-/[^\P{Yi}A]/
-
-/[^\P{Yi}\P{Yi}\P{Yi}A]/
-
-/(\P{Yi}*\277)*/
-
-/(\P{Yi}*?\277)*/
-
-/(\p{Yi}*+\277)*/
-
-/(\P{Yi}?\277)*/
-
-/(\P{Yi}??\277)*/
-
-/(\p{Yi}?+\277)*/
-
-/(\P{Yi}{0,3}\277)*/
-
-/(\P{Yi}{0,3}?\277)*/
-
-/(\p{Yi}{0,3}+\277)*/
-
 /^[\p{Arabic}]/8
     \x{60e} 
     \x{656} 
@@ -895,24 +724,6 @@ was broken in all cases./
     \x{1049f}
     \x{104aa}           
 
-/\p{Zl}{2,3}+/8BZ
-    \xe2\x80\xa8\xe2\x80\xa8
-    \x{2028}\x{2028}\x{2028}
-    
-/\p{Zl}/8BZ
-
-/\p{Lu}{3}+/8BZ
-
-/\pL{2}+/8BZ
-
-/\p{Cc}{2}+/8BZ
-
-/\x{c0}+\x{116}+/8i
-    \x{c0}\x{e0}\x{116}\x{117}
-
-/[\x{c0}\x{116}]+/8i
-    \x{c0}\x{e0}\x{116}\x{117}
-
 /\p{Carian}\p{Cham}\p{Kayah_Li}\p{Lepcha}\p{Lycian}\p{Lydian}\p{Ol_Chiki}\p{Rejang}\p{Saurashtra}\p{Sundanese}\p{Vai}/8
     \x{102A4}\x{AA52}\x{A91D}\x{1C46}\x{10283}\x{1092E}\x{1C6B}\x{A93B}\x{A8BF}\x{1BA0}\x{A50A}====
 
@@ -931,12 +742,6 @@ was broken in all cases./
     aa
     aA
 
-/(\x{de})\1/8i
-    \x{de}\x{de}
-    \x{de}\x{fe}
-    \x{fe}\x{fe}
-    \x{fe}\x{de}
-
 /(\x{10a})\1/8i
     \x{10a}\x{10a}
     \x{10a}\x{10b}
@@ -951,4 +756,4 @@ was broken in all cases./
 /[\p{Lu}\x20]+/
     \x41\x20\x50\xC2\x54\xC9\x20\x54\x4F\x44\x41\x59
 
-/ End of testinput6 /
+/-- End of testinput6 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput7 b/ext/pcre/pcrelib/testdata/testinput7
index 047a975..710d9ee 100644
--- a/ext/pcre/pcrelib/testdata/testinput7
+++ b/ext/pcre/pcrelib/testdata/testinput7
@@ -1,3 +1,6 @@
+/-- This set of tests check the DFA matching functionality of pcre_dfa_exec().
+    The -dfa flag must be used with pcretest when running it. --/
+     
 /abc/
     abc
     
@@ -4421,4 +4424,122 @@
     "ab"
     \C-"ab"
 
-/ End of testinput7 /
+/\d+X|9+Y/
+    ++++123999\P
+    ++++123999Y\P
+
+/Z(*F)/
+    Z\P
+    ZA\P 
+    
+/Z(?!)/
+    Z\P 
+    ZA\P 
+
+/dog(sbody)?/
+    dogs\P
+    dogs\P\P 
+    
+/dog(sbody)??/
+    dogs\P
+    dogs\P\P 
+
+/dog|dogsbody/
+    dogs\P
+    dogs\P\P 
+ 
+/dogsbody|dog/
+    dogs\P
+    dogs\P\P 
+
+/Z(*F)Q|ZXY/
+    Z\P
+    ZA\P 
+    X\P 
+
+/\bthe cat\b/
+    the cat\P
+    the cat\P\P
+
+/dog(sbody)?/
+    dogs\D\P
+    body\D\R
+
+/dog(sbody)?/
+    dogs\D\P\P
+    body\D\R
+
+/abc/
+   abc\P
+   abc\P\P
+
+/abc\K123/
+    xyzabc123pqr
+    
+/(?<=abc)123/
+    xyzabc123pqr 
+    xyzabc12\P
+    xyzabc12\P\P
+
+/\babc\b/
+    +++abc+++
+    +++ab\P
+    +++ab\P\P  
+
+/(?=C)/g+
+    ABCDECBA
+
+/(abc|def|xyz)/I
+    terhjk;abcdaadsfe
+    the quick xyz brown fox 
+    \Yterhjk;abcdaadsfe
+    \Ythe quick xyz brown fox 
+    ** Failers
+    thejk;adlfj aenjl;fda asdfasd ehj;kjxyasiupd
+    \Ythejk;adlfj aenjl;fda asdfasd ehj;kjxyasiupd
+
+/(abc|def|xyz)/SI
+    terhjk;abcdaadsfe
+    the quick xyz brown fox 
+    \Yterhjk;abcdaadsfe
+    \Ythe quick xyz brown fox 
+    ** Failers
+    thejk;adlfj aenjl;fda asdfasd ehj;kjxyasiupd
+    \Ythejk;adlfj aenjl;fda asdfasd ehj;kjxyasiupd
+
+/abcd*/+
+    xxxxabcd\P
+    xxxxabcd\P\P
+    dddxxx\R 
+    xxxxabcd\P\P
+    xxx\R 
+
+/abcd*/i
+    xxxxabcd\P
+    xxxxabcd\P\P
+    XXXXABCD\P
+    XXXXABCD\P\P
+
+/abc\d*/
+    xxxxabc1\P
+    xxxxabc1\P\P
+
+/abc[de]*/
+    xxxxabcde\P
+    xxxxabcde\P\P
+
+/(?:(?1)|B)(A(*F)|C)/
+    ABCD
+    CCD
+    ** Failers
+    CAD   
+
+/^(?:(?1)|B)(A(*F)|C)/
+    CCD
+    BCD 
+    ** Failers
+    ABCD
+    CAD
+    BAD    
+
+/-- End of testinput7 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput8 b/ext/pcre/pcrelib/testdata/testinput8
index 11884ad..1c6f684 100644
--- a/ext/pcre/pcrelib/testdata/testinput8
+++ b/ext/pcre/pcrelib/testdata/testinput8
@@ -1,6 +1,6 @@
-/-- Do not use the \x{} construct except with patterns that have the --/
-/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/
-/-- that option is set. However, the latest Perls recognize them always. --/
+/-- This set of tests checks UTF-8 support with the DFA matching functionality
+    of pcre_dfa_exec(). The -dfa flag must be used with pcretest when running 
+    it. --/
 
 /\x{100}ab/8
   \x{100}ab
@@ -667,4 +667,22 @@
 /X/8f<any> 
     A\x{1ec5}ABCXYZ
 
-/ End of testinput 8 / 
+/abcd*/8
+    xxxxabcd\P
+    xxxxabcd\P\P
+
+/abcd*/i8
+    xxxxabcd\P
+    xxxxabcd\P\P
+    XXXXABCD\P
+    XXXXABCD\P\P
+
+/abc\d*/8
+    xxxxabc1\P
+    xxxxabc1\P\P
+
+/abc[de]*/8
+    xxxxabcde\P
+    xxxxabcde\P\P
+
+/-- End of testinput8 --/ 
diff --git a/ext/pcre/pcrelib/testdata/testinput9 b/ext/pcre/pcrelib/testdata/testinput9
index ab04455..590420c 100644
--- a/ext/pcre/pcrelib/testdata/testinput9
+++ b/ext/pcre/pcrelib/testdata/testinput9
@@ -1,3 +1,7 @@
+/-- This set of tests check Unicode property support with the DFA matching 
+    functionality of pcre_dfa_exec(). The -dfa flag must be used with pcretest
+    when running it. --/
+
 /\pL\P{Nd}/8
     AB
     *** Failers
@@ -843,4 +847,4 @@
     ** Failers 
     \x{1d79}\x{a77d} 
 
-/ End / 
+/-- End of testinput9 --/ 
diff --git a/ext/pcre/pcrelib/testdata/testoutput1 b/ext/pcre/pcrelib/testdata/testoutput1
index 81b0cb8..a2a6dd4 100644
--- a/ext/pcre/pcrelib/testdata/testoutput1
+++ b/ext/pcre/pcrelib/testdata/testoutput1
@@ -1,3 +1,6 @@
+/-- This set of tests is for features that are compatible with all versions of
+    Perl 5, in non-UTF-8 mode. --/
+
 /the quick brown fox/
     the quick brown fox
  0: the quick brown fox
@@ -6646,4 +6649,4 @@ No match
  0: %ab%
  1: 
 
-/ End of testinput1 /
+/-- End of testinput1 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput10 b/ext/pcre/pcrelib/testdata/testoutput10
index 4eaaa39..a0db640 100644
--- a/ext/pcre/pcrelib/testdata/testoutput10
+++ b/ext/pcre/pcrelib/testdata/testoutput10
@@ -666,4 +666,4 @@ Memory allocation (code space): 40
  39     End
 ------------------------------------------------------------------
 
-/ End of testinput10 /
+/-- End of testinput10 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput2 b/ext/pcre/pcrelib/testdata/testoutput2
index 420e75d..30ea63b 100644
--- a/ext/pcre/pcrelib/testdata/testoutput2
+++ b/ext/pcre/pcrelib/testdata/testoutput2
@@ -1,3 +1,14 @@
+/-- This set of tests is not Perl-compatible. It checks on special features
+    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 
+    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. --/   
+
 /(a)b|/I
 Capturing subpattern count = 1
 No options
@@ -40,28 +51,24 @@ No match
 
 /a+bc/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'c'
 
 /a*bc/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 Need char = 'c'
 
 /a{3}bc/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'c'
 
 /(abc|a+z)/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 First char = 'a'
 No need char
@@ -113,14 +120,12 @@ Failed: unrecognized character after (? or (?- at offset 2
 
 /.*b/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char at start or follows newline
 Need char = 'b'
 
 /.*?b/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char at start or follows newline
 Need char = 'b'
@@ -140,6 +145,7 @@ Capturing subpattern count = 0
 No options
 No first char
 No need char
+Subject length lower bound = 3
 Starting byte set: c d e 
     this sentence eventually mentions a cat
  0: cat
@@ -151,6 +157,7 @@ Capturing subpattern count = 0
 Options: caseless
 No first char
 No need char
+Subject length lower bound = 3
 Starting byte set: C D E c d e 
     this sentence eventually mentions a CAT cat
  0: CAT
@@ -162,6 +169,7 @@ Capturing subpattern count = 0
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b c d 
 
 /(a|[^\dZ])/IS
@@ -169,6 +177,7 @@ Capturing subpattern count = 1
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: \x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0a 
   \x0b \x0c \x0d \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 
   \x1a \x1b \x1c \x1d \x1e \x1f \x20 ! " # $ % & ' ( ) * + , - . / : ; < = > 
@@ -189,6 +198,7 @@ Capturing subpattern count = 1
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: \x09 \x0a \x0c \x0d \x20 a b 
 
 /(ab\2)/
@@ -324,7 +334,6 @@ No need char
 
 /.*((abc)$|(def))/I
 Capturing subpattern count = 3
-Partial matching not supported
 No options
 First char at start or follows newline
 No need char
@@ -338,19 +347,19 @@ No need char
  2: <unset>
  3: def
 
-/abc/IP
+/abc/P
     abc
  0: abc
     *** Failers
 No match: POSIX code 17: match failed
 
-/^abc|def/IP
+/^abc|def/P
     abcdef
  0: abc
     abcdef\B
  0: def
 
-/.*((abc)$|(def))/IP
+/.*((abc)$|(def))/P
     defabc
  0: defabc
  1: abc
@@ -360,7 +369,7 @@ No match: POSIX code 17: match failed
  1: def
  3: def
 
-/the quick brown fox/IP
+/the quick brown fox/P
     the quick brown fox
  0: the quick brown fox
     *** Failers
@@ -368,28 +377,28 @@ No match: POSIX code 17: match failed
     The Quick Brown Fox
 No match: POSIX code 17: match failed
 
-/the quick brown fox/IPi
+/the quick brown fox/Pi
     the quick brown fox
  0: the quick brown fox
     The Quick Brown Fox
  0: The Quick Brown Fox
 
-/abc.def/IP
+/abc.def/P
     *** Failers
 No match: POSIX code 17: match failed
     abc\ndef
 No match: POSIX code 17: match failed
 
-/abc$/IP
+/abc$/P
     abc
  0: abc
     abc\n
  0: abc
 
-/(abc)\2/IP
+/(abc)\2/P
 Failed: POSIX code 15: bad back reference at offset 7     
 
-/(abc\1)/IP
+/(abc\1)/P
     abc
 No match: POSIX code 17: match failed
 
@@ -401,7 +410,6 @@ Failed: missing terminating ] for character class at offset 4
 
 /[^aeiou ]{3,}/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
@@ -410,7 +418,6 @@ No need char
 
 /<.*>/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = '<'
 Need char = '>'
@@ -419,7 +426,6 @@ Need char = '>'
 
 /<.*?>/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = '<'
 Need char = '>'
@@ -428,7 +434,6 @@ Need char = '>'
 
 /<.*>/IU
 Capturing subpattern count = 0
-Partial matching not supported
 Options: ungreedy
 First char = '<'
 Need char = '>'
@@ -437,7 +442,6 @@ Need char = '>'
 
 /(?U)<.*>/I
 Capturing subpattern count = 0
-Partial matching not supported
 Options: ungreedy
 First char = '<'
 Need char = '>'
@@ -446,7 +450,6 @@ Need char = '>'
 
 /<.*?>/IU
 Capturing subpattern count = 0
-Partial matching not supported
 Options: ungreedy
 First char = '<'
 Need char = '>'
@@ -455,7 +458,6 @@ Need char = '>'
 
 /={3,}/IU
 Capturing subpattern count = 0
-Partial matching not supported
 Options: ungreedy
 First char = '='
 Need char = '='
@@ -464,7 +466,6 @@ Need char = '='
 
 /(?U)={3,}?/I
 Capturing subpattern count = 0
-Partial matching not supported
 Options: ungreedy
 First char = '='
 Need char = '='
@@ -522,7 +523,6 @@ No need char
 
 /(?s).*/I
 Capturing subpattern count = 0
-Partial matching not supported
 Options: anchored dotall
 No first char
 No need char
@@ -532,6 +532,7 @@ Capturing subpattern count = 0
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b c d 
 
 /(?i)[abcd]/IS
@@ -539,6 +540,7 @@ Capturing subpattern count = 0
 Options: caseless
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: A B C D a b c d 
 
 /(?m)[xy]|(b|c)/IS
@@ -546,6 +548,7 @@ Capturing subpattern count = 1
 Options: multiline
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: b c x y 
 
 /(^a|^b)/Im
@@ -584,7 +587,6 @@ Failed: syntax error in subpattern name (missing terminator) at offset 7
 /((?s)blah)\s+\1/I
 Capturing subpattern count = 1
 Max back reference = 1
-Partial matching not supported
 No options
 First char = 'b'
 Need char = 'h'
@@ -592,7 +594,6 @@ Need char = 'h'
 /((?i)blah)\s+\1/I
 Capturing subpattern count = 1
 Max back reference = 1
-Partial matching not supported
 No options
 First char = 'b' (caseless)
 Need char = 'h' (caseless)
@@ -612,14 +613,15 @@ Capturing subpattern count = 1
 No options
 First char = 'b' (caseless)
 No need char
-Study returned NULL
+Subject length lower bound = 1
+No set of starting bytes
 
 /(a*b|(?i:c*(?-i)d))/IS
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: C a b c d 
 
 /a$/I
@@ -668,7 +670,6 @@ Need char = 'c'
 
 /^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/I
 Capturing subpattern count = 5
-Partial matching not supported
 Options: anchored
 No first char
 No need char
@@ -685,6 +686,7 @@ Capturing subpattern count = 0
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b 
 
 /(?<!foo)(alpha|omega)/IS
@@ -692,6 +694,7 @@ Capturing subpattern count = 1
 No options
 No first char
 Need char = 'a'
+Subject length lower bound = 5
 Starting byte set: a o 
 
 /(?!alphabet)[ab]/IS
@@ -699,6 +702,7 @@ Capturing subpattern count = 0
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b 
 
 /(?<=foo\n)^bar/Im
@@ -784,7 +788,6 @@ No need char
 
 /(?>.*)(?<=(abcd)|(xyz))/I
 Capturing subpattern count = 2
-Partial matching not supported
 No options
 First char at start or follows newline
 No need char
@@ -1003,7 +1006,6 @@ copy substring 5 failed -7
 
 /(.{20})/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
@@ -1021,7 +1023,6 @@ No need char
 
 /(.{15})/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
@@ -1036,7 +1037,6 @@ No need char
 
 /(.{16})/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
@@ -1103,7 +1103,6 @@ No need char
 )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
 )?)?)?)?)?)?)?)?)?otherword/I
 Capturing subpattern count = 8
-Partial matching not supported
 Contains explicit CR or LF match
 No options
 First char = 'w'
@@ -1118,7 +1117,6 @@ Need char = 'd'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char at start or follows newline
 Need char = 'X'
@@ -1132,7 +1130,6 @@ Need char = 'X'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: anchored dotall
 No first char
 Need char = 'X'
@@ -1151,7 +1148,6 @@ Need char = 'X'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 First char at start or follows newline
 No need char
@@ -1170,7 +1166,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 1
-Partial matching not supported
 Options: anchored dotall
 No first char
 No need char
@@ -1189,7 +1184,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 1
-Partial matching not supported
 Options: anchored dotall
 No first char
 No need char
@@ -1211,7 +1205,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: anchored
 No first char
 No need char
@@ -1296,7 +1289,6 @@ No need char
 
 /.*iss/Ig+
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char at start or follows newline
 Need char = 's'
@@ -1399,42 +1391,36 @@ Need char = 'c'
 
 /a*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
 
 /a+/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 No need char
 
 /(baa|a+)/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 Need char = 'a'
 
 /a{0,3}/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
 
 /baa{3,}/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'b'
 Need char = 'a'
 
 /"([^\\"]+|\\.)*"/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 First char = '"'
 Need char = '"'
@@ -1489,70 +1475,60 @@ Need char = 'b'
 
 /abc*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'b'
 
 /ab.c*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'b'
 
 /a.c*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 No need char
 
 /.c*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
 
 /ac*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 No need char
 
 /(a.c*|b.c*)/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
 
 /a.c*|aba/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 No need char
 
 /.+a/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 Need char = 'a'
 
 /(?=abcda)a.*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'a'
 
 /(?=a)a.*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 No need char
@@ -1565,14 +1541,12 @@ No need char
 
 /a\d*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 No need char
 
 /ab\d*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'b'
@@ -1591,7 +1565,6 @@ Need char = 'd'
 
 /ab\d+/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'b'
@@ -1666,7 +1639,7 @@ No need char
     \Nabc
 No match
 
-/a*(b+)(z)(z)/IP
+/a*(b+)(z)(z)/P
     aaaabbbbzzzz
  0: aaaabbbbzz
  1: bbbb
@@ -1698,7 +1671,8 @@ Capturing subpattern count = 0
 Options: anchored
 No first char
 Need char = 'd'
-Study returned NULL
+Subject length lower bound = 4
+No set of starting bytes
 
 /\(             # ( at start
   (?:           # Non-capturing bracket
@@ -1709,7 +1683,6 @@ Study returned NULL
   \)            # Closing )
   /Ix
 Capturing subpattern count = 0
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1738,7 +1711,6 @@ No match
 
 /\(  ( (?>[^()]+) | (?R) )* \) /Ixg
 Capturing subpattern count = 1
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1753,7 +1725,6 @@ Need char = ')'
 
 /\(  (?: (?>[^()]+) | (?R) ) \) /Ix
 Capturing subpattern count = 0
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1772,7 +1743,6 @@ No match
 
 /\(  (?: (?>[^()]+) | (?R) )? \) /Ix
 Capturing subpattern count = 0
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1783,7 +1753,6 @@ Need char = ')'
 
 /\(  ( (?>[^()]+) | (?R) )* \) /Ix
 Capturing subpattern count = 1
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1793,7 +1762,6 @@ Need char = ')'
 
 /\( ( ( (?>[^()]+) | (?R) )* ) \) /Ix
 Capturing subpattern count = 2
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1804,7 +1772,6 @@ Need char = ')'
 
 /\( (123)? ( ( (?>[^()]+) | (?R) )* ) \) /Ix
 Capturing subpattern count = 3
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1821,7 +1788,6 @@ Need char = ')'
 
 /\( ( (123)? ( (?>[^()]+) | (?R) )* ) \) /Ix
 Capturing subpattern count = 3
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1838,7 +1804,6 @@ Need char = ')'
 
 /\( (((((((((( ( (?>[^()]+) | (?R) )* )))))))))) \) /Ix
 Capturing subpattern count = 11
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1858,7 +1823,6 @@ Need char = ')'
 
 /\( ( ( (?>[^()<>]+) | ((?>[^()]+)) | (?R) )* ) \) /Ix
 Capturing subpattern count = 3
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1866,11 +1830,9 @@ Need char = ')'
  0: (abcd(xyz<p>qrs)123)
  1: abcd(xyz<p>qrs)123
  2: 123
- 3: <unset>
 
 /\( ( ( (?>[^()]+) | ((?R)) )* ) \) /Ix
 Capturing subpattern count = 3
-Partial matching not supported
 Options: extended
 First char = '('
 Need char = ')'
@@ -1942,6 +1904,7 @@ Capturing subpattern count = 0
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: 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 
 
@@ -2003,6 +1966,7 @@ Contains explicit CR or LF match
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: \x09 \x0a \x0b \x0c \x0d \x20 
 
 /^[[:cntrl:]]/DZ
@@ -2249,7 +2213,6 @@ Need char = 'd'
 /(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\w+)\s+(\270)/I
 Capturing subpattern count = 271
 Max back reference = 270
-Partial matching not supported
 No options
 No first char
 No need char
@@ -2930,7 +2893,6 @@ Need char = 'c'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
@@ -2959,7 +2921,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'x'
 No need char
@@ -2975,7 +2936,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'x'
 No need char
@@ -2999,7 +2959,6 @@ No need char
 
 /^(\w++|\s++)*$/I
 Capturing subpattern count = 1
-Partial matching not supported
 Options: anchored
 No first char
 No need char
@@ -3013,7 +2972,6 @@ No match
 
 /(\d++)(\w)/I
 Capturing subpattern count = 2
-Partial matching not supported
 No options
 No first char
 No need char
@@ -3028,7 +2986,6 @@ No match
 
 /a++b/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'b'
@@ -3037,7 +2994,6 @@ Need char = 'b'
 
 /(a++b)/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'b'
@@ -3047,7 +3003,6 @@ Need char = 'b'
 
 /(a++)b/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'b'
@@ -3057,7 +3012,6 @@ Need char = 'b'
 
 /([^()]++|\([^()]*\))+/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
@@ -3067,7 +3021,6 @@ No need char
 
 /\(([^()]++|\([^()]+\))+\)/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 First char = '('
 Need char = ')'
@@ -3130,7 +3083,6 @@ Failed: nothing to repeat at offset 7
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'x'
 Need char = 'b'
@@ -3147,7 +3099,6 @@ Need char = 'b'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: ungreedy
 First char = 'x'
 Need char = 'b'
@@ -3176,7 +3127,6 @@ Need char = 'b'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 5
-Partial matching not supported
 Options: anchored
 No first char
 No need char
@@ -3192,7 +3142,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: anchored
 No first char
 Need char = 'b'
@@ -3210,7 +3159,6 @@ Need char = 'b'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 1
-Partial matching not supported
 Options: anchored
 No first char
 Need char = 'b'
@@ -3286,7 +3234,6 @@ No need char
 
 /< (?: (?(R) \d++  | [^<>]*+) | (?R)) * >/Ix
 Capturing subpattern count = 0
-Partial matching not supported
 Options: extended
 First char = '<'
 Need char = '>'
@@ -3336,14 +3283,12 @@ Need char = 'X'
 /(.*)\d+\1/I
 Capturing subpattern count = 1
 Max back reference = 1
-Partial matching not supported
 No options
 No first char
 No need char
 
 /(.*)\d+/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 First char at start or follows newline
 No need char
@@ -3351,14 +3296,12 @@ No need char
 /(.*)\d+\1/Is
 Capturing subpattern count = 1
 Max back reference = 1
-Partial matching not supported
 Options: dotall
 No first char
 No need char
 
 /(.*)\d+/Is
 Capturing subpattern count = 1
-Partial matching not supported
 Options: anchored dotall
 No first char
 No need char
@@ -3366,7 +3309,6 @@ No need char
 /(.*(xyz))\d+\2/I
 Capturing subpattern count = 2
 Max back reference = 2
-Partial matching not supported
 No options
 First char at start or follows newline
 Need char = 'z'
@@ -3374,7 +3316,6 @@ Need char = 'z'
 /((.*))\d+\1/I
 Capturing subpattern count = 2
 Max back reference = 1
-Partial matching not supported
 No options
 No first char
 No need char
@@ -3391,7 +3332,6 @@ Need char = 'b'
 
 /(?=a).*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char = 'a'
 No need char
@@ -3497,6 +3437,7 @@ Capturing subpattern count = 0
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b 
 
 /[^a]/I
@@ -3516,6 +3457,7 @@ Capturing subpattern count = 0
 No options
 No first char
 Need char = '6'
+Subject length lower bound = 4
 Starting byte set: 0 1 2 3 4 5 6 7 8 9 
 
 /a^b/I
@@ -3549,6 +3491,7 @@ Capturing subpattern count = 0
 Options: caseless
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: A B a b 
 
 /[ab](?i)cd/IS
@@ -3556,6 +3499,7 @@ Capturing subpattern count = 0
 No options
 No first char
 Need char = 'd' (caseless)
+Subject length lower bound = 3
 Starting byte set: a b 
 
 /abc(?C)def/I
@@ -3713,7 +3657,6 @@ No need char
 
 /(\d{3}(?C))*/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
@@ -3842,7 +3785,6 @@ Callout 0: last capture = 1
 
 /a(b+)(c*)(?C1)/I
 Capturing subpattern count = 2
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'b'
@@ -3868,7 +3810,6 @@ No match
 
 /a(b+?)(c*?)(?C1)/I
 Capturing subpattern count = 2
-Partial matching not supported
 No options
 First char = 'a'
 Need char = 'b'
@@ -3909,6 +3850,7 @@ Capturing subpattern count = 0
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b 
 
 /(?R)/I
@@ -4028,43 +3970,8 @@ No options
 First char = 'a'
 Need char = 'b'
 
-/^\W*(?:((.)\W*(?1)\W*\2|)|((.)\W*(?3)\W*\4|\W*.\W*))\W*$/Ii
-Capturing subpattern count = 4
-Max back reference = 4
-Partial matching not supported
-Options: anchored caseless
-No first char
-No need char
-    1221
- 0: 1221
- 1: 1221
- 2: 1
-    Satan, oscillate my metallic sonatas!
- 0: Satan, oscillate my metallic sonatas!
- 1: <unset>
- 2: <unset>
- 3: Satan, oscillate my metallic sonatas
- 4: S
-    A man, a plan, a canal: Panama!
- 0: A man, a plan, a canal: Panama!
- 1: <unset>
- 2: <unset>
- 3: A man, a plan, a canal: Panama
- 4: A
-    Able was I ere I saw Elba.
- 0: Able was I ere I saw Elba.
- 1: <unset>
- 2: <unset>
- 3: Able was I ere I saw Elba
- 4: A
-    *** Failers
-No match
-    The quick brown fox
-No match
-
 /^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/I
 Capturing subpattern count = 2
-Partial matching not supported
 Options: anchored
 No first char
 No need char
@@ -4105,7 +4012,6 @@ No match
 
 /((< (?: (?(R) \d++  | [^<>]*+) | (?2)) * >))/Ix
 Capturing subpattern count = 2
-Partial matching not supported
 Options: extended
 First char = '<'
 Need char = '>'
@@ -4279,7 +4185,6 @@ Named capturing subpatterns:
   one     1
   three   3
   two     2
-Partial matching not supported
 Options: anchored caseless
 No first char
 No need char
@@ -4325,7 +4230,6 @@ No need char
 
 /(.*)a/Is
 Capturing subpattern count = 1
-Partial matching not supported
 Options: anchored dotall
 No first char
 Need char = 'a'
@@ -4333,7 +4237,6 @@ Need char = 'a'
 /(.*)a\1/Is
 Capturing subpattern count = 1
 Max back reference = 1
-Partial matching not supported
 Options: dotall
 No first char
 Need char = 'a'
@@ -4341,14 +4244,12 @@ Need char = 'a'
 /(.*)a(b)\2/Is
 Capturing subpattern count = 2
 Max back reference = 2
-Partial matching not supported
 Options: anchored dotall
 No first char
 Need char = 'b'
 
 /((.*)a|(.*)b)z/Is
 Capturing subpattern count = 3
-Partial matching not supported
 Options: anchored dotall
 No first char
 Need char = 'z'
@@ -4356,7 +4257,6 @@ Need char = 'z'
 /((.*)a|(.*)b)z\1/Is
 Capturing subpattern count = 3
 Max back reference = 1
-Partial matching not supported
 Options: dotall
 No first char
 Need char = 'z'
@@ -4364,7 +4264,6 @@ Need char = 'z'
 /((.*)a|(.*)b)z\2/Is
 Capturing subpattern count = 3
 Max back reference = 2
-Partial matching not supported
 Options: dotall
 No first char
 Need char = 'z'
@@ -4372,7 +4271,6 @@ Need char = 'z'
 /((.*)a|(.*)b)z\3/Is
 Capturing subpattern count = 3
 Max back reference = 3
-Partial matching not supported
 Options: dotall
 No first char
 Need char = 'z'
@@ -4380,14 +4278,12 @@ Need char = 'z'
 /((.*)a|^(.*)b)z\3/Is
 Capturing subpattern count = 3
 Max back reference = 3
-Partial matching not supported
 Options: anchored dotall
 No first char
 Need char = 'z'
 
 /(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a/Is
 Capturing subpattern count = 31
-Partial matching not supported
 Options: anchored dotall
 No first char
 No need char
@@ -4395,7 +4291,6 @@ No need char
 /(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\31/Is
 Capturing subpattern count = 31
 Max back reference = 31
-Partial matching not supported
 Options: dotall
 No first char
 No need char
@@ -4403,7 +4298,6 @@ No need char
 /(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\32/Is
 Capturing subpattern count = 32
 Max back reference = 32
-Partial matching not supported
 Options: dotall
 No first char
 No need char
@@ -4470,7 +4364,6 @@ Need char = 'c'
 
 /(a+)*zz/I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 Need char = 'z'
@@ -4607,7 +4500,6 @@ Failed: two named subpatterns have the same name at offset 30
 Capturing subpattern count = 3
 Named capturing subpatterns:
   elem   2
-Partial matching not supported
 No options
 First char = '['
 Need char = ']'
@@ -4625,7 +4517,6 @@ No match
 Capturing subpattern count = 3
 Named capturing subpatterns:
   elem   2
-Partial matching not supported
 No options
 First char = '['
 Need char = ']'
@@ -4732,7 +4623,6 @@ No need char
 
 /((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)/Ii
 Capturing subpattern count = 3
-Partial matching not supported
 Options: caseless
 No first char
 Need char = 'g' (caseless)
@@ -4742,11 +4632,11 @@ Need char = 'g' (caseless)
 
 /((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)/IiS
 Capturing subpattern count = 3
-Partial matching not supported
 Options: caseless
 No first char
 Need char = 'g' (caseless)
-Study returned NULL
+Subject length lower bound = 8
+No set of starting bytes
      Baby Bjorn Active Carrier - With free SHIPPING!!
  0: Baby Bjorn Active Carrier - With free SHIPPING!!
  1: Baby Bjorn Active Carrier - With free SHIPPING!!
@@ -4761,11 +4651,11 @@ Study returned NULL
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 Need char = 'b'
-Study returned NULL
+Subject length lower bound = 1
+No set of starting bytes
 
 /(a|b)*.?c/ISDZ
 ------------------------------------------------------------------
@@ -4785,7 +4675,8 @@ Capturing subpattern count = 1
 No options
 No first char
 Need char = 'c'
-Study returned NULL
+Subject length lower bound = 1
+No set of starting bytes
 
 /abc(?C255)de(?C)f/DZ
 ------------------------------------------------------------------
@@ -4854,7 +4745,6 @@ No match
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options:
 No first char
 Need char = 'b'
@@ -4899,7 +4789,6 @@ Need char = 'b'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options:
 First char = 'a'
 Need char = 'b'
@@ -5337,7 +5226,6 @@ No match
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 1
-Partial matching not supported
 Options:
 No first char
 Need char = '3'
@@ -5369,7 +5257,6 @@ Need char = '3'
 
 /\b.*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
@@ -5378,7 +5265,6 @@ No need char
 
 /\b.*/Is
 Capturing subpattern count = 0
-Partial matching not supported
 Options: dotall
 No first char
 No need char
@@ -5387,7 +5273,6 @@ No need char
 
 /(?!.bcd).*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
@@ -5400,15 +5285,15 @@ No options
 First char = 'a'
 Need char = 'e'
     ab\P
-Partial match
+Partial match: ab
     abc\P
-Partial match
+Partial match: abc
     abcd\P
-Partial match
+Partial match: abcd
     abcde\P
  0: abcde
     the quick brown abc\P
-Partial match
+Partial match: abc
     ** Failers\P
 No match
     the quick brown abxyz fox\P
@@ -5433,23 +5318,23 @@ Need char = '/'
  1: 02
  2: 05
     1\P
-Partial match
+Partial match: 1
     1/2\P
-Partial match
+Partial match: 1/2
     1/2/0\P
-Partial match
+Partial match: 1/2/0
     1/2/04\P
  0: 1/2/04
  1: 1
  2: 2
     0\P
-Partial match
+Partial match: 0
     02/\P
-Partial match
+Partial match: 02/
     02/0\P
-Partial match
+Partial match: 02/0
     02/1\P
-Partial match
+Partial match: 02/1
     ** Failers\P
 No match
     \P
@@ -5471,28 +5356,24 @@ No match
 
 /0{0,2}ABC/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 Need char = 'C'
 
 /\d{3,}ABC/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 Need char = 'C'
 
 /\d*ABC/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 Need char = 'C'
 
 /[abc]+DE/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 Need char = 'E'
@@ -5505,13 +5386,13 @@ Need char = '3'
     123\P
  0: 123
     a\P
-Partial match
+Partial match: a
     b\P
-Partial match
+Partial match: b
     c\P
-Partial match
+Partial match: c
     c12\P
-Partial match
+Partial match: c12
     c123\P
  0: c123
 
@@ -5521,17 +5402,17 @@ Options: anchored
 No first char
 Need char = 'X'
     1\P
-Partial match
+Partial match: 1
     123\P
-Partial match
+Partial match: 123
     123X
  0: 123X
     1234\P
-Partial match
+Partial match: 1234
     1234X
  0: 1234X
     12345\P
-Partial match
+Partial match: 12345
     12345X
  0: 12345X
     *** Failers
@@ -5578,6 +5459,7 @@ Capturing subpattern count = 1
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b 
 Compiled regex written to testsavedregex
 Study data written to testsavedregex
@@ -5598,6 +5480,7 @@ Capturing subpattern count = 1
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b 
 Compiled regex written to testsavedregex
 Study data written to testsavedregex
@@ -5616,7 +5499,6 @@ No match
 ~<(\w+)/?>(.)*</(\1)>~smgI
 Capturing subpattern count = 3
 Max back reference = 1
-Partial matching not supported
 Options: multiline dotall
 First char = '<'
 Need char = '>'
@@ -5669,7 +5551,7 @@ No match
     line one\nthis is a line\nbreak in the second line
 No match
 
-/ab.cd/IP
+/ab.cd/P
     ab-cd
  0: ab-cd
     ab=cd
@@ -5679,7 +5561,7 @@ No match: POSIX code 17: match failed
     ab\ncd
 No match: POSIX code 17: match failed
 
-/ab.cd/IPs
+/ab.cd/Ps
     ab-cd
  0: ab-cd
     ab=cd
@@ -5923,7 +5805,6 @@ Matched, but too many substrings
 
 /[^()]*(?:\((?R)\)[^()]*)*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
@@ -5936,7 +5817,6 @@ No need char
 
 /[^()]*(?:\((?>(?R))\)[^()]*)*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
@@ -5947,7 +5827,6 @@ No need char
 
 /[^()]*(?:\((?R)\))*[^()]*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
@@ -5958,7 +5837,6 @@ No need char
 
 /(?:\((?R)\))*[^()]*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
@@ -5971,7 +5849,6 @@ No need char
 
 /(?:\((?R)\))|[^()]*/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
@@ -5984,11 +5861,11 @@ No need char
     ((this))
  0: ((this))
 
-/a(b)c/IPN
+/a(b)c/PN
     abc
 Matched with REG_NOSUB
 
-/a(?P<name>b)c/IPN
+/a(?P<name>b)c/PN
     abc
 Matched with REG_NOSUB
 
@@ -6313,10 +6190,10 @@ Failed: octal value is greater than \377 (not in UTF-8 mode) at offset 3
 
 /\s*,\s*/IS
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 Need char = ','
+Subject length lower bound = 1
 Starting byte set: \x09 \x0a \x0c \x0d \x20 , 
     \x0b,\x0b
  0: ,
@@ -6443,7 +6320,6 @@ Unknown newline type at: <bad>
 
 /.*/I<lf>
 Capturing subpattern count = 0
-Partial matching not supported
 Options:
 Forced newline sequence: LF
 First char at start or follows newline
@@ -6469,7 +6345,6 @@ No need char
 
 /\w+(.)(.)?def/Is
 Capturing subpattern count = 2
-Partial matching not supported
 Options: dotall
 No first char
 Need char = 'f'
@@ -6486,7 +6361,6 @@ Need char = 'f'
 
 +((?:\s|//.*\\n|/[*](?:\\n|.)*?[*]/)*)+I
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
@@ -6621,10 +6495,10 @@ No need char
 
 /(a*b|(?i:c*(?-i)d))/IS
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: C a b c d 
 
 /()[ab]xyz/IS
@@ -6632,6 +6506,7 @@ Capturing subpattern count = 1
 No options
 No first char
 Need char = 'z'
+Subject length lower bound = 4
 Starting byte set: a b 
 
 /(|)[ab]xyz/IS
@@ -6639,6 +6514,7 @@ Capturing subpattern count = 1
 No options
 No first char
 Need char = 'z'
+Subject length lower bound = 4
 Starting byte set: a b 
 
 /(|c)[ab]xyz/IS
@@ -6646,6 +6522,7 @@ Capturing subpattern count = 1
 No options
 No first char
 Need char = 'z'
+Subject length lower bound = 4
 Starting byte set: a b c 
 
 /(|c?)[ab]xyz/IS
@@ -6653,6 +6530,7 @@ Capturing subpattern count = 1
 No options
 No first char
 Need char = 'z'
+Subject length lower bound = 4
 Starting byte set: a b c 
 
 /(d?|c?)[ab]xyz/IS
@@ -6660,6 +6538,7 @@ Capturing subpattern count = 1
 No options
 No first char
 Need char = 'z'
+Subject length lower bound = 4
 Starting byte set: a b c d 
 
 /(d?|c)[ab]xyz/IS
@@ -6667,6 +6546,7 @@ Capturing subpattern count = 1
 No options
 No first char
 Need char = 'z'
+Subject length lower bound = 4
 Starting byte set: a b c d 
 
 /^a*b\d/DZ
@@ -6680,7 +6560,6 @@ Starting byte set: a b c d
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: anchored
 No first char
 Need char = 'b'
@@ -6696,7 +6575,6 @@ Need char = 'b'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: anchored
 No first char
 Need char = 'b'
@@ -6712,7 +6590,6 @@ Need char = 'b'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: anchored
 No first char
 Need char = 'b'
@@ -6728,7 +6605,6 @@ Need char = 'b'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: anchored
 No first char
 Need char = 'A'
@@ -6750,7 +6626,6 @@ No match
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: anchored caseless
 No first char
 Need char = 'A' (caseless)
@@ -6761,34 +6636,34 @@ Need char = 'A' (caseless)
 
 /(a*|b*)[cd]/IS
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b c d 
 
 /(a+|b*)[cd]/IS
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b c d 
 
 /(a*|b+)[cd]/IS
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a b c d 
 
 /(a+|b+)[cd]/IS
 Capturing subpattern count = 1
-Partial matching not supported
 No options
 No first char
 No need char
+Subject length lower bound = 2
 Starting byte set: a b 
 
 /((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
@@ -7594,7 +7469,7 @@ No match
         ^
         CBra 1
         Cond
-      2 Cond ref
+      2 Cond nref
         y
         Ket
         [()]
@@ -7660,7 +7535,6 @@ Named capturing subpatterns:
   one     1
   three   3
   two     2
-Partial matching not supported
 Options: anchored caseless
 No first char
 No need char
@@ -7694,7 +7568,6 @@ No match
 /(?=(\w+))\1:/I
 Capturing subpattern count = 1
 Max back reference = 1
-Partial matching not supported
 No options
 No first char
 Need char = ':'
@@ -7707,7 +7580,6 @@ Capturing subpattern count = 1
 Max back reference = 1
 Named capturing subpatterns:
   abc   1
-Partial matching not supported
 No options
 No first char
 Need char = ':'
@@ -7715,20 +7587,6 @@ Need char = ':'
  0: abcd:
  1: abcd
 
-/(?'abc'\w+):\k<abc>{2}/
-    a:aaxyz
- 0: a:aa
- 1: a
-    ab:ababxyz
- 0: ab:abab
- 1: ab
-    ** Failers
-No match
-    a:axyz
-No match
-    ab:abxyz
-No match
-
 /(?'abc'a|b)(?<abc>d|e)\k<abc>{2}/J
     adaa
  0: adaa
@@ -7755,13 +7613,6 @@ No match
     bddd
 No match
 
-/^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
-    abd
- 0: abd
- 1: a
-    ce
- 0: ce
-
 /(?(<bc))/
 Failed: malformed number or name after (?( at offset 6
 
@@ -7792,24 +7643,6 @@ Failed: reference to non-existent subpattern at offset 29
  1: abcabc1Xabc2XabcX
  2: abcabc1Xabc2XabcX
 
-/^(?(DEFINE) (?<A> a) (?<B> b) )  (?&A) (?&B) /x
-    abcd
- 0: ab
- 1: <unset>
- 2: <unset>
-
-/(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
-  (?(DEFINE)
-  (?<NAME_PAT>[a-z]+)
-  (?<ADDRESS_PAT>\d+)
-  )/x
-    metcalfe 33
- 0: metcalfe 33
- 1: metcalfe
- 2: 33
- 3: <unset>
- 4: <unset>
-
 /^(?(DEFINE) abc | xyz ) /x
 Failed: DEFINE group contains more than one branch at offset 22
 
@@ -7987,46 +7820,6 @@ Need char = 'P'
  0: PXP
  1: P
 
-/(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
-    1.2.3.4
- 0: 1.2.3.4
- 1: <unset>
- 2: .4
-    131.111.10.206
- 0: 131.111.10.206
- 1: <unset>
- 2: .206
-    10.0.0.0
- 0: 10.0.0.0
- 1: <unset>
- 2: .0
-    ** Failers
-No match
-    10.6
-No match
-    455.3.4.5
-No match
-
-/\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
-    1.2.3.4
- 0: 1.2.3.4
- 1: .4
- 2: <unset>
-    131.111.10.206
- 0: 131.111.10.206
- 1: .206
- 2: <unset>
-    10.0.0.0
- 0: 10.0.0.0
- 1: .0
- 2: <unset>
-    ** Failers
-No match
-    10.6
-No match
-    455.3.4.5
-No match
-
 /(?:a(?&abc)b)*(?<abc>x)/
     123axbaxbaxbx456
  0: axbaxbaxbx
@@ -8064,12 +7857,6 @@ No match
    DEFabcABCXYZ
 No match
 
-/^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-02}Z/
-    ababababbbabZXXXX
- 0: ababababbbabZ
- 1: ab
- 2: b
-
 /^(a)\g-2/
 Failed: reference to non-existent subpattern at offset 7
 
@@ -8325,26 +8112,6 @@ Failed: reference to non-existent subpattern at offset 7
  0: Y!
  1: !
 
-/(foo)\Kbar/
-    foobar
- 0: bar
- 1: foo
-   
-/(foo)(\Kbar|baz)/
-    foobar
- 0: bar
- 1: foo
- 2: bar
-    foobaz 
- 0: foobaz
- 1: foo
- 2: baz
-
-/(foo\Kbar)baz/
-    foobarbaz
- 0: barbaz
- 1: foobar
-
 /(?<A>tom|bon)-\k{A}/
     tom-tom
  0: tom-tom
@@ -8357,14 +8124,6 @@ No match
     tom-bon  
 No match
 
-/(?<A>tom|bon)-\g{A}/
-    tom-tom
- 0: tom-tom
- 1: tom
-    bon-bon 
- 0: bon-bon
- 1: bon
-    
 /\g{A/ 
 Failed: syntax error in subpattern name (missing terminator) at offset 4
 
@@ -8459,82 +8218,6 @@ Failed: syntax error in subpattern name (missing terminator) at offset 4
  3: <unset>
  4: x
 
-/(?|(abc)|(xyz))\1/
-    abcabc
- 0: abcabc
- 1: abc
-    xyzxyz 
- 0: xyzxyz
- 1: xyz
-    ** Failers
-No match
-    abcxyz
-No match
-    xyzabc   
-No match
-    
-/(?|(abc)|(xyz))(?1)/
-    abcabc
- 0: abcabc
- 1: abc
-    xyzabc 
- 0: xyzabc
- 1: xyz
-    ** Failers 
-No match
-    xyzxyz 
-No match
- 
-/\H\h\V\v/
-    X X\x0a
- 0: X X\x0a
-    X\x09X\x0b
- 0: X\x09X\x0b
-    ** Failers
-No match
-    \xa0 X\x0a   
-No match
-    
-/\H*\h+\V?\v{3,4}/ 
-    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
- 0: \x09 \xa0X\x0a\x0b\x0c\x0d
-    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
- 0: \x09 \xa0\x0a\x0b\x0c\x0d
-    \x09\x20\xa0\x0a\x0b\x0c
- 0: \x09 \xa0\x0a\x0b\x0c
-    ** Failers 
-No match
-    \x09\x20\xa0\x0a\x0b
-No match
-     
-/\H{3,4}/
-    XY  ABCDE
- 0: ABCD
-    XY  PQR ST 
- 0: PQR
-    
-/.\h{3,4}./
-    XY  AB    PQRS
- 0: B    P
-
-/\h*X\h?\H+Y\H?Z/
-    >XNNNYZ
- 0: XNNNYZ
-    >  X NYQZ
- 0:   X NYQZ
-    ** Failers
-No match
-    >XYZ   
-No match
-    >  X NY Z
-No match
-
-/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
-    >XY\x0aZ\x0aA\x0bNN\x0c
- 0: XY\x0aZ\x0aA\x0bNN\x0c
-    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
- 0: \x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
-
 /[\h]/BZ
 ------------------------------------------------------------------
         Bra
@@ -8831,87 +8514,6 @@ Failed: missing terminating ] for character class at offset 10
         End
 ------------------------------------------------------------------
 
-/^a+(*FAIL)/
-    aaaaaa
-No match
-    
-/a+b?c+(*FAIL)/
-    aaabccc
-No match
-
-/a+b?(*PRUNE)c+(*FAIL)/
-    aaabccc
-No match
-
-/a+b?(*COMMIT)c+(*FAIL)/
-    aaabccc
-No match
-    
-/a+b?(*SKIP)c+(*FAIL)/
-    aaabcccaaabccc
-No match
-
-/^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
-    aaaxxxxxx
- 0: aaaxxxxxx
-    aaa++++++ 
- 0: aaa
-    bbbxxxxx
- 0: bbbxxxxx
-    bbb+++++ 
- 0: bbb
-    cccxxxx
- 0: cccxxxx
-    ccc++++ 
- 0: ccc
-    dddddddd   
- 0: ddd
-
-/^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
-    aaaxxxxxx
- 0: aaaxxxxxx
- 1: aaaxxxxxx
-    aaa++++++ 
- 0: aaa
- 1: aaa
-    bbbxxxxx
- 0: bbbxxxxx
- 1: bbbxxxxx
-    bbb+++++ 
- 0: bbb
- 1: bbb
-    cccxxxx
- 0: cccxxxx
- 1: cccxxxx
-    ccc++++ 
- 0: ccc
- 1: ccc
-    dddddddd   
- 0: ddd
- 1: ddd
-
-/a+b?(*THEN)c+(*FAIL)/
-    aaabccc
-No match
-
-/(A (A|B(*ACCEPT)|C) D)(E)/x
-    ABX
- 0: AB
-    AADE
- 0: AADE
- 1: AAD
- 2: A
- 3: E
-    ACDE
- 0: ACDE
- 1: ACD
- 2: C
- 3: E
-    ** Failers
-No match
-    AD 
-No match
-        
 /^a+(*FAIL)/C
     aaaaaa
 --->aaaaaa
@@ -9216,7 +8818,6 @@ No match
     
 /a\R{2,4}b/I<bsr_anycrlf>
 Capturing subpattern count = 0
-Partial matching not supported
 Options: bsr_anycrlf
 First char = 'a'
 Need char = 'b'
@@ -9235,7 +8836,6 @@ No match
 
 /a\R{2,4}b/I<bsr_unicode>
 Capturing subpattern count = 0
-Partial matching not supported
 Options: bsr_unicode
 First char = 'a'
 Need char = 'b'
@@ -9385,143 +8985,14 @@ Failed: unknown POSIX class name at offset 6
 /[[:a\dz:]]/
 Failed: unknown POSIX class name at offset 3
 
-/^(?<name>a|b\g<name>c)/
-    aaaa
- 0: a
- 1: a
-    bacxxx
- 0: bac
- 1: bac
-    bbaccxxx 
- 0: bbacc
- 1: bbacc
-    bbbacccxx
- 0: bbbaccc
- 1: bbbaccc
-
-/^(?<name>a|b\g'name'c)/
-    aaaa
- 0: a
- 1: a
-    bacxxx
- 0: bac
- 1: bac
-    bbaccxxx 
- 0: bbacc
- 1: bbacc
-    bbbacccxx
- 0: bbbaccc
- 1: bbbaccc
-
-/^(a|b\g<1>c)/
-    aaaa
- 0: a
- 1: a
-    bacxxx
- 0: bac
- 1: bac
-    bbaccxxx 
- 0: bbacc
- 1: bbacc
-    bbbacccxx
- 0: bbbaccc
- 1: bbbaccc
-
-/^(a|b\g'1'c)/
-    aaaa
- 0: a
- 1: a
-    bacxxx
- 0: bac
- 1: bac
-    bbaccxxx 
- 0: bbacc
- 1: bbacc
-    bbbacccxx
- 0: bbbaccc
- 1: bbbaccc
-
-/^(a|b\g'-1'c)/
-    aaaa
- 0: a
- 1: a
-    bacxxx
- 0: bac
- 1: bac
-    bbaccxxx 
- 0: bbacc
- 1: bbacc
-    bbbacccxx
- 0: bbbaccc
- 1: bbbaccc
-
-/(^(a|b\g<-1>c))/
-    aaaa
- 0: a
- 1: a
- 2: a
-    bacxxx
- 0: bac
- 1: bac
- 2: bac
-    bbaccxxx 
- 0: bbacc
- 1: bbacc
- 2: bbacc
-    bbbacccxx
- 0: bbbaccc
- 1: bbbaccc
- 2: bbbaccc
-
 /(^(a|b\g<-1'c))/
 Failed: \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number at offset 15
 
-/(^(a|b\g{-1}))/
-    bacxxx
-No match
-
-/(?-i:\g<name>)(?i:(?<name>a))/
-    XaaX
- 0: aa
- 1: a
-    XAAX 
- 0: AA
- 1: A
-
-/(?i:\g<name>)(?-i:(?<name>a))/
-    XaaX
- 0: aa
- 1: a
-    ** Failers 
-No match
-    XAAX 
-No match
-
-/(?-i:\g<+1>)(?i:(a))/
-    XaaX
- 0: aa
- 1: a
-    XAAX 
- 0: AA
- 1: A
-
-/(?=(?<regex>(?#simplesyntax)\$(?<name>[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(?:\[(?<index>[a-zA-Z0-9_\x{7f}-\x{ff}]+|\$\g<name>)\]|->\g<name>(\(.*?\))?)?|(?#simple syntax withbraces)\$\{(?:\g<name>(?<indices>\[(?:\g<index>|'(?:\\.|[^'\\])*'|"(?:\g<regex>|\\.|[^"\\])*")\])?|\g<complex>|\$\{\g<complex>\})\}|(?#complexsyntax)\{(?<complex>\$(?<segment>\g<name>(\g<indices>*|\(.*?\))?)(?:->\g<segment>)*|\$\g<complex>|\$\{\g<complex>\})\}))\{/
-
-/(?<n>a|b|c)\g<n>*/
-   abc
- 0: abc
- 1: a
-   accccbbb 
- 0: accccbbb
- 1: a
-
 /^(?+1)(?<a>x|y){0}z/
     xzxx
  0: xz
- 1: <unset>
     yzyy 
  0: yz
- 1: <unset>
     ** Failers
 No match
     xxz  
@@ -9636,11 +9107,11 @@ Capturing subpattern count = 1
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: x y z 
 
 /(?(?=.*b)b|^)/CI
 Capturing subpattern count = 0
-Partial matching not supported
 Options:
 No first char
 No need char
@@ -9680,14 +9151,12 @@ No need char
    
 /(?(?=b).*b|^d)/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 No first char
 No need char
 
 /(?(?=.*b).*b|^d)/I
 Capturing subpattern count = 0
-Partial matching not supported
 No options
 First char at start or follows newline
 No need char
@@ -9786,15 +9255,6 @@ No match
  0: "ab"
  1: 
 
-/^X(?5)(a)(?|(b)|(q))(c)(d)(Y)/
-    XYabcdY
- 0: XYabcdY
- 1: a
- 2: b
- 3: c
- 4: d
- 5: Y
-
 /^X(?5)(a)(?|(b)|(q))(c)(d)Y/
 Failed: reference to non-existent subpattern at offset 5
 
@@ -9807,6 +9267,579 @@ Failed: reference to non-existent subpattern at offset 5
  4: d
  5: Y
  
+/Xa{2,4}b/
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/Xa{2,4}?b/
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/Xa{2,4}+b/
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X\d{2,4}b/
+    X\P
+Partial match: X
+    X3\P
+Partial match: X3
+    X33\P 
+Partial match: X33
+    X333\P
+Partial match: X333
+    X3333\P 
+Partial match: X3333
+    
+/X\d{2,4}?b/
+    X\P
+Partial match: X
+    X3\P
+Partial match: X3
+    X33\P 
+Partial match: X33
+    X333\P
+Partial match: X333
+    X3333\P 
+Partial match: X3333
+    
+/X\d{2,4}+b/
+    X\P
+Partial match: X
+    X3\P
+Partial match: X3
+    X33\P 
+Partial match: X33
+    X333\P
+Partial match: X333
+    X3333\P 
+Partial match: X3333
+    
+/X\D{2,4}b/
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X\D{2,4}?b/
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X\D{2,4}+b/
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X[abc]{2,4}b/
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X[abc]{2,4}?b/
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X[abc]{2,4}+b/
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X[^a]{2,4}b/
+    X\P
+Partial match: X
+    Xz\P
+Partial match: Xz
+    Xzz\P 
+Partial match: Xzz
+    Xzzz\P
+Partial match: Xzzz
+    Xzzzz\P 
+Partial match: Xzzzz
+    
+/X[^a]{2,4}?b/
+    X\P
+Partial match: X
+    Xz\P
+Partial match: Xz
+    Xzz\P 
+Partial match: Xzz
+    Xzzz\P
+Partial match: Xzzz
+    Xzzzz\P 
+Partial match: Xzzzz
+    
+/X[^a]{2,4}+b/
+    X\P
+Partial match: X
+    Xz\P
+Partial match: Xz
+    Xzz\P 
+Partial match: Xzz
+    Xzzz\P
+Partial match: Xzzz
+    Xzzzz\P 
+Partial match: Xzzzz
+    
+/(Y)X\1{2,4}b/
+    YX\P
+Partial match: YX
+    YXY\P
+Partial match: YXY
+    YXYY\P 
+Partial match: YXYY
+    YXYYY\P
+Partial match: YXYYY
+    YXYYYY\P 
+Partial match: YXYYYY
+    
+/(Y)X\1{2,4}?b/
+    YX\P
+Partial match: YX
+    YXY\P
+Partial match: YXY
+    YXYY\P 
+Partial match: YXYY
+    YXYYY\P
+Partial match: YXYYY
+    YXYYYY\P 
+Partial match: YXYYYY
+    
+/(Y)X\1{2,4}+b/
+    YX\P
+Partial match: YX
+    YXY\P
+Partial match: YXY
+    YXYY\P 
+Partial match: YXYY
+    YXYYY\P
+Partial match: YXYYY
+    YXYYYY\P 
+Partial match: YXYYYY
+    
+/\++\KZ|\d+X|9+Y/
+    ++++123999\P
+Partial match: 123999
+    ++++123999Y\P
+ 0: 999Y
+    ++++Z1234\P 
+ 0: Z
+
+/Z(*F)/
+    Z\P
+No match
+    ZA\P 
+No match
+    
+/Z(?!)/
+    Z\P 
+No match
+    ZA\P 
+No match
+
+/dog(sbody)?/
+    dogs\P
+ 0: dog
+    dogs\P\P 
+Partial match: dogs
+    
+/dog(sbody)??/
+    dogs\P
+ 0: dog
+    dogs\P\P 
+ 0: dog
+
+/dog|dogsbody/
+    dogs\P
+ 0: dog
+    dogs\P\P 
+ 0: dog
+ 
+/dogsbody|dog/
+    dogs\P
+ 0: dog
+    dogs\P\P 
+Partial match: dogs
+
+/\bthe cat\b/
+    the cat\P
+ 0: the cat
+    the cat\P\P
+Partial match: the cat
+
+/abc/
+   abc\P
+ 0: abc
+   abc\P\P
+ 0: abc
+   
+/\w+A/P
+   CDAAAAB 
+ 0: CDAAAA
+
+/\w+A/PU
+   CDAAAAB 
+ 0: CDA
+
+/abc\K123/
+    xyzabc123pqr
+ 0: 123
+    xyzabc12\P
+Partial match: abc12
+    xyzabc12\P\P
+Partial match: abc12
+    
+/(?<=abc)123/
+    xyzabc123pqr 
+ 0: 123
+    xyzabc12\P
+Partial match: abc12
+    xyzabc12\P\P
+Partial match: abc12
+
+/\babc\b/
+    +++abc+++
+ 0: abc
+    +++ab\P
+Partial match: +ab
+    +++ab\P\P  
+Partial match: +ab
+
+/(?&word)(?&element)(?(DEFINE)(?<element><[^m][^>]>[^<])(?<word>\w*+))/BZ
+------------------------------------------------------------------
+        Bra
+        Once
+        Recurse
+        Ket
+        Once
+        Recurse
+        Ket
+        Cond
+        Cond def
+        CBra 1
+        <
+        [^m]
+        [^>]
+        >
+        [^<]
+        Ket
+        CBra 2
+        \w*+
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
+/(?&word)(?&element)(?(DEFINE)(?<element><[^\d][^>]>[^<])(?<word>\w*+))/BZ
+------------------------------------------------------------------
+        Bra
+        Once
+        Recurse
+        Ket
+        Once
+        Recurse
+        Ket
+        Cond
+        Cond def
+        CBra 1
+        <
+        [\x00-/:-\xff] (neg)
+        [^>]
+        >
+        [^<]
+        Ket
+        CBra 2
+        \w*+
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
+/(ab)(x(y)z(cd(*ACCEPT)))pq/BZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        ab
+        Ket
+        CBra 2
+        x
+        CBra 3
+        y
+        Ket
+        z
+        CBra 4
+        cd
+        Close 4
+        Close 2
+        *ACCEPT
+        Ket
+        Ket
+        pq
+        Ket
+        End
+------------------------------------------------------------------
+
+/abc\K/+
+    abcdef
+ 0: 
+ 0+ def
+    abcdef\N\N
+ 0: 
+ 0+ def
+    xyzabcdef\N\N
+ 0: 
+ 0+ def
+    ** Failers
+No match
+    abcdef\N 
+No match
+    xyzabcdef\N
+No match
+    
+/^(?:(?=abc)|abc\K)/+
+    abcdef
+ 0: 
+ 0+ abcdef
+    abcdef\N\N 
+ 0: 
+ 0+ def
+    ** Failers 
+No match
+    abcdef\N 
+No match
+
+/a?b?/+
+    xyz
+ 0: 
+ 0+ xyz
+    xyzabc
+ 0: 
+ 0+ xyzabc
+    xyzabc\N
+ 0: ab
+ 0+ c
+    xyzabc\N\N
+ 0: 
+ 0+ yzabc
+    xyz\N\N    
+ 0: 
+ 0+ yz
+    ** Failers 
+ 0: 
+ 0+ ** Failers
+    xyz\N 
+No match
+
+/^a?b?/+
+    xyz
+ 0: 
+ 0+ xyz
+    xyzabc
+ 0: 
+ 0+ xyzabc
+    ** Failers 
+ 0: 
+ 0+ ** Failers
+    xyzabc\N
+No match
+    xyzabc\N\N
+No match
+    xyz\N\N    
+No match
+    xyz\N 
+No match
+    
+/^(?<name>a|b\g<name>c)/
+    aaaa
+ 0: a
+ 1: a
+    bacxxx
+ 0: bac
+ 1: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+
+/^(?<name>a|b\g'name'c)/
+    aaaa
+ 0: a
+ 1: a
+    bacxxx
+ 0: bac
+ 1: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+
+/^(a|b\g<1>c)/
+    aaaa
+ 0: a
+ 1: a
+    bacxxx
+ 0: bac
+ 1: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+
+/^(a|b\g'1'c)/
+    aaaa
+ 0: a
+ 1: a
+    bacxxx
+ 0: bac
+ 1: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+
+/^(a|b\g'-1'c)/
+    aaaa
+ 0: a
+ 1: a
+    bacxxx
+ 0: bac
+ 1: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+
+/(^(a|b\g<-1>c))/
+    aaaa
+ 0: a
+ 1: a
+ 2: a
+    bacxxx
+ 0: bac
+ 1: bac
+ 2: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+ 2: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+ 2: bbbaccc
+
+/(?-i:\g<name>)(?i:(?<name>a))/
+    XaaX
+ 0: aa
+ 1: a
+    XAAX 
+ 0: AA
+ 1: A
+
+/(?i:\g<name>)(?-i:(?<name>a))/
+    XaaX
+ 0: aa
+ 1: a
+    ** Failers 
+No match
+    XAAX 
+No match
+
+/(?-i:\g<+1>)(?i:(a))/
+    XaaX
+ 0: aa
+ 1: a
+    XAAX 
+ 0: AA
+ 1: A
+
+/(?=(?<regex>(?#simplesyntax)\$(?<name>[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(?:\[(?<index>[a-zA-Z0-9_\x{7f}-\x{ff}]+|\$\g<name>)\]|->\g<name>(\(.*?\))?)?|(?#simple syntax withbraces)\$\{(?:\g<name>(?<indices>\[(?:\g<index>|'(?:\\.|[^'\\])*'|"(?:\g<regex>|\\.|[^"\\])*")\])?|\g<complex>|\$\{\g<complex>\})\}|(?#complexsyntax)\{(?<complex>\$(?<segment>\g<name>(\g<indices>*|\(.*?\))?)(?:->\g<segment>)*|\$\g<complex>|\$\{\g<complex>\})\}))\{/
+
+/(?<n>a|b|c)\g<n>*/
+   abc
+ 0: abc
+ 1: a
+   accccbbb 
+ 0: accccbbb
+ 1: a
+
 /^X(?7)(a)(?|(b)|(q)(r)(s))(c)(d)(Y)/
     XYabcdY
  0: XYabcdY
@@ -9818,26 +9851,616 @@ Failed: reference to non-existent subpattern at offset 5
  6: d
  7: Y
 
-/^X(?7)(a)(?|(b|(r)(s))|(q))(c)(d)(Y)/
-    XYabcdY
- 0: XYabcdY
+/(?<=b(?1)|zzz)(a)/
+    xbaax
+ 0: a
+ 1: a
+    xzzzax 
+ 0: a
  1: a
- 2: b
- 3: <unset>
- 4: <unset>
- 5: c
- 6: d
- 7: Y
 
-/^X(?7)(a)(?|(b|(?|(r)|(t))(s))|(q))(c)(d)(Y)/
-    XYabcdY
- 0: XYabcdY
+/(a)(?<=b\1)/
+Failed: lookbehind assertion is not fixed length at offset 10
+
+/(a)(?<=b+(?1))/
+Failed: lookbehind assertion is not fixed length at offset 13
+
+/(a+)(?<=b(?1))/
+Failed: lookbehind assertion is not fixed length at offset 14
+
+/(a(?<=b(?1)))/
+Failed: lookbehind assertion is not fixed length at offset 13
+
+/(?<=b(?1))xyz/
+Failed: reference to non-existent subpattern at offset 8
+
+/(?<=b(?1))xyz(b+)pqrstuvew/
+Failed: lookbehind assertion is not fixed length at offset 26
+
+/(a|bc)\1/SI
+Capturing subpattern count = 1
+Max back reference = 1
+No options
+No first char
+No need char
+Subject length lower bound = 2
+Starting byte set: a b 
+
+/(a|bc)\1{2,3}/SI
+Capturing subpattern count = 1
+Max back reference = 1
+No options
+No first char
+No need char
+Subject length lower bound = 3
+Starting byte set: a b 
+
+/(a|bc)(?1)/SI
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+Subject length lower bound = 2
+Starting byte set: a b 
+
+/(a|b\1)(a|b\1)/SI
+Capturing subpattern count = 2
+Max back reference = 1
+No options
+No first char
+No need char
+Subject length lower bound = 2
+Starting byte set: a b 
+
+/(a|b\1){2}/SI
+Capturing subpattern count = 1
+Max back reference = 1
+No options
+No first char
+No need char
+Subject length lower bound = 2
+Starting byte set: a b 
+
+/(a|bbbb\1)(a|bbbb\1)/SI
+Capturing subpattern count = 2
+Max back reference = 1
+No options
+No first char
+No need char
+Subject length lower bound = 2
+Starting byte set: a b 
+
+/(a|bbbb\1){2}/SI
+Capturing subpattern count = 1
+Max back reference = 1
+No options
+No first char
+No need char
+Subject length lower bound = 2
+Starting byte set: a b 
+
+/^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/SI
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = ':'
+Subject length lower bound = 22
+No set of starting bytes
+
+/  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                          # optional leading comment
+(?:    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+# address
+|                     #  or
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)             # one word, optionally followed by....
+(?:
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]  |  # atom and space parts, or...
+\(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)       |  # comments, or...
+
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+# quoted strings
+)*
+<  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                     # leading <
+(?:  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  ,  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+)* # further okay, if led by comma
+:                                # closing colon
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  )? #       optional route
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+#       address spec
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  > #                  trailing >
+# name and address
+)  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                       # optional trailing comment
+/xSI
+Capturing subpattern count = 0
+Contains explicit CR or LF match
+Options: extended
+No first char
+No need char
+Subject length lower bound = 3
+Starting byte set: \x09 \x20 ! " # $ % & ' ( * + - / 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 
+
+/<tr([\w\W\s\d][^<>]{0,})><TD([\w\W\s\d][^<>]{0,})>([\d]{0,}\.)(.*)((<BR>([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/isIS
+Capturing subpattern count = 11
+Options: caseless dotall
+First char = '<'
+Need char = '>'
+Subject length lower bound = 47
+No set of starting bytes
+
+"(?>.*/)foo"SI
+Capturing subpattern count = 0
+No options
+First char at start or follows newline
+Need char = 'o'
+Subject length lower bound = 4
+No set of starting bytes
+
+/(?(?=[^a-z]+[a-z])  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} ) /xSI
+Capturing subpattern count = 0
+Options: extended
+No first char
+Need char = '-'
+Subject length lower bound = 8
+No set of starting bytes
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/iSI
+Capturing subpattern count = 1
+Options: caseless
+No first char
+No need char
+Subject length lower bound = 1
+Starting byte set: A B C a b c 
+
+/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/SI
+Capturing subpattern count = 0
+No options
+No first char
+Need char = 'b'
+Subject length lower bound = 41
+Starting byte set: c d 
+
+/<a[\s]+href[\s]*=[\s]*          # find <a href=
+ ([\"\'])?                       # find single or double quote
+ (?(1) (.*?)\1 | ([^\s]+))       # if quote found, match up to next matching
+                                 # quote, otherwise match up to next space
+/isxSI
+Capturing subpattern count = 3
+Max back reference = 1
+Options: caseless extended dotall
+First char = '<'
+Need char = '='
+Subject length lower bound = 9
+No set of starting bytes
+
+/^(?!:)                       # colon disallowed at start
+  (?:                         # start of item
+    (?: [0-9a-f]{1,4} |       # 1-4 hex digits or
+    (?(1)0 | () ) )           # if null previously matched, fail; else null
+    :                         # followed by colon
+  ){1,7}                      # end item; 1-7 of them required               
+  [0-9a-f]{1,4} $             # final hex number at end of string
+  (?(1)|.)                    # check that there was an empty component
+  /xiIS
+Capturing subpattern count = 1
+Options: anchored caseless extended
+No first char
+Need char = ':'
+Subject length lower bound = 2
+No set of starting bytes
+
+/(?|(?<a>A)|(?<a>B))/I
+Capturing subpattern count = 1
+Named capturing subpatterns:
+  a   1
+  a   1
+No options
+No first char
+No need char
+    AB\Ca
+ 0: A
+ 1: A
+  C A (1) a
+    BA\Ca
+ 0: B
+ 1: B
+  C B (1) a
+
+/(?|(?<a>A)|(?<b>B))/ 
+Failed: different names for subpatterns of the same number are not allowed at offset 15
+
+/(?:a(?<quote> (?<apostrophe>')|(?<realquote>")) |
+    b(?<quote> (?<apostrophe>')|(?<realquote>")) ) 
+    (?('quote')[a-z]+|[0-9]+)/JIx
+Capturing subpattern count = 6
+Named capturing subpatterns:
+  apostrophe   2
+  apostrophe   5
+  quote        1
+  quote        4
+  realquote    3
+  realquote    6
+Options: extended dupnames
+No first char
+No need char
+    a"aaaaa
+ 0: a"aaaaa
+ 1: "
+ 2: <unset>
+ 3: "
+    b"aaaaa 
+ 0: b"aaaaa
+ 1: <unset>
+ 2: <unset>
+ 3: <unset>
+ 4: "
+ 5: <unset>
+ 6: "
+    ** Failers 
+No match
+    b"11111
+No match
+    a"11111 
+No match
+    
+/^(?|(a)(b)(c)(?<D>d)|(?<D>e)) (?('D')X|Y)/JDZx
+------------------------------------------------------------------
+        Bra
+        ^
+        Bra
+        CBra 1
+        a
+        Ket
+        CBra 2
+        b
+        Ket
+        CBra 3
+        c
+        Ket
+        CBra 4
+        d
+        Ket
+        Alt
+        CBra 1
+        e
+        Ket
+        Ket
+        Cond
+      4 Cond nref
+        X
+        Alt
+        Y
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 4
+Named capturing subpatterns:
+  D   4
+  D   1
+Options: anchored extended dupnames
+No first char
+No need char
+    abcdX
+ 0: abcdX
  1: a
  2: b
- 3: <unset>
- 4: <unset>
- 5: c
- 6: d
- 7: Y
+ 3: c
+ 4: d
+    eX
+ 0: eX
+ 1: e
+    ** Failers
+No match
+    abcdY
+No match
+    ey     
+No match
+    
+/(?<A>a) (b)(c)  (?<A>d  (?(R&A)$ | (?4)) )/JDZx
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        a
+        Ket
+        CBra 2
+        b
+        Ket
+        CBra 3
+        c
+        Ket
+        CBra 4
+        d
+        Cond
+        Cond nrecurse 1
+        $
+        Alt
+        Once
+        Recurse
+        Ket
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 4
+Named capturing subpatterns:
+  A   1
+  A   4
+Options: extended dupnames
+First char = 'a'
+Need char = 'd'
+    abcdd
+ 0: abcdd
+ 1: a
+ 2: b
+ 3: c
+ 4: dd
+    ** Failers
+No match
+    abcdde  
+No match
+
+/abcd*/
+    xxxxabcd\P
+ 0: abcd
+    xxxxabcd\P\P
+Partial match: abcd
+
+/abcd*/i
+    xxxxabcd\P
+ 0: abcd
+    xxxxabcd\P\P
+Partial match: abcd
+    XXXXABCD\P
+ 0: ABCD
+    XXXXABCD\P\P
+Partial match: ABCD
+
+/abc\d*/
+    xxxxabc1\P
+ 0: abc1
+    xxxxabc1\P\P
+Partial match: abc1
+
+/(a)bc\1*/
+    xxxxabca\P
+ 0: abca
+ 1: a
+    xxxxabca\P\P
+Partial match: abca
+
+/abc[de]*/
+    xxxxabcde\P
+ 0: abcde
+    xxxxabcde\P\P
+Partial match: abcde
+
+/-- This is not in the Perl 5.10 test because Perl seems currently to be broken
+    and not behaving as specified in that it *does* bumpalong after hitting
+    (*COMMIT). --/ 
+
+/(?1)(A(*COMMIT)|B)D/
+    ABD
+ 0: ABD
+ 1: B
+    XABD
+ 0: ABD
+ 1: B
+    BAD
+ 0: BAD
+ 1: A
+    ABXABD  
+ 0: ABD
+ 1: B
+    ** Failers 
+No match
+    ABX 
+No match
+    BAXBAD  
+No match
+
+/(\3)(\1)(a)/<JS>
+    cat
+ 0: a
+ 1: 
+ 2: 
+ 3: a
+
+/(\3)(\1)(a)/SI<JS>
+Capturing subpattern count = 3
+Max back reference = 3
+Options:
+No first char
+Need char = 'a'
+Subject length lower bound = 1
+No set of starting bytes
+    cat
+ 0: a
+ 1: 
+ 2: 
+ 3: a
+
+/(\3)(\1)(a)/SI
+Capturing subpattern count = 3
+Max back reference = 3
+No options
+No first char
+Need char = 'a'
+Subject length lower bound = 3
+No set of starting bytes
+    cat
+No match
 
-/ End of testinput2 /
+/-- End of testinput2 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput3 b/ext/pcre/pcrelib/testdata/testoutput3
index 28b1c3a..7b0a3e9 100644
--- a/ext/pcre/pcrelib/testdata/testoutput3
+++ b/ext/pcre/pcrelib/testdata/testoutput3
@@ -1,3 +1,7 @@
+/-- This set of tests checks local-specific features, using the fr_FR locale. 
+    It is not Perl-compatible. There is different version called wintestinput3
+  f  or use on Windows, where the locale is called "french". --/
+
 /^[\w]+/
     *** Failers
 No match
@@ -83,6 +87,7 @@ Capturing subpattern count = 0
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: 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 
 
@@ -91,6 +96,7 @@ Capturing subpattern count = 0
 No options
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: 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 
   ª µ º À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú Û Ü Ý Þ ß à á â 
@@ -160,4 +166,4 @@ No options
 No first char
 No need char
 
-/ End of testinput3 /
+/-- End of testinput3 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput4 b/ext/pcre/pcrelib/testdata/testoutput4
index e67a958..128afe4 100644
--- a/ext/pcre/pcrelib/testdata/testoutput4
+++ b/ext/pcre/pcrelib/testdata/testoutput4
@@ -1,9 +1,6 @@
-/-- Do not use the \x{} construct except with patterns that have the --/
-/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/
-No match
-/-- that option is set. However, the latest Perls recognize them always. --/
-No match
-
+/-- This set of tests if for UTF-8 support, excluding Unicode properties. It is
+    compatible with all versions of Perl 5. --/
+   
 /a.b/8
     acb
  0: acb
@@ -1089,4 +1086,37 @@ No match
 
 /(?i)[\xc3\xa9\xc3\xbd]|[\xc3\xa9\xc3\xbdA]/8
 
-/ End of testinput4 /
+/^[a\x{c0}]b/8
+    \x{c0}b
+ 0: \x{c0}b
+    
+/^([a\x{c0}]*?)aa/8
+    a\x{c0}aaaa/ 
+ 0: a\x{c0}aa
+ 1: a\x{c0}
+
+/^([a\x{c0}]*?)aa/8
+    a\x{c0}aaaa/ 
+ 0: a\x{c0}aa
+ 1: a\x{c0}
+    a\x{c0}a\x{c0}aaa/ 
+ 0: a\x{c0}a\x{c0}aa
+ 1: a\x{c0}a\x{c0}
+
+/^([a\x{c0}]*)aa/8
+    a\x{c0}aaaa/ 
+ 0: a\x{c0}aaaa
+ 1: a\x{c0}aa
+    a\x{c0}a\x{c0}aaa/ 
+ 0: a\x{c0}a\x{c0}aaa
+ 1: a\x{c0}a\x{c0}a
+
+/^([a\x{c0}]*)a\x{c0}/8
+    a\x{c0}aaaa/ 
+ 0: a\x{c0}
+ 1: 
+    a\x{c0}a\x{c0}aaa/ 
+ 0: a\x{c0}a\x{c0}
+ 1: a\x{c0}
+
+/-- End of testinput4 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput5 b/ext/pcre/pcrelib/testdata/testoutput5
index 75630b4..f5de747 100644
--- a/ext/pcre/pcrelib/testdata/testoutput5
+++ b/ext/pcre/pcrelib/testdata/testoutput5
@@ -1,3 +1,6 @@
+/-- This set of tests checks the API, internals, and non-Perl stuff for UTF-8
+    support, excluding Unicode properties. --/
+
 /\x{100}/8DZ
 ------------------------------------------------------------------
         Bra
@@ -252,7 +255,6 @@ Need char = 171
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 Need char = 'X'
@@ -269,52 +271,12 @@ Need char = 'X'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 No need char
     \x{212ab}\x{212ab}\x{212ab}\x{861}
  0: \x{212ab}\x{212ab}\x{212ab}
 
-/-- These tests are here rather than in testinput4 because Perl 5.6 has some
-problems with UTF-8 support, in the area of \x{..} where the value is < 255. 
-It grumbles about invalid UTF-8 strings. --/
-
-/^[a\x{c0}]b/8
-    \x{c0}b
- 0: \x{c0}b
-    
-/^([a\x{c0}]*?)aa/8
-    a\x{c0}aaaa/ 
- 0: a\x{c0}aa
- 1: a\x{c0}
-
-/^([a\x{c0}]*?)aa/8
-    a\x{c0}aaaa/ 
- 0: a\x{c0}aa
- 1: a\x{c0}
-    a\x{c0}a\x{c0}aaa/ 
- 0: a\x{c0}a\x{c0}aa
- 1: a\x{c0}a\x{c0}
-
-/^([a\x{c0}]*)aa/8
-    a\x{c0}aaaa/ 
- 0: a\x{c0}aaaa
- 1: a\x{c0}aa
-    a\x{c0}a\x{c0}aaa/ 
- 0: a\x{c0}a\x{c0}aaa
- 1: a\x{c0}a\x{c0}a
-
-/^([a\x{c0}]*)a\x{c0}/8
-    a\x{c0}aaaa/ 
- 0: a\x{c0}
- 1: 
-    a\x{c0}a\x{c0}aaa/ 
- 0: a\x{c0}a\x{c0}
- 1: a\x{c0}
-    
-/-- --/ 
-    
 /(?<=\C)X/8
 Failed: \C not allowed in lookbehind assertion at offset 6
 
@@ -389,6 +351,7 @@ Capturing subpattern count = 0
 Options: utf8
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: \x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0a 
   \x0b \x0c \x0d \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 
   \x1a \x1b \x1c \x1d \x1e \x1f \x20 ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 
@@ -423,11 +386,11 @@ No match
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 First char = 196
 Need char = 128
-Study returned NULL
+Subject length lower bound = 3
+No set of starting bytes
   \x{100}\x{100}\x{100}\x{100\x{100}
  0: \x{100}\x{100}\x{100}
 
@@ -443,10 +406,10 @@ Study returned NULL
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 1
-Partial matching not supported
 Options: utf8
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: x \xc4 
 
 /(\x{100}*a|x)/8SDZ
@@ -462,10 +425,10 @@ Starting byte set: x \xc4
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 1
-Partial matching not supported
 Options: utf8
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a x \xc4 
 
 /(\x{100}{0,2}a|x)/8SDZ
@@ -481,10 +444,10 @@ Starting byte set: a x \xc4
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 1
-Partial matching not supported
 Options: utf8
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: a x \xc4 
 
 /(\x{100}{1,2}a|x)/8SDZ
@@ -501,10 +464,10 @@ Starting byte set: a x \xc4
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 1
-Partial matching not supported
 Options: utf8
 No first char
 No need char
+Subject length lower bound = 1
 Starting byte set: x \xc4 
 
 /\x{100}*(\d+|"(?1)")/8
@@ -551,7 +514,6 @@ Need char = 128
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 No need char
@@ -565,7 +527,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 First char = 'a'
 No need char
@@ -579,7 +540,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 First char = 'a'
 Need char = 'b'
@@ -593,7 +553,6 @@ Need char = 'b'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 First char = 'a'
 Need char = 128
@@ -607,7 +566,6 @@ Need char = 128
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 First char = 'a'
 Need char = 129
@@ -621,7 +579,6 @@ Need char = 129
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 Need char = 'A'
@@ -640,7 +597,6 @@ Need char = 'A'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 No need char
@@ -1122,7 +1078,6 @@ Need char = 191
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 No need char
@@ -1136,7 +1091,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 No need char
@@ -1150,7 +1104,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 No need char
@@ -1164,7 +1117,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 No need char
@@ -1178,7 +1130,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 No need char
@@ -1192,7 +1143,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 No first char
 No need char
@@ -1206,7 +1156,6 @@ No need char
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 First char = 196
 Need char = 128
@@ -1220,7 +1169,6 @@ Need char = 128
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 First char = 196
 Need char = 'X'
@@ -1234,7 +1182,6 @@ Need char = 'X'
         End
 ------------------------------------------------------------------
 Capturing subpattern count = 0
-Partial matching not supported
 Options: utf8
 First char = 'X'
 Need char = 128
@@ -1652,4 +1599,477 @@ Forced newline sequence: CRLF
 First char = 'a'
 Need char = 'b'
 
-/ End of testinput5 /
+/Xa{2,4}b/8
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/Xa{2,4}?b/8
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/Xa{2,4}+b/8
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X\x{123}{2,4}b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+    
+/X\x{123}{2,4}?b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+    
+/X\x{123}{2,4}+b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+    
+/X\x{123}{2,4}b/8
+    Xx\P
+No match
+    X\x{123}x\P
+No match
+    X\x{123}\x{123}x\P 
+No match
+    X\x{123}\x{123}\x{123}x\P
+No match
+    X\x{123}\x{123}\x{123}\x{123}x\P 
+No match
+    
+/X\x{123}{2,4}?b/8
+    Xx\P
+No match
+    X\x{123}x\P
+No match
+    X\x{123}\x{123}x\P 
+No match
+    X\x{123}\x{123}\x{123}x\P
+No match
+    X\x{123}\x{123}\x{123}\x{123}x\P 
+No match
+    
+/X\x{123}{2,4}+b/8
+    Xx\P
+No match
+    X\x{123}x\P
+No match
+    X\x{123}\x{123}x\P 
+No match
+    X\x{123}\x{123}\x{123}x\P
+No match
+    X\x{123}\x{123}\x{123}\x{123}x\P 
+No match
+    
+/X\d{2,4}b/8
+    X\P
+Partial match: X
+    X3\P
+Partial match: X3
+    X33\P 
+Partial match: X33
+    X333\P
+Partial match: X333
+    X3333\P 
+Partial match: X3333
+    
+/X\d{2,4}?b/8
+    X\P
+Partial match: X
+    X3\P
+Partial match: X3
+    X33\P 
+Partial match: X33
+    X333\P
+Partial match: X333
+    X3333\P 
+Partial match: X3333
+    
+/X\d{2,4}+b/8
+    X\P
+Partial match: X
+    X3\P
+Partial match: X3
+    X33\P 
+Partial match: X33
+    X333\P
+Partial match: X333
+    X3333\P 
+Partial match: X3333
+
+/X\D{2,4}b/8
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X\D{2,4}?b/8
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X\D{2,4}+b/8
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+
+/X\D{2,4}b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+    
+/X\D{2,4}?b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+    
+/X\D{2,4}+b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+
+/X[abc]{2,4}b/8
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X[abc]{2,4}?b/8
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+    
+/X[abc]{2,4}+b/8
+    X\P
+Partial match: X
+    Xa\P
+Partial match: Xa
+    Xaa\P 
+Partial match: Xaa
+    Xaaa\P
+Partial match: Xaaa
+    Xaaaa\P 
+Partial match: Xaaaa
+
+/X[abc\x{123}]{2,4}b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+    
+/X[abc\x{123}]{2,4}?b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+    
+/X[abc\x{123}]{2,4}+b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+
+/X[^a]{2,4}b/8
+    X\P
+Partial match: X
+    Xz\P
+Partial match: Xz
+    Xzz\P 
+Partial match: Xzz
+    Xzzz\P
+Partial match: Xzzz
+    Xzzzz\P 
+Partial match: Xzzzz
+    
+/X[^a]{2,4}?b/8
+    X\P
+Partial match: X
+    Xz\P
+Partial match: Xz
+    Xzz\P 
+Partial match: Xzz
+    Xzzz\P
+Partial match: Xzzz
+    Xzzzz\P 
+Partial match: Xzzzz
+    
+/X[^a]{2,4}+b/8
+    X\P
+Partial match: X
+    Xz\P
+Partial match: Xz
+    Xzz\P 
+Partial match: Xzz
+    Xzzz\P
+Partial match: Xzzz
+    Xzzzz\P 
+Partial match: Xzzzz
+
+/X[^a]{2,4}b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+    
+/X[^a]{2,4}?b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+    
+/X[^a]{2,4}+b/8
+    X\P
+Partial match: X
+    X\x{123}\P
+Partial match: X\x{123}
+    X\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\P
+Partial match: X\x{123}\x{123}\x{123}
+    X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: X\x{123}\x{123}\x{123}\x{123}
+
+/(Y)X\1{2,4}b/8
+    YX\P
+Partial match: YX
+    YXY\P
+Partial match: YXY
+    YXYY\P 
+Partial match: YXYY
+    YXYYY\P
+Partial match: YXYYY
+    YXYYYY\P 
+Partial match: YXYYYY
+    
+/(Y)X\1{2,4}?b/8
+    YX\P
+Partial match: YX
+    YXY\P
+Partial match: YXY
+    YXYY\P 
+Partial match: YXYY
+    YXYYY\P
+Partial match: YXYYY
+    YXYYYY\P 
+Partial match: YXYYYY
+    
+/(Y)X\1{2,4}+b/8
+    YX\P
+Partial match: YX
+    YXY\P
+Partial match: YXY
+    YXYY\P 
+Partial match: YXYY
+    YXYYY\P
+Partial match: YXYYY
+    YXYYYY\P 
+Partial match: YXYYYY
+
+/(\x{123})X\1{2,4}b/8
+    \x{123}X\P
+Partial match: \x{123}X
+    \x{123}X\x{123}\P
+Partial match: \x{123}X\x{123}
+    \x{123}X\x{123}\x{123}\P 
+Partial match: \x{123}X\x{123}\x{123}
+    \x{123}X\x{123}\x{123}\x{123}\P
+Partial match: \x{123}X\x{123}\x{123}\x{123}
+    \x{123}X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: \x{123}X\x{123}\x{123}\x{123}\x{123}
+    
+/(\x{123})X\1{2,4}?b/8
+    \x{123}X\P
+Partial match: \x{123}X
+    \x{123}X\x{123}\P
+Partial match: \x{123}X\x{123}
+    \x{123}X\x{123}\x{123}\P 
+Partial match: \x{123}X\x{123}\x{123}
+    \x{123}X\x{123}\x{123}\x{123}\P
+Partial match: \x{123}X\x{123}\x{123}\x{123}
+    \x{123}X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: \x{123}X\x{123}\x{123}\x{123}\x{123}
+    
+/(\x{123})X\1{2,4}+b/8
+    \x{123}X\P
+Partial match: \x{123}X
+    \x{123}X\x{123}\P
+Partial match: \x{123}X\x{123}
+    \x{123}X\x{123}\x{123}\P 
+Partial match: \x{123}X\x{123}\x{123}
+    \x{123}X\x{123}\x{123}\x{123}\P
+Partial match: \x{123}X\x{123}\x{123}\x{123}
+    \x{123}X\x{123}\x{123}\x{123}\x{123}\P 
+Partial match: \x{123}X\x{123}\x{123}\x{123}\x{123}
+
+/\bthe cat\b/8
+    the cat\P
+ 0: the cat
+    the cat\P\P
+Partial match: the cat
+
+/abcd*/8
+    xxxxabcd\P
+ 0: abcd
+    xxxxabcd\P\P
+Partial match: abcd
+
+/abcd*/i8
+    xxxxabcd\P
+ 0: abcd
+    xxxxabcd\P\P
+Partial match: abcd
+    XXXXABCD\P
+ 0: ABCD
+    XXXXABCD\P\P
+Partial match: ABCD
+
+/abc\d*/8
+    xxxxabc1\P
+ 0: abc1
+    xxxxabc1\P\P
+Partial match: abc1
+
+/(a)bc\1*/8
+    xxxxabca\P
+ 0: abca
+ 1: a
+    xxxxabca\P\P
+Partial match: abca
+
+/abc[de]*/8
+    xxxxabcde\P
+ 0: abcde
+    xxxxabcde\P\P
+Partial match: abcde
+
+/-- End of testinput5 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput6 b/ext/pcre/pcrelib/testdata/testoutput6
index cb6f7d5..4245d6a 100644
--- a/ext/pcre/pcrelib/testdata/testoutput6
+++ b/ext/pcre/pcrelib/testdata/testoutput6
@@ -1,3 +1,7 @@
+/-- This set of tests is for Unicode property support. It is compatible with
+    Perl 5.10, but not 5.8 because it tests some extra properties that are
+    not in the earlier release. --/ 
+
 /^\pC\pL\pM\pN\pP\pS\pZ</8
     \x7f\x{c0}\x{30f}\x{660}\x{66c}\x{f01}\x{1680}<
  0: \x{7f}\x{c0}\x{30f}\x{660}\x{66c}\x{f01}\x{1680}<
@@ -98,14 +102,6 @@ No match
     \x{09f} 
 No match
   
-/^\p{Cs}/8
-    \?\x{dfff}
- 0: \x{dfff}
-    ** Failers
-No match
-    \x{09f} 
-No match
-  
 /^\p{Ll}/8
     a
  0: a
@@ -338,18 +334,6 @@ No match
     \x{f3b}
 No match
   
-/^\p{Sc}+/8
-    $\x{a2}\x{a3}\x{a4}\x{a5}\x{a6}
- 0: $\x{a2}\x{a3}\x{a4}\x{a5}
-    \x{9f2}
- 0: \x{9f2}
-    ** Failers
-No match
-    X
-No match
-    \x{2c2}
-No match
-  
 /^\p{Sk}/8
     \x{2c2}
  0: \x{2c2}
@@ -402,26 +386,6 @@ No match
     \x{2028}
 No match
   
-/^\p{Zs}/8
-    \ \
- 0:  
-    \x{a0}
- 0: \x{a0}
-    \x{1680}
- 0: \x{1680}
-    \x{180e}
- 0: \x{180e}
-    \x{2000}
- 0: \x{2000}
-    \x{2001}     
- 0: \x{2001}
-    ** Failers
-No match
-    \x{2028}
-No match
-    \x{200d} 
-No match
-  
 /\p{Nd}+(..)/8
       \x{660}\x{661}\x{662}ABC
  0: \x{660}\x{661}\x{662}AB
@@ -494,34 +458,6 @@ No match
       \x{660}\x{661}\x{662}ABC
 No match
   
-/\p{Lu}/8i
-    A
- 0: A
-    a\x{10a0}B 
- 0: \x{10a0}
-    ** Failers 
- 0: F
-    a
-No match
-    \x{1d00}  
-No match
-
-/\p{^Lu}/8i
-    1234
- 0: 1
-    ** Failers
- 0: *
-    ABC 
-No match
-
-/\P{Lu}/8i
-    1234
- 0: 1
-    ** Failers
- 0: *
-    ABC 
-No match
-
 /(?<=A\p{Nd})XYZ/8
     A2XYZ
  0: XYZ
@@ -548,103 +484,6 @@ No match
     WXYZ 
 No match
 
-/[\p{L}]/DZ
-------------------------------------------------------------------
-        Bra
-        [\p{L}]
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-No options
-No first char
-No need char
-
-/[\p{^L}]/DZ
-------------------------------------------------------------------
-        Bra
-        [\P{L}]
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-No options
-No first char
-No need char
-
-/[\P{L}]/DZ
-------------------------------------------------------------------
-        Bra
-        [\P{L}]
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-No options
-No first char
-No need char
-
-/[\P{^L}]/DZ
-------------------------------------------------------------------
-        Bra
-        [\p{L}]
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-No options
-No first char
-No need char
-
-/[abc\p{L}\x{0660}]/8DZ
-------------------------------------------------------------------
-        Bra
-        [a-c\p{L}\x{660}]
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-No first char
-No need char
-
-/[\p{Nd}]/8DZ
-------------------------------------------------------------------
-        Bra
-        [\p{Nd}]
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-No first char
-No need char
-    1234
- 0: 1
-
-/[\p{Nd}+-]+/8DZ
-------------------------------------------------------------------
-        Bra
-        [+\-\p{Nd}]+
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Partial matching not supported
-Options: utf8
-No first char
-No need char
-    1234
- 0: 1234
-    12-34
- 0: 12-34
-    12+\x{661}-34  
- 0: 12+\x{661}-34
-    ** Failers
-No match
-    abcd  
-No match
-
 /[\P{Nd}]+/8
     abcd
  0: abcd
@@ -725,28 +564,6 @@ No match
     ABC   
 No match
 
-/\p{Ll}/8i 
-    a
- 0: a
-    Az
- 0: z
-    ** Failers
- 0: a
-    ABC   
-No match
-
-/^\x{c0}$/8i
-    \x{c0}
- 0: \x{c0}
-    \x{e0} 
- 0: \x{e0}
-
-/^\x{e0}$/8i
-    \x{c0}
- 0: \x{c0}
-    \x{e0} 
- 0: \x{e0}
-
 /A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8
     A\x{391}\x{10427}\x{ff3a}\x{1fb0}
  0: A\x{391}\x{10427}\x{ff3a}\x{1fb0}
@@ -777,54 +594,6 @@ No match
     A\x{391}\x{10427}\x{ff3a}\x{1fb8}
  0: A\x{391}\x{10427}\x{ff3a}\x{1fb8}
 
-/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iDZ
-------------------------------------------------------------------
-        Bra
-     NC A\x{391}\x{10427}\x{ff3a}\x{1fb0}
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: caseless utf8
-First char = 'A' (caseless)
-No need char
-
-/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8DZ
-------------------------------------------------------------------
-        Bra
-        A\x{391}\x{10427}\x{ff3a}\x{1fb0}
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 'A'
-Need char = 176
-
-/AB\x{1fb0}/8DZ
-------------------------------------------------------------------
-        Bra
-        AB\x{1fb0}
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 'A'
-Need char = 176
-
-/AB\x{1fb0}/8DZi
-------------------------------------------------------------------
-        Bra
-     NC AB\x{1fb0}
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: caseless utf8
-First char = 'A' (caseless)
-Need char = 'B' (caseless)
-
 /\x{391}+/8i
     \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
  0: \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
@@ -849,86 +618,6 @@ Need char = 'B' (caseless)
     \x{ff5a}   
  0: \x{ff5a}
     
-/[\x{c0}\x{391}]/8i
-    \x{c0}
- 0: \x{c0}
-    \x{e0} 
- 0: \x{e0}
-
-/[\x{105}-\x{109}]/8iDZ
-------------------------------------------------------------------
-        Bra
-        [\x{104}-\x{109}]
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: caseless utf8
-No first char
-No need char
-    \x{104}
- 0: \x{104}
-    \x{105}
- 0: \x{105}
-    \x{109}  
- 0: \x{109}
-    ** Failers
-No match
-    \x{100}
-No match
-    \x{10a} 
-No match
-    
-/[z-\x{100}]/8iDZ 
-------------------------------------------------------------------
-        Bra
-        [Z\x{39c}\x{178}z-\x{101}]
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: caseless utf8
-No first char
-No need char
-    Z
- 0: Z
-    z
- 0: z
-    \x{39c}
- 0: \x{39c}
-    \x{178}
- 0: \x{178}
-    |
- 0: |
-    \x{80}
- 0: \x{80}
-    \x{ff}
- 0: \x{ff}
-    \x{100}
- 0: \x{100}
-    \x{101} 
- 0: \x{101}
-    ** Failers
-No match
-    \x{102}
-No match
-    Y
-No match
-    y           
-No match
-
-/[z-\x{100}]/8DZi
-------------------------------------------------------------------
-        Bra
-        [Z\x{39c}\x{178}z-\x{101}]
-        Ket
-        End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: caseless utf8
-No first char
-No need char
-
 /^\X/8
     A
  0: A
@@ -1408,42 +1097,10 @@ No match
  1: L=abc
  2: abc
 
-/The next two should be Perl-compatible, but it fails to match \x{e0}. PCRE
-will match it only with UCP support, because without that it has no notion
-of case for anything other than the ASCII letters. / 
-
-/((?i)[\x{c0}])/8
-    \x{c0}
- 0: \x{c0}
- 1: \x{c0}
-    \x{e0} 
- 0: \x{e0}
- 1: \x{e0}
-
-/(?i:[\x{c0}])/8
-    \x{c0}
- 0: \x{c0}
-    \x{e0} 
- 0: \x{e0}
-    
 /^\p{Balinese}\p{Cuneiform}\p{Nko}\p{Phags_Pa}\p{Phoenician}/8
     \x{1b00}\x{12000}\x{7c0}\x{a840}\x{10900}
  0: \x{1b00}\x{12000}\x{7c0}\x{a840}\x{10900}
 
-/The next two are special cases where the lengths of the different cases of the 
-same character differ. The first went wrong with heap frame storage; the 2nd
-was broken in all cases./
-
-/^\x{023a}+?(\x{0130}+)/8i
-  \x{023a}\x{2c65}\x{0130}
- 0: \x{23a}\x{2c65}\x{130}
- 1: \x{130}
-  
-/^\x{023a}+([^X])/8i
-  \x{023a}\x{2c65}X
- 0: \x{23a}\x{2c65}
- 1: \x{2c65}
-
 /Check property support in non-UTF-8 mode/
  
 /\p{L}{4}/
@@ -1468,60 +1125,6 @@ No match
     A\x80
  0: A\x80
 
-/(?:[\PPa*]*){8,}/
-
-/[\P{Any}]/BZ
-------------------------------------------------------------------
-        Bra
-        [\P{Any}]
-        Ket
-        End
-------------------------------------------------------------------
-
-/[\P{Any}\E]/BZ
-------------------------------------------------------------------
-        Bra
-        [\P{Any}]
-        Ket
-        End
-------------------------------------------------------------------
-
-/(\P{Yi}+\277)/
-
-/(\P{Yi}+\277)?/
-
-/(?<=\P{Yi}{3}A)X/
-
-/\p{Yi}+(\P{Yi}+)(?1)/
-
-/(\P{Yi}{2}\277)?/
-
-/[\P{Yi}A]/
-
-/[\P{Yi}\P{Yi}\P{Yi}A]/
-
-/[^\P{Yi}A]/
-
-/[^\P{Yi}\P{Yi}\P{Yi}A]/
-
-/(\P{Yi}*\277)*/
-
-/(\P{Yi}*?\277)*/
-
-/(\p{Yi}*+\277)*/
-
-/(\P{Yi}?\277)*/
-
-/(\P{Yi}??\277)*/
-
-/(\p{Yi}?+\277)*/
-
-/(\P{Yi}{0,3}\277)*/
-
-/(\P{Yi}{0,3}?\277)*/
-
-/(\p{Yi}{0,3}+\277)*/
-
 /^[\p{Arabic}]/8
     \x{60e} 
  0: \x{60e}
@@ -1634,59 +1237,6 @@ No match
     \x{104aa}           
 No match
 
-/\p{Zl}{2,3}+/8BZ
-------------------------------------------------------------------
-        Bra
-        prop Zl {2}
-        prop Zl ?+
-        Ket
-        End
-------------------------------------------------------------------
-    \xe2\x80\xa8\xe2\x80\xa8
- 0: \x{2028}\x{2028}
-    \x{2028}\x{2028}\x{2028}
- 0: \x{2028}\x{2028}\x{2028}
-    
-/\p{Zl}/8BZ
-------------------------------------------------------------------
-        Bra
-        prop Zl
-        Ket
-        End
-------------------------------------------------------------------
-
-/\p{Lu}{3}+/8BZ
-------------------------------------------------------------------
-        Bra
-        prop Lu {3}
-        Ket
-        End
-------------------------------------------------------------------
-
-/\pL{2}+/8BZ
-------------------------------------------------------------------
-        Bra
-        prop L {2}
-        Ket
-        End
-------------------------------------------------------------------
-
-/\p{Cc}{2}+/8BZ
-------------------------------------------------------------------
-        Bra
-        prop Cc {2}
-        Ket
-        End
-------------------------------------------------------------------
-
-/\x{c0}+\x{116}+/8i
-    \x{c0}\x{e0}\x{116}\x{117}
- 0: \x{c0}\x{e0}\x{116}\x{117}
-
-/[\x{c0}\x{116}]+/8i
-    \x{c0}\x{e0}\x{116}\x{117}
- 0: \x{c0}\x{e0}\x{116}\x{117}
-
 /\p{Carian}\p{Cham}\p{Kayah_Li}\p{Lepcha}\p{Lycian}\p{Lydian}\p{Ol_Chiki}\p{Rejang}\p{Saurashtra}\p{Sundanese}\p{Vai}/8
     \x{102A4}\x{AA52}\x{A91D}\x{1C46}\x{10283}\x{1092E}\x{1C6B}\x{A93B}\x{A8BF}\x{1BA0}\x{A50A}====
  0: \x{102a4}\x{aa52}\x{a91d}\x{1c46}\x{10283}\x{1092e}\x{1c6b}\x{a93b}\x{a8bf}\x{1ba0}\x{a50a}
@@ -1719,20 +1269,6 @@ No match
  0: aA
  1: a
 
-/(\x{de})\1/8i
-    \x{de}\x{de}
- 0: \x{de}\x{de}
- 1: \x{de}
-    \x{de}\x{fe}
- 0: \x{de}\x{fe}
- 1: \x{de}
-    \x{fe}\x{fe}
- 0: \x{fe}\x{fe}
- 1: \x{fe}
-    \x{fe}\x{de}
- 0: \x{fe}\x{de}
- 1: \x{fe}
-
 /(\x{10a})\1/8i
     \x{10a}\x{10a}
  0: \x{10a}\x{10a}
@@ -1757,4 +1293,4 @@ No match
     \x41\x20\x50\xC2\x54\xC9\x20\x54\x4F\x44\x41\x59
  0: A P\xc2T\xc9 TODAY
 
-/ End of testinput6 /
+/-- End of testinput6 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput7 b/ext/pcre/pcrelib/testdata/testoutput7
index 78c8923..c6c9df4 100644
--- a/ext/pcre/pcrelib/testdata/testoutput7
+++ b/ext/pcre/pcrelib/testdata/testoutput7
@@ -1,3 +1,6 @@
+/-- This set of tests check the DFA matching functionality of pcre_dfa_exec().
+    The -dfa flag must be used with pcretest when running it. --/
+     
 /abc/
     abc
  0: abc
@@ -981,7 +984,7 @@ Partial match: abc
    xyzfo\P 
 No match
    foob\P\>2 
-Partial match: b
+Partial match: foob
    foobar...\R\P\>4 
  0: ar
    xyzfo\P
@@ -7168,7 +7171,6 @@ No match
     
 /a\R{2,4}b/I<bsr_anycrlf>
 Capturing subpattern count = 0
-Partial matching not supported
 Options: bsr_anycrlf
 First char = 'a'
 Need char = 'b'
@@ -7187,7 +7189,6 @@ No match
 
 /a\R{2,4}b/I<bsr_unicode>
 Capturing subpattern count = 0
-Partial matching not supported
 Options: bsr_unicode
 First char = 'a'
 Need char = 'b'
@@ -7370,4 +7371,217 @@ No match
     \C-"ab"
  0: "ab"
 
-/ End of testinput7 /
+/\d+X|9+Y/
+    ++++123999\P
+Partial match: 123999
+    ++++123999Y\P
+ 0: 999Y
+
+/Z(*F)/
+    Z\P
+No match
+    ZA\P 
+No match
+    
+/Z(?!)/
+    Z\P 
+No match
+    ZA\P 
+No match
+
+/dog(sbody)?/
+    dogs\P
+ 0: dog
+    dogs\P\P 
+Partial match: dogs
+    
+/dog(sbody)??/
+    dogs\P
+ 0: dog
+    dogs\P\P 
+Partial match: dogs
+
+/dog|dogsbody/
+    dogs\P
+ 0: dog
+    dogs\P\P 
+Partial match: dogs
+ 
+/dogsbody|dog/
+    dogs\P
+ 0: dog
+    dogs\P\P 
+Partial match: dogs
+
+/Z(*F)Q|ZXY/
+    Z\P
+Partial match: Z
+    ZA\P 
+No match
+    X\P 
+No match
+
+/\bthe cat\b/
+    the cat\P
+ 0: the cat
+    the cat\P\P
+Partial match: the cat
+
+/dog(sbody)?/
+    dogs\D\P
+ 0: dog
+    body\D\R
+ 0: body
+
+/dog(sbody)?/
+    dogs\D\P\P
+Partial match: dogs
+    body\D\R
+ 0: body
+
+/abc/
+   abc\P
+ 0: abc
+   abc\P\P
+ 0: abc
+
+/abc\K123/
+    xyzabc123pqr
+Error -16
+    
+/(?<=abc)123/
+    xyzabc123pqr 
+ 0: 123
+    xyzabc12\P
+Partial match: abc12
+    xyzabc12\P\P
+Partial match: abc12
+
+/\babc\b/
+    +++abc+++
+ 0: abc
+    +++ab\P
+Partial match: +ab
+    +++ab\P\P  
+Partial match: +ab
+
+/(?=C)/g+
+    ABCDECBA
+ 0: 
+ 0+ CDECBA
+ 0: 
+ 0+ CBA
+
+/(abc|def|xyz)/I
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+    terhjk;abcdaadsfe
+ 0: abc
+    the quick xyz brown fox 
+ 0: xyz
+    \Yterhjk;abcdaadsfe
+ 0: abc
+    \Ythe quick xyz brown fox 
+ 0: xyz
+    ** Failers
+No match
+    thejk;adlfj aenjl;fda asdfasd ehj;kjxyasiupd
+No match
+    \Ythejk;adlfj aenjl;fda asdfasd ehj;kjxyasiupd
+No match
+
+/(abc|def|xyz)/SI
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+Subject length lower bound = 3
+Starting byte set: a d x 
+    terhjk;abcdaadsfe
+ 0: abc
+    the quick xyz brown fox 
+ 0: xyz
+    \Yterhjk;abcdaadsfe
+ 0: abc
+    \Ythe quick xyz brown fox 
+ 0: xyz
+    ** Failers
+No match
+    thejk;adlfj aenjl;fda asdfasd ehj;kjxyasiupd
+No match
+    \Ythejk;adlfj aenjl;fda asdfasd ehj;kjxyasiupd
+No match
+
+/abcd*/+
+    xxxxabcd\P
+ 0: abcd
+ 0+ 
+ 1: abc
+    xxxxabcd\P\P
+Partial match: abcd
+    dddxxx\R 
+ 0: ddd
+ 0+ xxx
+ 1: dd
+ 2: d
+ 3: 
+    xxxxabcd\P\P
+Partial match: abcd
+    xxx\R 
+ 0: 
+ 0+ xxx
+
+/abcd*/i
+    xxxxabcd\P
+ 0: abcd
+ 1: abc
+    xxxxabcd\P\P
+Partial match: abcd
+    XXXXABCD\P
+ 0: ABCD
+ 1: ABC
+    XXXXABCD\P\P
+Partial match: ABCD
+
+/abc\d*/
+    xxxxabc1\P
+ 0: abc1
+ 1: abc
+    xxxxabc1\P\P
+Partial match: abc1
+
+/abc[de]*/
+    xxxxabcde\P
+ 0: abcde
+ 1: abcd
+ 2: abc
+    xxxxabcde\P\P
+Partial match: abcde
+
+/(?:(?1)|B)(A(*F)|C)/
+    ABCD
+ 0: BC
+    CCD
+ 0: CC
+    ** Failers
+No match
+    CAD   
+No match
+
+/^(?:(?1)|B)(A(*F)|C)/
+    CCD
+ 0: CC
+    BCD 
+ 0: BC
+    ** Failers
+No match
+    ABCD
+No match
+    CAD
+No match
+    BAD    
+No match
+
+/-- End of testinput7 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput8 b/ext/pcre/pcrelib/testdata/testoutput8
index af10c4a..0cc87d7 100644
--- a/ext/pcre/pcrelib/testdata/testoutput8
+++ b/ext/pcre/pcrelib/testdata/testoutput8
@@ -1,8 +1,6 @@
-/-- Do not use the \x{} construct except with patterns that have the --/
-/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/
-No match
-/-- that option is set. However, the latest Perls recognize them always. --/
-No match
+/-- This set of tests checks UTF-8 support with the DFA matching functionality
+    of pcre_dfa_exec(). The -dfa flag must be used with pcretest when running 
+    it. --/
 
 /\x{100}ab/8
   \x{100}ab
@@ -1288,4 +1286,38 @@ No match
     A\x{1ec5}ABCXYZ
  0: X
 
-/ End of testinput 8 / 
+/abcd*/8
+    xxxxabcd\P
+ 0: abcd
+ 1: abc
+    xxxxabcd\P\P
+Partial match: abcd
+
+/abcd*/i8
+    xxxxabcd\P
+ 0: abcd
+ 1: abc
+    xxxxabcd\P\P
+Partial match: abcd
+    XXXXABCD\P
+ 0: ABCD
+ 1: ABC
+    XXXXABCD\P\P
+Partial match: ABCD
+
+/abc\d*/8
+    xxxxabc1\P
+ 0: abc1
+ 1: abc
+    xxxxabc1\P\P
+Partial match: abc1
+
+/abc[de]*/8
+    xxxxabcde\P
+ 0: abcde
+ 1: abcd
+ 2: abc
+    xxxxabcde\P\P
+Partial match: abcde
+
+/-- End of testinput8 --/ 
diff --git a/ext/pcre/pcrelib/testdata/testoutput9 b/ext/pcre/pcrelib/testdata/testoutput9
index 04e3873..851e3f0 100644
--- a/ext/pcre/pcrelib/testdata/testoutput9
+++ b/ext/pcre/pcrelib/testdata/testoutput9
@@ -1,3 +1,7 @@
+/-- This set of tests check Unicode property support with the DFA matching 
+    functionality of pcre_dfa_exec(). The -dfa flag must be used with pcretest
+    when running it. --/
+
 /\pL\P{Nd}/8
     AB
  0: AB
@@ -1670,4 +1674,4 @@ No match
     \x{1d79}\x{a77d} 
 No match
 
-/ End / 
+/-- End of testinput9 --/ 
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index d89e353..bacb74f 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcre.c 289418 2009-10-09 14:25:51Z pajoye $ */
+/* $Id: php_pcre.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -1314,9 +1314,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
 		if (!zend_is_callable(*replace, 0, &callback_name TSRMLS_CC)) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires argument 2, '%s', to be a valid callback", callback_name);
 			efree(callback_name);
-			*return_value = **subject;
-			zval_copy_ctor(return_value);
-			INIT_PZVAL(return_value);
+			MAKE_COPY_ZVAL(subject, return_value);
 			return;
 		}
 		efree(callback_name);
diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h
index 841773b..5b173ea 100644
--- a/ext/pcre/php_pcre.h
+++ b/ext/pcre/php_pcre.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: php_pcre.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pcre.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PCRE_H
 #define PHP_PCRE_H
diff --git a/ext/pcre/tests/bug33200.phpt b/ext/pcre/tests/bug33200.phpt
index c75a6d4..67a4d86 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--
-PHP Warning:  Directive 'magic_quotes_sybase' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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/upgrade-pcre.php b/ext/pcre/upgrade-pcre.php
index 8c2061d..338b207 100644
--- a/ext/pcre/upgrade-pcre.php
+++ b/ext/pcre/upgrade-pcre.php
@@ -84,7 +84,12 @@ recurse('pcrelib');
 
 $dirorig = scandir('pcrelib/testdata');
 $k = array_search('CVS', $dirorig);
-unset($dirorig[$k]);
+if ($k !== false)
+	unset($dirorig[$k]);
+
+$k = array_search('.svn', $dirorig);
+if ($k !== false)
+	unset($dirorig[$k]);
 
 $dirnew = scandir("$newpcre/testdata");
 $diff   = array_diff($dirorig, $dirnew);
diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c
index 8b37340..7c8ee32 100755
--- a/ext/pdo/pdo.c
+++ b/ext/pdo/pdo.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo.c 284394 2009-07-19 22:46:03Z felipe $ */
+/* $Id: pdo.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -222,6 +222,7 @@ PDO_API int php_pdo_parse_data_source(const char *data_source,
 	int optstart = 0;
 	int nlen;
 	int n_matches = 0;
+	int n_semicolumns = 0;
 
 	i = 0;
 	while (i < data_source_len) {
@@ -240,14 +241,21 @@ PDO_API int php_pdo_parse_data_source(const char *data_source,
 
 		/* now we're looking for VALUE; or just VALUE<NUL> */
 		semi = -1;
+		n_semicolumns = 0;
 		while (i < data_source_len) {
 			if (data_source[i] == '\0') {
 				semi = i++;
 				break;
 			}
 			if (data_source[i] == ';') {
-				semi = i++;
-				break;
+				if ((i + 1 >= data_source_len) || data_source[i+1] != ';') {
+					semi = i++;
+					break;
+				} else {
+					n_semicolumns++; 
+					i += 2;
+					continue;
+				}
 			}
 			++i;
 		}
@@ -264,7 +272,31 @@ PDO_API int php_pdo_parse_data_source(const char *data_source,
 				if (parsed[j].freeme) {
 					efree(parsed[j].optval);
 				}
-				parsed[j].optval = estrndup(data_source + valstart, semi - valstart);
+
+				if (n_semicolumns == 0) {
+					parsed[j].optval = estrndup(data_source + valstart, semi - valstart - n_semicolumns);
+				} else {
+					int vlen = semi - valstart;
+					char *orig_val = data_source + valstart;
+					char *new_val  = (char *) emalloc(vlen - n_semicolumns + 1);
+				
+					parsed[j].optval = new_val;
+
+					while (vlen && *orig_val) {
+						*new_val = *orig_val;
+						new_val++;
+
+						if (*orig_val == ';') {
+							orig_val+=2; 
+							vlen-=2;
+						} else {
+							orig_val++;
+							vlen--;
+						}
+					}
+					*new_val = '\0';
+				}
+
 				parsed[j].freeme = 1;
 				++n_matches;
 				break;
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index c85a593..bb1f5bc 100755
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_dbh.c 289775 2009-10-19 21:43:34Z johannes $ */
+/* $Id: pdo_dbh.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* The PDO Database Handle Class */
 
@@ -44,7 +44,7 @@ void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate
 	char *message = NULL;
 	const char *msg;
 
-	if (dbh->error_mode == PDO_ERRMODE_SILENT) {
+	if (dbh && dbh->error_mode == PDO_ERRMODE_SILENT) {
 #if 0
 		/* BUG: if user is running in silent mode and hits an error at the driver level
 		 * when they use the PDO methods to call up the error information, they may
@@ -71,7 +71,7 @@ void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate
 		spprintf(&message, 0, "SQLSTATE[%s]: %s", *pdo_err, msg);
 	}
 
-	if (dbh->error_mode != PDO_ERRMODE_EXCEPTION) {
+	if (dbh && dbh->error_mode != PDO_ERRMODE_EXCEPTION) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", message);
 	} else {
 		zval *ex, *info;
@@ -1144,8 +1144,7 @@ static PHP_METHOD(PDO, quote)
 	char *qstr;
 	int qlen;
 
-	if (FAILURE == zend_parse_parameters(1 TSRMLS_CC, "s|l", &str, &str_len,
-			&paramtype)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len, &paramtype)) {
 		RETURN_FALSE;
 	}
 	
diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c
index 072d9e6..aef93f6 100644
--- a/ext/pdo/pdo_sql_parser.c
+++ b/ext/pdo/pdo_sql_parser.c
@@ -3,7 +3,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_sql_parser.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pdo_sql_parser.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_pdo_driver.h"
diff --git a/ext/pdo/pdo_sql_parser.c.orig b/ext/pdo/pdo_sql_parser.c.orig
index 1d3eaa6..9332151 100644
--- a/ext/pdo/pdo_sql_parser.c.orig
+++ b/ext/pdo/pdo_sql_parser.c.orig
@@ -4,7 +4,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_sql_parser.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pdo_sql_parser.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_pdo_driver.h"
diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re
index 4b92183..6021865 100644
--- a/ext/pdo/pdo_sql_parser.re
+++ b/ext/pdo/pdo_sql_parser.re
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_sql_parser.re 272369 2008-12-31 11:13:54Z sebastian $ */
+/* $Id: pdo_sql_parser.re 293035 2010-01-03 08:22:14Z sebastian $ */
 
 #include "php.h"
 #include "php_pdo_driver.h"
diff --git a/ext/pdo/pdo_sqlstate.c b/ext/pdo/pdo_sqlstate.c
index de44331..fe6e41f 100644
--- a/ext/pdo/pdo_sqlstate.c
+++ b/ext/pdo/pdo_sqlstate.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_sqlstate.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pdo_sqlstate.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 18a3bd8..5e0e9cb 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_stmt.c 289775 2009-10-19 21:43:34Z johannes $ */
+/* $Id: pdo_stmt.c 294942 2010-02-12 00:19:10Z johannes $ */
 
 /* The PDO Statement Handle Class */
 
@@ -469,9 +469,7 @@ static PHP_METHOD(PDOStatement, execute)
 
 			param.param_type = PDO_PARAM_STR;
 			MAKE_STD_ZVAL(param.parameter);
-			*param.parameter = **tmp;
-			zval_copy_ctor(param.parameter);
-			INIT_PZVAL(param.parameter);
+			MAKE_COPY_ZVAL(tmp, param.parameter);
 
 			if (!really_register_bound_param(&param, stmt, 1 TSRMLS_CC)) {
 				if (param.parameter) {
@@ -497,6 +495,7 @@ static PHP_METHOD(PDOStatement, execute)
 			/* no changes were made */
 			stmt->active_query_string = stmt->query_string;
 			stmt->active_query_stringlen = stmt->query_stringlen;
+			ret = 1;
 		} else if (ret == -1) {
 			/* something broke */
 			PDO_HANDLE_STMT_ERR();
@@ -785,95 +784,24 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
 
 static int make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info * fci, zend_fcall_info_cache * fcc, int num_args TSRMLS_DC) /* {{{ */
 {
-	zval *object = NULL, **method = NULL;
-	char *fname = NULL, *cname;
-	zend_class_entry * ce = NULL, **pce;
-	zend_function *function_handler;
-	
-	if (Z_TYPE_P(callable) == IS_ARRAY) {
-		if (Z_ARRVAL_P(callable)->nNumOfElements < 2) {
-			pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback" TSRMLS_CC);
-			return 0;
-		}
-		object = *(zval**)Z_ARRVAL_P(callable)->pListHead->pData;
-		method = (zval**)Z_ARRVAL_P(callable)->pListHead->pListNext->pData;
+	char *is_callable_error = NULL;
 
-		if (Z_TYPE_P(object) == IS_STRING) { /* static call */
-			if (zend_lookup_class(Z_STRVAL_P(object), Z_STRLEN_P(object), &pce TSRMLS_CC) == FAILURE) {
-				pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied class does not exist" TSRMLS_CC);
-				return 0;
-			} else {
-				ce = *pce;
-			}
-			object = NULL;
-		} else if (Z_TYPE_P(object) == IS_OBJECT) { /* object call */
-			ce = Z_OBJCE_P(object);
+	if (zend_fcall_info_init(callable, 0, fci, fcc, NULL, &is_callable_error TSRMLS_CC) == FAILURE) { 
+		if (is_callable_error) {
+			pdo_raise_impl_error(stmt->dbh, stmt, "HY000", is_callable_error TSRMLS_CC);
+			efree(is_callable_error);
 		} else {
-			pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback; bogus object/class name" TSRMLS_CC);
-			return 0;
-		}
-		
-		if (Z_TYPE_PP(method) != IS_STRING) {
-			pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback; bogus method name" TSRMLS_CC);
-			return 0;
-		}
-	} else if (Z_TYPE_P(callable) == IS_STRING) {
-		method = &callable;
-	}
-	
-	if (!method || !zend_is_callable(callable, 0, &fname TSRMLS_CC)) {
-		pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback" TSRMLS_CC);
-		if (fname) {
-			efree(fname);
+			pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback" TSRMLS_CC);
 		}
 		return 0;
 	}
-	
-	/* ATM we do not support array($obj, "CLASS::FUNC") or "CLASS_FUNC" */
-	cname = fname;
-	if ((fname = strstr(fname, "::")) == NULL) {
-		fname = cname;
-		cname = NULL;
-	} else {
-		*fname = '\0';
-		fname += 2;
+	if (is_callable_error) {
+		/* Possible E_STRICT error message */
+		efree(is_callable_error);
 	}
-	if (cname) {
-		if (zend_lookup_class(cname, strlen(cname), &pce TSRMLS_CC) == FAILURE) {
-			pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied class does not exist" TSRMLS_CC);
-			return 0;
-		} else {
-			if (ce) {
-				/* pce must be base of ce or ce itself */
-				if (ce != *pce && !instanceof_function(ce, *pce TSRMLS_CC)) {
-					pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied class has bogus lineage" TSRMLS_CC);
-					return 0;
-				}
-			}
-			ce = *pce;
-		}
-	}
-
-	zend_str_tolower_copy(fname, fname, strlen(fname));
-	fci->function_table = ce ? &ce->function_table : EG(function_table);
-	if (zend_hash_find(fci->function_table, fname, strlen(fname)+1, (void **)&function_handler) == FAILURE) {
-		pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function does not exist" TSRMLS_CC);
-		return 0;
-	}
-	efree(cname ? cname : fname);
-
-	fci->size = sizeof(zend_fcall_info);
-	fci->function_name = NULL;
-	fci->symbol_table = NULL;
+	
 	fci->param_count = num_args; /* probably less */
 	fci->params = safe_emalloc(sizeof(zval**), num_args, 0);
-	fci->object_ptr = object;
-
-	fcc->initialized = 1;
-	fcc->function_handler = function_handler;
-	fcc->calling_scope = EG(scope);
-	fcc->called_scope = object ? Z_OBJCE_P(object) : NULL;
-	fcc->object_ptr = object;
 	
 	return 1;
 }
@@ -1271,9 +1199,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value,
 						zval_ptr_dtor(&return_value); /* we don't need that */
 						return_value = retval;
 					} else if (retval) {
-						*return_value = *retval;
-						zval_copy_ctor(return_value);
-						INIT_PZVAL(return_value);
+						MAKE_COPY_ZVAL(&retval, return_value);
 						zval_ptr_dtor(&retval);
 					}
 				}
@@ -1566,7 +1492,9 @@ static PHP_METHOD(PDOStatement, fetchAll)
 		case 3:
 		case 2:
 			stmt->fetch.func.function = arg2;
-			do_fetch_func_prepare(stmt TSRMLS_CC);
+			if (do_fetch_func_prepare(stmt TSRMLS_CC) == 0) {
+				error = 1;
+			}
 			break;
 		}
 		break;
@@ -1657,20 +1585,22 @@ static PHP_METHOD(PDOStatement, fetchAll)
 static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int is_param) /* {{{ */
 {
 	struct pdo_bound_param_data param = {0};
+	long param_type = PDO_PARAM_STR;
 
 	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|llz!", &param.paramno, &param.parameter, &param.param_type, &param.max_value_len,
+			"lz|llz!", &param.paramno, &param.parameter, &param_type, &param.max_value_len,
 			&param.driver_params)) {
 		if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|llz!", &param.name,
-				&param.namelen, &param.parameter, &param.param_type, &param.max_value_len, 
+				&param.namelen, &param.parameter, &param_type, &param.max_value_len, 
 				&param.driver_params)) {
 			return 0;
 		}	
 	}
-
+	
+	param.param_type = (int) param_type;
+	
 	if (param.paramno > 0) {
 		--param.paramno; /* make it zero-based internally */
 	} else if (!param.name) {
diff --git a/ext/pdo/php_pdo.h b/ext/pdo/php_pdo.h
index 6d66581..b72c8dc 100755
--- a/ext/pdo/php_pdo.h
+++ b/ext/pdo/php_pdo.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_H
 #define PHP_PDO_H
diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h
index e8aa505..3fcbde7 100755
--- a/ext/pdo/php_pdo_driver.h
+++ b/ext/pdo/php_pdo_driver.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_driver.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_driver.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_DRIVER_H
 #define PHP_PDO_DRIVER_H
diff --git a/ext/pdo/php_pdo_int.h b/ext/pdo/php_pdo_int.h
index 3e301b5..28f7969 100755
--- a/ext/pdo/php_pdo_int.h
+++ b/ext/pdo/php_pdo_int.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_int.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_int.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Stuff private to the PDO extension and not for consumption by PDO drivers
  * */
diff --git a/ext/pdo/tests/bug_44861.phpt b/ext/pdo/tests/bug_44861.phpt
index a392372..3612561 100644
--- a/ext/pdo/tests/bug_44861.phpt
+++ b/ext/pdo/tests/bug_44861.phpt
@@ -32,7 +32,7 @@ if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') {
 	$from = '';
 }
 
-$query = "SELECT 'row1' AS r $from UNION SELECT 'row2' $from UNION SELECT 'row3' $from UNION SELECT 'row4' $from";
+$query = "SELECT 'row1' AS r $from UNION SELECT 'row2' $from UNION SELECT 'row3' $from UNION SELECT 'row4' $from ORDER BY r";
 $aParams = array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL);
 
 $res = $db->prepare($query, $aParams);
diff --git a/ext/pdo/tests/bug_50458.phpt b/ext/pdo/tests/bug_50458.phpt
new file mode 100644
index 0000000..3deb289
--- /dev/null
+++ b/ext/pdo/tests/bug_50458.phpt
@@ -0,0 +1,29 @@
+--TEST--
+PDO Common: Bug #50458 (PDO::FETCH_FUNC fails with Closures)
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded('pdo')) die('skip');
+$dir = getenv('REDIR_TEST_DIR');
+if (false == $dir) die('skip no driver');
+require_once $dir . 'pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/'); 
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+
+$db = PDOTest::factory();
+$db->exec("CREATE TABLE test (a VARCHAR(10))");
+$db->exec("INSERT INTO test (a) VALUES ('xyz')");
+$res = $db->query("SELECT a FROM test");
+var_dump($res->fetchAll(PDO::FETCH_FUNC, function($a) { return strtoupper($a); }));
+
+?>
+===DONE===
+--EXPECTF--
+array(1) {
+  [0]=>
+  string(3) "XYZ"
+}
+===DONE===
diff --git a/ext/pdo_dblib/config.m4 b/ext/pdo_dblib/config.m4
index 657da62..5068b87 100644
--- a/ext/pdo_dblib/config.m4
+++ b/ext/pdo_dblib/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 266959 2008-10-04 12:52:58Z felipe $
+dnl $Id: config.m4 291414 2009-11-29 06:13:22Z rasmus $
 dnl
 
 PHP_ARG_WITH(pdo-dblib, for PDO_DBLIB support via FreeTDS,
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index 7234c2b..5e9464e 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: dblib_driver.c 289440 2009-10-09 18:56:19Z pajoye $ */
+/* $Id: dblib_driver.c 294444 2010-02-03 19:48:04Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -255,7 +255,7 @@ cleanup:
 	dbh->driver_data = H;
 
 	if (!ret) {
-		zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC,
+		zend_throw_exception_ex(php_pdo_get_exception(), DBLIB_G(err).dberr TSRMLS_CC,
 			"SQLSTATE[%s] %s (severity %d)",
 			DBLIB_G(err).sqlstate,
 			DBLIB_G(err).dberrstr,
diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c
index 0080b30..290a25c 100644
--- a/ext/pdo_dblib/dblib_stmt.c
+++ b/ext/pdo_dblib/dblib_stmt.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: dblib_stmt.c 277492 2009-03-19 22:16:29Z sfox $ */
+/* $Id: dblib_stmt.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
diff --git a/ext/pdo_dblib/pdo_dblib.c b/ext/pdo_dblib/pdo_dblib.c
index 73cf49b..0da36da 100644
--- a/ext/pdo_dblib/pdo_dblib.c
+++ b/ext/pdo_dblib/pdo_dblib.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_dblib.c 280855 2009-05-20 10:18:51Z kalle $ */
+/* $Id: pdo_dblib.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
diff --git a/ext/pdo_dblib/php_pdo_dblib.h b/ext/pdo_dblib/php_pdo_dblib.h
index f2096c7..dc54a87 100644
--- a/ext/pdo_dblib/php_pdo_dblib.h
+++ b/ext/pdo_dblib/php_pdo_dblib.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_dblib.h 280765 2009-05-19 10:22:25Z kalle $ */
+/* $Id: php_pdo_dblib.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_DBLIB_H
 #define PHP_PDO_DBLIB_H
diff --git a/ext/pdo_dblib/php_pdo_dblib_int.h b/ext/pdo_dblib/php_pdo_dblib_int.h
index 518787b..273fb07 100644
--- a/ext/pdo_dblib/php_pdo_dblib_int.h
+++ b/ext/pdo_dblib/php_pdo_dblib_int.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_dblib_int.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_dblib_int.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_DBLIB_INT_H
 #define PHP_PDO_DBLIB_INT_H
diff --git a/ext/pdo_firebird/config.m4 b/ext/pdo_firebird/config.m4
index e30b4b4..e878bfb 100644
--- a/ext/pdo_firebird/config.m4
+++ b/ext/pdo_firebird/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 280986 2009-05-23 13:52:00Z nlopess $
+dnl $Id: config.m4 291414 2009-11-29 06:13:22Z rasmus $
 dnl
 
 PHP_ARG_WITH(pdo-firebird,for Firebird support for PDO,
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index b099d31..5039223 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: firebird_driver.c 278929 2009-04-18 18:56:11Z felipe $ */
+/* $Id: firebird_driver.c 294444 2010-02-03 19:48:04Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -691,7 +691,7 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
 		char errmsg[512];
 		ISC_STATUS *s = H->isc_status;
 		isc_interprete(errmsg, &s);
-		zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
+		zend_throw_exception_ex(php_pdo_get_exception(), H->isc_status[1] TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
 				"HY000", H->isc_status[1], errmsg);
 	}
 
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index b58b756..8c6bb83 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: firebird_statement.c 284404 2009-07-20 00:17:24Z felipe $ */
+/* $Id: firebird_statement.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/pdo_firebird/pdo_firebird.c b/ext/pdo_firebird/pdo_firebird.c
index 7f63649..fb71c9d 100644
--- a/ext/pdo_firebird/pdo_firebird.c
+++ b/ext/pdo_firebird/pdo_firebird.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_firebird.c 284399 2009-07-19 23:33:50Z felipe $ */
+/* $Id: pdo_firebird.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/pdo_firebird/php_pdo_firebird.h b/ext/pdo_firebird/php_pdo_firebird.h
index 4797cc6..7d77062 100644
--- a/ext/pdo_firebird/php_pdo_firebird.h
+++ b/ext/pdo_firebird/php_pdo_firebird.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_firebird.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_firebird.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_FIREBIRD_H
 #define PHP_PDO_FIREBIRD_H
diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h
index 485a862..0df268e 100644
--- a/ext/pdo_firebird/php_pdo_firebird_int.h
+++ b/ext/pdo_firebird/php_pdo_firebird_int.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_firebird_int.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_firebird_int.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_FIREBIRD_INT_H
 #define PHP_PDO_FIREBIRD_INT_H
diff --git a/ext/pdo_mysql/config.m4 b/ext/pdo_mysql/config.m4
index aa5efd8..0b0de12 100755
--- a/ext/pdo_mysql/config.m4
+++ b/ext/pdo_mysql/config.m4
@@ -1,4 +1,4 @@
-dnl $Id: config.m4 287424 2009-08-17 17:57:40Z jani $
+dnl $Id: config.m4 291501 2009-11-30 15:11:29Z jani $
 dnl config.m4 for extension pdo_mysql
 dnl vim: se ts=2 sw=2 et:
 
@@ -28,46 +28,42 @@ if test "$PHP_PDO_MYSQL" != "no"; then
     done
   ])
 
+  if test -f $PHP_PDO_MYSQL && test -x $PHP_PDO_MYSQL ; then
+    PDO_MYSQL_CONFIG=$PHP_PDO_MYSQL
+  elif test "$PHP_PDO_MYSQL" != "yes"; then
+    if test -d "$PHP_PDO_MYSQL" ; then
+      if test -x "$PHP_PDO_MYSQL/bin/mysql_config" ; then
+        PDO_MYSQL_CONFIG="$PHP_PDO_MYSQL/bin/mysql_config"
+      else
+        PDO_MYSQL_DIR="$PHP_PDO_MYSQL"
+      fi
+    fi
+  else
+    for i in /usr/local /usr ; do
+      if test -x "$i/bin/mysql_config" ; then
+        PDO_MYSQL_CONFIG="$i/bin/mysql_config"
+        break;
+      fi
+      if test -r $i/include/mysql/mysql.h || test -r $i/include/mysql.h ; then
+        PDO_MYSQL_DIR="$i"
+        break;
+      fi
+    done
+  fi
+
   if test "$PHP_PDO_MYSQL" = "mysqlnd"; then
     dnl enables build of mysqnd library
     PHP_MYSQLND_ENABLED=yes
     AC_DEFINE([PDO_USE_MYSQLND], 1, [Whether pdo_mysql uses mysqlnd])
   else
     AC_DEFINE(HAVE_MYSQL, 1, [Whether you have MySQL])
-    AC_MSG_CHECKING([for mysql_config])
 
-    if test -f $PHP_PDO_MYSQL && test -x $PHP_PDO_MYSQL ; then
-      PDO_MYSQL_CONFIG=$PHP_PDO_MYSQL
-    elif test "$PHP_PDO_MYSQL" != "yes"; then
-      if test -d "$PHP_PDO_MYSQL" ; then
-        if test -x "$PHP_PDO_MYSQL/bin/mysql_config" ; then
-          PDO_MYSQL_CONFIG="$PHP_PDO_MYSQL/bin/mysql_config"
-        else
-          PDO_MYSQL_DIR="$PHP_PDO_MYSQL"
-        fi
-      else
-        AC_MSG_RESULT([$PHP_PDO_MYSQL is not a directory])
-        AC_MSG_ERROR([can not find mysql under the "$PHP_PDO_MYSQL" that you specified])
-      fi
-    else
-      for i in /usr/local /usr ; do
-        if test -x "$i/bin/mysql_config" ; then
-          PDO_MYSQL_CONFIG="$i/bin/mysql_config"
-          break;
-        fi
-        if test -r $i/include/mysql/mysql.h || test -r $i/include/mysql.h ; then
-          PDO_MYSQL_DIR="$i"
-          break;
-        fi
-      done
-    fi
-
-    if test -n "$PDO_MYSQL_CONFIG" && test -x "$PDO_MYSQL_CONFIG" ; then
+    AC_MSG_CHECKING([for mysql_config])
+    if test -n "$PDO_MYSQL_CONFIG"; then
       AC_MSG_RESULT($PDO_MYSQL_CONFIG)
       if test "x$SED" = "x"; then
         AC_PATH_PROG(SED, sed)
       fi
-
       if test "$enable_maintainer_zts" = "yes"; then
         PDO_MYSQL_LIBNAME=mysqlclient_r
         PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs_r | $SED -e "s/'//g"`
@@ -76,11 +72,7 @@ if test "$PHP_PDO_MYSQL" != "no"; then
         PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g"`
       fi
       PDO_MYSQL_INCLUDE=`$PDO_MYSQL_CONFIG --cflags | $SED -e "s/'//g"`
-      PDO_MYSQL_SOCKET=`$PDO_MYSQL_CONFIG --socket` 
-    elif test -z "$PDO_MYSQL_DIR"; then
-      AC_MSG_RESULT([not found])
-      AC_MSG_ERROR([Cannot find MySQL header files under $PDO_MYSQL_DIR])
-    else
+    elif test -n "$PDO_MYSQL_DIR"; then
       AC_MSG_RESULT([not found])
       AC_MSG_CHECKING([for mysql install under $PDO_MYSQL_DIR])
       if test -r $PDO_MYSQL_DIR/include/mysql; then
@@ -103,10 +95,11 @@ if test "$PHP_PDO_MYSQL" != "no"; then
 
       PHP_ADD_INCLUDE($PDO_MYSQL_INC_DIR)
       PDO_MYSQL_INCLUDE=-I$PDO_MYSQL_INC_DIR
+    else
+      AC_MSG_RESULT([not found])
+      AC_MSG_ERROR([Unable to find your mysql installation])
     fi
 
-    AC_DEFINE_UNQUOTED(PDO_MYSQL_UNIX_ADDR, "$PDO_MYSQL_SOCKET", [ ])
-
     PHP_CHECK_LIBRARY($PDO_MYSQL_LIBNAME, mysql_query,
     [
       PHP_EVAL_INCLINE($PDO_MYSQL_INCLUDE)
@@ -159,6 +152,10 @@ if test "$PHP_PDO_MYSQL" != "no"; then
     AC_MSG_RESULT($pdo_inc_path)
   ])
 
+  if test -n "$PDO_MYSQL_CONFIG"; then
+    PDO_MYSQL_SOCKET=`$PDO_MYSQL_CONFIG --socket`
+    AC_DEFINE_UNQUOTED(PDO_MYSQL_UNIX_ADDR, "$PDO_MYSQL_SOCKET", [ ])
+  fi
 
   dnl fix after renaming to pdo_mysql
   PHP_NEW_EXTENSION(pdo_mysql, pdo_mysql.c mysql_driver.c mysql_statement.c, $ext_shared,,-I$pdo_inc_path -I)
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c
index 1b4b227..37a67e5 100755
--- a/ext/pdo_mysql/mysql_driver.c
+++ b/ext/pdo_mysql/mysql_driver.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysql_driver.c 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: mysql_driver.c 294543 2010-02-04 20:28:55Z johannes $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -127,7 +127,7 @@ int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int lin
 
 	if (!dbh->methods) {
 		PDO_DBG_INF("Throwing exception");
-		zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
+		zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
 				*pdo_err, einfo->errcode, einfo->errmsg);
 	}
 
@@ -462,7 +462,7 @@ static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value
 		case PDO_ATTR_SERVER_INFO: {
 			char *tmp;
 #if PDO_USE_MYSQLND
-			int tmp_len;
+			unsigned int tmp_len;
 
 			if (mysqlnd_stat(H->server, &tmp, &tmp_len) == PASS) {
 				ZVAL_STRINGL(return_value, tmp, tmp_len, 0);
@@ -731,7 +731,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
 	}
 
 	if (mysqlnd_connect(H->server, host, dbh->username, dbh->password, password_len, dbname, dbname_len,
-						port, unix_socket, connect_opts, PDO_MYSQL_G(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL) {
+						port, unix_socket, connect_opts TSRMLS_CC) == NULL) {
 #else
 	if (mysql_real_connect(H->server, host, dbh->username, dbh->password, dbname, port, unix_socket, connect_opts) == NULL) {
 #endif
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c
index 6899dd7..074e9fb 100755
--- a/ext/pdo_mysql/mysql_statement.c
+++ b/ext/pdo_mysql/mysql_statement.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysql_statement.c 280838 2009-05-20 08:30:12Z kalle $ */
+/* $Id: mysql_statement.c 294543 2010-02-04 20:28:55Z johannes $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -120,7 +120,7 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
 }
 /* }}} */
 
-static void pdo_mysql_stmt_set_row_count(pdo_stmt_t *stmt) /* {{{ */
+static void pdo_mysql_stmt_set_row_count(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
 {
 	long row_count;
 	pdo_mysql_stmt *S = stmt->driver_data;
@@ -237,7 +237,7 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt TSRMLS_DC)
 		}
 	}
 	
-	pdo_mysql_stmt_set_row_count(stmt);
+	pdo_mysql_stmt_set_row_count(stmt TSRMLS_CC);
 	PDO_DBG_RETURN(1);
 }
 /* }}} */
@@ -280,7 +280,7 @@ static int pdo_mysql_stmt_execute_prepared_mysqlnd(pdo_stmt_t *stmt TSRMLS_DC) /
 		}
 	}
 	
-	pdo_mysql_stmt_set_row_count(stmt);
+	pdo_mysql_stmt_set_row_count(stmt TSRMLS_CC);
 	PDO_DBG_RETURN(1);
 }
 /* }}} */
diff --git a/ext/pdo_mysql/pdo_mysql.c b/ext/pdo_mysql/pdo_mysql.c
index 44719fd..158c033 100755
--- a/ext/pdo_mysql/pdo_mysql.c
+++ b/ext/pdo_mysql/pdo_mysql.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_mysql.c 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: pdo_mysql.c 294514 2010-02-04 09:37:38Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -35,43 +35,37 @@
 ZEND_GET_MODULE(pdo_mysql)
 #endif
 
-#if PDO_USE_MYSQLND
 ZEND_DECLARE_MODULE_GLOBALS(pdo_mysql);
 
 #ifndef PHP_WIN32
 # ifndef PDO_MYSQL_UNIX_ADDR
-#  define PDO_MYSQL_UNIX_ADDR  "/tmp/mysql.sock"
+#  ifdef PHP_MYSQL_UNIX_SOCK_ADDR
+#   define PDO_MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR
+#  else
+#   define PDO_MYSQL_UNIX_ADDR "/tmp/mysql.sock"
+#  endif
 # endif
 #endif
 
-
 /* {{{ PHP_INI_BEGIN
 */
 PHP_INI_BEGIN()
 #ifndef PHP_WIN32
-	STD_PHP_INI_ENTRY("pdo_mysql.default_socket", PDO_MYSQL_UNIX_ADDR, PHP_INI_SYSTEM, OnUpdateString, default_socket, zend_pdo_mysql_globals, pdo_mysql_globals)
+	STD_PHP_INI_ENTRY("pdo_mysql.default_socket", PDO_MYSQL_UNIX_ADDR, PHP_INI_SYSTEM, OnUpdateStringUnempty, default_socket, zend_pdo_mysql_globals, pdo_mysql_globals)
 #endif
 #if PDO_DBG_ENABLED
 	STD_PHP_INI_ENTRY("pdo_mysql.debug",	NULL, PHP_INI_SYSTEM, OnUpdateString, debug, zend_pdo_mysql_globals, pdo_mysql_globals)
 #endif
-	STD_PHP_INI_ENTRY("pdo_mysql.cache_size",			"2000",	PHP_INI_SYSTEM,		OnUpdateLong,		cache_size,			zend_pdo_mysql_globals,		pdo_mysql_globals)
 PHP_INI_END()
 /* }}} */
-#endif
 
-/* true global environment */
-#ifdef PDO_USE_MYSQLND
-static MYSQLND_ZVAL_PCACHE *pdo_mysqlnd_zval_cache;
-#endif
-		
+/* true global environment */		
 		
 /* {{{ PHP_MINIT_FUNCTION
  */
 static PHP_MINIT_FUNCTION(pdo_mysql)
 {
-#if PDO_USE_MYSQLND
 	REGISTER_INI_ENTRIES();
-#endif
 
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (long)PDO_MYSQL_ATTR_LOCAL_INFILE);	
@@ -86,10 +80,6 @@ static PHP_MINIT_FUNCTION(pdo_mysql)
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_FOUND_ROWS", (long)PDO_MYSQL_ATTR_FOUND_ROWS);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_IGNORE_SPACE", (long)PDO_MYSQL_ATTR_IGNORE_SPACE);
 
-#ifdef PDO_USE_MYSQLND
-	pdo_mysqlnd_zval_cache = mysqlnd_palloc_init_cache(PDO_MYSQL_G(cache_size));
-#endif
-	
 	return php_pdo_register_driver(&pdo_mysql_driver);
 }
 /* }}} */
@@ -100,7 +90,6 @@ static PHP_MSHUTDOWN_FUNCTION(pdo_mysql)
 {
 	php_pdo_unregister_driver(&pdo_mysql_driver);
 #if PDO_USE_MYSQLND
-	mysqlnd_palloc_free_cache(pdo_mysqlnd_zval_cache);
 	UNREGISTER_INI_ENTRIES();
 #endif
 
@@ -117,20 +106,6 @@ static PHP_MINFO_FUNCTION(pdo_mysql)
 	php_info_print_table_header(2, "PDO Driver for MySQL", "enabled");
 	php_info_print_table_row(2, "Client API version", mysql_get_client_info());
 
-#ifdef PDO_USE_MYSQLND
-	{
-		zval values;
-
-		php_info_print_table_header(2, "Persistent cache", pdo_mysqlnd_zval_cache ? "enabled":"disabled");
-		
-		if (pdo_mysqlnd_zval_cache) {
-			/* Now report cache status */
-			mysqlnd_palloc_stats(pdo_mysqlnd_zval_cache, &values);
-			mysqlnd_minfo_print_hash(&values);
-			zval_dtor(&values);
-		}
-	}
-#endif
 	php_info_print_table_end();
 
 #ifdef PDO_USE_MYSQLND
@@ -144,12 +119,10 @@ static PHP_MINFO_FUNCTION(pdo_mysql)
 /* {{{ PHP_RINIT_FUNCTION
  */
 static PHP_RINIT_FUNCTION(pdo_mysql)
-{
-	PDO_MYSQL_G(mysqlnd_thd_zval_cache) = mysqlnd_palloc_rinit(pdo_mysqlnd_zval_cache);
-	
+{	
 #if PDO_DBG_ENABLED
 	if (PDO_MYSQL_G(debug)) {
-		MYSQLND_DEBUG *dbg = mysqlnd_debug_init(TSRMLS_C);
+		MYSQLND_DEBUG *dbg = mysqlnd_debug_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC);
 		if (!dbg) {
 			return FAILURE;
 		}
@@ -167,8 +140,6 @@ static PHP_RINIT_FUNCTION(pdo_mysql)
  */
 static PHP_RSHUTDOWN_FUNCTION(pdo_mysql)
 {
-	mysqlnd_palloc_rshutdown(PDO_MYSQL_G(mysqlnd_thd_zval_cache));
-	
 #if PDO_DBG_ENABLED
 	MYSQLND_DEBUG *dbg = PDO_MYSQL_G(dbg);
 	PDO_DBG_ENTER("RSHUTDOWN");
@@ -187,8 +158,6 @@ static PHP_RSHUTDOWN_FUNCTION(pdo_mysql)
  */
 static PHP_GINIT_FUNCTION(pdo_mysql)
 {
-	pdo_mysql_globals->mysqlnd_thd_zval_cache = NULL; /* zval cache */
-	pdo_mysql_globals->cache_size = 0;
 #ifndef PHP_WIN32
 	pdo_mysql_globals->default_socket = NULL;
 #endif
@@ -227,7 +196,7 @@ zend_module_entry pdo_mysql_module_entry = {
 	pdo_mysql_functions,
 	PHP_MINIT(pdo_mysql),
 	PHP_MSHUTDOWN(pdo_mysql),
-#if PDO_USE_MYSQLND
+#if PDO_USE_MYSQLND && PDO_DBG_ENABLED
 	PHP_RINIT(pdo_mysql),
 	PHP_RSHUTDOWN(pdo_mysql),
 #else
diff --git a/ext/pdo_mysql/php_pdo_mysql.h b/ext/pdo_mysql/php_pdo_mysql.h
index 6adfbf0..202c2a2 100755
--- a/ext/pdo_mysql/php_pdo_mysql.h
+++ b/ext/pdo_mysql/php_pdo_mysql.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_mysql.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_mysql.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_MYSQL_H
 #define PHP_PDO_MYSQL_H
diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h
index ac0a973..51e5e55 100755
--- a/ext/pdo_mysql/php_pdo_mysql_int.h
+++ b/ext/pdo_mysql/php_pdo_mysql_int.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_mysql_int.h 289630 2009-10-14 13:51:25Z johannes $ */
+/* $Id: php_pdo_mysql_int.h 294514 2010-02-04 09:37:38Z pajoye $ */
 
 #ifndef PHP_PDO_MYSQL_INT_H
 #define PHP_PDO_MYSQL_INT_H
@@ -61,10 +61,7 @@ static inline void PDO_DBG_ENTER(char *func_name) {}
 #include "ext/mysqlnd/mysqlnd_debug.h"
 #endif
 
-#ifdef PDO_USE_MYSQLND
 ZEND_BEGIN_MODULE_GLOBALS(pdo_mysql)
-	MYSQLND_THD_ZVAL_PCACHE *mysqlnd_thd_zval_cache;
-	long          cache_size;
 #ifndef PHP_WIN32
 	char          *default_socket;
 #endif
@@ -72,10 +69,15 @@ ZEND_BEGIN_MODULE_GLOBALS(pdo_mysql)
 	char          *debug; /* The actual string */
 	MYSQLND_DEBUG *dbg;	/* The DBG object */
 #endif
+#if defined(PHP_WIN32) && !PDO_DBG_ENABLED
+	/* dummy member so we get at least one member in the struct
+	 * and avoids build errors.
+	 */
+	void *dummymemmber;
+#endif
 ZEND_END_MODULE_GLOBALS(pdo_mysql)
 
-ZEND_EXTERN_MODULE_GLOBALS(pdo_mysql);
-#endif
+ZEND_EXTERN_MODULE_GLOBALS(pdo_mysql)
 
 #ifdef ZTS
 #define PDO_MYSQL_G(v) TSRMG(pdo_mysql_globals_id, zend_pdo_mysql_globals *, v)
diff --git a/ext/pdo_mysql/tests/bug44327.phpt b/ext/pdo_mysql/tests/bug44327.phpt
index 1952cce..f82c430 100644
--- a/ext/pdo_mysql/tests/bug44327.phpt
+++ b/ext/pdo_mysql/tests/bug44327.phpt
@@ -42,22 +42,22 @@ $db = MySQLPDOTest::factory();
 ?>
 --EXPECTF--
 object(PDORow)#%d (2) {
-  ["queryString"]=>
-  string(17) "SELECT 1 AS "one""
-  ["one"]=>
-  string(1) "1"
+  [%u|b%"queryString"]=>
+  %unicode|string%(17) "SELECT 1 AS "one""
+  [%u|b%"one"]=>
+  %unicode|string%(1) "1"
 }
-string(1) "1"
-string(1) "1"
-string(17) "SELECT 1 AS "one""
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(17) "SELECT 1 AS "one""
 ----------------------------------
 object(PDORow)#%d (2) {
-  ["queryString"]=>
-  string(19) "SELECT id FROM test"
-  ["id"]=>
-  string(1) "1"
+  [%u|b%"queryString"]=>
+  %unicode|string%(19) "SELECT id FROM test"
+  [%u|b%"id"]=>
+  %unicode|string%(1) "1"
 }
-string(19) "SELECT id FROM test"
+%unicode|string%(19) "SELECT id FROM test"
 ----------------------------------
 
 Notice: Trying to get property of non-object in %s on line %d
diff --git a/ext/pdo_mysql/tests/bug46292.phpt b/ext/pdo_mysql/tests/bug46292.phpt
index 80423bc..a0f9716 100644
--- a/ext/pdo_mysql/tests/bug46292.phpt
+++ b/ext/pdo_mysql/tests/bug46292.phpt
@@ -50,32 +50,35 @@ if (version_compare(PHP_VERSION, '5.1.0', '<'))
 	var_dump($stmt->fetch());
 	var_dump($stmt->fetch());
 	var_dump($stmt->fetchAll());
-	
-	$pdoDb->query('DROP TABLE IF EXISTS testz');
-	
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS testz');
 ?>
 --EXPECTF--
 bool(true)
 myclass::__construct()
 object(myclass)#%d (1) {
-  ["value"]=>
-  string(1) "1"
+  [%u|b%"value"]=>
+  %unicode|string%(1) "1"
 }
 myclass::__construct()
 object(myclass2)#%d (1) {
-  ["value"]=>
-  string(1) "2"
+  [%u|b%"value"]=>
+  %unicode|string%(1) "2"
 }
 myclass::__construct()
 array(2) {
   [0]=>
   object(myclass)#%d (1) {
-    ["value"]=>
+    [%u|b%"value"]=>
     NULL
   }
   [1]=>
   object(stdClass)#%d (1) {
-    ["value"]=>
+    [%u|b%"value"]=>
     NULL
   }
 }
diff --git a/ext/pdo_mysql/tests/bug_33689.phpt b/ext/pdo_mysql/tests/bug_33689.phpt
index 88392ef..5969cae 100644
--- a/ext/pdo_mysql/tests/bug_33689.phpt
+++ b/ext/pdo_mysql/tests/bug_33689.phpt
@@ -34,10 +34,15 @@ else
 
 print_r($tmp);
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 object(PDOStatement)#%d (1) {
-  ["queryString"]=>
-  string(18) "SELECT * from test"
+  [%u|b%"queryString"]=>
+  %unicode|string%(18) "SELECT * from test"
 }
 Array
 (
diff --git a/ext/pdo_mysql/tests/bug_37445.phpt b/ext/pdo_mysql/tests/bug_37445.phpt
index 524a3d0..8e91533 100644
--- a/ext/pdo_mysql/tests/bug_37445.phpt
+++ b/ext/pdo_mysql/tests/bug_37445.phpt
@@ -15,7 +15,6 @@ $db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
 $db->setAttribute(PDO :: ATTR_EMULATE_PREPARES, true);
 $stmt = $db->prepare("SELECT 1");
 $stmt->bindParam(':a', 'b');
-
 ?>
 --EXPECTF--
 Fatal error: Cannot pass parameter 2 by reference in %sbug_37445.php on line %d
diff --git a/ext/pdo_mysql/tests/bug_39858.phpt b/ext/pdo_mysql/tests/bug_39858.phpt
index 6a2124d..4745718 100644
--- a/ext/pdo_mysql/tests/bug_39858.phpt
+++ b/ext/pdo_mysql/tests/bug_39858.phpt
@@ -62,35 +62,41 @@ bug_39858($db);
 
 print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec("DROP PROCEDURE IF EXISTS p");
+?>
 --EXPECTF--
 Emulated Prepared Statements...
 array(1) {
   [0]=>
   array(1) {
-    ["2 * 2"]=>
-    string(1) "4"
+    [%u|b%"2 * 2"]=>
+    %unicode|string%(1) "4"
   }
 }
 array(1) {
   [0]=>
   array(1) {
-    ["2 * 2"]=>
-    string(1) "4"
+    [%u|b%"2 * 2"]=>
+    %unicode|string%(1) "4"
   }
 }
 Native Prepared Statements...
 array(1) {
   [0]=>
   array(1) {
-    ["2 * 2"]=>
-    string(1) "4"
+    [%u|b%"2 * 2"]=>
+    %unicode|string%(1) "4"
   }
 }
 array(1) {
   [0]=>
   array(1) {
-    ["2 * 2"]=>
-    string(1) "4"
+    [%u|b%"2 * 2"]=>
+    %unicode|string%(1) "4"
   }
 }
 done!
diff --git a/ext/pdo_mysql/tests/bug_41125.phpt b/ext/pdo_mysql/tests/bug_41125.phpt
index 1f54cca..a1d8dd1 100644
--- a/ext/pdo_mysql/tests/bug_41125.phpt
+++ b/ext/pdo_mysql/tests/bug_41125.phpt
@@ -22,6 +22,7 @@ if ($version < 40100)
 <?php
 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
 $db = MySQLPDOTest::factory();
+$db->exec("DROP TABLE IF EXISTS test");
 
 // And now allow the evil to do his work
 $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
@@ -37,6 +38,12 @@ do {
 
 print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec("DROP TABLE IF EXISTS test");
+?>
 --EXPECTF--
 Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
 array(0) {
diff --git a/ext/pdo_mysql/tests/bug_41698.phpt b/ext/pdo_mysql/tests/bug_41698.phpt
index b2dee60..890ba77 100644
--- a/ext/pdo_mysql/tests/bug_41698.phpt
+++ b/ext/pdo_mysql/tests/bug_41698.phpt
@@ -22,16 +22,16 @@ $stmt = $db->prepare('INSERT INTO test VALUES(?)');
 $stmt->execute(array($value));
 var_dump($db->query('SELECT * from test')->fetchAll(PDO::FETCH_ASSOC));
 ?>
---EXPECT--
+--EXPECTF--
 array(2) {
   [0]=>
   array(1) {
-    ["floatval"]=>
-    string(8) "2.340000"
+    [%u|b%"floatval"]=>
+    %unicode|string%(8) "2.340000"
   }
   [1]=>
   array(1) {
-    ["floatval"]=>
-    string(8) "4.560000"
+    [%u|b%"floatval"]=>
+    %unicode|string%(8) "4.560000"
   }
 }
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/bug_41997.phpt b/ext/pdo_mysql/tests/bug_41997.phpt
index c48a641..ee0cfe9 100644
--- a/ext/pdo_mysql/tests/bug_41997.phpt
+++ b/ext/pdo_mysql/tests/bug_41997.phpt
@@ -38,17 +38,17 @@ var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 var_dump($stmt->errorInfo());
 print "done!";
 ?>
---EXPECT--
+--EXPECTF--
 array(1) {
   [0]=>
   array(1) {
-    ["one"]=>
-    string(1) "1"
+    [%u|b%"one"]=>
+    %unicode|string%(1) "1"
   }
 }
 array(3) {
   [0]=>
-  string(5) "00000"
+  %unicode|string%(5) "00000"
   [1]=>
   NULL
   [2]=>
@@ -57,13 +57,13 @@ array(3) {
 array(1) {
   [0]=>
   array(1) {
-    ["two"]=>
-    string(1) "2"
+    [%u|b%"two"]=>
+    %unicode|string%(1) "2"
   }
 }
 array(3) {
   [0]=>
-  string(5) "00000"
+  %unicode|string%(5) "00000"
   [1]=>
   NULL
   [2]=>
diff --git a/ext/pdo_mysql/tests/bug_42499.phpt b/ext/pdo_mysql/tests/bug_42499.phpt
index 4fcea87..dece019 100644
--- a/ext/pdo_mysql/tests/bug_42499.phpt
+++ b/ext/pdo_mysql/tests/bug_42499.phpt
@@ -61,8 +61,8 @@ Emulated Prepared Statements...
 array(1) {
   [0]=>
   array(1) {
-    ["_id"]=>
-    string(1) "a"
+    [%u|b%"_id"]=>
+    %unicode|string%(1) "a"
   }
 }
 
@@ -71,8 +71,8 @@ Native Prepared Statements...
 array(1) {
   [0]=>
   array(1) {
-    ["_id"]=>
-    string(1) "a"
+    [%u|b%"_id"]=>
+    %unicode|string%(1) "a"
   }
 }
 
diff --git a/ext/pdo_mysql/tests/bug_44454.phpt b/ext/pdo_mysql/tests/bug_44454.phpt
index e8f91a0..7ad7f85 100644
--- a/ext/pdo_mysql/tests/bug_44454.phpt
+++ b/ext/pdo_mysql/tests/bug_44454.phpt
@@ -63,9 +63,15 @@ bug_44454($db);
 
 print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --XFAIL--
 For some reason the exception gets thrown at the wrong place
---EXPECT--
+--EXPECTF--
 Native Prepared Statements
 ... SELECT has returned 1 row...
 ... INSERT should fail...
diff --git a/ext/pdo_mysql/tests/bug_44707.phpt b/ext/pdo_mysql/tests/bug_44707.phpt
index d5d4539..18c8104 100644
--- a/ext/pdo_mysql/tests/bug_44707.phpt
+++ b/ext/pdo_mysql/tests/bug_44707.phpt
@@ -73,7 +73,7 @@ bug_44707($db);
 
 print "done!";
 ?>
---EXPECT--
+--EXPECTF--
 Native Prepared Statements
 bool(false)
 bool(false)
@@ -83,10 +83,10 @@ array(0) {
 array(1) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["mybool"]=>
-    string(1) "0"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"mybool"]=>
+    %unicode|string%(1) "0"
   }
 }
 done!
diff --git a/ext/pdo_mysql/tests/bug_45120.phpt b/ext/pdo_mysql/tests/bug_45120.phpt
index 0e46d5e..db5da82 100644
--- a/ext/pdo_mysql/tests/bug_45120.phpt
+++ b/ext/pdo_mysql/tests/bug_45120.phpt
@@ -42,8 +42,6 @@ bug_45120($db);
 
 print "done!";
 ?>
---XFAIL--
-This is an open PDO bug. It is not a PDO_MYSQL bug
 --EXPECT--
 Emulated Prepared Statements
 Native Prepared Statements
diff --git a/ext/pdo_mysql/tests/bug_50323.phpt b/ext/pdo_mysql/tests/bug_50323.phpt
new file mode 100644
index 0000000..02050fa
--- /dev/null
+++ b/ext/pdo_mysql/tests/bug_50323.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Bug #50323 (No ability to connect to database named 't;', no chance to escape semicolon)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+
+    function changeDSN($original, $new_options) {
+        $old_options = array();
+        $dsn = substr($original,
+                strpos($original, ':') + 1,
+                strlen($original));
+
+        // no real parser - any excotic setting can fool us
+        $parts = explode(';', $dsn);
+        foreach ($parts as $k => $v) {
+            $tmp = explode('=', $v);
+            if (count($tmp) == 2)
+                    $old_options[$tmp[0]] = $tmp[1];
+        }
+
+        $options = $old_options;
+        foreach ($new_options as $k => $v)
+            $options[$k] = $v;
+
+        $dsn = 'mysql:';
+        foreach ($options as $k => $v)
+            $dsn .= sprintf('%s=%s;', $k, $v);
+
+        $dsn = substr($dsn, 0, strlen($dsn) -1);
+
+        return $dsn;
+    }
+
+
+if (1 === @$db->exec('CREATE DATABASE `crazy;dbname`')) {
+    $dsn = changeDSN(getenv('PDOTEST_DSN'), array('dbname' => 'crazy;;dbname'));
+    $user = getenv('PDOTEST_USER');
+    $pass = getenv('PDOTEST_PASS');
+    
+    new PDO($dsn, $user, $pass);
+}
+echo 'done!';
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+
+@$db->exec('DROP DATABASE IF EXISTS `crazy;dbname`');
+?>
+--EXPECTF--
+done!
+
diff --git a/ext/pdo_mysql/tests/bug_pecl_12925.phpt b/ext/pdo_mysql/tests/bug_pecl_12925.phpt
index 1e7cea5..1867868 100644
--- a/ext/pdo_mysql/tests/bug_pecl_12925.phpt
+++ b/ext/pdo_mysql/tests/bug_pecl_12925.phpt
@@ -42,21 +42,21 @@ bug_pecl_1295($db);
 $db->exec('DROP TABLE IF EXISTS test');
 print "done!";
 ?>
---EXPECT--
+--EXPECTF--
 Emulated...
 array(1) {
   [0]=>
   array(1) {
-    ["id"]=>
-    string(1) "c"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "c"
   }
 }
 Native...
 array(1) {
   [0]=>
   array(1) {
-    ["id"]=>
-    string(1) "c"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "c"
   }
 }
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/bug_pecl_7976.phpt b/ext/pdo_mysql/tests/bug_pecl_7976.phpt
index 24e934f..5f585bd 100644
--- a/ext/pdo_mysql/tests/bug_pecl_7976.phpt
+++ b/ext/pdo_mysql/tests/bug_pecl_7976.phpt
@@ -48,40 +48,45 @@ $db = MySQLPDOTest::factory();
 $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
 bug_pecl_7976($db);
 
-$db->exec('DROP PROCEDURE IF EXISTS p');
 print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP PROCEDURE IF EXISTS p');
+?>
 --XFAIL--
 Works with mysqlnd. It is not supported by libmysql. For libmysql is good enough to see no crash.
---EXPECT--
+--EXPECTF--
 Emulated...
 array(1) {
   [0]=>
   array(1) {
-    ["_one"]=>
-    string(1) "1"
+    [%u|b%"_one"]=>
+    %unicode|string%(1) "1"
   }
 }
 array(1) {
   [0]=>
   array(1) {
-    ["_one"]=>
-    string(1) "1"
+    [%u|b%"_one"]=>
+    %unicode|string%(1) "1"
   }
 }
 Native...
 array(1) {
   [0]=>
   array(1) {
-    ["_one"]=>
-    string(1) "1"
+    [%u|b%"_one"]=>
+    %unicode|string%(1) "1"
   }
 }
 array(1) {
   [0]=>
   array(1) {
-    ["_one"]=>
-    string(1) "1"
+    [%u|b%"_one"]=>
+    %unicode|string%(1) "1"
   }
 }
 done!
diff --git a/ext/pdo_mysql/tests/mysql_pdo_test.inc b/ext/pdo_mysql/tests/mysql_pdo_test.inc
index aa98d14..7367919 100644
--- a/ext/pdo_mysql/tests/mysql_pdo_test.inc
+++ b/ext/pdo_mysql/tests/mysql_pdo_test.inc
@@ -158,5 +158,12 @@ class MySQLPDOTest extends PDOTest {
 			return (bool)preg_match('/Client API version.*mysqlnd/', $tmp);
 	}
 
+	static function dropTestTable($db = NULL) {
+		if (is_null($db)) 
+			$db = self::factory();
+
+		$db->exec('DROP TABLE IF EXISTS test');
+	}
+
 }
-?>
+?>
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct.phpt
index 8602a49..4601553 100644
--- a/ext/pdo_mysql/tests/pdo_mysql___construct.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql___construct.phpt
@@ -101,7 +101,8 @@ MySQLPDOTest::skip();
 		}
 
 		// what about long values for a valid option ...
-		$dsn = MySQLPDOTest::getDSN(array('host' => str_repeat('0123456789', 1024 * 100)));
+		// hostnames > 1024 chars break on some NIS-enabled FreeBSD...
+		$dsn = MySQLPDOTest::getDSN(array('host' => str_repeat('0123456789', 100)));
 		try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) {
 			$tmp = $e->getMessage();
 			if (!stristr($tmp, 'HY000') && !stristr($tmp, '2005') && !stristr($tmp, '2002'))
@@ -285,6 +286,7 @@ MySQLPDOTest::skip();
 	}
 
 	print "done!";
+?>
 --EXPECTF--
 [002] invalid data source name, [n/a] n/a
 [003] invalid data source name, [n/a] n/a
@@ -295,4 +297,4 @@ MySQLPDOTest::skip();
 [009] SQLSTATE[28000] [1045] Access denied for user 'dont%s'@'%s' (using password: YES), [n/a] n/a
 [010] SQLSTATE[28000] [1045] Access denied for user 'dont%s'@'%s' (using password: YES), [n/a] n/a
 [017] DSN=%s, SQLSTATE[%s] [%d] %s
-[033] DSN = mysql:%s, character sets has not been set, @@character_set_connection reports 'latin1', expecting 'latin2'done!
\ No newline at end of file
+[033] DSN = mysql:%s, character sets has not been set, @@character_set_connection reports 'latin1', expecting 'latin2'done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt
index 5bd824b..14f81a6 100644
--- a/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt
@@ -8,7 +8,6 @@ MySQLPDOTest::skip();
 /* TODO - fix this limitation */
 if (getenv('PDO_MYSQL_TEST_DSN') !== "mysql:dbname=phptest;unix_socket=/tmp/mysql.sock")
 	die("skip Fix test to run in other environments as well!");
-
 ?>
 --INI--
 pdo.dsn.mysql="mysql:dbname=phptest;socket=/tmp/mysql.sock"
@@ -51,6 +50,7 @@ pdo.dsn.mysql="mysql:dbname=phptest;socket=/tmp/mysql.sock"
 	}
 
 	print "done!";
+?>
 --EXPECTF--
 pdo.dsn.mysql cannot be accessed through ini_get_all()/ini_get()
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt
index 8bd714d..c0df4a5 100644
--- a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt
@@ -46,6 +46,8 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
 			PDO::MYSQL_ATTR_USE_BUFFERED_QUERY		=> 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY',
 			PDO::MYSQL_ATTR_LOCAL_INFILE					=> 'PDO::MYSQL_ATTR_LOCAL_INFILE',
 			PDO::MYSQL_ATTR_DIRECT_QUERY					=> 'PDO::MYSQL_ATTR_DIRECT_QUERY',
+
+			PDO::MYSQL_ATTR_INIT_COMMAND					=> 'PDO::MYSQL_ATTR_INIT_COMMAND',
 		);
 
 		$defaults = array(
@@ -59,6 +61,7 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
 			PDO::MYSQL_ATTR_LOCAL_INFILE					=> false,
 			/* TODO getAttribute() does not handle it */
 			PDO::MYSQL_ATTR_DIRECT_QUERY					=> 1,
+			PDO::MYSQL_ATTR_INIT_COMMAND					=> '',
 		);
 
 		if (NULL !== ($db = @new PDO($dsn, $user, $pass, 'wrong type')))
@@ -140,6 +143,10 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
 		set_option_and_check(21, PDO::MYSQL_ATTR_LOCAL_INFILE, true, 'PDO::MYSQL_ATTR_LOCAL_INFILE');
 		set_option_and_check(22, PDO::MYSQL_ATTR_LOCAL_INFILE, false, 'PDO::MYSQL_ATTR_LOCAL_INFILE');
 
+		set_option_and_check(23, PDO::MYSQL_ATTR_INIT_COMMAND, 'SET @a=1', 'PDO::MYSQL_ATTR_INIT_COMMAND');
+		set_option_and_check(24, PDO::MYSQL_ATTR_INIT_COMMAND, '', 'PDO::MYSQL_ATTR_INIT_COMMAND');
+		set_option_and_check(25, PDO::MYSQL_ATTR_INIT_COMMAND, 'INSERT INTO nonexistent(invalid) VALUES (1)', 'PDO::MYSQL_ATTR_INIT_COMMAND');
+
 		set_option_and_check(33, PDO::MYSQL_ATTR_DIRECT_QUERY, 1, 'PDO::MYSQL_ATTR_DIRECT_QUERY');
 		set_option_and_check(34, PDO::MYSQL_ATTR_DIRECT_QUERY, 0, 'PDO::MYSQL_ATTR_DIRECT_QUERY');
 
@@ -151,9 +158,11 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
 	}
 
 	print "done!";
+?>
 --EXPECTF--
 [003] [TODO][CHANGEREQUEST] Please, lets not ignore invalid options and bail out!
 [003a] Expecting default value for 'PDO::ATTR_EMULATE_PREPARES' of '1'/integer, getAttribute() reports setting ''/boolean
+[003a] Expecting default value for 'PDO::MYSQL_ATTR_INIT_COMMAND' of ''/string, getAttribute() reports setting ''/boolean
 
 Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in %s on line %d
 [010] [TODO][CHANGEREQUEST] ATTR_EMULATE_PREPARES should be on
@@ -167,4 +176,7 @@ Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this func
 Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in %s on line %d
 [018] PDO::MYSQL_ATTR_DIRECT_QUERY should be off
 [021] Execting '1'/boolean got ''/boolean' for options 'PDO::MYSQL_ATTR_LOCAL_INFILE'
-done!
\ No newline at end of file
+[023] Execting 'SET @a=1'/string got ''/boolean' for options 'PDO::MYSQL_ATTR_INIT_COMMAND'
+[024] SQLSTATE[42000] [1065] Query was empty
+[025] SQLSTATE[42S02] [1146] Table 'test.nonexistent' doesn't exist
+done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt
index 8a8e347..4c9e414 100644
--- a/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt
@@ -59,10 +59,6 @@ if (MySQLPDOTest::isPDOMySQLnd())
 					$tmp, gettype($tmp));
 		}
 
-		set_option_and_check(23, PDO::MYSQL_ATTR_INIT_COMMAND, 'SET @a=1', 'PDO::MYSQL_ATTR_INIT_COMMAND');
-		set_option_and_check(24, PDO::MYSQL_ATTR_INIT_COMMAND, '', 'PDO::MYSQL_ATTR_INIT_COMMAND');
-		set_option_and_check(25, PDO::MYSQL_ATTR_INIT_COMMAND, 'INSERT INTO nonexistent(invalid) VALUES (1)', 'PDO::MYSQL_ATTR_INIT_COMMAND');
-
 		set_option_and_check(26, PDO::MYSQL_ATTR_READ_DEFAULT_FILE, true, 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE');
 		set_option_and_check(27, PDO::MYSQL_ATTR_READ_DEFAULT_FILE, false, 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE');
 
@@ -79,10 +75,8 @@ if (MySQLPDOTest::isPDOMySQLnd())
 	}
 
 	print "done!";
+?>
 --EXPECTF--
 [001] Expecting default value for 'PDO::MYSQL_ATTR_INIT_COMMAND' of ''/string, getAttribute() reports setting ''/boolean
-[023] Execting 'SET @a=1'/string got ''/boolean' for options 'PDO::MYSQL_ATTR_INIT_COMMAND'
-[024] SQLSTATE[42000] [1065] Query was empty
-[025] SQLSTATE[42S02] [1146] Table '%snonexistent' doesn't exist
 [026] Execting '1'/boolean got ''/boolean' for options 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE'
 done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt
index 87e1a1e..7e92ff2 100644
--- a/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt
@@ -66,6 +66,7 @@ MySQLPDOTest::skip();
 	}
 
 	print "done!";
+?>
 --EXPECTF--
 Warning: PDO::__construct(%s
 [002] URI=uri:file:%spdomuri.tst, DSN=mysql%sdbname=%s, File=%spdomuri.tst (%d bytes, 'mysql%sdbname=%s'), invalid data source URI
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt
index b489528..b1e5507 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt
@@ -87,7 +87,12 @@ $db = MySQLPDOTest::factory();
 
 	}
 
-	$db->exec(sprintf('DROP TABLE IF EXISTS test'));
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt
index c7a2037..618d9e6 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt
@@ -81,86 +81,91 @@ $db = MySQLPDOTest::factory();
 			var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
 
 	var_dump($stmt->fetchAll(PDO::FETCH_BOTH));
-
-	$db->exec(sprintf('DROP TABLE IF EXISTS test'));
+	
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
-string(15) "PDO::CASE_LOWER"
+%unicode|string%(15) "PDO::CASE_LOWER"
 array(2) {
   [0]=>
   array(6) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
     [0]=>
-    string(1) "1"
-    ["id_upper"]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
+    [%u|b%"id_upper"]=>
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
     [2]=>
-    string(1) "a"
+    %unicode|string%(1) "a"
   }
   [1]=>
   array(6) {
-    ["id"]=>
-    string(1) "2"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
     [0]=>
-    string(1) "2"
-    ["id_upper"]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
+    [%u|b%"id_upper"]=>
+    %unicode|string%(1) "2"
     [1]=>
-    string(1) "2"
-    ["label"]=>
-    string(1) "b"
+    %unicode|string%(1) "2"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "b"
     [2]=>
-    string(1) "b"
+    %unicode|string%(1) "b"
   }
 }
 array(2) {
   [0]=>
   array(10) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
     [0]=>
-    string(1) "1"
-    ["id_upper"]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
+    [%u|b%"id_upper"]=>
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
     [2]=>
-    string(1) "a"
-    ["mixed"]=>
+    %unicode|string%(1) "a"
+    [%u|b%"mixed"]=>
     NULL
     [3]=>
     NULL
-    ["myupper"]=>
+    [%u|b%"myupper"]=>
     NULL
     [4]=>
     NULL
   }
   [1]=>
   array(10) {
-    ["id"]=>
-    string(1) "2"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
     [0]=>
-    string(1) "2"
-    ["id_upper"]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
+    [%u|b%"id_upper"]=>
+    %unicode|string%(1) "2"
     [1]=>
-    string(1) "2"
-    ["label"]=>
-    string(1) "b"
+    %unicode|string%(1) "2"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "b"
     [2]=>
-    string(1) "b"
-    ["mixed"]=>
+    %unicode|string%(1) "b"
+    [%u|b%"mixed"]=>
     NULL
     [3]=>
     NULL
-    ["myupper"]=>
+    [%u|b%"myupper"]=>
     NULL
     [4]=>
     NULL
@@ -169,23 +174,23 @@ array(2) {
 array(1) {
   [0]=>
   array(10) {
-    ["ID"]=>
-    string(1) "1"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "1"
     [0]=>
-    string(1) "1"
-    ["LABEL"]=>
-    string(1) "a"
+    %unicode|string%(1) "1"
+    [%u|b%"LABEL"]=>
+    %unicode|string%(1) "a"
     [1]=>
-    string(1) "a"
-    ["MIXED"]=>
+    %unicode|string%(1) "a"
+    [%u|b%"MIXED"]=>
     NULL
     [2]=>
     NULL
-    ["MYUPPER"]=>
+    [%u|b%"MYUPPER"]=>
     NULL
     [3]=>
     NULL
-    ["LOWER"]=>
+    [%u|b%"LOWER"]=>
     NULL
     [4]=>
     NULL
@@ -194,26 +199,26 @@ array(1) {
 array(1) {
   [0]=>
   array(10) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
     [0]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
     [1]=>
-    string(1) "a"
-    ["MiXeD"]=>
+    %unicode|string%(1) "a"
+    [%u|b%"MiXeD"]=>
     NULL
     [2]=>
     NULL
-    ["MYUPPER"]=>
+    [%u|b%"MYUPPER"]=>
     NULL
     [3]=>
     NULL
-    ["ID"]=>
-    string(1) "1"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "1"
     [4]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
   }
 }
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_client_version.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_client_version.phpt
index e3f21fb..2d93963 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_client_version.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_client_version.phpt
@@ -32,5 +32,6 @@ $db = MySQLPDOTest::factory();
 		printf("[003] Did we change it from '%s' to '%s'?\n", $version, $new_version);
 
 	print "done!";
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt
index 038df3c..187f9ec 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt
@@ -32,5 +32,6 @@ $db = MySQLPDOTest::factory();
 		printf("[005] Connection status should not have changed\n");
 
 	print "done!";
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt
index 0c156e4..8661dda 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt
@@ -25,6 +25,7 @@ $db = MySQLPDOTest::factory();
 		printf("[002] Did we change it from '%s' to '%s'?\n", $name, $new_name);
 
 	print "done!";
+?>
 --EXPECTF--
-string(5) "mysql"
+%unicode|string%(5) "mysql"
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt
index 3b2b092..b9a4fc9 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt
@@ -23,19 +23,20 @@ MySQLPDOTest::skip();
 	$stmt->closeCursor();
 
 	print "done!";
+?>
 --EXPECTF--
 array(1) {
   [0]=>
   array(1) {
-    ["test.label"]=>
-    string(1) "a"
+    [%u|b%"test.label"]=>
+    %unicode|string%(1) "a"
   }
 }
 array(1) {
   [0]=>
   array(1) {
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt
index 8d086b7..89e6f38 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt
@@ -33,7 +33,8 @@ error_reporting=E_ALL
 	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 
 	$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
-	print "done!\n";
+	print "done!";
+?>
 --EXPECTF--
 %unicode|string%(58) "CREATE TABLE test_%s(id INT)"
 %unicode|string%(5) "00000"
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt
index 9ba8dee..115103d 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt
@@ -62,6 +62,13 @@ if (MySQLPDOTest::isPDOMySQLnd())
 	try_buffer_size(4, 2000);
 
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 [001] id = 1, val = 0123456789... (length: %d)
 [002] id = 1, val = 0123456789... (length: 1000)
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 9e938ef..cdc0b26 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt
@@ -80,41 +80,42 @@ MySQLPDOTest::skip();
 		@$db->exec('DROP PROCEDURE IF EXISTS p');
 
 	print "done!";
+?>
 --EXPECTF--
 [002] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...
 [003] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...
 array(1) {
   [0]=>
   array(6) {
-    ["z"]=>
+    [%u|b%"z"]=>
     NULL
-    ["a"]=>
+    [%u|b%"a"]=>
     NULL
-    ["b"]=>
-    string(1) " "
-    ["c"]=>
+    [%u|b%"b"]=>
+    %unicode|string%(1) " "
+    [%u|b%"c"]=>
     NULL
-    ["d"]=>
-    string(2) " d"
-    ["e"]=>
-    string(3) "%se"
+    [%u|b%"d"]=>
+    %unicode|string%(2) " d"
+    [%u|b%"e"]=>
+    %unicode|string%(3) "%se"
   }
 }
 array(1) {
   [0]=>
   array(6) {
-    ["z"]=>
+    [%u|b%"z"]=>
     NULL
-    ["a"]=>
-    string(0) ""
-    ["b"]=>
-    string(1) " "
-    ["c"]=>
-    string(0) ""
-    ["d"]=>
-    string(2) " d"
-    ["e"]=>
-    string(3) "%se"
+    [%u|b%"a"]=>
+    %unicode|string%(0) ""
+    [%u|b%"b"]=>
+    %unicode|string%(1) " "
+    [%u|b%"c"]=>
+    %unicode|string%(0) ""
+    [%u|b%"d"]=>
+    %unicode|string%(2) " d"
+    [%u|b%"e"]=>
+    %unicode|string%(3) "%se"
   }
 }
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt
index 07bb8c3..a59a6b0 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt
@@ -60,5 +60,6 @@ $db = MySQLPDOTest::factory();
 		printf("[010] Did we change it from '%s' to '%s'?\n", $version, $new_version);
 
 	print "done!";
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt
index d077f6e..631a918 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt
@@ -106,10 +106,11 @@ $db = MySQLPDOTest::factory();
 	$stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 1');
 
 	print "done!";
+?>
 --EXPECTF--
 array(1) {
   [0]=>
-  string(12) "PDOStatement"
+  %unicode|string%(12) "PDOStatement"
 }
 
 Warning: PDO::setAttribute(): SQLSTATE[HY000]: General error: PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); the classname must be a string specifying an existing class in %s on line %d
@@ -125,29 +126,29 @@ Warning: PDO::setAttribute(): SQLSTATE[HY000]: General error: user-supplied stat
 Warning: PDO::setAttribute(): SQLSTATE[HY000]: General error in %s on line %d
 array(2) {
   [0]=>
-  string(12) "mystatement4"
+  %unicode|string%(12) "mystatement4"
   [1]=>
   array(1) {
     [0]=>
-    string(6) "param1"
+    %unicode|string%(6) "param1"
   }
 }
 mystatement4
-string(6) "param1"
+%unicode|string%(6) "param1"
 mystatement5
-string(12) "mystatement5"
-string(10) "no data :)"
+%unicode|string%(12) "mystatement5"
+%unicode|string%(10) "no data :)"
 array(1) {
   [0]=>
   array(4) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
     [0]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
     [1]=>
-    string(1) "a"
+    %unicode|string%(1) "a"
   }
 }
 
diff --git a/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt b/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt
index 30aecf4..8871a31 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt
@@ -120,7 +120,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 	$tmp = $stmt->fetch(PDO::FETCH_ASSOC);
 	if ($tmp['auto_commit'] != 0)
 		printf("[026] Autocommit mode of the MySQL Server should be off, got '%s', [%d] %s\n",
-			$tmp['auto_commit'], $stmt->errorCode(), implode(' ', $stmt->errorInfo()));
+			$tmp['auto_commit'], $stmt->errorCode(), trim(implode(' ', $stmt->errorInfo())));
 
 	$db->commit();
 	// Now we should be back to autocommit - we've issues a commit
@@ -179,23 +179,28 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 	if (1 != $db->exec('DELETE FROM test'))
 		printf("[038] No rows deleted, can't be true.\n");
 
-	$db->exec(sprintf('DROP TABLE IF EXISTS test'));
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 array(2) {
-  ["id"]=>
-  string(1) "1"
-  ["label"]=>
-  string(1) "a"
+  [%u|b%"id"]=>
+  %unicode|string%(1) "1"
+  [%u|b%"label"]=>
+  %unicode|string%(1) "a"
 }
 bool(false)
 array(2) {
-  ["id"]=>
-  string(1) "1"
-  ["label"]=>
-  string(1) "z"
+  [%u|b%"id"]=>
+  %unicode|string%(1) "1"
+  [%u|b%"label"]=>
+  %unicode|string%(1) "z"
 }
-[026] Autocommit mode of the MySQL Server should be off, got '1', [0] 00000  
+[026] Autocommit mode of the MySQL Server should be off, got '1', [0] 00000
 [028] I'm confused, how can autocommit be on? Didn't I say I want to manually control transactions?
-string(5) "00000"
+%unicode|string%(5) "00000"
 done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql_bit.phpt b/ext/pdo_mysql/tests/pdo_mysql_bit.phpt
index 18506ac..899231a 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_bit.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_bit.phpt
@@ -35,7 +35,6 @@ if (MySQLPDOTest::isPDOMySQLnd())
 		var_dump($row);
 		var_dump($value);
 
-
 		return true;
 	}
 
@@ -48,12 +47,18 @@ if (MySQLPDOTest::isPDOMySQLnd())
 
 	echo "done!\n";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 array(2) {
-  ["id"]=>
-  string(2) "20"
-  ["label"]=>
-  string(1) "1"
+  [%u|b%"id"]=>
+  %unicode|string%(2) "20"
+  [%u|b%"label"]=>
+  %unicode|string%(1) "1"
 }
 int(1)
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt b/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt
index b09c1a5..9200d7b 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt
@@ -12,16 +12,16 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
 		'MYSQL_ATTR_USE_BUFFERED_QUERY'		=> true,
 		'MYSQL_ATTR_LOCAL_INFILE'					=> true,
 		'MYSQL_ATTR_DIRECT_QUERY'					=> true,
-		'MYSQL_ATTR_FOUND_ROWS'							=> true,
+		'MYSQL_ATTR_FOUND_ROWS'						=> true,
 		'MYSQL_ATTR_IGNORE_SPACE'					=> true,
+		'MYSQL_ATTR_INIT_COMMAND'					=> true,
 	);
 
 	if (!MySQLPDOTest::isPDOMySQLnd()) {
 		$expected['MYSQL_ATTR_MAX_BUFFER_SIZE'] 		= true;
-		$expected['MYSQL_ATTR_INIT_COMMAND'] 				= true;
 		$expected['MYSQL_ATTR_READ_DEFAULT_FILE'] 	= true;
 		$expected['MYSQL_ATTR_READ_DEFAULT_GROUP'] 	= true;
-		$expected['MYSQL_ATTR_COMPRESS']			= true;
+		$expected['MYSQL_ATTR_COMPRESS']						= true;
 	}
 
 	/*
diff --git a/ext/pdo_mysql/tests/pdo_mysql_commit.phpt b/ext/pdo_mysql/tests/pdo_mysql_commit.phpt
index 056c0e0..e213f66 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_commit.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_commit.phpt
@@ -78,7 +78,13 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 			$db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec(sprintf('DROP TABLE IF EXISTS test_commit'));
 	print "done!";
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test_commit');
+MySQLPDOTest::dropTestTable($db);
+?>
 --EXPECT--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt b/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt
index 35056a7..b970c4e 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt
@@ -75,7 +75,12 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_errorinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_errorinfo.phpt
index 99b2b84..93e1fbf 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_errorinfo.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_errorinfo.phpt
@@ -29,8 +29,6 @@ $db = MySQLPDOTest::factory();
 				printf("[%03d] Driver-specific error message.not set\n", $offset);
 		}
 
-		
-
 	}
 
 	function pdo_mysql_errorinfo($db, $offset) {
@@ -96,9 +94,13 @@ $db = MySQLPDOTest::factory();
 	printf("Native Prepared Statements...\n");
 	pdo_mysql_errorinfo($db, 20);
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 Emulated Prepared Statements...
 [015] Driver-specific error code not set
diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec.phpt
index 5ca5f44..381a2b5 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_exec.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_exec.phpt
@@ -170,8 +170,14 @@ MySQLPDOTest::skip();
 	}
 	$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
 
-	@$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+@$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 Warning: PDO::exec(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'THIS IS NOT VALID SQL, I HOPE' at line 1 in %s on line %d
 [016] [42000] 42000 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'THIS IS NOT VALID SQL, I HOPE' at line %d
diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt
index 00a2de1..2e80053 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt
@@ -70,13 +70,6 @@ MySQLPDOTest::skip();
 		11.1.17. DROP TABLESPACE Syntax
 		*/
 
-		// clean up
-		@$db->exec('DROP TABLE IF EXISTS pdo_exec_ddl');
-		@$db->exec('DROP TABLE IF EXISTS pdo_exec_ddl2');
-		@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl');
-		@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl2');
-
-
 	} catch (PDOException $e) {
 		printf("[001] %s, [%s] %s\n",
 			$e->getMessage(),
@@ -84,5 +77,16 @@ MySQLPDOTest::skip();
 	}
 
 	print "done!";
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+MySQLPDOTest::dropTestTable($db);
+// clean up
+@$db->exec('DROP TABLE IF EXISTS pdo_exec_ddl');
+@$db->exec('DROP TABLE IF EXISTS pdo_exec_ddl2');
+@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl');
+@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl2');
+?>
 --EXPECTF--
 done!
\ No newline at end of file
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 ecfa502..1310c0e 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
@@ -96,7 +96,13 @@ if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1'))
 			$db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt
index a759f72..ef85fab 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt
@@ -50,9 +50,15 @@ MySQLPDOTest::skip();
 			$e->getMessage(),
 			$db->errorCode(), implode(' ', $db->errorInfo()));
 	}
-
-	@$db->exec(sprintf('DROP TABLE IF EXISTS test'));
+	
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+@$db->exec('DROP TABLE IF EXISTS test');
+?>
 --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.
diff --git a/ext/pdo_mysql/tests/pdo_mysql_fetch_both.phpt b/ext/pdo_mysql/tests/pdo_mysql_fetch_both.phpt
index a8cbde6..da88639 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_fetch_both.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_fetch_both.phpt
@@ -56,33 +56,33 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec(sprintf('DROP TABLE IF EXISTS test'));
 	print "done!";
+?>
 --EXPECTF--
 [002] Suspicious FETCH_BOTH result, dumping
 array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
 }
 array(2) {
   [1]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [2]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
 }
 [002] Expected differes from returned data, dumping
 array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
 }
 array(2) {
   [1]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [2]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
 }
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt b/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt
index 74f17d5..c992d3a 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt
@@ -94,8 +94,13 @@ PDO::ATTR_CONNECTION_STATUS
 PDO::ATTR_SERVER_INFO
 */
 
-	$db->exec(sprintf('DROP TABLE IF EXISTS test'));
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 [001] Call to PDO::setAttribute(int attribute, mixed value) has changed the type of value from integer to boolean, test will not work properly
 done!
\ No newline at end of file
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 552128c..2bb5573 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt
@@ -108,7 +108,12 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec(sprintf('DROP TABLE IF EXISTS test'));
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt b/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt
index e5ab3d5..eb0fff1 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt
@@ -92,10 +92,6 @@ MySQLPDOTest::skip();
 	}
 
 	print "done!";
---XFAIL--
-Expected to fail in debug mode as PDO doesn't properly clean persistent connections
+?>
 --EXPECTF--
-Warning: PDO::exec(): MySQL server has gone away in %s on line %d
-
-Warning: PDO::exec(): Error while reading SET_OPTION's EOF packet. PID=%d in %s on line %d
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt
index 30e7bda..a570c1f 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt
@@ -26,5 +26,6 @@ $db = MySQLPDOTest::factory();
 	}
 
 	print "done!";
+?>
 --EXPECT--
 done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt
index fa942f3..4447146 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt
@@ -316,99 +316,104 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --XFAIL--
 PDO's PS parser has some problems with invalid SQL and crashes from time to time
 (check with valgrind...)
 --EXPECTF--
 array(1) {
-  ["one"]=>
-  string(1) "1"
+  [%u|b%"one"]=>
+  %unicode|string%(1) "1"
 }
 array(1) {
   [0]=>
   array(1) {
-    ["label"]=>
-    string(12) ":placeholder"
+    [%u|b%"label"]=>
+    %unicode|string%(12) ":placeholder"
   }
 }
 array(1) {
   [0]=>
   array(1) {
-    ["label"]=>
-    string(12) ":placeholder"
+    [%u|b%"label"]=>
+    %unicode|string%(12) ":placeholder"
   }
 }
 array(2) {
   [0]=>
   array(1) {
-    ["label"]=>
-    string(9) "first row"
+    [%u|b%"label"]=>
+    %unicode|string%(9) "first row"
   }
   [1]=>
   array(1) {
-    ["label"]=>
-    string(10) "second row"
+    [%u|b%"label"]=>
+    %unicode|string%(10) "second row"
   }
 }
 array(2) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(3) "row"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(3) "row"
   }
   [1]=>
   array(2) {
-    ["id"]=>
-    string(1) "2"
-    ["label"]=>
-    string(3) "row"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"label"]=>
+    %unicode|string%(3) "row"
   }
 }
 array(1) {
   [0]=>
   array(1) {
-    ["label"]=>
-    string(1) "?"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "?"
   }
 }
 array(1) {
   [0]=>
   array(1) {
-    ["label"]=>
-    string(1) "?"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "?"
   }
 }
 array(2) {
   [0]=>
   array(1) {
-    ["label"]=>
-    string(9) "first row"
+    [%u|b%"label"]=>
+    %unicode|string%(9) "first row"
   }
   [1]=>
   array(1) {
-    ["label"]=>
-    string(10) "second row"
+    [%u|b%"label"]=>
+    %unicode|string%(10) "second row"
   }
 }
 array(2) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(3) "row"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(3) "row"
   }
   [1]=>
   array(2) {
-    ["id"]=>
-    string(1) "2"
-    ["label"]=>
-    string(3) "row"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"label"]=>
+    %unicode|string%(3) "row"
   }
 }
 done!
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 30edcbe..c382025 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt
@@ -56,17 +56,22 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 array(1) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "?"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "?"
   }
 }
 now the same with native PS
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 a8faa8d..e8f7d39 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
@@ -52,9 +52,14 @@ MySQLPDOTest::skip();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec(sprintf('DROP TABLE IF EXISTS test'));
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number in %s on line %d
 [003] Execute has failed, 'HY093' array (
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 1f8a4c2..b8b77ff 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt
@@ -100,9 +100,14 @@ if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1'))
 			implode(' ', $db->errorInfo()),
 			(isset($stmt)) ? implode(' ', $stmt->errorInfo()) : 'N/A');
 	}
-
-	// $db->exec('DROP TABLE IF EXISTS test');
+	
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 Warning: PDOStatement::execute(): SQLSTATE[HY000]: General error: %s in %s on line %d
 [004] [0] array (
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_match_against.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_match_against.phpt
index 54257be..ba5142a 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_match_against.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_match_against.phpt
@@ -36,8 +36,14 @@ MySQLPDOTest::skip();
 
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 array(0) {
 }
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt
index 1d5f301..b9027c8 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt
@@ -333,9 +333,14 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 array(1) {
   [0]=>
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 33c699c..8c367af 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
@@ -66,9 +66,14 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 Warning: PDOStatement::execute(): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'unknown_column' in 'field list' in %s on line %d
 [003] Execute has failed, '42S22' array (
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt
index b497268..57a4529 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt
@@ -26,9 +26,14 @@ $db = MySQLPDOTest::factory();
 
 	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 array(1) {
   [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 4f90196..c9d122a 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
@@ -92,9 +92,14 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 Native...
 
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt
index c8d1a5b..90cedef 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt
@@ -24,9 +24,13 @@ $db = MySQLPDOTest::factory();
 	$stmt->execute(array(1, 1));
 	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 Warning: PDO::prepare(): SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters in %s on line %d
 
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 4ead73d..c4a74ea 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
@@ -64,9 +64,14 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 [003] Execute has failed, 'HY093' array (
   0 => 'HY093',
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 aa7815d..0f8c888 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
@@ -57,9 +57,14 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 array(1) {
   [0]=>
diff --git a/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt b/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt
index 358d4a7..193b1a1 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt
@@ -79,9 +79,15 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 	$db->commit();
 	var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT));
 
-	$db->exec('DROP TABLE IF EXISTS test');
-	$db->exec('DROP TABLE IF EXISTS test2');
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+$db->exec('DROP TABLE IF EXISTS test2');
+?>
 --EXPECTF--
 int(1)
 int(0)
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt
index 394ed4f..dd4920e 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt
@@ -99,9 +99,14 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 id = 1 (integer) / label = 'a' (string)
 id = 2 (integer) / label = 'b' (string)
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt
index 993ea04..70b2f3f 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt
@@ -114,9 +114,13 @@ MySQLPDOTest::skip();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 Emulated PS...
 Buffered...
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt
index 64d4df0..9421f62 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt
@@ -162,8 +162,12 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt
index 6dc557d..1c62d77 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt
@@ -293,9 +293,13 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 Testing native PS...
 Binding variable...
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_blobfromsteam.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_blobfromsteam.phpt
index 88b847c..ae7e7fc 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_blobfromsteam.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_blobfromsteam.phpt
@@ -132,11 +132,16 @@ unlink($file);
 		printf("[001] %s [%s] %s\n",
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
-
-	@unlink($file);
-	$db->exec('DROP TABLE IF EXISTS test');
+	
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+ at unlink(MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . 'pdoblob.tst');
+?>
 --EXPECTF--
 Emulated PS...
 Native PS...
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_blobs.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_blobs.phpt
index 2914583..96489ef 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_blobs.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_blobs.phpt
@@ -87,5 +87,12 @@ MySQLPDOTest::skip();
 	}
 
 	print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt
index c96da1f..455b17d 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt
@@ -142,10 +142,14 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 Testing emulated PS...
 Buffered...
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt
index a575014..aea272b 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt
@@ -61,6 +61,11 @@ $db = MySQLPDOTest::factory();
 	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 in = 0 -> id = 1 (integer) / label = 'a' (string)
 in = 0 -> id = 2 (integer) / label = 'b' (string)
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt
index 508ba0a..85985dd 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt
@@ -52,9 +52,13 @@ $db = MySQLPDOTest::factory();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 Testing emulated PS...
 int(3)
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt
index 8772006..4d59e8c 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt
@@ -40,8 +40,6 @@ $db = MySQLPDOTest::factory();
 		$stmt->execute();
 		var_dump($stmt->errorCode());
 
-
-
 	} catch (PDOException $e) {
 		printf("[003] %s [%s] %s\n",
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt
index da37253..d5a3489 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt
@@ -59,11 +59,16 @@ $db = MySQLPDOTest::factory();
 	}
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 Testing emulated PS...
 array(3) {
   [0]=>
-  string(0) ""
+  %unicode|string%(0) ""
   [1]=>
   NULL
   [2]=>
@@ -73,26 +78,26 @@ array(3) {
 Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d
 array(3) {
   [0]=>
-  string(5) "42S02"
+  %unicode|string%(5) "42S02"
   [1]=>
   int(1146)
   [2]=>
-  string(%d) "Table '%s.ihopeitdoesnotexist' doesn't exist"
+  %unicode|string%(%d) "Table '%s.ihopeitdoesnotexist' doesn't exist"
 }
 
 Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test' doesn't exist in %s on line %d
 bool(false)
 array(3) {
   [0]=>
-  string(5) "42S02"
+  %unicode|string%(5) "42S02"
   [1]=>
   int(1146)
   [2]=>
-  string(%d) "Table '%s.test' doesn't exist"
+  %unicode|string%(%d) "Table '%s.test' doesn't exist"
 }
 array(3) {
   [0]=>
-  string(5) "00000"
+  %unicode|string%(5) "00000"
   [1]=>
   NULL
   [2]=>
@@ -104,7 +109,7 @@ Warning: PDO::prepare(): SQLSTATE[42S02]: Base table or view not found: 1146 Tab
 bool(false)
 array(3) {
   [0]=>
-  string(0) ""
+  %unicode|string%(0) ""
   [1]=>
   NULL
   [2]=>
@@ -114,18 +119,18 @@ array(3) {
 Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test' doesn't exist in %s on line %d
 array(3) {
   [0]=>
-  string(5) "42S02"
+  %unicode|string%(5) "42S02"
   [1]=>
   int(1146)
   [2]=>
-  string(%d) "Table '%s.test' doesn't exist"
+  %unicode|string%(%d) "Table '%s.test' doesn't exist"
 }
 array(3) {
   [0]=>
-  string(5) "00000"
+  %unicode|string%(5) "00000"
   [1]=>
   int(1146)
   [2]=>
-  string(%d) "Table '%s.ihopeitdoesnotexist' doesn't exist"
+  %unicode|string%(%d) "Table '%s.ihopeitdoesnotexist' doesn't exist"
 }
 done!
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 fdf63ea..928e90d 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
@@ -180,8 +180,12 @@ MySQLPDOTest::skip();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!\n";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt
index db8f2f5..9c54dc2 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt
@@ -113,9 +113,14 @@ if (version_compare(PHP_VERSION, '5.1.0', '<'))
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!\n";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 Creating an object, serializing it and writing it to DB...
 myclass::singleton(Creating object)
@@ -125,24 +130,24 @@ myclass::serialize()
 Unserializing the previously serialized object...
 myclass::unserialize('Data from serialize')
 object(myclass)#4 (1) {
-  ["myprotected":protected]=>
-  string(19) "a protected propery"
+  [%u|b%"myprotected":protected]=>
+  %unicode|string%(19) "a protected propery"
 }
 
 Using PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE to fetch the object from DB and unserialize it...
 myclass::unserialize('C:7:"myclass":19:{Data from serialize}')
 object(myclass)#%d (1) {
-  ["myprotected":protected]=>
-  string(19) "a protected propery"
+  [%u|b%"myprotected":protected]=>
+  %unicode|string%(19) "a protected propery"
 }
 
 Using PDO::FETCH_CLASS to fetch the object from DB and unserialize it...
-myclass::__set(myobj, 'C:7:"myclass":19:{Data from serialize}')
 myclass::__construct(PDO shall call __construct())
+myclass::__set(myobj, 'C:7:"myclass":19:{Data from serialize}')
 object(myclass)#%d (2) {
-  ["myprotected":protected]=>
-  string(19) "a protected propery"
-  ["myobj"]=>
-  string(38) "C:7:"myclass":19:{Data from serialize}"
+  [%u|b%"myprotected":protected]=>
+  %unicode|string%(19) "a protected propery"
+  [%u|b%"myobj"]=>
+  %unicode|string%(38) "C:7:"myclass":19:{Data from serialize}"
 }
 done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt
index 79ef0c3..067f9ca 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt
@@ -63,9 +63,13 @@ try {
 		$e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo()));
 }
 
-$db->exec('DROP TABLE IF EXISTS test');
 print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 myclass::__set(id, -'1'-) 1
 myclass::__set(, -''-) 2
@@ -83,13 +87,13 @@ myclass::__set(null, -NULL-) 3
 myclass::__set(, -''-) 4
 myclass::__construct(2, 3): 12 / 4
 object(myclass)#%d (4) {
-  ["set_calls":"myclass":private]=>
+  [%u|b%"set_calls":"myclass":private]=>
   int(4)
-  ["grp":protected]=>
+  [%u|b%"grp":protected]=>
   NULL
-  ["id"]=>
-  string(1) "3"
-  ["null"]=>
+  [%u|b%"id"]=>
+  %unicode|string%(1) "3"
+  [%u|b%"null"]=>
   NULL
 }
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt
index fbff844..91b5237 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt
@@ -49,14 +49,18 @@ MySQLPDOTest::skip();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 Emulated Prepared Statements...
 array(3) {
   [0]=>
-  string(5) "00000"
+  %unicode|string%(5) "00000"
   [1]=>
   NULL
   [2]=>
@@ -65,13 +69,13 @@ array(3) {
 array(1) {
   [0]=>
   array(1) {
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 array(3) {
   [0]=>
-  string(5) "00000"
+  %unicode|string%(5) "00000"
   [1]=>
   NULL
   [2]=>
@@ -80,15 +84,15 @@ array(3) {
 array(1) {
   [0]=>
   array(1) {
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 array(1) {
   [0]=>
   array(1) {
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 Native Prepared Statements...
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt
index f491536..7996245 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt
@@ -104,106 +104,110 @@ if (!MySQLPDOTest::isPDOMySQLnd())
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 Emulated PS...
 array(1) {
   [0]=>
   array(1) {
-    ["_version"]=>
-    string(%d) "%s"
+    [%u|b%"_version"]=>
+    %unicode|string%(%d) "%s"
   }
 }
 bool(false)
 array(3) {
   [0]=>
   array(1) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
   }
   [1]=>
   array(1) {
-    ["id"]=>
-    string(1) "2"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
   }
   [2]=>
   array(1) {
-    ["id"]=>
-    string(1) "3"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "3"
   }
 }
 array(3) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "3"
-    ["label"]=>
-    string(1) "c"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "c"
   }
   [1]=>
   array(2) {
-    ["id"]=>
-    string(1) "2"
-    ["label"]=>
-    string(1) "b"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "b"
   }
   [2]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 bool(false)
 array(1) {
   [0]=>
   array(1) {
-    ["_version"]=>
-    string(%d) "%s"
+    [%u|b%"_version"]=>
+    %unicode|string%(%d) "%s"
   }
 }
 bool(false)
 array(3) {
   [0]=>
   array(1) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
   }
   [1]=>
   array(1) {
-    ["id"]=>
-    string(1) "2"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
   }
   [2]=>
   array(1) {
-    ["id"]=>
-    string(1) "3"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "3"
   }
 }
 array(3) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "3"
-    ["label"]=>
-    string(1) "c"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "c"
   }
   [1]=>
   array(2) {
-    ["id"]=>
-    string(1) "2"
-    ["label"]=>
-    string(1) "b"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "b"
   }
   [2]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 bool(false)
@@ -211,98 +215,98 @@ Native PS...
 array(1) {
   [0]=>
   array(1) {
-    ["_version"]=>
-    string(%d) "%s"
+    [%u|b%"_version"]=>
+    %unicode|string%(%d) "%s"
   }
 }
 bool(false)
 array(3) {
   [0]=>
   array(1) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
   }
   [1]=>
   array(1) {
-    ["id"]=>
-    string(1) "2"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
   }
   [2]=>
   array(1) {
-    ["id"]=>
-    string(1) "3"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "3"
   }
 }
 array(3) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "3"
-    ["label"]=>
-    string(1) "c"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "c"
   }
   [1]=>
   array(2) {
-    ["id"]=>
-    string(1) "2"
-    ["label"]=>
-    string(1) "b"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "b"
   }
   [2]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 bool(false)
 array(1) {
   [0]=>
   array(1) {
-    ["_version"]=>
-    string(%d) "%s"
+    [%u|b%"_version"]=>
+    %unicode|string%(%d) "%s"
   }
 }
 bool(false)
 array(3) {
   [0]=>
   array(1) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
   }
   [1]=>
   array(1) {
-    ["id"]=>
-    string(1) "2"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
   }
   [2]=>
   array(1) {
-    ["id"]=>
-    string(1) "3"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "3"
   }
 }
 array(3) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "3"
-    ["label"]=>
-    string(1) "c"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "c"
   }
   [1]=>
   array(2) {
-    ["id"]=>
-    string(1) "2"
-    ["label"]=>
-    string(1) "b"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "b"
   }
   [2]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 bool(false)
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_rowcount.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_rowcount.phpt
index 8883b84..17e2412 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_rowcount.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_rowcount.phpt
@@ -25,8 +25,12 @@ MySQLPDOTest::skip();
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt
index 0be9eac..f051403 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt
@@ -108,28 +108,32 @@ if (MYSQLPDOTest::isPDOMySQLnd())
 			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
 	}
 
-	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+MySQLPDOTest::dropTestTable();
+?>
 --EXPECTF--
 Native PS...
 Buffered...
 array(1) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 array(1) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 Unbuffered...
@@ -144,37 +148,37 @@ array(0) {
 array(1) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 array(1) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 array(1) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 array(1) {
   [0]=>
   array(2) {
-    ["id"]=>
-    string(1) "1"
-    ["label"]=>
-    string(1) "a"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"label"]=>
+    %unicode|string%(1) "a"
   }
 }
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt
index 853f5a3..c34f4a9 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt
@@ -118,5 +118,6 @@ if ($version < 50000)
 	}
 
 	print "done!";
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt b/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt
index fbe0e17..c83130d 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt
@@ -74,6 +74,12 @@ if (version_compare(PHP_VERSION, '5.0.0', '<'))
 	$db->exec('DROP TABLE IF EXISTS test');
 	print "done!\n";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 __construct('%S', '%S', '%S')
 exec('DROP TABLE IF EXISTS test')
@@ -83,13 +89,13 @@ query('SELECT * FROM test ORDER BY id ASC')
 array(2) {
   [0]=>
   array(1) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
   }
   [1]=>
   array(1) {
-    ["id"]=>
-    string(1) "2"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "2"
   }
 }
 bool(false)
diff --git a/ext/pdo_mysql/tests/pdo_mysql_types.phpt b/ext/pdo_mysql/tests/pdo_mysql_types.phpt
index 7bd5823..3629ab9 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_types.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_types.phpt
@@ -174,5 +174,11 @@ MySQLPDOTest::skip();
 
 	echo "done!\n";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt b/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt
index 9d521a1..7c0ec37 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt
@@ -113,5 +113,11 @@ MySQLPDOTest::skip();
 
 	echo "done!\n";
 ?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECTF--
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pecl_bug_5200.phpt b/ext/pdo_mysql/tests/pecl_bug_5200.phpt
index d07fe94..ff5b0e4 100644
--- a/ext/pdo_mysql/tests/pecl_bug_5200.phpt
+++ b/ext/pdo_mysql/tests/pecl_bug_5200.phpt
@@ -17,7 +17,13 @@ $db->exec("CREATE TABLE test (bar INT NOT NULL, phase enum('please_select', 'I',
 foreach ($db->query('DESCRIBE test phase')->fetchAll(PDO::FETCH_ASSOC) as $row) {
 	print_r($row);
 }
-
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
 --EXPECT--
 Array
 (
diff --git a/ext/pdo_mysql/tests/pecl_bug_5780.phpt b/ext/pdo_mysql/tests/pecl_bug_5780.phpt
index 5cc3497..5984284 100644
--- a/ext/pdo_mysql/tests/pecl_bug_5780.phpt
+++ b/ext/pdo_mysql/tests/pecl_bug_5780.phpt
@@ -26,17 +26,24 @@ $info = $logstmt->errorInfo();
 unset($info[2]);
 var_dump($info);
 ?>
---EXPECT--
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+$db->exec('DROP TABLE IF EXISTS test2');
+?>
+--EXPECTF--
 array(2) {
   [0]=>
-  string(7) "testing"
+  %unicode|string%(7) "testing"
   [1]=>
-  string(7) "testing"
+  %unicode|string%(7) "testing"
 }
 bool(true)
 array(2) {
   [0]=>
-  string(5) "00000"
+  %unicode|string%(5) "00000"
   [1]=>
   NULL
 }
diff --git a/ext/pdo_mysql/tests/pecl_bug_5802.phpt b/ext/pdo_mysql/tests/pecl_bug_5802.phpt
index fa22ecd..04aa2c9 100644
--- a/ext/pdo_mysql/tests/pecl_bug_5802.phpt
+++ b/ext/pdo_mysql/tests/pecl_bug_5802.phpt
@@ -32,21 +32,30 @@ $stmt = $db->prepare('select * from test') or var_dump($db->errorInfo());
 if($stmt) $stmt->execute();
 if($stmt) var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 
---EXPECT--
+print "done!";
+?>
+--CLEAN--
+<?php
+require dirname(__FILE__) . '/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS test');
+?>
+--EXPECTF--
 array(3) {
   [0]=>
   array(1) {
-    ["bar"]=>
-    string(3) "foo"
+    [%u|b%"bar"]=>
+    %unicode|string%(3) "foo"
   }
   [1]=>
   array(1) {
-    ["bar"]=>
+    [%u|b%"bar"]=>
     NULL
   }
   [2]=>
   array(1) {
-    ["bar"]=>
-    string(3) "qaz"
+    [%u|b%"bar"]=>
+    %unicode|string%(3) "qaz"
   }
 }
+done!
\ No newline at end of file
diff --git a/ext/pdo_oci/config.m4 b/ext/pdo_oci/config.m4
index ebe68a8..27512a2 100755
--- a/ext/pdo_oci/config.m4
+++ b/ext/pdo_oci/config.m4
@@ -1,4 +1,4 @@
-dnl $Id: config.m4 267636 2008-10-22 19:29:24Z stas $
+dnl $Id: config.m4 294541 2010-02-04 19:50:49Z pajoye $
 dnl config.m4 for extension pdo_oci
 dnl vim:et:sw=2:ts=2:
 
@@ -132,7 +132,7 @@ You need to tell me where to find your Oracle Instant Client SDK, or set ORACLE_
   fi
 
   case $PDO_OCI_VERSION in
-    9.0|10.1|10.2|11.1)
+    9.0|10.1|10.2|11.1|11.2)
       PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
       ;;
 
diff --git a/ext/pdo_oci/oci_driver.c b/ext/pdo_oci/oci_driver.c
index a862857..92f5045 100755
--- a/ext/pdo_oci/oci_driver.c
+++ b/ext/pdo_oci/oci_driver.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: oci_driver.c 280403 2009-05-12 21:53:18Z mbeccati $ */
+/* $Id: oci_driver.c 294444 2010-02-03 19:48:04Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -173,7 +173,7 @@ ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, swor
 
 	/* little mini hack so that we can use this code from the dbh ctor */
 	if (!dbh->methods) {
-		zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s]: %s", *pdo_err, einfo->errmsg);
+		zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s]: %s", *pdo_err, einfo->errmsg);
 	}
 
 	return einfo->errcode;
diff --git a/ext/pdo_oci/oci_statement.c b/ext/pdo_oci/oci_statement.c
index 62d4f9a..87de607 100755
--- a/ext/pdo_oci/oci_statement.c
+++ b/ext/pdo_oci/oci_statement.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: oci_statement.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: oci_statement.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/pdo_oci/pdo_oci.c b/ext/pdo_oci/pdo_oci.c
index 39efda4..43004cf 100755
--- a/ext/pdo_oci/pdo_oci.c
+++ b/ext/pdo_oci/pdo_oci.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_oci.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pdo_oci.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/pdo_oci/php_pdo_oci.h b/ext/pdo_oci/php_pdo_oci.h
index e638ca6..f73a01c 100755
--- a/ext/pdo_oci/php_pdo_oci.h
+++ b/ext/pdo_oci/php_pdo_oci.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_oci.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_oci.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_OCI_H
 #define PHP_PDO_OCI_H
diff --git a/ext/pdo_oci/php_pdo_oci_int.h b/ext/pdo_oci/php_pdo_oci_int.h
index 671c135..b4d7541 100755
--- a/ext/pdo_oci/php_pdo_oci_int.h
+++ b/ext/pdo_oci/php_pdo_oci_int.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_oci_int.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_oci_int.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <oci.h>
 
diff --git a/ext/pdo_odbc/config.m4 b/ext/pdo_odbc/config.m4
index 3dc54d8..c846d13 100755
--- a/ext/pdo_odbc/config.m4
+++ b/ext/pdo_odbc/config.m4
@@ -1,4 +1,4 @@
-dnl $Id: config.m4 263549 2008-07-25 13:46:24Z jani $
+dnl $Id: config.m4 291414 2009-11-29 06:13:22Z rasmus $
 dnl config.m4 for extension pdo_odbc
 dnl vim:et:sw=2:ts=2:
 
diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c
index a54add3..fbf54ff 100755
--- a/ext/pdo_odbc/odbc_driver.c
+++ b/ext/pdo_odbc/odbc_driver.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | Copyright (c) 1997-2010 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.0 of the PHP license,       |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: odbc_driver.c 284099 2009-07-15 02:36:08Z felipe $ */
+/* $Id: odbc_driver.c 294444 2010-02-03 19:48:04Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -104,7 +104,7 @@ void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement,
 	strcpy(*pdo_err, einfo->last_state);
 /* printf("@@ SQLSTATE[%s] %s\n", *pdo_err, einfo->last_err_msg); */
 	if (!dbh->methods) {
-		zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] %s: %d %s",
+		zend_throw_exception_ex(php_pdo_get_exception(), einfo->last_error TSRMLS_CC, "SQLSTATE[%s] %s: %d %s",
 				*pdo_err, what, einfo->last_error, einfo->last_err_msg);
 	}
 
diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c
index d650b6f..589be13 100755
--- a/ext/pdo_odbc/odbc_stmt.c
+++ b/ext/pdo_odbc/odbc_stmt.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | Copyright (c) 1997-2010 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.0 of the PHP license,       |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: odbc_stmt.c 284097 2009-07-15 02:32:43Z felipe $ */
+/* $Id: odbc_stmt.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/pdo_odbc/pdo_odbc.c b/ext/pdo_odbc/pdo_odbc.c
index 698fced..311b310 100755
--- a/ext/pdo_odbc/pdo_odbc.c
+++ b/ext/pdo_odbc/pdo_odbc.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | Copyright (c) 1997-2010 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.0 of the PHP license,       |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_odbc.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pdo_odbc.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/pdo_odbc/php_pdo_odbc.h b/ext/pdo_odbc/php_pdo_odbc.h
index 7524756..e5bc65d 100644
--- a/ext/pdo_odbc/php_pdo_odbc.h
+++ b/ext/pdo_odbc/php_pdo_odbc.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | Copyright (c) 1997-2010 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.0 of the PHP license,       |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_odbc.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_odbc.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_ODBC_H
 #define PHP_PDO_ODBC_H
diff --git a/ext/pdo_odbc/php_pdo_odbc_int.h b/ext/pdo_odbc/php_pdo_odbc_int.h
index 550c4ff..24d60dd 100755
--- a/ext/pdo_odbc/php_pdo_odbc_int.h
+++ b/ext/pdo_odbc/php_pdo_odbc_int.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | Copyright (c) 1997-2010 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.0 of the PHP license,       |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_odbc_int.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_odbc_int.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef PHP_WIN32
 # define PDO_ODBC_TYPE	"Win32"
diff --git a/ext/pdo_pgsql/config.m4 b/ext/pdo_pgsql/config.m4
index 8e55524..f75d791 100644
--- a/ext/pdo_pgsql/config.m4
+++ b/ext/pdo_pgsql/config.m4
@@ -1,4 +1,4 @@
-dnl $Id: config.m4 279602 2009-04-30 12:38:43Z mbeccati $
+dnl $Id: config.m4 291414 2009-11-29 06:13:22Z rasmus $
 dnl config.m4 for extension pdo_pgsql
 dnl vim:et:sw=2:ts=2:
 
diff --git a/ext/pdo_pgsql/pdo_pgsql.c b/ext/pdo_pgsql/pdo_pgsql.c
index 4085655..1be19ce 100644
--- a/ext/pdo_pgsql/pdo_pgsql.c
+++ b/ext/pdo_pgsql/pdo_pgsql.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_pgsql.c 277898 2009-03-28 01:58:49Z mbeccati $ */
+/* $Id: pdo_pgsql.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -85,8 +85,8 @@ ZEND_GET_MODULE(pdo_pgsql)
  */
 PHP_MINIT_FUNCTION(pdo_pgsql)
 {
-	php_pdo_register_driver(&pdo_pgsql_driver);
 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT", PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT);
+	php_pdo_register_driver(&pdo_pgsql_driver);
 	return SUCCESS;
 }
 /* }}} */
@@ -128,7 +128,7 @@ PHP_MINFO_FUNCTION(pdo_pgsql)
 	php_info_print_table_row(2, "PostgreSQL(libpq) Version", PG_VERSION);
 #endif	
 	php_info_print_table_row(2, "Module version", pdo_pgsql_module_entry.version);
-	php_info_print_table_row(2, "Revision", " $Id: pdo_pgsql.c 277898 2009-03-28 01:58:49Z mbeccati $ ");
+	php_info_print_table_row(2, "Revision", " $Id: pdo_pgsql.c 293036 2010-01-03 09:23:27Z sebastian $ ");
 
 	php_info_print_table_end();
 }
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c
index ef720cd..32fd472 100644
--- a/ext/pdo_pgsql/pgsql_driver.c
+++ b/ext/pdo_pgsql/pgsql_driver.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pgsql_driver.c 279604 2009-04-30 12:56:00Z mbeccati $ */
+/* $Id: pgsql_driver.c 294444 2010-02-03 19:48:04Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -87,7 +87,7 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *
 	}
 
 	if (!dbh->methods) {
-		zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
+		zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
 				*pdo_err, einfo->errcode, einfo->errmsg);
 	}
 	
@@ -232,22 +232,20 @@ static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
 		if (S->cursor_name) {
 			efree(S->cursor_name);
 		}
-		spprintf(&S->cursor_name, 0, "pdo_crsr_%016lx", (unsigned long) stmt);
+		spprintf(&S->cursor_name, 0, "pdo_crsr_%08x", ++H->stmt_counter);
 #if HAVE_PQPREPARE
 		emulate = 1;
 #endif
 	}
 
 #if HAVE_PQPREPARE
-
 	else if (driver_options) {
-		if (pdo_attr_lval(driver_options,
-				PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, 0 TSRMLS_CC) == 1) {
-			emulate = 1;
-		} else if (pdo_attr_lval(driver_options, PDO_ATTR_EMULATE_PREPARES,
-				0 TSRMLS_CC) == 1) {
+		if (pdo_attr_lval(driver_options, PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, H->disable_native_prepares TSRMLS_CC) == 1 ||
+			pdo_attr_lval(driver_options, PDO_ATTR_EMULATE_PREPARES, H->emulate_prepares TSRMLS_CC) == 1) {
 			emulate = 1;
 		}
+	} else {
+		emulate = H->disable_native_prepares || H->emulate_prepares;
 	}
 
 	if (!emulate && PQprotocolVersion(H->server) > 2) {
@@ -264,7 +262,7 @@ static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
 			return 0;
 		}
 
-		spprintf(&S->stmt_name, 0, "pdo_stmt_%016lx", (unsigned long)stmt);
+		spprintf(&S->stmt_name, 0, "pdo_stmt_%08x", ++H->stmt_counter);
 		/* that's all for now; we'll defer the actual prepare until the first execute call */
 	
 		if (nsql) {
@@ -625,7 +623,21 @@ static const zend_function_entry *pdo_pgsql_get_driver_methods(pdo_dbh_t *dbh, i
 
 static int pdo_pgsql_set_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC)
 {
-	return 0;
+	pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
+
+	switch (attr) {
+#if HAVE_PQPREPARE
+		case PDO_ATTR_EMULATE_PREPARES:
+			H->emulate_prepares = Z_LVAL_P(val);
+			return 1;
+		case PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT:
+			H->disable_native_prepares = Z_LVAL_P(val);
+			return 1;
+#endif
+
+		default:
+			return 0;
+	}
 }
 
 static struct pdo_dbh_methods pgsql_methods = {
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index 85ae913..8f2c8f8 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pgsql_statement.c 281107 2009-05-25 19:41:13Z kalle $ */
+/* $Id: pgsql_statement.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -185,7 +185,7 @@ stmt_retry:
 					 * deallocate it and retry ONCE (thies 2005.12.15)
 					 */
 					if (!strcmp(sqlstate, "42P05")) {
-						char buf[100]; /* stmt_name == "pdo_crsr_%016lx" */
+						char buf[100]; /* stmt_name == "pdo_crsr_%08x" */
 						PGresult *res;
 						snprintf(buf, sizeof(buf), "DEALLOCATE %s", S->stmt_name);
 						res = PQexec(H->server, buf);
diff --git a/ext/pdo_pgsql/php_pdo_pgsql.h b/ext/pdo_pgsql/php_pdo_pgsql.h
index 1760d61..9cdb176 100644
--- a/ext/pdo_pgsql/php_pdo_pgsql.h
+++ b/ext/pdo_pgsql/php_pdo_pgsql.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_pgsql.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_pgsql.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_PGSQL_H
 #define PHP_PDO_PGSQL_H
diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h
index fb0a95e..a9c686b 100644
--- a/ext/pdo_pgsql/php_pdo_pgsql_int.h
+++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_pgsql_int.h 280407 2009-05-12 22:18:15Z mbeccati $ */
+/* $Id: php_pdo_pgsql_int.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_PGSQL_INT_H
 #define PHP_PDO_PGSQL_INT_H
@@ -43,6 +43,14 @@ typedef struct {
 	unsigned 	_reserved:31;
 	pdo_pgsql_error_info	einfo;
 	Oid 		pgoid;
+#if HAVE_PQPREPARE
+	/* The following two variables have the same purpose. Unfortunately we need
+	   to keep track of two different attributes having the same effect.
+	   It might be worth to deprecate the driver specific one soon. */
+	int		emulate_prepares;
+	int		disable_native_prepares;
+#endif
+	unsigned int stmt_counter;
 } pdo_pgsql_db_handle;
 
 typedef struct {
diff --git a/ext/pdo_pgsql/tests/bug48764.phpt b/ext/pdo_pgsql/tests/bug48764.phpt
new file mode 100644
index 0000000..67e8f39
--- /dev/null
+++ b/ext/pdo_pgsql/tests/bug48764.phpt
@@ -0,0 +1,134 @@
+--TEST--
+Bug #48764 (PDO_pgsql::query always uses implicit prepared statements if v3 proto available)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+PDOTest::skip();
+
+$db = PDOTest::factory();
+
+$client_version = $db->getAttribute(PDO::ATTR_CLIENT_VERSION);
+$server_version = $db->getAttribute(PDO::ATTR_SERVER_VERSION);
+
+if (version_compare($server_version, '7.4', '<') || version_compare($client_version, '7.4', '<')) {
+        die('skip');
+}
+
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+echo "Test 1\n";
+bug($db);
+
+echo "Test 2\n";
+bug($db, array(PDO::ATTR_EMULATE_PREPARES => 0));
+bug($db, array(PDO::ATTR_EMULATE_PREPARES => 1));
+
+echo "Test 3\n";
+bug($db, array(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => 0));
+bug($db, array(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => 1));
+
+echo "Test 4\n";
+$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
+bug($db);
+$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
+bug($db);
+
+echo "Test 5\n";
+$db->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, 1);
+bug($db);
+$db->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, 0);
+bug($db);
+
+
+putenv('PDOTEST_ATTR='.serialize(array(
+	PDO::ATTR_EMULATE_PREPARES => 1,
+)));
+$db = PDOTest::factory('PDO', false);
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+echo "Test 6\n";
+bug($db);
+bug($db, array(PDO::ATTR_EMULATE_PREPARES => 0));
+bug($db, array(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => 0));
+
+
+putenv('PDOTEST_ATTR='.serialize(array(
+	PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => 1,
+)));
+
+$db = PDOTest::factory('PDO', false);
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+echo "Test 7\n";
+bug($db);
+bug($db, array(PDO::ATTR_EMULATE_PREPARES => 0));
+bug($db, array(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => 0));
+
+
+putenv('PDOTEST_ATTR='.serialize(array(
+	PDO::ATTR_EMULATE_PREPARES => 1,
+	PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => 1,
+)));
+
+$db = PDOTest::factory('PDO', false);
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+echo "Test 8\n";
+bug($db);
+bug($db, array(PDO::ATTR_EMULATE_PREPARES => 0));
+bug($db, array(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => 0));
+bug($db, array(
+	PDO::ATTR_EMULATE_PREPARES => 0,
+	PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => 0,
+));
+
+
+putenv('PDOTEST_ATTR');
+
+
+function bug($db, $options = array()) {
+	try {
+		$stmt = $db->prepare("SELECT ?", $options);
+		$stmt->execute(array(1));
+		echo "OK\n";
+	} catch (PDOException $e) {
+		// Indetermined data type when using native prepared statements
+		echo $e->getCode()."\n";
+	}
+}
+
+--EXPECT--
+Test 1
+42P18
+Test 2
+42P18
+OK
+Test 3
+42P18
+OK
+Test 4
+OK
+42P18
+Test 5
+OK
+42P18
+Test 6
+OK
+42P18
+OK
+Test 7
+OK
+OK
+42P18
+Test 8
+OK
+OK
+OK
+42P18
diff --git a/ext/pdo_pgsql/tests/bug_33876.phpt b/ext/pdo_pgsql/tests/bug_33876.phpt
index 0ec04e8..48618e1 100644
--- a/ext/pdo_pgsql/tests/bug_33876.phpt
+++ b/ext/pdo_pgsql/tests/bug_33876.phpt
@@ -80,10 +80,14 @@ else
 
 # Expected to fail; unless told otherwise, PDO assumes string inputs
 # false -> "" as string, which pgsql doesn't like
-if (!$res->execute(array(false)))
-	print_r($res->errorInfo());
-else
+if (!$res->execute(array(false))) {
+	$err = $res->errorInfo();
+	// Strip additional lines ouputted by recent PgSQL versions
+	$err[2] = trim(current(explode("\n", $err[2])));
+	print_r($err);
+} else {
 	print_r($res->fetchAll(PDO::FETCH_ASSOC));
+}
 
 
 
diff --git a/ext/pdo_pgsql/tests/bug_49985.phpt b/ext/pdo_pgsql/tests/bug_49985.phpt
new file mode 100644
index 0000000..26dcfc6
--- /dev/null
+++ b/ext/pdo_pgsql/tests/bug_49985.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Bug #49985 (pdo_pgsql prepare() re-use previous aborted transaction)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+$db->exec("CREATE TABLE test (a int PRIMARY KEY)");
+
+for ($i = 0; $i < 3; $i++) {
+    try {
+        $db->beginTransaction();
+        $stmt = $db->prepare("INSERT INTO test (a) VALUES (?)");
+        var_dump($stmt->execute(array(1)));
+        $db->commit();
+    } catch (Exception $e) {
+        echo trim(current(explode("\n", $e->getMessage())))."\n";
+        $db->rollback();
+    }
+}
+
+?>
+--EXPECTF--
+bool(true)
+SQLSTATE[23505]: %s"test_pkey"
+SQLSTATE[23505]: %s"test_pkey"
+
diff --git a/ext/pdo_sqlite/config.m4 b/ext/pdo_sqlite/config.m4
index 1735f0f..eceb94d 100644
--- a/ext/pdo_sqlite/config.m4
+++ b/ext/pdo_sqlite/config.m4
@@ -1,4 +1,4 @@
-dnl $Id: config.m4 273413 2009-01-13 02:50:54Z scottmac $
+dnl $Id: config.m4 291414 2009-11-29 06:13:22Z rasmus $
 dnl config.m4 for extension pdo_sqlite
 dnl vim:et:sw=2:ts=2:
 
diff --git a/ext/pdo_sqlite/config.w32 b/ext/pdo_sqlite/config.w32
index d1f159d..6db4e4b 100644
--- a/ext/pdo_sqlite/config.w32
+++ b/ext/pdo_sqlite/config.w32
@@ -1,10 +1,10 @@
-// $Id: config.w32 287047 2009-08-10 16:58:53Z kalle $
+// $Id: config.w32 289692 2009-10-16 02:22:48Z scottmac $
 // vim:ft=javascript
 
 ARG_WITH("pdo-sqlite", "for pdo_sqlite support", "no");
 
 if (PHP_PDO_SQLITE != "no") {
-	EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c", null, "/DSQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /I" + configure_module_dirname + "/../sqlite3/libsqlite /I" + configure_module_dirname);
+	EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c", null, "/DSQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 /I" + configure_module_dirname + "/../sqlite3/libsqlite /I" + configure_module_dirname);
 	
 	ADD_EXTENSION_DEP('pdo_sqlite', 'pdo');
 	// If pdo_sqlite is static, and sqlite3 is also static, then we don't add a second copy of the sqlite3 libs
diff --git a/ext/pdo_sqlite/pdo_sqlite.c b/ext/pdo_sqlite/pdo_sqlite.c
index ba2b697..f9735f5 100644
--- a/ext/pdo_sqlite/pdo_sqlite.c
+++ b/ext/pdo_sqlite/pdo_sqlite.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_sqlite.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pdo_sqlite.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/pdo_sqlite/php_pdo_sqlite.h b/ext/pdo_sqlite/php_pdo_sqlite.h
index 36bbb93..71813e0 100644
--- a/ext/pdo_sqlite/php_pdo_sqlite.h
+++ b/ext/pdo_sqlite/php_pdo_sqlite.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_sqlite.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_sqlite.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 
 #ifndef PHP_PDO_SQLITE_H
diff --git a/ext/pdo_sqlite/php_pdo_sqlite_int.h b/ext/pdo_sqlite/php_pdo_sqlite_int.h
index 4deb996..eb8329a 100644
--- a/ext/pdo_sqlite/php_pdo_sqlite_int.h
+++ b/ext/pdo_sqlite/php_pdo_sqlite_int.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_sqlite_int.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_sqlite_int.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PDO_SQLITE_INT_H
 #define PHP_PDO_SQLITE_INT_H
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c
index f16e17e..56d6f3d 100644
--- a/ext/pdo_sqlite/sqlite_driver.c
+++ b/ext/pdo_sqlite/sqlite_driver.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sqlite_driver.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sqlite_driver.c 294444 2010-02-03 19:48:04Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -78,7 +78,7 @@ int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int li
 	}
 
 	if (!dbh->methods) {
-		zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
+		zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
 				*pdo_err, einfo->errcode, einfo->errmsg);
 	}
 	
@@ -496,9 +496,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
 		func->funcname = estrdup(func_name);
 		
 		MAKE_STD_ZVAL(func->func);
-		*(func->func) = *callback;
-		zval_copy_ctor(func->func);
-		INIT_PZVAL(func->func);
+		MAKE_COPY_ZVAL(&callback, func->func);
 		
 		func->argc = argc;
 
@@ -575,14 +573,10 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
 		func->funcname = estrdup(func_name);
 		
 		MAKE_STD_ZVAL(func->step);
-		*(func->step) = *step_callback;
-		zval_copy_ctor(func->step);
-		INIT_PZVAL(func->step);
+		MAKE_COPY_ZVAL(&step_callback, func->step);
 
 		MAKE_STD_ZVAL(func->fini);
-		*(func->fini) = *fini_callback;
-		zval_copy_ctor(func->fini);
-		INIT_PZVAL(func->fini);
+		MAKE_COPY_ZVAL(&fini_callback, func->fini);
 		
 		func->argc = argc;
 
diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c
index d8e5049..26e2e5f 100644
--- a/ext/pdo_sqlite/sqlite_statement.c
+++ b/ext/pdo_sqlite/sqlite_statement.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sqlite_statement.c 280873 2009-05-20 15:05:36Z iliaa $ */
+/* $Id: sqlite_statement.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/pdo_sqlite/tests/bug50728.phpt b/ext/pdo_sqlite/tests/bug50728.phpt
new file mode 100644
index 0000000..3dbbb1f
--- /dev/null
+++ b/ext/pdo_sqlite/tests/bug50728.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #50728 (All PDOExceptions hardcode 'code' property to 0)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
+?>
+--FILE--
+<?php
+try {
+	$a = new PDO("sqlite:/this/path/should/not/exist.db");
+} catch (PDOException $e) {
+	var_dump($e->getCode());
+}
+?>
+--EXPECTF--
+int(14)
diff --git a/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt b/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
new file mode 100644
index 0000000..efcb2e7
--- /dev/null
+++ b/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
@@ -0,0 +1,130 @@
+--TEST--
+Testing several callbacks using PDO::FETCH_FUNC
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
+?>
+--FILE--
+<?php
+
+$db = new PDO('sqlite::memory:');
+$db->exec('CREATE TABLE testing (id INTEGER , name VARCHAR)');
+$db->exec('INSERT INTO testing VALUES(1, "php")');
+$db->exec('INSERT INTO testing VALUES(2, "")');
+
+$st = $db->query('SELECT * FROM testing');
+$st->fetchAll(PDO::FETCH_FUNC, function($x, $y) use ($st) { var_dump($st); print "data: $x, $y\n"; });
+
+$st = $db->query('SELECT name FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, 'strtoupper'));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, 'nothing'));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, ''));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, NULL));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, 1));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, array('self', 'foo')));
+
+class foo { 
+	public function foo($x) {
+		return "--- $x ---";
+	}
+}
+class bar extends foo {
+	public function __construct($db) {
+		$st = $db->query('SELECT * FROM testing');
+		var_dump($st->fetchAll(PDO::FETCH_FUNC, array($this, 'parent::foo')));
+	}
+	
+	static public function test($x, $y) {
+		return $x .'---'. $y;
+	}
+	
+	private function test2($x, $y) {
+		return $x;
+	}
+	
+	public function test3($x, $y) {
+		return $x .'==='. $y;
+	}
+}
+
+new bar($db);
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test')));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test2')));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test3')));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'inexistent')));
+
+?>
+--EXPECTF--
+object(PDOStatement)#%d (1) {
+  [%u|b%"queryString"]=>
+  %string|unicode%(21) "SELECT * FROM testing"
+}
+data: 1, php
+object(PDOStatement)#%d (1) {
+  [%u|b%"queryString"]=>
+  %string|unicode%(21) "SELECT * FROM testing"
+}
+data: 2, 
+array(2) {
+  [0]=>
+  %string|unicode%(3) "PHP"
+  [1]=>
+  %string|unicode%(0) ""
+}
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function 'nothing' not found or invalid function name in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function '' not found or invalid function name in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access self:: when no class scope is active in %s on line %d
+bool(false)
+array(2) {
+  [0]=>
+  %string|unicode%(9) "--- 1 ---"
+  [1]=>
+  %string|unicode%(9) "--- 2 ---"
+}
+array(2) {
+  [0]=>
+  %string|unicode%(7) "1---php"
+  [1]=>
+  %string|unicode%(4) "2---"
+}
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access private method bar::test2() in %s on line %d
+bool(false)
+array(2) {
+  [0]=>
+  %string|unicode%(7) "1===php"
+  [1]=>
+  %string|unicode%(4) "2==="
+}
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class 'bar' does not have a method 'inexistent' in %s on line %d
+bool(false)
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index c8cf494..273bee0 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: pgsql.c 280789 2009-05-19 16:03:36Z kalle $ */
+/* $Id: pgsql.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdlib.h>
 
@@ -819,7 +819,7 @@ static void _php_pgsql_notice_handler(void *resource_id, const char *message)
 		if (PGG(log_notices)) {
 			php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s", notice->message);
 		}
-		zend_hash_index_update(&PGG(notices), (int)resource_id, (void **)&notice, sizeof(php_pgsql_notice *), NULL);
+		zend_hash_index_update(&PGG(notices), (ulong)resource_id, (void **)&notice, sizeof(php_pgsql_notice *), NULL);
 	}
 }
 /* }}} */
@@ -1217,13 +1217,14 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 		 */
 		if (!(connect_type & PGSQL_CONNECT_FORCE_NEW)
 			&& zend_hash_find(&EG(regular_list),str.c,str.len+1,(void **) &index_ptr)==SUCCESS) {
-			int type,link;
+			int type;
+			ulong link;
 			void *ptr;
 
 			if (Z_TYPE_P(index_ptr) != le_index_ptr) {
 				RETURN_FALSE;
 			}
-			link = (int) index_ptr->ptr;
+			link = (ulong) index_ptr->ptr;
 			ptr = zend_list_find(link,&type);   /* check if the link is still there */
 			if (ptr && (type==le_link || type==le_plink)) {
 				Z_LVAL_P(return_value) = link;
@@ -2166,14 +2167,15 @@ PHP_FUNCTION(pg_field_table)
 
 
 	if (return_oid) {
+#if UINT_MAX > LONG_MAX /* Oid is unsigned int, we don't need this code, where LONG is wider */
 		if (oid > LONG_MAX) {
 			smart_str oidstr = {0};
 			smart_str_append_unsigned(&oidstr, oid);
 			smart_str_0(&oidstr);
 			RETURN_STRINGL(oidstr.c, oidstr.len, 0);
-		} else {
+		} else
+#endif
 			RETURN_LONG((long)oid);
-		}
 	}
 
 	/* try to lookup the table name in the resource list */
@@ -2271,7 +2273,7 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ
 		case PHP_PG_FIELD_TYPE_OID:
 			
 			oid = PQftype(pgsql_result, field);
-
+#if UINT_MAX > LONG_MAX
 			if (oid > LONG_MAX) {
 				smart_str s = {0};
 				smart_str_append_unsigned(&s, oid);
@@ -2279,7 +2281,9 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ
 				Z_STRVAL_P(return_value) = s.c;
 				Z_STRLEN_P(return_value) = s.len;
 				Z_TYPE_P(return_value) = IS_STRING;
-			} else {
+			} else
+#endif
+			{
 				Z_LVAL_P(return_value) = (long)oid;
 				Z_TYPE_P(return_value) = IS_LONG;
 			}
@@ -3760,7 +3764,11 @@ PHP_FUNCTION(pg_copy_to)
 		pg_null_as = safe_estrdup("\\\\N");
 	}
 
-	spprintf(&query, 0, "COPY \"%s\" TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as);
+	if (memchr(table_name, '.', table_name_len)) {
+		spprintf(&query, 0, "COPY %s TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as);
+	} else {
+		spprintf(&query, 0, "COPY \"%s\" TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as);
+	}
 
 	while ((pgsql_result = PQgetResult(pgsql))) {
 		PQclear(pgsql_result);
diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h
index efc8040..09a53c1 100644
--- a/ext/pgsql/php_pgsql.h
+++ b/ext/pgsql/php_pgsql.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: php_pgsql.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pgsql.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PGSQL_H
 #define PHP_PGSQL_H
diff --git a/ext/pgsql/tests/10pg_convert.phpt b/ext/pgsql/tests/10pg_convert.phpt
index b88b8e5..73bf2b6 100644
--- a/ext/pgsql/tests/10pg_convert.phpt
+++ b/ext/pgsql/tests/10pg_convert.phpt
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_convert()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);
diff --git a/ext/pgsql/tests/10pg_convert_85.phpt b/ext/pgsql/tests/10pg_convert_85.phpt
new file mode 100644
index 0000000..4f1c92b
--- /dev/null
+++ b/ext/pgsql/tests/10pg_convert_85.phpt
@@ -0,0 +1,29 @@
+--TEST--
+PostgreSQL pg_convert() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+$converted = pg_convert($db, $table_name, $fields);
+
+var_dump($converted);
+?>
+--EXPECT--
+array(3) {
+  ["num"]=>
+  string(4) "1234"
+  ["str"]=>
+  string(5) "'AAA'"
+  ["bin"]=>
+  string(11) "'\\x424242'"
+}
diff --git a/ext/pgsql/tests/12pg_insert.phpt b/ext/pgsql/tests/12pg_insert.phpt
index 8d98f22..f5cd868 100644
--- a/ext/pgsql/tests/12pg_insert.phpt
+++ b/ext/pgsql/tests/12pg_insert.phpt
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_insert()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);
diff --git a/ext/pgsql/tests/12pg_insert_85.phpt b/ext/pgsql/tests/12pg_insert_85.phpt
new file mode 100644
index 0000000..a85dea0
--- /dev/null
+++ b/ext/pgsql/tests/12pg_insert_85.phpt
@@ -0,0 +1,24 @@
+--TEST--
+PostgreSQL pg_insert() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+
+pg_insert($db, $table_name, $fields) or print "Error in test 1\n";
+echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n";
+
+echo "Ok\n";
+?>
+--EXPECT--
+INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','\\x424242');
+Ok
diff --git a/ext/pgsql/tests/13pg_select.phpt b/ext/pgsql/tests/13pg_select.phpt
index 55e88db..f1504a8 100644
--- a/ext/pgsql/tests/13pg_select.phpt
+++ b/ext/pgsql/tests/13pg_select.phpt
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_select()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);
diff --git a/ext/pgsql/tests/13pg_select_85.phpt b/ext/pgsql/tests/13pg_select_85.phpt
new file mode 100644
index 0000000..e6d86bd
--- /dev/null
+++ b/ext/pgsql/tests/13pg_select_85.phpt
@@ -0,0 +1,37 @@
+--TEST--
+PostgreSQL pg_select() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
+$ids = array('num'=>'1234');
+
+$res = pg_select($db, $table_name, $ids) or print "Error\n";
+var_dump($res);
+echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n";
+echo "Ok\n";
+
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  array(3) {
+    ["num"]=>
+    string(4) "1234"
+    ["str"]=>
+    string(3) "AAA"
+    ["bin"]=>
+    string(8) "\x424242"
+  }
+}
+SELECT * FROM php_pgsql_test WHERE num=1234;
+Ok
diff --git a/ext/pgsql/tests/14pg_update.phpt b/ext/pgsql/tests/14pg_update.phpt
index ef8d7e4..b41dd1a 100644
--- a/ext/pgsql/tests/14pg_update.phpt
+++ b/ext/pgsql/tests/14pg_update.phpt
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_update()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);
diff --git a/ext/pgsql/tests/14pg_update_85.phpt b/ext/pgsql/tests/14pg_update_85.phpt
new file mode 100644
index 0000000..f1c77ea
--- /dev/null
+++ b/ext/pgsql/tests/14pg_update_85.phpt
@@ -0,0 +1,25 @@
+--TEST--
+PostgreSQL pg_update() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
+$ids = array('num'=>'1234');
+
+pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n";
+echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n";
+
+echo "Ok\n";
+?>
+--EXPECT--
+UPDATE php_pgsql_test SET num=1234,str='ABC',bin='\\x58595a' WHERE num=1234;
+Ok
diff --git a/ext/pgsql/tests/bug37100.phpt b/ext/pgsql/tests/bug37100.phpt
index b66149e..fa6b9ba 100644
--- a/ext/pgsql/tests/bug37100.phpt
+++ b/ext/pgsql/tests/bug37100.phpt
@@ -1,7 +1,10 @@
 --TEST--
 Bug #37100 (data is returned truncated with BINARY CURSOR)
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 
diff --git a/ext/pgsql/tests/bug37100_85.phpt b/ext/pgsql/tests/bug37100_85.phpt
new file mode 100644
index 0000000..aa24776
--- /dev/null
+++ b/ext/pgsql/tests/bug37100_85.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Bug #37100 (data is returned truncated with BINARY CURSOR) (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+ at pg_query('DROP TABLE test_bug');
+
+pg_query('CREATE TABLE test_bug (binfield byteA) ;');
+pg_query("INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))");
+
+
+$data = pg_query("SELECT binfield FROM test_bug");
+$res = pg_fetch_result($data,0);
+var_dump($res);
+var_dump(bin2hex(pg_unescape_bytea($res)));
+
+$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM test_bug; FETCH ALL IN mycursor;";
+
+$data = pg_query($sql);
+$res = pg_fetch_result($data,0);
+
+var_dump(strlen($res));
+var_dump(bin2hex($res));
+
+pg_close($db);
+
+$db = pg_connect($conn_str);
+pg_query('DROP TABLE test_bug');
+pg_close($db);
+
+
+?>
+--EXPECT--
+string(14) "\x0103aa000812"
+string(12) "0103aa000812"
+int(6)
+string(12) "0103aa000812"
diff --git a/ext/pgsql/tests/skipif.inc b/ext/pgsql/tests/skipif.inc
index 043a0bd..74b27b3 100644
--- a/ext/pgsql/tests/skipif.inc
+++ b/ext/pgsql/tests/skipif.inc
@@ -15,4 +15,17 @@ $conn = @pg_connect($conn_str);
 if (!is_resource($conn)) {
     die("skip could not connect\n");
 }
-?>
\ No newline at end of file
+
+function skip_server_version($version, $op = '<') { _skip_version('server', $version, $op); }
+function skip_client_version($version, $op = '<') { _skip_version('client', $version, $op); }
+
+
+function _skip_version($type, $version, $op)
+{
+	$pg = pg_parameter_status($type.'_version');
+	if (version_compare($pg, $version, $op)) {
+		die("skip {$type} version {$pg} is {$op} {$version}\n");
+	}
+}
+
+?>
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 571ae45..9b8233d 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar.c 286338 2009-07-26 01:03:47Z cellog $ */
+/* $Id: phar.c 290435 2009-11-09 17:21:15Z rasmus $ */
 
 #define PHAR_MAIN 1
 #include "phar_internal.h"
@@ -3665,7 +3665,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, "CVS revision", "$Revision: 286338 $");
+	php_info_print_table_row(2, "SVN revision", "$Revision: 290435 $");
 	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");
@@ -3706,7 +3706,7 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */
 
 /* {{{ phar_module_entry
  */
-static zend_module_dep phar_deps[] = {
+static const zend_module_dep phar_deps[] = {
 	ZEND_MOD_OPTIONAL("apc")
 	ZEND_MOD_OPTIONAL("bz2")
 	ZEND_MOD_OPTIONAL("openssl")
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 69e8e38..9c6d884 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar_object.c 286518 2009-07-29 16:17:57Z felipe $ */
+/* $Id: phar_object.c 290647 2009-11-13 00:58:11Z cellog $ */
 
 #include "phar_internal.h"
 #include "func_interceptors.h"
@@ -2945,7 +2945,7 @@ PHP_METHOD(Phar, isBuffering)
 {
 	PHAR_ARCHIVE_OBJECT();
 
-	RETURN_BOOL(!phar_obj->arc.archive->donotflush);
+	RETURN_BOOL(phar_obj->arc.archive->donotflush);
 }
 /* }}} */
 
diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h
index 494ef67..198ac76 100644
--- a/ext/phar/php_phar.h
+++ b/ext/phar/php_phar.h
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_phar.h 290601 2009-11-12 17:43:23Z johannes $ */
+/* $Id: php_phar.h 290527 2009-11-11 21:02:59Z cellog $ */
 
 #ifndef PHP_PHAR_H
 #define PHP_PHAR_H
diff --git a/ext/phar/tests/phar_begin_setstub_commit.phpt b/ext/phar/tests/phar_begin_setstub_commit.phpt
index 42556c3..9d3e383 100755
--- a/ext/phar/tests/phar_begin_setstub_commit.phpt
+++ b/ext/phar/tests/phar_begin_setstub_commit.phpt
@@ -36,8 +36,8 @@ var_dump($p->getStub());
 unlink(dirname(__FILE__) . '/brandnewphar.phar');
 ?>
 --EXPECT--
-bool(true)
 bool(false)
+bool(true)
 string(5) "Hello"
 string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
@@ -45,7 +45,7 @@ string(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
 ===COMMIT===
-bool(true)
+bool(false)
 string(5) "Hello"
 string(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
diff --git a/ext/phar/tests/phar_begin_setstub_commitU.phpt b/ext/phar/tests/phar_begin_setstub_commitU.phpt
index c766557..805e762 100644
--- a/ext/phar/tests/phar_begin_setstub_commitU.phpt
+++ b/ext/phar/tests/phar_begin_setstub_commitU.phpt
@@ -36,8 +36,8 @@ var_dump($p->getStub());
 unlink(dirname(__FILE__) . '/brandnewphar.phar');
 ?>
 --EXPECT--
-bool(true)
 bool(false)
+bool(true)
 unicode(5) "Hello"
 string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
@@ -45,7 +45,7 @@ unicode(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
 ===COMMIT===
-bool(true)
+bool(false)
 unicode(5) "Hello"
 unicode(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
diff --git a/ext/phar/tests/phar_buildfromdirectory6.phpt b/ext/phar/tests/phar_buildfromdirectory6.phpt
index 2edd096..99566c1 100644
--- a/ext/phar/tests/phar_buildfromdirectory6.phpt
+++ b/ext/phar/tests/phar_buildfromdirectory6.phpt
@@ -15,7 +15,7 @@ foreach(range(1, 4) as $i) {
 
 try {
 	$phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar');
-	var_dump($phar->buildFromDirectory(dirname(__FILE__) . '/testdir', '/\.php/'));
+	var_dump($phar->buildFromDirectory(dirname(__FILE__) . '/testdir', '/\.php$/'));
 } catch (Exception $e) {
 	var_dump(get_class($e));
 	echo $e->getMessage() . "\n";
diff --git a/ext/phar/tests/tar/phar_begin_setstub_commit.phpt b/ext/phar/tests/tar/phar_begin_setstub_commit.phpt
index 693b7ed..d18f32e 100755
--- a/ext/phar/tests/tar/phar_begin_setstub_commit.phpt
+++ b/ext/phar/tests/tar/phar_begin_setstub_commit.phpt
@@ -37,8 +37,8 @@ unlink(dirname(__FILE__) . '/brandnewphar.phar.tar');
 ?>
 --EXPECT--
 bool(true)
-bool(true)
 bool(false)
+bool(true)
 string(5) "Hello"
 string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
@@ -46,7 +46,7 @@ string(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
 ===COMMIT===
-bool(true)
+bool(false)
 string(5) "Hello"
 string(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
diff --git a/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt b/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt
index 06b2bed..d058b36 100644
--- a/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt
+++ b/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt
@@ -37,8 +37,8 @@ unlink(dirname(__FILE__) . '/brandnewphar.phar.tar');
 ?>
 --EXPECT--
 bool(true)
-bool(true)
 bool(false)
+bool(true)
 unicode(5) "Hello"
 string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
@@ -46,7 +46,7 @@ unicode(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
 ===COMMIT===
-bool(true)
+bool(false)
 unicode(5) "Hello"
 unicode(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
diff --git a/ext/phar/tests/zip/phar_begin_setstub_commit.phpt b/ext/phar/tests/zip/phar_begin_setstub_commit.phpt
index e0f14cc..dc59f2f 100755
--- a/ext/phar/tests/zip/phar_begin_setstub_commit.phpt
+++ b/ext/phar/tests/zip/phar_begin_setstub_commit.phpt
@@ -50,8 +50,8 @@ unlink(dirname(__FILE__) . '/myfakestub.php');
 ?>
 --EXPECT--
 bool(true)
-bool(true)
 bool(false)
+bool(true)
 string(5) "Hello"
 string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
@@ -59,7 +59,7 @@ string(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
 ===COMMIT===
-bool(true)
+bool(false)
 string(5) "Hello"
 string(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
diff --git a/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt b/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt
index 43a140f..2956fc6 100644
--- a/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt
+++ b/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt
@@ -50,8 +50,8 @@ unlink(dirname(__FILE__) . '/myfakestub.php');
 ?>
 --EXPECT--
 bool(true)
-bool(true)
 bool(false)
+bool(true)
 unicode(5) "Hello"
 string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
@@ -59,7 +59,7 @@ unicode(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
 "
 ===COMMIT===
-bool(true)
+bool(false)
 unicode(5) "Hello"
 unicode(5) "World"
 string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
diff --git a/ext/phar/tests/zip/phar_stub.phpt b/ext/phar/tests/zip/phar_stub.phpt
index 302a894..72c1f17 100644
--- a/ext/phar/tests/zip/phar_stub.phpt
+++ b/ext/phar/tests/zip/phar_stub.phpt
@@ -19,12 +19,6 @@ $p['b'] = 'b';
 $p['c'] = 'c';
 copy($fname2, $fname);
 
-$a = stat($pname . '/a');
-$b = stat($pname2 . '/a');
-if ($a['mtime'] != $b['mtime']) {
-	echo "timestamp changed, was $a[mtime], now $b[mtime]!\n";
-}
-
 $phar = new Phar($fname);
 echo $phar->getStub();
 
diff --git a/ext/posix/php_posix.h b/ext/posix/php_posix.h
index fdc69b7..834fc7c 100644
--- a/ext/posix/php_posix.h
+++ b/ext/posix/php_posix.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
  */
 
 
-/* $Id: php_posix.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_posix.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_POSIX_H
 #define PHP_POSIX_H
diff --git a/ext/posix/posix.c b/ext/posix/posix.c
index 1e6c5ec..3d4dd64 100644
--- a/ext/posix/posix.c
+++ b/ext/posix/posix.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: posix.c 289424 2009-10-09 14:46:48Z pajoye $ */
+/* $Id: posix.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #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: 289424 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 293036 $");
 	php_info_print_table_end();
 }
 /* }}} */
diff --git a/ext/posix/tests/posix_access.phpt b/ext/posix/tests/posix_access.phpt
index a427f8a..1bd601a 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--
-PHP Warning:  Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d
+Warning: 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 bfe366f..0d79996 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--
-PHP Warning:  Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line %d
+Warning: 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 04f9335..7f938a8 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--
-PHP Warning:  Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 6055c80..1e156f9 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--
-PHP Warning:  Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d
+Warning: 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_errno_variation1.phpt b/ext/posix/tests/posix_errno_variation1.phpt
index aa9889f..b57b7c0 100644
--- a/ext/posix/tests/posix_errno_variation1.phpt
+++ b/ext/posix/tests/posix_errno_variation1.phpt
@@ -7,6 +7,7 @@ Francesco Fullone ff at ideato.it
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_getuid()==0) print "skip - Cannot run test as root.";    
 ?>
 --FILE--
 <?php
diff --git a/ext/posix/tests/posix_errno_variation2.phpt b/ext/posix/tests/posix_errno_variation2.phpt
index f463d78..ad3aa31 100644
--- a/ext/posix/tests/posix_errno_variation2.phpt
+++ b/ext/posix/tests/posix_errno_variation2.phpt
@@ -7,6 +7,7 @@ Francesco Fullone ff at ideato.it
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(!extension_loaded("pcntl")) print "skip - PCNTL extension required";
 ?>
 --FILE--
 <?php
diff --git a/ext/posix/tests/posix_mkfifo_safemode.phpt b/ext/posix/tests/posix_mkfifo_safemode.phpt
index 4cbcc68..9dbddc2 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--
-PHP Warning:  Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d
+Warning: 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/posix/tests/posix_seteuid_variation2.phpt b/ext/posix/tests/posix_seteuid_variation2.phpt
index 2ab7302..bcba394 100644
--- a/ext/posix/tests/posix_seteuid_variation2.phpt
+++ b/ext/posix/tests/posix_seteuid_variation2.phpt
@@ -3,6 +3,7 @@ Test function posix_seteuid() by substituting argument 1 with boolean values.
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
diff --git a/ext/posix/tests/posix_seteuid_variation3.phpt b/ext/posix/tests/posix_seteuid_variation3.phpt
index 70c05c8..8b57864 100644
--- a/ext/posix/tests/posix_seteuid_variation3.phpt
+++ b/ext/posix/tests/posix_seteuid_variation3.phpt
@@ -3,6 +3,7 @@ Test function posix_seteuid() by substituting argument 1 with emptyUnsetUndefNul
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
diff --git a/ext/posix/tests/posix_seteuid_variation4.phpt b/ext/posix/tests/posix_seteuid_variation4.phpt
index 6529141..a647328 100644
--- a/ext/posix/tests/posix_seteuid_variation4.phpt
+++ b/ext/posix/tests/posix_seteuid_variation4.phpt
@@ -3,6 +3,7 @@ Test function posix_seteuid() by substituting argument 1 with float values.
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
diff --git a/ext/posix/tests/posix_seteuid_variation5.phpt b/ext/posix/tests/posix_seteuid_variation5.phpt
index 91d3a72..8e43e1a 100644
--- a/ext/posix/tests/posix_seteuid_variation5.phpt
+++ b/ext/posix/tests/posix_seteuid_variation5.phpt
@@ -3,6 +3,7 @@ Test function posix_seteuid() by substituting argument 1 with int values.
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
diff --git a/ext/posix/tests/posix_setgid_variation2.phpt b/ext/posix/tests/posix_setgid_variation2.phpt
index 6d53b08..b8e50ba 100644
--- a/ext/posix/tests/posix_setgid_variation2.phpt
+++ b/ext/posix/tests/posix_setgid_variation2.phpt
@@ -3,6 +3,7 @@ Test function posix_setgid() by substituting argument 1 with boolean values.
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
@@ -36,4 +37,4 @@ bool(false)
 bool(false)
 bool(false)
 ===DONE===
-	
\ No newline at end of file
+	
diff --git a/ext/posix/tests/posix_setgid_variation3.phpt b/ext/posix/tests/posix_setgid_variation3.phpt
index 5855746..cb9da62 100644
--- a/ext/posix/tests/posix_setgid_variation3.phpt
+++ b/ext/posix/tests/posix_setgid_variation3.phpt
@@ -7,6 +7,7 @@ Francesco Fullone ff at ideato.it
 --SKIPIF--
 <?php
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded";
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --FILE--
 <?php
diff --git a/ext/posix/tests/posix_setgid_variation4.phpt b/ext/posix/tests/posix_setgid_variation4.phpt
index 2bd209b..faae4d4 100644
--- a/ext/posix/tests/posix_setgid_variation4.phpt
+++ b/ext/posix/tests/posix_setgid_variation4.phpt
@@ -3,6 +3,7 @@ Test function posix_setgid() by substituting argument 1 with float values.
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
@@ -38,4 +39,4 @@ bool(false)
 bool(false)
 bool(false)
 ===DONE===
-	
\ No newline at end of file
+	
diff --git a/ext/posix/tests/posix_setgid_variation5.phpt b/ext/posix/tests/posix_setgid_variation5.phpt
index 91f2bb5..49e98ec 100644
--- a/ext/posix/tests/posix_setgid_variation5.phpt
+++ b/ext/posix/tests/posix_setgid_variation5.phpt
@@ -3,6 +3,7 @@ Test function posix_setgid() by substituting argument 1 with int values.
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
@@ -34,4 +35,4 @@ bool(false)
 bool(false)
 bool(false)
 ===DONE===
-	
\ No newline at end of file
+	
diff --git a/ext/posix/tests/posix_setuid_variation2.phpt b/ext/posix/tests/posix_setuid_variation2.phpt
index c8ef928..77505a6 100644
--- a/ext/posix/tests/posix_setuid_variation2.phpt
+++ b/ext/posix/tests/posix_setuid_variation2.phpt
@@ -3,6 +3,7 @@ Test function posix_setuid() by substituting argument 1 with boolean values.
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
diff --git a/ext/posix/tests/posix_setuid_variation3.phpt b/ext/posix/tests/posix_setuid_variation3.phpt
index 1630cd1..4957229 100644
--- a/ext/posix/tests/posix_setuid_variation3.phpt
+++ b/ext/posix/tests/posix_setuid_variation3.phpt
@@ -3,6 +3,7 @@ Test function posix_setuid() by substituting argument 1 with emptyUnsetUndefNull
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
diff --git a/ext/posix/tests/posix_setuid_variation4.phpt b/ext/posix/tests/posix_setuid_variation4.phpt
index 1675964..288ac0d 100644
--- a/ext/posix/tests/posix_setuid_variation4.phpt
+++ b/ext/posix/tests/posix_setuid_variation4.phpt
@@ -3,6 +3,7 @@ Test function posix_setuid() by substituting argument 1 with float values.
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
diff --git a/ext/posix/tests/posix_setuid_variation5.phpt b/ext/posix/tests/posix_setuid_variation5.phpt
index e1b7c05..a4ebe63 100644
--- a/ext/posix/tests/posix_setuid_variation5.phpt
+++ b/ext/posix/tests/posix_setuid_variation5.phpt
@@ -3,6 +3,7 @@ Test function posix_setuid() by substituting argument 1 with int values.
 --SKIPIF--
 <?php 
         if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; 
+        if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
 ?>
 --CREDITS--
 Marco Fabbri mrfabbri at gmail.com
diff --git a/ext/posix/tests/posix_uname.phpt b/ext/posix/tests/posix_uname.phpt
index 12c4bae..3acbdaf 100644
--- a/ext/posix/tests/posix_uname.phpt
+++ b/ext/posix/tests/posix_uname.phpt
@@ -14,7 +14,9 @@ PHP Testfest Berlin 2009-05-10
 ?>
 --FILE--
 <?php
-    var_dump(posix_uname());
+    $uname = posix_uname();
+    unset($uname['domainname']);
+    var_dump($uname);
 ?>
 ===DONE===
 --EXPECTF--
diff --git a/ext/posix/tests/posix_uname_basic.phpt b/ext/posix/tests/posix_uname_basic.phpt
index 7dd3781..6bd5b10 100644
--- a/ext/posix/tests/posix_uname_basic.phpt
+++ b/ext/posix/tests/posix_uname_basic.phpt
@@ -9,7 +9,7 @@ Test posix_uname() function : basic functionality
   echo "Basic test of POSIX uname function\n"; 
   	
   $uname = posix_uname();  
-  
+  unset($uname['domainname']);  
   print_r($uname);
   
 ?>
diff --git a/ext/pspell/php_pspell.h b/ext/pspell/php_pspell.h
index 525a2c9..6aa91ef 100644
--- a/ext/pspell/php_pspell.h
+++ b/ext/pspell/php_pspell.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pspell.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pspell.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef _PSPELL_H
 #define _PSPELL_H
diff --git a/ext/pspell/pspell.c b/ext/pspell/pspell.c
index 692d597..4db27d9 100644
--- a/ext/pspell/pspell.c
+++ b/ext/pspell/pspell.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: pspell.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pspell.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define IS_EXT_MODULE
 
diff --git a/ext/readline/config.m4 b/ext/readline/config.m4
index 00875c0..0779203 100644
--- a/ext/readline/config.m4
+++ b/ext/readline/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 286797 2009-08-04 11:20:49Z jani $
+dnl $Id: config.m4 292081 2009-12-13 17:06:47Z felipe $
 dnl
 
 PHP_ARG_WITH(libedit,for libedit readline replacement, 
@@ -65,7 +65,7 @@ if test "$PHP_READLINE" && test "$PHP_READLINE" != "no"; then
 elif test "$PHP_LIBEDIT" != "no"; then
 
   for i in $PHP_LIBEDIT /usr/local /usr; do
-    test -f $i/include/readline/readline.h && LIBEDIT_DIR=$i && break
+    test -f $i/include/editline/readline.h && LIBEDIT_DIR=$i && break
   done
 
   if test -z "$LIBEDIT_DIR"; then
diff --git a/ext/readline/php_readline.h b/ext/readline/php_readline.h
index 3b4ded0..eddf1f9 100644
--- a/ext/readline/php_readline.h
+++ b/ext/readline/php_readline.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_readline.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_readline.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_READLINE_H
 #define PHP_READLINE_H
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 9678d8f..84b9ef2 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: readline.c 274222 2009-01-22 14:40:20Z iliaa $ */
+/* $Id: readline.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* {{{ includes & prototypes */
 
@@ -33,8 +33,10 @@
 #define rl_completion_matches completion_matches
 #endif
 
+#ifdef HAVE_LIBEDIT
+#include <editline/readline.h>
+#else
 #include <readline/readline.h>
-#ifndef HAVE_LIBEDIT
 #include <readline/history.h>
 #endif
 
diff --git a/ext/readline/tests/readline_add_history_001.phpt b/ext/readline/tests/readline_add_history_001.phpt
index 4b092d0..a4bd524 100644
--- a/ext/readline/tests/readline_add_history_001.phpt
+++ b/ext/readline/tests/readline_add_history_001.phpt
@@ -1,7 +1,7 @@
 --TEST--
 readline_add_history(): Basic test
 --SKIPIF--
-<?php if (!extension_loaded("readline")) die("skip"); ?>
+<?php if (!extension_loaded("readline") || !function_exists('readline_list_history')) die("skip"); ?>
 --FILE--
 <?php
 
diff --git a/ext/readline/tests/readline_callback_handler_install_001.phpt b/ext/readline/tests/readline_callback_handler_install_001.phpt
index 6df4429..8bf1d61 100644
--- a/ext/readline/tests/readline_callback_handler_install_001.phpt
+++ b/ext/readline/tests/readline_callback_handler_install_001.phpt
@@ -1,7 +1,7 @@
 --TEST--
 readline_callback_handler_install(): Basic test
 --SKIPIF--
-<?php if (!extension_loaded("readline")) die("skip"); ?>
+<?php if (!extension_loaded("readline") || !function_exists('readline_callback_handler_install')) die("skip"); ?>
 --FILE--
 <?php
 
diff --git a/ext/readline/tests/readline_callback_handler_remove_001.phpt b/ext/readline/tests/readline_callback_handler_remove_001.phpt
index 6688f83..768041a 100644
--- a/ext/readline/tests/readline_callback_handler_remove_001.phpt
+++ b/ext/readline/tests/readline_callback_handler_remove_001.phpt
@@ -1,7 +1,7 @@
 --TEST--
 readline_callback_handler_remove(): Basic test
 --SKIPIF--
-<?php if (!extension_loaded("readline")) die("skip"); ?>
+<?php if (!extension_loaded("readline") || !function_exists('readline_callback_handler_remove')) die("skip"); ?>
 --FILE--
 <?php
 
diff --git a/ext/readline/tests/readline_list_history_001.phpt b/ext/readline/tests/readline_list_history_001.phpt
index ad8f8eb..2f6f952 100644
--- a/ext/readline/tests/readline_list_history_001.phpt
+++ b/ext/readline/tests/readline_list_history_001.phpt
@@ -1,7 +1,7 @@
 --TEST--
 readline_list_history(): Basic test
 --SKIPIF--
-<?php if (!extension_loaded("readline")) die("skip"); ?>
+<?php if (!extension_loaded("readline") || !function_exists('readline_list_history')) die("skip"); ?>
 --FILE--
 <?php
 
diff --git a/ext/readline/tests/readline_read_history_001.phpt b/ext/readline/tests/readline_read_history_001.phpt
index 2f7c889..fcdb1ae 100644
--- a/ext/readline/tests/readline_read_history_001.phpt
+++ b/ext/readline/tests/readline_read_history_001.phpt
@@ -1,7 +1,7 @@
 --TEST--
 readline_read_history(): Basic test
 --SKIPIF--
-<?php if (!extension_loaded("readline")) die("skip"); ?>
+<?php if (!extension_loaded("readline") || !function_exists('readline_list_history')) die("skip"); ?>
 --FILE--
 <?php
 
diff --git a/ext/readline/tests/readline_write_history_001.phpt b/ext/readline/tests/readline_write_history_001.phpt
index eca831f..fc0ae32 100644
--- a/ext/readline/tests/readline_write_history_001.phpt
+++ b/ext/readline/tests/readline_write_history_001.phpt
@@ -1,7 +1,7 @@
 --TEST--
 readline_write_history(): Basic test
 --SKIPIF--
-<?php if (!extension_loaded("readline")) die("skip"); ?>
+<?php if (!extension_loaded("readline") || !function_exists('readline_add_history')) die("skip"); ?>
 --FILE--
 <?php
 
diff --git a/ext/recode/php_recode.h b/ext/recode/php_recode.h
index d501b5b..0dacd46 100644
--- a/ext/recode/php_recode.h
+++ b/ext/recode/php_recode.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_recode.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_recode.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_RECODE_H
 #define PHP_RECODE_H
diff --git a/ext/recode/recode.c b/ext/recode/recode.c
index 3fd3c16..bc3e53c 100644
--- a/ext/recode/recode.c
+++ b/ext/recode/recode.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: recode.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: recode.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* {{{ includes & prototypes */
 
@@ -135,7 +135,7 @@ PHP_MINFO_FUNCTION(recode)
 {
 	php_info_print_table_start();
 	php_info_print_table_row(2, "Recode Support", "enabled");
-	php_info_print_table_row(2, "Revision", "$Revision: 272370 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 293036 $");
 	php_info_print_table_end();
 }
 
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 77af950..ae77dd2 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_reflection.c 287991 2009-09-03 14:02:51Z sebastian $ */
+/* $Id: php_reflection.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -176,7 +176,6 @@ static void string_free(string *str)
 typedef struct _property_reference {
 	zend_class_entry *ce;
 	zend_property_info prop;
-	unsigned int ignore_visibility:1;
 } property_reference;
 
 /* Struct for parameters */
@@ -201,6 +200,7 @@ typedef struct {
 	reflection_type_t ref_type;
 	zval *obj;
 	zend_class_entry *ce;
+	unsigned int ignore_visibility:1;
 } reflection_object;
 
 static zend_object_handlers reflection_object_handlers;
@@ -213,9 +213,7 @@ static void _default_get_entry(zval *object, char *name, int name_len, zval *ret
 		RETURN_FALSE;
 	}
 
-	*return_value = **value;
-	zval_copy_ctor(return_value);
-	INIT_PZVAL(return_value);
+	MAKE_COPY_ZVAL(value, return_value);
 }
 
 #ifdef ilia_0
@@ -1290,10 +1288,10 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info
 	reference = (property_reference*) emalloc(sizeof(property_reference));
 	reference->ce = ce;
 	reference->prop = *prop;
-	reference->ignore_visibility = 0;
 	intern->ptr = reference;
 	intern->ref_type = REF_TYPE_PROPERTY;
 	intern->ce = ce;
+	intern->ignore_visibility = 0;
 	zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL);
 	zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL);
 }
@@ -2561,8 +2559,9 @@ ZEND_METHOD(reflection_method, invoke)
 
 	GET_REFLECTION_OBJECT_PTR(mptr);
 
-	if (!(mptr->common.fn_flags & ZEND_ACC_PUBLIC)
-		|| (mptr->common.fn_flags & ZEND_ACC_ABSTRACT))
+	if ((!(mptr->common.fn_flags & ZEND_ACC_PUBLIC)
+		 || (mptr->common.fn_flags & ZEND_ACC_ABSTRACT))
+		 && intern->ignore_visibility == 0)
 	{
 		if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
 			zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 
@@ -2669,8 +2668,9 @@ ZEND_METHOD(reflection_method, invokeArgs)
 		return;
 	}
 
-	if (!(mptr->common.fn_flags & ZEND_ACC_PUBLIC)
-		|| (mptr->common.fn_flags & ZEND_ACC_ABSTRACT))
+	if ((!(mptr->common.fn_flags & ZEND_ACC_PUBLIC)
+		 || (mptr->common.fn_flags & ZEND_ACC_ABSTRACT))
+		 && intern->ignore_visibility == 0)
 	{
 		if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
 			zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 
@@ -2959,6 +2959,27 @@ ZEND_METHOD(reflection_method, getPrototype)
 }
 /* }}} */
 
+/* {{{ proto public void ReflectionMethod::setAccessible(bool visible)
+   Sets whether non-public methods can be invoked */
+ZEND_METHOD(reflection_method, setAccessible)
+{
+	reflection_object *intern;
+	zend_bool visible;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &visible) == FAILURE) {
+		return;
+	}
+
+	intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
+
+	if (intern == NULL) {
+		return;
+	}
+
+	intern->ignore_visibility = visible;
+}
+/* }}} */
+
 /* {{{ proto public static mixed ReflectionClass::export(mixed argument [, bool return]) throws ReflectionException
    Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
 ZEND_METHOD(reflection_class, export)
@@ -3064,9 +3085,7 @@ ZEND_METHOD(reflection_class, getStaticProperties)
 			if (!(class_name && class_name[0] != '*' && strcmp(class_name, ce->name))) {
 				/* copy: enforce read only access */
 				ALLOC_ZVAL(prop_copy);
-				*prop_copy = **value;
-				zval_copy_ctor(prop_copy);
-				INIT_PZVAL(prop_copy);
+				MAKE_COPY_ZVAL(value, prop_copy);
 
 				add_assoc_zval(return_value, prop_name, prop_copy);
 			}
@@ -3189,9 +3208,7 @@ ZEND_METHOD(reflection_class, getDefaultProperties)
 
 				/* copy: enforce read only access */
 				ALLOC_ZVAL(prop_copy);
-				*prop_copy = **prop;
-				zval_copy_ctor(prop_copy);
-				INIT_PZVAL(prop_copy);
+				MAKE_COPY_ZVAL(prop, prop_copy);
 
 				add_assoc_zval(return_value, prop_name, prop_copy);
 			}
@@ -3489,6 +3506,7 @@ ZEND_METHOD(reflection_class, getMethods)
 ZEND_METHOD(reflection_class, hasProperty)
 {
 	reflection_object *intern;
+	zend_property_info *property_info;
 	zend_class_entry *ce;
 	char *name; 
 	int name_len;
@@ -3500,14 +3518,16 @@ ZEND_METHOD(reflection_class, hasProperty)
 	}
 
 	GET_REFLECTION_OBJECT_PTR(ce);
-	if (zend_hash_exists(&ce->properties_info, name, name_len + 1)) {
+	if (zend_hash_find(&ce->properties_info, name, name_len+1, (void **) &property_info) == SUCCESS) {
+		if (property_info->flags & ZEND_ACC_SHADOW) {
+			RETURN_FALSE;
+		}
 		RETURN_TRUE;
 	} else {
-		if (intern->obj && Z_OBJ_HANDLER_P(intern->obj, has_property))
-		{
+		if (intern->obj && Z_OBJ_HANDLER_P(intern->obj, has_property)) {
 			MAKE_STD_ZVAL(property);
 			ZVAL_STRINGL(property, name, name_len, 1);
-			if (Z_OBJ_HANDLER_P(intern->obj, has_property)(intern->obj, property, 0 TSRMLS_CC)) {
+			if (Z_OBJ_HANDLER_P(intern->obj, has_property)(intern->obj, property, 2 TSRMLS_CC)) {
 				zval_ptr_dtor(&property);
 				RETURN_TRUE;
 			}
@@ -3720,9 +3740,7 @@ ZEND_METHOD(reflection_class, getConstant)
 	if (zend_hash_find(&ce->constants_table, name, name_len + 1, (void **) &value) == FAILURE) {
 		RETURN_FALSE;
 	}
-	*return_value = **value;
-	zval_copy_ctor(return_value);
-	INIT_PZVAL(return_value);
+	MAKE_COPY_ZVAL(value, return_value);
 }
 /* }}} */
 
@@ -4375,10 +4393,10 @@ ZEND_METHOD(reflection_property, __construct)
 		reference->prop = *property_info;
 	}
 	reference->ce = ce;
-	reference->ignore_visibility = 0;
 	intern->ptr = reference;
 	intern->ref_type = REF_TYPE_PROPERTY;
 	intern->ce = ce;
+	intern->ignore_visibility = 0;
 }
 /* }}} */
 
@@ -4491,7 +4509,7 @@ ZEND_METHOD(reflection_property, getValue)
 	METHOD_NOTSTATIC(reflection_property_ptr);
 	GET_REFLECTION_OBJECT_PTR(ref);
 
-	if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && ref->ignore_visibility == 0) {
+	if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) {
 		_default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC);
 		zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 
 			"Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name));
@@ -4505,9 +4523,7 @@ ZEND_METHOD(reflection_property, getValue)
 			zend_error(E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name);
 			/* Bails out */
 		}
-		*return_value= **member;
-		zval_copy_ctor(return_value);
-		INIT_PZVAL(return_value);
+		MAKE_COPY_ZVAL(member, return_value);
 	} else {
 		char *class_name, *prop_name;
 		
@@ -4516,9 +4532,7 @@ ZEND_METHOD(reflection_property, getValue)
 		}
 		zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name);
 		member_p = zend_read_property(ref->ce, object, prop_name, strlen(prop_name), 1 TSRMLS_CC);
-		*return_value= *member_p;
-		zval_copy_ctor(return_value);
-		INIT_PZVAL(return_value);
+		MAKE_COPY_ZVAL(&member_p, return_value);
 		if (member_p != EG(uninitialized_zval_ptr)) {
 			zval_add_ref(&member_p);
 			zval_ptr_dtor(&member_p);
@@ -4543,7 +4557,7 @@ ZEND_METHOD(reflection_property, setValue)
 	METHOD_NOTSTATIC(reflection_property_ptr);
 	GET_REFLECTION_OBJECT_PTR(ref);
 
-	if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && ref->ignore_visibility == 0) {
+	if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
 		_default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC);
 		zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 
 			"Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name));
@@ -4655,19 +4669,24 @@ ZEND_METHOD(reflection_property, getDocComment)
 }
 /* }}} */
 
-/* {{{ proto public int ReflectionProperty::setAccessible()
+/* {{{ proto public int ReflectionProperty::setAccessible(bool visible)
    Sets whether non-public properties can be requested */
 ZEND_METHOD(reflection_property, setAccessible)
 {
 	reflection_object *intern;
-	property_reference *ref;
 	zend_bool visible;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &visible) == FAILURE) {
 		return;
 	}
-	GET_REFLECTION_OBJECT_PTR(ref);
-	ref->ignore_visibility = visible;
+
+	intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
+
+	if (intern == NULL) {
+		return;
+	}
+
+	intern->ignore_visibility = visible;
 }
 /* }}} */
 
@@ -5000,6 +5019,9 @@ static const zend_function_entry reflection_exception_functions[] = {
 	{NULL, NULL, NULL}
 };
 
+ZEND_BEGIN_ARG_INFO(arginfo_reflection__void, 0)
+ZEND_END_ARG_INFO()
+
 
 ZEND_BEGIN_ARG_INFO(arginfo_reflection_getModifierNames, 0)
 	ZEND_ARG_INFO(0, modifiers)
@@ -5018,7 +5040,7 @@ static const zend_function_entry reflection_functions[] = {
 
 static const zend_function_entry reflector_functions[] = {
 	ZEND_FENTRY(export, NULL, NULL, ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT|ZEND_ACC_PUBLIC)
-	ZEND_ABSTRACT_ME(reflector, __toString, NULL)
+	ZEND_ABSTRACT_ME(reflector, __toString, arginfo_reflection__void)
 	{NULL, NULL, NULL}
 };
 
@@ -5040,35 +5062,35 @@ ZEND_BEGIN_ARG_INFO(arginfo_reflection_function_invokeArgs, 0)
 ZEND_END_ARG_INFO()
 
 static const zend_function_entry reflection_function_abstract_functions[] = {
-	ZEND_ME(reflection, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
-	PHP_ABSTRACT_ME(reflection_function, __toString, NULL)
-	ZEND_ME(reflection_function, inNamespace, NULL, 0)
-	ZEND_ME(reflection_function, isClosure, NULL, 0)
-	ZEND_ME(reflection_function, isDeprecated, NULL, 0)
-	ZEND_ME(reflection_function, isInternal, NULL, 0)
-	ZEND_ME(reflection_function, isUserDefined, NULL, 0)
-	ZEND_ME(reflection_function, getDocComment, NULL, 0)
-	ZEND_ME(reflection_function, getEndLine, NULL, 0)
-	ZEND_ME(reflection_function, getExtension, NULL, 0)
-	ZEND_ME(reflection_function, getExtensionName, NULL, 0)
-	ZEND_ME(reflection_function, getFileName, NULL, 0)
-	ZEND_ME(reflection_function, getName, NULL, 0)
-	ZEND_ME(reflection_function, getNamespaceName, NULL, 0)
-	ZEND_ME(reflection_function, getNumberOfParameters, NULL, 0)
-	ZEND_ME(reflection_function, getNumberOfRequiredParameters, NULL, 0)
-	ZEND_ME(reflection_function, getParameters, NULL, 0)
-	ZEND_ME(reflection_function, getShortName, NULL, 0)
-	ZEND_ME(reflection_function, getStartLine, NULL, 0)
-	ZEND_ME(reflection_function, getStaticVariables, NULL, 0)
-	ZEND_ME(reflection_function, returnsReference, NULL, 0)
+	ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+	PHP_ABSTRACT_ME(reflection_function, __toString, arginfo_reflection__void)
+	ZEND_ME(reflection_function, inNamespace, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, isClosure, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, isDeprecated, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, isInternal, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, isUserDefined, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getDocComment, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getEndLine, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getExtension, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getExtensionName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getFileName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getNamespaceName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getNumberOfParameters, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getNumberOfRequiredParameters, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getParameters, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getShortName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getStartLine, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, getStaticVariables, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_function, returnsReference, arginfo_reflection__void, 0)
 	{NULL, NULL, NULL}
 };
 
 static const zend_function_entry reflection_function_functions[] = {
 	ZEND_ME(reflection_function, __construct, arginfo_reflection_function___construct, 0)
-	ZEND_ME(reflection_function, __toString, NULL, 0)
+	ZEND_ME(reflection_function, __toString, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_function, export, arginfo_reflection_function_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
-	ZEND_ME(reflection_function, isDisabled, NULL, 0)
+	ZEND_ME(reflection_function, isDisabled, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_function, invoke, arginfo_reflection_function_invoke, 0)
 	ZEND_ME(reflection_function, invokeArgs, arginfo_reflection_function_invokeArgs, 0)
 	{NULL, NULL, NULL}
@@ -5095,23 +5117,28 @@ ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_invokeArgs, 0)
 	ZEND_ARG_ARRAY_INFO(0, args, 0)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_setAccessible, 0)
+	ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
 static const zend_function_entry reflection_method_functions[] = {
 	ZEND_ME(reflection_method, export, arginfo_reflection_method_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
 	ZEND_ME(reflection_method, __construct, arginfo_reflection_method___construct, 0)
-	ZEND_ME(reflection_method, __toString, NULL, 0)
-	ZEND_ME(reflection_method, isPublic, NULL, 0)
-	ZEND_ME(reflection_method, isPrivate, NULL, 0)
-	ZEND_ME(reflection_method, isProtected, NULL, 0)
-	ZEND_ME(reflection_method, isAbstract, NULL, 0)
-	ZEND_ME(reflection_method, isFinal, NULL, 0)
-	ZEND_ME(reflection_method, isStatic, NULL, 0)
-	ZEND_ME(reflection_method, isConstructor, NULL, 0)
-	ZEND_ME(reflection_method, isDestructor, NULL, 0)
-	ZEND_ME(reflection_method, getModifiers, NULL, 0)
+	ZEND_ME(reflection_method, __toString, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_method, isPublic, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_method, isPrivate, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_method, isProtected, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_method, isAbstract, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_method, isFinal, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_method, isStatic, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_method, isConstructor, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_method, isDestructor, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_method, getModifiers, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_method, invoke, arginfo_reflection_method_invoke, 0)
 	ZEND_ME(reflection_method, invokeArgs, arginfo_reflection_method_invokeArgs, 0)
-	ZEND_ME(reflection_method, getDeclaringClass, NULL, 0)
-	ZEND_ME(reflection_method, getPrototype, NULL, 0)
+	ZEND_ME(reflection_method, getDeclaringClass, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_method, getPrototype, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_property, setAccessible, arginfo_reflection_method_setAccessible, 0)
 	{NULL, NULL, NULL}
 };
 
@@ -5188,19 +5215,19 @@ ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_implementsInterface, 0)
 ZEND_END_ARG_INFO()
 
 static const zend_function_entry reflection_class_functions[] = {
-	ZEND_ME(reflection, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+	ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
 	ZEND_ME(reflection_class, export, arginfo_reflection_class_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
 	ZEND_ME(reflection_class, __construct, arginfo_reflection_class___construct, 0)
-	ZEND_ME(reflection_class, __toString, NULL, 0)
-	ZEND_ME(reflection_class, getName, NULL, 0)
-	ZEND_ME(reflection_class, isInternal, NULL, 0)
-	ZEND_ME(reflection_class, isUserDefined, NULL, 0)
-	ZEND_ME(reflection_class, isInstantiable, NULL, 0)
-	ZEND_ME(reflection_class, getFileName, NULL, 0)
-	ZEND_ME(reflection_class, getStartLine, NULL, 0)
-	ZEND_ME(reflection_class, getEndLine, NULL, 0)
-	ZEND_ME(reflection_class, getDocComment, NULL, 0)
-	ZEND_ME(reflection_class, getConstructor, NULL, 0)
+	ZEND_ME(reflection_class, __toString, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, isInternal, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, isUserDefined, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, isInstantiable, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getFileName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getStartLine, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getEndLine, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getDocComment, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getConstructor, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_class, hasMethod, arginfo_reflection_class_hasMethod, 0)
 	ZEND_ME(reflection_class, getMethod, arginfo_reflection_class_getMethod, 0)
 	ZEND_ME(reflection_class, getMethods, arginfo_reflection_class_getMethods, 0)
@@ -5208,30 +5235,30 @@ static const zend_function_entry reflection_class_functions[] = {
 	ZEND_ME(reflection_class, getProperty, arginfo_reflection_class_getProperty, 0)
 	ZEND_ME(reflection_class, getProperties, arginfo_reflection_class_getProperties, 0)
 	ZEND_ME(reflection_class, hasConstant, arginfo_reflection_class_hasConstant, 0)
-	ZEND_ME(reflection_class, getConstants, NULL, 0)
+	ZEND_ME(reflection_class, getConstants, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_class, getConstant, arginfo_reflection_class_getConstant, 0)
-	ZEND_ME(reflection_class, getInterfaces, NULL, 0)
-	ZEND_ME(reflection_class, getInterfaceNames, NULL, 0)
-	ZEND_ME(reflection_class, isInterface, NULL, 0)
-	ZEND_ME(reflection_class, isAbstract, NULL, 0)
-	ZEND_ME(reflection_class, isFinal, NULL, 0)
-	ZEND_ME(reflection_class, getModifiers, NULL, 0)
+	ZEND_ME(reflection_class, getInterfaces, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getInterfaceNames, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, isInterface, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, isAbstract, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, isFinal, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getModifiers, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_class, isInstance, arginfo_reflection_class_isInstance, 0)
 	ZEND_ME(reflection_class, newInstance, arginfo_reflection_class_newInstance, 0)
 	ZEND_ME(reflection_class, newInstanceArgs, arginfo_reflection_class_newInstanceArgs, 0)
-	ZEND_ME(reflection_class, getParentClass, NULL, 0)
+	ZEND_ME(reflection_class, getParentClass, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_class, isSubclassOf, arginfo_reflection_class_isSubclassOf, 0)
-	ZEND_ME(reflection_class, getStaticProperties, NULL, 0)
+	ZEND_ME(reflection_class, getStaticProperties, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_class, getStaticPropertyValue, arginfo_reflection_class_getStaticPropertyValue, 0)
 	ZEND_ME(reflection_class, setStaticPropertyValue, arginfo_reflection_class_setStaticPropertyValue, 0)
-	ZEND_ME(reflection_class, getDefaultProperties, NULL, 0)
-	ZEND_ME(reflection_class, isIterateable, NULL, 0)
+	ZEND_ME(reflection_class, getDefaultProperties, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, isIterateable, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_class, implementsInterface, arginfo_reflection_class_implementsInterface, 0)
-	ZEND_ME(reflection_class, getExtension, NULL, 0)
-	ZEND_ME(reflection_class, getExtensionName, NULL, 0)
-	ZEND_ME(reflection_class, inNamespace, NULL, 0)
-	ZEND_ME(reflection_class, getNamespaceName, NULL, 0)
-	ZEND_ME(reflection_class, getShortName, NULL, 0)
+	ZEND_ME(reflection_class, getExtension, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getExtensionName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, inNamespace, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getNamespaceName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_class, getShortName, arginfo_reflection__void, 0)
 	{NULL, NULL, NULL}
 };
 
@@ -5252,44 +5279,46 @@ static const zend_function_entry reflection_object_functions[] = {
 };
 
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_export, 0, 0, 1)
-	ZEND_ARG_INFO(0, argument)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_export, 0, 0, 2)
+	ZEND_ARG_INFO(0, class)
+	ZEND_ARG_INFO(0, name)
 	ZEND_ARG_INFO(0, return)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_property___construct, 0)
-	ZEND_ARG_INFO(0, argument)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property___construct, 0, 0, 0)
+	ZEND_ARG_INFO(0, class)
+	ZEND_ARG_INFO(0, name)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_getValue, 0, 0, 0)
 	ZEND_ARG_INFO(0, object)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_property_setValue, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_setValue, 0, 0, 1)
 	ZEND_ARG_INFO(0, object)
 	ZEND_ARG_INFO(0, value)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO(arginfo_reflection_property_setAccessible, 0)
-	ZEND_ARG_INFO(0, value)
+	ZEND_ARG_INFO(0, visible)
 ZEND_END_ARG_INFO()
 
 static const zend_function_entry reflection_property_functions[] = {
-	ZEND_ME(reflection, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+	ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
 	ZEND_ME(reflection_property, export, arginfo_reflection_property_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
 	ZEND_ME(reflection_property, __construct, arginfo_reflection_property___construct, 0)
-	ZEND_ME(reflection_property, __toString, NULL, 0)
-	ZEND_ME(reflection_property, getName, NULL, 0)
+	ZEND_ME(reflection_property, __toString, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_property, getName, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_property, getValue, arginfo_reflection_property_getValue, 0)
 	ZEND_ME(reflection_property, setValue, arginfo_reflection_property_setValue, 0)
-	ZEND_ME(reflection_property, isPublic, NULL, 0)
-	ZEND_ME(reflection_property, isPrivate, NULL, 0)
-	ZEND_ME(reflection_property, isProtected, NULL, 0)
-	ZEND_ME(reflection_property, isStatic, NULL, 0)
-	ZEND_ME(reflection_property, isDefault, NULL, 0)
-	ZEND_ME(reflection_property, getModifiers, NULL, 0)
-	ZEND_ME(reflection_property, getDeclaringClass, NULL, 0)
-	ZEND_ME(reflection_property, getDocComment, NULL, 0)
+	ZEND_ME(reflection_property, isPublic, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_property, isPrivate, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_property, isProtected, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_property, isStatic, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_property, isDefault, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_property, getModifiers, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_property, getDeclaringClass, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_property, getDocComment, arginfo_reflection__void, 0)
 	ZEND_ME(reflection_property, setAccessible, arginfo_reflection_property_setAccessible, 0)
 	{NULL, NULL, NULL}
 };
@@ -5306,21 +5335,21 @@ ZEND_BEGIN_ARG_INFO(arginfo_reflection_parameter___construct, 0)
 ZEND_END_ARG_INFO()
 
 static const zend_function_entry reflection_parameter_functions[] = {
-	ZEND_ME(reflection, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+	ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
 	ZEND_ME(reflection_parameter, export, arginfo_reflection_parameter_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
 	ZEND_ME(reflection_parameter, __construct, arginfo_reflection_parameter___construct, 0)
-	ZEND_ME(reflection_parameter, __toString, NULL, 0)
-	ZEND_ME(reflection_parameter, getName, NULL, 0)
-	ZEND_ME(reflection_parameter, isPassedByReference, NULL, 0)
-	ZEND_ME(reflection_parameter, getDeclaringFunction, NULL, 0)
-	ZEND_ME(reflection_parameter, getDeclaringClass, NULL, 0)
-	ZEND_ME(reflection_parameter, getClass, NULL, 0)
-	ZEND_ME(reflection_parameter, isArray, NULL, 0)
-	ZEND_ME(reflection_parameter, allowsNull, NULL, 0)
-	ZEND_ME(reflection_parameter, getPosition, NULL, 0)
-	ZEND_ME(reflection_parameter, isOptional, NULL, 0)
-	ZEND_ME(reflection_parameter, isDefaultValueAvailable, NULL, 0)
-	ZEND_ME(reflection_parameter, getDefaultValue, NULL, 0)
+	ZEND_ME(reflection_parameter, __toString, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, getName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, isPassedByReference, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, getDeclaringFunction, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, getDeclaringClass, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, getClass, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, isArray, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, allowsNull, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, getPosition, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, isOptional, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, isDefaultValueAvailable, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_parameter, getDefaultValue, arginfo_reflection__void, 0)
 	{NULL, NULL, NULL}
 };
 
@@ -5334,19 +5363,19 @@ ZEND_BEGIN_ARG_INFO(arginfo_reflection_extension___construct, 0)
 ZEND_END_ARG_INFO()
 
 static const zend_function_entry reflection_extension_functions[] = {
-	ZEND_ME(reflection, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+	ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
 	ZEND_ME(reflection_extension, export, arginfo_reflection_extension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
 	ZEND_ME(reflection_extension, __construct, arginfo_reflection_extension___construct, 0)
-	ZEND_ME(reflection_extension, __toString, NULL, 0)
-	ZEND_ME(reflection_extension, getName, NULL, 0)
-	ZEND_ME(reflection_extension, getVersion, NULL, 0)
-	ZEND_ME(reflection_extension, getFunctions, NULL, 0)
-	ZEND_ME(reflection_extension, getConstants, NULL, 0)
-	ZEND_ME(reflection_extension, getINIEntries, NULL, 0)
-	ZEND_ME(reflection_extension, getClasses, NULL, 0)
-	ZEND_ME(reflection_extension, getClassNames, NULL, 0)
-	ZEND_ME(reflection_extension, getDependencies, NULL, 0)
-	ZEND_ME(reflection_extension, info, NULL, 0)
+	ZEND_ME(reflection_extension, __toString, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_extension, getName, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_extension, getVersion, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_extension, getFunctions, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_extension, getConstants, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_extension, getINIEntries, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_extension, getClasses, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_extension, getClassNames, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_extension, getDependencies, arginfo_reflection__void, 0)
+	ZEND_ME(reflection_extension, info, arginfo_reflection__void, 0)
 	{NULL, NULL, NULL}
 };
 /* }}} */
@@ -5465,7 +5494,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: 287991 $");
+	php_info_print_table_row(2, "Version", "$Revision: 293036 $");
 
 	php_info_print_table_end();
 } /* }}} */
@@ -5479,7 +5508,7 @@ zend_module_entry reflection_module_entry = { /* {{{ */
 	NULL,
 	NULL,
 	PHP_MINFO(reflection),
-	"$Revision: 287991 $",
+	"$Revision: 293036 $",
 	STANDARD_MODULE_PROPERTIES
 }; /* }}} */
 
diff --git a/ext/reflection/php_reflection.h b/ext/reflection/php_reflection.h
index d280a9f..f53f581 100644
--- a/ext/reflection/php_reflection.h
+++ b/ext/reflection/php_reflection.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_reflection.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_reflection.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_REFLECTION_H
 #define PHP_REFLECTION_H
diff --git a/ext/reflection/tests/020.phpt b/ext/reflection/tests/020.phpt
index 04cc6a1..c5b0ae5 100755
--- a/ext/reflection/tests/020.phpt
+++ b/ext/reflection/tests/020.phpt
@@ -24,5 +24,4 @@ var_dump($obj->hasProperty("p4"));
 bool(true)
 bool(true)
 bool(true)
-string(2) "p4"
 bool(false)
diff --git a/ext/reflection/tests/ReflectionClass_hasProperty_001.phpt b/ext/reflection/tests/ReflectionClass_hasProperty_001.phpt
index 94f739c..88c4cd5 100644
--- a/ext/reflection/tests/ReflectionClass_hasProperty_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_hasProperty_001.phpt
@@ -69,7 +69,7 @@ Reflecting on class privf:
   --> Check for doesntExist: bool(false)
 Reflecting on class subprivf: 
   --> Check for s: bool(true)
-  --> Check for a: bool(true)
+  --> Check for a: bool(false)
   --> Check for A: bool(false)
   --> Check for doesntExist: bool(false)
 
diff --git a/ext/reflection/tests/ReflectionClass_toString_001.phpt b/ext/reflection/tests/ReflectionClass_toString_001.phpt
index bf2221c..6173cf0 100644
--- a/ext/reflection/tests/ReflectionClass_toString_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_toString_001.phpt
@@ -36,6 +36,9 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
 
   - Methods [43] {
     Method [ <internal:Reflection> final private method __clone ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection, ctor> public method __construct ] {
@@ -46,33 +49,63 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
     }
 
     Method [ <internal:Reflection> public method __toString ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getName ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method isInternal ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method isUserDefined ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method isInstantiable ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getFileName ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getStartLine ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getEndLine ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getDocComment ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getConstructor ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method hasMethod ] {
@@ -125,6 +158,9 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
     }
 
     Method [ <internal:Reflection> public method getConstants ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getConstant ] {
@@ -135,21 +171,39 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
     }
 
     Method [ <internal:Reflection> public method getInterfaces ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getInterfaceNames ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method isInterface ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method isAbstract ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method isFinal ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getModifiers ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method isInstance ] {
@@ -174,6 +228,9 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
     }
 
     Method [ <internal:Reflection> public method getParentClass ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method isSubclassOf ] {
@@ -184,6 +241,9 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
     }
 
     Method [ <internal:Reflection> public method getStaticProperties ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getStaticPropertyValue ] {
@@ -203,9 +263,15 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
     }
 
     Method [ <internal:Reflection> public method getDefaultProperties ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method isIterateable ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method implementsInterface ] {
@@ -216,18 +282,33 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
     }
 
     Method [ <internal:Reflection> public method getExtension ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getExtensionName ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method inNamespace ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getNamespaceName ] {
+
+      - Parameters [0] {
+      }
     }
 
     Method [ <internal:Reflection> public method getShortName ] {
+
+      - Parameters [0] {
+      }
     }
   }
 }
diff --git a/ext/reflection/tests/ReflectionMethod_basic2.phpt b/ext/reflection/tests/ReflectionMethod_basic2.phpt
index 1e21c42..e2c23c1 100644
--- a/ext/reflection/tests/ReflectionMethod_basic2.phpt
+++ b/ext/reflection/tests/ReflectionMethod_basic2.phpt
@@ -152,8 +152,9 @@ Reflecting on method ReflectionProperty::__construct()
 __toString():
 string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
 
-  - Parameters [1] {
-    Parameter #0 [ <required> $argument ]
+  - Parameters [2] {
+    Parameter #0 [ <optional> $class ]
+    Parameter #1 [ <optional> $name ]
   }
 }
 "
@@ -161,8 +162,9 @@ string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
 export():
 string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
 
-  - Parameters [1] {
-    Parameter #0 [ <required> $argument ]
+  - Parameters [2] {
+    Parameter #0 [ <optional> $class ]
+    Parameter #1 [ <optional> $name ]
   }
 }
 "
diff --git a/ext/reflection/tests/ReflectionMethod_setAccessible.phpt b/ext/reflection/tests/ReflectionMethod_setAccessible.phpt
new file mode 100644
index 0000000..79a8fbe
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_setAccessible.phpt
@@ -0,0 +1,111 @@
+--TEST--
+Test ReflectionMethod::setAccessible().
+--FILE--
+<?php
+class A {
+    private function aPrivate($a) { print __METHOD__ . "\n"; }
+    private static function aPrivateStatic($a) { print __METHOD__ . "\n"; }
+    protected function aProtected($a) { print __METHOD__ . "\n"; }
+    protected static function aProtectedStatic($a) { print __METHOD__ . "\n"; }
+}
+
+$private         = new ReflectionMethod('A', 'aPrivate');
+$privateStatic   = new ReflectionMethod('A', 'aPrivateStatic');
+$protected       = new ReflectionMethod('A', 'aProtected');
+$protectedStatic = new ReflectionMethod('A', 'aProtectedStatic');
+
+try {
+    $private->invoke(new A, NULL);
+}
+
+catch (ReflectionException $e) {
+    var_dump($e->getMessage());
+}
+
+try {
+    $private->invokeArgs(new A, array(NULL));
+}
+
+catch (ReflectionException $e) {
+    var_dump($e->getMessage());
+}
+
+try {
+    $privateStatic->invoke(NULL, NULL);
+}
+
+catch (ReflectionException $e) {
+    var_dump($e->getMessage());
+}
+
+try {
+    $privateStatic->invokeArgs(NULL, array(NULL));
+}
+
+catch (ReflectionException $e) {
+    var_dump($e->getMessage());
+}
+
+try {
+    $protected->invoke(new A, NULL);
+}
+
+catch (ReflectionException $e) {
+    var_dump($e->getMessage());
+}
+
+try {
+    $protected->invokeArgs(new A, array(NULL));
+}
+
+catch (ReflectionException $e) {
+    var_dump($e->getMessage());
+}
+
+try {
+    $protectedStatic->invoke(NULL, NULL);
+}
+
+catch (ReflectionException $e) {
+    var_dump($e->getMessage());
+}
+
+try {
+    $protectedStatic->invokeArgs(NULL, array(NULL));
+}
+
+catch (ReflectionException $e) {
+    var_dump($e->getMessage());
+}
+
+$private->setAccessible(TRUE);
+$privateStatic->setAccessible(TRUE);
+$protected->setAccessible(TRUE);
+$protectedStatic->setAccessible(TRUE);
+
+$private->invoke(new A, NULL);
+$private->invokeArgs(new A, array(NULL));
+$privateStatic->invoke(NULL, NULL);
+$privateStatic->invokeArgs(NULL, array(NULL));
+$protected->invoke(new A, NULL);
+$protected->invokeArgs(new A, array(NULL));
+$protectedStatic->invoke(NULL, NULL);
+$protectedStatic->invokeArgs(NULL, array(NULL));
+?>
+--EXPECT--
+string(73) "Trying to invoke private method A::aPrivate() from scope ReflectionMethod"
+string(73) "Trying to invoke private method A::aPrivate() from scope ReflectionMethod"
+string(79) "Trying to invoke private method A::aPrivateStatic() from scope ReflectionMethod"
+string(79) "Trying to invoke private method A::aPrivateStatic() from scope ReflectionMethod"
+string(77) "Trying to invoke protected method A::aProtected() from scope ReflectionMethod"
+string(77) "Trying to invoke protected method A::aProtected() from scope ReflectionMethod"
+string(83) "Trying to invoke protected method A::aProtectedStatic() from scope ReflectionMethod"
+string(83) "Trying to invoke protected method A::aProtectedStatic() from scope ReflectionMethod"
+A::aPrivate
+A::aPrivate
+A::aPrivateStatic
+A::aPrivateStatic
+A::aProtected
+A::aProtected
+A::aProtectedStatic
+A::aProtectedStatic
diff --git a/ext/reflection/tests/bug49719.phpt b/ext/reflection/tests/bug49719.phpt
new file mode 100644
index 0000000..215140a
--- /dev/null
+++ b/ext/reflection/tests/bug49719.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Bug #49719 (ReflectionClass::hasProperty returns true for a private property in base class)
+--FILE--
+<?php
+
+class A {
+	private $a;
+}
+class B extends A {
+	private $b;
+}
+
+try {
+	$b = new B;
+	$ref = new ReflectionClass($b);
+	
+	var_dump(property_exists('b', 'a'));
+	var_dump(property_exists($b, 'a'));
+	var_dump($ref->hasProperty('a'));	
+	var_dump($ref->getProperty('a'));
+} catch (Exception $e) {
+	var_dump($e->getMessage());
+}
+
+class A2 {
+	private $a = 1;
+}
+
+class B2 extends A2 {
+	private $a = 2;
+}
+
+$b2 = new ReflectionClass('B2');
+$prop = $b2->getProperty('a');
+$prop->setAccessible(true);
+var_dump($prop->getValue(new b2));
+
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+bool(false)
+%string|unicode%(25) "Property a does not exist"
+int(2)
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 045acdf..512f93e 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mod_files.c 280729 2009-05-18 16:10:09Z jani $ */
+/* $Id: mod_files.c 294027 2010-01-25 23:06:09Z johannes $ */
 
 #include "php.h"
 
@@ -87,7 +87,9 @@ static int ps_files_valid_key(const char *key)
 
 	len = p - key;
 
-	if (len == 0) {
+	/* Somewhat arbitrary length limit here, but should be way more than
+	   anyone needs and avoids file-level warnings later on if we exceed MAX_PATH */
+	if (len == 0 || len > 128) {
 		ret = 0;
 	}
 
@@ -154,7 +156,7 @@ static void ps_files_open(ps_files *data, const char *key TSRMLS_DC)
 		ps_files_close(data);
 
 		if (!ps_files_valid_key(key)) {
-			php_error_docref(NULL TSRMLS_CC, E_WARNING, "The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,'");
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,'");
 			PS(invalid_session_id) = 1;
 			return;
 		}
@@ -244,11 +246,7 @@ static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC)
 
 				/* check whether its last access was more than maxlifet ago */
 				if (VCWD_STAT(buf, &sbuf) == 0 &&
-#ifdef NETWARE
-						(now - sbuf.st_mtime.tv_sec) > maxlifetime) {
-#else
 						(now - sbuf.st_mtime) > maxlifetime) {
-#endif
 					VCWD_UNLINK(buf);
 					nrdels++;
 				}
diff --git a/ext/session/mod_files.h b/ext/session/mod_files.h
index 2522f6f..bc5bb4c 100644
--- a/ext/session/mod_files.h
+++ b/ext/session/mod_files.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mod_files.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: mod_files.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef MOD_FILES_H
 #define MOD_FILES_H
diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c
index 37623da..a938c48 100644
--- a/ext/session/mod_mm.c
+++ b/ext/session/mod_mm.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mod_mm.c 280729 2009-05-18 16:10:09Z jani $ */
+/* $Id: mod_mm.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/ext/session/mod_mm.h b/ext/session/mod_mm.h
index 983424f..a5c2c99 100644
--- a/ext/session/mod_mm.h
+++ b/ext/session/mod_mm.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mod_mm.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: mod_mm.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef MOD_MM_H
 #define MOD_MM_H
diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c
index f1e922f..01f7f8e 100644
--- a/ext/session/mod_user.c
+++ b/ext/session/mod_user.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mod_user.c 280729 2009-05-18 16:10:09Z jani $ */
+/* $Id: mod_user.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_session.h"
diff --git a/ext/session/mod_user.h b/ext/session/mod_user.h
index 3ee546e..2b00250 100644
--- a/ext/session/mod_user.h
+++ b/ext/session/mod_user.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mod_user.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: mod_user.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef MOD_USER_H
 #define MOD_USER_H
diff --git a/ext/session/php_session.h b/ext/session/php_session.h
index 4dcab6c..b321f44 100644
--- a/ext/session/php_session.h
+++ b/ext/session/php_session.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_session.h 280729 2009-05-18 16:10:09Z jani $ */
+/* $Id: php_session.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SESSION_H
 #define PHP_SESSION_H
diff --git a/ext/session/session.c b/ext/session/session.c
index 05a66f2..0d8ddd0 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: session.c 286443 2009-07-28 08:54:23Z tony2001 $ */
+/* $Id: session.c 294515 2010-02-04 09:40:38Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -61,12 +61,6 @@ PHPAPI ZEND_DECLARE_MODULE_GLOBALS(ps);
    * Helpers *
    *********** */
 
-#ifdef NETWARE
-# define SESS_SB_MTIME(sb)	((sb).st_mtime.tv_sec)
-#else
-# define SESS_SB_MTIME(sb)	((sb).st_mtime)
-#endif
-
 #define IF_SESSION_VARS() \
 	if (PS(http_session_vars) && PS(http_session_vars)->type == IS_ARRAY)
 
@@ -693,17 +687,22 @@ static PHP_INI_MH(OnUpdateSaveDir) /* {{{ */
 			return FAILURE;
 		}
 
-		if ((p = zend_memrchr(new_value, ';', new_value_length))) {
+		/* we do not use zend_memrchr() since path can contain ; itself */
+		if ((p = strchr(new_value, ';'))) {
+			char *p2;
 			p++;
+			if ((p2 = strchr(p, ';'))) {
+				p = p2 + 1;
+			}
 		} else {
 			p = new_value;
 		}
 
-		if (PG(safe_mode) && (!php_checkuid(p, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
+		if (PG(safe_mode) && *p && (!php_checkuid(p, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 			return FAILURE;
 		}
 
-		if (PG(open_basedir) && php_check_open_basedir(p TSRMLS_CC)) {
+		if (PG(open_basedir) && *p && php_check_open_basedir(p TSRMLS_CC)) {
 			return FAILURE;
 		}
 	}
@@ -1095,7 +1094,7 @@ static inline void last_modified(TSRMLS_D) /* {{{ */
 
 #define LAST_MODIFIED "Last-Modified: "
 		memcpy(buf, LAST_MODIFIED, sizeof(LAST_MODIFIED) - 1);
-		strcpy_gmt(buf + sizeof(LAST_MODIFIED) - 1, &SESS_SB_MTIME(sb));
+		strcpy_gmt(buf + sizeof(LAST_MODIFIED) - 1, &sb.st_mtime);
 		ADD_HEADER(buf);
 	}
 }
@@ -1888,7 +1887,10 @@ static PHP_FUNCTION(session_unset)
 	}
 
 	IF_SESSION_VARS() {
-		HashTable *ht = Z_ARRVAL_P(PS(http_session_vars));
+		HashTable *ht;
+
+		SEPARATE_ZVAL_IF_NOT_REF(&PS(http_session_vars));
+		ht = Z_ARRVAL_P(PS(http_session_vars));
 
 		if (PG(register_globals)) {
 			uint str_len;
@@ -1966,7 +1968,10 @@ static PHP_FUNCTION(session_unregister)
 		return;
 	}
 
-	PS_DEL_VARL(p_name, p_name_len);
+	IF_SESSION_VARS() {
+		SEPARATE_ZVAL_IF_NOT_REF(&PS(http_session_vars));
+		PS_DEL_VARL(p_name, p_name_len);
+	}
 
 	RETURN_TRUE;
 }
diff --git a/ext/session/tests/001.phpt b/ext/session/tests/001.phpt
index 1007f40..19dff78 100644
--- a/ext/session/tests/001.phpt
+++ b/ext/session/tests/001.phpt
@@ -31,7 +31,7 @@ print session_encode()."\n";
 
 session_destroy();
 --EXPECTF--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 253b740..8a4e002 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--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 7a61167..2ff675e 100644
--- a/ext/session/tests/004.phpt
+++ b/ext/session/tests/004.phpt
@@ -73,7 +73,7 @@ var_dump($arr);
 session_destroy();
 ?>
 --EXPECT--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 4b73865..124f0a8 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--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 08327ea..7c7af61 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--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 64b5bc9..9531b3d 100644
--- a/ext/session/tests/007.phpt
+++ b/ext/session/tests/007.phpt
@@ -50,8 +50,9 @@ var_dump($HTTP_SESSION_VARS);
 session_destroy();
 ?>
 --EXPECTF--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
-PHP Warning:  Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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: 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 fffc1d3..4fe938f 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--
-PHP Warning:  Directive 'register_long_arrays' 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
 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 206d8cd..705a275 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--
-PHP Warning:  Directive 'register_long_arrays' 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
 array(0) {
 }
 array(1) {
diff --git a/ext/session/tests/012.phpt b/ext/session/tests/012.phpt
index c6b94de..32aeb29 100644
--- a/ext/session/tests/012.phpt
+++ b/ext/session/tests/012.phpt
@@ -32,7 +32,7 @@ session_destroy();
 print "I live\n";
 ?>
 --EXPECTF--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 818699e..ad6c14e 100644
--- a/ext/session/tests/013.phpt
+++ b/ext/session/tests/013.phpt
@@ -24,5 +24,5 @@ session_destroy();
 print "I live\n";
 ?>
 --EXPECT--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 eaeaab3..4e77a7a 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--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 f4d7630..5bdd03b 100644
--- a/ext/session/tests/019.phpt
+++ b/ext/session/tests/019.phpt
@@ -47,7 +47,7 @@ var_dump($_SESSION);
 session_destroy();
 ?>
 --EXPECTF--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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/shmop/php_shmop.h b/ext/shmop/php_shmop.h
index 79d6f81..3cf94ce 100644
--- a/ext/shmop/php_shmop.h
+++ b/ext/shmop/php_shmop.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/shmop/shmop.c b/ext/shmop/shmop.c
index aed85d6..58a0fcf 100644
--- a/ext/shmop/shmop.c
+++ b/ext/shmop/shmop.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP version 4                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    |          Ilia Alshanetsky <ilia at prohost.org>                         |
    +----------------------------------------------------------------------+
  */
-/* $Id: shmop.c 281742 2009-06-06 02:40:49Z mattwil $ */
+/* $Id: shmop.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/simplexml/php_simplexml.h b/ext/simplexml/php_simplexml.h
index 37b5835..822cc51 100644
--- a/ext/simplexml/php_simplexml.h
+++ b/ext/simplexml/php_simplexml.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_simplexml.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_simplexml.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SIMPLEXML_H
 #define PHP_SIMPLEXML_H
diff --git a/ext/simplexml/php_simplexml_exports.h b/ext/simplexml/php_simplexml_exports.h
index 23e70e9..73c1651 100755
--- a/ext/simplexml/php_simplexml_exports.h
+++ b/ext/simplexml/php_simplexml_exports.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_simplexml_exports.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_simplexml_exports.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SIMPLEXML_EXPORTS_H
 #define PHP_SIMPLEXML_EXPORTS_H
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 21fb5d8..1f3966f 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c 281953 2009-06-11 09:41:15Z bjori $ */
+/* $Id: simplexml.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -2531,7 +2531,8 @@ PHP_MINIT_FUNCTION(simplexml)
 	sxe_object_handlers.get_constructor = zend_get_std_object_handlers()->get_constructor;
 	sxe_object_handlers.get_class_entry = zend_get_std_object_handlers()->get_class_entry;
 	sxe_object_handlers.get_class_name = zend_get_std_object_handlers()->get_class_name;
-
+	sxe_class_entry->serialize = zend_class_serialize_deny;
+	sxe_class_entry->unserialize = zend_class_unserialize_deny;
 
 	php_libxml_register_export(sxe_class_entry, simplexml_export_node);
 
@@ -2556,7 +2557,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: 281953 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 293036 $");
 	php_info_print_table_row(2, "Schema support",
 #ifdef LIBXML_SCHEMAS_ENABLED
 		"enabled");
diff --git a/ext/simplexml/sxe.c b/ext/simplexml/sxe.c
index 406f89f..30ea2da 100755
--- a/ext/simplexml/sxe.c
+++ b/ext/simplexml/sxe.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sxe.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sxe.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
diff --git a/ext/simplexml/sxe.h b/ext/simplexml/sxe.h
index d0bf59f..90489b2 100755
--- a/ext/simplexml/sxe.h
+++ b/ext/simplexml/sxe.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sxe.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sxe.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SXE_H
 #define SXE_H
diff --git a/ext/snmp/config.w32 b/ext/snmp/config.w32
index 49d0d00..6ee042f 100644
--- a/ext/snmp/config.w32
+++ b/ext/snmp/config.w32
@@ -1,16 +1,21 @@
-// $Id: config.w32 242949 2007-09-26 15:44:16Z cvs2svn $
+// $Id: config.w32 294815 2010-02-09 16:42:40Z pajoye $
 // vim:ft=javascript
 
 ARG_WITH("snmp", "SNMP support", "no");
 
 if (PHP_SNMP != "no") {
-
-	if (CHECK_HEADER_ADD_INCLUDE("snmp.h", "CFLAGS_SNMP", PHP_PHP_BUILD + "\\include\\ucd-snmp;" + PHP_PHP_BUILD + "\\include\\net-snmp;" + PHP_SNMP) &&
-			CHECK_LIB("libsnmp.lib", "snmp", PHP_SNMP)) {
-		EXTENSION('snmp', 'snmp.c');
-
-		AC_DEFINE('HAVE_SNMP', 1);
-
+	if (CHECK_HEADER_ADD_INCLUDE("snmp.h", "CFLAGS_SNMP", PHP_PHP_BUILD + "\\include\\net-snmp;" + PHP_SNMP)) {
+		if (CHECK_LIB("netsnmp.lib", "snmp", PHP_SNMP)) {
+			EXTENSION('snmp', 'snmp.c');
+			CHECK_LIB("libeay32.lib", "snmp", PHP_SNMP)
+			AC_DEFINE('HAVE_SNMP', 1);
+			AC_DEFINE("HAVE_NET_SNMP", 1);
+		} else if (CHECK_LIB("libsnmp.lib", "snmp", PHP_SNMP)) {
+			EXTENSION('snmp', 'snmp.c');
+			AC_DEFINE('HAVE_SNMP', 1);
+		} else {
+			WARNING("snmp not enabled; libraries and headers not found");
+		}
 	} else {
 		WARNING("snmp not enabled; libraries and headers not found");
 	}
diff --git a/ext/snmp/php_snmp.h b/ext/snmp/php_snmp.h
index f1239a7..c7b5512 100644
--- a/ext/snmp/php_snmp.h
+++ b/ext/snmp/php_snmp.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -20,7 +20,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_snmp.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_snmp.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SNMP_H
 #define PHP_SNMP_H
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index 7819fed..b3d5405 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: snmp.c 287430 2009-08-17 22:15:18Z stas $ */
+/* $Id: snmp.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -981,7 +981,6 @@ static int netsnmp_session_set_sec_level(struct snmp_session *s, char *level TSR
 			s->securityLevel = SNMP_SEC_LEVEL_AUTHPRIV;
 			return (0);
 		}
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid security level: %s", level);
 	}
 	return (-1);
 }
@@ -1000,8 +999,6 @@ static int netsnmp_session_set_auth_protocol(struct snmp_session *s, char *prot
 			s->securityAuthProto = usmHMACSHA1AuthProtocol;
 			s->securityAuthProtoLen = OIDSIZE(usmHMACSHA1AuthProtocol);
 			return (0);
-		} else if (strlen(prot)) {
-			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid authentication protocol: %s", prot);
 		}
 	}
 	return (-1);
@@ -1053,8 +1050,6 @@ static int netsnmp_session_set_sec_protocol(struct snmp_session *s, char *prot T
 			return (0);
 #endif
 #endif
-		} else if (strlen(prot)) {
-			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid privacy protocol: %s", prot);
 		}
 	}
 	return (-1);
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 9bf3356..6cc6113 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_encoding.c 282177 2009-06-15 17:31:02Z felipe $ */
+/* $Id: php_encoding.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #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' propery");
+			soap_error0(E_ERROR, "Encoding: SoapVar hasn't 'enc_type' property");
 		}
 
 		if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) {
diff --git a/ext/soap/php_encoding.h b/ext/soap/php_encoding.h
index e144901..17989c5 100644
--- a/ext/soap/php_encoding.h
+++ b/ext/soap/php_encoding.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_encoding.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_encoding.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_ENCODING_H
 #define PHP_ENCODING_H
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index f1efbed..f13e89a 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_http.c 281589 2009-06-03 12:39:50Z iliaa $ */
+/* $Id: php_http.c 294456 2010-02-03 20:29:09Z pajoye $ */
 
 #include "php_soap.h"
 #include "ext/standard/base64.h"
@@ -207,6 +207,7 @@ int make_http_soap_request(zval  *this_ptr,
 	int http_1_1;
 	int http_status;
 	int content_type_xml = 0;
+	long redirect_max = 20;
 	char *content_encoding;
 	char *http_msg = NULL;
 	zend_bool old_allow_url_fopen;
@@ -283,6 +284,14 @@ int make_http_soap_request(zval  *this_ptr,
 		context = php_stream_context_from_zval(*tmp, 0);
 	}
 
+	if (context && 
+		php_stream_context_get_option(context, "http", "max_redirects", &tmp) == SUCCESS) {
+		if (Z_TYPE_PP(tmp) != IS_STRING || !is_numeric_string(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &redirect_max, NULL, 1)) {
+			if (Z_TYPE_PP(tmp) == IS_LONG)
+				redirect_max = Z_LVAL_PP(tmp);
+		}
+	}
+
 try_again:
 	if (phpurl == NULL || phpurl->host == NULL) {
 	  if (phpurl != NULL) {php_url_free(phpurl);}
@@ -752,16 +761,15 @@ try_again:
 		err = php_stream_write(stream, soap_headers.c, soap_headers.len);
 		if (err != soap_headers.len) {
 			if (request != buf) {efree(request);}
-			smart_str_free(&soap_headers);
 			php_stream_close(stream);
 			zend_hash_del(Z_OBJPROP_P(this_ptr), "httpurl", sizeof("httpurl"));
 			zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
 			zend_hash_del(Z_OBJPROP_P(this_ptr), "_use_proxy", sizeof("_use_proxy"));
 			add_soap_fault(this_ptr, "HTTP", "Failed Sending HTTP SOAP request", NULL, NULL TSRMLS_CC);
+			smart_str_free(&soap_headers_z);
 			return FALSE;
 		}
 		smart_str_free(&soap_headers);
-
 	} else {
 		add_soap_fault(this_ptr, "HTTP", "Failed to create stream??", NULL, NULL TSRMLS_CC);
 		smart_str_free(&soap_headers_z);
@@ -990,12 +998,20 @@ try_again:
 					new_url->host = phpurl->host ? estrdup(phpurl->host) : NULL;
 					new_url->port = phpurl->port;
 					if (new_url->path && new_url->path[0] != '/') {
-						char *t = phpurl->path;
-						char *p = strrchr(t, '/');
-						if (p) {
-							char *s = emalloc((p - t) + strlen(new_url->path) + 2);
-							strncpy(s, t, (p - t) + 1);
-							s[(p - t) + 1] = 0;
+						if (phpurl->path) {
+							char *t = phpurl->path;
+							char *p = strrchr(t, '/');
+							if (p) {
+								char *s = emalloc((p - t) + strlen(new_url->path) + 2);
+								strncpy(s, t, (p - t) + 1);
+								s[(p - t) + 1] = 0;
+								strcat(s, new_url->path);
+								efree(new_url->path);
+								new_url->path = s;
+							} 
+						} else {
+							char *s = emalloc(strlen(new_url->path) + 2);
+							s[0] = '/'; s[1] = 0;
 							strcat(s, new_url->path);
 							efree(new_url->path);
 							new_url->path = s;
@@ -1004,6 +1020,12 @@ try_again:
 				}
 				phpurl = new_url;
 
+				if (--redirect_max < 1) {
+					add_soap_fault(this_ptr, "HTTP", "Redirection limit reached, aborting", NULL, NULL TSRMLS_CC);
+					smart_str_free(&soap_headers_z);
+					return FALSE;
+				}
+
 				goto try_again;
 			}
 		}
diff --git a/ext/soap/php_http.h b/ext/soap/php_http.h
index e3470a1..2177e18 100644
--- a/ext/soap/php_http.h
+++ b/ext/soap/php_http.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_http.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_http.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HTTP_H
 #define PHP_HTTP_H
diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c
index f93e768..0b02fbd 100644
--- a/ext/soap/php_packet_soap.c
+++ b/ext/soap/php_packet_soap.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_packet_soap.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_packet_soap.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_soap.h"
 
diff --git a/ext/soap/php_packet_soap.h b/ext/soap/php_packet_soap.h
index d9c00ed..2ba3eb1 100644
--- a/ext/soap/php_packet_soap.h
+++ b/ext/soap/php_packet_soap.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_packet_soap.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_packet_soap.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_PACKET_SOAP_H
 #define PHP_PACKET_SOAP_H
diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c
index c51bea4..0396d91 100644
--- a/ext/soap/php_schema.c
+++ b/ext/soap/php_schema.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_schema.c 287425 2009-08-17 18:23:48Z dmitry $ */
+/* $Id: php_schema.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_soap.h"
 #include "libxml/uri.h"
diff --git a/ext/soap/php_schema.h b/ext/soap/php_schema.h
index d7cc00a..9022e3f 100644
--- a/ext/soap/php_schema.h
+++ b/ext/soap/php_schema.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_schema.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_schema.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SCHEMA_H
 #define PHP_SCHEMA_H
diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c
index 62161f9..462c589 100644
--- a/ext/soap/php_sdl.c
+++ b/ext/soap/php_sdl.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_sdl.c 287425 2009-08-17 18:23:48Z dmitry $ */
+/* $Id: php_sdl.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_soap.h"
 #include "ext/libxml/php_libxml.h"
diff --git a/ext/soap/php_sdl.h b/ext/soap/php_sdl.h
index 97612bf..5edbbdf 100644
--- a/ext/soap/php_sdl.h
+++ b/ext/soap/php_sdl.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_sdl.h 287425 2009-08-17 18:23:48Z dmitry $ */
+/* $Id: php_sdl.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SDL_H
 #define PHP_SDL_H
diff --git a/ext/soap/php_soap.h b/ext/soap/php_soap.h
index 11ff510..36b154e 100644
--- a/ext/soap/php_soap.h
+++ b/ext/soap/php_soap.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_soap.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_soap.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SOAP_H
 #define PHP_SOAP_H
diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c
index 92fa6cf..5929ee2 100644
--- a/ext/soap/php_xml.c
+++ b/ext/soap/php_xml.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_xml.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_xml.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_soap.h"
 #include "libxml/parser.h"
@@ -138,6 +138,9 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
 		ctxt->sax->warning = NULL;
 		ctxt->sax->error = NULL;
 		/*ctxt->sax->fatalError = NULL;*/
+#if LIBXML_VERSION >= 20703
+		ctxt->options |= XML_PARSE_HUGE;
+#endif
 		xmlParseDocument(ctxt);
 		if (ctxt->wellFormed) {
 			ret = ctxt->myDoc;
diff --git a/ext/soap/php_xml.h b/ext/soap/php_xml.h
index 7d22ce7..cbef45e 100644
--- a/ext/soap/php_xml.h
+++ b/ext/soap/php_xml.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_xml.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_xml.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SOAP_XML_H
 #define PHP_SOAP_XML_H
diff --git a/ext/soap/readme.html b/ext/soap/readme.html
deleted file mode 100644
index 98efff3..0000000
--- a/ext/soap/readme.html
+++ /dev/null
@@ -1,646 +0,0 @@
-<HTML>
-<HEAD>
-<TITLE>PHP SOAP Manual</TITLE>
-<STYLE>
-TR{
-	vertical-align: "top";
-}
-TH{
-	text-align: "left";
-}
-TD:{
-	text-align: "left";
-}
-</STYLE>
-</HEAD>
-<BODY>
-<A name="ref.soap">
-<H1>PHP SOAP</H1>
-<H2>Introduction</H2>
-<TABLE BORDER="1">
-<TR><TD ALIGN="center"><B>Warning</B></TD></TR>
-<TR><TD ALIGN="left">This extension is <I>EXPERIMENTAL</I>. The behaviour of this extension -- including the names of its functions and anything else documented about this extension -- may change without notice in a future release of PHP. Use this extension at your own risk.
-</TD></TR>
-</TABLE>
-<p>
-SOAP extension can be used to write SOAP Servers and Clients. It supports 
-subsets of <a href="http://www.w3.org/TR/2000/NOTE-SOAP-20000508" target="_top">SOAP 1.1</a>,
-<a href="http://www.w3.org/TR/" target="_top">SOAP 1.2</a> and
-<a href="http://www.w3.org/TR/wsdl" target="_top">WSDL 1.1</a> specifications.
-</p>
-<HR>
-<H2>Requirements</H2>
-This extension makes use of the <A HREF="http://www.xmlsoft.org" TARGET="_top">GNOME XML library</A>. Download and install this library. You will need at least libxml-2.5.4.
-<HR>
-<H2>Installation</H2>
-This extension is only available if PHP was configured with --enable-soap.
-<HR>
-<H2>Runtime Configuration</H2>
-<p>The behaviour of these functions is affected by settings in php.ini.</p>
-<TABLE BORDER="1">
-<TR><TH>Name</TH><TH>Default</TH><TH>Changeable</TH></TR>
-<TR><TD>soap.wsdl_cache_enabled</TD><TD>"1"</TD><TD>PHP_INI_ALL</TD></TR>
-<TR><TD>soap.wsdl_cache_dir</TD><TD>"/tmp"</TD><TD>PHP_INI_ALL</TD></TR>
-<TR><TD>soap.wsdl_cache_ttl</TD><TD>86400</TD><TD>PHP_INI_ALL</TD></TR>
-</TABLE>
-</p>Here is a short explanation of the configuration directives.</p>
-<dl>
-<dt><b>soap.wsdl_cache_enabled</b> (boolean)</dt>
-<dd>enables or disables WSDL caching feature.</dd>
-<dt><b>soap.wsdl_cache_dir</b> (string)</dt>
-<dd>sets the directory name where SOAP extension will put cache files</dd>
-<dt><b>soap.wsdl_cache_ttl</b> (integer)</dt>
-<dd>(time to live) sets the number of second while cached file will be used instead of original one.</dd>
-</dl>
-
-
-<HR>
-<H2>Predefined Constants</H2>
-The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
-<TABLE BORDER="1">
-<TR><TH>Constant</TH><TH>Value</TH><TH>Description</TH></TR>
-<TR><TH>SOAP_1_1 (integer)</TH><TD>1</TD><TD>SOAP version - SOAP 1.1. Can be used as an option in SoapClient and SoapServer constructors.</TD></TR>
-<TR><TH>SOAP_1_2 (integer)</TH><TD>2</TD><TD>SOAP version - SOAP 1.2. Can be used as an option in SoapClient and SoapServer constructors.</TD></TR>
-<TR><TH>SOAP_FUNCTIONS_ALL (integer)</TH><TD>999</TD><TD>Allows to export all defined functions with SoapClient::addFunction</TD></TR>
-<TR><TH>SOAP_PERSISTENCE_SESSION (integer)</TH><TD>1</TD><TD>Allows making class passed to SoapServer::setClass persistent for a PHP session.</TD></TR>
-<TR><TH>SOAP_PERSISTENCE_REQUEST (integer)</TH><TD>2</TD><TD>Allows making class passed to SoapServer::setClass non-persistent for a PHP session.</TD></TR>
-<TR><TH>SOAP_ENCODED (integer)</TH><TD>1</TD><TD>Can be passed as <b>style</b> option to SoapClient constructor in nonWSDL mode.</TD></TR>
-<TR><TH>SOAP_LITERAL (integer)</TH><TD>2</TD><TD>Can be passed as <b>style</b> option to SoapClient constructor in nonWSDL mode.</TD></TR>
-<TR><TH>SOAP_RPC (integer)</TH><TD>1</TD><TD>Can be passed as <b>use</b> option to SoapClient constructor in nonWSDL mode.</TD></TR>
-<TR><TH>SOAP_DOCUMENT (integer)</TH><TD>2</TD><TD>Can be passed as <b>use</b> option to SoapClient constructor in nonWSDL mode.</TD></TR>
-<TR><TH>SOAP_ACTOR_NEXT (integer)</TH><TD>1</TD><TD>Can be passed as <b>actor</b> to SoapHeader constructor.</TD></TR>
-<TR><TH>SOAP_ACTOR_NONE (integer)</TH><TD>2</TD><TD>Can be passed as <b>actor</b> to SoapHeader constructor</TD></TR>
-<TR><TH>SOAP_ACTOR_UNLIMATERECEIVER (integer)</TH><TD>3</TD><TD>Can be passed as <b>actor</b> to SoapHeader constructor</TD></TR>
-<TR><TH>UNKNOWN_TYPE (integer)</TH><TD>999998</TD><TD>Encoding for unknown type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_STRING (integer)</TH><TD>101</TD><TD>Encoding for standard XMLSchema <b>string</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_BOOLEAN (integer)</TH><TD>102</TD><TD>Encoding for standard XMLSchema <b>boolen</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_DECIMAL (integer)</TH><TD>103</TD><TD>Encoding for standard XMLSchema <b>decimal</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_FLOAT (integer)</TH><TD>104</TD><TD>Encoding for standard XMLSchema <b>float</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_DOUBLE (integer)</TH><TD>105</TD><TD>Encoding for standard XMLSchema <b>double</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_DURATION (integer)</TH><TD>106</TD><TD>Encoding for standard XMLSchema <b>duration</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_DATETIME (integer)</TH><TD>107</TD><TD>Encoding for standard XMLSchema <b>dateTime</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_TIME (integer)</TH><TD>108</TD><TD>Encoding for standard XMLSchema <b>time</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_DATE (integer)</TH><TD>109</TD><TD>Encoding for standard XMLSchema <b>data</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_GYEARMONTH (integer)</TH><TD>110</TD><TD>Encoding for standard XMLSchema <b>gYearMonth</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_GYEAR (integer)</TH><TD>111</TD><TD>Encoding for standard XMLSchema <b>gYear</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_GMONTHDAY (integer)</TH><TD>112</TD><TD>Encoding for standard XMLSchema <b>gMonthDay</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_GDAY (integer)</TH><TD>113</TD><TD>Encoding for standard XMLSchema <b>gDay</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_GMONTH (integer)</TH><TD>114</TD><TD>Encoding for standard XMLSchema <b>gMonth</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_HEXBINARY (integer)</TH><TD>115</TD><TD>Encoding for standard XMLSchema <b>hexBinary</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_BASE64BINARY (integer)</TH><TD>116</TD><TD>Encoding for standard XMLSchema <b>base64Binary</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_ANYURI (integer)</TH><TD>117</TD><TD>Encoding for standard XMLSchema <b>anyURI</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_QNAME (integer)</TH><TD>118</TD><TD>Encoding for standard XMLSchema <b>QName</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_NOTATION (integer)</TH><TD>119</TD><TD>Encoding for standard XMLSchema <b>NOTATION</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_NORMALIZEDSTRING (integer)</TH><TD>120</TD><TD>Encoding for standard XMLSchema <b>normalizedString</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_TOKEN (integer)</TH><TD>121</TD><TD>Encoding for standard XMLSchema <b>token</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_LANGUAGE (integer)</TH><TD>122</TD><TD>Encoding for standard XMLSchema <b>language</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_NMTOKEN (integer)</TH><TD>123</TD><TD>Encoding for standard XMLSchema <b>NMTOKEN</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_NAME (integer)</TH><TD>124</TD><TD>Encoding for standard XMLSchema <b>Name</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_NCNAME (integer)</TH><TD>125</TD><TD>Encoding for standard XMLSchema <b>NCName</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_ID (integer)</TH><TD>126</TD><TD>Encoding for standard XMLSchema <b>ID</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_IDREF (integer)</TH><TD>127</TD><TD>Encoding for standard XMLSchema <b>IDREF</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_IDREFS (integer)</TH><TD>128</TD><TD>Encoding for standard XMLSchema <b>IDREFS</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_ENTITY (integer)</TH><TD>129</TD><TD>Encoding for standard XMLSchema <b>ENTITY</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_ENTITIES (integer)</TH><TD>130</TD><TD>Encoding for standard XMLSchema <b>ENTITIES</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_INTEGER (integer)</TH><TD>131</TD><TD>Encoding for standard XMLSchema <b>integer</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_NONPOSITIVEINTEGER (integer)</TH><TD>132</TD><TD>Encoding for standard XMLSchema <b>nonPositiveInteger</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_NEGATIVEINTEGER (integer)</TH><TD>133</TD><TD>Encoding for standard XMLSchema <b>negativeInteger</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_LONG (integer)</TH><TD>134</TD><TD>Encoding for standard XMLSchema <b>long</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_INT (integer)</TH><TD>135</TD><TD>Encoding for standard XMLSchema <b>int</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_SHORT (integer)</TH><TD>136</TD><TD>Encoding for standard XMLSchema <b>short</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_BYTE (integer)</TH><TD>137</TD><TD>Encoding for standard XMLSchema <b>byte</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_NONNEGATIVEINTEGER (integer)</TH><TD>138</TD><TD>Encoding for standard XMLSchema <b>nonNegativeInteger</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_UNSIGNEDLONG (integer)</TH><TD>139</TD><TD>Encoding for standard XMLSchema <b>unsignedLong</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_UNSIGNEDINT (integer)</TH><TD>140</TD><TD>Encoding for standard XMLSchema <b>unsignedInt</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_UNSIGNEDSHORT (integer)</TH><TD>141</TD><TD>Encoding for standard XMLSchema <b>unsignedShort</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_UNSIGNEDBYTE (integer)</TH><TD>142</TD><TD>Encoding for standard XMLSchema <b>unsignedByte</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_POSITIVEINTEGER (integer)</TH><TD>143</TD><TD>Encoding for standard XMLSchema <b>positiveInteger</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_NMTOKENS (integer)</TH><TD>144</TD><TD>Encoding for standard XMLSchema <b>NMTOKENS</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_ANYTYPE (integer)</TH><TD>145</TD><TD>Encoding for standard XMLSchema <b>anyType</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>SOAP_ENC_ARRAY (integer)</TH><TD>300</TD><TD>Encoding for SOAP <b>Array</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>SOAP_ENC_OBJECT (integer)</TH><TD>301</TD><TD>Encoding for SOAP <b>Struct</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_1999_TIMEINSTANT (integer)</TH><TD>401</TD><TD>Encoding for old XMLSchema <b>timeInstant</b> type. Can be passed to SoapVar constructor.</TD></TR>
-<TR><TH>XSD_NAMESPACE (string)</TH><TD> </TD><TD>The XML Schema namespace.</TD></TR>
-<TR><TH>XSD_1999_NAMESPACE (string)</TH><TD> </TD><TD>The old XML Schema namespace.</TD></TR>
-</TABLE>
-<HR>
-<H2>Classes</H2>
-<h4>List of classes</h4>
-<table border="0">
-<tr><td><a href="#ref.soap.soapclient">SoapClient</a></td></tr>
-<tr><td><a href="#ref.soap.soapserver">SoapServer</a></td></tr>
-<tr><td><a href="#ref.soap.soapparam">SoapParam</a></td></tr>
-<tr><td><a href="#ref.soap.soapvar">SoapVar</a></td></tr>
-<tr><td><a href="#ref.soap.soapheader">SoapHeader</a></td></tr>
-<tr><td><a href="#ref.soap.soapfault">SoapFault</a></td></tr>
-</table>
-<a name="ref.soap.soapclient">
-<h4>SoapClient class</h4>
-A SOAP client, that allows calling remote methods on SOAP WebService over HTTP
-or HTTPS.
-<table border="0">
-<tr><td><a href="#ref.soap.soapclient.soapclient">SoapClient</a> -- SoapClient constructor</td></tr>
-<tr><td><a href="#ref.soap.soapclient.__call">__call</a> -- calls a SOAP function</td></tr>
-<tr><td><a href="#ref.soap.soapclient.__getlastrequest">__getLastRequest</a> -- returns last SOAP request</td></tr>
-<tr><td><a href="#ref.soap.soapclient.__getlastresponse">__getLastResponse</a> -- returns last SOAP response</td></tr>
-<tr><td><a href="#ref.soap.soapclient.__getfunctions">__getFunctions</a> -- returns list of SOAP functions</td></tr>
-<tr><td><a href="#ref.soap.soapclient.__gettypes">__getTypes</a> -- returns list of SOAP types</td></tr>
-</table>
-<a name="ref.soap.soapserver">
-<h4>SoapServer class</h4>
-This class can be used to build SOAP WebServices, which can be accessed from
-remote SOAP clients over HTTP or HTTPS.
-<table border="0">
-<tr><td><a href="#ref.soap.soapserver.soapserver">SoapServer</a> -- SoapServer constructor</td></tr>
-<tr><td><a href="#ref.soap.soapserver.addfunction">addFunction</a> -- adds one or several functions those will handle SOAP requests</td></tr>
-<tr><td><a href="#ref.soap.soapserver.setclass">setClass</a> -- sets class which will handle SOAP requests</td></tr>
-<tr><td><a href="#ref.soap.soapserver.getfunctions">getFunctions</a> -- returns list of defined functions</td></tr>
-<tr><td><a href="#ref.soap.soapserver.setpersistence">setPersistence</a> -- sets persistence mode of SoapServer</td></tr>
-<tr><td><a href="#ref.soap.soapserver.handle">handle</a> -- handles a SOAP request</td></tr>
-</table>
-<a name="ref.soap.soapparam">
-<h4>SoapParam class</h4>
-<p>
-SoapParam is a special low-level class for naming parameters and return values
-in nonWSDL mode. It is just a data holder and it has not any special method
-except constructor.
-</p>
-<table border="0">
-<tr><td><a href="#ref.soap.soapparam.soapparam">SoapParam</a> -- SoapParam constructor</td></tr>
-</table>
-<a name="ref.soap.soapvar">
-<h4>SoapVar classes</h4>
-<p>
-SoapVar is a special low-level class for encoding parameters and return values
-in  nonWSDL mode. It is just a data holder and it has not any special method
-except constructor. It is useful when you like to set type property in SOAP
-request or response.
-</p>
-<table border="0">
-<tr><td><a href="#ref.soap.soapvar.soapvar">SoapVar</a> -- SoapVar constructor</td></tr>
-</table>
-<a name="ref.soap.soapheader">
-<h4>SoapHeader class</h4>
-<p>
-SoapHeader is a special low-level class for passing or returning SOAP headers.
-It is just a data holder and it has not any special method except constructor.
-</p>
-<table border="0">
-<tr><td><a href="#ref.soap.soapheader.soapheader">SoapHeader</a> -- SoapHeader constructor</td></tr>
-</table>
-<a name="ref.soap.soapfault">
-<h4>SoapFault class</h4>
-<p>
-SoapFault is a special class that can be used for error reporting during
-handling of SOAP request. It is derived form standard PHP Exception class, 
-so it can be used to throw exceptions in server side and to catch tham on 
-client side.
-</p>
-<table border="0">
-<tr><td><a href="#ref.soap.soapfault.soapfault">SoapFault</a> -- SoapFault constructor</td></tr>
-</table>
-<HR>
-<!--
-<H2>Examples</H2>
--->
-<h4>Table of Contents</h4>
-<table border="0">
-<tr><td><a href="#ref.soap.is_soap_fault">is_soap_fault</a> -- checks if SOAP call was failed</td></tr>
-<tr><td><a href="#ref.soap.soapclient.soapclient">SoapClient::SoapClient</a> -- SoapClient constructor</td></tr>
-<tr><td><a href="#ref.soap.soapclient.__call">SoapClient::__call</a> -- calls a SOAP function</td></tr>
-<tr><td><a href="#ref.soap.soapclient.__getlastrequest">SoapClient::__getLastRequest</a> -- returns last SOAP request</td></tr>
-<tr><td><a href="#ref.soap.soapclient.__getlastresponse">SoapClient::__getLastResponse</a> -- returns last SOAP response</td></tr>
-<tr><td><a href="#ref.soap.soapclient.__getfunctions">SoapClient::__getFunctions</a> -- returns list of SOAP functions</td></tr>
-<tr><td><a href="#ref.soap.soapclient.__gettypes">SoapClient::__getTypes</a> -- returns list of SOAP types</td></tr>
-<tr><td><a href="#ref.soap.soapserver.soapserver">SoapServer::SoapServer</a> -- SoapServer constructor</td></tr>
-<tr><td><a href="#ref.soap.soapserver.addfunction">SoapServer::addFunction</a> -- adds one or several functions those will handle SOAP requests</td></tr>
-<tr><td><a href="#ref.soap.soapserver.setclass">SoapServer::setClass</a> -- sets class which will handle SOAP requests</td></tr>
-<tr><td><a href="#ref.soap.soapserver.getfunctions">SoapServer::getFunctions</a> -- returns list of defined functions</td></tr>
-<tr><td><a href="#ref.soap.soapserver.setpersistence">SoapServer::setPersistence</a> -- sets persistence mode of SoapServer</td></tr>
-<tr><td><a href="#ref.soap.soapserver.handle">SoapServer::handle</a> -- handles a SOAP request</td></tr>
-<tr><td><a href="#ref.soap.soapparam.soapparam">SoapParam::SoapParam</a> -- SoapParam constructor</td></tr>
-<tr><td><a href="#ref.soap.soapvar.soapvar">SoapVar::SoapVar</a> -- SoapVar constructor</td></tr>
-<tr><td><a href="#ref.soap.soapheader.soapheader">SoapHeader::SoapHeader</a> -- SoapHeader constructor</td></tr>
-<tr><td><a href="#ref.soap.soapfault.soapfault">SoapFault::SoapFault</a> -- SoapFault constructor</td></tr>
-</table>
-
-<a name="ref.soap.is_soap_fault"></a>
-<h2>is_soap_fault</h2>
-<p>(PHP 5)</p>
-<p>checks if SOAP call was failed</p>
-<h3>Description</h3>
-<p>bool <b>is_soap_fault</b>(mixed obj)</p>
-<p>
-This function is useful when you like to check if the SOAP call was failed,
-but don't like to use exceptions. To use it you must create SoapClient object
-with <b>exceptions</b> option set to zero or false. In this case SOAP method 
-will return a special SoapFault object which encapsulate the fault details 
-(faultcode, faultstring, faultactor and faultdetails). If <b>exceptions</b> is 
-not set then SOAP call will throw an exception on error.<br>
-is_soap_fault() functions checks if the given parameter is a SoapFault object.<br>
-</p>
-<h4>Example</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    $client = SoapClient("some.wsdl",array("exceptions"=>0));
-    $result = $client->SomeFunction(...);
-    if (is_soap_fault($result)) {
-        trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faulstring})", E_ERROR);
-    }
-?></PRE></TD></TR></TABLE>
-<p>Standard method that used by SOAP extension for error reporting is excptions.</p>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    try {
-        $client = SoapClient("some.wsdl");
-        $result = $client->SomeFunction(...);
-    } catch (SoapFault $fault) {
-        trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faulstring})", E_ERROR);
-    }
-?></PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapclient.soapclient"></a>
-<h2>SoapClient::SoapClient</h2>
-<p>(PHP 5)</p>
-<p>SoapClient constructor</p>
-<h3>Description</h3>
-<p><b>SoapClient</b>(mixed wsdl [, array options])</p>
-<p>
-The constructor allows creating SoapClient objects in WSDL or nonWSDL mode.
-The first case requires URI of WSDL file as first parameter and optional
-options array. The second case requires NULL as first parameter and options
-array with <b>location</b> and <b>uri</b> options set. Where <b>location</b> is
-a URL to request and <b>uri</b> is a target namespace of the SOAP service.
-<b>style</b> and <b>use</b> options has effect only on nonWSDL (in WSDL mode
-they comes from WSDL file). <b>soap_version</b> option allows to work as SOAP 1.1 or
-SOAP 1.2 client.
-Some additional optional options allow using HTTP authentication (<b>login</b>
-and <b>password</b>) and HTTP connection through proxy server (<b>proxy_host</b>,
-<b>proxy_port</b>, <b>proxy_login</b> and <b>proxy_password</b>).
-</p>
-<h4>Examples</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-    $client = new SoapClient("some.wsdl");
-
-    $client = new SoapClient("some.wsdl",array('soap_version'   => SOAP_1_2));
-
-    $client = new SoapClient("some.wsdl",array('login'          => "some_name",
-                                               'password'       => "some_password"));
-
-    $client = new SoapClient("some.wsdl",array('proxy_host'     => "localhost",
-                                               'proxy_port'     => 8080));
-
-    $client = new SoapClient("some.wsdl",array('proxy_host'     => "localhost",
-                                               'proxy_port'     => 8080,
-                                               'proxy_login'    => "some_name",
-                                               'proxy_password' => "some_password"));
-
-    $client = new SoapClient(null,array('location' => "http://localhost/soap.php",
-                                        'uri'      => "http://test-uri/"));
-
-    $client = new SoapClient(null,array('location' => "http://localhost/soap.php",
-                                        'uri'      => "http://test-uri/",
-                                        'style'    => SOAP_DOCUMENT,
-                                        'use'      => SOAP_LITERAL));
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapclient.__call"></a>
-<h2>SoapClient::__call</h2>
-<p>(PHP 5)</p>
-<p>calls a SOAP function</p>
-<h3>Description</h3>
-<p>mixed <b>__call</b>(string function_name, array arguments, [array options [, mixed input_headers [, mixed &output_headers]]])</p>
-<p>
-This is a low level API function to make a SOAP call. Usually in WSDL mode
-you can simple call SOAP functions as SoapClient methods. It is useful for
-nonWSDL mode when 'soapaction' is unknown, 'uri' is differ form default or
-when ypu like to send and/or receive SOAP Headers. To check if function call
-is failed check the result with is_soap_fault() function.<br>
-SOAP function may return one or several values. In the first case __call will
-return just the value of output parameter, in the second it will return
-array with named output parameters.
-</p>
-<h4>Examples</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-    $client = new SoapClient("some.wsdl");
-    $client->SomeFunction($a,$b,$c);
-    $client->__call("SomeFunction",array($a,$b,$c));
-    $client->__call("SomeFunction",array($a,$b,$c), NULL,
-                    new SoapHeader(...), $output_headers);
-
-
-    $client = new SoapClient(null,array('location' => "http://localhost/soap.php",
-                                        'uri'      => "http://test-uri/"));
-    $client->SomeFunction($a,$b,$c);
-    $client->__call("SomeFunction",array($a,$b,$c));
-    $client->__call("SomeFunction",array($a,$b,$c),
-                    array('soapaction' => 'some_action',
-                          'uri'        => 'some_uri'));
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapclient.__getlastrequest"></a>
-<h2>SoapClient::__getLastRequest</h2>
-<p>(PHP 5)</p>
-<p>returns last SOAP request</p>
-<h3>Description</h3>
-<p>string <b>__getLastRequest</b>()</p>
-<p>
-This function works only with SoapClient which was created with trace option.
-</p>
-<h4>Example</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    $client = SoapClient("some.wsdl", array('trace'=>1));
-    $result = $client->SomeFunction(...);
-    echo "REQUEST:\n".$client->__getLastRequest()."\n";
-?>
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapclient.__getlastresponse"></a>
-<h2>SoapClient::__getLastResponse</h2>
-<p>(PHP 5)</p>
-<p>returns last SOAP response</p>
-<h3>Description</h3>
-<p>string <b>__getLastResponse</b>()</p>
-<p>
-This function works only with SoapClient which was created with trace option.
-</p>
-<h4>Example</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    $client = SoapClient("some.wsdl", array('trace'=>1));
-    $result = $client->SomeFunction(...);
-    echo "RESPONSE:\n".$client->__getLastResponse()."\n";
-?>
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapclient.__getfunctions"></a>
-<h2>SoapClient::__getFunctions</h2>
-<p>(PHP 5)</p>
-<p>returns list of SOAP functions</p>
-<h3>Description</h3>
-<p>array <b>__getFunctions</b>()</p>
-<p>
-This function works only in WSDL mode.
-</p>
-<h4>Example</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    $client = SoapClient("some.wsdl");
-    var_dump($client->__getFunctions());
-?>
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapclient.__gettypes"></a>
-<h2>SoapClient::__getTypes</h2>
-<p>(PHP 5)</p>
-<p>returns list of SOAP types</p>
-<h3>Description</h3>
-<p>array <b>__getTypes</b>()</p>
-<p>
-This function works only in WSDL mode.
-</p>
-<h4>Example</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    $client = SoapClient("some.wsdl");
-    var_dump($client->__getTypes());
-?>
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapserver.soapserver"></a>
-<h2>SoapServer::SoapServer</h2>
-<p>(PHP 5)</p>
-<p>SoapServer constructor</p>
-<h3>Description</h3>
-<p><b>SoapServer</b>(mixed wsdl [, array options])</p>
-It allows creating SoapServer objects in WSDL or nonWSDL mode. In the first
-case  <b>wsdl</b> must be set to URI of WSDL file. In the second <b>wsdl</b>
-must be set to null and <b>uti</b> option must be set. Additional options
-allow setting a default SOAP version (<b>soap_version</b>) and actor URI
-(<b>actor</b>).
-
-<h4>Examples</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-    $server = new SoapServer("some.wsdl");
-
-    $server = new SoapServer("some.wsdl",array('soap_version'=>SOAP_1_2));
-
-    $server = new SoapServer("some.wsdl",array('actor'=>"http://example.org/ts-tests/C"));
-
-    $server = new SoapServer(null,array('uri'=>"http://test-uri/"));
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapserver.addfunction">
-<h2>SoapServer::addFunction</h2>
-<p>(PHP 5)</p>
-<p>adds one or several functions those will handle SOAP requests</p>
-<h3>Description</h3>
-<p>void <b>addFunction</b>(mixed functions)</p>
-Exports one or more functions for remote clients. To export one function pass
-function name into <b>functions</b> parameter as string. To export several
-functions pass an array of function names and to export all functions pass
-a special constant <b>SOAP_FUNCTIONS_ALL</b>.<br>
-Functions must receive all input arguments in the same order as defined
-in WSDL file (They should not receive any output parameters as arguments) and
-return one or more values. To return several values they must return array with
-named output parameters.
-<h4>Examples</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-    function func($inputString) {
-        return $inputString;
-    }
-    $server->addFunction("echoString");
-
-    function echoTwoStrings($inputString1, $inputString2) {
-        return array("outputString1"=>$inputString1,"outputString2"=>$inputString2);
-    }
-    $server->addFunction(array("echoString","echoTwoStrings"));
-
-    $server->addFunction(SOAP_FUNCTIONS_ALL);
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapserver.setclass"></a>
-<h2>SoapServer::setClass</h2>
-<p>(PHP 5)</p>
-<p>sets class which will handle SOAP requests</p>
-<h3>Description</h3>
-<p>void <b>setClass</b>(string class_name [, ...])</p>
-Exports all methods from specified class. Additional parameters will be passed
-to default class constructor during object creation. The object can be maiden
-persistent across request for a given PHP session with
-<a href="#ref.soap.soapserver.setpersistence">SoapServer::setPersistence</a> method.
-<h4>Examples</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-    $server->setClass("foo");
-
-    $server->setClass("foo", $arg1, $arg2);
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapserver.getfunctions">
-<h2>SoapServer::getFunctions</h2>
-<p>(PHP 5)</p>
-<p>returns list of defined functions</p>
-<h3>Description</h3>
-<p>array <b>getFunctions</b>()</p>
-
-<a name="ref.soap.soapserver.setpersistence"></a>
-<h2>SoapServer::setPersistence</h2>
-<p>(PHP 5)</p>
-<p>sets persistence mode of SoapServer</p>
-<h3>Description</h3>
-<p>void <b>setPersistence</b>(int mode)</p>
-This function allows saving data between requests in PHP session. It works only
-with server that exports functions form class (see
-<a href="#ref.soap.soapserver.setclass">SoapServer:setCalss</a>).
-<h4>Examples</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-    $server->setpersistence(SOAP_PERSISTENCE_SESSION);
-
-    $server->setpersistence(SOAP_PERSISTENCE_REQUEST);
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapserver.handle"></a>
-<h2>SoapServer::handle</h2>
-<p>(PHP 5)</p>
-<p>handles a SOAP request</p>
-<h3>Description</h3>
-<p>void <b>handle</b>([string soap_envelope])</p>
-It processes a SOAP request, call necessary functions, and send response back.
-It assumes request in input parameter or in global <b>$HTTP_RAW_POST_DATA</b> PHP variable
-if the argument is omitted.
-<h4>Example</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    function test($x) {
-        return $x;
-    }
-
-    $server = new SoapServer(null,array('uri'=>"http://test-uri/"));
-    $server->addFunction("test");
-    $server->handle();
-?>
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapparam.soapparam"></a>
-<h2>SoapParam::SoapParam</h2>
-<p>(PHP 5)</p>
-<p>SoapParam constructor</p>
-<h3>Description</h3>
-<p><b>SoapParam</b>(mixed data, string name)</p>
-<p>
-SoapParam is a special low-level class for naming parameters and return values
-in nonWSDL mode. It is just a data holder and it has not any special method
-except constructor. The constructor takes <b>data</b> to pass or return and
-<b>name</b>. It is possible to pass parameter directly as PHP value, but in
-this case it will be named as <b><i>paramN</i></b> and SOAP Service may not
-understand it.
-</p>
-<h4>Example</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    $client = new SoapClient(null,array('location' => "http://localhost/soap.php",
-                                        'uri'      => "http://test-uri/"));
-    $client->SomeFunction(new SoapParam($a,"a"),
-                          new SoapParam($b,"b"),
-                          new SoapParam($c,"c"));
-?>
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapvar.soapvar"></a>
-<h2>SoapVar::SoapVar</h2>
-<p>(PHP 5)</p>
-<p>SoapVar constructor</p>
-<h3>Description</h3>
-<p><b>SoapVar</b>(mixed data, int encoding [, string type [, string type_ns [, string name [, string name_ns]]]])</p>
-<p>
-SoapVar is a special low-level class for encoding parameters and return values
-in nonWSDL mode. It is just a data holder and it has not any special method
-except constructor. It is useful when you like to set type property in SOAP
-request or response. The constructor takes <b>data</b> to pass or return,
-<b>encoding</b> ID to encode it (see <b><i>XSD_...</i></b> constants) and as
-option type name and namespace and value name and namespace.
-</p>
-<h4>Example</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    class SOAPStruct {
-    	function SOAPStruct($s, $i, $f) {
-    		$this->varString = $s;
-    		$this->varInt = $i;
-    		$this->varFloat = $f;
-    	}
-    }
-    $client = new SoapClient(null,array('location' => "http://localhost/soap.php",
-                                        'uri'      => "http://test-uri/"));
-    $struct = new SOAPStruct('arg',34,325.325);
-    $soapstruct = new SoapVar($struct,SOAP_ENC_OBJECT,"SOAPStruct","http://soapinterop.org/xsd");
-    $client->echoStruct(new SoapParam($soapstruct, "inputStruct"));
-?>
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapheader.soapheader"></a>
-<h2>SoapHeader::SoapHeader</h2>
-<p>(PHP 5)</p>
-<p>SoapHeader constructor</p>
-<h3>Description</h3>
-<p><b>SoapHeader</b>(string name_ns, string name [, mixed data [, bool must_understand [, mixed actor]]])</p>
-<p>
-SoapHeader is a special low-level class for passing or returning SOAP headers.
-It is just a data holder and it has not any special method except constructor.
-It can be used in <a href="#ref.soap.soapclient.__call">SoapClient::__call</a>
-method to pass SOAP header or in SOAP header handler to return header in SOAP
-response. <b>name_ns</b> and <b>name</b> are namespace and name of the SOAP
-header element. <b>data</b> is a SOAP header's content. It can be a PHP value
-or SoapVar object. <b>must_understand</b> and <b>actor</b> are values for
-<b><i>mustUnderstand</i></b> and <b><i>actor</i></b> attributes of this SOAP
-Header element.
-</p>
-<h4>Example</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    $client = new SoapClient(null,array('location' => "http://localhost/soap.php",
-                                        'uri'      => "http://test-uri/"));
-    $client->__call("echoVoid",NULL,NULL,
-                    new SoapHeader('http://soapinterop.org/echoheader/',
-                                   'echoMeStringRequest',
-                                   'hello world'));
-?>
-</PRE></TD></TR></TABLE>
-
-<a name="ref.soap.soapfault.soapfault"></a>
-<h2>SoapFault::SoapFault</h2>
-<p>(PHP 5)</p>
-<p>SoapFault constructor</p>
-<h3>Description</h3>
-<p><b>SoapFault</b>(string faultcode, string faultstring [, string faultactor [, mixed details [, string faultname [, mixed headerfault]]]])</p>
-This class is useful when you like to send SOAP fault response from PHP handler.<br>
-<b>faultcode</b>, <b>faultstring</b>, <b>faultactor</b> and <b>details</b> are standard elements of SOAP Fault;<br>
-<b>faultname</b> is an optional parameter that can be used to select proper fault encoding from WSDL.<br>
-<b>headerfault</b> is an optional parameter that can be used during SOAP header handling to report error in response header.
-<h4>Example</h4>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    function test($x) {
-        return new SoapFault("Server","Some error message");
-    }
-
-    $server = new SoapServer(null,array('uri'=>"http://test-uri/"));
-    $server->addFunction("test");
-    $server->handle();
-?>
-</PRE></TD></TR></TABLE>
-<p>It is possible to use PHP exception mechanism to throw SOAP Fault.</p>
-<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
-<?php
-    function test($x) {
-        throw new SoapFault("Server","Some error message");
-    }
-
-    $server = new SoapServer(null,array('uri'=>"http://test-uri/"));
-    $server->addFunction("test");
-    $server->handle();
-?>
-</PRE></TD></TR></TABLE>
-</BODY>
-</HTML>
\ No newline at end of file
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index 62abbe5..c1c51ce 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: soap.c 287746 2009-08-26 14:05:48Z dmitry $ */
+/* $Id: soap.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1416,9 +1416,7 @@ PHP_METHOD(SoapServer, setObject)
 	service->type = SOAP_OBJECT;
 
 	MAKE_STD_ZVAL(service->soap_object);
-	*service->soap_object = *obj;
-	zval_copy_ctor(service->soap_object);
-	INIT_PZVAL(service->soap_object);
+	MAKE_COPY_ZVAL(&obj, service->soap_object);
 
 	SOAP_SERVER_END_CODE();
 }
@@ -2335,9 +2333,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
 			}
 			fault = add_soap_fault(SOAP_GLOBAL(error_object), code, buffer, NULL, NULL TSRMLS_CC);
 			MAKE_STD_ZVAL(exception);
-			*exception = *fault;
-			zval_copy_ctor(exception);
-			INIT_PZVAL(exception);
+			MAKE_COPY_ZVAL(&fault, exception);
 			zend_throw_exception_object(exception TSRMLS_CC);
 
 			old_objects = EG(objects_store).object_buckets;
@@ -2623,9 +2619,7 @@ PHP_METHOD(SoapClient, SoapClient)
 			zval *class_map;
 
 			MAKE_STD_ZVAL(class_map);
-			*class_map = **tmp;
-			INIT_PZVAL(class_map);
-			zval_copy_ctor(class_map);
+			MAKE_COPY_ZVAL(tmp, class_map);
 #ifdef ZEND_ENGINE_2
 			Z_DELREF_P(class_map);
 #endif
@@ -2955,9 +2949,7 @@ static void do_soap_call(zval* this_ptr,
 		zval *exception;
 
 		MAKE_STD_ZVAL(exception);
-		*exception = *return_value;
-		zval_copy_ctor(exception);
-		INIT_PZVAL(exception);
+		MAKE_COPY_ZVAL(&return_value, exception);
 		zend_throw_exception_object(exception TSRMLS_CC);
 	}
 #endif
diff --git a/ext/soap/tests/server009.phpt b/ext/soap/tests/server009.phpt
index 0a34127..28d195a 100644
--- a/ext/soap/tests/server009.phpt
+++ b/ext/soap/tests/server009.phpt
@@ -7,6 +7,9 @@ SOAP Server 9: setclass and setpersistence(SOAP_PERSISTENCE_SESSION)
 		die('skip this test needs session extension');
 	}
 ?>
+--INI--
+session.auto_start=1
+session.save_handler=files
 --FILE--
 <?php
 class foo {
diff --git a/ext/sockets/config.m4 b/ext/sockets/config.m4
index ce18979..93f892a 100644
--- a/ext/sockets/config.m4
+++ b/ext/sockets/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 240160 2007-07-22 22:18:41Z jani $
+dnl $Id: config.m4 294029 2010-01-25 23:12:42Z johannes $
 dnl
 
 PHP_ARG_ENABLE(sockets, whether to enable sockets support,
@@ -29,4 +29,5 @@ if test "$PHP_SOCKETS" != "no"; then
   AC_DEFINE([HAVE_SOCKETS], 1, [ ])
 
   PHP_NEW_EXTENSION([sockets], [sockets.c], [$ext_shared])
+  PHP_INSTALL_HEADERS([ext/sockets/], [php_sockets.h])
 fi
diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h
index 4f5c21e..f9aaaa5 100644
--- a/ext/sockets/php_sockets.h
+++ b/ext/sockets/php_sockets.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -22,7 +22,7 @@
 #ifndef PHP_SOCKETS_H
 #define PHP_SOCKETS_H
 
-/* $Id: php_sockets.h 289417 2009-10-09 14:22:29Z pajoye $ */
+/* $Id: php_sockets.h 294029 2010-01-25 23:12:42Z johannes $ */
 
 #if HAVE_SOCKETS
 
@@ -95,6 +95,8 @@ struct	sockaddr_un {
 
 PHP_SOCKETS_API int php_sockets_le_socket(void);
 
+#define php_sockets_le_socket_name "Socket"
+
 /* Prototypes */
 #ifdef ilia_0 /* not needed, only causes a compiler warning */
 static int php_open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC);
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 6e74490..099d391 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sockets.c 289417 2009-10-09 14:22:29Z pajoye $ */
+/* $Id: sockets.c 294029 2010-01-25 23:12:42Z johannes $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -41,6 +41,12 @@
 # include "php_sockets.h"
 # include "win32/sockets.h"
 # define IS_INVALID_SOCKET(a)	(a->bsd_socket == INVALID_SOCKET)
+# ifdef EPROTONOSUPPORT
+#  undef EPROTONOSUPPORT
+# endif
+# ifdef ECONNRESET
+#  undef ECONNRESET
+# endif
 # define EPROTONOSUPPORT	WSAEPROTONOSUPPORT
 # define ECONNRESET		WSAECONNRESET
 # ifdef errno
@@ -104,7 +110,7 @@ static char *php_strerror(int error TSRMLS_DC);
 						php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s [%d]: %s", msg, errn, php_strerror(errn TSRMLS_CC))
 
 static int le_socket;
-#define le_socket_name "Socket"
+#define le_socket_name php_sockets_le_socket_name
 
 /* {{{ arginfo */
 ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_select, 0, 0, 4)
diff --git a/ext/sockets/tests/socket_getpeername_ipv6loop.phpt b/ext/sockets/tests/socket_getpeername_ipv6loop.phpt
index ba3c134..e865f3e 100644
--- a/ext/sockets/tests/socket_getpeername_ipv6loop.phpt
+++ b/ext/sockets/tests/socket_getpeername_ipv6loop.phpt
@@ -5,9 +5,10 @@ ext/sockets - socket_getpeername_ipv6loop - basic test
 # $Id: socket_getpeername_ipv6loop.phpt 494 2009-06-09 20:38:05Z tatjana.andersen at redpill-linpro.com $
 --SKIPIF--
 <?php   
-        if (!extension_loaded('sockets')) {
-                die('skip sockets extension not available.');
-        }
+if (!extension_loaded('sockets')) {
+	die('skip sockets extension not available.');
+}
+require 'ipv6_skipif.inc';
 ?>
 --FILE--
 <?php   
diff --git a/ext/sockets/tests/socket_set_option_rcvtimeo.phpt b/ext/sockets/tests/socket_set_option_rcvtimeo.phpt
index 84c533f..ea14fd3 100644
--- a/ext/sockets/tests/socket_set_option_rcvtimeo.phpt
+++ b/ext/sockets/tests/socket_set_option_rcvtimeo.phpt
@@ -1,6 +1,6 @@
 --TEST--
 Test if socket_set_option() works, option:SO_RCVTIMEO
---DESCRIPTION---
+--DESCRIPTION--
 -wrong params 
 -set/get params comparison 
 --SKIPIF--
diff --git a/ext/sockets/tests/socket_set_option_seolinger.phpt b/ext/sockets/tests/socket_set_option_seolinger.phpt
index 05bc213..e49a7eb 100644
--- a/ext/sockets/tests/socket_set_option_seolinger.phpt
+++ b/ext/sockets/tests/socket_set_option_seolinger.phpt
@@ -1,6 +1,6 @@
 --TEST--
 Test if socket_set_option() works, option:SO_SEOLINGER
---DESCRIPTION---
+--DESCRIPTION--
 -wrong params 
 -set/get params comparison 
 -l_linger not given
diff --git a/ext/sockets/tests/socket_set_option_sndtimeo.phpt b/ext/sockets/tests/socket_set_option_sndtimeo.phpt
index c4e4851..6fd008c 100644
--- a/ext/sockets/tests/socket_set_option_sndtimeo.phpt
+++ b/ext/sockets/tests/socket_set_option_sndtimeo.phpt
@@ -1,6 +1,6 @@
 --TEST--
 Test if socket_set_option() works, option:SO_SNDTIMEO
---DESCRIPTION---
+--DESCRIPTION--
 -wrong params 
 -set/get params comparison 
 --SKIPIF--
diff --git a/ext/sockets/unix_socket_constants.h b/ext/sockets/unix_socket_constants.h
index 8403425..0cba232 100644
--- a/ext/sockets/unix_socket_constants.h
+++ b/ext/sockets/unix_socket_constants.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: unix_socket_constants.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: unix_socket_constants.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* This file is to be included by sockets.c */
 
diff --git a/ext/sockets/win32_socket_constants.h b/ext/sockets/win32_socket_constants.h
index f593ec6..74b572e 100644
--- a/ext/sockets/win32_socket_constants.h
+++ b/ext/sockets/win32_socket_constants.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: win32_socket_constants.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: win32_socket_constants.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* This file is to be included by sockets.c */
 
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index 1945f98..8a7d6f3 100755
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_spl.c 283179 2009-06-30 17:14:37Z cseiler $ */
+/* $Id: php_spl.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h
index 8412b4c..353923a 100755
--- a/ext/spl/php_spl.h
+++ b/ext/spl/php_spl.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 2a2e2f3..db3de04 100755
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_array.c 287266 2009-08-13 22:07:05Z colder $ */
+/* $Id: spl_array.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -700,6 +700,7 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /*
 		}
 
 		if (intern->debug_info->nApplyCount == 0) {
+			zend_hash_clean(intern->debug_info);
 			zend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
 
 			storage = intern->array;
diff --git a/ext/spl/spl_array.h b/ext/spl/spl_array.h
index 9590ca6..be11a51 100755
--- a/ext/spl/spl_array.h
+++ b/ext/spl/spl_array.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_array.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_array.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SPL_ARRAY_H
 #define SPL_ARRAY_H
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 860c672..5606062 100755
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c 284648 2009-07-23 14:42:46Z jani $ */
+/* $Id: spl_directory.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
diff --git a/ext/spl/spl_directory.h b/ext/spl/spl_directory.h
index 549cff6..404390e 100755
--- a/ext/spl/spl_directory.h
+++ b/ext/spl/spl_directory.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.h 283689 2009-07-08 03:06:59Z iliaa $ */
+/* $Id: spl_directory.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index 2caf9cc..505e92d 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_dllist.c 287266 2009-08-13 22:07:05Z colder $ */
+/* $Id: spl_dllist.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
diff --git a/ext/spl/spl_dllist.h b/ext/spl/spl_dllist.h
index e5b6cb7..52b029c 100644
--- a/ext/spl/spl_dllist.h
+++ b/ext/spl/spl_dllist.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_dllist.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_dllist.h 294892 2010-02-11 17:24:43Z johannes $ */
 
 #ifndef SPL_DLLIST_H
 #define SPL_DLLIST_H
@@ -24,9 +24,9 @@
 #include "php.h"
 #include "php_spl.h"
 
-PHPAPI zend_class_entry *spl_ce_SplDoublyLinkedList;
-PHPAPI zend_class_entry *spl_ce_SplQueue;
-PHPAPI zend_class_entry *spl_ce_SplStack;
+extern PHPAPI zend_class_entry *spl_ce_SplDoublyLinkedList;
+extern PHPAPI zend_class_entry *spl_ce_SplQueue;
+extern PHPAPI zend_class_entry *spl_ce_SplStack;
 
 PHP_MINIT_FUNCTION(spl_dllist);
 
diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c
index 2eb0a4e..e8edf6a 100755
--- a/ext/spl/spl_engine.c
+++ b/ext/spl/spl_engine.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/spl/spl_engine.h b/ext/spl/spl_engine.h
index bb62cb3..7baea3a 100755
--- a/ext/spl/spl_engine.h
+++ b/ext/spl/spl_engine.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_engine.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_engine.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SPL_ENGINE_H
 #define SPL_ENGINE_H
diff --git a/ext/spl/spl_exceptions.c b/ext/spl/spl_exceptions.c
index 3a0904d..b761be7 100755
--- a/ext/spl/spl_exceptions.c
+++ b/ext/spl/spl_exceptions.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_exceptions.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_exceptions.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
diff --git a/ext/spl/spl_exceptions.h b/ext/spl/spl_exceptions.h
index 1eabcdf..20416d5 100755
--- a/ext/spl/spl_exceptions.h
+++ b/ext/spl/spl_exceptions.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_exceptions.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_exceptions.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SPL_EXCEPTIONS_H
 #define SPL_EXCEPTIONS_H
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index 5c192c8..b7bc246 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: spl_fixedarray.c 283486 2009-07-04 20:31:27Z felipe $ */
+/* $Id: spl_fixedarray.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/spl/spl_fixedarray.h b/ext/spl/spl_fixedarray.h
index 0dfd9eb..83e796a 100644
--- a/ext/spl/spl_fixedarray.h
+++ b/ext/spl/spl_fixedarray.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,12 +17,12 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: spl_fixedarray.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_fixedarray.h 294892 2010-02-11 17:24:43Z johannes $ */
 
 #ifndef SPL_FIXEDARRAY_H
 #define SPL_FIXEDARRAY_H
 
-PHPAPI zend_class_entry *spl_ce_SplFixedArray;
+extern PHPAPI zend_class_entry *spl_ce_SplFixedArray;
 
 PHP_MINIT_FUNCTION(spl_fixedarray);
 
diff --git a/ext/spl/spl_functions.c b/ext/spl/spl_functions.c
index 8279aee..177a131 100755
--- a/ext/spl/spl_functions.c
+++ b/ext/spl/spl_functions.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_functions.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_functions.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 	#include "config.h"
diff --git a/ext/spl/spl_functions.h b/ext/spl/spl_functions.h
index c992f48..6cfb8bf 100755
--- a/ext/spl/spl_functions.h
+++ b/ext/spl/spl_functions.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_functions.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_functions.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_FUNCTIONS_H
 #define PHP_FUNCTIONS_H
diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c
index 550b9ef..d063377 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_heap.c 287266 2009-08-13 22:07:05Z colder $ */
+/* $Id: spl_heap.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
diff --git a/ext/spl/spl_heap.h b/ext/spl/spl_heap.h
index cd9d36a..0cc707d 100644
--- a/ext/spl/spl_heap.h
+++ b/ext/spl/spl_heap.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_heap.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_heap.h 294892 2010-02-11 17:24:43Z johannes $ */
 
 #ifndef SPL_HEAP_H
 #define SPL_HEAP_H
@@ -24,11 +24,11 @@
 #include "php.h"
 #include "php_spl.h"
 
-PHPAPI zend_class_entry *spl_ce_SplHeap;
-PHPAPI zend_class_entry *spl_ce_SplMinHeap;
-PHPAPI zend_class_entry *spl_ce_SplMaxHeap;
+extern PHPAPI zend_class_entry *spl_ce_SplHeap;
+extern PHPAPI zend_class_entry *spl_ce_SplMinHeap;
+extern PHPAPI zend_class_entry *spl_ce_SplMaxHeap;
 
-PHPAPI zend_class_entry *spl_ce_SplPriorityQueue;
+extern PHPAPI zend_class_entry *spl_ce_SplPriorityQueue;
 
 PHP_MINIT_FUNCTION(spl_heap);
 
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index d498890..daf2284 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.c 283486 2009-07-04 20:31:27Z felipe $ */
+/* $Id: spl_iterators.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -1166,7 +1166,7 @@ static union _zend_function *spl_dual_it_get_method(zval **object_ptr, char *met
 	intern = (spl_dual_it_object*)zend_object_store_get_object(*object_ptr TSRMLS_CC);
 
 	function_handler = std_object_handlers.get_method(object_ptr, method, method_len TSRMLS_CC);
-	if (!function_handler) {
+	if (!function_handler && intern->inner.ce) {
 		if (zend_hash_find(&intern->inner.ce->function_table, method, method_len+1, (void **) &function_handler) == FAILURE) {
 			if (Z_OBJ_HT_P(intern->inner.zobject)->get_method) {
 				*object_ptr = intern->inner.zobject;
@@ -1332,7 +1332,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
 						return NULL;
 					}
 					if (!retval || Z_TYPE_P(retval) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(retval), zend_ce_traversable TSRMLS_CC)) {
-						zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "%s::getIterator() must return an object that implememnts Traversable", ce->name);
+						zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "%s::getIterator() must return an object that implements Traversable", ce->name);
 						zend_restore_error_handling(&error_handling TSRMLS_CC);
 						return NULL;
 					}
@@ -2077,7 +2077,7 @@ static inline void spl_limit_it_seek(spl_dual_it_object *intern, long pos TSRMLS
 		return;
 	}
 	if (pos >= intern->u.limit.offset + intern->u.limit.count && intern->u.limit.count != -1) {
-		zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Cannot seek to %ld which is behind offest %ld plus count %ld", pos, intern->u.limit.offset, intern->u.limit.count);
+		zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Cannot seek to %ld which is behind offset %ld plus count %ld", pos, intern->u.limit.offset, intern->u.limit.count);
 		return;
 	}
 	if (instanceof_function(intern->inner.ce, spl_ce_SeekableIterator TSRMLS_CC)) {
@@ -2382,10 +2382,8 @@ SPL_METHOD(CachingIterator, __toString)
 			return;
 		}
 	} else if (intern->u.caching.flags & CIT_TOSTRING_USE_CURRENT) {
-		*return_value = *intern->current.data;
-		zval_copy_ctor(return_value);
+		MAKE_COPY_ZVAL(&intern->current.data, return_value);
 		convert_to_string(return_value);
-		INIT_PZVAL(return_value);
 		return;
 	}
 	if (intern->u.caching.zstr) {
diff --git a/ext/spl/spl_iterators.h b/ext/spl/spl_iterators.h
index d252d71..4464e09 100755
--- a/ext/spl/spl_iterators.h
+++ b/ext/spl/spl_iterators.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_iterators.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SPL_ITERATORS_H
 #define SPL_ITERATORS_H
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index 3100ead..75855ad 100755
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | Copyright (c) 1997-2010 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is SplSubject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_observer.c 287266 2009-08-13 22:07:05Z colder $ */
+/* $Id: spl_observer.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -622,7 +622,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
 	++p;
 
 	ALLOC_INIT_ZVAL(pcount);
-	if (!php_var_unserialize(&pcount, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pcount) != IS_LONG) {
+	if (!php_var_unserialize(&pcount, &p, s + buf_len, NULL TSRMLS_CC) || Z_TYPE_P(pcount) != IS_LONG) {
 		zval_ptr_dtor(&pcount);
 		goto outexcept;
 	}
diff --git a/ext/spl/spl_observer.h b/ext/spl/spl_observer.h
index 0edb338..cbe25d6 100755
--- a/ext/spl/spl_observer.h
+++ b/ext/spl/spl_observer.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_observer.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spl_observer.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SPL_OBSERVER_H
 #define SPL_OBSERVER_H
diff --git a/ext/spl/tests/bug49263.phpt b/ext/spl/tests/bug49263.phpt
new file mode 100644
index 0000000..14d0950
--- /dev/null
+++ b/ext/spl/tests/bug49263.phpt
@@ -0,0 +1,54 @@
+--TEST--
+SPL: SplObjectStorage serialization references
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+$o1 = new stdClass;
+$o2 = new stdClass;
+
+$s = new splObjectStorage();
+
+$s->attach($o1, array('prev' => 2, 'next' => $o2));
+$s->attach($o2, array('prev' => $o1));
+
+$ss = serialize($s);
+unset($s,$o1,$o2);
+echo $ss."\n";
+var_dump(unserialize($ss));
+?>
+===DONE===
+--EXPECTF--
+C:16:"SplObjectStorage":113:{x:i:2;O:8:"stdClass":0:{},a:2:{s:4:"prev";i:2;s:4:"next";O:8:"stdClass":0:{}};r:4;,a:1:{s:4:"prev";r:1;};m:a:0:{}}
+object(SplObjectStorage)#2 (1) {
+  ["storage":"SplObjectStorage":private]=>
+  array(2) {
+    ["%s"]=>
+    array(2) {
+      ["obj"]=>
+      object(stdClass)#1 (0) {
+      }
+      ["inf"]=>
+      array(2) {
+        ["prev"]=>
+        int(2)
+        ["next"]=>
+        object(stdClass)#3 (0) {
+        }
+      }
+    }
+    ["%s"]=>
+    array(2) {
+      ["obj"]=>
+      object(stdClass)#3 (0) {
+      }
+      ["inf"]=>
+      array(1) {
+        ["prev"]=>
+        object(stdClass)#1 (0) {
+        }
+      }
+    }
+  }
+}
+===DONE===
diff --git a/ext/spl/tests/bug49972.phpt b/ext/spl/tests/bug49972.phpt
new file mode 100755
index 0000000..843c251
--- /dev/null
+++ b/ext/spl/tests/bug49972.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #49972 (AppendIterator undefined function crash)
+--FILE--
+<?php
+
+$iterator = new AppendIterator();
+$iterator->undefined();
+
+?>
+--EXPECTF--
+Fatal error: Call to undefined method AppendIterator::undefined() in %s on line %d
diff --git a/ext/spl/tests/iterator_032.phpt b/ext/spl/tests/iterator_032.phpt
index 8b1d97e..84eb8e6 100755
--- a/ext/spl/tests/iterator_032.phpt
+++ b/ext/spl/tests/iterator_032.phpt
@@ -45,6 +45,6 @@ int(1)
 int(2)
 Cannot seek to 0 which is below the offset 1
 int(3)
-Cannot seek to 3 which is behind offest 1 plus count 2
+Cannot seek to 3 which is behind offset 1 plus count 2
 bool(false)
 ===DONE===
diff --git a/ext/spl/tests/iterator_069.phpt b/ext/spl/tests/iterator_069.phpt
new file mode 100644
index 0000000..e9b3177
--- /dev/null
+++ b/ext/spl/tests/iterator_069.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: RecursiveIteratorIterator cannot be used with foreach by reference
+--FILE--
+<?php 
+
+$arr = array(array(1,2));
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+$recItIt = new RecursiveIteratorIterator($recArrIt);
+
+foreach ($recItIt as &$val) echo "$val\n";
+
+?>
+--EXPECTF--
+Fatal error: An iterator cannot be used with foreach by reference in %s on line %d
diff --git a/ext/spl/tests/iterator_070.phpt b/ext/spl/tests/iterator_070.phpt
new file mode 100644
index 0000000..c45f08e
--- /dev/null
+++ b/ext/spl/tests/iterator_070.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Ensure that non-overriden methods execute problem free.
+--FILE--
+<?php
+
+$array = array();
+$recArrIt = new RecursiveArrayIterator($array);
+
+$recItIt = new RecursiveIteratorIterator($recArrIt);
+
+var_dump($recItIt->beginIteration());
+var_dump($recItIt->endIteration());
+var_dump($recItIt->nextElement());
+
+?>
+
+--EXPECTF--
+NULL
+NULL
+NULL
\ No newline at end of file
diff --git a/ext/spl/tests/iterator_071.phpt b/ext/spl/tests/iterator_071.phpt
new file mode 100644
index 0000000..21ec798
--- /dev/null
+++ b/ext/spl/tests/iterator_071.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Test where the case is RS_SELF and mode is CHILD_FIRST
+--FILE--
+<?php 
+
+$arr = array(array(1,2),2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+    
+    function nextelement() {
+    	echo __METHOD__."\n";
+    }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::CHILD_FIRST);
+
+foreach ($recItIt as $key => $val) echo "$key\n";
+
+?>
+--EXPECTF--
+MyRecursiveIteratorIterator::nextelement
+0
+MyRecursiveIteratorIterator::nextelement
+1
+MyRecursiveIteratorIterator::nextelement
+0
+MyRecursiveIteratorIterator::nextelement
+1
\ No newline at end of file
diff --git a/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt b/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
new file mode 100644
index 0000000..f543072
--- /dev/null
+++ b/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in beginchildren which should be handled in next()
+--FILE--
+<?php 
+
+$arr = array(array(1,2),2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+    
+    function beginchildren() {
+    	throw new Exception;
+    }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt2->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->beginchildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+  thrown in %s on line %d
diff --git a/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt b/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
new file mode 100644
index 0000000..88f03fb
--- /dev/null
+++ b/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in callHasChildren which should be handled in next()
+--FILE--
+<?php 
+
+$arr = array(1,2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+    
+    function callHasChildren() {
+    	throw new Exception;
+    }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt2->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->callHasChildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+  thrown in %s on line %d
diff --git a/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt b/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
new file mode 100644
index 0000000..e25d3ed
--- /dev/null
+++ b/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
@@ -0,0 +1,42 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in endchildren which should be handled in next()
+--FILE--
+<?php 
+
+$arr = array(array(1,2));
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+    
+    function endchildren() {
+    	throw new Exception;
+    }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+foreach ($recItIt as $val) echo "$val\n";
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+echo "===NEXT LOOP===\n";
+
+foreach ($recItIt2 as $val) echo "$val\n";
+
+?>
+--EXPECTF--
+1
+2
+===NEXT LOOP===
+1
+2
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->endchildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+  thrown in %s on line %d
diff --git a/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt b/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
new file mode 100644
index 0000000..3a91ed5
--- /dev/null
+++ b/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in nextelement which should be handled in next()
+--FILE--
+<?php 
+
+$arr = array(1,2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+    
+    function nextelement() {
+    	throw new Exception;
+    }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->nextelement()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+  thrown in %s on line %d
diff --git a/ext/sqlite/config.m4 b/ext/sqlite/config.m4
index 25af846..4f7b72c 100644
--- a/ext/sqlite/config.m4
+++ b/ext/sqlite/config.m4
@@ -1,4 +1,4 @@
-dnl $Id: config.m4 266233 2008-09-13 00:23:48Z moriyoshi $
+dnl $Id: config.m4 291414 2009-11-29 06:13:22Z rasmus $
 dnl config.m4 for extension sqlite
 dnl vim:et:ts=2:sw=2
 
diff --git a/ext/sqlite/pdo_sqlite2.c b/ext/sqlite/pdo_sqlite2.c
index 663c6f5..826a9fa 100644
--- a/ext/sqlite/pdo_sqlite2.c
+++ b/ext/sqlite/pdo_sqlite2.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_sqlite2.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pdo_sqlite2.c 293036 2010-01-03 09:23:27Z sebastian $ */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/ext/sqlite/php_sqlite.h b/ext/sqlite/php_sqlite.h
index f0cd311..439cbf5 100644
--- a/ext/sqlite/php_sqlite.h
+++ b/ext/sqlite/php_sqlite.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    |          Marcus Boerger <helly at php.net>                              |
    +----------------------------------------------------------------------+
 
-   $Id: php_sqlite.h 272370 2008-12-31 11:15:49Z sebastian $ 
+   $Id: php_sqlite.h 293036 2010-01-03 09:23:27Z sebastian $ 
 */
 
 #ifndef PHP_SQLITE_H
diff --git a/ext/sqlite/sess_sqlite.c b/ext/sqlite/sess_sqlite.c
index 877da8b..443f621 100644
--- a/ext/sqlite/sess_sqlite.c
+++ b/ext/sqlite/sess_sqlite.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sess_sqlite.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sess_sqlite.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c
index d9a4a79..4ea17ee 100644
--- a/ext/sqlite/sqlite.c
+++ b/ext/sqlite/sqlite.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    |          Marcus Boerger <helly at php.net>                              |
    +----------------------------------------------------------------------+
 
-   $Id: sqlite.c 289598 2009-10-12 22:37:52Z pajoye $
+   $Id: sqlite.c 293036 2010-01-03 09:23:27Z sebastian $
 */
 
 #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 289598 2009-10-12 22:37:52Z pajoye $");
+	php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c 293036 2010-01-03 09:23:27Z sebastian $");
 	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();
diff --git a/ext/sqlite3/config.w32 b/ext/sqlite3/config.w32
index 3ea7546..9b36073 100644
--- a/ext/sqlite3/config.w32
+++ b/ext/sqlite3/config.w32
@@ -1,10 +1,10 @@
-// $Id: config.w32 281461 2009-05-31 11:16:46Z kalle $
+// $Id: config.w32 289692 2009-10-16 02:22:48Z scottmac $
 // vim:ft=javascript
 
 ARG_WITH("sqlite3", "SQLite 3 support", "no");
 
 if (PHP_SQLITE3 != "no") {
-	ADD_FLAG("CFLAGS_SQLITE3", "/D SQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_CORE=1 ");
+	ADD_FLAG("CFLAGS_SQLITE3", "/D SQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 ");
 	EXTENSION("sqlite3", "sqlite3.c", null, "/I" + configure_module_dirname + "/libsqlite /I" + configure_module_dirname);
 
 	ADD_SOURCES(configure_module_dirname + "/libsqlite", "sqlite3.c", "sqlite3");
diff --git a/ext/sqlite3/libsqlite/sqlite3.c b/ext/sqlite3/libsqlite/sqlite3.c
index db34d0c..5339b31 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.19.  By combining all the individual C code files into this 
+** version 3.6.22.  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
@@ -20,8 +20,6 @@
 ** if you want a wrapper to interface SQLite with your choice of programming
 ** language. The code for the "sqlite3" command-line shell is also in a
 ** separate file. This file contains only code for the core SQLite library.
-**
-** This amalgamation was generated on 2009-10-14 11:35:02 UTC.
 */
 #define SQLITE_CORE 1
 #define SQLITE_AMALGAMATION 1
@@ -99,8 +97,6 @@
 *************************************************************************
 ** 
 ** This file defines various limits of what SQLite can process.
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -285,12 +281,8 @@
 ** may be executed.
 */
 #ifndef SQLITE_MAX_TRIGGER_DEPTH
-#if defined(SQLITE_SMALL_STACK)
-# define SQLITE_MAX_TRIGGER_DEPTH 10
-#else
 # define SQLITE_MAX_TRIGGER_DEPTH 1000
 #endif
-#endif
 
 /************** End of sqliteLimit.h *****************************************/
 /************** Continuing where we left off in sqliteInt.h ******************/
@@ -613,55 +605,43 @@ extern "C" {
 #endif
 
 /*
-** CAPI3REF: Compile-Time Library Version Numbers {H10010} <S60100>
-**
-** The SQLITE_VERSION and SQLITE_VERSION_NUMBER #defines in
-** the sqlite3.h file specify the version of SQLite with which
-** that header file is associated.
+** CAPI3REF: Compile-Time Library Version Numbers
 **
-** The "version" of SQLite is a string of the form "W.X.Y" or "W.X.Y.Z".
-** The W value is major version number and is always 3 in SQLite3.
-** The W value only changes when backwards compatibility is
-** broken and we intend to never break backwards compatibility.
-** The X value is the minor version number and only changes when
-** there are major feature enhancements that are forwards compatible
-** but not backwards compatible.
-** The Y value is the release number and is incremented with
-** each release but resets back to 0 whenever X is incremented.
-** The Z value only appears on branch releases.
-**
-** The SQLITE_VERSION_NUMBER is an integer that is computed as
-** follows:
-**
-** <blockquote><pre>
-** SQLITE_VERSION_NUMBER = W*1000000 + X*1000 + Y
-** </pre></blockquote>
+** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
+** evaluates to a string literal that is the SQLite version in the
+** format "X.Y.Z" where X is the major version number (always 3 for
+** SQLite3) and Y is the minor version number and Z is the release number.)^
+** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
+** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
+** numbers used in [SQLITE_VERSION].)^
+** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
+** be larger than the release from which it is derived.  Either Y will
+** be held constant and Z will be incremented or else Y will be incremented
+** and Z will be reset to zero.
 **
 ** 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 is a string which identifies a particular check-in of SQLite
-** within its configuration management system.  The string contains the
-** date and time of the check-in (UTC) and an SHA1 hash of the entire
-** source tree.
+** <a href="http://www.fossil-scm.org/">Fossil configuration management
+** system</a>.  ^The SQLITE_SOURCE_ID macro evalutes 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
+** hash of the entire source tree.
 **
 ** See also: [sqlite3_libversion()],
 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
 ** [sqlite_version()] and [sqlite_source_id()].
-**
-** Requirements: [H10011] [H10014]
 */
-#define SQLITE_VERSION        "3.6.19"
-#define SQLITE_VERSION_NUMBER 3006019
-#define SQLITE_SOURCE_ID      "2009-10-14 11:33:55 c1d499afc50d54b376945b4efb65c56c787a073d"
+#define SQLITE_VERSION        "3.6.22"
+#define SQLITE_VERSION_NUMBER 3006022
+#define SQLITE_SOURCE_ID      "2010-01-05 15:30:36 28d0d7710761114a44a1a3a425a6883c661f06e7"
 
 /*
-** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
+** CAPI3REF: Run-Time Library Version Numbers
 ** KEYWORDS: sqlite3_version
 **
 ** These interfaces provide the same information as the [SQLITE_VERSION],
-** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] #defines in the header,
-** but are associated with the library instead of the header file.  Cautious
+** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
+** but are associated with the library instead of the header file.  ^(Cautious
 ** programmers might include assert() statements in their application to
 ** verify that values returned by these interfaces match the macros in
 ** the header, and thus insure that the application is
@@ -670,19 +650,20 @@ extern "C" {
 ** <blockquote><pre>
 ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
 ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
-** assert( strcmp(sqlite3_libversion,SQLITE_VERSION)==0 );
-** </pre></blockquote>
-**
-** The sqlite3_libversion() function returns the same information as is
-** in the sqlite3_version[] string constant.  The function is provided
-** for use in DLLs since DLL users usually do not have direct access to string
-** constants within the DLL.  Similarly, the sqlite3_sourceid() function
-** returns the same information as is in the [SQLITE_SOURCE_ID] #define of
-** the header file.
+** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
+** </pre></blockquote>)^
+**
+** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
+** macro.  ^The sqlite3_libversion() function returns a pointer to the
+** to the sqlite3_version[] string constant.  The sqlite3_libversion()
+** function is provided for use in DLLs since DLL users usually do not have
+** direct access to string constants within the DLL.  ^The
+** sqlite3_libversion_number() function returns an integer equal to
+** [SQLITE_VERSION_NUMBER].  ^The sqlite3_sourceid() function a pointer
+** to a string constant whose value is the same as the [SQLITE_SOURCE_ID]
+** C preprocessor macro.
 **
 ** See also: [sqlite_version()] and [sqlite_source_id()].
-**
-** Requirements: [H10021] [H10022] [H10023]
 */
 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
 SQLITE_API const char *sqlite3_libversion(void);
@@ -690,7 +671,11 @@ SQLITE_API const char *sqlite3_sourceid(void);
 SQLITE_API int sqlite3_libversion_number(void);
 
 /*
-** CAPI3REF: Test To See If The Library Is Threadsafe {H10100} <S60100>
+** CAPI3REF: Test To See If The Library Is Threadsafe
+**
+** ^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 can be compiled with or without mutexes.  When
 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
@@ -702,7 +687,7 @@ SQLITE_API int sqlite3_libversion_number(void);
 ** Enabling mutexes incurs a measurable performance penalty.
 ** So if speed is of utmost importance, it makes sense to disable
 ** the mutexes.  But for maximum safety, mutexes should be enabled.
-** The default behavior is for mutexes to be enabled.
+** ^The default behavior is for mutexes to be enabled.
 **
 ** This interface can be used by an application to make sure that the
 ** version of SQLite that it is linking against was compiled with
@@ -710,21 +695,21 @@ SQLITE_API int sqlite3_libversion_number(void);
 **
 ** This interface only reports on the compile-time mutex setting
 ** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with
-** SQLITE_THREADSAFE=1 then mutexes are enabled by default but
+** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
 ** can be fully or partially disabled using a call to [sqlite3_config()]
 ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
-** or [SQLITE_CONFIG_MUTEX].  The return value of this function shows
-** only the default compile-time setting, not any run-time changes
-** to that setting.
+** or [SQLITE_CONFIG_MUTEX].  ^(The return value of the
+** sqlite3_threadsafe() function shows only the compile-time setting of
+** thread safety, not any run-time changes to that setting made by
+** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
+** is unchanged by calls to sqlite3_config().)^
 **
 ** See the [threading mode] documentation for additional information.
-**
-** Requirements: [H10101] [H10102]
 */
 SQLITE_API int sqlite3_threadsafe(void);
 
 /*
-** CAPI3REF: Database Connection Handle {H12000} <S40200>
+** CAPI3REF: Database Connection Handle
 ** KEYWORDS: {database connection} {database connections}
 **
 ** Each open SQLite database is represented by a pointer to an instance of
@@ -739,7 +724,7 @@ SQLITE_API int sqlite3_threadsafe(void);
 typedef struct sqlite3 sqlite3;
 
 /*
-** CAPI3REF: 64-Bit Integer Types {H10200} <S10110>
+** CAPI3REF: 64-Bit Integer Types
 ** KEYWORDS: sqlite_int64 sqlite_uint64
 **
 ** Because there is no cross-platform way to specify 64-bit integer types
@@ -749,7 +734,10 @@ typedef struct sqlite3 sqlite3;
 ** The sqlite_int64 and sqlite_uint64 types are supported for backwards
 ** compatibility only.
 **
-** Requirements: [H10201] [H10202]
+** ^The sqlite3_int64 and sqlite_int64 types can store integer values
+** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
+** sqlite3_uint64 and sqlite_uint64 types can store integer values 
+** between 0 and +18446744073709551615 inclusive.
 */
 #ifdef SQLITE_INT64_TYPE
   typedef SQLITE_INT64_TYPE sqlite_int64;
@@ -773,34 +761,28 @@ typedef sqlite_uint64 sqlite3_uint64;
 #endif
 
 /*
-** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200>
+** CAPI3REF: Closing A Database Connection
 **
-** This routine is the destructor for the [sqlite3] object.
+** ^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.
 **
-** Applications should [sqlite3_finalize | finalize] all [prepared statements]
+** Applications must [sqlite3_finalize | finalize] all [prepared statements]
 ** and [sqlite3_blob_close | close] all [BLOB handles] associated with
-** the [sqlite3] object prior to attempting to close the object.
-** The [sqlite3_next_stmt()] interface can be used to locate all
-** [prepared statements] associated with a [database connection] if desired.
-** Typical code might look like this:
+** the [sqlite3] object prior to attempting to close the object.  ^If
+** sqlite3_close() is called on a [database connection] that still has
+** outstanding [prepared statements] or [BLOB handles], then it returns
+** SQLITE_BUSY.
 **
-** <blockquote><pre>
-** sqlite3_stmt *pStmt;
-** while( (pStmt = sqlite3_next_stmt(db, 0))!=0 ){
-**     sqlite3_finalize(pStmt);
-** }
-** </pre></blockquote>
-**
-** If [sqlite3_close()] is invoked while a transaction is open,
+** ^If [sqlite3_close()] is invoked while a transaction is open,
 ** the transaction is automatically rolled back.
 **
 ** The C parameter to [sqlite3_close(C)] must be either a NULL
 ** pointer or an [sqlite3] object pointer obtained
 ** from [sqlite3_open()], [sqlite3_open16()], or
 ** [sqlite3_open_v2()], and not previously closed.
-**
-** Requirements:
-** [H12011] [H12012] [H12013] [H12014] [H12015] [H12019]
+** ^Calling sqlite3_close() with a NULL pointer argument is a 
+** harmless no-op.
 */
 SQLITE_API int sqlite3_close(sqlite3 *);
 
@@ -812,48 +794,65 @@ SQLITE_API int sqlite3_close(sqlite3 *);
 typedef int (*sqlite3_callback)(void*,int,char**, char**);
 
 /*
-** CAPI3REF: One-Step Query Execution Interface {H12100} <S10000>
-**
-** The sqlite3_exec() interface is a convenient way of running one or more
-** SQL statements without having to write a lot of C code.  The UTF-8 encoded
-** SQL statements are passed in as the second parameter to sqlite3_exec().
-** The statements are evaluated one by one until either an error or
-** an interrupt is encountered, or until they are all done.  The 3rd parameter
-** is an optional callback that is invoked once for each row of any query
-** results produced by the SQL statements.  The 5th parameter tells where
-** to write any error messages.
+** CAPI3REF: One-Step Query Execution Interface
+**
+** The sqlite3_exec() interface is a convenience wrapper around
+** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
+** that allows an application to run multiple statements of SQL
+** without having to use a lot of C code. 
+**
+** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
+** semicolon-separate SQL statements passed into its 2nd argument,
+** in the context of the [database connection] passed in as its 1st
+** argument.  ^If the callback function of the 3rd argument to
+** sqlite3_exec() is not NULL, then it is invoked for each result row
+** coming out of the evaluated SQL statements.  ^The 4th argument to
+** to sqlite3_exec() is relayed through to the 1st argument of each
+** callback invocation.  ^If the callback pointer to sqlite3_exec()
+** is NULL, then no callback is ever invoked and result rows are
+** ignored.
+**
+** ^If an error occurs while evaluating the SQL statements passed into
+** sqlite3_exec(), then execution of the current statement stops and
+** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()
+** is not NULL then any error message is written into memory obtained
+** from [sqlite3_malloc()] and passed back through the 5th parameter.
+** To avoid memory leaks, the application should invoke [sqlite3_free()]
+** on error message strings returned through the 5th parameter of
+** of sqlite3_exec() after the error message string is no longer needed.
+** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
+** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
+** NULL before returning.
+**
+** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
+** routine returns SQLITE_ABORT without invoking the callback again and
+** without running any subsequent SQL statements.
+**
+** ^The 2nd argument to the sqlite3_exec() callback function is the
+** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()
+** callback is an array of pointers to strings obtained as if from
+** [sqlite3_column_text()], one for each column.  ^If an element of a
+** result row is NULL then the corresponding string pointer for the
+** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the
+** sqlite3_exec() callback is an array of pointers to strings where each
+** entry represents the name of corresponding result column as obtained
+** from [sqlite3_column_name()].
+**
+** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
+** to an empty string, or a pointer that contains only whitespace and/or 
+** SQL comments, then no SQL statements are evaluated and the database
+** is not changed.
+**
+** Restrictions:
 **
-** The error message passed back through the 5th parameter is held
-** in memory obtained from [sqlite3_malloc()].  To avoid a memory leak,
-** the calling application should call [sqlite3_free()] on any error
-** message returned through the 5th parameter when it has finished using
-** the error message.
-**
-** If the SQL statement in the 2nd parameter is NULL or an empty string
-** or a string containing only whitespace and comments, then no SQL
-** statements are evaluated and the database is not changed.
-**
-** The sqlite3_exec() interface is implemented in terms of
-** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
-** The sqlite3_exec() routine does nothing to the database that cannot be done
-** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
-**
-** The first parameter to [sqlite3_exec()] must be an valid and open
-** [database connection].
-**
-** The database connection must not be closed while
-** [sqlite3_exec()] is running.
-**
-** The calling function should use [sqlite3_free()] to free
-** the memory that *errmsg is left pointing at once the error
-** message is no longer needed.
-**
-** The SQL statement text in the 2nd parameter to [sqlite3_exec()]
-** must remain unchanged while [sqlite3_exec()] is running.
-**
-** Requirements:
-** [H12101] [H12102] [H12104] [H12105] [H12107] [H12110] [H12113] [H12116]
-** [H12119] [H12122] [H12125] [H12131] [H12134] [H12137] [H12138]
+** <ul>
+** <li> The application must insure that the 1st parameter to sqlite3_exec()
+**      is a valid and open [database connection].
+** <li> The application must not close [database connection] specified by
+**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
+** <li> The application must not modify the SQL statement text passed into
+**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
+** </ul>
 */
 SQLITE_API int sqlite3_exec(
   sqlite3*,                                  /* An open database */
@@ -864,7 +863,7 @@ SQLITE_API int sqlite3_exec(
 );
 
 /*
-** CAPI3REF: Result Codes {H10210} <S10700>
+** CAPI3REF: Result Codes
 ** KEYWORDS: SQLITE_OK {error code} {error codes}
 ** KEYWORDS: {result code} {result codes}
 **
@@ -908,7 +907,7 @@ SQLITE_API int sqlite3_exec(
 /* end-of-error-codes */
 
 /*
-** CAPI3REF: Extended Result Codes {H10220} <S10700>
+** CAPI3REF: Extended Result Codes
 ** KEYWORDS: {extended error code} {extended error codes}
 ** KEYWORDS: {extended result code} {extended result codes}
 **
@@ -950,7 +949,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED | (1<<8) )
 
 /*
-** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
+** CAPI3REF: Flags For File Open Operations
 **
 ** These bit values are intended for use in the
 ** 3rd parameter to the [sqlite3_open_v2()] interface and
@@ -975,7 +974,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */
 
 /*
-** CAPI3REF: Device Characteristics {H10240} <H11120>
+** CAPI3REF: Device Characteristics
 **
 ** The xDeviceCapabilities method of the [sqlite3_io_methods]
 ** object returns an integer which is a vector of the these
@@ -1007,7 +1006,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_IOCAP_SEQUENTIAL      0x00000400
 
 /*
-** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310>
+** CAPI3REF: File Locking Levels
 **
 ** SQLite uses one of these integer values as the second
 ** argument to calls it makes to the xLock() and xUnlock() methods
@@ -1020,7 +1019,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_LOCK_EXCLUSIVE     4
 
 /*
-** CAPI3REF: Synchronization Type Flags {H10260} <H11120>
+** CAPI3REF: Synchronization Type Flags
 **
 ** When SQLite invokes the xSync() method of an
 ** [sqlite3_io_methods] object it uses a combination of
@@ -1038,7 +1037,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_SYNC_DATAONLY      0x00010
 
 /*
-** CAPI3REF: OS Interface Open File Handle {H11110} <S20110>
+** CAPI3REF: OS Interface Open File Handle
 **
 ** An [sqlite3_file] object represents an open file in the 
 ** [sqlite3_vfs | OS interface layer].  Individual OS interface
@@ -1054,7 +1053,7 @@ struct sqlite3_file {
 };
 
 /*
-** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110>
+** CAPI3REF: OS Interface File Virtual Methods Object
 **
 ** Every file opened by the [sqlite3_vfs] xOpen method populates an
 ** [sqlite3_file] object (or, more commonly, a subclass of the
@@ -1159,7 +1158,7 @@ struct sqlite3_io_methods {
 };
 
 /*
-** CAPI3REF: Standard File Control Opcodes {H11310} <S30800>
+** CAPI3REF: Standard File Control Opcodes
 **
 ** These integer constants are opcodes for the xFileControl method
 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
@@ -1179,7 +1178,7 @@ struct sqlite3_io_methods {
 #define SQLITE_LAST_ERRNO             4
 
 /*
-** CAPI3REF: Mutex Handle {H17110} <S20130>
+** CAPI3REF: Mutex Handle
 **
 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
 ** abstract type for a mutex object.  The SQLite core never looks
@@ -1191,7 +1190,7 @@ struct sqlite3_io_methods {
 typedef struct sqlite3_mutex sqlite3_mutex;
 
 /*
-** CAPI3REF: OS Interface Object {H11140} <S20100>
+** CAPI3REF: OS Interface Object
 **
 ** An instance of the sqlite3_vfs object defines the interface between
 ** the SQLite core and the underlying operating system.  The "vfs"
@@ -1345,10 +1344,10 @@ struct sqlite3_vfs {
 };
 
 /*
-** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140>
+** CAPI3REF: Flags for the xAccess VFS method
 **
 ** These integer constants can be used as the third parameter to
-** the xAccess method of an [sqlite3_vfs] object. {END}  They determine
+** the xAccess method of an [sqlite3_vfs] object.  They determine
 ** what kind of permissions the xAccess method is looking for.
 ** With SQLITE_ACCESS_EXISTS, the xAccess method
 ** simply checks whether the file exists.
@@ -1362,39 +1361,48 @@ struct sqlite3_vfs {
 #define SQLITE_ACCESS_READ      2
 
 /*
-** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100>
+** CAPI3REF: Initialize The SQLite Library
 **
-** The sqlite3_initialize() routine initializes the
-** SQLite library.  The sqlite3_shutdown() routine
+** ^The sqlite3_initialize() routine initializes the
+** SQLite library.  ^The sqlite3_shutdown() routine
 ** deallocates any resources that were allocated by sqlite3_initialize().
+** These routines are designed to aid in process initialization and
+** shutdown on embedded systems.  Workstation applications using
+** SQLite normally do not need to invoke either of these routines.
 **
 ** A call to sqlite3_initialize() is an "effective" call if it is
 ** the first time sqlite3_initialize() is invoked during the lifetime of
 ** the process, or if it is the first time sqlite3_initialize() is invoked
-** following a call to sqlite3_shutdown().  Only an effective call
+** following a call to sqlite3_shutdown().  ^(Only an effective call
 ** of sqlite3_initialize() does any initialization.  All other calls
-** are harmless no-ops.
+** are harmless no-ops.)^
 **
 ** A call to sqlite3_shutdown() is an "effective" call if it is the first
-** call to sqlite3_shutdown() since the last sqlite3_initialize().  Only
+** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only
 ** an effective call to sqlite3_shutdown() does any deinitialization.
-** All other calls to sqlite3_shutdown() are harmless no-ops.
+** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
 **
-** Among other things, sqlite3_initialize() shall invoke
-** sqlite3_os_init().  Similarly, sqlite3_shutdown()
-** shall invoke sqlite3_os_end().
+** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
+** is not.  The sqlite3_shutdown() interface must only be called from a
+** single thread.  All open [database connections] must be closed and all
+** other SQLite resources must be deallocated prior to invoking
+** sqlite3_shutdown().
 **
-** The sqlite3_initialize() routine returns [SQLITE_OK] on success.
-** If for some reason, sqlite3_initialize() is unable to initialize
+** Among other things, ^sqlite3_initialize() will invoke
+** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()
+** will invoke sqlite3_os_end().
+**
+** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
+** ^If for some reason, sqlite3_initialize() is unable to initialize
 ** the library (perhaps it is unable to allocate a needed resource such
 ** as a mutex) it returns an [error code] other than [SQLITE_OK].
 **
-** The sqlite3_initialize() routine is called internally by many other
+** ^The sqlite3_initialize() routine is called internally by many other
 ** SQLite interfaces so that an application usually does not need to
 ** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]
 ** calls sqlite3_initialize() so the SQLite library will be automatically
 ** initialized when [sqlite3_open()] is called if it has not be initialized
-** already.  However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
+** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
 ** compile-time option, then the automatic calls to sqlite3_initialize()
 ** are omitted and the application must call sqlite3_initialize() directly
 ** prior to using any other SQLite interface.  For maximum portability,
@@ -1433,7 +1441,7 @@ SQLITE_API int sqlite3_os_init(void);
 SQLITE_API int sqlite3_os_end(void);
 
 /*
-** CAPI3REF: Configuring The SQLite Library {H14100} <S20000><S30200>
+** CAPI3REF: Configuring The SQLite Library
 ** EXPERIMENTAL
 **
 ** The sqlite3_config() interface is used to make global configuration
@@ -1447,7 +1455,9 @@ SQLITE_API int sqlite3_os_end(void);
 ** threads while sqlite3_config() is running.  Furthermore, sqlite3_config()
 ** may only be invoked prior to library initialization using
 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
-** Note, however, that sqlite3_config() can be called as part of the
+** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
+** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
+** Note, however, that ^sqlite3_config() can be called as part of the
 ** implementation of an application-defined [sqlite3_os_init()].
 **
 ** The first argument to sqlite3_config() is an integer
@@ -1456,26 +1466,21 @@ SQLITE_API int sqlite3_os_end(void);
 ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option]
 ** in the first argument.
 **
-** When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
-** If the option is unknown or SQLite is unable to set the option
+** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
+** ^If the option is unknown or SQLite is unable to set the option
 ** then this routine returns a non-zero [error code].
-**
-** Requirements:
-** [H14103] [H14106] [H14120] [H14123] [H14126] [H14129] [H14132] [H14135]
-** [H14138] [H14141] [H14144] [H14147] [H14150] [H14153] [H14156] [H14159]
-** [H14162] [H14165] [H14168]
 */
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
 
 /*
-** CAPI3REF: Configure database connections  {H14200} <S20000>
+** 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
 ** [sqlite3_config()] except that the changes apply to a single
 ** [database connection] (specified in the first argument).  The
-** sqlite3_db_config() interface can only be used immediately after
+** sqlite3_db_config() interface should only be used immediately after
 ** the database connection is created using [sqlite3_open()],
 ** [sqlite3_open16()], or [sqlite3_open_v2()].  
 **
@@ -1486,13 +1491,13 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
 ** New verbs are likely to be added in future releases of SQLite.
 ** Additional arguments depend on the verb.
 **
-** Requirements:
-** [H14203] [H14206] [H14209] [H14212] [H14215]
+** ^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, ...);
 
 /*
-** CAPI3REF: Memory Allocation Routines {H10155} <S20120>
+** CAPI3REF: Memory Allocation Routines
 ** EXPERIMENTAL
 **
 ** An instance of this object defines the interface between SQLite
@@ -1522,7 +1527,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
 ** The xRealloc method must work like realloc() from the standard C library
 ** with the exception that if the second argument to xRealloc is zero,
 ** xRealloc must be a no-op - it must not perform any allocation or
-** deallocation.  SQLite guaranteeds that the second argument to
+** deallocation.  ^SQLite guarantees that the second argument to
 ** xRealloc is always a value returned by a prior call to xRoundup.
 ** And so in cases where xRoundup always returns a positive number,
 ** xRealloc can perform exactly as the standard library realloc() and
@@ -1574,7 +1579,7 @@ struct sqlite3_mem_methods {
 };
 
 /*
-** CAPI3REF: Configuration Options {H10160} <S20000>
+** CAPI3REF: Configuration Options
 ** EXPERIMENTAL
 **
 ** These constants are the available integer configuration options that
@@ -1589,22 +1594,33 @@ struct sqlite3_mem_methods {
 **
 ** <dl>
 ** <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
-** <dd>There are no arguments to this option.  This option disables
+** <dd>There are no arguments to this option.  ^This option sets the
+** [threading mode] to Single-thread.  In other words, it disables
 ** all mutexing and puts SQLite into a mode where it can only be used
-** by a single thread.</dd>
+** by a single thread.   ^If SQLite is compiled with
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
+** it is not possible to change the [threading mode] from its default
+** value of Single-thread and so [sqlite3_config()] will return 
+** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
+** configuration option.</dd>
 **
 ** <dt>SQLITE_CONFIG_MULTITHREAD</dt>
-** <dd>There are no arguments to this option.  This option disables
+** <dd>There are no arguments to this option.  ^This option sets the
+** [threading mode] to Multi-thread.  In other words, it disables
 ** mutexing on [database connection] and [prepared statement] objects.
 ** The application is responsible for serializing access to
 ** [database connections] and [prepared statements].  But other mutexes
 ** are enabled so that SQLite will be safe to use in a multi-threaded
 ** environment as long as no two threads attempt to use the same
-** [database connection] at the same time.  See the [threading mode]
-** documentation for additional information.</dd>
+** [database connection] at the same time.  ^If SQLite is compiled with
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
+** it is not possible to set the Multi-thread [threading mode] and
+** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
+** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
 **
 ** <dt>SQLITE_CONFIG_SERIALIZED</dt>
-** <dd>There are no arguments to this option.  This option enables
+** <dd>There are no arguments to this option.  ^This option sets the
+** [threading mode] to Serialized. In other words, this option enables
 ** all mutexes including the recursive
 ** mutexes on [database connection] and [prepared statement] objects.
 ** In this mode (which is the default when SQLite is compiled with
@@ -1612,55 +1628,63 @@ struct sqlite3_mem_methods {
 ** to [database connections] and [prepared statements] so that the
 ** application is free to use the same [database connection] or the
 ** same [prepared statement] in different threads at the same time.
-** See the [threading mode] documentation for additional information.</dd>
+** ^If SQLite is compiled with
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
+** it is not possible to set the Serialized [threading mode] and
+** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
+** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
 **
 ** <dt>SQLITE_CONFIG_MALLOC</dt>
-** <dd>This option takes a single argument which is a pointer to an
+** <dd> ^(This option takes a single argument which is a pointer to an
 ** instance of the [sqlite3_mem_methods] structure.  The argument specifies
 ** alternative low-level memory allocation routines to be used in place of
-** the memory allocation routines built into SQLite.</dd>
+** the memory allocation routines built into SQLite.)^ ^SQLite makes
+** its own private copy of the content of the [sqlite3_mem_methods] structure
+** before the [sqlite3_config()] call returns.</dd>
 **
 ** <dt>SQLITE_CONFIG_GETMALLOC</dt>
-** <dd>This option takes a single argument which is a pointer to an
+** <dd> ^(This option takes a single argument which is a pointer to an
 ** instance of the [sqlite3_mem_methods] structure.  The [sqlite3_mem_methods]
-** structure is filled with the currently defined memory allocation routines.
+** structure is filled with the currently defined memory allocation routines.)^
 ** This option can be used to overload the default memory allocation
 ** routines with a wrapper that simulations memory allocation failure or
-** tracks memory usage, for example.</dd>
+** tracks memory usage, for example. </dd>
 **
 ** <dt>SQLITE_CONFIG_MEMSTATUS</dt>
-** <dd>This option takes single argument of type int, interpreted as a 
+** <dd> ^This option takes single argument of type int, interpreted as a 
 ** boolean, which enables or disables the collection of memory allocation 
-** statistics. When disabled, the following SQLite interfaces become 
-** non-operational:
+** statistics. ^(When memory allocation statistics are disabled, the 
+** following SQLite interfaces become non-operational:
 **   <ul>
 **   <li> [sqlite3_memory_used()]
 **   <li> [sqlite3_memory_highwater()]
 **   <li> [sqlite3_soft_heap_limit()]
 **   <li> [sqlite3_status()]
-**   </ul>
+**   </ul>)^
+** ^Memory allocation statistics are enabled by default unless SQLite is
+** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
+** allocation statistics are disabled by default.
 ** </dd>
 **
 ** <dt>SQLITE_CONFIG_SCRATCH</dt>
-** <dd>This option specifies a static memory buffer that SQLite can use for
+** <dd> ^This option specifies a static memory buffer that SQLite can use for
 ** scratch memory.  There are three arguments:  A pointer an 8-byte
 ** 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.
-** The first argument should pointer to an 8-byte aligned buffer
+** 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 at once per thread, so
-** N should be set to the expected maximum number of threads.  The sz
-** parameter should be 6 times the size of the largest database page size.
-** Scratch buffers are used as part of the btree balance operation.  If
-** The btree balancer needs additional memory beyond what is provided by
-** scratch buffers or if no scratch buffer space is specified, then SQLite
-** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd>
+** ^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 
+** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
 **
 ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
-** <dd>This option specifies a static memory buffer that SQLite can use for
+** <dd> ^This option specifies a static memory buffer that SQLite can use for
 ** the database page cache with the default page cache implemenation.  
 ** This configuration should not be used if an application-define page
 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
@@ -1668,28 +1692,28 @@ struct sqlite3_mem_methods {
 ** memory, the size of each page buffer (sz), and the number of pages (N).
 ** The sz argument should be the size of the largest database page
 ** (a power of two between 512 and 32768) plus a little extra for each
-** page header.  The page header size is 20 to 40 bytes depending on
-** the host architecture.  It is harmless, apart from the wasted memory,
+** page header.  ^The page header size is 20 to 40 bytes depending on
+** the host architecture.  ^It is harmless, apart from the wasted memory,
 ** to make sz a little too large.  The first
 ** argument should point to an allocation of at least sz*N bytes of memory.
-** SQLite will use the memory provided by the first argument to satisfy its
-** memory needs for the first N pages that it adds to cache.  If additional
+** ^SQLite will use the memory provided by the first argument to satisfy its
+** 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 
+** ^The implementation might use one or more of the N buffers to hold 
 ** memory accounting information. The pointer in the first argument must
 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
 ** will be undefined.</dd>
 **
 ** <dt>SQLITE_CONFIG_HEAP</dt>
-** <dd>This option specifies a static memory buffer that SQLite will use
+** <dd> ^This option specifies a static memory buffer that SQLite will use
 ** for all of its dynamic memory allocation needs beyond those provided
 ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
 ** There are three arguments: An 8-byte aligned pointer to the memory,
 ** the number of bytes in the memory buffer, and the minimum allocation size.
-** If the first pointer (the memory pointer) is NULL, then SQLite reverts
+** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
 ** to using its default memory allocator (the system malloc() implementation),
-** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  If the
+** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the
 ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
 ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
 ** allocator is engaged to handle all of SQLites memory allocation needs.
@@ -1697,39 +1721,50 @@ struct sqlite3_mem_methods {
 ** boundary or subsequent behavior of SQLite will be undefined.</dd>
 **
 ** <dt>SQLITE_CONFIG_MUTEX</dt>
-** <dd>This option takes a single argument which is a pointer to an
+** <dd> ^(This option takes a single argument which is a pointer to an
 ** instance of the [sqlite3_mutex_methods] structure.  The argument specifies
 ** alternative low-level mutex routines to be used in place
-** the mutex routines built into SQLite.</dd>
+** the mutex routines built into SQLite.)^  ^SQLite makes a copy of the
+** content of the [sqlite3_mutex_methods] structure before the call to
+** [sqlite3_config()] returns. ^If SQLite is compiled with
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
+** the entire mutexing subsystem is omitted from the build and hence calls to
+** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
+** return [SQLITE_ERROR].</dd>
 **
 ** <dt>SQLITE_CONFIG_GETMUTEX</dt>
-** <dd>This option takes a single argument which is a pointer to an
+** <dd> ^(This option takes a single argument which is a pointer to an
 ** instance of the [sqlite3_mutex_methods] structure.  The
 ** [sqlite3_mutex_methods]
-** structure is filled with the currently defined mutex routines.
+** structure is filled with the currently defined mutex routines.)^
 ** This option can be used to overload the default mutex allocation
 ** routines with a wrapper used to track mutex usage for performance
-** profiling or testing, for example.</dd>
+** profiling or testing, for example.   ^If SQLite is compiled with
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
+** the entire mutexing subsystem is omitted from the build and hence calls to
+** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
+** return [SQLITE_ERROR].</dd>
 **
 ** <dt>SQLITE_CONFIG_LOOKASIDE</dt>
-** <dd>This option takes two arguments that determine the default
-** memory allocation lookaside optimization.  The first argument is the
+** <dd> ^(This option takes two arguments that determine the default
+** memory allocation for the lookaside memory allocator on each
+** [database connection].  The first argument is the
 ** size of each lookaside buffer slot and the second is the number of
-** slots allocated to each database connection.  This option sets the
-** <i>default</i> lookaside size.  The [SQLITE_DBCONFIG_LOOKASIDE]
+** slots allocated to each database connection.)^  ^(This option sets the
+** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
 ** verb to [sqlite3_db_config()] can be used to change the lookaside
-** configuration on individual connections.</dd>
+** configuration on individual connections.)^ </dd>
 **
 ** <dt>SQLITE_CONFIG_PCACHE</dt>
-** <dd>This option takes a single argument which is a pointer to
+** <dd> ^(This option takes a single argument which is a pointer to
 ** an [sqlite3_pcache_methods] object.  This object specifies the interface
-** to a custom page cache implementation.  SQLite makes a copy of the
+** to a custom page cache implementation.)^  ^SQLite makes a copy of the
 ** object and uses it for page cache memory allocations.</dd>
 **
 ** <dt>SQLITE_CONFIG_GETPCACHE</dt>
-** <dd>This option takes a single argument which is a pointer to an
+** <dd> ^(This option takes a single argument which is a pointer to an
 ** [sqlite3_pcache_methods] object.  SQLite copies of the current
-** page cache implementation into that object.</dd>
+** page cache implementation into that object.)^ </dd>
 **
 ** </dl>
 */
@@ -1750,7 +1785,7 @@ struct sqlite3_mem_methods {
 #define SQLITE_CONFIG_GETPCACHE    15  /* sqlite3_pcache_methods* */
 
 /*
-** CAPI3REF: Configuration Options {H10170} <S20000>
+** CAPI3REF: Configuration Options
 ** EXPERIMENTAL
 **
 ** These constants are the available integer configuration options that
@@ -1759,23 +1794,25 @@ struct sqlite3_mem_methods {
 ** New configuration options may be added in future releases of SQLite.
 ** Existing configuration options might be discontinued.  Applications
 ** should check the return code from [sqlite3_db_config()] to make sure that
-** the call worked.  The [sqlite3_db_config()] interface will return a
+** the call worked.  ^The [sqlite3_db_config()] interface will return a
 ** non-zero [error code] if a discontinued or unsupported configuration option
 ** is invoked.
 **
 ** <dl>
 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
-** <dd>This option takes three additional arguments that determine the 
+** <dd> ^This option takes three additional arguments that determine the 
 ** [lookaside memory allocator] configuration for the [database connection].
-** The first argument (the third parameter to [sqlite3_db_config()] is a
+** ^The first argument (the third parameter to [sqlite3_db_config()] is a
 ** pointer to an memory buffer to use for lookaside memory.
-** The first argument may be NULL in which case SQLite will allocate the
-** lookaside buffer itself using [sqlite3_malloc()].  The second argument is the
-** size of each lookaside buffer slot and the third argument is the number of
+** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
+** may be NULL in which case SQLite will allocate the
+** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
+** size of each lookaside buffer slot.  ^The third argument is the number of
 ** slots.  The size of the buffer in the first argument must be greater than
 ** 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 is not
-** a multiple of 8, it is internally rounded down to the next smaller
+** 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>
 **
 ** </dl>
@@ -1784,52 +1821,49 @@ struct sqlite3_mem_methods {
 
 
 /*
-** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700>
+** CAPI3REF: Enable Or Disable Extended Result Codes
 **
-** The sqlite3_extended_result_codes() routine enables or disables the
-** [extended result codes] feature of SQLite. The extended result
-** codes are disabled by default for historical compatibility considerations.
-**
-** Requirements:
-** [H12201] [H12202]
+** ^The sqlite3_extended_result_codes() routine enables or disables the
+** [extended result codes] feature of SQLite. ^The extended result
+** codes are disabled by default for historical compatibility.
 */
 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
 
 /*
-** CAPI3REF: Last Insert Rowid {H12220} <S10700>
+** CAPI3REF: Last Insert Rowid
 **
-** Each entry in an SQLite table has a unique 64-bit signed
-** integer key called the [ROWID | "rowid"]. The rowid is always available
+** ^Each entry in an SQLite table has a unique 64-bit signed
+** integer key called the [ROWID | "rowid"]. ^The rowid is always available
 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
-** names are not also used by explicitly declared columns. If
+** names are not also used by explicitly declared columns. ^If
 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
 ** is another alias for the rowid.
 **
-** This routine returns the [rowid] of the most recent
+** ^This routine returns the [rowid] of the most recent
 ** successful [INSERT] into the database from the [database connection]
-** in the first argument.  If no successful [INSERT]s
+** in the first argument.  ^If no successful [INSERT]s
 ** have ever occurred on that database connection, zero is returned.
 **
-** If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
+** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
 ** row is returned by this routine as long as the trigger is running.
 ** But once the trigger terminates, the value returned by this routine
-** reverts to the last value inserted before the trigger fired.
+** reverts to the last value inserted before the trigger fired.)^
 **
-** An [INSERT] that fails due to a constraint violation is not a
+** ^An [INSERT] that fails due to a constraint violation is not a
 ** successful [INSERT] and does not change the value returned by this
-** routine.  Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
+** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
 ** and INSERT OR ABORT make no changes to the return value of this
-** routine when their insertion fails.  When INSERT OR REPLACE
+** routine when their insertion fails.  ^(When INSERT OR REPLACE
 ** encounters a constraint violation, it does not fail.  The
 ** INSERT continues to completion after deleting rows that caused
 ** the constraint problem so INSERT OR REPLACE will always change
-** the return value of this interface.
+** the return value of this interface.)^
 **
-** For the purposes of this routine, an [INSERT] is considered to
+** ^For the purposes of this routine, an [INSERT] is considered to
 ** be successful even if it is subsequently rolled back.
 **
-** Requirements:
-** [H12221] [H12223]
+** This function is accessible to SQL statements via the
+** [last_insert_rowid() SQL function].
 **
 ** If a separate thread performs a new [INSERT] on the same
 ** database connection while the [sqlite3_last_insert_rowid()]
@@ -1841,25 +1875,25 @@ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
 
 /*
-** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600>
+** CAPI3REF: Count The Number Of Rows Modified
 **
-** This function returns the number of database rows that were changed
+** ^This function returns the number of database rows that were changed
 ** or inserted or deleted by the most recently completed SQL statement
 ** on the [database connection] specified by the first parameter.
-** Only changes that are directly specified by the [INSERT], [UPDATE],
+** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
 ** or [DELETE] statement are counted.  Auxiliary changes caused by
-** triggers or [foreign key actions] are not counted. Use the
+** triggers or [foreign key actions] are not counted.)^ Use the
 ** [sqlite3_total_changes()] function to find the total number of changes
 ** including changes caused by triggers and foreign key actions.
 **
-** Changes to a view that are simulated by an [INSTEAD OF trigger]
+** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
 ** are not counted.  Only real table changes are counted.
 **
-** A "row change" is a change to a single row of a single table
+** ^(A "row change" is a change to a single row of a single table
 ** caused by an INSERT, DELETE, or UPDATE statement.  Rows that
 ** are changed as side effects of [REPLACE] constraint resolution,
 ** rollback, ABORT processing, [DROP TABLE], or by any other
-** mechanisms do not count as direct row changes.
+** mechanisms do not count as direct row changes.)^
 **
 ** A "trigger context" is a scope of execution that begins and
 ** ends with the script of a [CREATE TRIGGER | trigger]. 
@@ -1869,27 +1903,24 @@ SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
 ** new trigger context is entered for the duration of that one
 ** trigger.  Subtriggers create subcontexts for their duration.
 **
-** Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
+** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
 ** not create a new trigger context.
 **
-** This function returns the number of direct row changes in the
+** ^This function returns the number of direct row changes in the
 ** most recent INSERT, UPDATE, or DELETE statement within the same
 ** trigger context.
 **
-** Thus, when called from the top level, this function returns the
+** ^Thus, when called from the top level, this function returns the
 ** number of changes in the most recent INSERT, UPDATE, or DELETE
-** that also occurred at the top level.  Within the body of a trigger,
+** that also occurred at the top level.  ^(Within the body of a trigger,
 ** the sqlite3_changes() interface can be called to find the number of
 ** changes in the most recently completed INSERT, UPDATE, or DELETE
 ** statement within the body of the same trigger.
 ** However, the number returned does not include changes
-** caused by subtriggers since those have their own context.
-**
-** See also the [sqlite3_total_changes()] interface and the
-** [count_changes pragma].
+** caused by subtriggers since those have their own context.)^
 **
-** Requirements:
-** [H12241] [H12243]
+** See also the [sqlite3_total_changes()] interface, the
+** [count_changes pragma], and the [changes() SQL function].
 **
 ** If a separate thread makes changes on the same database connection
 ** while [sqlite3_changes()] is running then the value returned
@@ -1898,26 +1929,24 @@ SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
 SQLITE_API int sqlite3_changes(sqlite3*);
 
 /*
-** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
+** CAPI3REF: Total Number Of Rows Modified
 **
-** This function returns the number of row changes caused by [INSERT],
+** ^This function returns the number of row changes caused by [INSERT],
 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
-** The count includes all changes from all [CREATE TRIGGER | trigger] 
-** contexts and changes made by [foreign key actions]. However,
+** ^(The count returned by sqlite3_total_changes() includes all changes
+** from all [CREATE TRIGGER | trigger] contexts and changes made by
+** [foreign key actions]. However,
 ** the count does not include changes used to implement [REPLACE] constraints,
 ** do rollbacks or ABORT processing, or [DROP TABLE] processing.  The
 ** count does not include rows of views that fire an [INSTEAD OF trigger],
 ** though if the INSTEAD OF trigger makes changes of its own, those changes 
-** are counted.
-** The changes are counted as soon as the statement that makes them is
-** completed (when the statement handle is passed to [sqlite3_reset()] or
-** [sqlite3_finalize()]).
-**
-** See also the [sqlite3_changes()] interface and the
-** [count_changes pragma].
+** are counted.)^
+** ^The sqlite3_total_changes() function counts the changes as soon as
+** the statement that makes them is completed (when the statement handle
+** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
 **
-** Requirements:
-** [H12261] [H12263]
+** See also the [sqlite3_changes()] interface, the
+** [count_changes pragma], and the [total_changes() SQL function].
 **
 ** If a separate thread makes changes on the same database connection
 ** while [sqlite3_total_changes()] is running then the value
@@ -1926,75 +1955,70 @@ SQLITE_API int sqlite3_changes(sqlite3*);
 SQLITE_API int sqlite3_total_changes(sqlite3*);
 
 /*
-** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500>
+** CAPI3REF: Interrupt A Long-Running Query
 **
-** This function causes any pending database operation to abort and
+** ^This function causes any pending database operation to abort and
 ** return at its earliest opportunity. This routine is typically
 ** called in response to a user action such as pressing "Cancel"
 ** or Ctrl-C where the user wants a long query operation to halt
 ** immediately.
 **
-** It is safe to call this routine from a thread different from the
+** ^It is safe to call this routine from a thread different from the
 ** thread that is currently running the database operation.  But it
 ** is not safe to call this routine with a [database connection] that
 ** is closed or might close before sqlite3_interrupt() returns.
 **
-** If an SQL operation is very nearly finished at the time when
+** ^If an SQL operation is very nearly finished at the time when
 ** sqlite3_interrupt() is called, then it might not have an opportunity
 ** to be interrupted and might continue to completion.
 **
-** An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
-** If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
+** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
+** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
 ** that is inside an explicit transaction, then the entire transaction
 ** will be rolled back automatically.
 **
-** The sqlite3_interrupt(D) call is in effect until all currently running
-** SQL statements on [database connection] D complete.  Any new SQL statements
+** ^The sqlite3_interrupt(D) call is in effect until all currently running
+** SQL statements on [database connection] D complete.  ^Any new SQL statements
 ** that are started after the sqlite3_interrupt() call and before the 
 ** running statements reaches zero are interrupted as if they had been
-** running prior to the sqlite3_interrupt() call.  New SQL statements
+** running prior to the sqlite3_interrupt() call.  ^New SQL statements
 ** that are started after the running statement count reaches zero are
 ** not effected by the sqlite3_interrupt().
-** A call to sqlite3_interrupt(D) that occurs when there are no running
+** ^A call to sqlite3_interrupt(D) that occurs when there are no running
 ** SQL statements is a no-op and has no effect on SQL statements
 ** that are started after the sqlite3_interrupt() call returns.
 **
-** Requirements:
-** [H12271] [H12272]
-**
 ** If the database connection closes while [sqlite3_interrupt()]
 ** is running then bad things will likely happen.
 */
 SQLITE_API void sqlite3_interrupt(sqlite3*);
 
 /*
-** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200>
+** CAPI3REF: Determine If An SQL Statement Is Complete
 **
 ** These routines are useful during command-line input to determine if the
 ** currently entered text seems to form a complete SQL statement or
 ** if additional input is needed before sending the text into
-** SQLite for parsing.  These routines return 1 if the input string
-** appears to be a complete SQL statement.  A statement is judged to be
+** SQLite for parsing.  ^These routines return 1 if the input string
+** appears to be a complete SQL statement.  ^A statement is judged to be
 ** complete if it ends with a semicolon token and is not a prefix of a
-** well-formed CREATE TRIGGER statement.  Semicolons that are embedded within
+** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within
 ** string literals or quoted identifier names or comments are not
 ** independent tokens (they are part of the token in which they are
-** embedded) and thus do not count as a statement terminator.  Whitespace
+** embedded) and thus do not count as a statement terminator.  ^Whitespace
 ** and comments that follow the final semicolon are ignored.
 **
-** These routines return 0 if the statement is incomplete.  If a
+** ^These routines return 0 if the statement is incomplete.  ^If a
 ** memory allocation fails, then SQLITE_NOMEM is returned.
 **
-** These routines do not parse the SQL statements thus
+** ^These routines do not parse the SQL statements thus
 ** will not detect syntactically incorrect SQL.
 **
-** If SQLite has not been initialized using [sqlite3_initialize()] prior 
+** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior 
 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
 ** automatically by sqlite3_complete16().  If that initialization fails,
 ** then the return value from sqlite3_complete16() will be non-zero
-** regardless of whether or not the input SQL is complete.
-**
-** Requirements: [H10511] [H10512]
+** regardless of whether or not the input SQL is complete.)^
 **
 ** The input to [sqlite3_complete()] must be a zero-terminated
 ** UTF-8 string.
@@ -2006,27 +2030,27 @@ SQLITE_API int sqlite3_complete(const char *sql);
 SQLITE_API int sqlite3_complete16(const void *sql);
 
 /*
-** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400>
+** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
 **
-** This routine sets a callback function that might be invoked whenever
+** ^This routine sets a callback function that might be invoked whenever
 ** an attempt is made to open a database table that another thread
 ** or process has locked.
 **
-** If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
-** is returned immediately upon encountering the lock. If the busy callback
-** is not NULL, then the callback will be invoked with two arguments.
+** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
+** is returned immediately upon encountering the lock.  ^If the busy callback
+** is not NULL, then the callback might be invoked with two arguments.
 **
-** The first argument to the handler is a copy of the void* pointer which
-** is the third argument to sqlite3_busy_handler().  The second argument to
-** the handler callback is the number of times that the busy handler has
-** been invoked for this locking event.  If the
+** ^The first argument to the busy handler is a copy of the void* pointer which
+** is the third argument to sqlite3_busy_handler().  ^The second argument to
+** the busy handler callback is the number of times that the busy handler has
+** been invoked for this locking event.  ^If the
 ** busy callback returns 0, then no additional attempts are made to
 ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
-** If the callback returns non-zero, then another attempt
+** ^If the callback returns non-zero, then another attempt
 ** is made to open the database for reading and the cycle repeats.
 **
 ** The presence of a busy handler does not guarantee that it will be invoked
-** when there is lock contention. If SQLite determines that invoking the busy
+** when there is lock contention. ^If SQLite determines that invoking the busy
 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
 ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.
 ** Consider a scenario where one process is holding a read lock that
@@ -2040,65 +2064,59 @@ SQLITE_API int sqlite3_complete16(const void *sql);
 ** will induce the first process to release its read lock and allow
 ** the second process to proceed.
 **
-** The default busy callback is NULL.
+** ^The default busy callback is NULL.
 **
-** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
+** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
 ** when SQLite is in the middle of a large transaction where all the
 ** changes will not fit into the in-memory cache.  SQLite will
 ** already hold a RESERVED lock on the database file, but it needs
 ** to promote this lock to EXCLUSIVE so that it can spill cache
 ** pages into the database file without harm to concurrent
-** readers.  If it is unable to promote the lock, then the in-memory
+** readers.  ^If it is unable to promote the lock, then the in-memory
 ** cache will be left in an inconsistent state and so the error
 ** code is promoted from the relatively benign [SQLITE_BUSY] to
-** the more severe [SQLITE_IOERR_BLOCKED].  This error code promotion
+** the more severe [SQLITE_IOERR_BLOCKED].  ^This error code promotion
 ** forces an automatic rollback of the changes.  See the
 ** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError">
 ** CorruptionFollowingBusyError</a> wiki page for a discussion of why
 ** this is important.
 **
-** There can only be a single busy handler defined for each
+** ^(There can only be a single busy handler defined for each
 ** [database connection].  Setting a new busy handler clears any
-** previously set handler.  Note that calling [sqlite3_busy_timeout()]
+** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]
 ** will also set or clear the busy handler.
 **
 ** The busy callback should not take any actions which modify the
 ** database connection that invoked the busy handler.  Any such actions
 ** result in undefined behavior.
 ** 
-** Requirements:
-** [H12311] [H12312] [H12314] [H12316] [H12318]
-**
 ** A busy handler must not close the database connection
 ** or [prepared statement] that invoked the busy handler.
 */
 SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
 
 /*
-** CAPI3REF: Set A Busy Timeout {H12340} <S40410>
+** CAPI3REF: Set A Busy Timeout
 **
-** This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
-** for a specified amount of time when a table is locked.  The handler
+** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
+** for a specified amount of time when a table is locked.  ^The handler
 ** will sleep multiple times until at least "ms" milliseconds of sleeping
-** have accumulated. {H12343} After "ms" milliseconds of sleeping,
+** have accumulated.  ^After at least "ms" milliseconds of sleeping,
 ** the handler returns 0 which causes [sqlite3_step()] to return
 ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].
 **
-** Calling this routine with an argument less than or equal to zero
+** ^Calling this routine with an argument less than or equal to zero
 ** turns off all busy handlers.
 **
-** There can only be a single busy handler for a particular
+** ^(There can only be a single busy handler for a particular
 ** [database connection] any any given moment.  If another busy handler
 ** was defined  (using [sqlite3_busy_handler()]) prior to calling
-** this routine, that other busy handler is cleared.
-**
-** Requirements:
-** [H12341] [H12343] [H12344]
+** this routine, that other busy handler is cleared.)^
 */
 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 
 /*
-** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000>
+** CAPI3REF: Convenience Routines For Running Queries
 **
 ** Definition: A <b>result table</b> is memory data structure created by the
 ** [sqlite3_get_table()] interface.  A result table records the
@@ -2146,27 +2164,25 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 **        azResult[7] = "21";
 ** </pre></blockquote>
 **
-** The sqlite3_get_table() function evaluates one or more
+** ^The sqlite3_get_table() function evaluates one or more
 ** semicolon-separated SQL statements in the zero-terminated UTF-8
-** string of its 2nd parameter.  It returns a result table to the
+** string of its 2nd parameter and returns a result table to the
 ** pointer given in its 3rd parameter.
 **
-** After the calling function has finished using the result, it should
-** pass the pointer to the result table to sqlite3_free_table() in order to
+** 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
 ** 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()].
-**
-** Requirements:
-** [H12371] [H12373] [H12374] [H12376] [H12379] [H12382]
+** reflected in subsequent calls to [sqlite3_errcode()] or
+** [sqlite3_errmsg()].)^
 */
 SQLITE_API int sqlite3_get_table(
   sqlite3 *db,          /* An open database */
@@ -2179,33 +2195,33 @@ SQLITE_API int sqlite3_get_table(
 SQLITE_API void sqlite3_free_table(char **result);
 
 /*
-** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000>
+** CAPI3REF: Formatted String Printing Functions
 **
 ** These routines are work-alikes of the "printf()" family of functions
 ** from the standard C library.
 **
-** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
+** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
 ** results into memory obtained from [sqlite3_malloc()].
 ** The strings returned by these two routines should be
-** released by [sqlite3_free()].  Both routines return a
+** released by [sqlite3_free()].  ^Both routines return a
 ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
 ** memory to hold the resulting string.
 **
-** In sqlite3_snprintf() routine is similar to "snprintf()" from
+** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from
 ** the standard C library.  The result is written into the
 ** buffer supplied as the second parameter whose size is given by
 ** the first parameter. Note that the order of the
-** first two parameters is reversed from snprintf().  This is an
+** first two parameters is reversed from snprintf().)^  This is an
 ** historical accident that cannot be fixed without breaking
-** backwards compatibility.  Note also that sqlite3_snprintf()
+** backwards compatibility.  ^(Note also that sqlite3_snprintf()
 ** returns a pointer to its buffer instead of the number of
-** characters actually written into the buffer.  We admit that
+** characters actually written into the buffer.)^  We admit that
 ** the number of characters written would be a more useful return
 ** value but we cannot change the implementation of sqlite3_snprintf()
 ** now without breaking compatibility.
 **
-** As long as the buffer size is greater than zero, sqlite3_snprintf()
-** guarantees that the buffer is always zero-terminated.  The first
+** ^As long as the buffer size is greater than zero, sqlite3_snprintf()
+** guarantees that the buffer is always zero-terminated.  ^The first
 ** parameter "n" is the total size of the buffer, including space for
 ** the zero terminator.  So the longest string that can be completely
 ** written will be n-1 characters.
@@ -2215,9 +2231,9 @@ SQLITE_API void sqlite3_free_table(char **result);
 ** All of the usual printf() formatting options apply.  In addition, there
 ** is are "%q", "%Q", and "%z" options.
 **
-** The %q option works like %s in that it substitutes a null-terminated
+** ^(The %q option works like %s in that it substitutes a null-terminated
 ** string from the argument list.  But %q also doubles every '\'' character.
-** %q is designed for use inside a string literal.  By doubling each '\''
+** %q is designed for use inside a string literal.)^  By doubling each '\''
 ** character it escapes that character and allows it to be inserted into
 ** the string.
 **
@@ -2252,10 +2268,10 @@ SQLITE_API void sqlite3_free_table(char **result);
 ** This second example is an SQL syntax error.  As a general rule you should
 ** always use %q instead of %s when inserting text into a string literal.
 **
-** The %Q option works like %q except it also adds single quotes around
+** ^(The %Q option works like %q except it also adds single quotes around
 ** the outside of the total string.  Additionally, if the parameter in the
 ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
-** single quotes) in place of the %Q option.  So, for example, one could say:
+** single quotes).)^  So, for example, one could say:
 **
 ** <blockquote><pre>
 **  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
@@ -2266,35 +2282,32 @@ SQLITE_API void sqlite3_free_table(char **result);
 ** The code above will render a correct SQL statement in the zSQL
 ** variable even if the zText variable is a NULL pointer.
 **
-** The "%z" formatting option works exactly like "%s" with the
+** ^(The "%z" formatting option works like "%s" but with the
 ** addition that after the string has been read and copied into
-** the result, [sqlite3_free()] is called on the input string. {END}
-**
-** Requirements:
-** [H17403] [H17406] [H17407]
+** the result, [sqlite3_free()] is called on the input string.)^
 */
 SQLITE_API char *sqlite3_mprintf(const char*,...);
 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
 
 /*
-** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000>
+** CAPI3REF: Memory Allocation Subsystem
 **
-** The SQLite core  uses these three routines for all of its own
+** The SQLite core uses these three routines for all of its own
 ** internal memory allocation needs. "Core" in the previous sentence
 ** does not include operating-system specific VFS implementation.  The
 ** Windows VFS uses native malloc() and free() for some operations.
 **
-** The sqlite3_malloc() routine returns a pointer to a block
+** ^The sqlite3_malloc() routine returns a pointer to a block
 ** of memory at least N bytes in length, where N is the parameter.
-** If sqlite3_malloc() is unable to obtain sufficient free
-** memory, it returns a NULL pointer.  If the parameter N to
+** ^If sqlite3_malloc() is unable to obtain sufficient free
+** memory, it returns a NULL pointer.  ^If the parameter N to
 ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
 ** a NULL pointer.
 **
-** Calling sqlite3_free() with a pointer previously returned
+** ^Calling sqlite3_free() with a pointer previously returned
 ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
-** that it might be reused.  The sqlite3_free() routine is
+** that it might be reused.  ^The sqlite3_free() routine is
 ** a no-op if is called with a NULL pointer.  Passing a NULL pointer
 ** to sqlite3_free() is harmless.  After being freed, memory
 ** should neither be read nor written.  Even reading previously freed
@@ -2303,34 +2316,25 @@ SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
 ** might result if sqlite3_free() is called with a non-NULL pointer that
 ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
 **
-** The sqlite3_realloc() interface attempts to resize a
+** ^(The sqlite3_realloc() interface attempts to resize a
 ** prior memory allocation to be at least N bytes, where N is the
 ** second parameter.  The memory allocation to be resized is the first
-** parameter.  If the first parameter to sqlite3_realloc()
+** parameter.)^ ^ If the first parameter to sqlite3_realloc()
 ** is a NULL pointer then its behavior is identical to calling
 ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
-** If the second parameter to sqlite3_realloc() is zero or
+** ^If the second parameter to sqlite3_realloc() is zero or
 ** negative then the behavior is exactly the same as calling
 ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
-** sqlite3_realloc() returns a pointer to a memory allocation
+** ^sqlite3_realloc() returns a pointer to a memory allocation
 ** of at least N bytes in size or NULL if sufficient memory is unavailable.
-** If M is the size of the prior allocation, then min(N,M) bytes
+** ^If M is the size of the prior allocation, then min(N,M) bytes
 ** of the prior allocation are copied into the beginning of buffer returned
 ** by sqlite3_realloc() and the prior allocation is freed.
-** If sqlite3_realloc() returns NULL, then the prior allocation
+** ^If sqlite3_realloc() returns NULL, then the prior allocation
 ** is not freed.
 **
-** The memory returned by sqlite3_malloc() and sqlite3_realloc()
-** is always aligned to at least an 8 byte boundary. {END}
-**
-** The default implementation of the memory allocation subsystem uses
-** the malloc(), realloc() and free() provided by the standard C library.
-** {H17382} However, if SQLite is compiled with the
-** SQLITE_MEMORY_SIZE=<i>NNN</i> C preprocessor macro (where <i>NNN</i>
-** is an integer), then SQLite create a static array of at least
-** <i>NNN</i> bytes in size and uses that array for all of its dynamic
-** memory allocation needs. {END}  Additional memory allocator options
-** may be added in future releases.
+** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
+** is always aligned to at least an 8 byte boundary.
 **
 ** 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
@@ -2345,10 +2349,6 @@ SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
 ** they are reported back as [SQLITE_CANTOPEN] or
 ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
 **
-** Requirements:
-** [H17303] [H17304] [H17305] [H17306] [H17310] [H17312] [H17315] [H17318]
-** [H17321] [H17322] [H17323]
-**
 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
 ** must be either NULL or else pointers obtained from a prior
 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
@@ -2363,20 +2363,33 @@ SQLITE_API void *sqlite3_realloc(void*, int);
 SQLITE_API void sqlite3_free(void*);
 
 /*
-** CAPI3REF: Memory Allocator Statistics {H17370} <S30210>
+** CAPI3REF: Memory Allocator Statistics
 **
 ** SQLite provides these two interfaces for reporting on the status
 ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
 ** routines, which form the built-in memory allocation subsystem.
 **
-** Requirements:
-** [H17371] [H17373] [H17374] [H17375]
+** ^The [sqlite3_memory_used()] routine returns the number of bytes
+** of memory currently outstanding (malloced but not freed).
+** ^The [sqlite3_memory_highwater()] routine returns the maximum
+** value of [sqlite3_memory_used()] since the high-water mark
+** was last reset.  ^The values returned by [sqlite3_memory_used()] and
+** [sqlite3_memory_highwater()] include any overhead
+** added by SQLite in its implementation of [sqlite3_malloc()],
+** but not overhead added by the any underlying system library
+** routines that [sqlite3_malloc()] may call.
+**
+** ^The memory high-water mark is reset to the current value of
+** [sqlite3_memory_used()] if and only if the parameter to
+** [sqlite3_memory_highwater()] is true.  ^The value returned
+** by [sqlite3_memory_highwater(1)] is the high-water mark
+** prior to the reset.
 */
 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
 
 /*
-** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000>
+** CAPI3REF: Pseudo-Random Number Generator
 **
 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
 ** select random [ROWID | ROWIDs] when inserting new records into a table that
@@ -2384,60 +2397,57 @@ SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
 ** the build-in random() and randomblob() SQL functions.  This interface allows
 ** applications to access the same PRNG for other purposes.
 **
-** A call to this routine stores N bytes of randomness into buffer P.
+** ^A call to this routine stores N bytes of randomness into buffer P.
 **
-** The first time this routine is invoked (either internally or by
+** ^The first time this routine is invoked (either internally or by
 ** the application) the PRNG is seeded using randomness obtained
 ** from the xRandomness method of the default [sqlite3_vfs] object.
-** On all subsequent invocations, the pseudo-randomness is generated
+** ^On all subsequent invocations, the pseudo-randomness is generated
 ** internally and without recourse to the [sqlite3_vfs] xRandomness
 ** method.
-**
-** Requirements:
-** [H17392]
 */
 SQLITE_API void sqlite3_randomness(int N, void *P);
 
 /*
-** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100>
+** CAPI3REF: Compile-Time Authorization Callbacks
 **
-** This routine registers a authorizer callback with a particular
+** ^This routine registers a authorizer callback with a particular
 ** [database connection], supplied in the first argument.
-** The authorizer callback is invoked as SQL statements are being compiled
+** ^The authorizer callback is invoked as SQL statements are being compiled
 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
-** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()].  At various
+** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()].  ^At various
 ** points during the compilation process, as logic is being created
 ** to perform various actions, the authorizer callback is invoked to
-** see if those actions are allowed.  The authorizer callback should
+** see if those actions are allowed.  ^The authorizer callback should
 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
 ** specific action but allow the SQL statement to continue to be
 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
-** rejected with an error.  If the authorizer callback returns
+** rejected with an error.  ^If the authorizer callback returns
 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
 ** the authorizer will fail with an error message.
 **
 ** When the callback returns [SQLITE_OK], that means the operation
-** requested is ok.  When the callback returns [SQLITE_DENY], the
+** requested is ok.  ^When the callback returns [SQLITE_DENY], the
 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
 ** authorizer will fail with an error message explaining that
 ** access is denied. 
 **
-** The first parameter to the authorizer callback is a copy of the third
-** parameter to the sqlite3_set_authorizer() interface. The second parameter
+** ^The first parameter to the authorizer callback is a copy of the third
+** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
-** the particular action to be authorized. The third through sixth parameters
+** the particular action to be authorized. ^The third through sixth parameters
 ** to the callback are zero-terminated strings that contain additional
 ** details about the action to be authorized.
 **
-** If the action code is [SQLITE_READ]
+** ^If the action code is [SQLITE_READ]
 ** and the callback returns [SQLITE_IGNORE] then the
 ** [prepared statement] statement is constructed to substitute
 ** a NULL value in place of the table column that would have
 ** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]
 ** return can be used to deny an untrusted user access to individual
 ** columns of a table.
-** If the action code is [SQLITE_DELETE] and the callback returns
+** ^If the action code is [SQLITE_DELETE] and the callback returns
 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
 ** [truncate optimization] is disabled and all rows are deleted individually.
 **
@@ -2457,9 +2467,9 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
 ** and limiting database size using the [max_page_count] [PRAGMA]
 ** in addition to using an authorizer.
 **
-** Only a single authorizer can be in place on a database connection
+** ^(Only a single authorizer can be in place on a database connection
 ** at a time.  Each call to sqlite3_set_authorizer overrides the
-** previous call.  Disable the authorizer by installing a NULL callback.
+** previous call.)^  ^Disable the authorizer by installing a NULL callback.
 ** The authorizer is disabled by default.
 **
 ** The authorizer callback must not do anything that will modify
@@ -2467,20 +2477,16 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
-** When [sqlite3_prepare_v2()] is used to prepare a statement, the
+** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
 ** statement might be re-prepared during [sqlite3_step()] due to a 
 ** schema change.  Hence, the application should ensure that the
 ** correct authorizer callback remains in place during the [sqlite3_step()].
 **
-** Note that the authorizer callback is invoked only during
+** ^Note that the authorizer callback is invoked only during
 ** [sqlite3_prepare()] or its variants.  Authorization is not
 ** performed during statement evaluation in [sqlite3_step()], unless
 ** as stated in the previous paragraph, sqlite3_step() invokes
 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
-**
-** Requirements:
-** [H12501] [H12502] [H12503] [H12504] [H12505] [H12506] [H12507] [H12510]
-** [H12511] [H12512] [H12520] [H12521] [H12522]
 */
 SQLITE_API int sqlite3_set_authorizer(
   sqlite3*,
@@ -2489,7 +2495,7 @@ SQLITE_API int sqlite3_set_authorizer(
 );
 
 /*
-** CAPI3REF: Authorizer Return Codes {H12590} <H12500>
+** CAPI3REF: Authorizer Return Codes
 **
 ** The [sqlite3_set_authorizer | authorizer callback function] must
 ** return either [SQLITE_OK] or one of these two constants in order
@@ -2501,7 +2507,7 @@ SQLITE_API int sqlite3_set_authorizer(
 #define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */
 
 /*
-** CAPI3REF: Authorizer Action Codes {H12550} <H12500>
+** CAPI3REF: Authorizer Action Codes
 **
 ** The [sqlite3_set_authorizer()] interface registers a callback function
 ** that is invoked to authorize certain SQL statement actions.  The
@@ -2512,15 +2518,12 @@ SQLITE_API int sqlite3_set_authorizer(
 ** These action code values signify what kind of operation is to be
 ** authorized.  The 3rd and 4th parameters to the authorization
 ** callback function will be parameters or NULL depending on which of these
-** codes is used as the second parameter.  The 5th parameter to the
+** codes is used as the second parameter.  ^(The 5th parameter to the
 ** authorizer callback is the name of the database ("main", "temp",
-** etc.) if applicable.  The 6th parameter to the authorizer callback
+** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback
 ** is the name of the inner-most trigger or view that is responsible for
 ** the access attempt or NULL if this access attempt is directly from
 ** top-level SQL code.
-**
-** Requirements:
-** [H12551] [H12552] [H12553] [H12554]
 */
 /******************************************* 3rd ************ 4th ***********/
 #define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */
@@ -2558,42 +2561,39 @@ SQLITE_API int sqlite3_set_authorizer(
 #define SQLITE_COPY                  0   /* No longer used */
 
 /*
-** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400>
+** CAPI3REF: Tracing And Profiling Functions
 ** EXPERIMENTAL
 **
 ** These routines register callback functions that can be used for
 ** tracing and profiling the execution of SQL statements.
 **
-** The callback function registered by sqlite3_trace() is invoked at
+** ^The callback function registered by sqlite3_trace() is invoked at
 ** various times when an SQL statement is being run by [sqlite3_step()].
-** The callback returns a UTF-8 rendering of the SQL statement text
-** as the statement first begins executing.  Additional callbacks occur
+** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
+** SQL statement text as the statement first begins executing.
+** ^(Additional sqlite3_trace() callbacks might occur
 ** as each triggered subprogram is entered.  The callbacks for triggers
-** contain a UTF-8 SQL comment that identifies the trigger.
+** contain a UTF-8 SQL comment that identifies the trigger.)^
 **
-** The callback function registered by sqlite3_profile() is invoked
-** as each SQL statement finishes.  The profile callback contains
+** ^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.
-**
-** Requirements:
-** [H12281] [H12282] [H12283] [H12284] [H12285] [H12287] [H12288] [H12289]
-** [H12290]
 */
 SQLITE_API SQLITE_EXPERIMENTAL 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 {H12910} <S60400>
+** CAPI3REF: Query Progress Callbacks
 **
-** This routine configures a callback function - the
+** ^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
 ** interface is to keep a GUI updated during a large query.
 **
-** If the progress callback returns non-zero, the operation is
+** ^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.
 **
@@ -2602,28 +2602,26 @@ SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
-** Requirements:
-** [H12911] [H12912] [H12913] [H12914] [H12915] [H12916] [H12917] [H12918]
-**
 */
 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
 
 /*
-** CAPI3REF: Opening A New Database Connection {H12700} <S40200>
+** CAPI3REF: Opening A New Database Connection
 **
-** These routines open an SQLite database file whose name is given by the
-** filename argument. The filename argument is interpreted as UTF-8 for
+** ^These routines open an SQLite database file whose name is given by the
+** filename argument. ^The filename argument is interpreted as UTF-8 for
 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
-** order for sqlite3_open16(). A [database connection] handle is usually
+** order for sqlite3_open16(). ^(A [database connection] handle is usually
 ** returned in *ppDb, even if an error occurs.  The only exception is that
 ** if SQLite is unable to allocate memory to hold the [sqlite3] object,
 ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
-** object. If the database is opened (and/or created) successfully, then
-** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.  The
+** object.)^ ^(If the database is opened (and/or created) successfully, then
+** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The
 ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
-** an English language description of the error.
+** an English language description of the error following a failure of any
+** of the sqlite3_open() routines.
 **
-** The default encoding for the database will be UTF-8 if
+** ^The default encoding for the database will be UTF-8 if
 ** sqlite3_open() or sqlite3_open_v2() is called and
 ** UTF-16 in the native byte order if sqlite3_open16() is used.
 **
@@ -2633,25 +2631,26 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
 **
 ** The sqlite3_open_v2() interface works like sqlite3_open()
 ** except that it accepts two additional parameters for additional control
-** over the new database connection.  The flags parameter can take one of
+** over the new database connection.  ^(The flags parameter to
+** sqlite3_open_v2() can take one of
 ** the following three values, optionally combined with the 
 ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
-** and/or [SQLITE_OPEN_PRIVATECACHE] flags:
+** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^
 **
 ** <dl>
-** <dt>[SQLITE_OPEN_READONLY]</dt>
+** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
 ** <dd>The database is opened in read-only mode.  If the database does not
-** already exist, an error is returned.</dd>
+** already exist, an error is returned.</dd>)^
 **
-** <dt>[SQLITE_OPEN_READWRITE]</dt>
+** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>
 ** <dd>The database is opened for reading and writing if possible, or reading
 ** only if the file is write protected by the operating system.  In either
-** case the database must already exist, otherwise an error is returned.</dd>
+** case the database must already exist, otherwise an error is returned.</dd>)^
 **
-** <dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
+** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
 ** <dd>The database is opened for reading and writing, and is creates it if
 ** it does not already exist. This is the behavior that is always used for
-** sqlite3_open() and sqlite3_open16().</dd>
+** sqlite3_open() and sqlite3_open16().</dd>)^
 ** </dl>
 **
 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
@@ -2660,33 +2659,33 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
 ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
 ** then the behavior is undefined.
 **
-** If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
+** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
 ** opens in the multi-thread [threading mode] as long as the single-thread
-** mode has not been set at compile-time or start-time.  If the
+** mode has not been set at compile-time or start-time.  ^If the
 ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
 ** in the serialized [threading mode] unless single-thread was
 ** previously selected at compile-time or start-time.
-** The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
+** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
 ** eligible to use [shared cache mode], regardless of whether or not shared
-** cache is enabled using [sqlite3_enable_shared_cache()].  The
+** cache is enabled using [sqlite3_enable_shared_cache()].  ^The
 ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
 ** participate in [shared cache mode] even if it is enabled.
 **
-** If the filename is ":memory:", then a private, temporary in-memory database
-** is created for the connection.  This in-memory database will vanish when
+** ^If the filename is ":memory:", then a private, temporary in-memory database
+** is created for the connection.  ^This in-memory database will vanish when
 ** the database connection is closed.  Future versions of SQLite might
 ** make use of additional special filenames that begin with the ":" character.
 ** It is recommended that when a database filename actually does begin with
 ** a ":" character you should prefix the filename with a pathname such as
 ** "./" to avoid ambiguity.
 **
-** If the filename is an empty string, then a private, temporary
-** on-disk database will be created.  This private database will be
+** ^If the filename is an empty string, then a private, temporary
+** on-disk database will be created.  ^This private database will be
 ** automatically deleted as soon as the database connection is closed.
 **
-** The fourth parameter to sqlite3_open_v2() is the name of the
+** ^The fourth parameter to sqlite3_open_v2() is the name of the
 ** [sqlite3_vfs] object that defines the operating system interface that
-** the new database connection should use.  If the fourth parameter is
+** the new database connection should use.  ^If the fourth parameter is
 ** a NULL pointer then the default [sqlite3_vfs] object is used.
 **
 ** <b>Note to Windows users:</b>  The encoding used for the filename argument
@@ -2694,10 +2693,6 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
 ** codepage is currently defined.  Filenames containing international
 ** characters must be converted to UTF-8 prior to passing them into
 ** sqlite3_open() or sqlite3_open_v2().
-**
-** Requirements:
-** [H12701] [H12702] [H12703] [H12704] [H12706] [H12707] [H12709] [H12711]
-** [H12712] [H12713] [H12714] [H12717] [H12719] [H12721] [H12723]
 */
 SQLITE_API int sqlite3_open(
   const char *filename,   /* Database filename (UTF-8) */
@@ -2715,23 +2710,23 @@ SQLITE_API int sqlite3_open_v2(
 );
 
 /*
-** CAPI3REF: Error Codes And Messages {H12800} <S60200>
+** CAPI3REF: Error Codes And Messages
 **
-** The sqlite3_errcode() interface returns the numeric [result code] or
+** ^The sqlite3_errcode() interface returns the numeric [result code] or
 ** [extended result code] for the most recent failed sqlite3_* API call
 ** associated with a [database connection]. If a prior API call failed
 ** but the most recent API call succeeded, the return value from
-** sqlite3_errcode() is undefined.  The sqlite3_extended_errcode()
+** sqlite3_errcode() is undefined.  ^The sqlite3_extended_errcode()
 ** interface is the same except that it always returns the 
 ** [extended result code] even when extended result codes are
 ** disabled.
 **
-** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
+** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
-** Memory to hold the error message string is managed internally.
+** ^(Memory to hold the error message string is managed internally.
 ** The application does not need to worry about freeing the result.
 ** However, the error string might be overwritten or deallocated by
-** subsequent calls to other SQLite interface functions.
+** subsequent calls to other SQLite interface functions.)^
 **
 ** When the serialized [threading mode] is in use, it might be the
 ** case that a second error occurs on a separate thread in between
@@ -2746,9 +2741,6 @@ SQLITE_API int sqlite3_open_v2(
 ** If an interface fails with SQLITE_MISUSE, that means the interface
 ** was invoked incorrectly by the application.  In that case, the
 ** error code and message may or may not be set.
-**
-** Requirements:
-** [H12801] [H12802] [H12803] [H12807] [H12808] [H12809]
 */
 SQLITE_API int sqlite3_errcode(sqlite3 *db);
 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
@@ -2756,7 +2748,7 @@ SQLITE_API const char *sqlite3_errmsg(sqlite3*);
 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
 
 /*
-** CAPI3REF: SQL Statement Object {H13000} <H13010>
+** CAPI3REF: SQL Statement Object
 ** KEYWORDS: {prepared statement} {prepared statements}
 **
 ** An instance of this object represents a single SQL statement.
@@ -2782,25 +2774,25 @@ SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
 typedef struct sqlite3_stmt sqlite3_stmt;
 
 /*
-** CAPI3REF: Run-time Limits {H12760} <S20600>
+** CAPI3REF: Run-time Limits
 **
-** This interface allows the size of various constructs to be limited
+** ^(This interface allows the size of various constructs to be limited
 ** on a connection by connection basis.  The first parameter is the
 ** [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.  The function returns the old limit.)^
 **
-** If the new limit is a negative number, the limit is unchanged.
-** For the limit category of SQLITE_LIMIT_XYZ there is a 
+** ^If the new limit is a negative number, the limit is unchanged.
+** ^(For the limit category of SQLITE_LIMIT_XYZ there is a 
 ** [limits | hard upper bound]
 ** set by a compile-time C preprocessor macro named 
 ** [limits | SQLITE_MAX_XYZ].
-** (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 limit.
+** (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.
 **
-** Run time limits are intended for use in applications that manage
+** 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
 ** web browser that has its own databases for storing history and
@@ -2814,15 +2806,12 @@ typedef struct sqlite3_stmt sqlite3_stmt;
 ** [max_page_count] [PRAGMA].
 **
 ** New run-time limit categories may be added in future releases.
-**
-** Requirements:
-** [H12762] [H12766] [H12769]
 */
 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 
 /*
-** CAPI3REF: Run-Time Limit Categories {H12790} <H12760>
-** KEYWORDS: {limit category} {limit categories}
+** CAPI3REF: Run-Time Limit Categories
+** KEYWORDS: {limit category} {*limit categories}
 **
 ** These constants define various performance limits
 ** that can be lowered at run-time using [sqlite3_limit()].
@@ -2830,43 +2819,43 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** Additional information is available at [limits | Limits in SQLite].
 **
 ** <dl>
-** <dt>SQLITE_LIMIT_LENGTH</dt>
-** <dd>The maximum size of any string or BLOB or table row.<dd>
+** ^(<dt>SQLITE_LIMIT_LENGTH</dt>
+** <dd>The maximum size of any string or BLOB or table row.<dd>)^
 **
-** <dt>SQLITE_LIMIT_SQL_LENGTH</dt>
-** <dd>The maximum length of an SQL statement.</dd>
+** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
+** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
 **
-** <dt>SQLITE_LIMIT_COLUMN</dt>
+** ^(<dt>SQLITE_LIMIT_COLUMN</dt>
 ** <dd>The maximum number of columns in a table definition or in the
 ** result set of a [SELECT] or the maximum number of columns in an index
-** or in an ORDER BY or GROUP BY clause.</dd>
+** or in an ORDER BY or GROUP BY clause.</dd>)^
 **
-** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
-** <dd>The maximum depth of the parse tree on any expression.</dd>
+** ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
+** <dd>The maximum depth of the parse tree on any expression.</dd>)^
 **
-** <dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
-** <dd>The maximum number of terms in a compound SELECT statement.</dd>
+** ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
+** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
 **
-** <dt>SQLITE_LIMIT_VDBE_OP</dt>
+** ^(<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.</dd>)^
 **
-** <dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
-** <dd>The maximum number of arguments on a function.</dd>
+** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
+** <dd>The maximum number of arguments on a function.</dd>)^
 **
-** <dt>SQLITE_LIMIT_ATTACHED</dt>
-** <dd>The maximum number of [ATTACH | attached databases].</dd>
+** ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
+** <dd>The maximum number of [ATTACH | attached databases].)^</dd>
 **
-** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
+** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
 ** <dd>The maximum length of the pattern argument to the [LIKE] or
-** [GLOB] operators.</dd>
+** [GLOB] operators.</dd>)^
 **
-** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
+** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
 ** <dd>The maximum number of variables in an SQL statement that can
-** be bound.</dd>
+** be bound.</dd>)^
 **
-** <dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
-** <dd>The maximum depth of recursion for triggers.</dd>
+** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
+** <dd>The maximum depth of recursion for triggers.</dd>)^
 ** </dl>
 */
 #define SQLITE_LIMIT_LENGTH                    0
@@ -2882,7 +2871,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 #define SQLITE_LIMIT_TRIGGER_DEPTH            10
 
 /*
-** CAPI3REF: Compiling An SQL Statement {H13010} <S10000>
+** CAPI3REF: Compiling An SQL Statement
 ** KEYWORDS: {SQL statement compiler}
 **
 ** To execute an SQL query, it must first be compiled into a byte-code
@@ -2897,9 +2886,9 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
 ** use UTF-16.
 **
-** If the nByte argument is less than zero, then zSql is read up to the
-** first zero terminator. If nByte is non-negative, then it is the maximum
-** number of  bytes read from zSql.  When nByte is non-negative, the
+** ^If the nByte argument is less than zero, then zSql is read up to the
+** first zero terminator. ^If nByte is non-negative, then it is the maximum
+** number of  bytes read from zSql.  ^When nByte is non-negative, the
 ** zSql string ends at either the first '\000' or '\u0000' character or
 ** the nByte-th byte, whichever comes first. If the caller knows
 ** that the supplied string is nul-terminated, then there is a small
@@ -2907,34 +2896,35 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** is equal to the number of bytes in the input string <i>including</i>
 ** the nul-terminator bytes.
 **
-** If pzTail is not NULL then *pzTail is made to point to the first byte
+** ^If pzTail is not NULL then *pzTail is made to point to the first byte
 ** past the end of the first SQL statement in zSql.  These routines only
 ** compile the first statement in zSql, so *pzTail is left pointing to
 ** what remains uncompiled.
 **
-** *ppStmt is left pointing to a compiled [prepared statement] that can be
-** executed using [sqlite3_step()].  If there is an error, *ppStmt is set
-** to NULL.  If the input text contains no SQL (if the input is an empty
+** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
+** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set
+** to NULL.  ^If the input text contains no SQL (if the input is an empty
 ** string or a comment) then *ppStmt is set to NULL.
 ** The calling procedure is responsible for deleting the compiled
 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
 ** ppStmt may not be NULL.
 **
-** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
+** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
+** otherwise an [error code] is returned.
 **
 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
 ** recommended for all new programs. The two older interfaces are retained
 ** for backwards compatibility, but their use is discouraged.
-** In the "v2" interfaces, the prepared statement
+** ^In the "v2" interfaces, the prepared statement
 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
 ** original SQL text. This causes the [sqlite3_step()] interface to
-** behave a differently in two ways:
+** behave differently in three ways:
 **
 ** <ol>
 ** <li>
-** If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
+** ^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
+** 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
@@ -2943,18 +2933,22 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** </li>
 **
 ** <li>
-** When an error occurs, [sqlite3_step()] will return one of the detailed
-** [error codes] or [extended error codes].  The legacy behavior was that
+** ^When an error occurs, [sqlite3_step()] will return one of the detailed
+** [error codes] or [extended error codes].  ^The legacy behavior was that
 ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
-** and you would have to make a second call to [sqlite3_reset()] in order
-** to find the underlying cause of the problem. With the "v2" prepare
+** and the application would have to make a second call to [sqlite3_reset()]
+** in order to find the underlying cause of the problem. With the "v2" prepare
 ** interfaces, the underlying reason for the error is returned immediately.
 ** </li>
-** </ol>
-**
-** Requirements:
-** [H13011] [H13012] [H13013] [H13014] [H13015] [H13016] [H13019] [H13021]
 **
+** <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]. 
+** </li>
+** </ol>
 */
 SQLITE_API int sqlite3_prepare(
   sqlite3 *db,            /* Database handle */
@@ -2986,24 +2980,21 @@ SQLITE_API int sqlite3_prepare16_v2(
 );
 
 /*
-** CAPI3REF: Retrieving Statement SQL {H13100} <H13000>
+** CAPI3REF: Retrieving Statement SQL
 **
-** This interface can be used to retrieve a saved copy of the original
+** ^This interface can be used to retrieve a saved copy of the original
 ** SQL text used to create a [prepared statement] if that statement was
 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
-**
-** Requirements:
-** [H13101] [H13102] [H13103]
 */
 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Dynamically Typed Value Object {H15000} <S20200>
+** CAPI3REF: Dynamically Typed Value Object
 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
 **
 ** SQLite uses the sqlite3_value object to represent all values
 ** that can be stored in a database table. SQLite uses dynamic typing
-** for the values it stores. Values stored in sqlite3_value objects
+** for the values it stores.  ^Values stored in sqlite3_value objects
 ** can be integers, floating point values, strings, BLOBs, or NULL.
 **
 ** An sqlite3_value object may be either "protected" or "unprotected".
@@ -3025,9 +3016,9 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
 ** still make the distinction between between protected and unprotected
 ** sqlite3_value objects even when not strictly required.
 **
-** The sqlite3_value objects that are passed as parameters into the
+** ^The sqlite3_value objects that are passed as parameters into the
 ** implementation of [application-defined SQL functions] are protected.
-** The sqlite3_value object returned by
+** ^The sqlite3_value object returned by
 ** [sqlite3_column_value()] is unprotected.
 ** Unprotected sqlite3_value objects may only be used with
 ** [sqlite3_result_value()] and [sqlite3_bind_value()].
@@ -3037,10 +3028,10 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
 typedef struct Mem sqlite3_value;
 
 /*
-** CAPI3REF: SQL Function Context Object {H16001} <S20200>
+** CAPI3REF: SQL Function Context Object
 **
 ** The context in which an SQL function executes is stored in an
-** sqlite3_context object.  A pointer to an sqlite3_context object
+** sqlite3_context object.  ^A pointer to an sqlite3_context object
 ** is always first parameter to [application-defined SQL functions].
 ** The application-defined SQL function implementation will pass this
 ** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
@@ -3051,11 +3042,11 @@ typedef struct Mem sqlite3_value;
 typedef struct sqlite3_context sqlite3_context;
 
 /*
-** CAPI3REF: Binding Values To Prepared Statements {H13500} <S70300>
+** CAPI3REF: Binding Values To Prepared Statements
 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
 **
-** In the SQL strings input to [sqlite3_prepare_v2()] and its variants,
+** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
 ** literals may be replaced by a [parameter] that matches one of following
 ** templates:
 **
@@ -3068,72 +3059,66 @@ 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 identifer.)^  ^The values of these
 ** parameters (also called "host parameter names" or "SQL parameters")
 ** can be set using the sqlite3_bind_*() routines defined here.
 **
-** The first argument to the sqlite3_bind_*() routines is always
+** ^The first argument to the sqlite3_bind_*() routines is always
 ** a pointer to the [sqlite3_stmt] object returned from
 ** [sqlite3_prepare_v2()] or its variants.
 **
-** The second argument is the index of the SQL parameter to be set.
-** The leftmost SQL parameter has an index of 1.  When the same named
+** ^The second argument is the index of the SQL parameter to be set.
+** ^The leftmost SQL parameter has an index of 1.  ^When the same named
 ** SQL parameter is used more than once, second and subsequent
 ** occurrences have the same index as the first occurrence.
-** The index for named parameters can be looked up using the
-** [sqlite3_bind_parameter_index()] API if desired.  The index
+** ^The index for named parameters can be looked up using the
+** [sqlite3_bind_parameter_index()] API if desired.  ^The index
 ** for "?NNN" parameters is the value of NNN.
-** The NNN value must be between 1 and the [sqlite3_limit()]
+** ^The NNN value must be between 1 and the [sqlite3_limit()]
 ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
 **
-** The third argument is the value to bind to the parameter.
+** ^The third argument is the value to bind to the parameter.
 **
-** In those routines that have a fourth argument, its value is the
+** ^(In those routines that have a fourth argument, its value is the
 ** number of bytes in the parameter.  To be clear: the value is the
-** number of <u>bytes</u> in the value, not the number of characters.
-** If the fourth parameter is negative, the length of the string is
+** number of <u>bytes</u> in the value, not the number of characters.)^
+** ^If the fourth parameter is negative, the length of the string is
 ** the number of bytes up to the first zero terminator.
 **
-** The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
+** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
 ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
-** string after SQLite has finished with it. If the fifth argument is
+** string after SQLite has finished with it. ^If the fifth argument is
 ** the special value [SQLITE_STATIC], then SQLite assumes that the
 ** information is in static, unmanaged space and does not need to be freed.
-** If the fifth argument has the value [SQLITE_TRANSIENT], then
+** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
 ** SQLite makes its own private copy of the data immediately, before
 ** the sqlite3_bind_*() routine returns.
 **
-** The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
-** is filled with zeroes.  A zeroblob uses a fixed amount of memory
+** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
+** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory
 ** (just an integer to hold its size) while it is being processed.
 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
 ** content is later written using
 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
-** A negative value for the zeroblob results in a zero-length BLOB.
-**
-** The sqlite3_bind_*() routines must be called after
-** [sqlite3_prepare_v2()] (and its variants) or [sqlite3_reset()] and
-** before [sqlite3_step()].
-** Bindings are not cleared by the [sqlite3_reset()] routine.
-** Unbound parameters are interpreted as NULL.
-**
-** These routines return [SQLITE_OK] on success or an error code if
-** anything goes wrong.  [SQLITE_RANGE] is returned if the parameter
-** index is out of range.  [SQLITE_NOMEM] is returned if malloc() fails.
-** [SQLITE_MISUSE] might be returned if these routines are called on a
-** virtual machine that is the wrong state or which has already been finalized.
-** Detection of misuse is unreliable.  Applications should not depend
-** on SQLITE_MISUSE returns.  SQLITE_MISUSE is intended to indicate a
-** a logic error in the application.  Future versions of SQLite might
-** panic rather than return SQLITE_MISUSE.
+** ^A negative value for the zeroblob results in a zero-length BLOB.
 **
-** See also: [sqlite3_bind_parameter_count()],
-** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
+** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
+** for the [prepared statement] or with a prepared statement for which
+** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
+** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()
+** routine is passed a [prepared statement] that has been finalized, the
+** result is undefined and probably harmful.
+**
+** ^Bindings are not cleared by the [sqlite3_reset()] routine.
+** ^Unbound parameters are interpreted as NULL.
 **
-** Requirements:
-** [H13506] [H13509] [H13512] [H13515] [H13518] [H13521] [H13524] [H13527]
-** [H13530] [H13533] [H13536] [H13539] [H13542] [H13545] [H13548] [H13551]
+** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
+** [error code] if anything goes wrong.
+** ^[SQLITE_RANGE] is returned if the parameter
+** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.
 **
+** See also: [sqlite3_bind_parameter_count()],
+** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
 */
 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
@@ -3146,45 +3131,42 @@ SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
 
 /*
-** CAPI3REF: Number Of SQL Parameters {H13600} <S70300>
+** CAPI3REF: Number Of SQL Parameters
 **
-** This routine can be used to find the number of [SQL parameters]
+** ^This routine can be used to find the number of [SQL parameters]
 ** in a [prepared statement].  SQL parameters are tokens of the
 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
 ** placeholders for values that are [sqlite3_bind_blob | bound]
 ** to the parameters at a later time.
 **
-** This routine actually returns the index of the largest (rightmost)
+** ^(This routine actually returns the index of the largest (rightmost)
 ** parameter. For all forms except ?NNN, this will correspond to the
-** number of unique parameters.  If parameters of the ?NNN are used,
-** there may be gaps in the list.
+** number of unique parameters.  If parameters of the ?NNN form are used,
+** there may be gaps in the list.)^
 **
 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
 ** [sqlite3_bind_parameter_name()], and
 ** [sqlite3_bind_parameter_index()].
-**
-** Requirements:
-** [H13601]
 */
 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
 
 /*
-** CAPI3REF: Name Of A Host Parameter {H13620} <S70300>
+** CAPI3REF: Name Of A Host Parameter
 **
-** This routine returns a pointer to the name of the n-th
-** [SQL parameter] in a [prepared statement].
-** SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
+** ^The sqlite3_bind_parameter_name(P,N) interface returns
+** the name of the N-th [SQL parameter] in the [prepared statement] P.
+** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
 ** respectively.
 ** In other words, the initial ":" or "$" or "@" or "?"
-** is included as part of the name.
-** Parameters of the form "?" without a following integer have no name
-** and are also referred to as "anonymous parameters".
+** is included as part of the name.)^
+** ^Parameters of the form "?" without a following integer have no name
+** and are referred to as "nameless" or "anonymous parameters".
 **
-** The first host parameter has an index of 1, not 0.
+** ^The first host parameter has an index of 1, not 0.
 **
-** If the value n is out of range or if the n-th parameter is
-** nameless, then NULL is returned.  The returned string is
+** ^If the value N is out of range or if the N-th parameter is
+** nameless, then NULL is returned.  ^The returned string is
 ** always in UTF-8 encoding even if the named parameter was
 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
 ** [sqlite3_prepare16_v2()].
@@ -3192,125 +3174,108 @@ SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
 ** [sqlite3_bind_parameter_count()], and
 ** [sqlite3_bind_parameter_index()].
-**
-** Requirements:
-** [H13621]
 */
 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
 
 /*
-** CAPI3REF: Index Of A Parameter With A Given Name {H13640} <S70300>
+** CAPI3REF: Index Of A Parameter With A Given Name
 **
-** Return the index of an SQL parameter given its name.  The
+** ^Return the index of an SQL parameter given its name.  ^The
 ** index value returned is suitable for use as the second
-** parameter to [sqlite3_bind_blob|sqlite3_bind()].  A zero
-** is returned if no matching parameter is found.  The parameter
+** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero
+** is returned if no matching parameter is found.  ^The parameter
 ** name must be given in UTF-8 even if the original statement
 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
 **
 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
 ** [sqlite3_bind_parameter_count()], and
 ** [sqlite3_bind_parameter_index()].
-**
-** Requirements:
-** [H13641]
 */
 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
 
 /*
-** CAPI3REF: Reset All Bindings On A Prepared Statement {H13660} <S70300>
+** CAPI3REF: Reset All Bindings On A Prepared Statement
 **
-** Contrary to the intuition of many, [sqlite3_reset()] does not reset
+** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
-** Use this routine to reset all host parameters to NULL.
-**
-** Requirements:
-** [H13661]
+** ^Use this routine to reset all host parameters to NULL.
 */
 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
 
 /*
-** CAPI3REF: Number Of Columns In A Result Set {H13710} <S10700>
+** CAPI3REF: Number Of Columns In A Result Set
 **
-** Return the number of columns in the result set returned by the
-** [prepared statement]. This routine returns 0 if pStmt is an SQL
+** ^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]).
-**
-** Requirements:
-** [H13711]
 */
 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Column Names In A Result Set {H13720} <S10700>
+** CAPI3REF: Column Names In A Result Set
 **
-** These routines return the name assigned to a particular column
-** in the result set of a [SELECT] statement.  The sqlite3_column_name()
+** ^These routines return the name assigned to a particular column
+** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()
 ** interface returns a pointer to a zero-terminated UTF-8 string
 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
-** UTF-16 string.  The first parameter is the [prepared statement]
-** that implements the [SELECT] statement. The second parameter is the
-** column number.  The leftmost column is number 0.
+** UTF-16 string.  ^The first parameter is the [prepared statement]
+** that implements the [SELECT] statement. ^The second parameter is the
+** column number.  ^The leftmost column is number 0.
 **
-** The returned string pointer is valid until either the [prepared statement]
+** ^The returned string pointer is valid until either the [prepared statement]
 ** is destroyed by [sqlite3_finalize()] or until the next call to
 ** sqlite3_column_name() or sqlite3_column_name16() on the same column.
 **
-** If sqlite3_malloc() fails during the processing of either routine
+** ^If sqlite3_malloc() fails during the processing of either routine
 ** (for example during a conversion from UTF-8 to UTF-16) then a
 ** NULL pointer is returned.
 **
-** The name of a result column is the value of the "AS" clause for
+** ^The name of a result column is the value of the "AS" clause for
 ** that column, if there is an AS clause.  If there is no AS clause
 ** then the name of the column is unspecified and may change from
 ** one release of SQLite to the next.
-**
-** Requirements:
-** [H13721] [H13723] [H13724] [H13725] [H13726] [H13727]
 */
 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
 
 /*
-** CAPI3REF: Source Of Data In A Query Result {H13740} <S10700>
+** CAPI3REF: Source Of Data In A Query Result
 **
-** These routines provide a means to determine what column of what
-** table in which database a result of a [SELECT] statement comes from.
-** The name of the database or table or column can be returned as
-** either a UTF-8 or UTF-16 string.  The _database_ routines return
+** ^These routines provide a means to determine the database, table, and
+** table column that is the origin of a particular result column in
+** [SELECT] statement.
+** ^The name of the database or table or column can be returned as
+** either a UTF-8 or UTF-16 string.  ^The _database_ routines return
 ** the database name, the _table_ routines return the table name, and
 ** the origin_ routines return the column name.
-** The returned string is valid until the [prepared statement] is destroyed
+** ^The returned string is valid until the [prepared statement] is destroyed
 ** using [sqlite3_finalize()] or until the same information is requested
 ** again in a different encoding.
 **
-** The names returned are the original un-aliased names of the
+** ^The names returned are the original un-aliased names of the
 ** database, table, and column.
 **
-** The first argument to the following calls is a [prepared statement].
-** These functions return information about the Nth column returned by
+** ^The first argument to these interfaces is a [prepared statement].
+** ^These functions return information about the Nth result column returned by
 ** the statement, where N is the second function argument.
+** ^The left-most column is column 0 for these routines.
 **
-** If the Nth column returned by the statement is an expression or
+** ^If the Nth column returned by the statement is an expression or
 ** subquery and is not a column value, then all of these functions return
-** NULL.  These routine might also return NULL if a memory allocation error
-** occurs.  Otherwise, they return the name of the attached database, table
-** and column that query result column was extracted from.
+** NULL.  ^These routine might also return NULL if a memory allocation error
+** occurs.  ^Otherwise, they return the name of the attached database, table,
+** or column that query result column was extracted from.
 **
-** As with all other SQLite APIs, those postfixed with "16" return
-** UTF-16 encoded strings, the other functions return UTF-8. {END}
+** ^As with all other SQLite APIs, those whose names end with "16" return
+** UTF-16 encoded strings and the other functions return UTF-8.
 **
-** These APIs are only available if the library was compiled with the
-** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
+** ^These APIs are only available if the library was compiled with the
+** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
 **
-** {A13751}
 ** If two or more threads call one or more of these routines against the same
 ** prepared statement and column at the same time then the results are
 ** undefined.
 **
-** Requirements:
-** [H13741] [H13742] [H13743] [H13744] [H13745] [H13746] [H13748]
-**
 ** If two or more threads call one or more
 ** [sqlite3_column_database_name | column metadata interfaces]
 ** for the same [prepared statement] and result column
@@ -3324,17 +3289,17 @@ SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
 
 /*
-** CAPI3REF: Declared Datatype Of A Query Result {H13760} <S10700>
+** CAPI3REF: Declared Datatype Of A Query Result
 **
-** The first parameter is a [prepared statement].
+** ^(The first parameter is a [prepared statement].
 ** If this statement is a [SELECT] statement and the Nth column of the
 ** returned result set of that [SELECT] is a table column (not an
 ** expression or subquery) then the declared type of the table
-** column is returned.  If the Nth column of the result set is an
+** column is returned.)^  ^If the Nth column of the result set is an
 ** expression or subquery, then a NULL pointer is returned.
-** The returned string is always UTF-8 encoded. {END}
+** ^The returned string is always UTF-8 encoded.
 **
-** For example, given the database schema:
+** ^(For example, given the database schema:
 **
 ** CREATE TABLE t1(c1 VARIANT);
 **
@@ -3343,23 +3308,20 @@ SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
 ** SELECT c1 + 1, c1 FROM t1;
 **
 ** this routine would return the string "VARIANT" for the second result
-** column (i==1), and a NULL pointer for the first result column (i==0).
+** column (i==1), and a NULL pointer for the first result column (i==0).)^
 **
-** SQLite uses dynamic run-time typing.  So just because a column
+** ^SQLite uses dynamic run-time typing.  ^So just because a column
 ** is declared to contain a particular type does not mean that the
 ** data stored in that column is of the declared type.  SQLite is
-** strongly typed, but the typing is dynamic not static.  Type
+** strongly typed, but the typing is dynamic not static.  ^Type
 ** is associated with individual values, not with the containers
 ** used to hold those values.
-**
-** Requirements:
-** [H13761] [H13762] [H13763]
 */
 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
 
 /*
-** CAPI3REF: Evaluate An SQL Statement {H13200} <S10000>
+** CAPI3REF: Evaluate An SQL Statement
 **
 ** After a [prepared statement] has been prepared using either
 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
@@ -3373,35 +3335,35 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
 ** new "v2" interface is recommended for new applications but the legacy
 ** interface will continue to be supported.
 **
-** In the legacy interface, the return value will be either [SQLITE_BUSY],
+** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
-** With the "v2" interface, any of the other [result codes] or
+** ^With the "v2" interface, any of the other [result codes] or
 ** [extended result codes] might be returned as well.
 **
-** [SQLITE_BUSY] means that the database engine was unable to acquire the
-** database locks it needs to do its job.  If the statement is a [COMMIT]
+** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
+** database locks it needs to do its job.  ^If the statement is a [COMMIT]
 ** or occurs outside of an explicit transaction, then you can retry the
 ** statement.  If the statement is not a [COMMIT] and occurs within a
 ** explicit transaction then you should rollback the transaction before
 ** continuing.
 **
-** [SQLITE_DONE] means that the statement has finished executing
+** ^[SQLITE_DONE] means that the statement has finished executing
 ** successfully.  sqlite3_step() should not be called again on this virtual
 ** machine without first calling [sqlite3_reset()] to reset the virtual
 ** machine back to its initial state.
 **
-** If the SQL statement being executed returns any data, then [SQLITE_ROW]
+** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]
 ** is returned each time a new row of data is ready for processing by the
 ** caller. The values may be accessed using the [column access functions].
 ** sqlite3_step() is called again to retrieve the next row of data.
 **
-** [SQLITE_ERROR] means that a run-time error (such as a constraint
+** ^[SQLITE_ERROR] means that a run-time error (such as a constraint
 ** violation) has occurred.  sqlite3_step() should not be called again on
 ** the VM. More information may be found by calling [sqlite3_errmsg()].
-** With the legacy interface, a more specific error code (for example,
+** ^With the legacy interface, a more specific error code (for example,
 ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
 ** can be obtained by calling [sqlite3_reset()] on the
-** [prepared statement].  In the "v2" interface,
+** [prepared statement].  ^In the "v2" interface,
 ** the more specific error code is returned directly by sqlite3_step().
 **
 ** [SQLITE_MISUSE] means that the this routine was called inappropriately.
@@ -3422,27 +3384,22 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
 ** then the more specific [error codes] are returned directly
 ** by sqlite3_step().  The use of the "v2" interface is recommended.
-**
-** Requirements:
-** [H13202] [H15304] [H15306] [H15308] [H15310]
 */
 SQLITE_API int sqlite3_step(sqlite3_stmt*);
 
 /*
-** CAPI3REF: Number of columns in a result set {H13770} <S10700>
-**
-** Returns the number of values in the current row of the result set.
+** CAPI3REF: Number of columns in a result set
 **
-** Requirements:
-** [H13771] [H13772]
+** ^The sqlite3_data_count(P) the number of columns in the
+** of the result set of [prepared statement] P.
 */
 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Fundamental Datatypes {H10265} <S10110><S10120>
+** CAPI3REF: Fundamental Datatypes
 ** KEYWORDS: SQLITE_TEXT
 **
-** {H10266} Every value in SQLite has one of five fundamental datatypes:
+** ^(Every value in SQLite has one of five fundamental datatypes:
 **
 ** <ul>
 ** <li> 64-bit signed integer
@@ -3450,7 +3407,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** <li> string
 ** <li> BLOB
 ** <li> NULL
-** </ul> {END}
+** </ul>)^
 **
 ** These constants are codes for each of those types.
 **
@@ -3471,17 +3428,19 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 #define SQLITE3_TEXT     3
 
 /*
-** CAPI3REF: Result Values From A Query {H13800} <S10700>
+** CAPI3REF: Result Values From A Query
 ** KEYWORDS: {column access functions}
 **
-** These routines form the "result set query" interface.
+** These routines form the "result set" interface.
 **
-** These routines return information about a single column of the current
-** result row of a query.  In every case the first argument is a pointer
+** ^These routines return information about a single column of the current
+** result row of a query.  ^In every case the first argument is a pointer
 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
 ** and the second argument is the index of the column for which information
-** should be returned.  The leftmost column of the result set has the index 0.
+** should be returned. ^The leftmost column of the result set has the index 0.
+** ^The number of columns in the result can be determined using
+** [sqlite3_column_count()].
 **
 ** If the SQL statement does not currently point to a valid row, or if the
 ** column index is out of range, the result is undefined.
@@ -3495,9 +3454,9 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** are called from a different thread while any of these routines
 ** are pending, then the results are undefined.
 **
-** The sqlite3_column_type() routine returns the
+** ^The sqlite3_column_type() routine returns the
 ** [SQLITE_INTEGER | datatype code] for the initial data type
-** of the result column.  The returned value is one of [SQLITE_INTEGER],
+** of the result column.  ^The returned value is one of [SQLITE_INTEGER],
 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].  The value
 ** returned by sqlite3_column_type() is only meaningful if no type
 ** conversions have occurred as described below.  After a type conversion,
@@ -3505,27 +3464,27 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** versions of SQLite may change the behavior of sqlite3_column_type()
 ** following a type conversion.
 **
-** If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
+** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
 ** routine returns the number of bytes in that BLOB or string.
-** If the result is a UTF-16 string, then sqlite3_column_bytes() converts
+** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
 ** the string to UTF-8 and then returns the number of bytes.
-** If the result is a numeric value then sqlite3_column_bytes() uses
+** ^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
+** ^The value returned does not include the zero terminator at the end
+** of the string.  ^For clarity: the value returned is 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
+** ^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()
+** ^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.
+** ^The zero terminator is not included in this count.
 **
-** The object returned by [sqlite3_column_value()] is an
+** ^The object returned by [sqlite3_column_value()] is an
 ** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object
 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
 ** If the [unprotected sqlite3_value] object returned by
@@ -3533,10 +3492,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
 ** or [sqlite3_value_bytes()], then the behavior is undefined.
 **
-** These routines attempt to convert the value where appropriate.  For
+** These routines attempt to convert the value where appropriate.  ^For
 ** example, if the internal representation is FLOAT and a text result
 ** is requested, [sqlite3_snprintf()] is used internally to perform the
-** conversion automatically.  The following table details the conversions
+** conversion automatically.  ^(The following table details the conversions
 ** that are applied:
 **
 ** <blockquote>
@@ -3560,7 +3519,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** <tr><td>  BLOB    <td>  FLOAT    <td> Convert to TEXT then use atof()
 ** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed
 ** </table>
-** </blockquote>
+** </blockquote>)^
 **
 ** The table above makes reference to standard C library functions atoi()
 ** and atof().  SQLite does not really use these functions.  It has its
@@ -3568,10 +3527,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>
@@ -3584,22 +3543,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
+** ^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
 ** 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
@@ -3609,22 +3568,18 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
 ** with calls to sqlite3_column_bytes().
 **
-** The pointers returned are valid until a type conversion occurs as
+** ^The pointers returned are valid until a type conversion occurs as
 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
-** [sqlite3_finalize()] is called.  The memory space used to hold strings
+** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
 ** and BLOBs is freed automatically.  Do <b>not</b> pass the pointers returned
 ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
 ** [sqlite3_free()].
 **
-** If a memory allocation error occurs during the evaluation of any
+** ^(If a memory allocation error occurs during the evaluation of any
 ** of these routines, a default value is returned.  The default value
 ** is either the integer 0, the floating point number 0.0, or a NULL
 ** pointer.  Subsequent calls to [sqlite3_errcode()] will return
-** [SQLITE_NOMEM].
-**
-** Requirements:
-** [H13803] [H13806] [H13809] [H13812] [H13815] [H13818] [H13821] [H13824]
-** [H13827] [H13830]
+** [SQLITE_NOMEM].)^
 */
 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
@@ -3638,79 +3593,76 @@ SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
 
 /*
-** CAPI3REF: Destroy A Prepared Statement Object {H13300} <S70300><S30100>
+** 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
+** ^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
+** ^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,
+** ^Incomplete updates may be rolled back and transactions canceled,
 ** depending on the circumstances, and the
 ** [error code] returned will be [SQLITE_ABORT].
-**
-** Requirements:
-** [H11302] [H11304]
 */
 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Reset A Prepared Statement Object {H13330} <S70300>
+** CAPI3REF: Reset A Prepared Statement Object
 **
 ** The sqlite3_reset() function is called to reset a [prepared statement]
 ** object back to its initial state, ready to be re-executed.
-** Any SQL statement variables that had values bound to them using
+** ^Any SQL statement variables that had values bound to them using
 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
 ** Use [sqlite3_clear_bindings()] to reset the bindings.
 **
-** {H11332} The [sqlite3_reset(S)] interface resets the [prepared statement] S
-**          back to the beginning of its program.
+** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
+** back to the beginning of its program.
 **
-** {H11334} If the most recent call to [sqlite3_step(S)] for the
-**          [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
-**          or if [sqlite3_step(S)] has never before been called on S,
-**          then [sqlite3_reset(S)] returns [SQLITE_OK].
+** ^If the most recent call to [sqlite3_step(S)] for the
+** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
+** or if [sqlite3_step(S)] has never before been called on S,
+** then [sqlite3_reset(S)] returns [SQLITE_OK].
 **
-** {H11336} If the most recent call to [sqlite3_step(S)] for the
-**          [prepared statement] S indicated an error, then
-**          [sqlite3_reset(S)] returns an appropriate [error code].
+** ^If the most recent call to [sqlite3_step(S)] for the
+** [prepared statement] S indicated an error, then
+** [sqlite3_reset(S)] returns an appropriate [error code].
 **
-** {H11338} The [sqlite3_reset(S)] interface does not change the values
-**          of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
+** ^The [sqlite3_reset(S)] interface does not change the values
+** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
 */
 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Create Or Redefine SQL Functions {H16100} <S20200>
+** CAPI3REF: Create Or Redefine SQL Functions
 ** KEYWORDS: {function creation routines}
 ** KEYWORDS: {application-defined SQL function}
 ** KEYWORDS: {application-defined SQL functions}
 **
-** These two functions (collectively known as "function creation routines")
+** ^These two 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().
 **
-** The first parameter is the [database connection] to which the SQL
-** function is to be added.  If a single program uses more than one database
-** connection internally, then SQL functions must be added individually to
-** each database connection.
+** ^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
+** 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
+** characters.  ^Any attempt to create a function with a longer name
 ** will result in [SQLITE_ERROR] being returned.
 **
-** The third parameter (nArg)
+** ^The third parameter (nArg)
 ** is the number of arguments that the SQL function or
-** aggregate takes. If this parameter is -1, then the SQL function or
+** aggregate takes. ^If this parameter is -1, then the SQL function or
 ** aggregate may take any number of arguments between 0 and the limit
 ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third
 ** parameter is less than -1 or greater than 127 then the behavior is
@@ -3720,53 +3672,49 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 ** [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
-** more efficient with one encoding than another.  An application may
+** 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.
-** When multiple implementations of the same function are available, SQLite
+** ^When multiple implementations of the same function are available, SQLite
 ** will pick the one that involves the least amount of data conversion.
 ** If there is only a single implementation which does not care what text
 ** encoding is used, then the fourth argument should be [SQLITE_ANY].
 **
-** The fifth parameter is an arbitrary pointer.  The implementation of the
-** function can gain access to this pointer using [sqlite3_user_data()].
+** ^(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
 ** 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
-** parameters. An aggregate SQL function requires an implementation of xStep
-** and xFinal and NULL should be passed for xFunc. To delete an existing
+** aggregate. ^A scalar SQL function requires an implementation of the xFunc
+** callback only; NULL pointers should 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.
 **
-** It is permitted to register multiple implementations of the same
+** ^It is permitted to register multiple implementations of the same
 ** functions with the same name but with either differing numbers of
-** arguments or differing preferred text encodings.  SQLite will use
+** arguments or differing preferred text encodings.  ^SQLite will use
 ** the implementation that most closely matches the way in which the
-** SQL function is used.  A function implementation with a non-negative
+** SQL function is used.  ^A function implementation with a non-negative
 ** nArg parameter is a better match than a function implementation with
-** a negative nArg.  A function where the preferred text encoding
+** a negative nArg.  ^A function where the preferred text encoding
 ** matches the database encoding is a better
 ** match than a function where the encoding is different.  
-** A function where the encoding difference is between UTF16le and UTF16be
+** ^A function where the encoding difference is between UTF16le and UTF16be
 ** is a closer match than a function where the encoding difference is
 ** 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 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 
+** ^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
+** ^An application-defined function is permitted to call other
 ** SQLite interfaces.  However, such calls must not
 ** close the database connection nor finalize or reset the prepared
 ** statement in which the function is running.
-**
-** Requirements:
-** [H16103] [H16106] [H16109] [H16112] [H16118] [H16121] [H16127]
-** [H16130] [H16133] [H16136] [H16139] [H16142]
 */
 SQLITE_API int sqlite3_create_function(
   sqlite3 *db,
@@ -3790,7 +3738,7 @@ SQLITE_API int sqlite3_create_function16(
 );
 
 /*
-** CAPI3REF: Text Encodings {H10267} <S50200> <H16100>
+** CAPI3REF: Text Encodings
 **
 ** These constant define integer codes that represent the various
 ** text encodings supported by SQLite.
@@ -3822,7 +3770,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
 #endif
 
 /*
-** CAPI3REF: Obtaining SQL Function Parameter Values {H15100} <S20200>
+** CAPI3REF: Obtaining SQL Function Parameter Values
 **
 ** The C-language implementation of SQL functions and aggregates uses
 ** this set of interface routines to access the parameter values on
@@ -3840,22 +3788,22 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
 ** Any attempt to use these routines on an [unprotected sqlite3_value]
 ** object results in undefined behavior.
 **
-** These routines work just like the corresponding [column access functions]
+** ^These routines work just like the corresponding [column access functions]
 ** except that  these routines take a single [protected sqlite3_value] object
 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
 **
-** The sqlite3_value_text16() interface extracts a UTF-16 string
-** in the native byte-order of the host machine.  The
+** ^The sqlite3_value_text16() interface extracts a UTF-16 string
+** in the native byte-order of the host machine.  ^The
 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
 ** extract UTF-16 strings as big-endian and little-endian respectively.
 **
-** The sqlite3_value_numeric_type() interface attempts to apply
+** ^(The sqlite3_value_numeric_type() interface attempts to apply
 ** numeric affinity to the value.  This means that an attempt is
 ** made to convert the value to an integer or floating point.  If
 ** such a conversion is possible without loss of information (in other
 ** words, if the value is a string that looks like a number)
 ** then the conversion is performed.  Otherwise no conversion occurs.
-** The [SQLITE_INTEGER | datatype] after conversion is returned.
+** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
 **
 ** Please pay particular attention to the fact that the pointer returned
 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
@@ -3865,10 +3813,6 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
 **
 ** These routines must be called from the same thread as
 ** the SQL function that supplied the [sqlite3_value*] parameters.
-**
-** Requirements:
-** [H15103] [H15106] [H15109] [H15112] [H15115] [H15118] [H15121] [H15124]
-** [H15127] [H15130] [H15133] [H15136]
 */
 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -3884,66 +3828,73 @@ SQLITE_API int sqlite3_value_type(sqlite3_value*);
 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
 
 /*
-** CAPI3REF: Obtain Aggregate Function Context {H16210} <S20200>
+** CAPI3REF: Obtain Aggregate Function Context
 **
-** The implementation of aggregate SQL functions use this routine to allocate
-** a structure for storing their state.
+** Implementions of aggregate SQL functions use this
+** routine to allocate memory for storing their state.
 **
-** The first time the sqlite3_aggregate_context() routine is called for a
-** particular aggregate, SQLite allocates nBytes of memory, zeroes out that
-** memory, and returns a pointer to it. On second and subsequent calls to
-** sqlite3_aggregate_context() for the same aggregate function index,
-** the same buffer is returned. The implementation of the aggregate can use
-** the returned buffer to accumulate data.
+** ^The first time the sqlite3_aggregate_context(C,N) routine is called 
+** for a particular aggregate function, SQLite
+** allocates N of memory, zeroes out that memory, and returns a pointer
+** to the new memory. ^On second and subsequent calls to
+** sqlite3_aggregate_context() for the same aggregate function instance,
+** the same buffer is returned.  Sqlite3_aggregate_context() is normally
+** called once for each invocation of the xStep callback and then one
+** last time when the xFinal callback is invoked.  ^(When no rows match
+** an aggregate query, the xStep() callback of the aggregate function
+** implementation is never called and xFinal() is called exactly once.
+** In those cases, sqlite3_aggregate_context() might be called for the
+** first time from within xFinal().)^
 **
-** SQLite automatically frees the allocated buffer when the aggregate
-** query concludes.
+** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is
+** less than or equal to zero or if a memory allocate error occurs.
 **
-** The first parameter should be a copy of the
+** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
+** determined by the N parameter on first successful call.  Changing the
+** value of N in subsequent call to sqlite3_aggregate_context() within
+** the same aggregate function instance will not resize the memory
+** allocation.)^
+**
+** ^SQLite automatically frees the memory allocated by 
+** sqlite3_aggregate_context() when the aggregate query concludes.
+**
+** The first parameter must be a copy of the
 ** [sqlite3_context | SQL function context] that is the first parameter
-** to the callback routine that implements the aggregate function.
+** to the xStep or xFinal callback routine that implements the aggregate
+** function.
 **
 ** This routine must be called from the same thread in which
 ** the aggregate SQL function is running.
-**
-** Requirements:
-** [H16211] [H16213] [H16215] [H16217]
 */
 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
 
 /*
-** CAPI3REF: User Data For Functions {H16240} <S20200>
+** CAPI3REF: User Data For Functions
 **
-** The sqlite3_user_data() interface returns a copy of
+** ^The sqlite3_user_data() interface returns a copy of
 ** the pointer that was the pUserData parameter (the 5th parameter)
 ** of the [sqlite3_create_function()]
 ** and [sqlite3_create_function16()] routines that originally
-** registered the application defined function. {END}
+** registered the application defined function.
 **
 ** This routine must be called from the same thread in which
 ** the application-defined function is running.
-**
-** Requirements:
-** [H16243]
 */
 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
 
 /*
-** CAPI3REF: Database Connection For Functions {H16250} <S60600><S20200>
+** CAPI3REF: Database Connection For Functions
 **
-** The sqlite3_context_db_handle() interface returns a copy of
+** ^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.
-**
-** Requirements:
-** [H16253]
 */
 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
 
 /*
-** CAPI3REF: Function Auxiliary Data {H16270} <S20200>
+** CAPI3REF: Function Auxiliary Data
 **
 ** The following two functions may be used by scalar SQL functions to
 ** associate metadata with argument values. If the same value is passed to
@@ -3956,48 +3907,45 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
 ** invocations of the same function so that the original pattern string
 ** does not need to be recompiled on each invocation.
 **
-** The sqlite3_get_auxdata() interface returns a pointer to the metadata
+** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
 ** associated by the sqlite3_set_auxdata() function with the Nth argument
-** value to the application-defined function. If no metadata has been ever
+** value to the application-defined function. ^If no metadata has been ever
 ** been set for the Nth argument of the function, or if the corresponding
 ** function parameter has changed since the meta-data was set,
 ** then sqlite3_get_auxdata() returns a NULL pointer.
 **
-** The sqlite3_set_auxdata() interface saves the metadata
+** ^The sqlite3_set_auxdata() interface saves the metadata
 ** pointed to by its 3rd parameter as the metadata for the N-th
 ** argument of the application-defined function.  Subsequent
 ** calls to sqlite3_get_auxdata() might return this data, if it has
 ** not been destroyed.
-** If it is not NULL, SQLite will invoke the destructor
+** ^If it is not NULL, SQLite will invoke the destructor
 ** function given by the 4th parameter to sqlite3_set_auxdata() on
 ** the metadata when the corresponding function parameter changes
 ** or when the SQL statement completes, whichever comes first.
 **
 ** SQLite is free to call the destructor and drop metadata on any
-** parameter of any function at any time.  The only guarantee is that
+** parameter of any function at any time.  ^The only guarantee is that
 ** the destructor will be called before the metadata is dropped.
 **
-** In practice, metadata is preserved between function calls for
+** ^(In practice, metadata is preserved between function calls for
 ** expressions that are constant at compile time. This includes literal
-** values and SQL variables.
+** values and [parameters].)^
 **
 ** These routines must be called from the same thread in which
 ** the SQL function is running.
-**
-** Requirements:
-** [H16272] [H16274] [H16276] [H16277] [H16278] [H16279]
 */
 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
 
 
 /*
-** CAPI3REF: Constants Defining Special Destructor Behavior {H10280} <S30100>
+** CAPI3REF: Constants Defining Special Destructor Behavior
 **
 ** These are special values for the destructor that is passed in as the
-** final argument to routines like [sqlite3_result_blob()].  If the destructor
+** final argument to routines like [sqlite3_result_blob()].  ^If the destructor
 ** argument is SQLITE_STATIC, it means that the content pointer is constant
-** and will never change.  It does not need to be destroyed.  The
+** and will never change.  It does not need to be destroyed.  ^The
 ** SQLITE_TRANSIENT value means that the content will likely change in
 ** the near future and that SQLite should make its own private copy of
 ** the content before returning.
@@ -4010,7 +3958,7 @@ typedef void (*sqlite3_destructor_type)(void*);
 #define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)
 
 /*
-** CAPI3REF: Setting The Result Of An SQL Function {H16400} <S20200>
+** CAPI3REF: Setting The Result Of An SQL Function
 **
 ** These routines are used by the xFunc or xFinal callbacks that
 ** implement SQL functions and aggregates.  See
@@ -4021,103 +3969,98 @@ typedef void (*sqlite3_destructor_type)(void*);
 ** functions used to bind values to host parameters in prepared statements.
 ** Refer to the [SQL parameter] documentation for additional information.
 **
-** The sqlite3_result_blob() interface sets the result from
+** ^The sqlite3_result_blob() interface sets the result from
 ** an application-defined function to be the BLOB whose content is pointed
 ** to by the second parameter and which is N bytes long where N is the
 ** third parameter.
 **
-** The sqlite3_result_zeroblob() interfaces set the result of
+** ^The sqlite3_result_zeroblob() interfaces set the result of
 ** the application-defined function to be a BLOB containing all zero
 ** bytes and N bytes in size, where N is the value of the 2nd parameter.
 **
-** The sqlite3_result_double() interface sets the result from
+** ^The sqlite3_result_double() interface sets the result from
 ** an application-defined function to be a floating point value specified
 ** by its 2nd argument.
 **
-** The sqlite3_result_error() and sqlite3_result_error16() functions
+** ^The sqlite3_result_error() and sqlite3_result_error16() functions
 ** cause the implemented SQL function to throw an exception.
-** SQLite uses the string pointed to by the
+** ^SQLite uses the string pointed to by the
 ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
-** as the text of an error message.  SQLite interprets the error
-** message string from sqlite3_result_error() as UTF-8. SQLite
+** as the text of an error message.  ^SQLite interprets the error
+** message string from sqlite3_result_error() as UTF-8. ^SQLite
 ** interprets the string from sqlite3_result_error16() as UTF-16 in native
-** byte order.  If the third parameter to sqlite3_result_error()
+** byte order.  ^If the third parameter to sqlite3_result_error()
 ** or sqlite3_result_error16() is negative then SQLite takes as the error
 ** message all text up through the first zero character.
-** If the third parameter to sqlite3_result_error() or
+** ^If the third parameter to sqlite3_result_error() or
 ** sqlite3_result_error16() is non-negative then SQLite takes that many
 ** bytes (not characters) from the 2nd parameter as the error message.
-** The sqlite3_result_error() and sqlite3_result_error16()
+** ^The sqlite3_result_error() and sqlite3_result_error16()
 ** routines make a private copy of the error message text before
 ** they return.  Hence, the calling function can deallocate or
 ** modify the text after they return without harm.
-** The sqlite3_result_error_code() function changes the error code
-** returned by SQLite as a result of an error in a function.  By default,
-** the error code is SQLITE_ERROR.  A subsequent call to sqlite3_result_error()
+** ^The sqlite3_result_error_code() function changes the error code
+** returned by SQLite as a result of an error in a function.  ^By default,
+** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()
 ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
 **
-** The sqlite3_result_toobig() interface causes SQLite to throw an error
-** indicating that a string or BLOB is to long to represent.
+** ^The sqlite3_result_toobig() interface causes SQLite to throw an error
+** indicating that a string or BLOB is too long to represent.
 **
-** The sqlite3_result_nomem() interface causes SQLite to throw an error
+** ^The sqlite3_result_nomem() interface causes SQLite to throw an error
 ** indicating that a memory allocation failed.
 **
-** The sqlite3_result_int() interface sets the return value
+** ^The sqlite3_result_int() interface sets the return value
 ** of the application-defined function to be the 32-bit signed integer
 ** value given in the 2nd argument.
-** The sqlite3_result_int64() interface sets the return value
+** ^The sqlite3_result_int64() interface sets the return value
 ** of the application-defined function to be the 64-bit signed integer
 ** value given in the 2nd argument.
 **
-** The sqlite3_result_null() interface sets the return value
+** ^The sqlite3_result_null() interface sets the return value
 ** of the application-defined function to be NULL.
 **
-** The sqlite3_result_text(), sqlite3_result_text16(),
+** ^The sqlite3_result_text(), sqlite3_result_text16(),
 ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
 ** set the return value of the application-defined function to be
 ** a text string which is represented as UTF-8, UTF-16 native byte order,
 ** UTF-16 little endian, or UTF-16 big endian, respectively.
-** SQLite takes the text result from the application from
+** ^SQLite takes the text result from the application from
 ** the 2nd parameter of the sqlite3_result_text* interfaces.
-** If the 3rd parameter to the sqlite3_result_text* interfaces
+** ^If the 3rd parameter to the sqlite3_result_text* interfaces
 ** is negative, then SQLite takes result text from the 2nd parameter
 ** through the first zero character.
-** If the 3rd parameter to the sqlite3_result_text* interfaces
+** ^If the 3rd parameter to the sqlite3_result_text* interfaces
 ** is non-negative, then as many bytes (not characters) of the text
 ** pointed to by the 2nd parameter are taken as the application-defined
 ** function result.
-** If the 4th parameter to the sqlite3_result_text* interfaces
+** ^If the 4th parameter to the sqlite3_result_text* interfaces
 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
 ** function as the destructor on the text or BLOB result when it has
 ** finished using that result.
-** If the 4th parameter to the sqlite3_result_text* interfaces or to
+** ^If the 4th parameter to the sqlite3_result_text* interfaces or to
 ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
 ** assumes that the text or BLOB result is in constant space and does not
 ** copy the content of the parameter nor call a destructor on the content
 ** when it has finished using that result.
-** If the 4th parameter to the sqlite3_result_text* interfaces
+** ^If the 4th parameter to the sqlite3_result_text* interfaces
 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
 ** then SQLite makes a copy of the result into space obtained from
 ** from [sqlite3_malloc()] before it returns.
 **
-** The sqlite3_result_value() interface sets the result of
+** ^The sqlite3_result_value() interface sets the result of
 ** the application-defined function to be a copy the
-** [unprotected sqlite3_value] object specified by the 2nd parameter.  The
+** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The
 ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
 ** so that the [sqlite3_value] specified in the parameter may change or
 ** be deallocated after sqlite3_result_value() returns without harm.
-** A [protected sqlite3_value] object may always be used where an
+** ^A [protected sqlite3_value] object may always be used where an
 ** [unprotected sqlite3_value] object is required, so either
 ** kind of [sqlite3_value] object can be used with this interface.
 **
 ** If these routines are called from within the different thread
 ** than the one containing the application-defined function that received
 ** the [sqlite3_context] pointer, the results are undefined.
-**
-** Requirements:
-** [H16403] [H16406] [H16409] [H16412] [H16415] [H16418] [H16421] [H16424]
-** [H16427] [H16430] [H16433] [H16436] [H16439] [H16442] [H16445] [H16448]
-** [H16451] [H16454] [H16457] [H16460] [H16463]
 */
 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
@@ -4137,20 +4080,20 @@ SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
 
 /*
-** CAPI3REF: Define New Collating Sequences {H16600} <S20300>
+** CAPI3REF: Define New Collating Sequences
 **
 ** These functions are used to add new collation sequences to 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 new collation sequence is specified as 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
+** 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],
+** ^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
+** 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
@@ -4158,33 +4101,29 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
 ** 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
+** 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
+** ^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,
+** ^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. {END}  The application defined collation routine should
+** 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).
 **
-** The sqlite3_create_collation_v2() works like sqlite3_create_collation()
+** ^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
+** 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
+** ^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()].
 **
 ** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
-**
-** Requirements:
-** [H16603] [H16604] [H16606] [H16609] [H16612] [H16615] [H16618] [H16621]
-** [H16624] [H16627] [H16630]
 */
 SQLITE_API int sqlite3_create_collation(
   sqlite3*, 
@@ -4210,33 +4149,30 @@ SQLITE_API int sqlite3_create_collation16(
 );
 
 /*
-** CAPI3REF: Collation Needed Callbacks {H16700} <S20300>
+** CAPI3REF: Collation Needed Callbacks
 **
-** To avoid having to register all collation sequences before a database
+** ^To avoid having to register all collation sequences before a database
 ** can be used, a single callback function may be registered with the
-** [database connection] to be called whenever an undefined collation
+** [database connection] to be invoked whenever an undefined collation
 ** sequence is required.
 **
-** If the function is registered using the sqlite3_collation_needed() API,
+** ^If the function is registered using the sqlite3_collation_needed() API,
 ** then it is passed the names of undefined collation sequences as strings
-** encoded in UTF-8. {H16703} If sqlite3_collation_needed16() is used,
+** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,
 ** the names are passed as UTF-16 in machine native byte order.
-** A call to either function replaces any existing callback.
+** ^A call to either function replaces the existing collation-needed callback.
 **
-** When the callback is invoked, the first argument passed is a copy
+** ^(When the callback is invoked, the first argument passed is a copy
 ** of the second argument to sqlite3_collation_needed() or
 ** sqlite3_collation_needed16().  The second argument is the database
 ** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
 ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
 ** sequence function required.  The fourth parameter is the name of the
-** required collation sequence.
+** required collation sequence.)^
 **
 ** The callback function should register the desired collation using
 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
 ** [sqlite3_create_collation_v2()].
-**
-** Requirements:
-** [H16702] [H16704] [H16706]
 */
 SQLITE_API int sqlite3_collation_needed(
   sqlite3*, 
@@ -4275,29 +4211,28 @@ SQLITE_API int sqlite3_rekey(
 );
 
 /*
-** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410>
+** 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()
+** ^SQLite implements this interface by calling the xSleep()
 ** method of the default [sqlite3_vfs] object.
-**
-** Requirements: [H10533] [H10536]
 */
 SQLITE_API int sqlite3_sleep(int);
 
 /*
-** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000>
+** CAPI3REF: Name Of The Folder Holding Temporary Files
 **
-** If this global variable is made to point to a string which is
+** ^(If this global variable is made to point to a string which is
 ** the name of a folder (a.k.a. directory), then all temporary files
-** created by SQLite will be placed in that directory.  If this variable
+** created by SQLite when using a built-in [sqlite3_vfs | VFS]
+** will be placed in that directory.)^  ^If this variable
 ** is a NULL pointer, then SQLite performs a search for an appropriate
 ** temporary file directory.
 **
@@ -4310,8 +4245,8 @@ SQLITE_API int sqlite3_sleep(int);
 ** routines have been called and that this variable remain unchanged
 ** thereafter.
 **
-** The [temp_store_directory pragma] may modify this variable and cause
-** it to point to memory obtained from [sqlite3_malloc].  Furthermore,
+** ^The [temp_store_directory pragma] may modify this variable and cause
+** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,
 ** the [temp_store_directory pragma] always assumes that any string
 ** that this variable points to is held in memory obtained from 
 ** [sqlite3_malloc] and the pragma may attempt to free that memory
@@ -4323,14 +4258,14 @@ SQLITE_API int sqlite3_sleep(int);
 SQLITE_API char *sqlite3_temp_directory;
 
 /*
-** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
+** CAPI3REF: Test For Auto-Commit Mode
 ** KEYWORDS: {autocommit mode}
 **
-** The sqlite3_get_autocommit() interface returns non-zero or
+** ^The sqlite3_get_autocommit() interface returns non-zero or
 ** zero if the given database connection is or is not in autocommit mode,
-** respectively.  Autocommit mode is on by default.
-** Autocommit mode is disabled by a [BEGIN] statement.
-** Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
+** respectively.  ^Autocommit mode is on by default.
+** ^Autocommit mode is disabled by a [BEGIN] statement.
+** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
 **
 ** If certain kinds of errors occur on a statement within a multi-statement
 ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
@@ -4342,58 +4277,55 @@ SQLITE_API char *sqlite3_temp_directory;
 ** If another thread changes the autocommit status of the database
 ** connection while this routine is running, then the return value
 ** is undefined.
-**
-** Requirements: [H12931] [H12932] [H12933] [H12934]
 */
 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
 
 /*
-** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600>
+** CAPI3REF: Find The Database Handle Of A Prepared Statement
 **
-** The sqlite3_db_handle interface returns the [database connection] handle
-** to which a [prepared statement] belongs.  The [database connection]
-** returned by sqlite3_db_handle is the same [database connection] that was the first argument
+** ^The sqlite3_db_handle interface returns the [database connection] handle
+** to which a [prepared statement] belongs.  ^The [database connection]
+** returned by sqlite3_db_handle is the same [database connection]
+** that was the first argument
 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
 ** create the statement in the first place.
-**
-** Requirements: [H13123]
 */
 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
 
 /*
-** CAPI3REF: Find the next prepared statement {H13140} <S60600>
+** CAPI3REF: Find the next prepared statement
 **
-** This interface returns a pointer to the next [prepared statement] after
-** pStmt associated with the [database connection] pDb.  If pStmt is NULL
+** ^This interface returns a pointer to the next [prepared statement] after
+** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL
 ** then this interface returns a pointer to the first prepared statement
-** associated with the database connection pDb.  If no prepared statement
+** associated with the database connection pDb.  ^If no prepared statement
 ** satisfies the conditions of this routine, it returns NULL.
 **
 ** The [database connection] pointer D in a call to
 ** [sqlite3_next_stmt(D,S)] must refer to an open database
 ** connection and in particular must not be a NULL pointer.
-**
-** Requirements: [H13143] [H13146] [H13149] [H13152]
 */
 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400>
+** CAPI3REF: Commit And Rollback Notification Callbacks
 **
-** The sqlite3_commit_hook() interface registers a callback
+** ^The sqlite3_commit_hook() interface registers a callback
 ** function to be invoked whenever a transaction is [COMMIT | committed].
-** Any callback set by a previous call to sqlite3_commit_hook()
+** ^Any callback set by a previous call to sqlite3_commit_hook()
 ** for the same database connection is overridden.
-** The sqlite3_rollback_hook() interface registers a callback
+** ^The sqlite3_rollback_hook() interface registers a callback
 ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
-** Any callback set by a previous call to sqlite3_commit_hook()
+** ^Any callback set by a previous call to sqlite3_rollback_hook()
 ** for the same database connection is overridden.
-** The pArg argument is passed through to the callback.
-** If the callback on a commit hook function returns non-zero,
+** ^The pArg argument is passed through to the callback.
+** ^If the callback on a commit hook function returns non-zero,
 ** then the commit is converted into a rollback.
 **
-** If another function was previously registered, its
-** pArg value is returned.  Otherwise NULL is returned.
+** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
+** return the P argument from the previous call of the same function
+** on the same [database connection] D, or NULL for
+** the first call for each function on D.
 **
 ** The callback implementation must not do anything that will modify
 ** the database connection that invoked the callback.  Any actions
@@ -4403,59 +4335,54 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
-** Registering a NULL function disables the callback.
+** ^Registering a NULL function disables the callback.
 **
-** When the commit hook callback routine returns zero, the [COMMIT]
-** operation is allowed to continue normally.  If the commit hook
+** ^When the commit hook callback routine returns zero, the [COMMIT]
+** operation is allowed to continue normally.  ^If the commit hook
 ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
-** The rollback hook is invoked on a rollback that results from a commit
+** ^The rollback hook is invoked on a rollback that results from a commit
 ** hook returning non-zero, just as it would be with any other rollback.
 **
-** For the purposes of this API, a transaction is said to have been
+** ^For the purposes of this API, a transaction is said to have been
 ** rolled back if an explicit "ROLLBACK" statement is executed, or
 ** an error or constraint causes an implicit rollback to occur.
-** The rollback callback is not invoked if a transaction is
+** ^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
+** ^The rollback callback is not invoked if a transaction is
 ** rolled back because a commit callback returned non-zero.
-** <todo> Check on this </todo>
 **
 ** See also the [sqlite3_update_hook()] interface.
-**
-** Requirements:
-** [H12951] [H12952] [H12953] [H12954] [H12955]
-** [H12961] [H12962] [H12963] [H12964]
 */
 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
 
 /*
-** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400>
+** CAPI3REF: Data Change Notification Callbacks
 **
-** The sqlite3_update_hook() interface registers a callback function
+** ^The sqlite3_update_hook() interface registers a callback function
 ** with the [database connection] identified by the first argument
 ** to be invoked whenever a row is updated, inserted or deleted.
-** Any callback set by a previous call to this function
+** ^Any callback set by a previous call to this function
 ** for the same database connection is overridden.
 **
-** The second argument is a pointer to the function to invoke when a
+** ^The second argument is a pointer to the function to invoke when a
 ** row is updated, inserted or deleted.
-** The first argument to the callback is a copy of the third argument
+** ^The first argument to the callback is a copy of the third argument
 ** to sqlite3_update_hook().
-** The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
+** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
 ** or [SQLITE_UPDATE], depending on the operation that caused the callback
 ** to be invoked.
-** The third and fourth arguments to the callback contain pointers to the
+** ^The third and fourth arguments to the callback contain pointers to the
 ** database and table name containing the affected row.
-** The final callback parameter is the [rowid] of the row.
-** In the case of an update, this is the [rowid] after the update takes place.
+** ^The final callback parameter is the [rowid] of the row.
+** ^In the case of an update, this is the [rowid] after the update takes place.
 **
-** The update hook is not invoked when internal system tables are
-** modified (i.e. sqlite_master and sqlite_sequence).
+** ^(The update hook is not invoked when internal system tables are
+** modified (i.e. sqlite_master and sqlite_sequence).)^
 **
-** In the current implementation, the update hook
+** ^In the current implementation, the update hook
 ** is not invoked when duplication rows are deleted because of an
-** [ON CONFLICT | ON CONFLICT REPLACE] clause.  Nor is the update hook
+** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook
 ** invoked when rows are deleted using the [truncate optimization].
 ** The exceptions defined in this paragraph might change in a future
 ** release of SQLite.
@@ -4467,14 +4394,13 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
-** If another function was previously registered, its pArg value
-** is returned.  Otherwise NULL is returned.
+** ^The sqlite3_update_hook(D,C,P) function
+** returns the P argument from the previous call
+** on the same [database connection] D, or NULL for
+** the first call on D.
 **
 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
 ** interfaces.
-**
-** Requirements:
-** [H12971] [H12973] [H12975] [H12977] [H12979] [H12981] [H12983] [H12986]
 */
 SQLITE_API void *sqlite3_update_hook(
   sqlite3*, 
@@ -4483,74 +4409,66 @@ SQLITE_API void *sqlite3_update_hook(
 );
 
 /*
-** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900>
+** CAPI3REF: Enable Or Disable Shared Pager Cache
 ** KEYWORDS: {shared cache}
 **
-** This routine enables or disables the sharing of the database cache
+** ^(This routine enables or disables the sharing of the database cache
 ** and schema data structures between [database connection | connections]
 ** to the same database. Sharing is enabled if the argument is true
-** and disabled if the argument is false.
+** and disabled if the argument is false.)^
 **
-** Cache sharing is enabled and disabled for an entire process.
+** ^Cache sharing is enabled and disabled for an entire process.
 ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
 ** sharing was enabled or disabled for each thread separately.
 **
-** The cache sharing mode set by this interface effects all subsequent
+** ^(The cache sharing mode set by this interface effects all subsequent
 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
 ** Existing database connections continue use the sharing mode
-** that was in effect at the time they were opened.
+** that was in effect at the time they were opened.)^
 **
-** Virtual tables cannot be used with a shared cache.  When shared
-** cache is enabled, the [sqlite3_create_module()] API used to register
-** virtual tables will always return an error.
+** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
+** successfully.  An [error code] is returned otherwise.)^
 **
-** This routine returns [SQLITE_OK] if shared cache was enabled or disabled
-** successfully.  An [error code] is returned otherwise.
-**
-** Shared cache is disabled by default. But this might change in
+** ^Shared cache is disabled by default. But this might change in
 ** future releases of SQLite.  Applications that care about shared
 ** cache setting should set it explicitly.
 **
 ** See Also:  [SQLite Shared-Cache Mode]
-**
-** Requirements: [H10331] [H10336] [H10337] [H10339]
 */
 SQLITE_API int sqlite3_enable_shared_cache(int);
 
 /*
-** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220>
+** CAPI3REF: Attempt To Free Heap Memory
 **
-** The sqlite3_release_memory() interface attempts to free N bytes
+** ^The sqlite3_release_memory() interface attempts to free N bytes
 ** of heap memory by deallocating non-essential memory allocations
-** held by the database library. {END}  Memory used to cache database
+** held by the database library.   Memory used to cache database
 ** pages to improve performance is an example of non-essential memory.
-** sqlite3_release_memory() returns the number of bytes actually freed,
+** ^sqlite3_release_memory() returns the number of bytes actually freed,
 ** which might be more or less than the amount requested.
-**
-** Requirements: [H17341] [H17342]
 */
 SQLITE_API int sqlite3_release_memory(int);
 
 /*
-** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220>
+** CAPI3REF: Impose A Limit On Heap Size
 **
-** The sqlite3_soft_heap_limit() interface places a "soft" limit
+** ^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
+** ^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 limit is called "soft", because if [sqlite3_release_memory()]
+** ^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.
 **
-** A negative or zero value for N means that there is no soft heap limit and
+** ^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.
+** ^The default value for the soft heap limit is zero.
 **
-** SQLite makes a best effort to honor the soft heap limit.
+** ^(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
+** continue without error or notification.)^  This is why the limit is
 ** called a "soft" limit.  It is advisory only.
 **
 ** Prior to SQLite version 3.5.0, this routine only constrained the memory
@@ -4560,35 +4478,32 @@ SQLITE_API int sqlite3_release_memory(int);
 ** 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.
-**
-** Requirements:
-** [H16351] [H16352] [H16353] [H16354] [H16355] [H16358]
 */
 SQLITE_API void sqlite3_soft_heap_limit(int);
 
 /*
-** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300>
+** CAPI3REF: Extract Metadata About A Column Of A Table
 **
-** This routine returns metadata about a specific column of a specific
+** ^This routine returns metadata about a specific column of a specific
 ** database table accessible using the [database connection] handle
 ** passed as the first function argument.
 **
-** The column is identified by the second, third and fourth parameters to
-** this function. The second parameter is either the name of the database
-** (i.e. "main", "temp" or an attached database) containing the specified
-** table or NULL. If it is NULL, then all attached databases are searched
+** ^The column is identified by the second, third and fourth parameters to
+** this function. ^The second parameter is either the name of the database
+** (i.e. "main", "temp", or an attached database) containing the specified
+** table or NULL. ^If it is NULL, then all attached databases are searched
 ** for the table using the same algorithm used by the database engine to
 ** resolve unqualified table references.
 **
-** The third and fourth parameters to this function are the table and column
+** ^The third and fourth parameters to this function are the table and column
 ** name of the desired column, respectively. Neither of these parameters
 ** may be NULL.
 **
-** Metadata is returned by writing to the memory locations passed as the 5th
-** and subsequent parameters to this function. Any of these arguments may be
+** ^Metadata is returned by writing to the memory locations passed as the 5th
+** and subsequent parameters to this function. ^Any of these arguments may be
 ** NULL, in which case the corresponding element of metadata is omitted.
 **
-** <blockquote>
+** ^(<blockquote>
 ** <table border="1">
 ** <tr><th> Parameter <th> Output<br>Type <th>  Description
 **
@@ -4598,17 +4513,17 @@ SQLITE_API void sqlite3_soft_heap_limit(int);
 ** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY
 ** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]
 ** </table>
-** </blockquote>
+** </blockquote>)^
 **
-** The memory pointed to by the character pointers returned for the
+** ^The memory pointed to by the character pointers returned for the
 ** declaration type and collation sequence is valid only until the next
 ** call to any SQLite API function.
 **
-** If the specified table is actually a view, an [error code] is returned.
+** ^If the specified table is actually a view, an [error code] is returned.
 **
-** If the specified column is "rowid", "oid" or "_rowid_" and an
+** ^If the specified column is "rowid", "oid" or "_rowid_" and an
 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
-** parameters are set for the explicitly declared column. If there is no
+** parameters are set for the explicitly declared column. ^(If there is no
 ** explicitly declared [INTEGER PRIMARY KEY] column, then the output
 ** parameters are set as follows:
 **
@@ -4618,14 +4533,14 @@ SQLITE_API void sqlite3_soft_heap_limit(int);
 **     not null: 0
 **     primary key: 1
 **     auto increment: 0
-** </pre>
+** </pre>)^
 **
-** This function may load one or more schemas from database files. If an
+** ^(This function may load one or more schemas from database files. If an
 ** error occurs during this process, or if the requested table or column
 ** cannot be found, an [error code] is returned and an error message left
-** in the [database connection] (to be retrieved using sqlite3_errmsg()).
+** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
 **
-** This API is only available if the library was compiled with the
+** ^This API is only available if the library was compiled with the
 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
 */
 SQLITE_API int sqlite3_table_column_metadata(
@@ -4641,30 +4556,29 @@ SQLITE_API int sqlite3_table_column_metadata(
 );
 
 /*
-** CAPI3REF: Load An Extension {H12600} <S20500>
+** CAPI3REF: Load An Extension
 **
-** This interface loads an SQLite extension library from the named file.
+** ^This interface loads an SQLite extension library from the named file.
 **
-** {H12601} The sqlite3_load_extension() interface attempts to load an
-**          SQLite extension library contained in the file zFile.
+** ^The sqlite3_load_extension() interface attempts to load an
+** SQLite extension library contained in the file zFile.
 **
-** {H12602} The entry point is zProc.
+** ^The entry point is zProc.
+** ^zProc may be 0, in which case the name of the entry point
+** defaults to "sqlite3_extension_init".
+** ^The sqlite3_load_extension() interface returns
+** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
+** ^If an error occurs and pzErrMsg is not 0, then the
+** [sqlite3_load_extension()] interface shall attempt to
+** fill *pzErrMsg with error message text stored in memory
+** obtained from [sqlite3_malloc()]. The calling function
+** should free this memory by calling [sqlite3_free()].
 **
-** {H12603} zProc may be 0, in which case the name of the entry point
-**          defaults to "sqlite3_extension_init".
+** ^Extension loading must be enabled using
+** [sqlite3_enable_load_extension()] prior to calling this API,
+** otherwise an error will be returned.
 **
-** {H12604} The sqlite3_load_extension() interface shall return
-**          [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
-**
-** {H12605} If an error occurs and pzErrMsg is not 0, then the
-**          [sqlite3_load_extension()] interface shall attempt to
-**          fill *pzErrMsg with error message text stored in memory
-**          obtained from [sqlite3_malloc()]. {END}  The calling function
-**          should free this memory by calling [sqlite3_free()].
-**
-** {H12606} Extension loading must be enabled using
-**          [sqlite3_enable_load_extension()] prior to calling this API,
-**          otherwise an error will be returned.
+** See also the [load_extension() SQL function].
 */
 SQLITE_API int sqlite3_load_extension(
   sqlite3 *db,          /* Load the extension into this database connection */
@@ -4674,61 +4588,49 @@ SQLITE_API int sqlite3_load_extension(
 );
 
 /*
-** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500>
+** CAPI3REF: Enable Or Disable Extension Loading
 **
-** So as not to open security holes in older applications that are
+** ^So as not to open security holes in older applications that are
 ** unprepared to deal with extension loading, and as a means of disabling
 ** extension loading while evaluating user-entered SQL, the following API
 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
 **
-** Extension loading is off by default. See ticket #1863.
-**
-** {H12621} Call the sqlite3_enable_load_extension() routine with onoff==1
-**          to turn extension loading on and call it with onoff==0 to turn
-**          it back off again.
-**
-** {H12622} Extension loading is off by default.
+** ^Extension loading is off by default. See ticket #1863.
+** ^Call the sqlite3_enable_load_extension() routine with onoff==1
+** to turn extension loading on and call it with onoff==0 to turn
+** it back off again.
 */
 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
 
 /*
-** CAPI3REF: Automatically Load An Extensions {H12640} <S20500>
+** CAPI3REF: Automatically Load An Extensions
 **
-** This API can be invoked at program startup in order to register
+** ^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]. {END}
-**
-** This routine stores a pointer to the extension in an array that is
-** obtained from [sqlite3_malloc()].  If you run a memory leak checker
-** on your program and it reports a leak because of this array, invoke
-** [sqlite3_reset_auto_extension()] prior to shutdown to free the memory.
-**
-** {H12641} 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()].
+** to all new [database connections].
 **
-** {H12642} Duplicate extensions are detected so calling this routine
-**          multiple times with the same extension is harmless.
+** ^(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()].)^
 **
-** {H12643} This routine stores a pointer to the extension in an array
-**          that is obtained from [sqlite3_malloc()].
-**
-** {H12644} Automatic extensions apply across all threads.
+** ^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.
 */
 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
 
 /*
-** CAPI3REF: Reset Automatic Extension Loading {H12660} <S20500>
-**
-** This function disables all previously registered automatic
-** extensions. {END}  It undoes the effect of all prior
-** [sqlite3_auto_extension()] calls.
+** CAPI3REF: Reset Automatic Extension Loading
 **
-** {H12661} This function disables all previously registered
-**          automatic extensions.
+** ^(This function disables all previously registered automatic
+** extensions. It undoes the effect of all prior
+** [sqlite3_auto_extension()] calls.)^
 **
-** {H12662} This function disables automatic extensions in all threads.
+** ^This function disables automatic extensions in all threads.
 */
 SQLITE_API void sqlite3_reset_auto_extension(void);
 
@@ -4752,7 +4654,7 @@ typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
 typedef struct sqlite3_module sqlite3_module;
 
 /*
-** CAPI3REF: Virtual Table Object {H18000} <S20400>
+** CAPI3REF: Virtual Table Object
 ** KEYWORDS: sqlite3_module {virtual table module}
 ** EXPERIMENTAL
 **
@@ -4760,10 +4662,10 @@ typedef struct sqlite3_module sqlite3_module;
 ** defines the implementation of a [virtual tables].  
 ** This structure consists mostly of methods for the module.
 **
-** A virtual table module is created by filling in a persistent
+** ^A virtual table module is created by filling in a persistent
 ** instance of this structure and passing a pointer to that instance
 ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
-** The registration remains valid until it is replaced by a different
+** ^The registration remains valid until it is replaced by a different
 ** module or until the [database connection] closes.  The content
 ** of this structure must not change while it is registered with
 ** any database connection.
@@ -4799,7 +4701,7 @@ struct sqlite3_module {
 };
 
 /*
-** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400>
+** CAPI3REF: Virtual Table Indexing Information
 ** KEYWORDS: sqlite3_index_info
 ** EXPERIMENTAL
 **
@@ -4809,42 +4711,42 @@ struct sqlite3_module {
 ** inputs to xBestIndex and are read-only.  xBestIndex inserts its
 ** results into the **Outputs** fields.
 **
-** The aConstraint[] array records WHERE clause constraints of the form:
+** ^(The aConstraint[] array records WHERE clause constraints of the form:
 **
 ** <pre>column OP expr</pre>
 **
-** where OP is =, <, <=, >, or >=.  The particular operator is
-** stored in aConstraint[].op.  The index of the column is stored in
-** aConstraint[].iColumn.  aConstraint[].usable is TRUE if the
+** where OP is =, <, <=, >, or >=.)^  ^(The particular operator is
+** stored in aConstraint[].op.)^  ^(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.
+** is usable) and false if it cannot.)^
 **
-** The optimizer automatically inverts terms of the form "expr OP column"
+** ^The optimizer automatically inverts terms of the form "expr OP column"
 ** and makes other simplifications to the WHERE clause in an attempt to
 ** get as many WHERE clause terms into the form shown above as possible.
-** The aConstraint[] array only reports WHERE clause terms in the correct
-** form that refer to the particular virtual table being queried.
+** ^The aConstraint[] array only reports WHERE clause terms that are
+** relevant to the particular virtual table being queried.
 **
-** Information about the ORDER BY clause is stored in aOrderBy[].
-** Each term of aOrderBy records a column of the ORDER BY clause.
+** ^Information about the ORDER BY clause is stored in aOrderBy[].
+** ^Each term of aOrderBy records a column of the ORDER BY clause.
 **
 ** The [xBestIndex] method must fill aConstraintUsage[] with information
-** about what parameters to pass to xFilter.  If argvIndex>0 then
+** about what parameters to pass to xFilter.  ^If argvIndex>0 then
 ** the right-hand side of the corresponding aConstraint[] is evaluated
-** and becomes the argvIndex-th entry in argv.  If aConstraintUsage[].omit
+** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit
 ** is true, then the constraint is assumed to be fully handled by the
-** virtual table and is not checked again by SQLite.
+** virtual table and is not checked again by SQLite.)^
 **
-** The idxNum and idxPtr values are recorded and passed into the
+** ^The idxNum and idxPtr values are recorded and passed into the
 ** [xFilter] method.
-** [sqlite3_free()] is used to free idxPtr if and only iff
+** ^[sqlite3_free()] is used to free idxPtr if and only if
 ** needToFreeIdxPtr is true.
 **
-** The orderByConsumed means that output from [xFilter]/[xNext] will occur in
+** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
 ** the correct order to satisfy the ORDER BY clause so that no separate
 ** sorting step is required.
 **
-** The estimatedCost value is an estimate of the cost of doing the
+** ^The estimatedCost value is an estimate of the cost of doing the
 ** particular lookup.  A full scan of a table with N entries should have
 ** a cost of N.  A binary search of a table of N entries should have a
 ** cost of approximately log(N).
@@ -4882,24 +4784,28 @@ struct sqlite3_index_info {
 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
 
 /*
-** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400>
+** CAPI3REF: Register A Virtual Table Implementation
 ** EXPERIMENTAL
 **
-** This routine is used to register a new [virtual table module] name.
-** Module names must be registered before
-** creating a new [virtual table] using the module, or before using a
+** ^These routines are used to register a new [virtual table module] name.
+** ^Module names must be registered before
+** creating a new [virtual table] using the module and before using a
 ** preexisting [virtual table] for the module.
 **
-** The module name is registered on the [database connection] specified
-** by the first parameter.  The name of the module is given by the 
-** second parameter.  The third parameter is a pointer to
-** the implementation of the [virtual table module].   The fourth
+** ^The module name is registered on the [database connection] specified
+** by the first parameter.  ^The name of the module is given by the 
+** second parameter.  ^The third parameter is a pointer to
+** the implementation of the [virtual table module].   ^The fourth
 ** parameter is an arbitrary client data pointer that is passed through
 ** into the [xCreate] and [xConnect] methods of the virtual table module
 ** when a new virtual table is be being created or reinitialized.
 **
-** This interface has exactly the same effect as calling
-** [sqlite3_create_module_v2()] with a NULL client data destructor.
+** ^The sqlite3_create_module_v2() interface has a fifth parameter which
+** is a pointer to a destructor for the pClientData.  ^SQLite will
+** invoke the destructor function (if it is not NULL) when SQLite
+** no longer needs the pClientData pointer.  ^The sqlite3_create_module()
+** interface is equivalent to sqlite3_create_module_v2() with a NULL
+** destructor.
 */
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
   sqlite3 *db,               /* SQLite connection to register module with */
@@ -4907,17 +4813,6 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
   const sqlite3_module *p,   /* Methods for the module */
   void *pClientData          /* Client data for xCreate/xConnect */
 );
-
-/*
-** CAPI3REF: Register A Virtual Table Implementation {H18210} <S20400>
-** EXPERIMENTAL
-**
-** This routine is identical to the [sqlite3_create_module()] method,
-** except that it has an extra parameter to specify 
-** a destructor function for the client data pointer.  SQLite will
-** invoke the destructor function (if it is not NULL) when SQLite
-** no longer needs the pClientData pointer.  
-*/
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
   sqlite3 *db,               /* SQLite connection to register module with */
   const char *zName,         /* Name of the module */
@@ -4927,21 +4822,21 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
 );
 
 /*
-** CAPI3REF: Virtual Table Instance Object {H18010} <S20400>
+** CAPI3REF: Virtual Table Instance Object
 ** KEYWORDS: sqlite3_vtab
 ** EXPERIMENTAL
 **
 ** Every [virtual table module] implementation uses a subclass
-** of the following structure to describe a particular instance
+** of this object to describe a particular instance
 ** of the [virtual table].  Each subclass will
 ** be tailored to the specific needs of the module implementation.
 ** The purpose of this superclass is to define certain fields that are
 ** common to all module implementations.
 **
-** Virtual tables methods can set an error message by assigning a
+** ^Virtual tables methods can set an error message by assigning a
 ** string obtained from [sqlite3_mprintf()] to zErrMsg.  The method should
 ** take care that any prior string is freed by a call to [sqlite3_free()]
-** prior to assigning a new string to zErrMsg.  After the error message
+** prior to assigning a new string to zErrMsg.  ^After the error message
 ** is delivered up to the client application, the string will be automatically
 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
 */
@@ -4953,7 +4848,7 @@ struct sqlite3_vtab {
 };
 
 /*
-** CAPI3REF: Virtual Table Cursor Object  {H18020} <S20400>
+** CAPI3REF: Virtual Table Cursor Object
 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
 ** EXPERIMENTAL
 **
@@ -4962,7 +4857,7 @@ struct sqlite3_vtab {
 ** [virtual table] and are used
 ** to loop through the virtual table.  Cursors are created using the
 ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed
-** by the [sqlite3_module.xClose | xClose] method.  Cussors are used
+** by the [sqlite3_module.xClose | xClose] method.  Cursors are used
 ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods
 ** of the module.  Each module implementation will define
 ** the content of a cursor structure to suit its own needs.
@@ -4976,10 +4871,10 @@ struct sqlite3_vtab_cursor {
 };
 
 /*
-** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400>
+** CAPI3REF: Declare The Schema Of A Virtual Table
 ** EXPERIMENTAL
 **
-** The [xCreate] and [xConnect] methods of a
+** ^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.
@@ -4987,17 +4882,17 @@ struct sqlite3_vtab_cursor {
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
 
 /*
-** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400>
+** CAPI3REF: Overload A Function For A Virtual Table
 ** EXPERIMENTAL
 **
-** Virtual tables can provide alternative implementations of functions
+** ^(Virtual tables can provide alternative implementations of functions
 ** using the [xFindFunction] method of the [virtual table module].  
 ** But global versions of those functions
-** must exist in order to be overloaded.
+** must exist in order to be overloaded.)^
 **
-** This API makes sure a global version of a function with a particular
+** ^(This API makes sure a global version of a function with a particular
 ** name and number of parameters exists.  If no such function exists
-** before this API is called, a new function is created.  The implementation
+** before this API is called, a new function is created.)^  ^The implementation
 ** of the new function always causes an exception to be thrown.  So
 ** the new function is not good for anything by itself.  Its only
 ** purpose is to be a placeholder function that can be overloaded
@@ -5018,77 +4913,74 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_overload_function(sqlite3*, const cha
 */
 
 /*
-** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230>
+** CAPI3REF: A Handle To An Open BLOB
 ** KEYWORDS: {BLOB handle} {BLOB handles}
 **
 ** An instance of this object represents an open BLOB on which
 ** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
-** Objects of this type are created by [sqlite3_blob_open()]
+** ^Objects of this type are created by [sqlite3_blob_open()]
 ** and destroyed by [sqlite3_blob_close()].
-** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
+** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
 ** can be used to read or write small subsections of the BLOB.
-** The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
+** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
 */
 typedef struct sqlite3_blob sqlite3_blob;
 
 /*
-** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230>
+** CAPI3REF: Open A BLOB For Incremental I/O
 **
-** This interfaces opens a [BLOB handle | handle] to the BLOB located
+** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
 ** in row iRow, column zColumn, table zTable in database zDb;
 ** in other words, the same BLOB that would be selected by:
 **
 ** <pre>
 **     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
-** </pre> {END}
+** </pre>)^
 **
-** If the flags parameter is non-zero, then the BLOB is opened for read
-** and write access. If it is zero, the BLOB is opened for read access.
-** It is not possible to open a column that is part of an index or primary 
+** ^If the flags parameter is non-zero, then the BLOB is opened for read
+** and write access. ^If it is zero, the BLOB is opened for read access.
+** ^It is not possible to open a column that is part of an index or primary 
 ** key for writing. ^If [foreign key constraints] are enabled, it is 
 ** not possible to open a column that is part of a [child key] for writing.
 **
-** Note that the database name is not the filename that contains
+** ^Note that the database name is not the filename that contains
 ** the database but rather the symbolic name of the database that
-** is assigned when the database is connected using [ATTACH].
-** For the main database file, the database name is "main".
-** For TEMP tables, the database name is "temp".
+** appears after the AS keyword when the database is connected using [ATTACH].
+** ^For the main database file, the database name is "main".
+** ^For TEMP tables, the database name is "temp".
 **
-** On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
+** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
 ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
-** to be a null pointer.
-** This function sets the [database connection] error code and message
+** to be a null pointer.)^
+** ^This function sets the [database connection] error code and message
 ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
-** functions.  Note that the *ppBlob variable is always initialized in a
+** functions. ^Note that the *ppBlob variable is always initialized in a
 ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
 ** regardless of the success or failure of this routine.
 **
-** If the row that a BLOB handle points to is modified by an
+** ^(If the row that a BLOB handle points to is modified by an
 ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
 ** then the BLOB handle is marked as "expired".
 ** This is true if any column of the row is changed, even a column
-** other than the one the BLOB handle is open on.
-** Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
+** other than the one the BLOB handle is open on.)^
+** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
 ** a expired BLOB handle fail with an return code of [SQLITE_ABORT].
-** Changes written into a BLOB prior to the BLOB expiring are not
-** rollback by the expiration of the BLOB.  Such changes will eventually
-** commit if the transaction continues to completion.
+** ^(Changes written into a BLOB prior to the BLOB expiring are not
+** rolled back by the expiration of the BLOB.  Such changes will eventually
+** commit if the transaction continues to completion.)^
 **
-** Use the [sqlite3_blob_bytes()] interface to determine the size of
-** the opened blob.  The size of a blob may not be changed by this
+** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
+** the opened blob.  ^The size of a blob may not be changed by this
 ** interface.  Use the [UPDATE] SQL command to change the size of a
 ** blob.
 **
-** The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
+** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
 ** and the built-in [zeroblob] SQL function can be used, if desired,
 ** to create an empty, zero-filled blob in which to read or write using
 ** this interface.
 **
 ** To avoid a resource leak, every open [BLOB handle] should eventually
 ** be released by a call to [sqlite3_blob_close()].
-**
-** Requirements:
-** [H17813] [H17814] [H17816] [H17819] [H17821] [H17824]
 */
 SQLITE_API int sqlite3_blob_open(
   sqlite3*,
@@ -5101,37 +4993,34 @@ SQLITE_API int sqlite3_blob_open(
 );
 
 /*
-** CAPI3REF: Close A BLOB Handle {H17830} <S30230>
+** CAPI3REF: Close A BLOB Handle
 **
-** Closes an open [BLOB handle].
+** ^Closes an open [BLOB handle].
 **
-** Closing a BLOB shall cause the current transaction to commit
+** ^Closing a BLOB shall cause the current transaction to commit
 ** if there are no other BLOBs, no pending prepared statements, and the
 ** database connection is in [autocommit mode].
-** If any writes were made to the BLOB, they might be held in cache
+** ^If any writes were made to the BLOB, they might be held in cache
 ** until the close operation if they will fit.
 **
-** Closing the BLOB often forces the changes
+** ^(Closing the BLOB often forces the changes
 ** out to disk and so if any I/O errors occur, they will likely occur
 ** at the time when the BLOB is closed.  Any errors that occur during
-** closing are reported as a non-zero return value.
-**
-** The BLOB is closed unconditionally.  Even if this routine returns
-** an error code, the BLOB is still closed.
+** closing are reported as a non-zero return value.)^
 **
-** Calling this routine with a null pointer (which as would be returned
-** by failed call to [sqlite3_blob_open()]) is a harmless no-op.
+** ^(The BLOB is closed unconditionally.  Even if this routine returns
+** an error code, the BLOB is still closed.)^
 **
-** Requirements:
-** [H17833] [H17836] [H17839]
+** ^Calling this routine with a null pointer (such as would be returned
+** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
 */
 SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
 
 /*
-** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230>
+** CAPI3REF: Return The Size Of An Open BLOB
 **
-** Returns the size in bytes of the BLOB accessible via the 
-** successfully opened [BLOB handle] in its only argument.  The
+** ^Returns the size in bytes of the BLOB accessible via the 
+** successfully opened [BLOB handle] in its only argument.  ^The
 ** incremental blob I/O routines can only read or overwriting existing
 ** blob content; they cannot change the size of a blob.
 **
@@ -5139,30 +5028,27 @@ SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
 ** by a prior successful call to [sqlite3_blob_open()] and which has not
 ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
 ** to this routine results in undefined and probably undesirable behavior.
-**
-** Requirements:
-** [H17843]
 */
 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
 
 /*
-** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230>
+** CAPI3REF: Read Data From A BLOB Incrementally
 **
-** This function is used to read data from an open [BLOB handle] into a
+** ^(This function is used to read data from an open [BLOB handle] into a
 ** caller-supplied buffer. N bytes of data are copied into buffer Z
-** from the open BLOB, starting at offset iOffset.
+** from the open BLOB, starting at offset iOffset.)^
 **
-** If offset iOffset is less than N bytes from the end of the BLOB,
-** [SQLITE_ERROR] is returned and no data is read.  If N or iOffset is
+** ^If offset iOffset is less than N bytes from the end of the BLOB,
+** [SQLITE_ERROR] is returned and no data is read.  ^If N or iOffset is
 ** less than zero, [SQLITE_ERROR] is returned and no data is read.
-** The size of the blob (and hence the maximum value of N+iOffset)
+** ^The size of the blob (and hence the maximum value of N+iOffset)
 ** can be determined using the [sqlite3_blob_bytes()] interface.
 **
-** An attempt to read from an expired [BLOB handle] fails with an
+** ^An attempt to read from an expired [BLOB handle] fails with an
 ** error code of [SQLITE_ABORT].
 **
-** On success, SQLITE_OK is returned.
-** Otherwise, an [error code] or an [extended error code] is returned.
+** ^(On success, sqlite3_blob_read() returns SQLITE_OK.
+** Otherwise, an [error code] or an [extended error code] is returned.)^
 **
 ** This routine only works on a [BLOB handle] which has been created
 ** by a prior successful call to [sqlite3_blob_open()] and which has not
@@ -5170,40 +5056,37 @@ SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
 ** to this routine results in undefined and probably undesirable behavior.
 **
 ** See also: [sqlite3_blob_write()].
-**
-** Requirements:
-** [H17853] [H17856] [H17859] [H17862] [H17863] [H17865] [H17868]
 */
 SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
 
 /*
-** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230>
+** CAPI3REF: Write Data Into A BLOB Incrementally
 **
-** This function is used to write data into an open [BLOB handle] from a
-** caller-supplied buffer. N bytes of data are copied from the buffer Z
+** ^This function is used to write data into an open [BLOB handle] from a
+** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
 ** into the open BLOB, starting at offset iOffset.
 **
-** If the [BLOB handle] passed as the first argument was not opened for
+** ^If the [BLOB handle] passed as the first argument was not opened for
 ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
 ** this function returns [SQLITE_READONLY].
 **
-** This function may only modify the contents of the BLOB; it is
+** ^This function may only modify the contents of the BLOB; it is
 ** not possible to increase the size of a BLOB using this API.
-** If offset iOffset is less than N bytes from the end of the BLOB,
-** [SQLITE_ERROR] is returned and no data is written.  If N is
+** ^If offset iOffset is less than N bytes from the end of the BLOB,
+** [SQLITE_ERROR] is returned and no data is written.  ^If N is
 ** less than zero [SQLITE_ERROR] is returned and no data is written.
 ** The size of the BLOB (and hence the maximum value of N+iOffset)
 ** can be determined using the [sqlite3_blob_bytes()] interface.
 **
-** An attempt to write to an expired [BLOB handle] fails with an
-** error code of [SQLITE_ABORT].  Writes to the BLOB that occurred
+** ^An attempt to write to an expired [BLOB handle] fails with an
+** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred
 ** before the [BLOB handle] expired are not rolled back by the
 ** expiration of the handle, though of course those changes might
 ** have been overwritten by the statement that expired the BLOB handle
 ** or by other independent statements.
 **
-** On success, SQLITE_OK is returned.
-** Otherwise, an  [error code] or an [extended error code] is returned.
+** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
+** Otherwise, an  [error code] or an [extended error code] is returned.)^
 **
 ** This routine only works on a [BLOB handle] which has been created
 ** by a prior successful call to [sqlite3_blob_open()] and which has not
@@ -5211,15 +5094,11 @@ SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
 ** to this routine results in undefined and probably undesirable behavior.
 **
 ** See also: [sqlite3_blob_read()].
-**
-** Requirements:
-** [H17873] [H17874] [H17875] [H17876] [H17877] [H17879] [H17882] [H17885]
-** [H17888]
 */
 SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
 
 /*
-** CAPI3REF: Virtual File System Objects {H11200} <S20100>
+** CAPI3REF: Virtual File System Objects
 **
 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
 ** that SQLite uses to interact
@@ -5228,34 +5107,31 @@ SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOff
 ** New VFSes can be registered and existing VFSes can be unregistered.
 ** The following interfaces are provided.
 **
-** The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
-** Names are case sensitive.
-** Names are zero-terminated UTF-8 strings.
-** If there is no match, a NULL pointer is returned.
-** If zVfsName is NULL then the default VFS is returned.
+** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
+** ^Names are case sensitive.
+** ^Names are zero-terminated UTF-8 strings.
+** ^If there is no match, a NULL pointer is returned.
+** ^If zVfsName is NULL then the default VFS is returned.
 **
-** New VFSes are registered with sqlite3_vfs_register().
-** Each new VFS becomes the default VFS if the makeDflt flag is set.
-** The same VFS can be registered multiple times without injury.
-** To make an existing VFS into the default VFS, register it again
+** ^New VFSes are registered with sqlite3_vfs_register().
+** ^Each new VFS becomes the default VFS if the makeDflt flag is set.
+** ^The same VFS can be registered multiple times without injury.
+** ^To make an existing VFS into the default VFS, register it again
 ** with the makeDflt flag set.  If two different VFSes with the
 ** same name are registered, the behavior is undefined.  If a
 ** VFS is registered with a name that is NULL or an empty string,
 ** then the behavior is undefined.
 **
-** Unregister a VFS with the sqlite3_vfs_unregister() interface.
-** If the default VFS is unregistered, another VFS is chosen as
-** the default.  The choice for the new VFS is arbitrary.
-**
-** Requirements:
-** [H11203] [H11206] [H11209] [H11212] [H11215] [H11218]
+** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
+** ^(If the default VFS is unregistered, another VFS is chosen as
+** the default.  The choice for the new VFS is arbitrary.)^
 */
 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
 
 /*
-** CAPI3REF: Mutexes {H17000} <S20000>
+** CAPI3REF: Mutexes
 **
 ** The SQLite core uses these routines for thread
 ** synchronization. Though they are intended for internal
@@ -5264,7 +5140,7 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
 **
 ** The SQLite source code contains multiple implementations
 ** of these mutex routines.  An appropriate implementation
-** is selected automatically at compile-time.  The following
+** is selected automatically at compile-time.  ^(The following
 ** implementations are available in the SQLite core:
 **
 ** <ul>
@@ -5272,26 +5148,26 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
 ** <li>   SQLITE_MUTEX_PTHREAD
 ** <li>   SQLITE_MUTEX_W32
 ** <li>   SQLITE_MUTEX_NOOP
-** </ul>
+** </ul>)^
 **
-** The SQLITE_MUTEX_NOOP implementation is a set of routines
+** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
 ** that does no real locking and is appropriate for use in
-** a single-threaded application.  The SQLITE_MUTEX_OS2,
+** a single-threaded application.  ^The SQLITE_MUTEX_OS2,
 ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
 ** are appropriate for use on OS/2, Unix, and Windows.
 **
-** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
+** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
 ** implementation is included with the library. In this case the
 ** application must supply a custom mutex implementation using the
 ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
 ** before calling sqlite3_initialize() or any other public sqlite3_
-** function that calls sqlite3_initialize().
+** function that calls sqlite3_initialize().)^
 **
-** {H17011} The sqlite3_mutex_alloc() routine allocates a new
-** mutex and returns a pointer to it. {H17012} If it returns NULL
-** that means that a mutex could not be allocated. {H17013} SQLite
-** will unwind its stack and return an error. {H17014} The argument
+** ^The sqlite3_mutex_alloc() routine allocates a new
+** mutex and returns a pointer to it. ^If it returns NULL
+** that means that a mutex could not be allocated.  ^SQLite
+** will unwind its stack and return an error.  ^(The argument
 ** to sqlite3_mutex_alloc() is one of these integer constants:
 **
 ** <ul>
@@ -5303,64 +5179,66 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
 ** <li>  SQLITE_MUTEX_STATIC_PRNG
 ** <li>  SQLITE_MUTEX_STATIC_LRU
 ** <li>  SQLITE_MUTEX_STATIC_LRU2
-** </ul>
+** </ul>)^
 **
-** {H17015} The first two constants cause sqlite3_mutex_alloc() to create
-** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
-** is used but not necessarily so when SQLITE_MUTEX_FAST is used. {END}
+** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
+** cause sqlite3_mutex_alloc() to create
+** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
+** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
 ** The mutex implementation does not need to make a distinction
 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
-** not want to.  {H17016} But SQLite will only request a recursive mutex in
-** cases where it really needs one.  {END} If a faster non-recursive mutex
+** not want to.  ^SQLite will only request a recursive mutex in
+** cases where it really needs one.  ^If a faster non-recursive mutex
 ** implementation is available on the host platform, the mutex subsystem
 ** might return such a mutex in response to SQLITE_MUTEX_FAST.
 **
-** {H17017} The other allowed parameters to sqlite3_mutex_alloc() each return
-** a pointer to a static preexisting mutex. {END}  Six static mutexes are
+** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
+** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
+** a pointer to a static preexisting mutex.  ^Six static mutexes are
 ** used by the current version of SQLite.  Future versions of SQLite
 ** may add additional static mutexes.  Static mutexes are for internal
 ** use by SQLite only.  Applications that use SQLite mutexes should
 ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
 ** SQLITE_MUTEX_RECURSIVE.
 **
-** {H17018} Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
+** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
 ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
-** returns a different mutex on every call.  {H17034} But for the static
+** returns a different mutex on every call.  ^But for the static
 ** mutex types, the same mutex is returned on every call that has
 ** the same type number.
 **
-** {H17019} The sqlite3_mutex_free() routine deallocates a previously
-** allocated dynamic mutex. {H17020} SQLite is careful to deallocate every
-** dynamic mutex that it allocates. {A17021} The dynamic mutexes must not be in
-** use when they are deallocated. {A17022} Attempting to deallocate a static
-** mutex results in undefined behavior. {H17023} SQLite never deallocates
-** a static mutex. {END}
+** ^The sqlite3_mutex_free() routine deallocates a previously
+** allocated dynamic mutex.  ^SQLite is careful to deallocate every
+** dynamic mutex that it allocates.  The dynamic mutexes must not be in
+** use when they are deallocated.  Attempting to deallocate a static
+** mutex results in undefined behavior.  ^SQLite never deallocates
+** a static mutex.
 **
-** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
-** to enter a mutex. {H17024} If another thread is already within the mutex,
+** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
+** to enter a mutex.  ^If another thread is already within the mutex,
 ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
-** SQLITE_BUSY. {H17025}  The sqlite3_mutex_try() interface returns [SQLITE_OK]
-** upon successful entry.  {H17026} Mutexes created using
+** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
+** upon successful entry.  ^(Mutexes created using
 ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
-** {H17027} In such cases the,
+** In such cases the,
 ** mutex must be exited an equal number of times before another thread
-** can enter.  {A17028} If the same thread tries to enter any other
+** can enter.)^  ^(If the same thread tries to enter any other
 ** kind of mutex more than once, the behavior is undefined.
-** {H17029} SQLite will never exhibit
-** such behavior in its own use of mutexes.
+** SQLite will never exhibit
+** such behavior in its own use of mutexes.)^
 **
-** Some systems (for example, Windows 95) do not support the operation
+** ^(Some systems (for example, Windows 95) do not support the operation
 ** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()
-** will always return SQLITE_BUSY.  {H17030} The SQLite core only ever uses
-** sqlite3_mutex_try() as an optimization so this is acceptable behavior.
+** will always return SQLITE_BUSY.  The SQLite core only ever uses
+** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
 **
-** {H17031} The sqlite3_mutex_leave() routine exits a mutex that was
-** previously entered by the same thread.  {A17032} The behavior
+** ^The sqlite3_mutex_leave() routine exits a mutex that was
+** previously entered by the same thread.   ^(The behavior
 ** is undefined if the mutex is not currently entered by the
-** calling thread or is not currently allocated.  {H17033} SQLite will
-** never do either. {END}
+** calling thread or is not currently allocated.  SQLite will
+** never do either.)^
 **
-** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
+** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
 ** behave as no-ops.
 **
@@ -5373,7 +5251,7 @@ SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 
 /*
-** CAPI3REF: Mutex Methods Object {H17120} <S20130>
+** CAPI3REF: Mutex Methods Object
 ** EXPERIMENTAL
 **
 ** An instance of this structure defines the low-level routines
@@ -5389,19 +5267,19 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 ** output variable when querying the system for the current mutex
 ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
 **
-** The xMutexInit method defined by this structure is invoked as
+** ^The xMutexInit method defined by this structure is invoked as
 ** part of system initialization by the sqlite3_initialize() function.
-** {H17001} The xMutexInit routine shall be called by SQLite once for each
+** ^The xMutexInit routine is calle by SQLite exactly once for each
 ** effective call to [sqlite3_initialize()].
 **
-** The xMutexEnd method defined by this structure is invoked as
+** ^The xMutexEnd method defined by this structure is invoked as
 ** part of system shutdown by the sqlite3_shutdown() function. The
 ** implementation of this method is expected to release all outstanding
 ** resources obtained by the mutex methods implementation, especially
-** those obtained by the xMutexInit method. {H17003} The xMutexEnd()
-** interface shall be invoked once for each call to [sqlite3_shutdown()].
+** those obtained by the xMutexInit method.  ^The xMutexEnd()
+** interface is invoked exactly once for each call to [sqlite3_shutdown()].
 **
-** The remaining seven methods defined by this structure (xMutexAlloc,
+** ^(The remaining seven methods defined by this structure (xMutexAlloc,
 ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
 ** xMutexNotheld) implement the following interfaces (respectively):
 **
@@ -5413,7 +5291,7 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 **   <li>  [sqlite3_mutex_leave()] </li>
 **   <li>  [sqlite3_mutex_held()] </li>
 **   <li>  [sqlite3_mutex_notheld()] </li>
-** </ul>
+** </ul>)^
 **
 ** The only difference is that the public sqlite3_XXX functions enumerated
 ** above silently ignore any invocations that pass a NULL pointer instead
@@ -5423,17 +5301,17 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 ** (i.e. it is acceptable to provide an implementation that segfaults if
 ** it is passed a NULL pointer).
 **
-** The xMutexInit() method must be threadsafe.  It must be harmless to
+** The xMutexInit() method must be threadsafe.  ^It must be harmless to
 ** invoke xMutexInit() mutiple times within the same process and without
 ** intervening calls to xMutexEnd().  Second and subsequent calls to
 ** xMutexInit() must be no-ops.
 **
-** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
-** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory
-** allocation for a static mutex.  However xMutexAlloc() may use SQLite
+** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
+** and its associates).  ^Similarly, xMutexAlloc() must not use SQLite memory
+** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite
 ** memory allocation for a fast or recursive mutex.
 **
-** SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
+** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
 ** called, but only if the prior call to xMutexInit returned SQLITE_OK.
 ** If xMutexInit fails in any way, it is expected to clean up after itself
 ** prior to returning.
@@ -5452,39 +5330,41 @@ struct sqlite3_mutex_methods {
 };
 
 /*
-** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800>
+** CAPI3REF: Mutex Verification Routines
 **
 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
-** are intended for use inside assert() statements. {H17081} The SQLite core
+** are intended for use inside assert() statements.  ^The SQLite core
 ** never uses these routines except inside an assert() and applications
-** are advised to follow the lead of the core.  {H17082} The core only
+** are advised to follow the lead of the core.  ^The SQLite core only
 ** provides implementations for these routines when it is compiled
-** with the SQLITE_DEBUG flag.  {A17087} External mutex implementations
+** with the SQLITE_DEBUG flag.  ^External mutex implementations
 ** are only required to provide these routines if SQLITE_DEBUG is
 ** defined and if NDEBUG is not defined.
 **
-** {H17083} These routines should return true if the mutex in their argument
+** ^These routines should return true if the mutex in their argument
 ** is held or not held, respectively, by the calling thread.
 **
-** {X17084} The implementation is not required to provided versions of these
+** ^The implementation is not required to provided versions of these
 ** routines that actually work. If the implementation does not provide working
 ** versions of these routines, it should at least provide stubs that always
 ** return true so that one does not get spurious assertion failures.
 **
-** {H17085} If the argument to sqlite3_mutex_held() is a NULL pointer then
-** the routine should return 1.  {END} This seems counter-intuitive since
+** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
+** the routine should return 1.   This seems counter-intuitive since
 ** clearly the mutex cannot be held if it does not exist.  But the
 ** the reason the mutex does not exist is because the build is not
 ** using mutexes.  And we do not want the assert() containing the
 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
-** the appropriate thing to do.  {H17086} The sqlite3_mutex_notheld()
+** the appropriate thing to do.  ^The sqlite3_mutex_notheld()
 ** interface should also return 1 when given a NULL pointer.
 */
+#ifndef NDEBUG
 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
+#endif
 
 /*
-** CAPI3REF: Mutex Types {H17001} <H17000>
+** CAPI3REF: Mutex Types
 **
 ** The [sqlite3_mutex_alloc()] interface takes a single argument
 ** which is one of these integer constants.
@@ -5504,48 +5384,50 @@ SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
 #define SQLITE_MUTEX_STATIC_LRU2      7  /* lru page list */
 
 /*
-** CAPI3REF: Retrieve the mutex for a database connection {H17002} <H17000>
+** CAPI3REF: Retrieve the mutex for a database connection
 **
-** This interface returns a pointer the [sqlite3_mutex] object that 
+** ^This interface returns a pointer the [sqlite3_mutex] object that 
 ** serializes access to the [database connection] given in the argument
 ** when the [threading mode] is Serialized.
-** If the [threading mode] is Single-thread or Multi-thread then this
+** ^If the [threading mode] is Single-thread or Multi-thread then this
 ** routine returns a NULL pointer.
 */
 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
 
 /*
-** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800>
+** CAPI3REF: Low-Level Control Of Database Files
 **
-** {H11301} The [sqlite3_file_control()] interface makes a direct call to the
+** ^The [sqlite3_file_control()] interface makes a direct call to the
 ** xFileControl method for the [sqlite3_io_methods] object associated
-** with a particular database identified by the second argument. {H11302} The
-** name of the database is the name assigned to the database by the
-** <a href="lang_attach.html">ATTACH</a> SQL command that opened the
-** database. {H11303} To control the main database file, use the name "main"
-** or a NULL pointer. {H11304} The third and fourth parameters to this routine
+** with a particular database identified by the second argument. ^The
+** name of the database "main" for the main database or "temp" for the
+** TEMP database, or the name that appears after the AS keyword for
+** databases that are added using the [ATTACH] SQL command.
+** ^A NULL pointer can be used in place of "main" to refer to the
+** main database file.
+** ^The third and fourth parameters to this routine
 ** are passed directly through to the second and third parameters of
-** the xFileControl method.  {H11305} The return value of the xFileControl
+** the xFileControl method.  ^The return value of the xFileControl
 ** method becomes the return value of this routine.
 **
-** {H11306} If the second parameter (zDbName) does not match the name of any
-** open database file, then SQLITE_ERROR is returned. {H11307} This error
+** ^If the second parameter (zDbName) does not match the name of any
+** open database file, then SQLITE_ERROR is returned.  ^This error
 ** code is not remembered and will not be recalled by [sqlite3_errcode()]
-** or [sqlite3_errmsg()]. {A11308} The underlying xFileControl method might
-** also return SQLITE_ERROR.  {A11309} There is no way to distinguish between
+** or [sqlite3_errmsg()].  The underlying xFileControl method might
+** also return SQLITE_ERROR.  There is no way to distinguish between
 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
-** xFileControl method. {END}
+** xFileControl method.
 **
 ** See also: [SQLITE_FCNTL_LOCKSTATE]
 */
 SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
 
 /*
-** CAPI3REF: Testing Interface {H11400} <S30800>
+** CAPI3REF: Testing Interface
 **
-** The sqlite3_test_control() interface is used to read out internal
+** ^The sqlite3_test_control() interface is used to read out internal
 ** state of SQLite and to inject faults into SQLite for testing
-** purposes.  The first parameter is an operation code that determines
+** purposes.  ^The first parameter is an operation code that determines
 ** the number, meaning, and operation of all subsequent parameters.
 **
 ** This interface is not for use by applications.  It exists solely
@@ -5560,7 +5442,7 @@ SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*
 SQLITE_API int sqlite3_test_control(int op, ...);
 
 /*
-** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400>
+** CAPI3REF: Testing Interface Operation Codes
 **
 ** These constants are the valid operation code parameters used
 ** as the first argument to [sqlite3_test_control()].
@@ -5570,6 +5452,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 ** Applications should not use any of these parameters or the
 ** [sqlite3_test_control()] interface.
 */
+#define SQLITE_TESTCTRL_FIRST                    5
 #define SQLITE_TESTCTRL_PRNG_SAVE                5
 #define SQLITE_TESTCTRL_PRNG_RESTORE             6
 #define SQLITE_TESTCTRL_PRNG_RESET               7
@@ -5580,27 +5463,30 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 #define SQLITE_TESTCTRL_ASSERT                  12
 #define SQLITE_TESTCTRL_ALWAYS                  13
 #define SQLITE_TESTCTRL_RESERVE                 14
+#define SQLITE_TESTCTRL_OPTIMIZATIONS           15
+#define SQLITE_TESTCTRL_ISKEYWORD               16
+#define SQLITE_TESTCTRL_LAST                    16
 
 /*
-** CAPI3REF: SQLite Runtime Status {H17200} <S60200>
+** CAPI3REF: SQLite Runtime Status
 ** EXPERIMENTAL
 **
-** This interface is used to retrieve runtime status information
+** ^This interface is used to retrieve runtime status information
 ** about the preformance 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_...].
-** The current value of the parameter is returned into *pCurrent.
-** The highest recorded value is returned in *pHighwater.  If the
+** 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_...].)^
+** ^The current value of the parameter is returned into *pCurrent.
+** ^The highest recorded value is returned in *pHighwater.  ^If the
 ** resetFlag is true, then the highest record value is reset after
-** *pHighwater is written. Some parameters do not record the highest
+** *pHighwater is written.  ^(Some parameters do not record the highest
 ** value.  For those parameters
-** nothing is written into *pHighwater and the resetFlag is ignored.
-** Other parameters record only the highwater mark and not the current
-** value.  For these latter parameters nothing is written into *pCurrent.
+** nothing is written into *pHighwater and the resetFlag is ignored.)^
+** ^(Other parameters record only the highwater mark and not the current
+** value.  For these latter parameters nothing is written into *pCurrent.)^
 **
-** This routine returns SQLITE_OK on success and a non-zero
-** [error code] on failure.
+** ^The sqlite3_db_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
 ** called while other threads are running the same or different SQLite
@@ -5615,14 +5501,14 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 
 
 /*
-** CAPI3REF: Status Parameters {H17250} <H17200>
+** CAPI3REF: Status Parameters
 ** EXPERIMENTAL
 **
 ** These integer constants designate various run-time status parameters
 ** that can be returned by [sqlite3_status()].
 **
 ** <dl>
-** <dt>SQLITE_STATUS_MEMORY_USED</dt>
+** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>
 ** <dd>This parameter is the current amount of memory checked out
 ** using [sqlite3_malloc()], either directly or indirectly.  The
 ** figure includes calls made to [sqlite3_malloc()] by the application
@@ -5630,45 +5516,45 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache
 ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in
 ** this parameter.  The amount returned is the sum of the allocation
-** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>
+** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^
 **
-** <dt>SQLITE_STATUS_MALLOC_SIZE</dt>
+** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>
 ** <dd>This parameter records the largest memory allocation request
 ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
 ** internal equivalents).  Only the value returned in the
 ** *pHighwater parameter to [sqlite3_status()] is of interest.  
-** The value written into the *pCurrent parameter is undefined.</dd>
+** The value written into the *pCurrent parameter is undefined.</dd>)^
 **
-** <dt>SQLITE_STATUS_PAGECACHE_USED</dt>
+** ^(<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 
 ** [SQLITE_CONFIG_PAGECACHE].  The
-** value returned is in pages, not in bytes.</dd>
+** value returned is in pages, not in bytes.</dd>)^
 **
-** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
+** ^(<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]
 ** 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
 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
-** no space was left in the page cache.</dd>
+** no space was left in the page cache.</dd>)^
 **
-** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
+** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
 ** <dd>This parameter records the largest memory allocation request
 ** handed to [pagecache memory allocator].  Only the value returned in the
 ** *pHighwater parameter to [sqlite3_status()] is of interest.  
-** The value written into the *pCurrent parameter is undefined.</dd>
+** The value written into the *pCurrent parameter is undefined.</dd>)^
 **
-** <dt>SQLITE_STATUS_SCRATCH_USED</dt>
+** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>
 ** <dd>This parameter returns the number of allocations used out of the
 ** [scratch memory allocator] configured using
 ** [SQLITE_CONFIG_SCRATCH].  The value returned is in allocations, not
 ** in bytes.  Since a single thread may only have one scratch allocation
 ** outstanding at time, this parameter also reports the number of threads
-** using scratch memory at the same time.</dd>
+** using scratch memory at the same time.</dd>)^
 **
-** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
+** ^(<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]
 ** buffer and where forced to overflow to [sqlite3_malloc()].  The values
@@ -5676,17 +5562,17 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 ** larger (that is, because the requested allocation was larger than the
 ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer
 ** slots were available.
-** </dd>
+** </dd>)^
 **
-** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
+** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
 ** <dd>This parameter records the largest memory allocation request
 ** handed to [scratch memory allocator].  Only the value returned in the
 ** *pHighwater parameter to [sqlite3_status()] is of interest.  
-** The value written into the *pCurrent parameter is undefined.</dd>
+** The value written into the *pCurrent parameter is undefined.</dd>)^
 **
-** <dt>SQLITE_STATUS_PARSER_STACK</dt>
+** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
 ** <dd>This parameter records the deepest parser stack.  It is only
-** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>
+** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
 ** </dl>
 **
 ** New status parameters may be added from time to time.
@@ -5702,18 +5588,18 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 #define SQLITE_STATUS_SCRATCH_SIZE         8
 
 /*
-** CAPI3REF: Database Connection Status {H17500} <S60200>
+** 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
+** ^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.
 **
-** The current value of the requested parameter is written into *pCur
-** and the highest instantaneous value is written into *pHiwtr.  If
+** ^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.
 **
@@ -5722,7 +5608,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
 
 /*
-** CAPI3REF: Status Parameters for database connections {H17520} <H17500>
+** CAPI3REF: Status Parameters for database connections
 ** EXPERIMENTAL
 **
 ** These constants are the available integer "verbs" that can be passed as
@@ -5735,34 +5621,34 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur
 ** if a discontinued or unsupported verb is invoked.
 **
 ** <dl>
-** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
+** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
 ** <dd>This parameter returns the number of lookaside memory slots currently
-** checked out.</dd>
+** checked out.</dd>)^
 ** </dl>
 */
 #define SQLITE_DBSTATUS_LOOKASIDE_USED     0
 
 
 /*
-** CAPI3REF: Prepared Statement Status {H17550} <S60200>
+** CAPI3REF: Prepared Statement Status
 ** EXPERIMENTAL
 **
-** Each prepared statement maintains various
+** ^(Each prepared statement maintains various
 ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
-** of times it has performed specific operations.  These counters can
+** of times it has performed specific operations.)^  These counters can
 ** be used to monitor the performance characteristics of the prepared
 ** statements.  For example, if the number of table steps greatly exceeds
 ** the number of table searches or result rows, that would tend to indicate
 ** that the prepared statement is using a full table scan rather than
 ** an index.  
 **
-** This interface is used to retrieve and reset counter values from
+** ^(This interface is used to retrieve and reset counter values from
 ** a [prepared statement].  The first argument is the prepared statement
 ** object to be interrogated.  The second argument
 ** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter]
-** to be interrogated. 
-** The current value of the requested counter is returned.
-** If the resetFlg is true, then the counter is reset to zero after this
+** to be interrogated.)^
+** ^The current value of the requested counter is returned.
+** ^If the resetFlg is true, then the counter is reset to zero after this
 ** interface call returns.
 **
 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
@@ -5770,7 +5656,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
 
 /*
-** CAPI3REF: Status Parameters for prepared statements {H17570} <H17550>
+** CAPI3REF: Status Parameters for prepared statements
 ** EXPERIMENTAL
 **
 ** These preprocessor macros define integer codes that name counter
@@ -5779,13 +5665,13 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int
 **
 ** <dl>
 ** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
-** <dd>This is the number of times that SQLite has stepped forward in
+** <dd>^This is the number of times that SQLite has stepped forward in
 ** a table as part of a full table scan.  Large numbers for this counter
 ** may indicate opportunities for performance improvement through 
 ** careful use of indices.</dd>
 **
 ** <dt>SQLITE_STMTSTATUS_SORT</dt>
-** <dd>This is the number of sort operations that have occurred.
+** <dd>^This is the number of sort operations that have occurred.
 ** A non-zero value in this counter may indicate an opportunity to
 ** improvement performance through careful use of indices.</dd>
 **
@@ -5813,9 +5699,9 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 ** KEYWORDS: {page cache}
 ** EXPERIMENTAL
 **
-** The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
+** ^(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 
+** 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 
@@ -5824,69 +5710,69 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 ** determine exactly which parts of a database file are cached and for 
 ** how long.
 **
-** The contents of the sqlite3_pcache_methods structure are copied to an
+** ^(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.
+** [sqlite3_config()] returns.)^
 **
-** The xInit() method is called once for each call to [sqlite3_initialize()]
-** (usually only once during the lifetime of the process). It is passed
-** a copy of the sqlite3_pcache_methods.pArg value. It can be used to set
-** up global structures and mutexes required by the custom page cache 
-** implementation. 
+** ^The xInit() method is called once for each 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
+** required by the custom page cache implementation. 
 **
-** The xShutdown() method is called from within [sqlite3_shutdown()], 
+** ^The xShutdown() method is called from within [sqlite3_shutdown()], 
 ** if the application invokes this API. It can be used to clean up 
 ** any outstanding resources before process shutdown, if required.
 **
-** SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
-** the xInit method, so the xInit method need not be threadsafe.  The
+** ^SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
+** 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.
 **
-** SQLite will never invoke xInit() more than once without an intervening
+** ^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
+** ^The xCreate() method is used to construct a new cache instance.  SQLite
 ** will typically create one cache instance for each open database file,
-** though this is not guaranteed. The
+** 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
+** 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
+** ^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
+** 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, a cache created with bPurgeable set to false will
 ** never contain any unpinned pages.
 **
-** The xCachesize() method may be called at any time by SQLite to set the
+** ^(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 parameter,
-** the implementation is not required to do anything with this
+** 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
+** ^The xPagecount() method should return the number of pages currently
 ** stored in the cache.
 ** 
-** 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
+** ^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 
 ** 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
+** 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:
 **
@@ -5897,7 +5783,7 @@ 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
@@ -5906,32 +5792,32 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 ** attempting to unpin pages, the xFetch() method will be invoked again with
 ** a createFlag of 2.
 **
-** 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,
+** ^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
+** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is
+** zero, then the page is considered to be unpinned. ^The 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 is not required to 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
+** ^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
-** discarded. Any prior cache entry associated with newKey is guaranteed not
+** 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.
 **
-** The xDestroy() method is used to delete a cache allocated by xCreate().
-** All resources associated with the specified cache should be freed. After
+** ^The xDestroy() method is used to delete a cache allocated by xCreate().
+** All resources associated with the specified cache should be freed. ^After
 ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
 ** handle invalid, and will not use it with any other sqlite3_pcache_methods
 ** functions.
@@ -5956,7 +5842,7 @@ struct sqlite3_pcache_methods {
 ** EXPERIMENTAL
 **
 ** The sqlite3_backup object records state information about an ongoing
-** online backup operation.  The sqlite3_backup object is created by
+** online backup operation.  ^The sqlite3_backup object is created by
 ** a call to [sqlite3_backup_init()] and is destroyed by a call to
 ** [sqlite3_backup_finish()].
 **
@@ -5968,20 +5854,20 @@ typedef struct sqlite3_backup sqlite3_backup;
 ** CAPI3REF: Online Backup API.
 ** EXPERIMENTAL
 **
-** This API is used to overwrite the contents of one database with that
-** of another. It is useful either for creating backups of databases or
+** The backup API copies the content of one database into another.
+** It is useful either for creating backups of databases or
 ** for copying in-memory databases to or from persistent files. 
 **
 ** See Also: [Using the SQLite Online Backup API]
 **
-** Exclusive access is required to the destination database for the 
-** duration of the operation. However the source database is only
-** read-locked while it is actually being read, it is not locked
-** continuously for the entire operation. Thus, the backup may be
-** performed on a live database without preventing other users from
-** writing to the database for an extended period of time.
+** ^Exclusive access is required to the destination database for the 
+** duration of the operation. ^However the source database is only
+** read-locked while it is actually being read; it is not locked
+** continuously for the entire backup operation. ^Thus, the backup may be
+** performed on a live source database without preventing other users from
+** reading or writing to the source database while the backup is underway.
 ** 
-** To perform a backup operation: 
+** ^(To perform a backup operation: 
 **   <ol>
 **     <li><b>sqlite3_backup_init()</b> is called once to initialize the
 **         backup, 
@@ -5989,143 +5875,148 @@ typedef struct sqlite3_backup sqlite3_backup;
 **         the data between the two databases, and finally
 **     <li><b>sqlite3_backup_finish()</b> is called to release all resources 
 **         associated with the backup operation. 
-**   </ol>
+**   </ol>)^
 ** There should be exactly one call to sqlite3_backup_finish() for each
 ** successful call to sqlite3_backup_init().
 **
 ** <b>sqlite3_backup_init()</b>
 **
-** The first two arguments passed to [sqlite3_backup_init()] are the database
-** handle associated with the destination database and the database name 
-** used to attach the destination database to the handle. The database name
-** is "main" for the main database, "temp" for the temporary database, or
-** the name specified as part of the [ATTACH] statement if the destination is
-** an attached database. The third and fourth arguments passed to 
-** sqlite3_backup_init() identify the [database connection]
-** and database name used
-** to access the source database. The values passed for the source and 
-** destination [database connection] parameters must not be the same.
-**
-** If an error occurs within sqlite3_backup_init(), then NULL is returned
-** and an error code and error message written into the [database connection] 
-** passed as the first argument. They may be retrieved using the
-** [sqlite3_errcode()], [sqlite3_errmsg()], and [sqlite3_errmsg16()] functions.
-** Otherwise, if successful, a pointer to an [sqlite3_backup] object is
-** returned. This pointer may be used with the sqlite3_backup_step() and
+** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the 
+** [database connection] associated with the destination database 
+** and the database name, respectively.
+** ^The database name is "main" for the main database, "temp" for the
+** temporary database, or the name specified after the AS keyword in
+** an [ATTACH] statement for an attached database.
+** ^The S and M arguments passed to 
+** sqlite3_backup_init(D,N,S,M) identify the [database connection]
+** and database name of the source database, respectively.
+** ^The source and destination [database connections] (parameters S and D)
+** must be different or else sqlite3_backup_init(D,N,S,M) will file with
+** an error.
+**
+** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
+** returned and an error code and error message are store3d in the
+** destination [database connection] D.
+** ^The error code and message for the failed call to sqlite3_backup_init()
+** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or
+** [sqlite3_errmsg16()] functions.
+** ^A successful call to sqlite3_backup_init() returns a pointer to an
+** [sqlite3_backup] object.
+** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and
 ** sqlite3_backup_finish() functions to perform the specified backup 
 ** operation.
 **
 ** <b>sqlite3_backup_step()</b>
 **
-** Function [sqlite3_backup_step()] is used to copy up to nPage pages between 
-** the source and destination databases, where nPage is the value of the 
-** second parameter passed to sqlite3_backup_step(). If nPage is a negative
-** value, all remaining source pages are copied. If the required pages are 
-** succesfully copied, but there are still more pages to copy before the 
-** backup is complete, it returns [SQLITE_OK]. If no error occured and there 
-** are no more pages to copy, then [SQLITE_DONE] is returned. If an error 
-** occurs, then an SQLite error code is returned. As well as [SQLITE_OK] and
+** ^Function sqlite3_backup_step(B,N) will copy up to N pages between 
+** the source and destination databases specified by [sqlite3_backup] object B.
+** ^If N is negative, all remaining source pages are copied. 
+** ^If sqlite3_backup_step(B,N) successfully copies N pages and there
+** are still more pages to be copied, then the function resturns [SQLITE_OK].
+** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages
+** from source to destination, then it returns [SQLITE_DONE].
+** ^If an error occurs while running sqlite3_backup_step(B,N),
+** then an [error code] is returned. ^As well as [SQLITE_OK] and
 ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],
 ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
 **
-** As well as the case where the destination database file was opened for
-** read-only access, sqlite3_backup_step() may return [SQLITE_READONLY] if
+** ^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.
 **
-** If sqlite3_backup_step() cannot obtain a required file-system lock, then
+** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
 ** the [sqlite3_busy_handler | busy-handler function]
-** is invoked (if one is specified). If the 
+** is invoked (if one is specified). ^If the 
 ** busy-handler returns non-zero before the lock is available, then 
-** [SQLITE_BUSY] is returned to the caller. In this case the call to
-** sqlite3_backup_step() can be retried later. If the source
+** [SQLITE_BUSY] is returned to the caller. ^In this case the call to
+** sqlite3_backup_step() can be retried later. ^If the source
 ** [database connection]
 ** is being used to write to the source database when sqlite3_backup_step()
-** is called, then [SQLITE_LOCKED] is returned immediately. Again, in this
-** case the call to sqlite3_backup_step() can be retried later on. If
+** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this
+** case the call to sqlite3_backup_step() can be retried later on. ^(If
 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
 ** [SQLITE_READONLY] is returned, then 
 ** there is no point in retrying the call to sqlite3_backup_step(). These 
-** errors are considered fatal. At this point the application must accept 
+** errors are considered fatal.)^  The application must accept 
 ** that the backup operation has failed and pass the backup operation handle 
 ** to the sqlite3_backup_finish() to release associated resources.
 **
-** Following the first call to sqlite3_backup_step(), an exclusive lock is
-** obtained on the destination file. It is not released until either 
+** ^The first call to sqlite3_backup_step() obtains an exclusive lock
+** on the destination file. ^The exclusive lock is not released until either 
 ** sqlite3_backup_finish() is called or the backup operation is complete 
-** and sqlite3_backup_step() returns [SQLITE_DONE]. Additionally, each time 
-** a call to sqlite3_backup_step() is made a [shared lock] is obtained on
-** the source database file. This lock is released before the
-** sqlite3_backup_step() call returns. Because the source database is not
-** locked between calls to sqlite3_backup_step(), it may be modified mid-way
-** through the backup procedure. If the source database is modified by an
+** and sqlite3_backup_step() returns [SQLITE_DONE].  ^Every call to
+** sqlite3_backup_step() obtains a [shared lock] on the source database that
+** lasts for the duration of the sqlite3_backup_step() call.
+** ^Because the source database is not locked between calls to
+** sqlite3_backup_step(), the source database may be modified mid-way
+** through the backup process.  ^If the source database is modified by an
 ** external process or via a database connection other than the one being
-** used by the backup operation, then the backup will be transparently
-** restarted by the next call to sqlite3_backup_step(). If the source 
+** used by the backup operation, then the backup will be automatically
+** restarted by the next call to sqlite3_backup_step(). ^If the source 
 ** database is modified by the using the same database connection as is used
-** by the backup operation, then the backup database is transparently 
+** by the backup operation, then the backup database is automatically
 ** updated at the same time.
 **
 ** <b>sqlite3_backup_finish()</b>
 **
-** Once sqlite3_backup_step() has returned [SQLITE_DONE], or when the 
-** application wishes to abandon the backup operation, the [sqlite3_backup]
-** object should be passed to sqlite3_backup_finish(). This releases all
-** resources associated with the backup operation. If sqlite3_backup_step()
-** has not yet returned [SQLITE_DONE], then any active write-transaction on the
-** destination database is rolled back. The [sqlite3_backup] object is invalid
+** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the 
+** application wishes to abandon the backup operation, the application
+** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().
+** ^The sqlite3_backup_finish() interfaces releases all
+** resources associated with the [sqlite3_backup] object. 
+** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any
+** active write-transaction on the destination database is rolled back.
+** The [sqlite3_backup] object is invalid
 ** and may not be used following a call to sqlite3_backup_finish().
 **
-** The value returned by sqlite3_backup_finish is [SQLITE_OK] if no error
-** occurred, regardless or whether or not sqlite3_backup_step() was called
-** a sufficient number of times to complete the backup operation. Or, if
-** an out-of-memory condition or IO error occured during a call to
-** sqlite3_backup_step() then [SQLITE_NOMEM] or an
-** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] error code
-** is returned. In this case the error code and an error message are
-** written to the destination [database connection].
-**
-** A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() is
-** not a permanent error and does not affect the return value of
+** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no
+** sqlite3_backup_step() errors occurred, regardless or whether or not
+** sqlite3_backup_step() completed.
+** ^If an out-of-memory condition or IO error occurred during any prior
+** sqlite3_backup_step() call on the same [sqlite3_backup] object, then
+** sqlite3_backup_finish() returns the corresponding [error code].
+**
+** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
+** is not a permanent error and does not affect the return value of
 ** sqlite3_backup_finish().
 **
 ** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
 **
-** Each call to sqlite3_backup_step() sets two values stored internally
-** by an [sqlite3_backup] object. The number of pages still to be backed
-** up, which may be queried by sqlite3_backup_remaining(), and the total
-** number of pages in the source database file, which may be queried by
-** sqlite3_backup_pagecount().
+** ^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.
+** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
+** retrieve these two values, respectively.
 **
-** The values returned by these functions are only updated by
-** sqlite3_backup_step(). If the source database is modified during a backup
+** ^The values returned by these functions are only updated by
+** sqlite3_backup_step(). ^If the source database is modified during a backup
 ** operation, then the values are not updated to account for any extra
 ** pages that need to be updated or the size of the source database file
 ** changing.
 **
 ** <b>Concurrent Usage of Database Handles</b>
 **
-** The source [database connection] may be used by the application for other
+** ^The source [database connection] may be used by the application for other
 ** purposes while a backup operation is underway or being initialized.
-** If SQLite is compiled and configured to support threadsafe database
+** ^If SQLite is compiled and configured to support threadsafe database
 ** connections, then the source database connection may be used concurrently
 ** from within other threads.
 **
-** However, the application must guarantee that the destination database
-** connection handle is not passed to any other API (by any thread) after 
+** However, the application must guarantee that the destination 
+** [database connection] is not passed to any other API (by any thread) after 
 ** sqlite3_backup_init() is called and before the corresponding call to
-** sqlite3_backup_finish(). Unfortunately SQLite does not currently check
-** for this, if the application does use the destination [database connection]
-** for some other purpose during a backup operation, things may appear to
-** work correctly but in fact be subtly malfunctioning.  Use of the
-** destination database connection while a backup is in progress might
-** also cause a mutex deadlock.
-**
-** Furthermore, if running in [shared cache mode], the application must
+** sqlite3_backup_finish().  SQLite does not currently check to see
+** if the application incorrectly accesses the destination [database connection]
+** and so no error code is reported, but the operations may malfunction
+** nevertheless.  Use of the destination database connection while a
+** backup is in progress might also also cause a mutex deadlock.
+**
+** If running in [shared cache mode], the application must
 ** guarantee that the shared cache used by the destination database
 ** is not accessed while the backup is running. In practice this means
-** that the application must guarantee that the file-system file being 
+** that the application must guarantee that the disk file being 
 ** backed up to is not accessed by any connection within the process,
 ** not just the specific connection that was passed to sqlite3_backup_init().
 **
@@ -6151,48 +6042,48 @@ 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
+** ^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
 ** individual tables within the shared-cache cannot be obtained. See
 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. 
-** This API may be used to register a callback that SQLite will invoke 
+** ^This API may be used to register a callback that SQLite will invoke 
 ** when the connection currently holding the required lock relinquishes it.
-** This API is only available if the library was compiled with the
+** ^This API is only available if the library was compiled with the
 ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
 **
 ** See Also: [Using the SQLite Unlock Notification Feature].
 **
-** Shared-cache locks are released when a database connection concludes
+** ^Shared-cache locks are released when a database connection concludes
 ** its current transaction, either by committing it or rolling it back. 
 **
-** When a connection (known as the blocked connection) fails to obtain a
+** ^When a connection (known as the blocked connection) fails to obtain a
 ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
 ** identity of the database connection (the blocking connection) that
-** has locked the required resource is stored internally. After an 
+** has locked the required resource is stored internally. ^After an 
 ** application receives an SQLITE_LOCKED error, it may call the
 ** sqlite3_unlock_notify() method with the blocked connection handle as 
 ** the first argument to register for a callback that will be invoked
-** when the blocking connections current transaction is concluded. The
+** when the blocking connections current transaction is concluded. ^The
 ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
 ** call that concludes the blocking connections transaction.
 **
-** If sqlite3_unlock_notify() is called in a multi-threaded application,
+** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
 ** there is a chance that the blocking connection will have already
 ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
 ** If this happens, then the specified callback is invoked immediately,
-** from within the call to sqlite3_unlock_notify().
+** from within the call to sqlite3_unlock_notify().)^
 **
-** If the blocked connection is attempting to obtain a write-lock on a
+** ^If the blocked connection is attempting to obtain a write-lock on a
 ** shared-cache table, and more than one other connection currently holds
 ** a read-lock on the same table, then SQLite arbitrarily selects one of 
 ** the other connections to use as the blocking connection.
 **
-** There may be at most one unlock-notify callback registered by a 
+** ^(There may be at most one unlock-notify callback registered by a 
 ** blocked connection. If sqlite3_unlock_notify() is called when the
 ** blocked connection already has a registered unlock-notify callback,
-** then the new callback replaces the old. If sqlite3_unlock_notify() is
+** 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 cancelled. ^The blocked connections 
 ** unlock-notify callback may also be canceled by closing the blocked
 ** connection using [sqlite3_close()].
 **
@@ -6200,7 +6091,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 ** any sqlite3_xxx API functions from within an unlock-notify callback, a
 ** crash or deadlock may be the result.
 **
-** Unless deadlock is detected (see below), sqlite3_unlock_notify() always
+** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always
 ** returns SQLITE_OK.
 **
 ** <b>Callback Invocation Details</b>
@@ -6214,7 +6105,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 **
 ** When a blocking connections transaction is concluded, there may be
 ** more than one blocked connection that has registered for an unlock-notify
-** callback. If two or more such blocked connections have specified the
+** callback. ^If two or more such blocked connections have specified the
 ** same callback function, then instead of invoking the callback function
 ** multiple times, it is invoked once with the set of void* context pointers
 ** specified by the blocked connections bundled together into an array.
@@ -6232,16 +6123,16 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 ** will proceed and the system may remain deadlocked indefinitely.
 **
 ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
-** detection. If a given call to sqlite3_unlock_notify() would put the
+** detection. ^If a given call to sqlite3_unlock_notify() would put the
 ** system in a deadlocked state, then SQLITE_LOCKED is returned and no
 ** unlock-notify callback is registered. The system is said to be in
 ** a deadlocked state if connection A has registered for an unlock-notify
 ** callback on the conclusion of connection B's transaction, and connection
 ** B has itself registered for an unlock-notify callback when connection
-** A's transaction is concluded. Indirect deadlock is also detected, so
+** A's transaction is concluded. ^Indirect deadlock is also detected, so
 ** the system is also considered to be deadlocked if connection B has
 ** registered for an unlock-notify callback on the conclusion of connection
-** C's transaction, where connection C is waiting on connection A. Any
+** C's transaction, where connection C is waiting on connection A. ^Any
 ** number of levels of indirection are allowed.
 **
 ** <b>The "DROP TABLE" Exception</b>
@@ -6257,10 +6148,10 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 ** or "DROP INDEX" query, an infinite loop might be the result.
 **
 ** One way around this problem is to check the extended error code returned
-** by an sqlite3_step() call. If there is a blocking connection, then the
+** by an sqlite3_step() call. ^(If there is a blocking connection, then the
 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
 ** the special "DROP TABLE/INDEX" case, the extended error code is just 
-** SQLITE_LOCKED.
+** SQLITE_LOCKED.)^
 */
 SQLITE_API int sqlite3_unlock_notify(
   sqlite3 *pBlocked,                          /* Waiting connection */
@@ -6273,7 +6164,7 @@ SQLITE_API int sqlite3_unlock_notify(
 ** CAPI3REF: String Comparison
 ** EXPERIMENTAL
 **
-** The [sqlite3_strnicmp()] API allows applications and extensions to
+** ^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 
 ** that SQLite uses internally when comparing identifiers.
@@ -6311,8 +6202,6 @@ SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
 *************************************************************************
 ** This is the header file for the generic hash-table implemenation
 ** used in SQLite.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _SQLITE_HASH_H_
 #define _SQLITE_HASH_H_
@@ -6505,30 +6394,30 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
 #define TK_REFERENCES                     102
 #define TK_AUTOINCR                       103
 #define TK_ON                             104
-#define TK_DELETE                         105
-#define TK_UPDATE                         106
-#define TK_SET                            107
-#define TK_DEFERRABLE                     108
-#define TK_FOREIGN                        109
-#define TK_DROP                           110
-#define TK_UNION                          111
-#define TK_ALL                            112
-#define TK_EXCEPT                         113
-#define TK_INTERSECT                      114
-#define TK_SELECT                         115
-#define TK_DISTINCT                       116
-#define TK_DOT                            117
-#define TK_FROM                           118
-#define TK_JOIN                           119
-#define TK_USING                          120
-#define TK_ORDER                          121
-#define TK_GROUP                          122
-#define TK_HAVING                         123
-#define TK_LIMIT                          124
-#define TK_WHERE                          125
-#define TK_INTO                           126
-#define TK_VALUES                         127
-#define TK_INSERT                         128
+#define TK_INSERT                         105
+#define TK_DELETE                         106
+#define TK_UPDATE                         107
+#define TK_SET                            108
+#define TK_DEFERRABLE                     109
+#define TK_FOREIGN                        110
+#define TK_DROP                           111
+#define TK_UNION                          112
+#define TK_ALL                            113
+#define TK_EXCEPT                         114
+#define TK_INTERSECT                      115
+#define TK_SELECT                         116
+#define TK_DISTINCT                       117
+#define TK_DOT                            118
+#define TK_FROM                           119
+#define TK_JOIN                           120
+#define TK_USING                          121
+#define TK_ORDER                          122
+#define TK_GROUP                          123
+#define TK_HAVING                         124
+#define TK_LIMIT                          125
+#define TK_WHERE                          126
+#define TK_INTO                           127
+#define TK_VALUES                         128
 #define TK_INTEGER                        129
 #define TK_FLOAT                          130
 #define TK_BLOB                           131
@@ -6753,9 +6642,19 @@ SQLITE_PRIVATE const int sqlite3one;
 #define ROUNDDOWN8(x) ((x)&~7)
 
 /*
-** Assert that the pointer X is aligned to an 8-byte boundary.
+** Assert that the pointer X is aligned to an 8-byte boundary.  This
+** macro is used only within assert() to verify that the code gets
+** all alignment restrictions correct.
+**
+** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the
+** underlying malloc() implemention might return us 4-byte aligned
+** pointers.  In that case, only verify 4-byte alignment.
 */
-#define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&7)==0)
+#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
+# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&3)==0)
+#else
+# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&7)==0)
+#endif
 
 
 /*
@@ -6915,8 +6814,6 @@ typedef struct WhereLevel WhereLevel;
 ** This header file defines the interface that the sqlite B-Tree file
 ** subsystem.  See comments in the source code for a detailed description
 ** of what each interface routine does.
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _BTREE_H_
 #define _BTREE_H_
@@ -7053,6 +6950,7 @@ SQLITE_PRIVATE int sqlite3BtreeCursor(
   BtCursor *pCursor                    /* Space to write cursor structure */
 );
 SQLITE_PRIVATE int sqlite3BtreeCursorSize(void);
+SQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor*);
 
 SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*);
 SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
@@ -7164,8 +7062,6 @@ SQLITE_PRIVATE   int sqlite3BtreeHoldsAllMutexes(sqlite3*);
 ** This header defines the interface to the virtual database engine
 ** or VDBE.  The VDBE implements an abstract machine that runs a
 ** simple program to access and modify the underlying database.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _SQLITE_VDBE_H_
 #define _SQLITE_VDBE_H_
@@ -7193,7 +7089,7 @@ typedef struct SubProgram SubProgram;
 struct VdbeOp {
   u8 opcode;          /* What operation to perform */
   signed char p4type; /* One of the P4_xxx constants for p4 */
-  u8 opflags;         /* Not currently used */
+  u8 opflags;         /* Mask of the OPFLG_* flags in opcodes.h */
   u8 p5;              /* Fifth parameter is an unsigned character */
   int p1;             /* First operand */
   int p2;             /* Second parameter (often the jump destination) */
@@ -7313,147 +7209,147 @@ typedef struct VdbeOpList VdbeOpList;
 /************** Begin file opcodes.h *****************************************/
 /* Automatically generated.  Do not edit */
 /* See the mkopcodeh.awk script for details */
-#define OP_VNext                                1
-#define OP_Affinity                             2
-#define OP_Column                               3
-#define OP_SetCookie                            4
-#define OP_Seek                                 5
+#define OP_Goto                                 1
+#define OP_Gosub                                2
+#define OP_Return                               3
+#define OP_Yield                                4
+#define OP_HaltIfNull                           5
+#define OP_Halt                                 6
+#define OP_Integer                              7
+#define OP_Int64                                8
 #define OP_Real                               130   /* same as TK_FLOAT    */
-#define OP_Sequence                             6
-#define OP_Savepoint                            7
-#define OP_Ge                                  80   /* same as TK_GE       */
-#define OP_RowKey                               8
-#define OP_SCopy                                9
-#define OP_Eq                                  76   /* same as TK_EQ       */
-#define OP_OpenWrite                           10
-#define OP_NotNull                             74   /* same as TK_NOTNULL  */
-#define OP_If                                  11
-#define OP_ToInt                              144   /* same as TK_TO_INT   */
 #define OP_String8                             94   /* same as TK_STRING   */
-#define OP_CollSeq                             12
-#define OP_OpenRead                            13
-#define OP_Expire                              14
-#define OP_AutoCommit                          15
-#define OP_Gt                                  77   /* same as TK_GT       */
-#define OP_Pagecount                           16
-#define OP_IntegrityCk                         17
-#define OP_Sort                                18
-#define OP_Copy                                20
-#define OP_Trace                               21
-#define OP_Function                            22
-#define OP_IfNeg                               23
-#define OP_And                                 69   /* same as TK_AND      */
+#define OP_String                               9
+#define OP_Null                                10
+#define OP_Blob                                11
+#define OP_Variable                            12
+#define OP_Move                                13
+#define OP_Copy                                14
+#define OP_SCopy                               15
+#define OP_ResultRow                           16
+#define OP_Concat                              91   /* same as TK_CONCAT   */
+#define OP_Add                                 86   /* same as TK_PLUS     */
 #define OP_Subtract                            87   /* same as TK_MINUS    */
-#define OP_Noop                                24
-#define OP_Program                             25
-#define OP_Return                              26
-#define OP_Remainder                           90   /* same as TK_REM      */
-#define OP_NewRowid                            27
 #define OP_Multiply                            88   /* same as TK_STAR     */
-#define OP_FkCounter                           28
-#define OP_Variable                            29
-#define OP_String                              30
-#define OP_RealAffinity                        31
-#define OP_VRename                             32
-#define OP_ParseSchema                         33
-#define OP_VOpen                               34
-#define OP_Close                               35
-#define OP_CreateIndex                         36
-#define OP_IsUnique                            37
-#define OP_NotFound                            38
-#define OP_Int64                               39
-#define OP_MustBeInt                           40
-#define OP_Halt                                41
-#define OP_Rowid                               42
-#define OP_IdxLT                               43
-#define OP_AddImm                              44
-#define OP_RowData                             45
-#define OP_MemMax                              46
-#define OP_Or                                  68   /* same as TK_OR       */
-#define OP_NotExists                           47
-#define OP_Gosub                               48
 #define OP_Divide                              89   /* same as TK_SLASH    */
-#define OP_Integer                             49
-#define OP_ToNumeric                          143   /* same as TK_TO_NUMERIC*/
-#define OP_Prev                                50
-#define OP_RowSetRead                          51
-#define OP_Concat                              91   /* same as TK_CONCAT   */
-#define OP_RowSetAdd                           52
+#define OP_Remainder                           90   /* same as TK_REM      */
+#define OP_CollSeq                             17
+#define OP_Function                            18
 #define OP_BitAnd                              82   /* same as TK_BITAND   */
-#define OP_VColumn                             53
-#define OP_CreateTable                         54
-#define OP_Last                                55
-#define OP_SeekLe                              56
-#define OP_IsNull                              73   /* same as TK_ISNULL   */
-#define OP_IncrVacuum                          57
-#define OP_IdxRowid                            58
-#define OP_ShiftRight                          85   /* same as TK_RSHIFT   */
-#define OP_ResetCount                          59
-#define OP_Yield                               60
-#define OP_DropTrigger                         61
-#define OP_DropIndex                           62
-#define OP_Param                               63
-#define OP_IdxGE                               64
-#define OP_IdxDelete                           65
-#define OP_Vacuum                              66
-#define OP_IfNot                               67
-#define OP_DropTable                           70
-#define OP_SeekLt                              71
-#define OP_MakeRecord                          72
-#define OP_ToBlob                             142   /* same as TK_TO_BLOB  */
-#define OP_ResultRow                           81
-#define OP_Delete                              92
-#define OP_AggFinal                            95
-#define OP_Compare                             96
+#define OP_BitOr                               83   /* same as TK_BITOR    */
 #define OP_ShiftLeft                           84   /* same as TK_LSHIFT   */
-#define OP_Goto                                97
-#define OP_TableLock                           98
-#define OP_Clear                               99
-#define OP_Le                                  78   /* same as TK_LE       */
-#define OP_VerifyCookie                       100
-#define OP_AggStep                            101
+#define OP_ShiftRight                          85   /* same as TK_RSHIFT   */
+#define OP_AddImm                              20
+#define OP_MustBeInt                           21
+#define OP_RealAffinity                        22
 #define OP_ToText                             141   /* same as TK_TO_TEXT  */
-#define OP_Not                                 19   /* same as TK_NOT      */
+#define OP_ToBlob                             142   /* same as TK_TO_BLOB  */
+#define OP_ToNumeric                          143   /* same as TK_TO_NUMERIC*/
+#define OP_ToInt                              144   /* same as TK_TO_INT   */
 #define OP_ToReal                             145   /* same as TK_TO_REAL  */
-#define OP_Transaction                        102
-#define OP_VFilter                            103
+#define OP_Eq                                  76   /* same as TK_EQ       */
 #define OP_Ne                                  75   /* same as TK_NE       */
-#define OP_VDestroy                           104
-#define OP_BitOr                               83   /* same as TK_BITOR    */
-#define OP_Next                               105
-#define OP_Count                              106
-#define OP_IdxInsert                          107
 #define OP_Lt                                  79   /* same as TK_LT       */
-#define OP_FkIfZero                           108
-#define OP_SeekGe                             109
-#define OP_Insert                             110
-#define OP_Destroy                            111
-#define OP_ReadCookie                         112
-#define OP_RowSetTest                         113
-#define OP_LoadAnalysis                       114
-#define OP_Explain                            115
-#define OP_HaltIfNull                         116
-#define OP_OpenPseudo                         117
-#define OP_OpenEphemeral                      118
-#define OP_Null                               119
-#define OP_Move                               120
-#define OP_Blob                               121
-#define OP_Add                                 86   /* same as TK_PLUS     */
-#define OP_Rewind                             122
-#define OP_SeekGt                             123
-#define OP_VBegin                             124
-#define OP_VUpdate                            125
-#define OP_IfZero                             126
+#define OP_Le                                  78   /* same as TK_LE       */
+#define OP_Gt                                  77   /* same as TK_GT       */
+#define OP_Ge                                  80   /* same as TK_GE       */
+#define OP_Permutation                         23
+#define OP_Compare                             24
+#define OP_Jump                                25
+#define OP_And                                 69   /* same as TK_AND      */
+#define OP_Or                                  68   /* same as TK_OR       */
+#define OP_Not                                 19   /* same as TK_NOT      */
 #define OP_BitNot                              93   /* same as TK_BITNOT   */
-#define OP_VCreate                            127
-#define OP_Found                              128
-#define OP_IfPos                              129
-#define OP_NullRow                            131
-#define OP_Jump                               132
-#define OP_Permutation                        133
+#define OP_If                                  26
+#define OP_IfNot                               27
+#define OP_IsNull                              73   /* same as TK_ISNULL   */
+#define OP_NotNull                             74   /* same as TK_NOTNULL  */
+#define OP_Column                              28
+#define OP_Affinity                            29
+#define OP_MakeRecord                          30
+#define OP_Count                               31
+#define OP_Savepoint                           32
+#define OP_AutoCommit                          33
+#define OP_Transaction                         34
+#define OP_ReadCookie                          35
+#define OP_SetCookie                           36
+#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
 
 /* The following opcode values are never used */
-#define OP_NotUsed_134                        134
 #define OP_NotUsed_135                        135
 #define OP_NotUsed_136                        136
 #define OP_NotUsed_137                        137
@@ -7471,25 +7367,26 @@ typedef struct VdbeOpList VdbeOpList;
 #define OPFLG_IN1             0x0004  /* in1:   P1 is an input */
 #define OPFLG_IN2             0x0008  /* in2:   P2 is an input */
 #define OPFLG_IN3             0x0010  /* in3:   P3 is an input */
-#define OPFLG_OUT3            0x0020  /* out3:  P3 is an output */
+#define OPFLG_OUT2            0x0020  /* out2:  P2 is an output */
+#define OPFLG_OUT3            0x0040  /* out3:  P3 is an output */
 #define OPFLG_INITIALIZER {\
-/*   0 */ 0x00, 0x01, 0x00, 0x00, 0x10, 0x08, 0x02, 0x00,\
-/*   8 */ 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,\
-/*  16 */ 0x02, 0x00, 0x01, 0x04, 0x04, 0x00, 0x00, 0x05,\
-/*  24 */ 0x00, 0x01, 0x04, 0x02, 0x00, 0x00, 0x02, 0x04,\
-/*  32 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x02,\
-/*  40 */ 0x05, 0x00, 0x02, 0x11, 0x04, 0x00, 0x08, 0x11,\
-/*  48 */ 0x01, 0x02, 0x01, 0x21, 0x08, 0x00, 0x02, 0x01,\
-/*  56 */ 0x11, 0x01, 0x02, 0x00, 0x04, 0x00, 0x00, 0x02,\
-/*  64 */ 0x11, 0x00, 0x00, 0x05, 0x2c, 0x2c, 0x00, 0x11,\
-/*  72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
-/*  80 */ 0x15, 0x00, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c,\
-/*  88 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x00, 0x04, 0x02, 0x00,\
-/*  96 */ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\
-/* 104 */ 0x00, 0x01, 0x02, 0x08, 0x01, 0x11, 0x00, 0x02,\
-/* 112 */ 0x02, 0x15, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02,\
-/* 120 */ 0x00, 0x02, 0x01, 0x11, 0x00, 0x00, 0x05, 0x00,\
-/* 128 */ 0x11, 0x05, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,\
+/*   0 */ 0x00, 0x01, 0x05, 0x04, 0x04, 0x10, 0x00, 0x02,\
+/*   8 */ 0x02, 0x02, 0x02, 0x02, 0x00, 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,\
+/*  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,\
 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,\
 /* 144 */ 0x04, 0x04,}
 
@@ -7506,6 +7403,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int);
 SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int);
 SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
 SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
+SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
 SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp);
 SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
 SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
@@ -7536,10 +7434,12 @@ 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);
-
-#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
-SQLITE_PRIVATE int sqlite3VdbeReleaseMemory(int);
+SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8);
+SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
+#ifndef SQLITE_OMIT_TRACE
+SQLITE_PRIVATE   char *sqlite3VdbeExpandSql(Vdbe*, const char*);
 #endif
+
 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int);
 SQLITE_PRIVATE void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*);
 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
@@ -7575,8 +7475,6 @@ SQLITE_PRIVATE   void sqlite3VdbeNoopComment(Vdbe*, const char*, ...);
 ** This header file defines the interface that the sqlite page cache
 ** subsystem.  The page cache subsystem reads and writes a file a page
 ** at a time and provides a journal for rollback.
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 #ifndef _PAGER_H_
@@ -7746,8 +7644,6 @@ SQLITE_PRIVATE   void sqlite3PagerRefdump(Pager*);
 *************************************************************************
 ** This header file defines the interface that the sqlite page cache
 ** subsystem. 
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 #ifndef _PCACHE_H_
@@ -7914,8 +7810,6 @@ SQLITE_PRIVATE void sqlite3PCacheSetDefault(void);
 **
 ** This header file is #include-ed by sqliteInt.h and thus ends up
 ** being included by every source file.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _SQLITE_OS_H_
 #define _SQLITE_OS_H_
@@ -8194,8 +8088,6 @@ SQLITE_PRIVATE int sqlite3OsCloseFree(sqlite3_file *);
 ** NOTE:  source files should *not* #include this header file directly.
 ** Source files should #include the sqliteInt.h file and let that file
 ** include this one indirectly.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -8501,37 +8393,43 @@ struct sqlite3 {
 #define ENC(db) ((db)->aDb[0].pSchema->enc)
 
 /*
-** Possible values for the sqlite.flags and or Db.flags fields.
-**
-** On sqlite.flags, the SQLITE_InTrans value means that we have
-** executed a BEGIN.  On Db.flags, SQLITE_InTrans means a statement
-** transaction is active on that particular database file.
+** Possible values for the sqlite3.flags.
 */
-#define SQLITE_VdbeTrace      0x00000001  /* True to trace VDBE execution */
-#define SQLITE_InTrans        0x00000008  /* True if in a transaction */
-#define SQLITE_InternChanges  0x00000010  /* Uncommitted Hash table changes */
-#define SQLITE_FullColNames   0x00000020  /* Show full column names on SELECT */
-#define SQLITE_ShortColNames  0x00000040  /* Show short columns names */
-#define SQLITE_CountRows      0x00000080  /* Count rows changed by INSERT, */
+#define SQLITE_VdbeTrace      0x00000100  /* True to trace VDBE execution */
+#define SQLITE_InternChanges  0x00000200  /* Uncommitted Hash table changes */
+#define SQLITE_FullColNames   0x00000400  /* Show full column names on SELECT */
+#define SQLITE_ShortColNames  0x00000800  /* Show short columns names */
+#define SQLITE_CountRows      0x00001000  /* Count rows changed by INSERT, */
                                           /*   DELETE, or UPDATE and return */
                                           /*   the count using a callback. */
-#define SQLITE_NullCallback   0x00000100  /* Invoke the callback once if the */
+#define SQLITE_NullCallback   0x00002000  /* Invoke the callback once if the */
                                           /*   result set is empty */
-#define SQLITE_SqlTrace       0x00000200  /* Debug print SQL as it executes */
-#define SQLITE_VdbeListing    0x00000400  /* Debug listings of VDBE programs */
-#define SQLITE_WriteSchema    0x00000800  /* OK to update SQLITE_MASTER */
-#define SQLITE_NoReadlock     0x00001000  /* Readlocks are omitted when 
+#define SQLITE_SqlTrace       0x00004000  /* Debug print SQL as it executes */
+#define SQLITE_VdbeListing    0x00008000  /* Debug listings of VDBE programs */
+#define SQLITE_WriteSchema    0x00010000  /* OK to update SQLITE_MASTER */
+#define SQLITE_NoReadlock     0x00020000  /* Readlocks are omitted when 
                                           ** accessing read-only databases */
-#define SQLITE_IgnoreChecks   0x00002000  /* Do not enforce check constraints */
-#define SQLITE_ReadUncommitted 0x00004000 /* For shared-cache mode */
-#define SQLITE_LegacyFileFmt  0x00008000  /* Create new databases in format 1 */
-#define SQLITE_FullFSync      0x00010000  /* Use full fsync on the backend */
-#define SQLITE_LoadExtension  0x00020000  /* Enable load_extension */
+#define SQLITE_IgnoreChecks   0x00040000  /* Do not enforce check constraints */
+#define SQLITE_ReadUncommitted 0x0080000  /* For shared-cache mode */
+#define SQLITE_LegacyFileFmt  0x00100000  /* Create new databases in format 1 */
+#define SQLITE_FullFSync      0x00200000  /* Use full fsync on the backend */
+#define SQLITE_LoadExtension  0x00400000  /* Enable load_extension */
+#define SQLITE_RecoveryMode   0x00800000  /* Ignore schema errors */
+#define SQLITE_ReverseOrder   0x01000000  /* Reverse unordered SELECTs */
+#define SQLITE_RecTriggers    0x02000000  /* Enable recursive triggers */
+#define SQLITE_ForeignKeys    0x04000000  /* Enforce foreign key constraints  */
 
-#define SQLITE_RecoveryMode   0x00040000  /* Ignore schema errors */
-#define SQLITE_ReverseOrder   0x00100000  /* Reverse unordered SELECTs */
-#define SQLITE_RecTriggers    0x00200000  /* Enable recursive triggers */
-#define SQLITE_ForeignKeys    0x00400000  /* Enforce foreign key constraints  */
+/*
+** Bits of the sqlite3.flags field that are used by the
+** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface.
+** These must be the low-order bits of the flags field.
+*/
+#define SQLITE_QueryFlattener 0x01        /* Disable query flattening */
+#define SQLITE_ColumnCache    0x02        /* Disable the column cache */
+#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 */
 
 /*
 ** Possible values for the sqlite.magic field.
@@ -8572,6 +8470,7 @@ struct FuncDef {
 #define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */
 #define SQLITE_FUNC_PRIVATE  0x10 /* Allowed for internal use only */
 #define SQLITE_FUNC_COUNT    0x20 /* Built-in count(*) aggregate */
+#define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */
 
 /*
 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
@@ -9111,6 +9010,22 @@ struct AggInfo {
 };
 
 /*
+** The datatype ynVar is a signed integer, either 16-bit or 32-bit.
+** Usually it is 16-bits.  But if SQLITE_MAX_VARIABLE_NUMBER is greater
+** than 32767 we have to make it 32-bit.  16-bit is preferred because
+** it uses less memory in the Expr object, which is a big memory user
+** in systems with lots of prepared statements.  And few applications
+** need more than about 10 or 20 variables.  But some extreme users want
+** to have prepared statements with over 32767 variables, and for them
+** the option is available (at compile-time).
+*/
+#if SQLITE_MAX_VARIABLE_NUMBER<=32767
+typedef i16 ynVar;
+#else
+typedef int ynVar;
+#endif
+
+/*
 ** Each node of an expression in the parse tree is an instance
 ** of this structure.
 **
@@ -9203,7 +9118,8 @@ struct Expr {
   int iTable;            /* TK_COLUMN: cursor number of table holding column
                          ** TK_REGISTER: register number
                          ** TK_TRIGGER: 1 -> new, 0 -> old */
-  i16 iColumn;           /* TK_COLUMN: column index.  -1 for rowid */
+  ynVar iColumn;         /* TK_COLUMN: column index.  -1 for rowid.
+                         ** TK_VARIABLE: variable number (always >= 1). */
   i16 iAgg;              /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
   i16 iRightJoinTable;   /* If EP_FromJoin, the right table of the join */
   u8 flags2;             /* Second set of flags.  EP2_... */
@@ -9227,14 +9143,13 @@ struct Expr {
 #define EP_DblQuoted  0x0040  /* token.z was originally in "..." */
 #define EP_InfixFunc  0x0080  /* True for an infix function: LIKE, GLOB, etc */
 #define EP_ExpCollate 0x0100  /* Collating sequence specified explicitly */
-#define EP_AnyAff     0x0200  /* Can take a cached column of any affinity */
-#define EP_FixedDest  0x0400  /* Result needed in a specific register */
-#define EP_IntValue   0x0800  /* Integer value contained in u.iValue */
-#define EP_xIsSelect  0x1000  /* x.pSelect is valid (otherwise x.pList is) */
+#define EP_FixedDest  0x0200  /* Result needed in a specific register */
+#define EP_IntValue   0x0400  /* Integer value contained in u.iValue */
+#define EP_xIsSelect  0x0800  /* x.pSelect is valid (otherwise x.pList is) */
 
-#define EP_Reduced    0x2000  /* Expr struct is EXPR_REDUCEDSIZE bytes only */
-#define EP_TokenOnly  0x4000  /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
-#define EP_Static     0x8000  /* Held in memory not obtained from malloc() */
+#define EP_Reduced    0x1000  /* Expr struct is EXPR_REDUCEDSIZE bytes only */
+#define EP_TokenOnly  0x2000  /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
+#define EP_Static     0x4000  /* Held in memory not obtained from malloc() */
 
 /*
 ** The following are the meanings of bits in the Expr.flags2 field.
@@ -9479,6 +9394,7 @@ struct WhereLevel {
 #define WHERE_OMIT_OPEN        0x0010 /* Table cursor 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 */
 
 /*
 ** The WHERE clause processing routine has two halves.  The
@@ -9491,6 +9407,7 @@ struct WhereInfo {
   Parse *pParse;       /* Parsing and code generating context */
   u16 wctrlFlags;      /* Flags originally passed to sqlite3WhereBegin() */
   u8 okOnePass;        /* Ok to use one-pass algorithm for UPDATE or DELETE */
+  u8 untestedTerms;    /* Not all WHERE terms resolved by outer loop */
   SrcList *pTabList;             /* List of tables in the join */
   int iTop;                      /* The very beginning of the WHERE loop */
   int iContinue;                 /* Jump here to continue with next record */
@@ -9654,15 +9571,16 @@ struct AutoincInfo {
 ** The Parse.pTriggerPrg list never contains two entries with the same
 ** values for both pTrigger and orconf.
 **
-** The TriggerPrg.oldmask variable is set to a mask of old.* columns
+** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns
 ** accessed (or set to 0 for triggers fired as a result of INSERT 
-** statements).
+** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to
+** a mask of new.* columns used by the program.
 */
 struct TriggerPrg {
   Trigger *pTrigger;      /* Trigger this program was coded from */
   int orconf;             /* Default ON CONFLICT policy */
   SubProgram *pProgram;   /* Program implementing pTrigger/orconf */
-  u32 oldmask;            /* Mask of old.* columns accessed */
+  u32 aColmask[2];        /* Masks of old.*, new.* columns accessed */
   TriggerPrg *pNext;      /* Next entry in Parse.pTriggerPrg list */
 };
 
@@ -9709,7 +9627,6 @@ struct Parse {
   struct yColCache {
     int iTable;           /* Table cursor number */
     int iColumn;          /* Table column number */
-    u8 affChange;         /* True if this register has had an affinity change */
     u8 tempReg;           /* iReg is a temp register that needs to be freed */
     int iLevel;           /* Nesting level */
     int iReg;             /* Reg with value of this column. 0 means none. */
@@ -9734,6 +9651,7 @@ struct Parse {
   Parse *pToplevel;    /* Parse structure for main program (or NULL) */
   Table *pTriggerTab;  /* Table triggers are being coded for */
   u32 oldmask;         /* Mask of old.* columns referenced */
+  u32 newmask;         /* Mask of new.* columns referenced */
   u8 eTriggerOp;       /* TK_UPDATE, TK_INSERT or TK_DELETE */
   u8 eOrconf;          /* Default ON CONFLICT policy for trigger steps */
   u8 disableTriggers;  /* True to disable triggers */
@@ -9745,6 +9663,7 @@ struct Parse {
   int nVarExpr;        /* Number of used slots in apVarExpr[] */
   int nVarExprAlloc;   /* Number of allocated slots in apVarExpr[] */
   Expr **apVarExpr;    /* Pointers to :aaa and $aaaa wildcard expressions */
+  Vdbe *pReprepare;    /* VM being reprepared (sqlite3Reprepare()) */
   int nAlias;          /* Number of aliased result set columns */
   int nAliasAlloc;     /* Number of allocated slots for aAlias[] */
   int *aAlias;         /* Register used to hold aliased result */
@@ -10111,6 +10030,9 @@ SQLITE_PRIVATE void sqlite3StatusSet(int, int);
 SQLITE_PRIVATE int sqlite3IsNaN(double);
 
 SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, int, const char*, va_list);
+#ifndef SQLITE_OMIT_TRACE
+SQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, const char*, ...);
+#endif
 SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
 SQLITE_PRIVATE char *sqlite3MAppendf(sqlite3*,char*,const char*,...);
@@ -10138,7 +10060,6 @@ SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*);
 SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);
 SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*);
 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*);
-SQLITE_PRIVATE void sqlite3ExprClear(sqlite3*, Expr*);
 SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
 SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
 SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
@@ -10224,13 +10145,13 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
 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, int);
+SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, 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);
 SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
 SQLITE_PRIVATE void sqlite3ExprCachePop(Parse*, int);
-SQLITE_PRIVATE void sqlite3ExprCacheRemove(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);
@@ -10254,7 +10175,6 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*);
 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
-SQLITE_PRIVATE Expr *sqlite3CreateIdExpr(Parse *, const char*);
 SQLITE_PRIVATE void sqlite3PrngSaveState(void);
 SQLITE_PRIVATE void sqlite3PrngRestoreState(void);
 SQLITE_PRIVATE void sqlite3PrngResetState(void);
@@ -10269,6 +10189,9 @@ SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);
 SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);
 SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*);
 SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);
+SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
+SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
+SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
 SQLITE_PRIVATE int sqlite3IsRowid(const char*);
 SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
@@ -10326,7 +10249,7 @@ SQLITE_PRIVATE   TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*
 SQLITE_PRIVATE   TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);
 SQLITE_PRIVATE   void sqlite3DeleteTrigger(sqlite3*, Trigger*);
 SQLITE_PRIVATE   void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
-SQLITE_PRIVATE   u32 sqlite3TriggerOldmask(Parse*,Trigger*,ExprList*,Table*,int);
+SQLITE_PRIVATE   u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
 # define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
 #else
 # define sqlite3TriggersExist(B,C,D,E,F) 0
@@ -10337,7 +10260,7 @@ SQLITE_PRIVATE   u32 sqlite3TriggerOldmask(Parse*,Trigger*,ExprList*,Table*,int)
 # define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)
 # define sqlite3TriggerList(X, Y) 0
 # define sqlite3ParseToplevel(p) p
-# define sqlite3TriggerOldmask(A,B,C,D,E) 0
+# define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0
 #endif
 
 SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);
@@ -10357,7 +10280,7 @@ 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(const sqlite3 *db, const char *zFilename,
+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*);
@@ -10440,6 +10363,7 @@ SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int *);
 SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
 SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
 #ifndef SQLITE_AMALGAMATION
+SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];
 SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];
 SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[];
 SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config;
@@ -10453,7 +10377,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
 SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);
-SQLITE_PRIVATE void sqlite3CodeSubselect(Parse *, Expr *, int, int);
+SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
 SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
 SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
@@ -10488,6 +10412,7 @@ SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum*,const char*,int);
 SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
 SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*);
 SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
+SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
 
 SQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);
 SQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
@@ -10549,6 +10474,7 @@ SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
 SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
 SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
 SQLITE_PRIVATE void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);
+SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
 SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
@@ -10680,7 +10606,6 @@ SQLITE_PRIVATE void (*sqlite3IoTrace)(const char*,...);
 ** This file contains definitions of global variables and contants.
 */
 
-
 /* An array to map all upper-case characters into their corresponding
 ** lower-case character. 
 **
@@ -10736,6 +10661,7 @@ SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[] = {
 **   isalnum()                        0x06
 **   isxdigit()                       0x08
 **   toupper()                        0x20
+**   SQLite identifier character      0x40
 **
 ** Bit 0x20 is set if the mapped character requires translation to upper
 ** case. i.e. if the character is a lower-case ASCII character.
@@ -10747,6 +10673,11 @@ SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[] = {
 ** Standard function tolower() is implemented using the sqlite3UpperToLower[]
 ** array. tolower() is used more often than toupper() by SQLite.
 **
+** Bit 0x40 is set if the character non-alphanumeric and can be used in an 
+** SQLite identifier.  Identifiers are alphanumerics, "_", "$", and any
+** non-ASCII UTF character. Hence the test for whether or not a character is
+** part of an identifier is 0x46.
+**
 ** SQLite's versions are identical to the standard versions assuming a
 ** locale of "C". They are implemented as macros in sqliteInt.h.
 */
@@ -10756,7 +10687,7 @@ SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = {
   0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,  /* 08..0f    ........ */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 10..17    ........ */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 18..1f    ........ */
-  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 20..27     !"#$%&' */
+  0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,  /* 20..27     !"#$%&' */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 28..2f    ()*+,-./ */
   0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,  /* 30..37    01234567 */
   0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 38..3f    89:;<=>? */
@@ -10764,29 +10695,29 @@ SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = {
   0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x02,  /* 40..47    @ABCDEFG */
   0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 48..4f    HIJKLMNO */
   0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 50..57    PQRSTUVW */
-  0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 58..5f    XYZ[\]^_ */
+  0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40,  /* 58..5f    XYZ[\]^_ */
   0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x22,  /* 60..67    `abcdefg */
   0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 68..6f    hijklmno */
   0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 70..77    pqrstuvw */
   0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 78..7f    xyz{|}~. */
 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 80..87    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 88..8f    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 90..97    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 98..9f    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* a0..a7    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* a8..af    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* b0..b7    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* b8..bf    ........ */
-
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* c0..c7    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* c8..cf    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* d0..d7    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* d8..df    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* e0..e7    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* e8..ef    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* f0..f7    ........ */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00   /* f8..ff    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 80..87    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 88..8f    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 90..97    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 98..9f    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a0..a7    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a8..af    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b0..b7    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b8..bf    ........ */
+
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c0..c7    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c8..cf    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d0..d7    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d8..df    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e0..e7    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e8..ef    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* f0..f7    ........ */
+  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40   /* f8..ff    ........ */
 };
 #endif
 
@@ -10855,6 +10786,14 @@ SQLITE_PRIVATE SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
 */
 SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;
 
+/*
+** Properties of opcodes.  The OPFLG_INITIALIZER macro is
+** created by mkopcodeh.awk during compilation.  Data is obtained
+** from the comments following the "case OP_xxxx:" statements in
+** the vdbe.c file.  
+*/
+SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
+
 /************** End of global.c **********************************************/
 /************** Begin file status.c ******************************************/
 /*
@@ -10871,8 +10810,6 @@ SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;
 **
 ** This module implements the sqlite3_status() interface and related
 ** functionality.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -10999,8 +10936,6 @@ SQLITE_API int sqlite3_db_status(
 ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
 ** All other code has file scope.
 **
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
-**
 ** SQLite processes all times and dates as Julian Day numbers.  The
 ** dates and times are stored as the number of days since noon
 ** in Greenwich on November 24, 4714 B.C. according to the Gregorian
@@ -12103,8 +12038,6 @@ SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
 **
 ** This file contains OS interface code that is common to all
 ** architectures.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #define _SQLITE_OS_C_ 1
 #undef _SQLITE_OS_C_
@@ -12230,6 +12163,7 @@ SQLITE_PRIVATE int sqlite3OsFullPathname(
   int nPathOut, 
   char *zPathOut
 ){
+  zPathOut[0] = 0;
   return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
 }
 #ifndef SQLITE_OMIT_LOAD_EXTENSION
@@ -12401,10 +12335,6 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
 **
 *************************************************************************
 **
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
-*/
-
-/*
 ** This file contains code to support the concept of "benign" 
 ** malloc failures (when the xMalloc() or xRealloc() method of the
 ** sqlite3_mem_methods structure fails to allocate a block of memory
@@ -12499,8 +12429,6 @@ SQLITE_PRIVATE void sqlite3EndBenignMalloc(void){
 ** here always fail.  SQLite will not operate with these drivers.  These
 ** are merely placeholders.  Real drivers must be substituted using
 ** sqlite3_config() before SQLite will operate.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -12563,8 +12491,6 @@ SQLITE_PRIVATE void sqlite3MemSetDefault(void){
 **
 ** This file contains implementations of the low-level memory allocation
 ** routines specified in the sqlite3_mem_methods object.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -12712,8 +12638,6 @@ SQLITE_PRIVATE void sqlite3MemSetDefault(void){
 **
 ** This file contains implementations of the low-level memory allocation
 ** routines specified in the sqlite3_mem_methods object.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -12905,6 +12829,31 @@ static int sqlite3MemRoundup(int n){
 }
 
 /*
+** Fill a buffer with pseudo-random bytes.  This is used to preset
+** the content of a new memory allocation to unpredictable values and
+** to clear the content of a freed allocation to unpredictable values.
+*/
+static void randomFill(char *pBuf, int nByte){
+  unsigned int x, y, r;
+  x = SQLITE_PTR_TO_INT(pBuf);
+  y = nByte | 1;
+  while( nByte >= 4 ){
+    x = (x>>1) ^ (-(x&1) & 0xd0000001);
+    y = y*1103515245 + 12345;
+    r = x ^ y;
+    *(int*)pBuf = r;
+    pBuf += 4;
+    nByte -= 4;
+  }
+  while( nByte-- > 0 ){
+    x = (x>>1) ^ (-(x&1) & 0xd0000001);
+    y = y*1103515245 + 12345;
+    r = x ^ y;
+    *(pBuf++) = r & 0xff;
+  }
+}
+
+/*
 ** Allocate nByte bytes of memory.
 */
 static void *sqlite3MemMalloc(int nByte){
@@ -12954,7 +12903,8 @@ static void *sqlite3MemMalloc(int nByte){
     adjustStats(nByte, +1);
     pInt = (int*)&pHdr[1];
     pInt[nReserve/sizeof(int)] = REARGUARD;
-    memset(pInt, 0x65, nReserve);
+    randomFill((char*)pInt, nByte);
+    memset(((char*)pInt)+nByte, 0x65, nReserve-nByte);
     p = (void*)pInt;
   }
   sqlite3_mutex_leave(mem.mutex);
@@ -12990,8 +12940,8 @@ static void sqlite3MemFree(void *pPrior){
   z = (char*)pBt;
   z -= pHdr->nTitle;
   adjustStats(pHdr->iSize, -1);
-  memset(z, 0x2b, sizeof(void*)*pHdr->nBacktraceSlots + sizeof(*pHdr) +
-                  pHdr->iSize + sizeof(int) + pHdr->nTitle);
+  randomFill(z, sizeof(void*)*pHdr->nBacktraceSlots + sizeof(*pHdr) +
+                pHdr->iSize + sizeof(int) + pHdr->nTitle);
   free(z);
   sqlite3_mutex_leave(mem.mutex);  
 }
@@ -13014,7 +12964,7 @@ static void *sqlite3MemRealloc(void *pPrior, int nByte){
   if( pNew ){
     memcpy(pNew, pPrior, nByte<pOldHdr->iSize ? nByte : pOldHdr->iSize);
     if( nByte>pOldHdr->iSize ){
-      memset(&((char*)pNew)[pOldHdr->iSize], 0x2b, nByte - pOldHdr->iSize);
+      randomFill(&((char*)pNew)[pOldHdr->iSize], nByte - pOldHdr->iSize);
     }
     sqlite3MemFree(pPrior);
   }
@@ -13161,8 +13111,6 @@ SQLITE_PRIVATE int sqlite3MemdebugMallocCount(){
 **
 ** This version of the memory allocation subsystem is included
 ** in the build only if SQLITE_ENABLE_MEMSYS3 is defined.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -14420,9 +14368,6 @@ SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void){
 ** This file contains the C functions that implement mutexes.
 **
 ** This file contains code that is common across all mutex implementations.
-
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 #if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT)
@@ -14587,8 +14532,6 @@ SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
 ** If compiled with SQLITE_DEBUG, then additional logic is inserted
 ** that does error checking on mutexes to make sure they are being
 ** called correctly.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -14761,8 +14704,6 @@ SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
 **
 *************************************************************************
 ** This file contains the C functions that implement mutexes for OS/2
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -14910,6 +14851,39 @@ static void os2MutexFree(sqlite3_mutex *p){
   sqlite3_free( p );
 }
 
+#ifdef SQLITE_DEBUG
+/*
+** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
+** intended for use inside assert() statements.
+*/
+static int os2MutexHeld(sqlite3_mutex *p){
+  TID tid;
+  PID pid;
+  ULONG ulCount;
+  PTIB ptib;
+  if( p!=0 ) {
+    DosQueryMutexSem(p->mutex, &pid, &tid, &ulCount);
+  } else {
+    DosGetInfoBlocks(&ptib, NULL);
+    tid = ptib->tib_ptib2->tib2_ultid;
+  }
+  return p==0 || (p->nRef!=0 && p->owner==tid);
+}
+static int os2MutexNotheld(sqlite3_mutex *p){
+  TID tid;
+  PID pid;
+  ULONG ulCount;
+  PTIB ptib;
+  if( p!= 0 ) {
+    DosQueryMutexSem(p->mutex, &pid, &tid, &ulCount);
+  } else {
+    DosGetInfoBlocks(&ptib, NULL);
+    tid = ptib->tib_ptib2->tib2_ultid;
+  }
+  return p==0 || p->nRef==0 || p->owner!=tid;
+}
+#endif
+
 /*
 ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
 ** to enter a mutex.  If another thread is already within the mutex,
@@ -14970,39 +14944,6 @@ static void os2MutexLeave(sqlite3_mutex *p){
   DosReleaseMutexSem(p->mutex);
 }
 
-#ifdef SQLITE_DEBUG
-/*
-** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
-** intended for use inside assert() statements.
-*/
-static int os2MutexHeld(sqlite3_mutex *p){
-  TID tid;
-  PID pid;
-  ULONG ulCount;
-  PTIB ptib;
-  if( p!=0 ) {
-    DosQueryMutexSem(p->mutex, &pid, &tid, &ulCount);
-  } else {
-    DosGetInfoBlocks(&ptib, NULL);
-    tid = ptib->tib_ptib2->tib2_ultid;
-  }
-  return p==0 || (p->nRef!=0 && p->owner==tid);
-}
-static int os2MutexNotheld(sqlite3_mutex *p){
-  TID tid;
-  PID pid;
-  ULONG ulCount;
-  PTIB ptib;
-  if( p!= 0 ) {
-    DosQueryMutexSem(p->mutex, &pid, &tid, &ulCount);
-  } else {
-    DosGetInfoBlocks(&ptib, NULL);
-    tid = ptib->tib_ptib2->tib2_ultid;
-  }
-  return p==0 || p->nRef==0 || p->owner!=tid;
-}
-#endif
-
 SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
   static sqlite3_mutex_methods sMutex = {
     os2MutexInit,
@@ -15036,8 +14977,6 @@ SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
 **
 *************************************************************************
 ** This file contains the C functions that implement mutexes for pthreads
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -15367,8 +15306,6 @@ SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
 **
 *************************************************************************
 ** This file contains the C functions that implement mutexes for win32
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -15654,8 +15591,6 @@ SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
 *************************************************************************
 **
 ** Memory allocation functions used throughout sqlite.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -15706,9 +15641,6 @@ SQLITE_API void sqlite3_soft_heap_limit(int n){
 SQLITE_API int sqlite3_release_memory(int n){
 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
   int nRet = 0;
-#if 0
-  nRet += sqlite3VdbeReleaseMemory(n);
-#endif
   nRet += sqlite3PcacheReleaseMemory(n-nRet);
   return nRet;
 #else
@@ -16364,8 +16296,6 @@ SQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){
 ** an historical reference.  Most of the "enhancements" have been backed
 ** out so that the functionality is now the same as standard printf().
 **
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
-**
 **************************************************************************
 **
 ** The following modules is an enhanced replacement for the "printf" subroutines
@@ -17005,14 +16935,15 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
       case etSQLESCAPE:
       case etSQLESCAPE2:
       case etSQLESCAPE3: {
-        int i, j, n, isnull;
+        int i, j, k, n, isnull;
         int needQuote;
         char ch;
         char q = ((xtype==etSQLESCAPE3)?'"':'\'');   /* Quote character */
         char *escarg = va_arg(ap,char*);
         isnull = escarg==0;
         if( isnull ) escarg = (xtype==etSQLESCAPE2 ? "NULL" : "(NULL)");
-        for(i=n=0; (ch=escarg[i])!=0; i++){
+        k = precision;
+        for(i=n=0; (ch=escarg[i])!=0 && k!=0; i++, k--){
           if( ch==q )  n++;
         }
         needQuote = !isnull && xtype==etSQLESCAPE2;
@@ -17028,15 +16959,17 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
         }
         j = 0;
         if( needQuote ) bufpt[j++] = q;
-        for(i=0; (ch=escarg[i])!=0; i++){
-          bufpt[j++] = ch;
+        k = i;
+        for(i=0; i<k; i++){
+          bufpt[j++] = ch = escarg[i];
           if( ch==q ) bufpt[j++] = ch;
         }
         if( needQuote ) bufpt[j++] = q;
         bufpt[j] = 0;
         length = j;
-        /* The precision is ignored on %q and %Q */
-        /* if( precision>=0 && precision<length ) length = precision; */
+        /* The precision in %q and %Q means how many input characters to
+        ** consume, not the length of the output...
+        ** if( precision>=0 && precision<length ) length = precision; */
         break;
       }
       case etTOKEN: {
@@ -17315,6 +17248,18 @@ SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
 }
 #endif
 
+#ifndef SQLITE_OMIT_TRACE
+/*
+** variable-argument wrapper around sqlite3VXPrintf().
+*/
+SQLITE_PRIVATE void sqlite3XPrintf(StrAccum *p, const char *zFormat, ...){
+  va_list ap;
+  va_start(ap,zFormat);
+  sqlite3VXPrintf(p, 1, zFormat, ap);
+  va_end(ap);
+}
+#endif
+
 /************** End of printf.c **********************************************/
 /************** Begin file random.c ******************************************/
 /*
@@ -17333,8 +17278,6 @@ SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
 **
 ** Random numbers are used by some of the database backends in order
 ** to generate random integer keys for tables or random filenames.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -17480,8 +17423,6 @@ SQLITE_PRIVATE void sqlite3PrngResetState(void){
 ** This file contains routines used to translate between UTF-8, 
 ** UTF-16, UTF-16BE, and UTF-16LE.
 **
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
-**
 ** Notes on UTF-8:
 **
 **   Byte-0    Byte-1    Byte-2    Byte-3    Value
@@ -17521,8 +17462,6 @@ SQLITE_PRIVATE void sqlite3PrngResetState(void){
 ** 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.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _VDBEINT_H_
 #define _VDBEINT_H_
@@ -17797,7 +17736,7 @@ struct Vdbe {
   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 */
-  u16 nVar;               /* Number of entries in aVar[] */
+  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 */
@@ -17830,6 +17769,7 @@ struct Vdbe {
 #endif
   VdbeFrame *pFrame;      /* Parent frame */
   int nFrame;             /* Number of frames in pFrame list */
+  u32 expmask;            /* Binding to these vars invalidates VM */
 };
 
 /*
@@ -17887,14 +17827,11 @@ 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 sqlite3VdbeOpcodeHasProperty(int, 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 *);
-#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
-SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p);
-#endif
+SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem);
 
 #ifndef SQLITE_OMIT_FOREIGN_KEY
 SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);
@@ -17994,20 +17931,20 @@ static const unsigned char sqlite3Utf8Trans1[] = {
   }                                                                 \
 }
 
-#define READ_UTF16LE(zIn, c){                                         \
+#define READ_UTF16LE(zIn, TERM, c){                                   \
   c = (*zIn++);                                                       \
   c += ((*zIn++)<<8);                                                 \
-  if( c>=0xD800 && c<0xE000 ){                                        \
+  if( c>=0xD800 && c<0xE000 && TERM ){                                \
     int c2 = (*zIn++);                                                \
     c2 += ((*zIn++)<<8);                                              \
     c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \
   }                                                                   \
 }
 
-#define READ_UTF16BE(zIn, c){                                         \
+#define READ_UTF16BE(zIn, TERM, c){                                   \
   c = ((*zIn++)<<8);                                                  \
   c += (*zIn++);                                                      \
-  if( c>=0xD800 && c<0xE000 ){                                        \
+  if( c>=0xD800 && c<0xE000 && TERM ){                                \
     int c2 = ((*zIn++)<<8);                                           \
     c2 += (*zIn++);                                                   \
     c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \
@@ -18192,13 +18129,13 @@ SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){
     if( pMem->enc==SQLITE_UTF16LE ){
       /* UTF-16 Little-endian -> UTF-8 */
       while( zIn<zTerm ){
-        READ_UTF16LE(zIn, c); 
+        READ_UTF16LE(zIn, zIn<zTerm, c); 
         WRITE_UTF8(z, c);
       }
     }else{
       /* UTF-16 Big-endian -> UTF-8 */
       while( zIn<zTerm ){
-        READ_UTF16BE(zIn, c); 
+        READ_UTF16BE(zIn, zIn<zTerm, c); 
         WRITE_UTF8(z, c);
       }
     }
@@ -18368,7 +18305,7 @@ SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *db, u8 enc, char *z, int n, int *p
 #endif
 
 /*
-** pZ is a UTF-16 encoded unicode string at least nChar characters long.
+** zIn is a UTF-16 encoded unicode string at least nChar characters long.
 ** Return the number of bytes in the first nChar unicode characters
 ** in pZ.  nChar must be non-negative.
 */
@@ -18376,23 +18313,15 @@ SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *zIn, int nChar){
   int c;
   unsigned char const *z = zIn;
   int n = 0;
+  
   if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){
-    /* Using an "if (SQLITE_UTF16NATIVE==SQLITE_UTF16BE)" construct here
-    ** and in other parts of this file means that at one branch will
-    ** not be covered by coverage testing on any single host. But coverage
-    ** will be complete if the tests are run on both a little-endian and 
-    ** big-endian host. Because both the UTF16NATIVE and SQLITE_UTF16BE
-    ** macros are constant at compile time the compiler can determine
-    ** which branch will be followed. It is therefore assumed that no runtime
-    ** penalty is paid for this "if" statement.
-    */
     while( n<nChar ){
-      READ_UTF16BE(z, c);
+      READ_UTF16BE(z, 1, c);
       n++;
     }
   }else{
     while( n<nChar ){
-      READ_UTF16LE(z, c);
+      READ_UTF16LE(z, 1, c);
       n++;
     }
   }
@@ -18434,7 +18363,7 @@ SQLITE_PRIVATE void sqlite3UtfSelfTest(void){
     assert( n>0 && n<=4 );
     z[0] = 0;
     z = zBuf;
-    READ_UTF16LE(z, c);
+    READ_UTF16LE(z, 1, c);
     assert( c==i );
     assert( (z-zBuf)==n );
   }
@@ -18446,7 +18375,7 @@ SQLITE_PRIVATE void sqlite3UtfSelfTest(void){
     assert( n>0 && n<=4 );
     z[0] = 0;
     z = zBuf;
-    READ_UTF16BE(z, c);
+    READ_UTF16BE(z, 1, c);
     assert( c==i );
     assert( (z-zBuf)==n );
   }
@@ -19564,8 +19493,6 @@ SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3 *db){
 *************************************************************************
 ** This is the implementation of generic hash-tables
 ** used in SQLite.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /* Turn bulk memory into a hash table object by initializing the
@@ -19836,78 +19763,78 @@ SQLITE_PRIVATE void *sqlite3HashInsert(Hash *pH, const char *pKey, int nKey, voi
 #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
 SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
  static const char *const azName[] = { "?",
-     /*   1 */ "VNext",
-     /*   2 */ "Affinity",
-     /*   3 */ "Column",
-     /*   4 */ "SetCookie",
-     /*   5 */ "Seek",
-     /*   6 */ "Sequence",
-     /*   7 */ "Savepoint",
-     /*   8 */ "RowKey",
-     /*   9 */ "SCopy",
-     /*  10 */ "OpenWrite",
-     /*  11 */ "If",
-     /*  12 */ "CollSeq",
-     /*  13 */ "OpenRead",
-     /*  14 */ "Expire",
-     /*  15 */ "AutoCommit",
-     /*  16 */ "Pagecount",
-     /*  17 */ "IntegrityCk",
-     /*  18 */ "Sort",
+     /*   1 */ "Goto",
+     /*   2 */ "Gosub",
+     /*   3 */ "Return",
+     /*   4 */ "Yield",
+     /*   5 */ "HaltIfNull",
+     /*   6 */ "Halt",
+     /*   7 */ "Integer",
+     /*   8 */ "Int64",
+     /*   9 */ "String",
+     /*  10 */ "Null",
+     /*  11 */ "Blob",
+     /*  12 */ "Variable",
+     /*  13 */ "Move",
+     /*  14 */ "Copy",
+     /*  15 */ "SCopy",
+     /*  16 */ "ResultRow",
+     /*  17 */ "CollSeq",
+     /*  18 */ "Function",
      /*  19 */ "Not",
-     /*  20 */ "Copy",
-     /*  21 */ "Trace",
-     /*  22 */ "Function",
-     /*  23 */ "IfNeg",
-     /*  24 */ "Noop",
-     /*  25 */ "Program",
-     /*  26 */ "Return",
-     /*  27 */ "NewRowid",
-     /*  28 */ "FkCounter",
-     /*  29 */ "Variable",
-     /*  30 */ "String",
-     /*  31 */ "RealAffinity",
-     /*  32 */ "VRename",
-     /*  33 */ "ParseSchema",
-     /*  34 */ "VOpen",
-     /*  35 */ "Close",
-     /*  36 */ "CreateIndex",
-     /*  37 */ "IsUnique",
-     /*  38 */ "NotFound",
-     /*  39 */ "Int64",
-     /*  40 */ "MustBeInt",
-     /*  41 */ "Halt",
-     /*  42 */ "Rowid",
-     /*  43 */ "IdxLT",
-     /*  44 */ "AddImm",
-     /*  45 */ "RowData",
-     /*  46 */ "MemMax",
-     /*  47 */ "NotExists",
-     /*  48 */ "Gosub",
-     /*  49 */ "Integer",
-     /*  50 */ "Prev",
-     /*  51 */ "RowSetRead",
-     /*  52 */ "RowSetAdd",
-     /*  53 */ "VColumn",
-     /*  54 */ "CreateTable",
-     /*  55 */ "Last",
-     /*  56 */ "SeekLe",
-     /*  57 */ "IncrVacuum",
-     /*  58 */ "IdxRowid",
-     /*  59 */ "ResetCount",
-     /*  60 */ "Yield",
-     /*  61 */ "DropTrigger",
-     /*  62 */ "DropIndex",
-     /*  63 */ "Param",
-     /*  64 */ "IdxGE",
-     /*  65 */ "IdxDelete",
-     /*  66 */ "Vacuum",
-     /*  67 */ "IfNot",
+     /*  20 */ "AddImm",
+     /*  21 */ "MustBeInt",
+     /*  22 */ "RealAffinity",
+     /*  23 */ "Permutation",
+     /*  24 */ "Compare",
+     /*  25 */ "Jump",
+     /*  26 */ "If",
+     /*  27 */ "IfNot",
+     /*  28 */ "Column",
+     /*  29 */ "Affinity",
+     /*  30 */ "MakeRecord",
+     /*  31 */ "Count",
+     /*  32 */ "Savepoint",
+     /*  33 */ "AutoCommit",
+     /*  34 */ "Transaction",
+     /*  35 */ "ReadCookie",
+     /*  36 */ "SetCookie",
+     /*  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",
      /*  68 */ "Or",
      /*  69 */ "And",
-     /*  70 */ "DropTable",
-     /*  71 */ "SeekLt",
-     /*  72 */ "MakeRecord",
+     /*  70 */ "IdxDelete",
+     /*  71 */ "IdxRowid",
+     /*  72 */ "IdxLT",
      /*  73 */ "IsNull",
      /*  74 */ "NotNull",
      /*  75 */ "Ne",
@@ -19916,7 +19843,7 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
      /*  78 */ "Le",
      /*  79 */ "Lt",
      /*  80 */ "Ge",
-     /*  81 */ "ResultRow",
+     /*  81 */ "IdxGE",
      /*  82 */ "BitAnd",
      /*  83 */ "BitOr",
      /*  84 */ "ShiftLeft",
@@ -19927,49 +19854,49 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
      /*  89 */ "Divide",
      /*  90 */ "Remainder",
      /*  91 */ "Concat",
-     /*  92 */ "Delete",
+     /*  92 */ "Destroy",
      /*  93 */ "BitNot",
      /*  94 */ "String8",
-     /*  95 */ "AggFinal",
-     /*  96 */ "Compare",
-     /*  97 */ "Goto",
-     /*  98 */ "TableLock",
-     /*  99 */ "Clear",
-     /* 100 */ "VerifyCookie",
-     /* 101 */ "AggStep",
-     /* 102 */ "Transaction",
-     /* 103 */ "VFilter",
-     /* 104 */ "VDestroy",
-     /* 105 */ "Next",
-     /* 106 */ "Count",
-     /* 107 */ "IdxInsert",
-     /* 108 */ "FkIfZero",
-     /* 109 */ "SeekGe",
-     /* 110 */ "Insert",
-     /* 111 */ "Destroy",
-     /* 112 */ "ReadCookie",
-     /* 113 */ "RowSetTest",
-     /* 114 */ "LoadAnalysis",
-     /* 115 */ "Explain",
-     /* 116 */ "HaltIfNull",
-     /* 117 */ "OpenPseudo",
-     /* 118 */ "OpenEphemeral",
-     /* 119 */ "Null",
-     /* 120 */ "Move",
-     /* 121 */ "Blob",
-     /* 122 */ "Rewind",
-     /* 123 */ "SeekGt",
-     /* 124 */ "VBegin",
-     /* 125 */ "VUpdate",
-     /* 126 */ "IfZero",
-     /* 127 */ "VCreate",
-     /* 128 */ "Found",
-     /* 129 */ "IfPos",
+     /*  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",
      /* 130 */ "Real",
-     /* 131 */ "NullRow",
-     /* 132 */ "Jump",
-     /* 133 */ "Permutation",
-     /* 134 */ "NotUsed_134",
+     /* 131 */ "Pagecount",
+     /* 132 */ "Trace",
+     /* 133 */ "Noop",
+     /* 134 */ "Explain",
      /* 135 */ "NotUsed_135",
      /* 136 */ "NotUsed_136",
      /* 137 */ "NotUsed_137",
@@ -20001,8 +19928,6 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
 ******************************************************************************
 **
 ** This file contains code that is specific to OS/2.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -20064,8 +19989,6 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
 **
 ** This file should be #included by the os_*.c files only.  It is not a
 ** general purpose header file.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _OS_COMMON_H_
 #define _OS_COMMON_H_
@@ -20126,8 +20049,6 @@ SQLITE_PRIVATE int sqlite3OSTrace = 0;
 **
 ** This file contains inline asm code for retrieving "high-performance"
 ** counters for x86 class CPUs.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _HWTIME_H_
 #define _HWTIME_H_
@@ -21593,8 +21514,6 @@ struct unixFile {
 **
 ** This file should be #included by the os_*.c files only.  It is not a
 ** general purpose header file.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _OS_COMMON_H_
 #define _OS_COMMON_H_
@@ -21655,8 +21574,6 @@ SQLITE_PRIVATE int sqlite3OSTrace = 0;
 **
 ** This file contains inline asm code for retrieving "high-performance"
 ** counters for x86 class CPUs.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _HWTIME_H_
 #define _HWTIME_H_
@@ -22721,7 +22638,7 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
 #endif
   
   unixLeaveMutex();
-  OSTRACE4("TEST WR-LOCK %d %d %d\n", pFile->h, rc, reserved);
+  OSTRACE4("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved);
 
   *pResOut = reserved;
   return rc;
@@ -22854,7 +22771,7 @@ static int unixLock(sqlite3_file *id, int locktype){
   int tErrno;
 
   assert( pFile );
-  OSTRACE7("LOCK    %d %s was %s(%s,%d) pid=%d\n", pFile->h,
+  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());
 
@@ -22863,7 +22780,7 @@ static int unixLock(sqlite3_file *id, int locktype){
   ** unixEnterMutex() hasn't been called yet.
   */
   if( pFile->locktype>=locktype ){
-    OSTRACE3("LOCK    %d %s ok (already held)\n", pFile->h,
+    OSTRACE3("LOCK    %d %s ok (already held) (unix)\n", pFile->h,
             locktypeName(locktype));
     return SQLITE_OK;
   }
@@ -23033,7 +22950,7 @@ static int unixLock(sqlite3_file *id, int locktype){
 
 end_lock:
   unixLeaveMutex();
-  OSTRACE4("LOCK    %d %s %s\n", pFile->h, locktypeName(locktype), 
+  OSTRACE4("LOCK    %d %s %s (unix)\n", pFile->h, locktypeName(locktype), 
       rc==SQLITE_OK ? "ok" : "failed");
   return rc;
 }
@@ -23097,7 +23014,7 @@ static int unixUnlock(sqlite3_file *id, int locktype){
   int tErrno;                      /* Error code from system call errors */
 
   assert( pFile );
-  OSTRACE7("UNLOCK  %d %d was %d(%d,%d) pid=%d\n", pFile->h, locktype,
+  OSTRACE7("UNLOCK  %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, locktype,
       pFile->locktype, pFile->pLock->locktype, pFile->pLock->cnt, getpid());
 
   assert( locktype<=SHARED_LOCK );
@@ -23378,7 +23295,7 @@ 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\n", pFile->h, rc, reserved);
+  OSTRACE4("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, rc, reserved);
   *pResOut = reserved;
   return rc;
 }
@@ -23468,7 +23385,7 @@ static int dotlockUnlock(sqlite3_file *id, int locktype) {
   char *zLockFile = (char *)pFile->lockingContext;
 
   assert( pFile );
-  OSTRACE5("UNLOCK  %d %d was %d pid=%d\n", pFile->h, locktype,
+  OSTRACE5("UNLOCK  %d %d was %d pid=%d (dotlock)\n", pFile->h, locktype,
 	   pFile->locktype, getpid());
   assert( locktype<=SHARED_LOCK );
   
@@ -23582,7 +23499,7 @@ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
       }
     }
   }
-  OSTRACE4("TEST WR-LOCK %d %d %d\n", pFile->h, rc, reserved);
+  OSTRACE4("TEST WR-LOCK %d %d %d (flock)\n", pFile->h, rc, reserved);
 
 #ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
   if( (rc & SQLITE_IOERR) == SQLITE_IOERR ){
@@ -23649,7 +23566,7 @@ static int flockLock(sqlite3_file *id, int locktype) {
     /* got it, set the type and return ok */
     pFile->locktype = locktype;
   }
-  OSTRACE4("LOCK    %d %s %s\n", pFile->h, locktypeName(locktype), 
+  OSTRACE4("LOCK    %d %s %s (flock)\n", pFile->h, locktypeName(locktype), 
            rc==SQLITE_OK ? "ok" : "failed");
 #ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
   if( (rc & SQLITE_IOERR) == SQLITE_IOERR ){
@@ -23671,7 +23588,7 @@ static int flockUnlock(sqlite3_file *id, int locktype) {
   unixFile *pFile = (unixFile*)id;
   
   assert( pFile );
-  OSTRACE5("UNLOCK  %d %d was %d pid=%d\n", pFile->h, locktype,
+  OSTRACE5("UNLOCK  %d %d was %d pid=%d (flock)\n", pFile->h, locktype,
            pFile->locktype, getpid());
   assert( locktype<=SHARED_LOCK );
   
@@ -23773,7 +23690,7 @@ static int semCheckReservedLock(sqlite3_file *id, int *pResOut) {
       sem_post(pSem);
     }
   }
-  OSTRACE4("TEST WR-LOCK %d %d %d\n", pFile->h, rc, reserved);
+  OSTRACE4("TEST WR-LOCK %d %d %d (sem)\n", pFile->h, rc, reserved);
 
   *pResOut = reserved;
   return rc;
@@ -23848,7 +23765,7 @@ static int semUnlock(sqlite3_file *id, int locktype) {
 
   assert( pFile );
   assert( pSem );
-  OSTRACE5("UNLOCK  %d %d was %d pid=%d\n", pFile->h, locktype,
+  OSTRACE5("UNLOCK  %d %d was %d pid=%d (sem)\n", pFile->h, locktype,
 	   pFile->locktype, getpid());
   assert( locktype<=SHARED_LOCK );
   
@@ -24018,7 +23935,7 @@ static int afpCheckReservedLock(sqlite3_file *id, int *pResOut){
     }
   }
   
-  OSTRACE4("TEST WR-LOCK %d %d %d\n", pFile->h, rc, reserved);
+  OSTRACE4("TEST WR-LOCK %d %d %d (afp)\n", pFile->h, rc, reserved);
   
   *pResOut = reserved;
   return rc;
@@ -24054,7 +23971,7 @@ static int afpLock(sqlite3_file *id, int locktype){
   afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
   
   assert( pFile );
-  OSTRACE5("LOCK    %d %s was %s pid=%d\n", pFile->h,
+  OSTRACE5("LOCK    %d %s was %s pid=%d (afp)\n", pFile->h,
          locktypeName(locktype), locktypeName(pFile->locktype), getpid());
 
   /* If there is already a lock of this type or more restrictive on the
@@ -24062,7 +23979,7 @@ static int afpLock(sqlite3_file *id, int locktype){
   ** unixEnterMutex() hasn't been called yet.
   */
   if( pFile->locktype>=locktype ){
-    OSTRACE3("LOCK    %d %s ok (already held)\n", pFile->h,
+    OSTRACE3("LOCK    %d %s ok (already held) (afp)\n", pFile->h,
            locktypeName(locktype));
     return SQLITE_OK;
   }
@@ -24104,7 +24021,8 @@ static int afpLock(sqlite3_file *id, int locktype){
   ** operating system calls for the specified lock.
   */
   if( locktype==SHARED_LOCK ){
-    int lk, lrc1, lrc2, lrc1Errno;
+    int lk, lrc1, lrc2;
+    int lrc1Errno = 0;
     
     /* Now get the read-lock SHARED_LOCK */
     /* note that the quality of the randomness doesn't matter that much */
@@ -24180,7 +24098,7 @@ static int afpLock(sqlite3_file *id, int locktype){
   
 afp_end_lock:
   unixLeaveMutex();
-  OSTRACE4("LOCK    %d %s %s\n", pFile->h, locktypeName(locktype), 
+  OSTRACE4("LOCK    %d %s %s (afp)\n", pFile->h, locktypeName(locktype), 
          rc==SQLITE_OK ? "ok" : "failed");
   return rc;
 }
@@ -24198,7 +24116,7 @@ static int afpUnlock(sqlite3_file *id, int locktype) {
   afpLockingContext *pCtx = (afpLockingContext *) pFile->lockingContext;
 
   assert( pFile );
-  OSTRACE5("UNLOCK  %d %d was %d pid=%d\n", pFile->h, locktype,
+  OSTRACE5("UNLOCK  %d %d was %d pid=%d (afp)\n", pFile->h, locktype,
          pFile->locktype, getpid());
 
   assert( locktype<=SHARED_LOCK );
@@ -24674,6 +24592,19 @@ static int unixTruncate(sqlite3_file *id, i64 nByte){
     ((unixFile*)id)->lastErrno = errno;
     return SQLITE_IOERR_TRUNCATE;
   }else{
+#ifndef NDEBUG
+    /* If we are doing a normal write to a database file (as opposed to
+    ** doing a hot-journal rollback or a write to some file other than a
+    ** normal database file) and we truncate the file to zero length,
+    ** that effectively updates the change counter.  This might happen
+    ** when restoring a database using the backup API from a zero-length
+    ** source.
+    */
+    if( ((unixFile*)id)->inNormalWrite && nByte==0 ){
+      ((unixFile*)id)->transCntrChng = 1;
+    }
+#endif
+
     return SQLITE_OK;
   }
 }
@@ -25352,16 +25283,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 *pO;
-    struct unixFileId id;
-    id.dev = sStat.st_dev;
-    id.ino = sStat.st_ino;
+    struct unixOpenCnt *pOpen;
 
     unixEnterMutex();
-    for(pO=openList; pO && memcmp(&id, &pO->fileId, sizeof(id)); pO=pO->pNext);
-    if( pO ){
+    pOpen = openList;
+    while( pOpen && (pOpen->fileId.dev!=sStat.st_dev
+                     || pOpen->fileId.ino!=sStat.st_ino) ){
+       pOpen = pOpen->pNext;
+    }
+    if( pOpen ){
       UnixUnusedFd **pp;
-      for(pp=&pO->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
+      for(pp=&pOpen->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
       pUnused = *pp;
       if( pUnused ){
         *pp = pUnused->pNext;
@@ -26221,7 +26153,7 @@ static int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){
 # ifdef _CS_DARWIN_USER_TEMP_DIR
   {
     confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen);
-    len = strlcat(lPath, "sqliteplocks", maxLen);
+    len = strlcat(lPath, "sqliteplocks", maxLen);    
     if( mkdir(lPath, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){
       /* if mkdir fails, handle as lock file creation failure */
 #  ifdef SQLITE_DEBUG
@@ -27031,8 +26963,6 @@ SQLITE_API int sqlite3_os_end(void){
 **
 ** This file should be #included by the os_*.c files only.  It is not a
 ** general purpose header file.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _OS_COMMON_H_
 #define _OS_COMMON_H_
@@ -27093,8 +27023,6 @@ SQLITE_PRIVATE int sqlite3OSTrace = 0;
 **
 ** This file contains inline asm code for retrieving "high-performance"
 ** counters for x86 class CPUs.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _HWTIME_H_
 #define _HWTIME_H_
@@ -27249,7 +27177,7 @@ SQLITE_API int sqlite3_open_file_count = 0;
 */
 #if SQLITE_OS_WINCE
 # define AreFileApisANSI() 1
-# define GetDiskFreeSpaceW() 0
+# define FormatMessageW(a,b,c,d,e,f,g) 0
 #endif
 
 /*
@@ -28423,27 +28351,59 @@ static int getTempname(int nBuf, char *zBuf){
 ** otherwise (if the message was truncated).
 */
 static int getLastErrorMsg(int nBuf, char *zBuf){
-  DWORD error = GetLastError();
-
-#if SQLITE_OS_WINCE
-  sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error);
-#else
   /* FormatMessage returns 0 on failure.  Otherwise it
   ** returns the number of TCHARs written to the output
   ** buffer, excluding the terminating null char.
   */
-  if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM,
-                      NULL,
-                      error,
-                      0,
-                      zBuf,
-                      nBuf-1,
-                      0))
-  {
+  DWORD error = GetLastError();
+  DWORD dwLen = 0;
+  char *zOut = 0;
+
+  if( isNT() ){
+    WCHAR *zTempWide = NULL;
+    dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+                           NULL,
+                           error,
+                           0,
+                           (LPWSTR) &zTempWide,
+                           0,
+                           0);
+    if( dwLen > 0 ){
+      /* allocate a buffer and convert to UTF8 */
+      zOut = unicodeToUtf8(zTempWide);
+      /* free the system buffer allocated by FormatMessage */
+      LocalFree(zTempWide);
+    }
+/* 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.
+*/
+#if SQLITE_OS_WINCE==0
+  }else{
+    char *zTemp = NULL;
+    dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+                           NULL,
+                           error,
+                           0,
+                           (LPSTR) &zTemp,
+                           0,
+                           0);
+    if( dwLen > 0 ){
+      /* allocate a buffer and convert to UTF8 */
+      zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
+      /* free the system buffer allocated by FormatMessage */
+      LocalFree(zTemp);
+    }
+#endif
+  }
+  if( 0 == dwLen ){
     sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error);
+  }else{
+    /* copy a maximum of nBuf chars to output buffer */
+    sqlite3_snprintf(nBuf, zBuf, "%s", zOut);
+    /* free the UTF8 buffer */
+    free(zOut);
   }
-#endif
-
   return 0;
 }
 
@@ -28811,14 +28771,14 @@ static int getSectorSize(
                                   &dwDummy);
       }else{
         /* trim path to just drive reference */
-        CHAR *p = (CHAR *)zConverted;
+        char *p = (char *)zConverted;
         for(;*p;p++){
           if( *p == '\\' ){
             *p = '\0';
             break;
           }
         }
-        dwRet = GetDiskFreeSpaceA((CHAR*)zConverted,
+        dwRet = GetDiskFreeSpaceA((char*)zConverted,
                                   &dwDummy,
                                   &bytesPerSector,
                                   &dwDummy,
@@ -29104,8 +29064,6 @@ SQLITE_API int sqlite3_os_end(void){
 ** Bitvec object is the number of pages in the database file at the
 ** start of a transaction, and is thus usually less than a few thousand,
 ** but can be as large as 2 billion for a really big database.
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /* Size of the Bitvec structure in bytes. */
@@ -29493,8 +29451,6 @@ bitvec_end:
 **
 *************************************************************************
 ** This file implements that page cache.
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -30076,8 +30032,6 @@ SQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHd
 ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.
 ** If the default page cache implementation is overriden, then neither of
 ** these two features are available.
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -30727,15 +30681,7 @@ static void pcache1Rekey(
   pPage->iKey = iNew;
   pPage->pNext = pCache->apHash[h];
   pCache->apHash[h] = pPage;
-
-  /* The xRekey() interface is only used to move pages earlier in the
-  ** database file (in order to move all free pages to the end of the
-  ** file where they can be truncated off.)  Hence, it is not possible
-  ** for the new page number to be greater than the largest previously
-  ** fetched page.  But we retain the following test in case xRekey()
-  ** begins to be used in different ways in the future.
-  */
-  if( NEVER(iNew>pCache->iMaxKey) ){
+  if( iNew>pCache->iMaxKey ){
     pCache->iMaxKey = iNew;
   }
 
@@ -30911,8 +30857,6 @@ SQLITE_PRIVATE void sqlite3PcacheStats(
 **
 ** There is an added cost of O(N) when switching between TEST and
 ** SMALLEST primitives.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -31295,8 +31239,6 @@ SQLITE_PRIVATE int sqlite3RowSetTest(RowSet *pRowSet, u8 iBatch, sqlite3_int64 i
 ** locking to prevent two processes from writing the same database
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef SQLITE_OMIT_DISKIO
 
@@ -32190,10 +32132,10 @@ static int readJournalHdr(
 
     /* 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, and not greater than their 
+    ** of two greater than or equal to 512 or 32, and not greater than their 
     ** respective compile time maximum limits.
     */
-    if( iPageSize<512                  || iSectorSize<512
+    if( iPageSize<512                  || iSectorSize<32
      || iPageSize>SQLITE_MAX_PAGE_SIZE || iSectorSize>MAX_SECTOR_SIZE
      || ((iPageSize-1)&iPageSize)!=0   || ((iSectorSize-1)&iSectorSize)!=0 
     ){
@@ -32426,6 +32368,7 @@ static void pager_unlock(Pager *pPager){
 
     pPager->changeCountDone = 0;
     pPager->state = PAGER_UNLOCK;
+    pPager->dbModified = 0;
   }
 }
 
@@ -32700,7 +32643,7 @@ static int pager_playback_one_page(
   PgHdr *pPg;                   /* An existing page in the cache */
   Pgno pgno;                    /* The page number of a page in journal */
   u32 cksum;                    /* Checksum used for sanity checking */
-  u8 *aData;                    /* Temporary storage for the page */
+  char *aData;                  /* Temporary storage for the page */
   sqlite3_file *jfd;            /* The file descriptor for the journal file */
 
   assert( (isMainJrnl&~1)==0 );      /* isMainJrnl is 0 or 1 */
@@ -32708,7 +32651,7 @@ static int pager_playback_one_page(
   assert( isMainJrnl || pDone );     /* pDone always used on sub-journals */
   assert( isSavepnt || pDone==0 );   /* pDone never used on non-savepoint */
 
-  aData = (u8*)pPager->pTmpSpace;
+  aData = pPager->pTmpSpace;
   assert( aData );         /* Temp storage must have already been allocated */
 
   /* Read the page number and page data from the journal or sub-journal
@@ -32717,7 +32660,7 @@ static int pager_playback_one_page(
   jfd = isMainJrnl ? pPager->jfd : pPager->sjfd;
   rc = read32bits(jfd, *pOffset, &pgno);
   if( rc!=SQLITE_OK ) return rc;
-  rc = sqlite3OsRead(jfd, aData, pPager->pageSize, (*pOffset)+4);
+  rc = sqlite3OsRead(jfd, (u8*)aData, pPager->pageSize, (*pOffset)+4);
   if( rc!=SQLITE_OK ) return rc;
   *pOffset += pPager->pageSize + 4 + isMainJrnl*4;
 
@@ -32736,7 +32679,7 @@ static int pager_playback_one_page(
   if( isMainJrnl ){
     rc = read32bits(jfd, (*pOffset)-4, &cksum);
     if( rc ) return rc;
-    if( !isSavepnt && pager_cksum(pPager, aData)!=cksum ){
+    if( !isSavepnt && pager_cksum(pPager, (u8*)aData)!=cksum ){
       return SQLITE_DONE;
     }
   }
@@ -32782,8 +32725,8 @@ static int pager_playback_one_page(
   pPg = pager_lookup(pPager, pgno);
   assert( pPg || !MEMDB );
   PAGERTRACE(("PLAYBACK %d page %d hash(%08x) %s\n",
-               PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, aData),
-               (isMainJrnl?"main-journal":"sub-journal")
+           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))
@@ -32791,14 +32734,14 @@ static int pager_playback_one_page(
    && !isUnsync
   ){
     i64 ofst = (pgno-1)*(i64)pPager->pageSize;
-    rc = sqlite3OsWrite(pPager->fd, aData, pPager->pageSize, ofst);
+    rc = sqlite3OsWrite(pPager->fd, (u8*)aData, pPager->pageSize, ofst);
     if( pgno>pPager->dbFileSize ){
       pPager->dbFileSize = pgno;
     }
     if( pPager->pBackup ){
       CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM);
-      sqlite3BackupUpdate(pPager->pBackup, pgno, aData);
-      CODEC1(pPager, aData, pgno, 0, rc=SQLITE_NOMEM);
+      sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData);
+      CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM, aData);
     }
   }else if( !isMainJrnl && pPg==0 ){
     /* If this is a rollback of a savepoint and data was not written to
@@ -32833,7 +32776,7 @@ static int pager_playback_one_page(
     */
     void *pData;
     pData = pPg->pData;
-    memcpy(pData, aData, pPager->pageSize);
+    memcpy(pData, (u8*)aData, pPager->pageSize);
     pPager->xReiniter(pPg);
     if( isMainJrnl && (!isSavepnt || *pOffset<=pPager->journalHdr) ){
       /* If the contents of this page were just restored from the main 
@@ -33058,8 +33001,8 @@ static int pager_truncate(Pager *pPager, Pgno nPage){
 ** For temporary files the effective sector size is always 512 bytes.
 **
 ** Otherwise, for non-temporary files, the effective sector size is
-** the value returned by the xSectorSize() method rounded up to 512 if
-** it is less than 512, or rounded down to MAX_SECTOR_SIZE if it
+** the value returned by the xSectorSize() method rounded up to 32 if
+** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it
 ** is greater than MAX_SECTOR_SIZE.
 */
 static void setSectorSize(Pager *pPager){
@@ -33072,7 +33015,7 @@ static void setSectorSize(Pager *pPager){
     */
     pPager->sectorSize = sqlite3OsSectorSize(pPager->fd);
   }
-  if( pPager->sectorSize<512 ){
+  if( pPager->sectorSize<32 ){
     pPager->sectorSize = 512;
   }
   if( pPager->sectorSize>MAX_SECTOR_SIZE ){
@@ -33097,21 +33040,15 @@ static void setSectorSize(Pager *pPager){
 **       database to during a rollback.
 **  (5)  4 byte big-endian integer which is the sector size.  The header
 **       is this many bytes in size.
-**  (6)  4 byte big-endian integer which is the page case.
-**  (7)  4 byte integer which is the number of bytes in the master journal
-**       name.  The value may be zero (indicate that there is no master
-**       journal.)
-**  (8)  N bytes of the master journal name.  The name will be nul-terminated
-**       and might be shorter than the value read from (5).  If the first byte
-**       of the name is \000 then there is no master journal.  The master
-**       journal name is stored in UTF-8.
-**  (9)  Zero or more pages instances, each as follows:
+**  (6)  4 byte big-endian integer which is the page size.
+**  (7)  zero padding out to the next sector size.
+**  (8)  Zero or more pages instances, each as follows:
 **        +  4 byte page number.
 **        +  pPager->pageSize bytes of data.
 **        +  4 byte checksum
 **
-** When we speak of the journal header, we mean the first 8 items above.
-** Each entry in the journal is an instance of the 9th item.
+** When we speak of the journal header, we mean the first 7 items above.
+** Each entry in the journal is an instance of the 8th item.
 **
 ** Call the value from the second bullet "nRec".  nRec is the number of
 ** valid page entries in the journal.  In most cases, you can compute the
@@ -33808,8 +33745,11 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){
   assert( PAGER_RESERVED==RESERVED_LOCK );
   assert( PAGER_EXCLUSIVE==EXCLUSIVE_LOCK );
 
-  /* If the file is currently unlocked then the size must be unknown */
+  /* 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
@@ -34156,7 +34096,9 @@ static int pager_write_pagelist(PgHdr *pList){
     ** any such pages to the file.
     **
     ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag
-    ** set (set by sqlite3PagerDontWrite()).
+    ** set (set by sqlite3PagerDontWrite()).  Note that if compiled with
+    ** SQLITE_SECURE_DELETE the PGHDR_DONT_WRITE bit is never set and so
+    ** the second test is always true.
     */
     if( pgno<=pPager->dbSize && 0==(pList->flags&PGHDR_DONT_WRITE) ){
       i64 offset = (pgno-1)*(i64)pPager->pageSize;   /* Offset to write */
@@ -35121,7 +35063,7 @@ SQLITE_PRIVATE int sqlite3PagerAcquire(
       goto pager_acquire_err;
     }
 
-    if( nMax<(int)pgno || MEMDB || noContent ){
+    if( MEMDB || nMax<(int)pgno || noContent ){
       if( pgno>pPager->mxPgno ){
 	rc = SQLITE_FULL;
 	goto pager_acquire_err;
@@ -35141,9 +35083,8 @@ SQLITE_PRIVATE int sqlite3PagerAcquire(
         TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno);
         testcase( rc==SQLITE_NOMEM );
         sqlite3EndBenignMalloc();
-      }else{
-        memset(pPg->pData, 0, pPager->pageSize);
       }
+      memset(pPg->pData, 0, pPager->pageSize);
       IOTRACE(("ZERO %p %d\n", pPager, pgno));
     }else{
       assert( pPg->pPager==pPager );
@@ -35665,6 +35606,7 @@ SQLITE_PRIVATE int sqlite3PagerIswriteable(DbPage *pPg){
 }
 #endif
 
+#ifndef SQLITE_SECURE_DELETE
 /*
 ** A call to this routine tells the pager that it is not necessary to
 ** write the information on page pPg back to the disk, even though
@@ -35690,6 +35632,7 @@ SQLITE_PRIVATE void sqlite3PagerDontWrite(PgHdr *pPg){
 #endif
   }
 }
+#endif /* !defined(SQLITE_SECURE_DELETE) */
 
 /*
 ** This routine is called to increment the value of the database file 
@@ -35729,7 +35672,7 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){
 #endif
 
   assert( pPager->state>=PAGER_RESERVED );
-  if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){
+  if( !pPager->changeCountDone && pPager->dbSize>0 ){
     PgHdr *pPgHdr;                /* Reference to page 1 */
     u32 change_counter;           /* Initial value of change-counter field */
 
@@ -36337,7 +36280,7 @@ static void sqlite3PagerSetCodec(
   void *pCodec
 ){
   if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);
-  pPager->xCodec = xCodec;
+  pPager->xCodec = pPager->memDb ? 0 : xCodec;
   pPager->xCodecSizeChng = xCodecSizeChng;
   pPager->xCodecFree = xCodecFree;
   pPager->pCodec = pCodec;
@@ -36382,6 +36325,14 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
 
   assert( pPg->nRef>0 );
 
+  /* In order to be able to rollback, an in-memory database must journal
+  ** the page we are moving from.
+  */
+  if( MEMDB ){
+    rc = sqlite3PagerWrite(pPg);
+    if( rc ) return rc;
+  }
+
   /* If the page being moved is dirty and has not been saved by the latest
   ** savepoint, then save the current contents of the page into the 
   ** sub-journal now. This is required to handle the following scenario:
@@ -36400,7 +36351,7 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
   ** one or more savepoint bitvecs. This is the reason this function
   ** may return SQLITE_NOMEM.
   */
-  if( pPg->flags&PGHDR_DIRTY 
+  if( pPg->flags&PGHDR_DIRTY
    && subjRequiresPage(pPg)
    && SQLITE_OK!=(rc = subjournalPage(pPg))
   ){
@@ -36435,7 +36386,14 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
   assert( !pPgOld || pPgOld->nRef==1 );
   if( pPgOld ){
     pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);
-    sqlite3PcacheDrop(pPgOld);
+    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);
+    }
   }
 
   origPgno = pPg->pgno;
@@ -36480,18 +36438,12 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
 
   /*
   ** For an in-memory database, make sure the original page continues
-  ** to exist, in case the transaction needs to roll back.  We allocate
-  ** the page now, instead of at rollback, because we can better deal
-  ** with an out-of-memory error now.  Ticket #3761.
+  ** to exist, in case the transaction needs to roll back.  Use pPgOld
+  ** as the original page since it has already been allocated.
   */
   if( MEMDB ){
-    DbPage *pNew;
-    rc = sqlite3PagerAcquire(pPager, origPgno, &pNew, 1);
-    if( rc!=SQLITE_OK ){
-      sqlite3PcacheMove(pPg, origPgno);
-      return rc;
-    }
-    sqlite3PagerUnref(pNew);
+    sqlite3PcacheMove(pPgOld, origPgno);
+    sqlite3PagerUnref(pPgOld);
   }
 
   return SQLITE_OK;
@@ -36618,8 +36570,6 @@ SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
 **
 *************************************************************************
 **
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
-**
 ** This file contains code used to implement mutexes on Btree objects.
 ** This code really belongs in btree.c.  But btree.c is getting too
 ** big and we want to break it down some.  This packaged seemed like
@@ -36638,8 +36588,6 @@ SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
-**
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
 **
@@ -36677,9 +36625,9 @@ 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 anything between 512 and 65536.
-** Each page can be either a btree page, a freelist page or an overflow
-** page.
+** "no such page".  The page size can be any power of 2 between 512 and 32768.
+** Each page can be either a btree page, a freelist page, an overflow
+** page, or a pointer-map page.
 **
 ** The first page is always a btree page.  The first 100 bytes of the first
 ** page contain a special header (the "file header") that describes the file.
@@ -36957,8 +36905,8 @@ struct BtLock {
 ** this structure.
 **
 ** For some database files, the same underlying database cache might be 
-** shared between multiple connections.  In that case, each contection
-** has it own pointer to this object.  But each instance of this object
+** shared between multiple connections.  In that case, each connection
+** has it own instance of this object.  But each instance of this object
 ** points to the same BtShared object.  The database cache and the
 ** schema associated with the database file are all contained within
 ** the BtShared object.
@@ -37099,7 +37047,7 @@ struct CellInfo {
 ** The entry is identified by its MemPage and the index in
 ** MemPage.aCell[] of the entry.
 **
-** When a single database file can shared by two more database connections,
+** A single database file can shared by two more database connections,
 ** but cursors cannot be shared.  Each cursor is associated with a
 ** particular database connection identified BtCursor.pBtree.db.
 **
@@ -37623,8 +37571,6 @@ SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
-**
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
 ** Including a description of file format and an overview of operation.
@@ -37703,22 +37649,24 @@ SQLITE_API int sqlite3_enable_shared_cache(int enable){
 
 #ifdef SQLITE_DEBUG
 /*
-** This function is only used as part of an assert() statement. It checks
-** that connection p holds the required locks to read or write to the 
-** b-tree with root page iRoot. If so, true is returned. Otherwise, false. 
-** For example, when writing to a table b-tree with root-page iRoot via 
+**** This function is only used as part of an assert() statement. ***
+**
+** Check to see if pBtree holds the required locks to read or write to the 
+** table with root page iRoot.   Return 1 if it does and 0 if not.
+**
+** For example, when writing to a table with root-page iRoot via 
 ** Btree connection pBtree:
 **
 **    assert( hasSharedCacheTableLock(pBtree, iRoot, 0, WRITE_LOCK) );
 **
-** When writing to an index b-tree that resides in a sharable database, the 
+** When writing to an index that resides in a sharable database, the 
 ** caller should have first obtained a lock specifying the root page of
-** the corresponding table b-tree. This makes things a bit more complicated,
-** as this module treats each b-tree as a separate structure. To determine
-** the table b-tree corresponding to the index b-tree being written, this
+** the corresponding table. This makes things a bit more complicated,
+** as this module treats each table as a separate structure. To determine
+** the table corresponding to the index being written, this
 ** function has to search through the database schema.
 **
-** Instead of a lock on the b-tree rooted at page iRoot, the caller may
+** Instead of a lock on the table/index rooted at page iRoot, the caller may
 ** hold a write-lock on the schema table (root page 1). This is also
 ** acceptable.
 */
@@ -37732,20 +37680,25 @@ static int hasSharedCacheTableLock(
   Pgno iTab = 0;
   BtLock *pLock;
 
-  /* If this b-tree database is not shareable, or if the client is reading
+  /* If this database is not shareable, or if the client is reading
   ** and has the read-uncommitted flag set, then no lock is required. 
-  ** In these cases return true immediately.  If the client is reading 
-  ** or writing an index b-tree, but the schema is not loaded, then return
-  ** true also. In this case the lock is required, but it is too difficult
-  ** to check if the client actually holds it. This doesn't happen very
-  ** often.  */
+  ** Return true immediately.
+  */
   if( (pBtree->sharable==0)
    || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommitted))
-   || (isIndex && (!pSchema || (pSchema->flags&DB_SchemaLoaded)==0 ))
   ){
     return 1;
   }
 
+  /* If the client is reading  or writing an index and the schema is
+  ** not loaded, then it is too difficult to actually check to see if
+  ** the correct locks are held.  So do not bother - just return true.
+  ** This case does not come up very often anyhow.
+  */
+  if( isIndex && (!pSchema || (pSchema->flags&DB_SchemaLoaded)==0) ){
+    return 1;
+  }
+
   /* Figure out the root-page that the lock should be held on. For table
   ** b-trees, this is just the root page of the b-tree being read or
   ** written. For index b-trees, it is the root page of the associated
@@ -37777,14 +37730,24 @@ static int hasSharedCacheTableLock(
   /* Failed to find the required lock. */
   return 0;
 }
+#endif /* SQLITE_DEBUG */
 
+#ifdef SQLITE_DEBUG
 /*
-** This function is also used as part of assert() statements only. It 
-** returns true if there exist one or more cursors open on the table 
-** with root page iRoot that do not belong to either connection pBtree 
-** or some other connection that has the read-uncommitted flag set.
+**** This function may be used as part of assert() statements only. ****
+**
+** Return true if it would be illegal for pBtree to write into the
+** table or index rooted at iRoot because other shared connections are
+** simultaneously reading that same table or index.
 **
-** For example, before writing to page iRoot:
+** It is illegal for pBtree to write if some other Btree object that
+** shares the same BtShared object is currently reading or writing
+** the iRoot table.  Except, if the other Btree object has the
+** read-uncommitted flag set, then it is OK for the other object to
+** have a read cursor.
+**
+** For example, before writing to any part of the table or index
+** rooted at page iRoot, one should call:
 **
 **    assert( !hasReadConflicts(pBtree, iRoot) );
 */
@@ -37803,7 +37766,7 @@ static int hasReadConflicts(Btree *pBtree, Pgno iRoot){
 #endif    /* #ifdef SQLITE_DEBUG */
 
 /*
-** Query to see if btree handle p may obtain a lock of type eLock 
+** Query to see if Btree handle p may obtain a lock of type eLock 
 ** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return
 ** SQLITE_OK if the lock may be obtained (by calling
 ** setSharedCacheTableLock()), or SQLITE_LOCKED if not.
@@ -37824,7 +37787,7 @@ static int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){
   assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );
   assert( eLock==READ_LOCK || pBt->inTransaction==TRANS_WRITE );
   
-  /* This is a no-op if the shared-cache is not enabled */
+  /* This routine is a no-op if the shared-cache is not enabled */
   if( !p->sharable ){
     return SQLITE_OK;
   }
@@ -37870,10 +37833,10 @@ static int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){
 **
 ** This function assumes the following:
 **
-**   (a) The specified b-tree connection handle is connected to a sharable
-**       b-tree database (one with the BtShared.sharable) flag set, and
+**   (a) The specified Btree object p is connected to a sharable
+**       database (one with the BtShared.sharable flag set), and
 **
-**   (b) No other b-tree connection handle holds a lock that conflicts
+**   (b) No other Btree objects hold a lock that conflicts
 **       with the requested lock (i.e. querySharedCacheTableLock() has
 **       already been called and returned SQLITE_OK).
 **
@@ -37938,9 +37901,9 @@ static int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){
 #ifndef SQLITE_OMIT_SHARED_CACHE
 /*
 ** Release all the table locks (locks obtained via calls to
-** the setSharedCacheTableLock() procedure) held by Btree handle p.
+** the setSharedCacheTableLock() procedure) held by Btree object p.
 **
-** This function assumes that handle p has an open read or write 
+** This function assumes that Btree p has an open read or write 
 ** transaction. If it does not, then the BtShared.isPending variable
 ** may be incorrectly cleared.
 */
@@ -37973,7 +37936,7 @@ static void clearAllSharedCacheTableLocks(Btree *p){
     pBt->isExclusive = 0;
     pBt->isPending = 0;
   }else if( pBt->nTransaction==2 ){
-    /* This function is called when connection p is concluding its 
+    /* This function is called when Btree p is concluding its 
     ** transaction. If there currently exists a writer, and p is not
     ** that writer, then the number of locks held by connections other
     ** than the writer must be about to drop to zero. In this case
@@ -37987,7 +37950,7 @@ static void clearAllSharedCacheTableLocks(Btree *p){
 }
 
 /*
-** This function changes all write-locks held by connection p to read-locks.
+** This function changes all write-locks held by Btree p into read-locks.
 */
 static void downgradeAllSharedCacheTableLocks(Btree *p){
   BtShared *pBt = p->pBt;
@@ -38008,9 +37971,11 @@ static void downgradeAllSharedCacheTableLocks(Btree *p){
 static void releasePage(MemPage *pPage);  /* Forward reference */
 
 /*
-** Verify that the cursor holds a mutex on the BtShared
+***** This routine is used inside of assert() only ****
+**
+** Verify that the cursor holds the mutex on its BtShared
 */
-#ifndef NDEBUG
+#ifdef SQLITE_DEBUG
 static int cursorHoldsMutex(BtCursor *p){
   return sqlite3_mutex_held(p->pBt->mutex);
 }
@@ -38041,7 +38006,7 @@ static void invalidateAllOverflowCache(BtShared *pBt){
 
 /*
 ** This function is called before modifying the contents of a table
-** b-tree to invalidate any incrblob cursors that are open on the
+** to invalidate any incrblob cursors that are open on the
 ** row or one of the rows being modified.
 **
 ** If argument isClearTable is true, then the entire contents of the
@@ -38050,7 +38015,7 @@ static void invalidateAllOverflowCache(BtShared *pBt){
 **
 ** Otherwise, if argument isClearTable is false, then the row with
 ** rowid iRow is being replaced or deleted. In this case invalidate
-** only those incrblob cursors open on this specific row.
+** only those incrblob cursors open on that specific row.
 */
 static void invalidateIncrblobCursors(
   Btree *pBtree,          /* The database file to check */
@@ -38068,10 +38033,11 @@ static void invalidateIncrblobCursors(
 }
 
 #else
+  /* Stub functions when INCRBLOB is omitted */
   #define invalidateOverflowCache(x)
   #define invalidateAllOverflowCache(x)
   #define invalidateIncrblobCursors(x,y,z)
-#endif
+#endif /* SQLITE_OMIT_INCRBLOB */
 
 /*
 ** Set bit pgno of the BtShared.pHasContent bitvec. This is called 
@@ -38104,7 +38070,7 @@ static void invalidateIncrblobCursors(
 ** The solution is the BtShared.pHasContent bitvec. Whenever a page is 
 ** moved to become a free-list leaf page, the corresponding bit is
 ** set in the bitvec. Whenever a leaf page is extracted from the free-list,
-** optimization 2 above is ommitted if the corresponding bit is already
+** optimization 2 above is omitted if the corresponding bit is already
 ** set in BtShared.pHasContent. The contents of the bitvec are cleared
 ** at the end of every transaction.
 */
@@ -38200,8 +38166,8 @@ static int saveCursorPosition(BtCursor *pCur){
 }
 
 /*
-** Save the positions of all cursors except pExcept open on the table 
-** with root-page iRoot. Usually, this is called just before cursor
+** Save the positions of all cursors (except pExcept) that are open on
+** the table  with root-page iRoot. Usually, this is called just before cursor
 ** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()).
 */
 static int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){
@@ -38606,7 +38572,10 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
   assert( nSize==debuginfo.nSize );
   return (u16)nSize;
 }
-#ifndef NDEBUG
+
+#ifdef SQLITE_DEBUG
+/* This variation on cellSizePtr() is used inside of assert() statements
+** only. */
 static u16 cellSize(MemPage *pPage, int iCell){
   return cellSizePtr(pPage, findCell(pPage, iCell));
 }
@@ -38735,6 +38704,7 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
   int top;                             /* First byte of cell content area */
   int gap;        /* First byte of gap between cell pointers and cell content */
   int rc;         /* Integer return code */
+  int usableSize; /* Usable size of the page */
   
   assert( sqlite3PagerIswriteable(pPage->pDbPage) );
   assert( pPage->pBt );
@@ -38742,7 +38712,8 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
   assert( nByte>=0 );  /* Minimum cell size is 4 */
   assert( pPage->nFree>=nByte );
   assert( pPage->nOverflow==0 );
-  assert( nByte<pPage->pBt->usableSize-8 );
+  usableSize = pPage->pBt->usableSize;
+  assert( nByte < usableSize-8 );
 
   nFrag = data[hdr+7];
   assert( pPage->cellOffset == hdr + 12 - 4*pPage->leaf );
@@ -38765,7 +38736,11 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
     */
     int pc, addr;
     for(addr=hdr+1; (pc = get2byte(&data[addr]))>0; addr=pc){
-      int size = get2byte(&data[pc+2]);     /* Size of free slot */
+      int size;            /* Size of the free slot */
+      if( pc>usableSize-4 || pc<addr+4 ){
+        return SQLITE_CORRUPT_BKPT;
+      }
+      size = get2byte(&data[pc+2]);
       if( size>=nByte ){
         int x = size - nByte;
         testcase( x==4 );
@@ -38775,6 +38750,8 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
           ** fragmented bytes within the page. */
           memcpy(&data[addr], &data[pc], 2);
           data[hdr+7] = (u8)(nFrag + x);
+        }else if( size+pc > usableSize ){
+          return SQLITE_CORRUPT_BKPT;
         }else{
           /* The slot remains on the free-list. Reduce its size to account
           ** for the portion used by the new allocation. */
@@ -39067,7 +39044,9 @@ static void zeroPage(MemPage *pPage, int flags){
   assert( sqlite3PagerGetData(pPage->pDbPage) == data );
   assert( sqlite3PagerIswriteable(pPage->pDbPage) );
   assert( sqlite3_mutex_held(pBt->mutex) );
-  /*memset(&data[hdr], 0, pBt->usableSize - hdr);*/
+#ifdef SQLITE_SECURE_DELETE
+  memset(&data[hdr], 0, pBt->usableSize - hdr);
+#endif
   data[hdr] = (char)flags;
   first = hdr + 8 + 4*((flags&PTF_LEAF)==0 ?1:0);
   memset(&data[hdr+1], 0, 4);
@@ -39196,7 +39175,6 @@ static int getAndInitPage(
 */
 static void releasePage(MemPage *pPage){
   if( pPage ){
-    assert( pPage->nOverflow==0 || sqlite3PagerPageRefcount(pPage->pDbPage)>1 );
     assert( pPage->aData );
     assert( pPage->pBt );
     assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
@@ -39936,11 +39914,8 @@ static int newDatabase(BtShared *pBt){
   int nPage;
 
   assert( sqlite3_mutex_held(pBt->mutex) );
-  /* The database size has already been measured and cached, so failure
-  ** is impossible here.  If the original size measurement failed, then
-  ** processing aborts before entering this routine. */
   rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
-  if( NEVER(rc!=SQLITE_OK) || nPage>0 ){
+  if( rc!=SQLITE_OK || nPage>0 ){
     return rc;
   }
   pP1 = pBt->pPage1;
@@ -40578,18 +40553,13 @@ SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){
 */
 static void btreeEndTransaction(Btree *p){
   BtShared *pBt = p->pBt;
-  BtCursor *pCsr;
   assert( sqlite3BtreeHoldsMutex(p) );
 
-  /* Search for a cursor held open by this b-tree connection. If one exists,
-  ** then the transaction will be downgraded to a read-only transaction
-  ** instead of actually concluded. A subsequent call to CommitPhaseTwo() 
-  ** or Rollback() will finish the transaction and unlock the database.  */
-  for(pCsr=pBt->pCursor; pCsr && pCsr->pBtree!=p; pCsr=pCsr->pNext);
-  assert( pCsr==0 || p->inTrans>TRANS_NONE );
-
   btreeClearHasContent(pBt);
-  if( pCsr ){
+  if( p->inTrans>TRANS_NONE && p->db->activeVdbeCnt>1 ){
+    /* If there are other active statements that belong to this database
+    ** handle, downgrade to a read-only transaction. The other statements
+    ** may still be reading from the database.  */
     downgradeAllSharedCacheTableLocks(p);
     p->inTrans = TRANS_READ;
   }else{
@@ -40875,8 +40845,8 @@ SQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){
 ** root page of a b-tree.  If it is not, then the cursor acquired
 ** will not work correctly.
 **
-** It is assumed that the sqlite3BtreeCursorSize() bytes of memory 
-** pointed to by pCur have been zeroed by the caller.
+** It is assumed that the sqlite3BtreeCursorZero() has been called
+** on pCur to initialize the memory space prior to invoking this routine.
 */
 static int btreeCursor(
   Btree *p,                              /* The btree */
@@ -40949,7 +40919,19 @@ SQLITE_PRIVATE int sqlite3BtreeCursor(
 ** this routine.
 */
 SQLITE_PRIVATE int sqlite3BtreeCursorSize(void){
-  return sizeof(BtCursor);
+  return ROUND8(sizeof(BtCursor));
+}
+
+/*
+** Initialize memory that will be converted into a BtCursor object.
+**
+** The simple approach here would be to memset() the entire object
+** to zero.  But it turns out that the apPage[] and aiIdx[] arrays
+** do not need to be zeroed and they are large, so we can save a lot
+** of run-time by skipping the initialization of those elements.
+*/
+SQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor *p){
+  memset(p, 0, offsetof(BtCursor, iPage));
 }
 
 /*
@@ -42881,8 +42863,13 @@ static void insertCell(
   assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
   assert( pPage->nCell<=MX_CELL(pPage->pBt) && MX_CELL(pPage->pBt)<=5460 );
   assert( pPage->nOverflow<=ArraySize(pPage->aOvfl) );
-  assert( sz==cellSizePtr(pPage, pCell) );
   assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+  /* The cell should normally be sized correctly.  However, when moving a
+  ** malformed cell from a leaf page to an interior page, if the cell size
+  ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size
+  ** might be less than 8 (leaf-size + pointer) on the interior node.  Hence
+  ** the term after the || in the following assert(). */
+  assert( sz==cellSizePtr(pPage, pCell) || (sz==8 && iChild>0) );
   if( pPage->nOverflow || sz+2>pPage->nFree ){
     if( pTemp ){
       memcpy(pTemp+nSkip, pCell+nSkip, sz-nSkip);
@@ -43161,7 +43148,7 @@ static void copyNodeContent(MemPage *pFrom, MemPage *pTo, int *pRC){
     u8 * const aTo = pTo->aData;
     int const iFromHdr = pFrom->hdrOffset;
     int const iToHdr = ((pTo->pgno==1) ? 100 : 0);
-    TESTONLY(int rc;)
+    int rc;
     int iData;
   
   
@@ -43175,11 +43162,16 @@ static void copyNodeContent(MemPage *pFrom, MemPage *pTo, int *pRC){
     memcpy(&aTo[iToHdr], &aFrom[iFromHdr], pFrom->cellOffset + 2*pFrom->nCell);
   
     /* Reinitialize page pTo so that the contents of the MemPage structure
-    ** match the new data. The initialization of pTo "cannot" fail, as the
-    ** data copied from pFrom is known to be valid.  */
+    ** match the new data. The initialization of pTo can actually fail under
+    ** fairly obscure circumstances, even though it is a copy of initialized 
+    ** page pFrom.
+    */
     pTo->isInit = 0;
-    TESTONLY(rc = ) btreeInitPage(pTo);
-    assert( rc==SQLITE_OK );
+    rc = btreeInitPage(pTo);
+    if( rc!=SQLITE_OK ){
+      *pRC = rc;
+      return;
+    }
   
     /* If this is an auto-vacuum database, update the pointer-map entries
     ** for any b-tree or overflow pages that pTo now contains the pointers to.
@@ -44049,7 +44041,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
 ){
   int rc;
   int loc = seekResult;          /* -1: before desired location  +1: after */
-  int szNew;
+  int szNew = 0;
   int idx;
   MemPage *pPage;
   Btree *p = pCur->pBtree;
@@ -44440,9 +44432,9 @@ SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){
 */
 static int clearDatabasePage(
   BtShared *pBt,           /* The BTree that contains the table */
-  Pgno pgno,            /* Page number to clear */
-  int freePageFlag,     /* Deallocate page if true */
-  int *pnChange
+  Pgno pgno,               /* Page number to clear */
+  int freePageFlag,        /* Deallocate page if true */
+  int *pnChange            /* Add number of Cells freed to this counter */
 ){
   MemPage *pPage;
   int rc;
@@ -45434,8 +45426,6 @@ SQLITE_PRIVATE void sqlite3BtreeCacheOverflow(BtCursor *pCur){
 *************************************************************************
 ** This file contains the implementation of the sqlite3_backup_XXX() 
 ** API functions and the related features.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /* Macro to find the minimum of two numeric values.
@@ -46068,8 +46058,6 @@ SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){
 ** stores a single value in the VDBE.  Mem is an opaque structure visible
 ** only within the VDBE.  Interface routines refer to a Mem using the
 ** name sqlite_value
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -46808,9 +46796,6 @@ SQLITE_PRIVATE int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const C
   int f1, f2;
   int combined_flags;
 
-  /* Interchange pMem1 and pMem2 if the collating sequence specifies
-  ** DESC order.
-  */
   f1 = pMem1->flags;
   f2 = pMem2->flags;
   combined_flags = f1|f2;
@@ -47061,7 +47046,7 @@ SQLITE_PRIVATE int sqlite3ValueFromExpr(
   }
   op = pExpr->op;
   if( op==TK_REGISTER ){
-    op = pExpr->op2;
+    op = pExpr->op2;  /* This only happens with SQLITE_ENABLE_STAT2 */
   }
 
   if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){
@@ -47105,6 +47090,9 @@ SQLITE_PRIVATE int sqlite3ValueFromExpr(
   }
 #endif
 
+  if( pVal ){
+    sqlite3VdbeMemStoreType(pVal);
+  }
   *ppVal = pVal;
   return SQLITE_OK;
 
@@ -47171,8 +47159,6 @@ SQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value *pVal, u8 enc){
 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)  Prior
 ** to version 2.8.7, all this code was combined into the vdbe.c source file.
 ** But that file was getting too big so this subroutines were split out.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -47209,13 +47195,14 @@ SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(sqlite3 *db){
 ** Remember the SQL string for a prepared statement.
 */
 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
+  assert( isPrepareV2==1 || isPrepareV2==0 );
   if( p==0 ) return;
 #ifdef SQLITE_OMIT_TRACE
   if( !isPrepareV2 ) return;
 #endif
   assert( p->zSql==0 );
   p->zSql = sqlite3DbStrNDup(p->db, z, n);
-  p->isPrepareV2 = isPrepareV2 ? 1 : 0;
+  p->isPrepareV2 = (u8)isPrepareV2;
 }
 
 /*
@@ -47353,6 +47340,22 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp4(
 }
 
 /*
+** Add an opcode that includes the p4 value as an integer.
+*/
+SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(
+  Vdbe *p,            /* Add the opcode to this VM */
+  int op,             /* The new opcode */
+  int p1,             /* The P1 operand */
+  int p2,             /* The P2 operand */
+  int p3,             /* The P3 operand */
+  int p4              /* The P4 operand as an integer */
+){
+  int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);
+  sqlite3VdbeChangeP4(p, addr, SQLITE_INT_TO_PTR(p4), P4_INT32);
+  return addr;
+}
+
+/*
 ** Create a new symbolic label for an instruction that has yet to be
 ** coded.  The symbolic label is really just a negative number.  The
 ** label can be used as the P2 value of an operation.  Later, when
@@ -47527,6 +47530,8 @@ SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
 ** Variable *pMaxFuncArgs is set to the maximum value of any P2 argument 
 ** to an OP_Function, OP_AggStep or OP_VFilter opcode. This is used by 
 ** sqlite3VdbeMakeReady() to size the Vdbe.apArg[] array.
+**
+** The Op.opflags field is set on all opcodes.
 */
 static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
   int i;
@@ -47537,15 +47542,14 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
   for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
     u8 opcode = pOp->opcode;
 
+    pOp->opflags = sqlite3OpcodeProperty[opcode];
     if( opcode==OP_Function || opcode==OP_AggStep ){
       if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
-#ifndef SQLITE_OMIT_VIRTUALTABLE
-    }else if( opcode==OP_VUpdate ){
-      if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
-#endif
     }else if( opcode==OP_Transaction && pOp->p2!=0 ){
       p->readOnly = 0;
 #ifndef SQLITE_OMIT_VIRTUALTABLE
+    }else if( opcode==OP_VUpdate ){
+      if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
     }else if( opcode==OP_VFilter ){
       int n;
       assert( p->nOp - i >= 3 );
@@ -47555,7 +47559,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
 #endif
     }
 
-    if( sqlite3VdbeOpcodeHasProperty(opcode, OPFLG_JUMP) && pOp->p2<0 ){
+    if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
       assert( -1-pOp->p2<p->nLabel );
       pOp->p2 = aLabel[-1-pOp->p2];
     }
@@ -47617,7 +47621,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp)
       VdbeOp *pOut = &p->aOp[i+addr];
       pOut->opcode = pIn->opcode;
       pOut->p1 = pIn->p1;
-      if( p2<0 && sqlite3VdbeOpcodeHasProperty(pOut->opcode, OPFLG_JUMP) ){
+      if( p2<0 && (sqlite3OpcodeProperty[pOut->opcode] & OPFLG_JUMP)!=0 ){
         pOut->p2 = addr + ADDR(p2);
       }else{
         pOut->p2 = p2;
@@ -48169,27 +48173,6 @@ SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame *p){
   sqlite3DbFree(p->v->db, p);
 }
 
-
-#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
-SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p){
-  int ii;
-  int nFree = 0;
-  assert( sqlite3_mutex_held(p->db->mutex) );
-  for(ii=1; ii<=p->nMem; ii++){
-    Mem *pMem = &p->aMem[ii];
-    if( pMem->flags & MEM_RowSet ){
-      sqlite3RowSetClear(pMem->u.pRowSet);
-    }
-    if( pMem->z && pMem->flags&MEM_Dyn ){
-      assert( !pMem->xDel );
-      nFree += sqlite3DbMallocSize(pMem->db, pMem->z);
-      sqlite3VdbeMemRelease(pMem);
-    }
-  }
-  return nFree;
-}
-#endif
-
 #ifndef SQLITE_OMIT_EXPLAIN
 /*
 ** Give a listing of the program in the virtual machine.
@@ -48202,18 +48185,21 @@ SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p){
 ** p->explain==2, only OP_Explain instructions are listed and these
 ** are shown in a different format.  p->explain==2 is used to implement
 ** EXPLAIN QUERY PLAN.
+**
+** When p->explain==1, first the main program is listed, then each of
+** the trigger subprograms are listed one by one.
 */
 SQLITE_PRIVATE int sqlite3VdbeList(
   Vdbe *p                   /* The VDBE */
 ){
-  int nRow;                            /* Total number of rows to return */
+  int nRow;                            /* Stop when row count reaches this */
   int nSub = 0;                        /* Number of sub-vdbes seen so far */
   SubProgram **apSub = 0;              /* Array of sub-vdbes */
-  Mem *pSub = 0;
-  sqlite3 *db = p->db;
-  int i;
-  int rc = SQLITE_OK;
-  Mem *pMem = p->pResultSet = &p->aMem[1];
+  Mem *pSub = 0;                       /* Memory cell hold array of subprogs */
+  sqlite3 *db = p->db;                 /* The database connection */
+  int i;                               /* Loop counter */
+  int rc = SQLITE_OK;                  /* Return code */
+  Mem *pMem = p->pResultSet = &p->aMem[1];  /* First Mem of result set */
 
   assert( p->explain );
   assert( p->magic==VDBE_MAGIC_RUN );
@@ -48233,12 +48219,24 @@ SQLITE_PRIVATE int sqlite3VdbeList(
     return SQLITE_ERROR;
   }
 
-  /* Figure out total number of rows that will be returned by this 
-  ** EXPLAIN program.  */
+  /* When the number of output rows reaches nRow, that means the
+  ** listing has finished and sqlite3_step() should return SQLITE_DONE.
+  ** nRow is the sum of the number of rows in the main program, plus
+  ** the sum of the number of rows in all trigger subprograms encountered
+  ** so far.  The nRow value will increase as new trigger subprograms are
+  ** encountered, but p->pc will eventually catch up to nRow.
+  */
   nRow = p->nOp;
   if( p->explain==1 ){
+    /* The first 8 memory cells are used for the result set.  So we will
+    ** commandeer the 9th cell to use as storage for an array of pointers
+    ** to trigger subprograms.  The VDBE is guaranteed to have at least 9
+    ** cells.  */
+    assert( p->nMem>9 );
     pSub = &p->aMem[9];
     if( pSub->flags&MEM_Blob ){
+      /* On the first call to sqlite3_step(), pSub will hold a NULL.  It is
+      ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */
       nSub = pSub->n/sizeof(Vdbe*);
       apSub = (SubProgram **)pSub->z;
     }
@@ -48261,8 +48259,12 @@ SQLITE_PRIVATE int sqlite3VdbeList(
     char *z;
     Op *pOp;
     if( i<p->nOp ){
+      /* The output line number is small enough that we are still in the
+      ** main program. */
       pOp = &p->aOp[i];
     }else{
+      /* We are currently listing subprograms.  Figure out which one and
+      ** pick up the appropriate opcode. */
       int j;
       i -= p->nOp;
       for(j=0; i>=apSub[j]->nOp; j++){
@@ -48284,6 +48286,11 @@ SQLITE_PRIVATE int sqlite3VdbeList(
       pMem->enc = SQLITE_UTF8;
       pMem++;
 
+      /* When an OP_Program opcode is encounter (the only opcode that has
+      ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms
+      ** kept in p->aMem[9].z to hold the new program - assuming this subprogram
+      ** has not already been seen.
+      */
       if( pOp->p4type==P4_SUBPROGRAM ){
         int nByte = (nSub+1)*sizeof(SubProgram*);
         int j;
@@ -48415,38 +48422,43 @@ SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe *p){
 #endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */
 
 /*
-** Allocate space from a fixed size buffer.  Make *pp point to the
-** allocated space.  (Note:  pp is a char* rather than a void** to
-** work around the pointer aliasing rules of C.)  *pp should initially
-** be zero.  If *pp is not zero, that means that the space has already
-** been allocated and this routine is a noop.
+** Allocate space from a fixed size buffer and return a pointer to
+** that space.  If insufficient space is available, return NULL.
+**
+** The pBuf parameter is the initial value of a pointer which will
+** receive the new memory.  pBuf is normally NULL.  If pBuf is not
+** NULL, it means that memory space has already been allocated and that
+** this routine should not allocate any new memory.  When pBuf is not
+** NULL simply return pBuf.  Only allocate new memory space when pBuf
+** is NULL.
 **
 ** nByte is the number of bytes of space needed.
 **
-** *ppFrom point to available space and pEnd points to the end of the
-** available space.
+** *ppFrom points to available space and pEnd points to the end of the
+** available space.  When space is allocated, *ppFrom is advanced past
+** the end of the allocated space.
 **
 ** *pnByte is a counter of the number of bytes of space that have failed
 ** to allocate.  If there is insufficient space in *ppFrom to satisfy the
 ** request, then increment *pnByte by the amount of the request.
 */
-static void allocSpace(
-  char *pp,            /* IN/OUT: Set *pp to point to allocated buffer */
+static void *allocSpace(
+  void *pBuf,          /* Where return pointer will be stored */
   int nByte,           /* Number of bytes to allocate */
   u8 **ppFrom,         /* IN/OUT: Allocate from *ppFrom */
   u8 *pEnd,            /* Pointer to 1 byte past the end of *ppFrom buffer */
   int *pnByte          /* If allocation cannot be made, increment *pnByte */
 ){
   assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) );
-  if( (*(void**)pp)==0 ){
-    nByte = ROUND8(nByte);
-    if( &(*ppFrom)[nByte] <= pEnd ){
-      *(void**)pp = (void *)*ppFrom;
-      *ppFrom += nByte;
-    }else{
-      *pnByte += nByte;
-    }
+  if( pBuf ) return pBuf;
+  nByte = ROUND8(nByte);
+  if( &(*ppFrom)[nByte] <= pEnd ){
+    pBuf = (void*)*ppFrom;
+    *ppFrom += nByte;
+  }else{
+    *pnByte += nByte;
   }
+  return pBuf;
 }
 
 /*
@@ -48505,9 +48517,10 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady(
   ** being called from sqlite3_reset() to reset the virtual machine.
   */
   if( nVar>=0 && ALWAYS(db->mallocFailed==0) ){
-    u8 *zCsr = (u8 *)&p->aOp[p->nOp];
-    u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc];
-    int nByte;
+    u8 *zCsr = (u8 *)&p->aOp[p->nOp];       /* Memory avaliable for alloation */
+    u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc];  /* First byte past available mem */
+    int nByte;                              /* How much extra memory needed */
+
     resolveP2Values(p, &nArg);
     p->usesStmtJournal = (u8)usesStmtJournal;
     if( isExplain && nMem<10 ){
@@ -48517,15 +48530,24 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady(
     zCsr += (zCsr - (u8*)0)&7;
     assert( EIGHT_BYTE_ALIGNMENT(zCsr) );
 
+    /* Memory for registers, parameters, cursor, etc, is allocated in two
+    ** passes.  On the first pass, we try to reuse unused space at the 
+    ** end of the opcode array.  If we are unable to satisfy all memory
+    ** requirements by reusing the opcode array tail, then the second
+    ** pass will fill in the rest using a fresh allocation.  
+    **
+    ** This two-pass approach that reuses as much memory as possible from
+    ** the leftover space at the end of the opcode array can significantly
+    ** reduce the amount of memory held by a prepared statement.
+    */
     do {
       nByte = 0;
-      allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
-      allocSpace((char*)&p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
-      allocSpace((char*)&p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
-      allocSpace((char*)&p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
-      allocSpace((char*)&p->apCsr, 
-                 nCursor*sizeof(VdbeCursor*), &zCsr, zEnd, &nByte
-      );
+      p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
+      p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
+      p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
+      p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
+      p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*),
+                            &zCsr, zEnd, &nByte);
       if( nByte ){
         p->pFree = sqlite3DbMallocZero(db, nByte);
       }
@@ -48535,7 +48557,7 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady(
 
     p->nCursor = (u16)nCursor;
     if( p->aVar ){
-      p->nVar = (u16)nVar;
+      p->nVar = (ynVar)nVar;
       for(n=0; n<nVar; n++){
         p->aVar[n].flags = MEM_Null;
         p->aVar[n].db = db;
@@ -48867,10 +48889,11 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
     */
     for(i=0; i<db->nDb; i++){
       Btree *pBt = db->aDb[i].pBt;
-      if( i==1 ) continue;   /* Ignore the TEMP database */
       if( sqlite3BtreeIsInTrans(pBt) ){
         char const *zFile = sqlite3BtreeGetJournalname(pBt);
-        if( zFile[0]==0 ) continue;  /* Ignore :memory: databases */
+        if( zFile==0 || zFile[0]==0 ){
+          continue;  /* Ignore TEMP and :memory: databases */
+        }
         if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){
           needSync = 1;
         }
@@ -49948,9 +49971,17 @@ SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
   pKeyInfo = pPKey2->pKeyInfo;
   mem1.enc = pKeyInfo->enc;
   mem1.db = pKeyInfo->db;
-  mem1.flags = 0;
-  mem1.u.i = 0;  /* not needed, here to silence compiler warning */
-  mem1.zMalloc = 0;
+  /* mem1.flags = 0;  // Will be initialized by sqlite3VdbeSerialGet() */
+  VVA_ONLY( mem1.zMalloc = 0; ) /* Only needed by assert() statements */
+
+  /* Compilers may complain that mem1.u.i is potentially uninitialized.
+  ** We could initialize it, as shown here, to silence those complaints.
+  ** But in fact, mem1.u.i will never actually be used initialized, and doing 
+  ** the unnecessary initialization has a measurable negative performance
+  ** impact, since this routine is a very high runner.  And so, we choose
+  ** to ignore the compiler warnings and leave this variable uninitialized.
+  */
+  /*  mem1.u.i = 0;  // not needed, here to silence compiler warning */
   
   idx1 = getVarint32(aKey1, szHdr1);
   d1 = szHdr1;
@@ -49974,47 +50005,52 @@ SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
     rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
                            i<nField ? pKeyInfo->aColl[i] : 0);
     if( rc!=0 ){
-      break;
+      assert( mem1.zMalloc==0 );  /* See comment below */
+
+      /* Invert the result if we are using DESC sort order. */
+      if( pKeyInfo->aSortOrder && i<nField && pKeyInfo->aSortOrder[i] ){
+        rc = -rc;
+      }
+    
+      /* If the PREFIX_SEARCH flag is set and all fields except the final
+      ** rowid field were equal, then clear the PREFIX_SEARCH flag and set 
+      ** pPKey2->rowid to the value of the rowid field in (pKey1, nKey1).
+      ** This is used by the OP_IsUnique opcode.
+      */
+      if( (pPKey2->flags & UNPACKED_PREFIX_SEARCH) && i==(pPKey2->nField-1) ){
+        assert( idx1==szHdr1 && rc );
+        assert( mem1.flags & MEM_Int );
+        pPKey2->flags &= ~UNPACKED_PREFIX_SEARCH;
+        pPKey2->rowid = mem1.u.i;
+      }
+    
+      return rc;
     }
     i++;
   }
 
-  /* No memory allocation is ever used on mem1. */
-  if( NEVER(mem1.zMalloc) ) sqlite3VdbeMemRelease(&mem1);
-
-  /* If the PREFIX_SEARCH flag is set and all fields except the final
-  ** rowid field were equal, then clear the PREFIX_SEARCH flag and set 
-  ** pPKey2->rowid to the value of the rowid field in (pKey1, nKey1).
-  ** This is used by the OP_IsUnique opcode.
+  /* No memory allocation is ever used on mem1.  Prove this using
+  ** the following assert().  If the assert() fails, it indicates a
+  ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).
   */
-  if( (pPKey2->flags & UNPACKED_PREFIX_SEARCH) && i==(pPKey2->nField-1) ){
-    assert( idx1==szHdr1 && rc );
-    assert( mem1.flags & MEM_Int );
-    pPKey2->flags &= ~UNPACKED_PREFIX_SEARCH;
-    pPKey2->rowid = mem1.u.i;
-  }
+  assert( mem1.zMalloc==0 );
 
-  if( rc==0 ){
-    /* rc==0 here means that one of the keys ran out of fields and
-    ** all the fields up to that point were equal. If the UNPACKED_INCRKEY
-    ** flag is set, then break the tie by treating key2 as larger.
-    ** If the UPACKED_PREFIX_MATCH flag is set, then keys with common prefixes
-    ** are considered to be equal.  Otherwise, the longer key is the 
-    ** larger.  As it happens, the pPKey2 will always be the longer
-    ** if there is a difference.
-    */
-    if( pPKey2->flags & UNPACKED_INCRKEY ){
-      rc = -1;
-    }else if( pPKey2->flags & UNPACKED_PREFIX_MATCH ){
-      /* Leave rc==0 */
-    }else if( idx1<szHdr1 ){
-      rc = 1;
-    }
-  }else if( pKeyInfo->aSortOrder && i<pKeyInfo->nField
-               && pKeyInfo->aSortOrder[i] ){
-    rc = -rc;
+  /* rc==0 here means that one of the keys ran out of fields and
+  ** all the fields up to that point were equal. If the UNPACKED_INCRKEY
+  ** flag is set, then break the tie by treating key2 as larger.
+  ** If the UPACKED_PREFIX_MATCH flag is set, then keys with common prefixes
+  ** are considered to be equal.  Otherwise, the longer key is the 
+  ** larger.  As it happens, the pPKey2 will always be the longer
+  ** if there is a difference.
+  */
+  assert( rc==0 );
+  if( pPKey2->flags & UNPACKED_INCRKEY ){
+    rc = -1;
+  }else if( pPKey2->flags & UNPACKED_PREFIX_MATCH ){
+    /* Leave rc==0 */
+  }else if( idx1<szHdr1 ){
+    rc = 1;
   }
-
   return rc;
 }
  
@@ -50179,6 +50215,45 @@ SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){
   return v->db;
 }
 
+/*
+** Return a pointer to an sqlite3_value structure containing the value bound
+** parameter iVar of VM v. Except, if the value is an SQL NULL, return 
+** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
+** constants) to the value before returning it.
+**
+** The returned value must be freed by the caller using sqlite3ValueFree().
+*/
+SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){
+  assert( iVar>0 );
+  if( v ){
+    Mem *pMem = &v->aVar[iVar-1];
+    if( 0==(pMem->flags & MEM_Null) ){
+      sqlite3_value *pRet = sqlite3ValueNew(v->db);
+      if( pRet ){
+        sqlite3VdbeMemCopy((Mem *)pRet, pMem);
+        sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
+        sqlite3VdbeMemStoreType((Mem *)pRet);
+      }
+      return pRet;
+    }
+  }
+  return 0;
+}
+
+/*
+** Configure SQL variable iVar so that binding a new value to it signals
+** to sqlite3_reoptimize() that re-preparing the statement may result
+** in a better query plan.
+*/
+SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
+  assert( iVar>0 );
+  if( iVar>32 ){
+    v->expmask = 0xffffffff;
+  }else{
+    v->expmask |= ((u32)1 << (iVar-1));
+  }
+}
+
 /************** End of vdbeaux.c *********************************************/
 /************** Begin file vdbeapi.c *****************************************/
 /*
@@ -50195,8 +50270,6 @@ SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){
 **
 ** This file contains code use to implement APIs that are part of the
 ** VDBE.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 #ifndef SQLITE_OMIT_DEPRECATED
@@ -50280,6 +50353,9 @@ SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
     sqlite3VdbeMemRelease(&p->aVar[i]);
     p->aVar[i].flags = MEM_Null;
   }
+  if( p->isPrepareV2 && p->expmask ){
+    p->expired = 1;
+  }
   sqlite3_mutex_leave(mutex);
   return rc;
 }
@@ -50485,7 +50561,7 @@ static int sqlite3Step(Vdbe *p){
   }
 
   if( p->pc<=0 && p->expired ){
-    if( ALWAYS(p->rc==SQLITE_OK) ){
+    if( ALWAYS(p->rc==SQLITE_OK || p->rc==SQLITE_SCHEMA) ){
       p->rc = SQLITE_SCHEMA;
     }
     rc = SQLITE_ERROR;
@@ -50663,8 +50739,9 @@ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
   assert( p && p->pFunc && p->pFunc->xStep );
   assert( sqlite3_mutex_held(p->s.db->mutex) );
   pMem = p->pMem;
+  testcase( nByte<0 );
   if( (pMem->flags & MEM_Agg)==0 ){
-    if( nByte==0 ){
+    if( nByte<=0 ){
       sqlite3VdbeMemReleaseExternal(pMem);
       pMem->flags = MEM_Null;
       pMem->z = 0;
@@ -51095,6 +51172,15 @@ static int vdbeUnbind(Vdbe *p, int i){
   sqlite3VdbeMemRelease(pVar);
   pVar->flags = MEM_Null;
   sqlite3Error(p->db, SQLITE_OK, 0);
+
+  /* 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.
+  */
+  if( p->isPrepareV2 &&
+     ((i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff)
+  ){
+    p->expired = 1;
+  }
   return SQLITE_OK;
 }
 
@@ -51291,8 +51377,7 @@ SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
 ** with that name.  If there is no variable with the given name,
 ** return 0.
 */
-SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
-  Vdbe *p = (Vdbe*)pStmt;
+SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nName){
   int i;
   if( p==0 ){
     return 0;
@@ -51301,13 +51386,16 @@ SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zNa
   if( zName ){
     for(i=0; i<p->nVar; i++){
       const char *z = p->azVar[i];
-      if( z && strcmp(z,zName)==0 ){
+      if( z && memcmp(z,zName,nName)==0 && z[nName]==0 ){
         return i+1;
       }
     }
   }
   return 0;
 }
+SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
+  return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));
+}
 
 /*
 ** Transfer all bindings from the first statement over to the second.
@@ -51345,6 +51433,12 @@ SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *
   if( pFrom->nVar!=pTo->nVar ){
     return SQLITE_ERROR;
   }
+  if( pTo->isPrepareV2 && pTo->expmask ){
+    pTo->expired = 1;
+  }
+  if( pFrom->isPrepareV2 && pFrom->expmask ){
+    pFrom->expired = 1;
+  }
   return sqlite3TransferBindings(pFromStmt, pToStmt);
 }
 #endif
@@ -51388,6 +51482,149 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
 }
 
 /************** End of vdbeapi.c *********************************************/
+/************** Begin file vdbetrace.c ***************************************/
+/*
+** 2009 November 25
+**
+** 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 code used to insert the values of host parameters
+** (aka "wildcards") into the SQL text output by sqlite3_trace().
+*/
+
+#ifndef SQLITE_OMIT_TRACE
+
+/*
+** zSql is a zero-terminated string of UTF-8 SQL text.  Return the number of
+** bytes in this text up to but excluding the first character in
+** a host parameter.  If the text contains no host parameters, return
+** the total number of bytes in the text.
+*/
+static int findNextHostParameter(const char *zSql, int *pnToken){
+  int tokenType;
+  int nTotal = 0;
+  int n;
+
+  *pnToken = 0;
+  while( zSql[0] ){
+    n = sqlite3GetToken((u8*)zSql, &tokenType);
+    assert( n>0 && tokenType!=TK_ILLEGAL );
+    if( tokenType==TK_VARIABLE ){
+      *pnToken = n;
+      break;
+    }
+    nTotal += n;
+    zSql += n;
+  }
+  return nTotal;
+}
+
+/*
+** Return a pointer to a string in memory obtained form sqlite3DbMalloc() which
+** holds a copy of zRawSql but with host parameters expanded to their
+** current bindings.
+**
+** The calling function is responsible for making sure the memory returned
+** is eventually freed.
+**
+** ALGORITHM:  Scan the input string looking for host parameters in any of
+** these forms:  ?, ?N, $A, @A, :A.  Take care to avoid text within
+** string literals, quoted identifier names, and comments.  For text forms,
+** the host parameter index is found by scanning the perpared
+** statement for the corresponding OP_Variable opcode.  Once the host
+** parameter index is known, locate the value in p->aVar[].  Then render
+** the value as a literal in place of the host parameter name.
+*/
+SQLITE_PRIVATE char *sqlite3VdbeExpandSql(
+  Vdbe *p,                 /* The prepared statement being evaluated */
+  const char *zRawSql      /* Raw text of the SQL statement */
+){
+  sqlite3 *db;             /* The database connection */
+  int idx = 0;             /* Index of a host parameter */
+  int nextIndex = 1;       /* Index of next ? host parameter */
+  int n;                   /* Length of a token prefix */
+  int nToken;              /* Length of the parameter token */
+  int i;                   /* Loop counter */
+  Mem *pVar;               /* Value of a host parameter */
+  StrAccum out;            /* Accumulate the output here */
+  char zBase[100];         /* Initial working space */
+
+  db = p->db;
+  sqlite3StrAccumInit(&out, zBase, sizeof(zBase), 
+                      db->aLimit[SQLITE_LIMIT_LENGTH]);
+  out.db = db;
+  while( zRawSql[0] ){
+    n = findNextHostParameter(zRawSql, &nToken);
+    assert( n>0 );
+    sqlite3StrAccumAppend(&out, zRawSql, n);
+    zRawSql += n;
+    assert( zRawSql[0] || nToken==0 );
+    if( nToken==0 ) break;
+    if( zRawSql[0]=='?' ){
+      if( nToken>1 ){
+        assert( sqlite3Isdigit(zRawSql[1]) );
+        sqlite3GetInt32(&zRawSql[1], &idx);
+      }else{
+        idx = nextIndex;
+      }
+    }else{
+      assert( zRawSql[0]==':' || zRawSql[0]=='$' || zRawSql[0]=='@' );
+      testcase( zRawSql[0]==':' );
+      testcase( zRawSql[0]=='$' );
+      testcase( zRawSql[0]=='@' );
+      idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken);
+      assert( idx>0 );
+    }
+    zRawSql += nToken;
+    nextIndex = idx + 1;
+    assert( idx>0 && idx<=p->nVar );
+    pVar = &p->aVar[idx-1];
+    if( pVar->flags & MEM_Null ){
+      sqlite3StrAccumAppend(&out, "NULL", 4);
+    }else if( pVar->flags & MEM_Int ){
+      sqlite3XPrintf(&out, "%lld", pVar->u.i);
+    }else if( pVar->flags & MEM_Real ){
+      sqlite3XPrintf(&out, "%!.15g", pVar->r);
+    }else if( pVar->flags & MEM_Str ){
+#ifndef SQLITE_OMIT_UTF16
+      u8 enc = ENC(db);
+      if( enc!=SQLITE_UTF8 ){
+        Mem utf8;
+        memset(&utf8, 0, sizeof(utf8));
+        utf8.db = db;
+        sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
+        sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8);
+        sqlite3XPrintf(&out, "'%.*q'", utf8.n, utf8.z);
+        sqlite3VdbeMemRelease(&utf8);
+      }else
+#endif
+      {
+        sqlite3XPrintf(&out, "'%.*q'", pVar->n, pVar->z);
+      }
+    }else if( pVar->flags & MEM_Zero ){
+      sqlite3XPrintf(&out, "zeroblob(%d)", pVar->u.nZero);
+    }else{
+      assert( pVar->flags & MEM_Blob );
+      sqlite3StrAccumAppend(&out, "x'", 2);
+      for(i=0; i<pVar->n; i++){
+        sqlite3XPrintf(&out, "%02x", pVar->z[i]&0xff);
+      }
+      sqlite3StrAccumAppend(&out, "'", 1);
+    }
+  }
+  return sqlite3StrAccumFinish(&out);
+}
+
+#endif /* #ifndef SQLITE_OMIT_TRACE */
+
+/************** End of vdbetrace.c *******************************************/
 /************** Begin file vdbe.c ********************************************/
 /*
 ** 2001 September 15
@@ -51433,8 +51670,6 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
 ** of the code in this file is, therefore, important.  See other comments
 ** in this file for details.  If in doubt, do not deviate from existing
 ** commenting and indentation practices when changing or adding code.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -51540,12 +51775,10 @@ SQLITE_API int sqlite3_found_count = 0;
 /*
 ** Argument pMem points at a register that will be passed to a
 ** user-defined function or returned to the user as the result of a query.
-** The second argument, 'db_enc' is the text encoding used by the vdbe for
-** register variables.  This routine sets the pMem->enc and pMem->type
-** variables used by the sqlite3_value_*() routines.
+** This routine sets the pMem->type variable used by the sqlite3_value_*() 
+** routines.
 */
-#define storeTypeInfo(A,B) _storeTypeInfo(A)
-static void _storeTypeInfo(Mem *pMem){
+SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem){
   int flags = pMem->flags;
   if( flags & MEM_Null ){
     pMem->type = SQLITE_NULL;
@@ -51564,23 +51797,6 @@ static void _storeTypeInfo(Mem *pMem){
 }
 
 /*
-** Properties of opcodes.  The OPFLG_INITIALIZER macro is
-** created by mkopcodeh.awk during compilation.  Data is obtained
-** from the comments following the "case OP_xxxx:" statements in
-** this file.  
-*/
-static const unsigned char opcodeProperty[] = OPFLG_INITIALIZER;
-
-/*
-** Return true if an opcode has any of the OPFLG_xxx properties
-** specified by mask.
-*/
-SQLITE_PRIVATE int sqlite3VdbeOpcodeHasProperty(int opcode, int mask){
-  assert( opcode>0 && opcode<(int)sizeof(opcodeProperty) );
-  return (opcodeProperty[opcode]&mask)!=0;
-}
-
-/*
 ** Allocate VdbeCursor number iCur.  Return a pointer to it.  Return NULL
 ** if we run out of memory.
 */
@@ -51614,7 +51830,7 @@ static VdbeCursor *allocateCursor(
   int nByte;
   VdbeCursor *pCx = 0;
   nByte = 
-      sizeof(VdbeCursor) + 
+      ROUND8(sizeof(VdbeCursor)) + 
       (isBtreeCursor?sqlite3BtreeCursorSize():0) + 
       2*nField*sizeof(u32);
 
@@ -51625,15 +51841,16 @@ static VdbeCursor *allocateCursor(
   }
   if( SQLITE_OK==sqlite3VdbeMemGrow(pMem, nByte, 0) ){
     p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
-    memset(pMem->z, 0, nByte);
+    memset(pCx, 0, sizeof(VdbeCursor));
     pCx->iDb = iDb;
     pCx->nField = nField;
     if( nField ){
-      pCx->aType = (u32 *)&pMem->z[sizeof(VdbeCursor)];
+      pCx->aType = (u32 *)&pMem->z[ROUND8(sizeof(VdbeCursor))];
     }
     if( isBtreeCursor ){
       pCx->pCursor = (BtCursor*)
-          &pMem->z[sizeof(VdbeCursor)+2*nField*sizeof(u32)];
+          &pMem->z[ROUND8(sizeof(VdbeCursor))+2*nField*sizeof(u32)];
+      sqlite3BtreeCursorZero(pCx->pCursor);
     }
   }
   return pCx;
@@ -51716,7 +51933,7 @@ static void applyAffinity(
 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
   Mem *pMem = (Mem*)pVal;
   applyNumericAffinity(pMem);
-  storeTypeInfo(pMem, 0);
+  sqlite3VdbeMemStoreType(pMem);
   return pMem->type;
 }
 
@@ -51875,8 +52092,6 @@ static void registerTrace(FILE *out, int iReg, Mem *p){
 **
 ** This file contains inline asm code for retrieving "high-performance"
 ** counters for x86 class CPUs.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _HWTIME_H_
 #define _HWTIME_H_
@@ -52039,24 +52254,27 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
   Vdbe *p                    /* The VDBE */
 ){
   int pc;                    /* The program counter */
+  Op *aOp = p->aOp;          /* Copy of p->aOp */
   Op *pOp;                   /* Current operation */
   int rc = SQLITE_OK;        /* Value to return */
   sqlite3 *db = p->db;       /* The database */
+  u8 resetSchemaOnFault = 0; /* Reset schema after an error if true */
   u8 encoding = ENC(db);     /* The database encoding */
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+  int checkProgress;         /* True if progress callbacks are enabled */
+  int nProgressOps = 0;      /* Opcodes executed since progress callback. */
+#endif
+  Mem *aMem = p->aMem;       /* Copy of p->aMem */
   Mem *pIn1 = 0;             /* 1st input operand */
   Mem *pIn2 = 0;             /* 2nd input operand */
   Mem *pIn3 = 0;             /* 3rd input operand */
   Mem *pOut = 0;             /* Output operand */
-  u8 opProperty;
   int iCompare = 0;          /* Result of last OP_Compare operation */
   int *aPermute = 0;         /* Permutation of columns for OP_Compare */
 #ifdef VDBE_PROFILE
   u64 start;                 /* CPU clock count at start of opcode */
   int origPc;                /* Program counter at start of opcode */
 #endif
-#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
-  int nProgressOps = 0;      /* Opcodes executed since progress callback. */
-#endif
   /********************************************************************
   ** Automatically generated code
   **
@@ -52152,10 +52370,8 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       Mem *pReg;         /* PseudoTable input register */
     } am;
     struct OP_Affinity_stack_vars {
-      char *zAffinity;   /* The affinity to be applied */
-      Mem *pData0;       /* First register to which to apply affinity */
-      Mem *pLast;        /* Last register to which to apply affinity */
-      Mem *pRec;         /* Current register */
+      const char *zAffinity;   /* The affinity to be applied */
+      char cAff;               /* A single character of affinity */
     } an;
     struct OP_MakeRecord_stack_vars {
       u8 *zNewRecord;        /* A buffer to hold the data for the new record */
@@ -52240,6 +52456,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       VdbeCursor *pC;
       int res;
       UnpackedRecord *pIdxKey;
+      UnpackedRecord r;
       char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7];
     } bb;
     struct OP_IsUnique_stack_vars {
@@ -52247,7 +52464,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       VdbeCursor *pCx;
       BtCursor *pCrsr;
       u16 nField;
-      Mem *aMem;
+      Mem *aMx;
       UnpackedRecord r;                  /* B-Tree index search key */
       i64 R;                             /* Rowid stored in register P3 */
     } bc;
@@ -52265,7 +52482,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       Mem *pMem;             /* Register holding largest rowid for AUTOINCREMENT */
       VdbeFrame *pFrame;     /* Root frame of VDBE */
     } be;
-    struct OP_Insert_stack_vars {
+    struct OP_InsertInt_stack_vars {
       Mem *pData;       /* MEM cell holding data for the record to be inserted */
       Mem *pKey;        /* MEM cell holding key  for the record */
       i64 iKey;         /* The integer ROWID or key for the record to be inserted */
@@ -52360,18 +52577,13 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       char *z;        /* Text of the error report */
       Mem *pnErr;     /* Register keeping track of errors remaining */
     } bv;
-    struct OP_RowSetAdd_stack_vars {
-      Mem *pIdx;
-      Mem *pVal;
-    } bw;
     struct OP_RowSetRead_stack_vars {
-      Mem *pIdx;
       i64 val;
-    } bx;
+    } bw;
     struct OP_RowSetTest_stack_vars {
       int iSet;
       int exists;
-    } by;
+    } bx;
     struct OP_Program_stack_vars {
       int nMem;               /* Number of memory registers for sub-program */
       int nByte;              /* Bytes of runtime space required for sub-program */
@@ -52381,15 +52593,15 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       VdbeFrame *pFrame;      /* New vdbe frame to execute in */
       SubProgram *pProgram;   /* Sub-program to execute */
       void *t;                /* Token identifying trigger */
-    } bz;
+    } by;
     struct OP_Param_stack_vars {
       VdbeFrame *pFrame;
       Mem *pIn;
-    } ca;
+    } bz;
     struct OP_MemMax_stack_vars {
       Mem *pIn1;
       VdbeFrame *pFrame;
-    } cb;
+    } ca;
     struct OP_AggStep_stack_vars {
       int n;
       int i;
@@ -52397,22 +52609,22 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       Mem *pRec;
       sqlite3_context ctx;
       sqlite3_value **apVal;
-    } cc;
+    } cb;
     struct OP_AggFinal_stack_vars {
       Mem *pMem;
-    } cd;
+    } cc;
     struct OP_IncrVacuum_stack_vars {
       Btree *pBt;
-    } ce;
+    } cd;
     struct OP_VBegin_stack_vars {
       VTable *pVTab;
-    } cf;
+    } ce;
     struct OP_VOpen_stack_vars {
       VdbeCursor *pCur;
       sqlite3_vtab_cursor *pVtabCursor;
       sqlite3_vtab *pVtab;
       sqlite3_module *pModule;
-    } cg;
+    } cf;
     struct OP_VFilter_stack_vars {
       int nArg;
       int iQuery;
@@ -52425,23 +52637,23 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       int res;
       int i;
       Mem **apArg;
-    } ch;
+    } cg;
     struct OP_VColumn_stack_vars {
       sqlite3_vtab *pVtab;
       const sqlite3_module *pModule;
       Mem *pDest;
       sqlite3_context sContext;
-    } ci;
+    } ch;
     struct OP_VNext_stack_vars {
       sqlite3_vtab *pVtab;
       const sqlite3_module *pModule;
       int res;
       VdbeCursor *pCur;
-    } cj;
+    } ci;
     struct OP_VRename_stack_vars {
       sqlite3_vtab *pVtab;
       Mem *pName;
-    } ck;
+    } cj;
     struct OP_VUpdate_stack_vars {
       sqlite3_vtab *pVtab;
       sqlite3_module *pModule;
@@ -52450,15 +52662,15 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       sqlite_int64 rowid;
       Mem **apArg;
       Mem *pX;
-    } cl;
+    } ck;
     struct OP_Pagecount_stack_vars {
       int p1;
       int nPage;
       Pager *pPager;
-    } cm;
+    } cl;
     struct OP_Trace_stack_vars {
       char *zTrace;
-    } cn;
+    } cm;
   } u;
   /* End automatically generated code
   ********************************************************************/
@@ -52478,6 +52690,9 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
   db->busyHandler.nBusy = 0;
   CHECK_FOR_INTERRUPT;
   sqlite3VdbeIOTraceSql(p);
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+  checkProgress = db->xProgress!=0;
+#endif
 #ifdef SQLITE_DEBUG
   sqlite3BeginBenignMalloc();
   if( p->pc==0 
@@ -52487,7 +52702,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
     printf("VDBE Program Listing:\n");
     sqlite3VdbePrintSql(p);
     for(i=0; i<p->nOp; i++){
-      sqlite3VdbePrintOp(stdout, i, &p->aOp[i]);
+      sqlite3VdbePrintOp(stdout, i, &aOp[i]);
     }
   }
   if( fileExists(db, "vdbe_trace") ){
@@ -52502,7 +52717,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
     origPc = pc;
     start = sqlite3Hwtime();
 #endif
-    pOp = &p->aOp[pc];
+    pOp = &aOp[pc];
 
     /* Only allow tracing if SQLITE_DEBUG is defined.
     */
@@ -52543,7 +52758,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
     ** If the progress callback returns non-zero, exit the virtual machine with
     ** a return code SQLITE_ABORT.
     */
-    if( db->xProgress ){
+    if( checkProgress ){
       if( db->nProgressOps==nProgressOps ){
         int prc;
         if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
@@ -52559,66 +52774,47 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
     }
 #endif
 
-    /* Do common setup processing for any opcode that is marked
-    ** with the "out2-prerelease" tag.  Such opcodes have a single
-    ** output which is specified by the P2 parameter.  The P2 register
-    ** is initialized to a NULL.
+    /* On any opcode with the "out2-prerelase" tag, free any
+    ** external allocations out of mem[p2] and set mem[p2] to be
+    ** an undefined integer.  Opcodes will either fill in the integer
+    ** value or convert mem[p2] to a different type.
     */
-    opProperty = opcodeProperty[pOp->opcode];
-    if( (opProperty & OPFLG_OUT2_PRERELEASE)!=0 ){
+    assert( pOp->opflags==sqlite3OpcodeProperty[pOp->opcode] );
+    if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){
       assert( pOp->p2>0 );
       assert( pOp->p2<=p->nMem );
-      pOut = &p->aMem[pOp->p2];
+      pOut = &aMem[pOp->p2];
       sqlite3VdbeMemReleaseExternal(pOut);
-      pOut->flags = MEM_Null;
-      pOut->n = 0;
-    }else
- 
-    /* Do common setup for opcodes marked with one of the following
-    ** combinations of properties.
-    **
-    **           in1
-    **           in1 in2
-    **           in1 in2 out3
-    **           in1 in3
-    **
-    ** Variables pIn1, pIn2, and pIn3 are made to point to appropriate
-    ** registers for inputs.  Variable pOut points to the output register.
-    */
-    if( (opProperty & OPFLG_IN1)!=0 ){
+      pOut->flags = MEM_Int;
+    }
+
+    /* Sanity checking on other operands */
+#ifdef SQLITE_DEBUG
+    if( (pOp->opflags & OPFLG_IN1)!=0 ){
       assert( pOp->p1>0 );
       assert( pOp->p1<=p->nMem );
-      pIn1 = &p->aMem[pOp->p1];
-      REGISTER_TRACE(pOp->p1, pIn1);
-      if( (opProperty & OPFLG_IN2)!=0 ){
-        assert( pOp->p2>0 );
-        assert( pOp->p2<=p->nMem );
-        pIn2 = &p->aMem[pOp->p2];
-        REGISTER_TRACE(pOp->p2, pIn2);
-        /* As currently implemented, in2 implies out3.  There is no reason
-        ** why this has to be, it just worked out that way. */
-        assert( (opProperty & OPFLG_OUT3)!=0 );
-        assert( pOp->p3>0 );
-        assert( pOp->p3<=p->nMem );
-        pOut = &p->aMem[pOp->p3];
-      }else if( (opProperty & OPFLG_IN3)!=0 ){
-        assert( pOp->p3>0 );
-        assert( pOp->p3<=p->nMem );
-        pIn3 = &p->aMem[pOp->p3];
-        REGISTER_TRACE(pOp->p3, pIn3);
-      }
-    }else if( (opProperty & OPFLG_IN2)!=0 ){
+      REGISTER_TRACE(pOp->p1, &aMem[pOp->p1]);
+    }
+    if( (pOp->opflags & OPFLG_IN2)!=0 ){
       assert( pOp->p2>0 );
       assert( pOp->p2<=p->nMem );
-      pIn2 = &p->aMem[pOp->p2];
-      REGISTER_TRACE(pOp->p2, pIn2);
-    }else if( (opProperty & OPFLG_IN3)!=0 ){
+      REGISTER_TRACE(pOp->p2, &aMem[pOp->p2]);
+    }
+    if( (pOp->opflags & OPFLG_IN3)!=0 ){
       assert( pOp->p3>0 );
       assert( pOp->p3<=p->nMem );
-      pIn3 = &p->aMem[pOp->p3];
-      REGISTER_TRACE(pOp->p3, pIn3);
+      REGISTER_TRACE(pOp->p3, &aMem[pOp->p3]);
     }
-
+    if( (pOp->opflags & OPFLG_OUT2)!=0 ){
+      assert( pOp->p2>0 );
+      assert( pOp->p2<=p->nMem );
+    }
+    if( (pOp->opflags & OPFLG_OUT3)!=0 ){
+      assert( pOp->p3>0 );
+      assert( pOp->p3<=p->nMem );
+    }
+#endif
+  
     switch( pOp->opcode ){
 
 /*****************************************************************************
@@ -52674,10 +52870,8 @@ case OP_Goto: {             /* jump */
 ** Write the current address onto register P1
 ** and then jump to address P2.
 */
-case OP_Gosub: {            /* jump */
-  assert( pOp->p1>0 );
-  assert( pOp->p1<=p->nMem );
-  pIn1 = &p->aMem[pOp->p1];
+case OP_Gosub: {            /* jump, in1 */
+  pIn1 = &aMem[pOp->p1];
   assert( (pIn1->flags & MEM_Dyn)==0 );
   pIn1->flags = MEM_Int;
   pIn1->u.i = pc;
@@ -52691,6 +52885,7 @@ case OP_Gosub: {            /* jump */
 ** Jump to the next instruction after the address in register P1.
 */
 case OP_Return: {           /* in1 */
+  pIn1 = &aMem[pOp->p1];
   assert( pIn1->flags & MEM_Int );
   pc = (int)pIn1->u.i;
   break;
@@ -52704,6 +52899,7 @@ case OP_Yield: {            /* in1 */
 #if 0  /* local variables moved into u.aa */
   int pcDest;
 #endif /* local variables moved into u.aa */
+  pIn1 = &aMem[pOp->p1];
   assert( (pIn1->flags & MEM_Dyn)==0 );
   pIn1->flags = MEM_Int;
   u.aa.pcDest = (int)pIn1->u.i;
@@ -52720,6 +52916,7 @@ case OP_Yield: {            /* in1 */
 ** value in register P3 is not NULL, then this routine is a no-op.
 */
 case OP_HaltIfNull: {      /* in3 */
+  pIn3 = &aMem[pOp->p3];
   if( (pIn3->flags & MEM_Null)==0 ) break;
   /* Fall through into OP_Halt */
 }
@@ -52759,6 +52956,8 @@ case OP_Halt: {
       ** as the p2 of the calling OP_Program.  */
       pc = p->aOp[pc].p2-1;
     }
+    aOp = p->aOp;
+    aMem = p->aMem;
     break;
   }
 
@@ -52785,7 +52984,6 @@ case OP_Halt: {
 ** The 32-bit integer value P1 is written into register P2.
 */
 case OP_Integer: {         /* out2-prerelease */
-  pOut->flags = MEM_Int;
   pOut->u.i = pOp->p1;
   break;
 }
@@ -52797,7 +52995,6 @@ case OP_Integer: {         /* out2-prerelease */
 */
 case OP_Int64: {           /* out2-prerelease */
   assert( pOp->p4.pI64!=0 );
-  pOut->flags = MEM_Int;
   pOut->u.i = *pOp->p4.pI64;
   break;
 }
@@ -52867,6 +53064,7 @@ case OP_String: {          /* out2-prerelease */
 ** Write a NULL into register P2.
 */
 case OP_Null: {           /* out2-prerelease */
+  pOut->flags = MEM_Null;
   break;
 }
 
@@ -52909,14 +53107,14 @@ case OP_Variable: {
   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 );
+  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 = &p->aMem[u.ab.p2++];
+    pOut = &aMem[u.ab.p2++];
     sqlite3VdbeMemReleaseExternal(pOut);
     pOut->flags = MEM_Null;
     sqlite3VdbeMemShallowCopy(pOut, u.ab.pVar, MEM_Static);
@@ -52946,11 +53144,11 @@ case OP_Move: {
   assert( u.ac.n>0 && u.ac.p1>0 && u.ac.p2>0 );
   assert( u.ac.p1+u.ac.n<=u.ac.p2 || u.ac.p2+u.ac.n<=u.ac.p1 );
 
-  pIn1 = &p->aMem[u.ac.p1];
-  pOut = &p->aMem[u.ac.p2];
+  pIn1 = &aMem[u.ac.p1];
+  pOut = &aMem[u.ac.p2];
   while( u.ac.n-- ){
-    assert( pOut<=&p->aMem[p->nMem] );
-    assert( pIn1<=&p->aMem[p->nMem] );
+    assert( pOut<=&aMem[p->nMem] );
+    assert( pIn1<=&aMem[p->nMem] );
     u.ac.zMalloc = pOut->zMalloc;
     pOut->zMalloc = 0;
     sqlite3VdbeMemMove(pOut, pIn1);
@@ -52969,10 +53167,9 @@ case OP_Move: {
 ** This instruction makes a deep copy of the value.  A duplicate
 ** is made of any string or blob constant.  See also OP_SCopy.
 */
-case OP_Copy: {             /* in1 */
-  assert( pOp->p2>0 );
-  assert( pOp->p2<=p->nMem );
-  pOut = &p->aMem[pOp->p2];
+case OP_Copy: {             /* in1, out2 */
+  pIn1 = &aMem[pOp->p1];
+  pOut = &aMem[pOp->p2];
   assert( pOut!=pIn1 );
   sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
   Deephemeralize(pOut);
@@ -52992,11 +53189,9 @@ case OP_Copy: {             /* in1 */
 ** during the lifetime of the copy.  Use OP_Copy to make a complete
 ** copy.
 */
-case OP_SCopy: {            /* in1 */
-  REGISTER_TRACE(pOp->p1, pIn1);
-  assert( pOp->p2>0 );
-  assert( pOp->p2<=p->nMem );
-  pOut = &p->aMem[pOp->p2];
+case OP_SCopy: {            /* in1, out2 */
+  pIn1 = &aMem[pOp->p1];
+  pOut = &aMem[pOp->p2];
   assert( pOut!=pIn1 );
   sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
   REGISTER_TRACE(pOp->p2, pOut);
@@ -53057,10 +53252,10 @@ case OP_ResultRow: {
   ** and have an assigned type.  The results are de-ephemeralized as
   ** as side effect.
   */
-  u.ad.pMem = p->pResultSet = &p->aMem[pOp->p1];
+  u.ad.pMem = p->pResultSet = &aMem[pOp->p1];
   for(u.ad.i=0; u.ad.i<pOp->p2; u.ad.i++){
     sqlite3VdbeMemNulTerminate(&u.ad.pMem[u.ad.i]);
-    storeTypeInfo(&u.ad.pMem[u.ad.i], encoding);
+    sqlite3VdbeMemStoreType(&u.ad.pMem[u.ad.i]);
     REGISTER_TRACE(pOp->p1+u.ad.i, &u.ad.pMem[u.ad.i]);
   }
   if( db->mallocFailed ) goto no_mem;
@@ -53089,6 +53284,9 @@ case OP_Concat: {           /* same as TK_CONCAT, in1, in2, out3 */
   i64 nByte;
 #endif /* local variables moved into u.ae */
 
+  pIn1 = &aMem[pOp->p1];
+  pIn2 = &aMem[pOp->p2];
+  pOut = &aMem[pOp->p3];
   assert( pIn1!=pOut );
   if( (pIn1->flags | pIn2->flags) & MEM_Null ){
     sqlite3VdbeMemSetNull(pOut);
@@ -53164,8 +53362,11 @@ case OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */
   double rB;      /* Real value of right operand */
 #endif /* local variables moved into u.af */
 
+  pIn1 = &aMem[pOp->p1];
   applyNumericAffinity(pIn1);
+  pIn2 = &aMem[pOp->p2];
   applyNumericAffinity(pIn2);
+  pOut = &aMem[pOp->p3];
   u.af.flags = pIn1->flags | pIn2->flags;
   if( (u.af.flags & MEM_Null)!=0 ) goto arithmetic_result_is_null;
   if( (pIn1->flags & pIn2->flags & MEM_Int)==MEM_Int ){
@@ -53282,10 +53483,10 @@ case OP_Function: {
 
   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 = &p->aMem[pOp->p2];
+  u.ag.pArg = &aMem[pOp->p2];
   for(u.ag.i=0; u.ag.i<u.ag.n; u.ag.i++, u.ag.pArg++){
     u.ag.apVal[u.ag.i] = u.ag.pArg;
-    storeTypeInfo(u.ag.pArg, encoding);
+    sqlite3VdbeMemStoreType(u.ag.pArg);
     REGISTER_TRACE(pOp->p2, u.ag.pArg);
   }
 
@@ -53299,7 +53500,7 @@ case OP_Function: {
   }
 
   assert( pOp->p3>0 && pOp->p3<=p->nMem );
-  pOut = &p->aMem[pOp->p3];
+  pOut = &aMem[pOp->p3];
   u.ag.ctx.s.flags = MEM_Null;
   u.ag.ctx.s.db = db;
   u.ag.ctx.s.xDel = 0;
@@ -53314,7 +53515,7 @@ case OP_Function: {
 
   u.ag.ctx.isError = 0;
   if( u.ag.ctx.pFunc->flags & SQLITE_FUNC_NEEDCOLL ){
-    assert( pOp>p->aOp );
+    assert( pOp>aOp );
     assert( pOp[-1].p4type==P4_COLLSEQ );
     assert( pOp[-1].opcode==OP_CollSeq );
     u.ag.ctx.pColl = pOp[-1].p4.pColl;
@@ -53400,6 +53601,9 @@ case OP_ShiftRight: {           /* same as TK_RSHIFT, in1, in2, out3 */
   i64 b;
 #endif /* local variables moved into u.ah */
 
+  pIn1 = &aMem[pOp->p1];
+  pIn2 = &aMem[pOp->p2];
+  pOut = &aMem[pOp->p3];
   if( (pIn1->flags | pIn2->flags) & MEM_Null ){
     sqlite3VdbeMemSetNull(pOut);
     break;
@@ -53426,6 +53630,7 @@ case OP_ShiftRight: {           /* same as TK_RSHIFT, in1, in2, out3 */
 ** To force any register to be an integer, just add 0.
 */
 case OP_AddImm: {            /* in1 */
+  pIn1 = &aMem[pOp->p1];
   sqlite3VdbeMemIntegerify(pIn1);
   pIn1->u.i += pOp->p2;
   break;
@@ -53439,6 +53644,7 @@ case OP_AddImm: {            /* in1 */
 ** raise an SQLITE_MISMATCH exception.
 */
 case OP_MustBeInt: {            /* jump, in1 */
+  pIn1 = &aMem[pOp->p1];
   applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);
   if( (pIn1->flags & MEM_Int)==0 ){
     if( pOp->p2==0 ){
@@ -53463,6 +53669,7 @@ case OP_MustBeInt: {            /* jump, in1 */
 ** to have only a real value.
 */
 case OP_RealAffinity: {                  /* in1 */
+  pIn1 = &aMem[pOp->p1];
   if( pIn1->flags & MEM_Int ){
     sqlite3VdbeMemRealify(pIn1);
   }
@@ -53480,6 +53687,7 @@ case OP_RealAffinity: {                  /* in1 */
 ** A NULL value is not changed by this routine.  It remains NULL.
 */
 case OP_ToText: {                  /* same as TK_TO_TEXT, in1 */
+  pIn1 = &aMem[pOp->p1];
   if( pIn1->flags & MEM_Null ) break;
   assert( MEM_Str==(MEM_Blob>>3) );
   pIn1->flags |= (pIn1->flags&MEM_Blob)>>3;
@@ -53501,6 +53709,7 @@ case OP_ToText: {                  /* same as TK_TO_TEXT, in1 */
 ** A NULL value is not changed by this routine.  It remains NULL.
 */
 case OP_ToBlob: {                  /* same as TK_TO_BLOB, in1 */
+  pIn1 = &aMem[pOp->p1];
   if( pIn1->flags & MEM_Null ) break;
   if( (pIn1->flags & MEM_Blob)==0 ){
     applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding);
@@ -53524,6 +53733,7 @@ case OP_ToBlob: {                  /* same as TK_TO_BLOB, in1 */
 ** A NULL value is not changed by this routine.  It remains NULL.
 */
 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);
   }
@@ -53541,6 +53751,7 @@ case OP_ToNumeric: {                  /* same as TK_TO_NUMERIC, in1 */
 ** A NULL value is not changed by this routine.  It remains NULL.
 */
 case OP_ToInt: {                  /* same as TK_TO_INT, in1 */
+  pIn1 = &aMem[pOp->p1];
   if( (pIn1->flags & MEM_Null)==0 ){
     sqlite3VdbeMemIntegerify(pIn1);
   }
@@ -53558,6 +53769,7 @@ case OP_ToInt: {                  /* same as TK_TO_INT, in1 */
 ** A NULL value is not changed by this routine.  It remains NULL.
 */
 case OP_ToReal: {                  /* same as TK_TO_REAL, in1 */
+  pIn1 = &aMem[pOp->p1];
   if( (pIn1->flags & MEM_Null)==0 ){
     sqlite3VdbeMemRealify(pIn1);
   }
@@ -53648,6 +53860,8 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
   char affinity;      /* Affinity to use for comparison */
 #endif /* local variables moved into u.ai */
 
+  pIn1 = &aMem[pOp->p1];
+  pIn3 = &aMem[pOp->p3];
   if( (pIn1->flags | pIn3->flags)&MEM_Null ){
     /* One or both operands are NULL */
     if( pOp->p5 & SQLITE_NULLEQ ){
@@ -53663,7 +53877,7 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
       ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
       */
       if( pOp->p5 & SQLITE_STOREP2 ){
-        pOut = &p->aMem[pOp->p2];
+        pOut = &aMem[pOp->p2];
         MemSetTypeFlag(pOut, MEM_Null);
         REGISTER_TRACE(pOp->p2, pOut);
       }else if( pOp->p5 & SQLITE_JUMPIFNULL ){
@@ -53695,7 +53909,7 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
   }
 
   if( pOp->p5 & SQLITE_STOREP2 ){
-    pOut = &p->aMem[pOp->p2];
+    pOut = &aMem[pOp->p2];
     MemSetTypeFlag(pOut, MEM_Int);
     pOut->u.i = u.ai.res;
     REGISTER_TRACE(pOp->p2, pOut);
@@ -53766,12 +53980,12 @@ 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;
-    REGISTER_TRACE(u.aj.p1+u.aj.idx, &p->aMem[u.aj.p1+u.aj.idx]);
-    REGISTER_TRACE(u.aj.p2+u.aj.idx, &p->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 );
     u.aj.pColl = u.aj.pKeyInfo->aColl[u.aj.i];
     u.aj.bRev = u.aj.pKeyInfo->aSortOrder[u.aj.i];
-    iCompare = sqlite3MemCompare(&p->aMem[u.aj.p1+u.aj.idx], &p->aMem[u.aj.p2+u.aj.idx], u.aj.pColl);
+    iCompare = sqlite3MemCompare(&aMem[u.aj.p1+u.aj.idx], &aMem[u.aj.p2+u.aj.idx], u.aj.pColl);
     if( iCompare ){
       if( u.aj.bRev ) iCompare = -iCompare;
       break;
@@ -53823,11 +54037,13 @@ case OP_Or: {             /* same as TK_OR, in1, in2, out3 */
   int v2;    /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */
 #endif /* local variables moved into u.ak */
 
+  pIn1 = &aMem[pOp->p1];
   if( pIn1->flags & MEM_Null ){
     u.ak.v1 = 2;
   }else{
     u.ak.v1 = sqlite3VdbeIntValue(pIn1)!=0;
   }
+  pIn2 = &aMem[pOp->p2];
   if( pIn2->flags & MEM_Null ){
     u.ak.v2 = 2;
   }else{
@@ -53840,6 +54056,7 @@ case OP_Or: {             /* same as TK_OR, in1, in2, out3 */
     static const unsigned char or_logic[] = { 0, 1, 2, 1, 1, 1, 2, 1, 2 };
     u.ak.v1 = or_logic[u.ak.v1*3+u.ak.v2];
   }
+  pOut = &aMem[pOp->p3];
   if( u.ak.v1==2 ){
     MemSetTypeFlag(pOut, MEM_Null);
   }else{
@@ -53855,8 +54072,9 @@ case OP_Or: {             /* same as TK_OR, in1, in2, out3 */
 ** boolean complement in register P2.  If the value in register P1 is 
 ** NULL, then a NULL is stored in P2.
 */
-case OP_Not: {                /* same as TK_NOT, in1 */
-  pOut = &p->aMem[pOp->p2];
+case OP_Not: {                /* same as TK_NOT, in1, out2 */
+  pIn1 = &aMem[pOp->p1];
+  pOut = &aMem[pOp->p2];
   if( pIn1->flags & MEM_Null ){
     sqlite3VdbeMemSetNull(pOut);
   }else{
@@ -53871,8 +54089,9 @@ case OP_Not: {                /* same as TK_NOT, in1 */
 ** ones-complement of the P1 value into register P2.  If P1 holds
 ** a NULL then store a NULL in P2.
 */
-case OP_BitNot: {             /* same as TK_BITNOT, in1 */
-  pOut = &p->aMem[pOp->p2];
+case OP_BitNot: {             /* same as TK_BITNOT, in1, out2 */
+  pIn1 = &aMem[pOp->p1];
+  pOut = &aMem[pOp->p2];
   if( pIn1->flags & MEM_Null ){
     sqlite3VdbeMemSetNull(pOut);
   }else{
@@ -53898,6 +54117,7 @@ case OP_IfNot: {            /* jump, in1 */
 #if 0  /* local variables moved into u.al */
   int c;
 #endif /* local variables moved into u.al */
+  pIn1 = &aMem[pOp->p1];
   if( pIn1->flags & MEM_Null ){
     u.al.c = pOp->p3;
   }else{
@@ -53919,6 +54139,7 @@ case OP_IfNot: {            /* jump, in1 */
 ** Jump to P2 if the value in register P1 is NULL.
 */
 case OP_IsNull: {            /* same as TK_ISNULL, jump, in1 */
+  pIn1 = &aMem[pOp->p1];
   if( (pIn1->flags & MEM_Null)!=0 ){
     pc = pOp->p2 - 1;
   }
@@ -53930,6 +54151,7 @@ case OP_IsNull: {            /* same as TK_ISNULL, jump, in1 */
 ** Jump to P2 if the value in register P1 is not NULL.  
 */
 case OP_NotNull: {            /* same as TK_NOTNULL, jump, in1 */
+  pIn1 = &aMem[pOp->p1];
   if( (pIn1->flags & MEM_Null)==0 ){
     pc = pOp->p2 - 1;
   }
@@ -53988,7 +54210,7 @@ case OP_Column: {
   memset(&u.am.sMem, 0, sizeof(u.am.sMem));
   assert( u.am.p1<p->nCursor );
   assert( pOp->p3>0 && pOp->p3<=p->nMem );
-  u.am.pDest = &p->aMem[pOp->p3];
+  u.am.pDest = &aMem[pOp->p3];
   MemSetTypeFlag(u.am.pDest, MEM_Null);
   u.am.zRec = 0;
 
@@ -54034,7 +54256,7 @@ case OP_Column: {
       assert( rc==SQLITE_OK );   /* DataSize() cannot fail */
     }
   }else if( u.am.pC->pseudoTableReg>0 ){
-    u.am.pReg = &p->aMem[u.am.pC->pseudoTableReg];
+    u.am.pReg = &aMem[u.am.pC->pseudoTableReg];
     assert( u.am.pReg->flags & MEM_Blob );
     u.am.payloadSize = u.am.pReg->n;
     u.am.zRec = u.am.pReg->z;
@@ -54246,18 +54468,19 @@ op_column_out:
 */
 case OP_Affinity: {
 #if 0  /* local variables moved into u.an */
-  char *zAffinity;   /* The affinity to be applied */
-  Mem *pData0;       /* First register to which to apply affinity */
-  Mem *pLast;        /* Last register to which to apply affinity */
-  Mem *pRec;         /* Current register */
+  const char *zAffinity;   /* The affinity to be applied */
+  char cAff;               /* A single character of affinity */
 #endif /* local variables moved into u.an */
 
   u.an.zAffinity = pOp->p4.z;
-  u.an.pData0 = &p->aMem[pOp->p1];
-  u.an.pLast = &u.an.pData0[pOp->p2-1];
-  for(u.an.pRec=u.an.pData0; u.an.pRec<=u.an.pLast; u.an.pRec++){
-    ExpandBlob(u.an.pRec);
-    applyAffinity(u.an.pRec, u.an.zAffinity[u.an.pRec-u.an.pData0], encoding);
+  assert( u.an.zAffinity!=0 );
+  assert( u.an.zAffinity[pOp->p2]==0 );
+  pIn1 = &aMem[pOp->p1];
+  while( (u.an.cAff = *(u.an.zAffinity++))!=0 ){
+    assert( pIn1 <= &p->aMem[p->nMem] );
+    ExpandBlob(pIn1);
+    applyAffinity(pIn1, u.an.cAff, encoding);
+    pIn1++;
   }
   break;
 }
@@ -54321,7 +54544,7 @@ case OP_MakeRecord: {
   u.ao.nField = pOp->p1;
   u.ao.zAffinity = pOp->p4.z;
   assert( u.ao.nField>0 && pOp->p2>0 && pOp->p2+u.ao.nField<=p->nMem+1 );
-  u.ao.pData0 = &p->aMem[u.ao.nField];
+  u.ao.pData0 = &aMem[u.ao.nField];
   u.ao.nField = pOp->p2;
   u.ao.pLast = &u.ao.pData0[u.ao.nField-1];
   u.ao.file_format = p->minWriteFileFormat;
@@ -54365,7 +54588,7 @@ case OP_MakeRecord: {
   ** sqlite3VdbeMemGrow() could clobber the value before it is used).
   */
   assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 );
-  pOut = &p->aMem[pOp->p3];
+  pOut = &aMem[pOp->p3];
   if( sqlite3VdbeMemGrow(pOut, (int)u.ao.nByte, 0) ){
     goto no_mem;
   }
@@ -54414,7 +54637,6 @@ case OP_Count: {         /* out2-prerelease */
   }else{
     u.ap.nEntry = 0;
   }
-  pOut->flags = MEM_Int;
   pOut->u.i = u.ap.nEntry;
   break;
 }
@@ -54743,7 +54965,6 @@ case OP_ReadCookie: {               /* out2-prerelease */
 
   sqlite3BtreeGetMeta(db->aDb[u.at.iDb].pBt, u.at.iCookie, (u32 *)&u.at.iMeta);
   pOut->u.i = u.at.iMeta;
-  MemSetTypeFlag(pOut, MEM_Int);
   break;
 }
 
@@ -54766,6 +54987,7 @@ case OP_SetCookie: {       /* in3 */
   assert( (p->btreeMask & (1<<pOp->p1))!=0 );
   u.au.pDb = &db->aDb[pOp->p1];
   assert( u.au.pDb->pBt!=0 );
+  pIn3 = &aMem[pOp->p3];
   sqlite3VdbeMemIntegerify(pIn3);
   /* See note about index shifting on OP_ReadCookie */
   rc = sqlite3BtreeUpdateMeta(u.au.pDb->pBt, pOp->p2, (int)pIn3->u.i);
@@ -54781,6 +55003,7 @@ case OP_SetCookie: {       /* in3 */
     /* Invalidate all prepared statements whenever the TEMP database
     ** schema is changed.  Ticket #1644 */
     sqlite3ExpirePreparedStatements(db);
+    p->expired = 0;
   }
   break;
 }
@@ -54902,6 +55125,11 @@ case OP_OpenWrite: {
   Db *pDb;
 #endif /* local variables moved into u.aw */
 
+  if( p->expired ){
+    rc = SQLITE_ABORT;
+    break;
+  }
+
   u.aw.nField = 0;
   u.aw.pKeyInfo = 0;
   u.aw.p2 = pOp->p2;
@@ -54922,7 +55150,7 @@ case OP_OpenWrite: {
   if( pOp->p5 ){
     assert( u.aw.p2>0 );
     assert( u.aw.p2<=p->nMem );
-    pIn2 = &p->aMem[u.aw.p2];
+    pIn2 = &aMem[u.aw.p2];
     sqlite3VdbeMemIntegerify(pIn2);
     u.aw.p2 = (int)pIn2->u.i;
     /* The u.aw.p2 value always comes from a prior OP_CreateTable opcode and
@@ -55144,6 +55372,9 @@ case OP_SeekGt: {       /* jump, in3 */
   u.az.pC = p->apCsr[pOp->p1];
   assert( u.az.pC!=0 );
   assert( u.az.pC->pseudoTableReg==0 );
+  assert( OP_SeekLe == OP_SeekLt+1 );
+  assert( OP_SeekGe == OP_SeekLt+2 );
+  assert( OP_SeekGt == OP_SeekLt+3 );
   if( u.az.pC->pCursor!=0 ){
     u.az.oc = pOp->opcode;
     u.az.pC->nullRow = 0;
@@ -55151,6 +55382,7 @@ case OP_SeekGt: {       /* jump, in3 */
       /* The input value in P3 might be of any type: integer, real, string,
       ** blob, or NULL.  But it needs to be an integer before we can do
       ** the seek, so covert it. */
+      pIn3 = &aMem[pOp->p3];
       applyNumericAffinity(pIn3);
       u.az.iKey = sqlite3VdbeIntValue(pIn3);
       u.az.pC->rowidIsValid = 0;
@@ -55173,12 +55405,12 @@ case OP_SeekGt: {       /* jump, in3 */
           ** integer. */
           u.az.res = 1;
           if( pIn3->r<0 ){
-            if( u.az.oc==OP_SeekGt || u.az.oc==OP_SeekGe ){
+            if( u.az.oc>=OP_SeekGe ){  assert( u.az.oc==OP_SeekGe || u.az.oc==OP_SeekGt );
               rc = sqlite3BtreeFirst(u.az.pC->pCursor, &u.az.res);
               if( rc!=SQLITE_OK ) goto abort_due_to_error;
             }
           }else{
-            if( u.az.oc==OP_SeekLt || u.az.oc==OP_SeekLe ){
+            if( u.az.oc<=OP_SeekLe ){  assert( u.az.oc==OP_SeekLt || u.az.oc==OP_SeekLe );
               rc = sqlite3BtreeLast(u.az.pC->pCursor, &u.az.res);
               if( rc!=SQLITE_OK ) goto abort_due_to_error;
             }
@@ -55210,12 +55442,22 @@ case OP_SeekGt: {       /* jump, in3 */
       assert( u.az.nField>0 );
       u.az.r.pKeyInfo = u.az.pC->pKeyInfo;
       u.az.r.nField = (u16)u.az.nField;
-      if( u.az.oc==OP_SeekGt || u.az.oc==OP_SeekLe ){
-        u.az.r.flags = UNPACKED_INCRKEY;
-      }else{
-        u.az.r.flags = 0;
-      }
-      u.az.r.aMem = &p->aMem[pOp->p3];
+
+      /* The next line of code computes as follows, only faster:
+      **   if( u.az.oc==OP_SeekGt || u.az.oc==OP_SeekLe ){
+      **     u.az.r.flags = UNPACKED_INCRKEY;
+      **   }else{
+      **     u.az.r.flags = 0;
+      **   }
+      */
+      u.az.r.flags = (u16)(UNPACKED_INCRKEY * (1 & (u.az.oc - OP_SeekLt)));
+      assert( u.az.oc!=OP_SeekGt || u.az.r.flags==UNPACKED_INCRKEY );
+      assert( u.az.oc!=OP_SeekLe || u.az.r.flags==UNPACKED_INCRKEY );
+      assert( u.az.oc!=OP_SeekGe || u.az.r.flags==0 );
+      assert( u.az.oc!=OP_SeekLt || u.az.r.flags==0 );
+
+      u.az.r.aMem = &aMem[pOp->p3];
+      ExpandBlob(u.az.r.aMem);
       rc = sqlite3BtreeMovetoUnpacked(u.az.pC->pCursor, &u.az.r, 0, 0, &u.az.res);
       if( rc!=SQLITE_OK ){
         goto abort_due_to_error;
@@ -55227,7 +55469,7 @@ case OP_SeekGt: {       /* jump, in3 */
 #ifdef SQLITE_TEST
     sqlite3_search_count++;
 #endif
-    if( u.az.oc==OP_SeekGe || u.az.oc==OP_SeekGt ){
+    if( u.az.oc>=OP_SeekGe ){  assert( u.az.oc==OP_SeekGe || u.az.oc==OP_SeekGt );
       if( u.az.res<0 || (u.az.res==0 && u.az.oc==OP_SeekGt) ){
         rc = sqlite3BtreeNext(u.az.pC->pCursor, &u.az.res);
         if( rc!=SQLITE_OK ) goto abort_due_to_error;
@@ -55282,6 +55524,7 @@ case OP_Seek: {    /* in2 */
   if( ALWAYS(u.ba.pC->pCursor!=0) ){
     assert( u.ba.pC->isTable );
     u.ba.pC->nullRow = 0;
+    pIn2 = &aMem[pOp->p2];
     u.ba.pC->movetoTarget = sqlite3VdbeIntValue(pIn2);
     u.ba.pC->rowidIsValid = 0;
     u.ba.pC->deferredMoveto = 1;
@@ -55290,33 +55533,27 @@ case OP_Seek: {    /* in2 */
 }
   
 
-/* Opcode: Found P1 P2 P3 * *
-**
-** Register P3 holds a blob constructed by MakeRecord.  P1 is an index.
-** If an entry that matches the value in register p3 exists in P1 then
-** jump to P2.  If the P3 value does not match any entry in P1
-** then fall thru.  The P1 cursor is left pointing at the matching entry
-** if it exists.
-**
-** This instruction is used to implement the IN operator where the
-** left-hand side is a SELECT statement.  P1 may be a true index, or it
-** may be a temporary index that holds the results of the SELECT
-** statement.   This instruction is also used to implement the
-** DISTINCT keyword in SELECT statements.
+/* Opcode: Found P1 P2 P3 P4 *
 **
-** This instruction checks if index P1 contains a record for which 
-** the first N serialized values exactly match the N serialized values
-** in the record in register P3, where N is the total number of values in
-** the P3 record (the P3 record is a prefix of the P1 record). 
+** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If
+** P4>0 then register P3 is the first of P4 registers that form an unpacked
+** record.
 **
-** See also: NotFound, IsUnique, NotExists
+** Cursor P1 is on an index btree.  If the record identified by P3 and P4
+** is a prefix of any entry in P1 then a jump is made to P2 and
+** P1 is left pointing at the matching entry.
 */
-/* Opcode: NotFound P1 P2 P3 * *
+/* Opcode: NotFound P1 P2 P3 P4 *
 **
-** Register P3 holds a blob constructed by MakeRecord.  P1 is
-** an index.  If no entry exists in P1 that matches the blob then jump
-** to P2.  If an entry does existing, fall through.  The cursor is left
-** pointing to the entry that matches.
+** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If
+** P4>0 then register P3 is the first of P4 registers that form an unpacked
+** record.
+** 
+** Cursor P1 is on an index btree.  If the record identified by P3 and P4
+** is not the prefix of any entry in P1 then a jump is made to P2.  If P1 
+** does contain an entry whose prefix matches the P3/P4 record then control
+** falls through to the next instruction and P1 is left pointing at the
+** matching entry.
 **
 ** See also: Found, NotExists, IsUnique
 */
@@ -55327,6 +55564,7 @@ case OP_Found: {        /* jump, in3 */
   VdbeCursor *pC;
   int res;
   UnpackedRecord *pIdxKey;
+  UnpackedRecord r;
   char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7];
 #endif /* local variables moved into u.bb */
 
@@ -55336,23 +55574,33 @@ case OP_Found: {        /* jump, in3 */
 
   u.bb.alreadyExists = 0;
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
+  assert( pOp->p4type==P4_INT32 );
   u.bb.pC = p->apCsr[pOp->p1];
   assert( u.bb.pC!=0 );
+  pIn3 = &aMem[pOp->p3];
   if( ALWAYS(u.bb.pC->pCursor!=0) ){
 
     assert( u.bb.pC->isTable==0 );
-    assert( pIn3->flags & MEM_Blob );
-    ExpandBlob(pIn3);
-    u.bb.pIdxKey = sqlite3VdbeRecordUnpack(u.bb.pC->pKeyInfo, pIn3->n, pIn3->z,
-                                      u.bb.aTempRec, sizeof(u.bb.aTempRec));
-    if( u.bb.pIdxKey==0 ){
-      goto no_mem;
-    }
-    if( pOp->opcode==OP_Found ){
+    if( pOp->p4.i>0 ){
+      u.bb.r.pKeyInfo = u.bb.pC->pKeyInfo;
+      u.bb.r.nField = (u16)pOp->p4.i;
+      u.bb.r.aMem = pIn3;
+      u.bb.r.flags = UNPACKED_PREFIX_MATCH;
+      u.bb.pIdxKey = &u.bb.r;
+    }else{
+      assert( pIn3->flags & MEM_Blob );
+      ExpandBlob(pIn3);
+      u.bb.pIdxKey = sqlite3VdbeRecordUnpack(u.bb.pC->pKeyInfo, pIn3->n, pIn3->z,
+                                        u.bb.aTempRec, sizeof(u.bb.aTempRec));
+      if( u.bb.pIdxKey==0 ){
+        goto no_mem;
+      }
       u.bb.pIdxKey->flags |= UNPACKED_PREFIX_MATCH;
     }
     rc = sqlite3BtreeMovetoUnpacked(u.bb.pC->pCursor, u.bb.pIdxKey, 0, 0, &u.bb.res);
-    sqlite3VdbeDeleteUnpackedRecord(u.bb.pIdxKey);
+    if( pOp->p4.i==0 ){
+      sqlite3VdbeDeleteUnpackedRecord(u.bb.pIdxKey);
+    }
     if( rc!=SQLITE_OK ){
       break;
     }
@@ -55370,9 +55618,10 @@ case OP_Found: {        /* jump, in3 */
 
 /* Opcode: IsUnique P1 P2 P3 P4 *
 **
-** Cursor P1 is open on an index.  So it has no data and its key consists 
-** of a record generated by OP_MakeRecord where the last field is the 
-** rowid of the entry that the index refers to.
+** Cursor P1 is open on an index b-tree - that is to say, a btree which
+** no data and where the key are records generated by OP_MakeRecord with
+** the list field being the integer ROWID of the entry that the index
+** entry refers to.
 **
 ** The P3 register contains an integer record number. Call this record 
 ** number R. Register P4 is the first in a set of N contiguous registers
@@ -55399,12 +55648,13 @@ case OP_IsUnique: {        /* jump, in3 */
   VdbeCursor *pCx;
   BtCursor *pCrsr;
   u16 nField;
-  Mem *aMem;
+  Mem *aMx;
   UnpackedRecord r;                  /* B-Tree index search key */
   i64 R;                             /* Rowid stored in register P3 */
 #endif /* local variables moved into u.bc */
 
-  u.bc.aMem = &p->aMem[pOp->p4.i];
+  pIn3 = &aMem[pOp->p3];
+  u.bc.aMx = &aMem[pOp->p4.i];
   /* Assert that the values of parameters P1 and P4 are in range. */
   assert( pOp->p4type==P4_INT32 );
   assert( pOp->p4.i>0 && pOp->p4.i<=p->nMem );
@@ -55420,20 +55670,20 @@ case OP_IsUnique: {        /* jump, in3 */
   /* If any of the values are NULL, take the jump. */
   u.bc.nField = u.bc.pCx->pKeyInfo->nField;
   for(u.bc.ii=0; u.bc.ii<u.bc.nField; u.bc.ii++){
-    if( u.bc.aMem[u.bc.ii].flags & MEM_Null ){
+    if( u.bc.aMx[u.bc.ii].flags & MEM_Null ){
       pc = pOp->p2 - 1;
       u.bc.pCrsr = 0;
       break;
     }
   }
-  assert( (u.bc.aMem[u.bc.nField].flags & MEM_Null)==0 );
+  assert( (u.bc.aMx[u.bc.nField].flags & MEM_Null)==0 );
 
   if( u.bc.pCrsr!=0 ){
     /* Populate the index search key. */
     u.bc.r.pKeyInfo = u.bc.pCx->pKeyInfo;
     u.bc.r.nField = u.bc.nField + 1;
     u.bc.r.flags = UNPACKED_PREFIX_SEARCH;
-    u.bc.r.aMem = u.bc.aMem;
+    u.bc.r.aMem = u.bc.aMx;
 
     /* Extract the value of u.bc.R from register P3. */
     sqlite3VdbeMemIntegerify(pIn3);
@@ -55474,6 +55724,7 @@ case OP_NotExists: {        /* jump, in3 */
   u64 iKey;
 #endif /* local variables moved into u.bd */
 
+  pIn3 = &aMem[pOp->p3];
   assert( pIn3->flags & MEM_Int );
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
   u.bd.pC = p->apCsr[pOp->p1];
@@ -55517,7 +55768,6 @@ case OP_Sequence: {           /* out2-prerelease */
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
   assert( p->apCsr[pOp->p1]!=0 );
   pOut->u.i = p->apCsr[pOp->p1]->seqCount++;
-  MemSetTypeFlag(pOut, MEM_Int);
   break;
 }
 
@@ -55588,7 +55838,7 @@ case OP_NewRowid: {           /* out2-prerelease */
           goto abort_due_to_error;
         }
         if( u.be.res ){
-          u.be.v = 1;
+          u.be.v = 1;   /* IMP: R-61914-48074 */
         }else{
           assert( sqlite3BtreeCursorIsValid(u.be.pC->pCursor) );
           rc = sqlite3BtreeKeySize(u.be.pC->pCursor, &u.be.v);
@@ -55596,7 +55846,7 @@ case OP_NewRowid: {           /* out2-prerelease */
           if( u.be.v==MAX_ROWID ){
             u.be.pC->useRandomRowid = 1;
           }else{
-            u.be.v++;
+            u.be.v++;   /* IMP: R-29538-34987 */
           }
         }
       }
@@ -55613,14 +55863,14 @@ case OP_NewRowid: {           /* out2-prerelease */
         }else{
           /* Assert that P3 is a valid memory cell. */
           assert( pOp->p3<=p->nMem );
-          u.be.pMem = &p->aMem[pOp->p3];
+          u.be.pMem = &aMem[pOp->p3];
         }
 
         REGISTER_TRACE(pOp->p3, u.be.pMem);
         sqlite3VdbeMemIntegerify(u.be.pMem);
         assert( (u.be.pMem->flags & MEM_Int)!=0 );  /* mem(P3) holds an integer */
         if( u.be.pMem->u.i==MAX_ROWID || u.be.pC->useRandomRowid ){
-          rc = SQLITE_FULL;
+          rc = SQLITE_FULL;   /* IMP: R-12275-61338 */
           goto abort_due_to_error;
         }
         if( u.be.v<u.be.pMem->u.i+1 ){
@@ -55633,6 +55883,11 @@ 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
+      ** largest possible integer (9223372036854775807) then the database
+      ** engine starts picking 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. */
       u.be.v = db->lastRowid;
@@ -55648,7 +55903,7 @@ case OP_NewRowid: {           /* out2-prerelease */
         u.be.cnt++;
       }while( u.be.cnt<100 && rc==SQLITE_OK && u.be.res==0 );
       if( rc==SQLITE_OK && u.be.res==0 ){
-        rc = SQLITE_FULL;
+        rc = SQLITE_FULL;   /* IMP: R-38219-53002 */
         goto abort_due_to_error;
       }
     }
@@ -55656,7 +55911,6 @@ case OP_NewRowid: {           /* out2-prerelease */
     u.be.pC->deferredMoveto = 0;
     u.be.pC->cacheStatus = CACHE_STALE;
   }
-  MemSetTypeFlag(pOut, MEM_Int);
   pOut->u.i = u.be.v;
   break;
 }
@@ -55700,7 +55954,13 @@ case OP_NewRowid: {           /* out2-prerelease */
 ** This instruction only works on tables.  The equivalent instruction
 ** for indices is OP_IdxInsert.
 */
-case OP_Insert: {
+/* Opcode: InsertInt P1 P2 P3 P4 P5
+**
+** This works exactly like OP_Insert except that the key is the
+** integer value P3, not the value of the integer stored in register P3.
+*/
+case OP_Insert: 
+case OP_InsertInt: {
 #if 0  /* local variables moved into u.bf */
   Mem *pData;       /* MEM cell holding data for the record to be inserted */
   Mem *pKey;        /* MEM cell holding key  for the record */
@@ -55713,21 +55973,27 @@ case OP_Insert: {
   int op;           /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */
 #endif /* local variables moved into u.bf */
 
-  u.bf.pData = &p->aMem[pOp->p2];
-  u.bf.pKey = &p->aMem[pOp->p3];
+  u.bf.pData = &aMem[pOp->p2];
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
   u.bf.pC = p->apCsr[pOp->p1];
   assert( u.bf.pC!=0 );
   assert( u.bf.pC->pCursor!=0 );
   assert( u.bf.pC->pseudoTableReg==0 );
-  assert( u.bf.pKey->flags & MEM_Int );
   assert( u.bf.pC->isTable );
   REGISTER_TRACE(pOp->p2, u.bf.pData);
-  REGISTER_TRACE(pOp->p3, u.bf.pKey);
 
-  u.bf.iKey = u.bf.pKey->u.i;
+  if( pOp->opcode==OP_Insert ){
+    u.bf.pKey = &aMem[pOp->p3];
+    assert( u.bf.pKey->flags & MEM_Int );
+    REGISTER_TRACE(pOp->p3, u.bf.pKey);
+    u.bf.iKey = u.bf.pKey->u.i;
+  }else{
+    assert( pOp->opcode==OP_InsertInt );
+    u.bf.iKey = pOp->p3;
+  }
+
   if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
-  if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = u.bf.pKey->u.i;
+  if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = u.bf.iKey;
   if( u.bf.pData->flags & MEM_Null ){
     u.bf.pData->z = 0;
     u.bf.pData->n = 0;
@@ -55869,7 +56135,7 @@ case OP_RowData: {
   i64 n64;
 #endif /* local variables moved into u.bh */
 
-  pOut = &p->aMem[pOp->p2];
+  pOut = &aMem[pOp->p2];
 
   /* Note that RowKey and RowData are really exactly the same instruction */
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -55944,7 +56210,7 @@ case OP_Rowid: {                 /* out2-prerelease */
   assert( u.bi.pC!=0 );
   assert( u.bi.pC->pseudoTableReg==0 );
   if( u.bi.pC->nullRow ){
-    /* Do nothing so that reg[P2] remains NULL */
+    pOut->flags = MEM_Null;
     break;
   }else if( u.bi.pC->deferredMoveto ){
     u.bi.v = u.bi.pC->movetoTarget;
@@ -55972,7 +56238,6 @@ case OP_Rowid: {                 /* out2-prerelease */
     }
   }
   pOut->u.i = u.bi.v;
-  MemSetTypeFlag(pOut, MEM_Int);
   break;
 }
 
@@ -56167,6 +56432,7 @@ case OP_IdxInsert: {        /* in2 */
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
   u.bn.pC = p->apCsr[pOp->p1];
   assert( u.bn.pC!=0 );
+  pIn2 = &aMem[pOp->p2];
   assert( pIn2->flags & MEM_Blob );
   u.bn.pCrsr = u.bn.pC->pCursor;
   if( ALWAYS(u.bn.pCrsr!=0) ){
@@ -56209,7 +56475,7 @@ case OP_IdxDelete: {
     u.bo.r.pKeyInfo = u.bo.pC->pKeyInfo;
     u.bo.r.nField = (u16)pOp->p3;
     u.bo.r.flags = 0;
-    u.bo.r.aMem = &p->aMem[pOp->p2];
+    u.bo.r.aMem = &aMem[pOp->p2];
     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);
@@ -56239,6 +56505,7 @@ case OP_IdxRowid: {              /* out2-prerelease */
   u.bp.pC = p->apCsr[pOp->p1];
   assert( u.bp.pC!=0 );
   u.bp.pCrsr = u.bp.pC->pCursor;
+  pOut->flags = MEM_Null;
   if( ALWAYS(u.bp.pCrsr!=0) ){
     rc = sqlite3VdbeCursorMoveto(u.bp.pC);
     if( NEVER(rc) ) goto abort_due_to_error;
@@ -56249,8 +56516,8 @@ case OP_IdxRowid: {              /* out2-prerelease */
       if( rc!=SQLITE_OK ){
         goto abort_due_to_error;
       }
-      MemSetTypeFlag(pOut, MEM_Int);
       pOut->u.i = u.bp.rowid;
+      pOut->flags = MEM_Int;
     }
   }
   break;
@@ -56282,8 +56549,8 @@ case OP_IdxRowid: {              /* out2-prerelease */
 ** If P5 is non-zero then the key value is increased by an epsilon prior 
 ** to the comparison.  This makes the opcode work like IdxLE.
 */
-case OP_IdxLT:          /* jump, in3 */
-case OP_IdxGE: {        /* jump, in3 */
+case OP_IdxLT:          /* jump */
+case OP_IdxGE: {        /* jump */
 #if 0  /* local variables moved into u.bq */
   VdbeCursor *pC;
   int res;
@@ -56304,7 +56571,7 @@ case OP_IdxGE: {        /* jump, in3 */
     }else{
       u.bq.r.flags = UNPACKED_IGNORE_ROWID;
     }
-    u.bq.r.aMem = &p->aMem[pOp->p3];
+    u.bq.r.aMem = &aMem[pOp->p3];
     rc = sqlite3VdbeIdxKeyCompare(u.bq.pC, &u.bq.r, &u.bq.res);
     if( pOp->opcode==OP_IdxLT ){
       u.bq.res = -u.bq.res;
@@ -56356,6 +56623,7 @@ case OP_Destroy: {     /* out2-prerelease */
 #else
   u.br.iCnt = db->activeVdbeCnt;
 #endif
+  pOut->flags = MEM_Null;
   if( u.br.iCnt>1 ){
     rc = SQLITE_LOCKED;
     p->errorAction = OE_Abort;
@@ -56364,11 +56632,12 @@ case OP_Destroy: {     /* out2-prerelease */
     assert( u.br.iCnt==1 );
     assert( (p->btreeMask & (1<<u.br.iDb))!=0 );
     rc = sqlite3BtreeDropTable(db->aDb[u.br.iDb].pBt, pOp->p1, &u.br.iMoved);
-    MemSetTypeFlag(pOut, MEM_Int);
+    pOut->flags = MEM_Int;
     pOut->u.i = u.br.iMoved;
 #ifndef SQLITE_OMIT_AUTOVACUUM
     if( rc==SQLITE_OK && u.br.iMoved!=0 ){
       sqlite3RootPageMoved(&db->aDb[u.br.iDb], u.br.iMoved, pOp->p1);
+      resetSchemaOnFault = 1;
     }
 #endif
   }
@@ -56406,7 +56675,7 @@ case OP_Clear: {
   if( pOp->p3 ){
     p->nChange += u.bs.nChange;
     if( pOp->p3>0 ){
-      p->aMem[pOp->p3].u.i += u.bs.nChange;
+      aMem[pOp->p3].u.i += u.bs.nChange;
     }
   }
   break;
@@ -56455,7 +56724,6 @@ case OP_CreateTable: {          /* out2-prerelease */
   }
   rc = sqlite3BtreeCreateTable(u.bt.pDb->pBt, &u.bt.pgno, u.bt.flags);
   pOut->u.i = u.bt.pgno;
-  MemSetTypeFlag(pOut, MEM_Int);
   break;
 }
 
@@ -56622,10 +56890,10 @@ case OP_IntegrityCk: {
   u.bv.aRoot = sqlite3DbMallocRaw(db, sizeof(int)*(u.bv.nRoot+1) );
   if( u.bv.aRoot==0 ) goto no_mem;
   assert( pOp->p3>0 && pOp->p3<=p->nMem );
-  u.bv.pnErr = &p->aMem[pOp->p3];
+  u.bv.pnErr = &aMem[pOp->p3];
   assert( (u.bv.pnErr->flags & MEM_Int)!=0 );
   assert( (u.bv.pnErr->flags & (MEM_Str|MEM_Blob))==0 );
-  pIn1 = &p->aMem[pOp->p1];
+  pIn1 = &aMem[pOp->p1];
   for(u.bv.j=0; u.bv.j<u.bv.nRoot; u.bv.j++){
     u.bv.aRoot[u.bv.j] = (int)sqlite3VdbeIntValue(&pIn1[u.bv.j]);
   }
@@ -56657,21 +56925,15 @@ case OP_IntegrityCk: {
 **
 ** An assertion fails if P2 is not an integer.
 */
-case OP_RowSetAdd: {       /* in2 */
-#if 0  /* local variables moved into u.bw */
-  Mem *pIdx;
-  Mem *pVal;
-#endif /* local variables moved into u.bw */
-  assert( pOp->p1>0 && pOp->p1<=p->nMem );
-  u.bw.pIdx = &p->aMem[pOp->p1];
-  assert( pOp->p2>0 && pOp->p2<=p->nMem );
-  u.bw.pVal = &p->aMem[pOp->p2];
-  assert( (u.bw.pVal->flags & MEM_Int)!=0 );
-  if( (u.bw.pIdx->flags & MEM_RowSet)==0 ){
-    sqlite3VdbeMemSetRowSet(u.bw.pIdx);
-    if( (u.bw.pIdx->flags & MEM_RowSet)==0 ) goto no_mem;
-  }
-  sqlite3RowSetInsert(u.bw.pIdx->u.pRowSet, u.bw.pVal->u.i);
+case OP_RowSetAdd: {       /* in1, in2 */
+  pIn1 = &aMem[pOp->p1];
+  pIn2 = &aMem[pOp->p2];
+  assert( (pIn2->flags & MEM_Int)!=0 );
+  if( (pIn1->flags & MEM_RowSet)==0 ){
+    sqlite3VdbeMemSetRowSet(pIn1);
+    if( (pIn1->flags & MEM_RowSet)==0 ) goto no_mem;
+  }
+  sqlite3RowSetInsert(pIn1->u.pRowSet, pIn2->u.i);
   break;
 }
 
@@ -56681,25 +56943,21 @@ case OP_RowSetAdd: {       /* in2 */
 ** register P3.  Or, if boolean index P1 is initially empty, leave P3
 ** unchanged and jump to instruction P2.
 */
-case OP_RowSetRead: {       /* jump, out3 */
-#if 0  /* local variables moved into u.bx */
-  Mem *pIdx;
+case OP_RowSetRead: {       /* jump, in1, out3 */
+#if 0  /* local variables moved into u.bw */
   i64 val;
-#endif /* local variables moved into u.bx */
-  assert( pOp->p1>0 && pOp->p1<=p->nMem );
+#endif /* local variables moved into u.bw */
   CHECK_FOR_INTERRUPT;
-  u.bx.pIdx = &p->aMem[pOp->p1];
-  pOut = &p->aMem[pOp->p3];
-  if( (u.bx.pIdx->flags & MEM_RowSet)==0
-   || sqlite3RowSetNext(u.bx.pIdx->u.pRowSet, &u.bx.val)==0
+  pIn1 = &aMem[pOp->p1];
+  if( (pIn1->flags & MEM_RowSet)==0
+   || sqlite3RowSetNext(pIn1->u.pRowSet, &u.bw.val)==0
   ){
     /* The boolean index is empty */
-    sqlite3VdbeMemSetNull(u.bx.pIdx);
+    sqlite3VdbeMemSetNull(pIn1);
     pc = pOp->p2 - 1;
   }else{
     /* A value was pulled from the index */
-    assert( pOp->p3>0 && pOp->p3<=p->nMem );
-    sqlite3VdbeMemSetInt64(pOut, u.bx.val);
+    sqlite3VdbeMemSetInt64(&aMem[pOp->p3], u.bw.val);
   }
   break;
 }
@@ -56728,12 +56986,14 @@ case OP_RowSetRead: {       /* jump, out3 */
 ** inserted as part of some other set).
 */
 case OP_RowSetTest: {                     /* jump, in1, in3 */
-#if 0  /* local variables moved into u.by */
+#if 0  /* local variables moved into u.bx */
   int iSet;
   int exists;
-#endif /* local variables moved into u.by */
+#endif /* local variables moved into u.bx */
 
-  u.by.iSet = pOp->p4.i;
+  pIn1 = &aMem[pOp->p1];
+  pIn3 = &aMem[pOp->p3];
+  u.bx.iSet = pOp->p4.i;
   assert( pIn3->flags&MEM_Int );
 
   /* If there is anything other than a rowset object in memory cell P1,
@@ -56745,17 +57005,17 @@ case OP_RowSetTest: {                     /* jump, in1, in3 */
   }
 
   assert( pOp->p4type==P4_INT32 );
-  assert( u.by.iSet==-1 || u.by.iSet>=0 );
-  if( u.by.iSet ){
-    u.by.exists = sqlite3RowSetTest(pIn1->u.pRowSet,
-                               (u8)(u.by.iSet>=0 ? u.by.iSet & 0xf : 0xff),
+  assert( u.bx.iSet==-1 || u.bx.iSet>=0 );
+  if( u.bx.iSet ){
+    u.bx.exists = sqlite3RowSetTest(pIn1->u.pRowSet,
+                               (u8)(u.bx.iSet>=0 ? u.bx.iSet & 0xf : 0xff),
                                pIn3->u.i);
-    if( u.by.exists ){
+    if( u.bx.exists ){
       pc = pOp->p2 - 1;
       break;
     }
   }
-  if( u.by.iSet>=0 ){
+  if( u.bx.iSet>=0 ){
     sqlite3RowSetInsert(pIn1->u.pRowSet, pIn3->u.i);
   }
   break;
@@ -56778,7 +57038,7 @@ case OP_RowSetTest: {                     /* jump, in1, in3 */
 ** P4 is a pointer to the VM containing the trigger program.
 */
 case OP_Program: {        /* jump */
-#if 0  /* local variables moved into u.bz */
+#if 0  /* local variables moved into u.by */
   int nMem;               /* Number of memory registers for sub-program */
   int nByte;              /* Bytes of runtime space required for sub-program */
   Mem *pRt;               /* Register to allocate runtime space */
@@ -56787,11 +57047,11 @@ case OP_Program: {        /* jump */
   VdbeFrame *pFrame;      /* New vdbe frame to execute in */
   SubProgram *pProgram;   /* Sub-program to execute */
   void *t;                /* Token identifying trigger */
-#endif /* local variables moved into u.bz */
+#endif /* local variables moved into u.by */
 
-  u.bz.pProgram = pOp->p4.pProgram;
-  u.bz.pRt = &p->aMem[pOp->p3];
-  assert( u.bz.pProgram->nOp>0 );
+  u.by.pProgram = pOp->p4.pProgram;
+  u.by.pRt = &aMem[pOp->p3];
+  assert( u.by.pProgram->nOp>0 );
 
   /* If the p5 flag is clear, then recursive invocation of triggers is
   ** disabled for backwards compatibility (p5 is set if this sub-program
@@ -56805,9 +57065,9 @@ case OP_Program: {        /* jump */
   ** single trigger all have the same value for the SubProgram.token
   ** variable.  */
   if( pOp->p5 ){
-    u.bz.t = u.bz.pProgram->token;
-    for(u.bz.pFrame=p->pFrame; u.bz.pFrame && u.bz.pFrame->token!=u.bz.t; u.bz.pFrame=u.bz.pFrame->pParent);
-    if( u.bz.pFrame ) break;
+    u.by.t = u.by.pProgram->token;
+    for(u.by.pFrame=p->pFrame; u.by.pFrame && u.by.pFrame->token!=u.by.t; u.by.pFrame=u.by.pFrame->pParent);
+    if( u.by.pFrame ) break;
   }
 
   if( p->nFrame>=db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){
@@ -56816,64 +57076,64 @@ case OP_Program: {        /* jump */
     break;
   }
 
-  /* Register u.bz.pRt is used to store the memory required to save the state
+  /* Register u.by.pRt is used to store the memory required to save the state
   ** of the current program, and the memory required at runtime to execute
-  ** the trigger program. If this trigger has been fired before, then u.bz.pRt
+  ** the trigger program. If this trigger has been fired before, then u.by.pRt
   ** is already allocated. Otherwise, it must be initialized.  */
-  if( (u.bz.pRt->flags&MEM_Frame)==0 ){
+  if( (u.by.pRt->flags&MEM_Frame)==0 ){
     /* SubProgram.nMem is set to the number of memory cells used by the
     ** program stored in SubProgram.aOp. As well as these, one memory
     ** cell is required for each cursor used by the program. Set local
-    ** variable u.bz.nMem (and later, VdbeFrame.nChildMem) to this value.
+    ** variable u.by.nMem (and later, VdbeFrame.nChildMem) to this value.
     */
-    u.bz.nMem = u.bz.pProgram->nMem + u.bz.pProgram->nCsr;
-    u.bz.nByte = ROUND8(sizeof(VdbeFrame))
-              + u.bz.nMem * sizeof(Mem)
-              + u.bz.pProgram->nCsr * sizeof(VdbeCursor *);
-    u.bz.pFrame = sqlite3DbMallocZero(db, u.bz.nByte);
-    if( !u.bz.pFrame ){
+    u.by.nMem = u.by.pProgram->nMem + u.by.pProgram->nCsr;
+    u.by.nByte = ROUND8(sizeof(VdbeFrame))
+              + u.by.nMem * sizeof(Mem)
+              + u.by.pProgram->nCsr * sizeof(VdbeCursor *);
+    u.by.pFrame = sqlite3DbMallocZero(db, u.by.nByte);
+    if( !u.by.pFrame ){
       goto no_mem;
     }
-    sqlite3VdbeMemRelease(u.bz.pRt);
-    u.bz.pRt->flags = MEM_Frame;
-    u.bz.pRt->u.pFrame = u.bz.pFrame;
-
-    u.bz.pFrame->v = p;
-    u.bz.pFrame->nChildMem = u.bz.nMem;
-    u.bz.pFrame->nChildCsr = u.bz.pProgram->nCsr;
-    u.bz.pFrame->pc = pc;
-    u.bz.pFrame->aMem = p->aMem;
-    u.bz.pFrame->nMem = p->nMem;
-    u.bz.pFrame->apCsr = p->apCsr;
-    u.bz.pFrame->nCursor = p->nCursor;
-    u.bz.pFrame->aOp = p->aOp;
-    u.bz.pFrame->nOp = p->nOp;
-    u.bz.pFrame->token = u.bz.pProgram->token;
-
-    u.bz.pEnd = &VdbeFrameMem(u.bz.pFrame)[u.bz.pFrame->nChildMem];
-    for(u.bz.pMem=VdbeFrameMem(u.bz.pFrame); u.bz.pMem!=u.bz.pEnd; u.bz.pMem++){
-      u.bz.pMem->flags = MEM_Null;
-      u.bz.pMem->db = db;
+    sqlite3VdbeMemRelease(u.by.pRt);
+    u.by.pRt->flags = MEM_Frame;
+    u.by.pRt->u.pFrame = u.by.pFrame;
+
+    u.by.pFrame->v = p;
+    u.by.pFrame->nChildMem = u.by.nMem;
+    u.by.pFrame->nChildCsr = u.by.pProgram->nCsr;
+    u.by.pFrame->pc = pc;
+    u.by.pFrame->aMem = p->aMem;
+    u.by.pFrame->nMem = p->nMem;
+    u.by.pFrame->apCsr = p->apCsr;
+    u.by.pFrame->nCursor = p->nCursor;
+    u.by.pFrame->aOp = p->aOp;
+    u.by.pFrame->nOp = p->nOp;
+    u.by.pFrame->token = u.by.pProgram->token;
+
+    u.by.pEnd = &VdbeFrameMem(u.by.pFrame)[u.by.pFrame->nChildMem];
+    for(u.by.pMem=VdbeFrameMem(u.by.pFrame); u.by.pMem!=u.by.pEnd; u.by.pMem++){
+      u.by.pMem->flags = MEM_Null;
+      u.by.pMem->db = db;
     }
   }else{
-    u.bz.pFrame = u.bz.pRt->u.pFrame;
-    assert( u.bz.pProgram->nMem+u.bz.pProgram->nCsr==u.bz.pFrame->nChildMem );
-    assert( u.bz.pProgram->nCsr==u.bz.pFrame->nChildCsr );
-    assert( pc==u.bz.pFrame->pc );
+    u.by.pFrame = u.by.pRt->u.pFrame;
+    assert( u.by.pProgram->nMem+u.by.pProgram->nCsr==u.by.pFrame->nChildMem );
+    assert( u.by.pProgram->nCsr==u.by.pFrame->nChildCsr );
+    assert( pc==u.by.pFrame->pc );
   }
 
   p->nFrame++;
-  u.bz.pFrame->pParent = p->pFrame;
-  u.bz.pFrame->lastRowid = db->lastRowid;
-  u.bz.pFrame->nChange = p->nChange;
+  u.by.pFrame->pParent = p->pFrame;
+  u.by.pFrame->lastRowid = db->lastRowid;
+  u.by.pFrame->nChange = p->nChange;
   p->nChange = 0;
-  p->pFrame = u.bz.pFrame;
-  p->aMem = &VdbeFrameMem(u.bz.pFrame)[-1];
-  p->nMem = u.bz.pFrame->nChildMem;
-  p->nCursor = (u16)u.bz.pFrame->nChildCsr;
-  p->apCsr = (VdbeCursor **)&p->aMem[p->nMem+1];
-  p->aOp = u.bz.pProgram->aOp;
-  p->nOp = u.bz.pProgram->nOp;
+  p->pFrame = u.by.pFrame;
+  p->aMem = aMem = &VdbeFrameMem(u.by.pFrame)[-1];
+  p->nMem = u.by.pFrame->nChildMem;
+  p->nCursor = (u16)u.by.pFrame->nChildCsr;
+  p->apCsr = (VdbeCursor **)&aMem[p->nMem+1];
+  p->aOp = aOp = u.by.pProgram->aOp;
+  p->nOp = u.by.pProgram->nOp;
   pc = -1;
 
   break;
@@ -56892,13 +57152,13 @@ case OP_Program: {        /* jump */
 ** calling OP_Program instruction.
 */
 case OP_Param: {           /* out2-prerelease */
-#if 0  /* local variables moved into u.ca */
+#if 0  /* local variables moved into u.bz */
   VdbeFrame *pFrame;
   Mem *pIn;
-#endif /* local variables moved into u.ca */
-  u.ca.pFrame = p->pFrame;
-  u.ca.pIn = &u.ca.pFrame->aMem[pOp->p1 + u.ca.pFrame->aOp[u.ca.pFrame->pc].p1];
-  sqlite3VdbeMemShallowCopy(pOut, u.ca.pIn, MEM_Ephem);
+#endif /* local variables moved into u.bz */
+  u.bz.pFrame = p->pFrame;
+  u.bz.pIn = &u.bz.pFrame->aMem[pOp->p1 + u.bz.pFrame->aOp[u.bz.pFrame->pc].p1];
+  sqlite3VdbeMemShallowCopy(pOut, u.bz.pIn, MEM_Ephem);
   break;
 }
 
@@ -56954,20 +57214,21 @@ case OP_FkIfZero: {         /* jump */
 ** an integer.
 */
 case OP_MemMax: {        /* in2 */
-#if 0  /* local variables moved into u.cb */
+#if 0  /* local variables moved into u.ca */
   Mem *pIn1;
   VdbeFrame *pFrame;
-#endif /* local variables moved into u.cb */
+#endif /* local variables moved into u.ca */
   if( p->pFrame ){
-    for(u.cb.pFrame=p->pFrame; u.cb.pFrame->pParent; u.cb.pFrame=u.cb.pFrame->pParent);
-    u.cb.pIn1 = &u.cb.pFrame->aMem[pOp->p1];
+    for(u.ca.pFrame=p->pFrame; u.ca.pFrame->pParent; u.ca.pFrame=u.ca.pFrame->pParent);
+    u.ca.pIn1 = &u.ca.pFrame->aMem[pOp->p1];
   }else{
-    u.cb.pIn1 = &p->aMem[pOp->p1];
+    u.ca.pIn1 = &aMem[pOp->p1];
   }
-  sqlite3VdbeMemIntegerify(u.cb.pIn1);
+  sqlite3VdbeMemIntegerify(u.ca.pIn1);
+  pIn2 = &aMem[pOp->p2];
   sqlite3VdbeMemIntegerify(pIn2);
-  if( u.cb.pIn1->u.i<pIn2->u.i){
-    u.cb.pIn1->u.i = pIn2->u.i;
+  if( u.ca.pIn1->u.i<pIn2->u.i){
+    u.ca.pIn1->u.i = pIn2->u.i;
   }
   break;
 }
@@ -56981,6 +57242,7 @@ case OP_MemMax: {        /* in2 */
 ** not contain an integer.  An assertion fault will result if you try.
 */
 case OP_IfPos: {        /* jump, in1 */
+  pIn1 = &aMem[pOp->p1];
   assert( pIn1->flags&MEM_Int );
   if( pIn1->u.i>0 ){
      pc = pOp->p2 - 1;
@@ -56996,6 +57258,7 @@ case OP_IfPos: {        /* jump, in1 */
 ** not contain an integer.  An assertion fault will result if you try.
 */
 case OP_IfNeg: {        /* jump, in1 */
+  pIn1 = &aMem[pOp->p1];
   assert( pIn1->flags&MEM_Int );
   if( pIn1->u.i<0 ){
      pc = pOp->p2 - 1;
@@ -57003,15 +57266,18 @@ case OP_IfNeg: {        /* jump, in1 */
   break;
 }
 
-/* Opcode: IfZero P1 P2 * * *
+/* Opcode: IfZero P1 P2 P3 * *
 **
-** If the value of register P1 is exactly 0, jump to P2. 
+** The register P1 must contain an integer.  Add literal P3 to the
+** value in register P1.  If the result is exactly 0, jump to P2. 
 **
 ** It is illegal to use this instruction on a register that does
 ** not contain an integer.  An assertion fault will result if you try.
 */
 case OP_IfZero: {        /* jump, in1 */
+  pIn1 = &aMem[pOp->p1];
   assert( pIn1->flags&MEM_Int );
+  pIn1->u.i += pOp->p3;
   if( pIn1->u.i==0 ){
      pc = pOp->p2 - 1;
   }
@@ -57029,47 +57295,47 @@ case OP_IfZero: {        /* jump, in1 */
 ** successors.
 */
 case OP_AggStep: {
-#if 0  /* local variables moved into u.cc */
+#if 0  /* local variables moved into u.cb */
   int n;
   int i;
   Mem *pMem;
   Mem *pRec;
   sqlite3_context ctx;
   sqlite3_value **apVal;
-#endif /* local variables moved into u.cc */
+#endif /* local variables moved into u.cb */
 
-  u.cc.n = pOp->p5;
-  assert( u.cc.n>=0 );
-  u.cc.pRec = &p->aMem[pOp->p2];
-  u.cc.apVal = p->apArg;
-  assert( u.cc.apVal || u.cc.n==0 );
-  for(u.cc.i=0; u.cc.i<u.cc.n; u.cc.i++, u.cc.pRec++){
-    u.cc.apVal[u.cc.i] = u.cc.pRec;
-    storeTypeInfo(u.cc.pRec, encoding);
+  u.cb.n = pOp->p5;
+  assert( u.cb.n>=0 );
+  u.cb.pRec = &aMem[pOp->p2];
+  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++){
+    u.cb.apVal[u.cb.i] = u.cb.pRec;
+    sqlite3VdbeMemStoreType(u.cb.pRec);
   }
-  u.cc.ctx.pFunc = pOp->p4.pFunc;
+  u.cb.ctx.pFunc = pOp->p4.pFunc;
   assert( pOp->p3>0 && pOp->p3<=p->nMem );
-  u.cc.ctx.pMem = u.cc.pMem = &p->aMem[pOp->p3];
-  u.cc.pMem->n++;
-  u.cc.ctx.s.flags = MEM_Null;
-  u.cc.ctx.s.z = 0;
-  u.cc.ctx.s.zMalloc = 0;
-  u.cc.ctx.s.xDel = 0;
-  u.cc.ctx.s.db = db;
-  u.cc.ctx.isError = 0;
-  u.cc.ctx.pColl = 0;
-  if( u.cc.ctx.pFunc->flags & SQLITE_FUNC_NEEDCOLL ){
+  u.cb.ctx.pMem = u.cb.pMem = &aMem[pOp->p3];
+  u.cb.pMem->n++;
+  u.cb.ctx.s.flags = MEM_Null;
+  u.cb.ctx.s.z = 0;
+  u.cb.ctx.s.zMalloc = 0;
+  u.cb.ctx.s.xDel = 0;
+  u.cb.ctx.s.db = db;
+  u.cb.ctx.isError = 0;
+  u.cb.ctx.pColl = 0;
+  if( u.cb.ctx.pFunc->flags & SQLITE_FUNC_NEEDCOLL ){
     assert( pOp>p->aOp );
     assert( pOp[-1].p4type==P4_COLLSEQ );
     assert( pOp[-1].opcode==OP_CollSeq );
-    u.cc.ctx.pColl = pOp[-1].p4.pColl;
+    u.cb.ctx.pColl = pOp[-1].p4.pColl;
   }
-  (u.cc.ctx.pFunc->xStep)(&u.cc.ctx, u.cc.n, u.cc.apVal);
-  if( u.cc.ctx.isError ){
-    sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&u.cc.ctx.s));
-    rc = u.cc.ctx.isError;
+  (u.cb.ctx.pFunc->xStep)(&u.cb.ctx, u.cb.n, u.cb.apVal);
+  if( u.cb.ctx.isError ){
+    sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&u.cb.ctx.s));
+    rc = u.cb.ctx.isError;
   }
-  sqlite3VdbeMemRelease(&u.cc.ctx.s);
+  sqlite3VdbeMemRelease(&u.cb.ctx.s);
   break;
 }
 
@@ -57086,19 +57352,19 @@ case OP_AggStep: {
 ** the step function was not previously called.
 */
 case OP_AggFinal: {
-#if 0  /* local variables moved into u.cd */
+#if 0  /* local variables moved into u.cc */
   Mem *pMem;
-#endif /* local variables moved into u.cd */
+#endif /* local variables moved into u.cc */
   assert( pOp->p1>0 && pOp->p1<=p->nMem );
-  u.cd.pMem = &p->aMem[pOp->p1];
-  assert( (u.cd.pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
-  rc = sqlite3VdbeMemFinalize(u.cd.pMem, pOp->p4.pFunc);
+  u.cc.pMem = &aMem[pOp->p1];
+  assert( (u.cc.pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
+  rc = sqlite3VdbeMemFinalize(u.cc.pMem, pOp->p4.pFunc);
   if( rc ){
-    sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(u.cd.pMem));
+    sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(u.cc.pMem));
   }
-  sqlite3VdbeChangeEncoding(u.cd.pMem, encoding);
-  UPDATE_MAX_BLOBSIZE(u.cd.pMem);
-  if( sqlite3VdbeMemTooBig(u.cd.pMem) ){
+  sqlite3VdbeChangeEncoding(u.cc.pMem, encoding);
+  UPDATE_MAX_BLOBSIZE(u.cc.pMem);
+  if( sqlite3VdbeMemTooBig(u.cc.pMem) ){
     goto too_big;
   }
   break;
@@ -57128,14 +57394,14 @@ case OP_Vacuum: {
 ** P2. Otherwise, fall through to the next instruction.
 */
 case OP_IncrVacuum: {        /* jump */
-#if 0  /* local variables moved into u.ce */
+#if 0  /* local variables moved into u.cd */
   Btree *pBt;
-#endif /* local variables moved into u.ce */
+#endif /* local variables moved into u.cd */
 
   assert( pOp->p1>=0 && pOp->p1<db->nDb );
   assert( (p->btreeMask & (1<<pOp->p1))!=0 );
-  u.ce.pBt = db->aDb[pOp->p1].pBt;
-  rc = sqlite3BtreeIncrVacuum(u.ce.pBt);
+  u.cd.pBt = db->aDb[pOp->p1].pBt;
+  rc = sqlite3BtreeIncrVacuum(u.cd.pBt);
   if( rc==SQLITE_DONE ){
     pc = pOp->p2 - 1;
     rc = SQLITE_OK;
@@ -57205,15 +57471,15 @@ case OP_TableLock: {
 ** code will be set to SQLITE_LOCKED.
 */
 case OP_VBegin: {
-#if 0  /* local variables moved into u.cf */
+#if 0  /* local variables moved into u.ce */
   VTable *pVTab;
-#endif /* local variables moved into u.cf */
-  u.cf.pVTab = pOp->p4.pVtab;
-  rc = sqlite3VtabBegin(db, u.cf.pVTab);
-  if( u.cf.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.cf.pVTab->pVtab->zErrMsg;
-    u.cf.pVTab->pVtab->zErrMsg = 0;
+    p->zErrMsg = u.ce.pVTab->pVtab->zErrMsg;
+    u.ce.pVTab->pVtab->zErrMsg = 0;
   }
   break;
 }
@@ -57253,36 +57519,36 @@ case OP_VDestroy: {
 ** table and stores that cursor in P1.
 */
 case OP_VOpen: {
-#if 0  /* local variables moved into u.cg */
+#if 0  /* local variables moved into u.cf */
   VdbeCursor *pCur;
   sqlite3_vtab_cursor *pVtabCursor;
   sqlite3_vtab *pVtab;
   sqlite3_module *pModule;
-#endif /* local variables moved into u.cg */
+#endif /* local variables moved into u.cf */
 
-  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);
+  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);
   if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
-  rc = u.cg.pModule->xOpen(u.cg.pVtab, &u.cg.pVtabCursor);
+  rc = u.cf.pModule->xOpen(u.cf.pVtab, &u.cf.pVtabCursor);
   sqlite3DbFree(db, p->zErrMsg);
-  p->zErrMsg = u.cg.pVtab->zErrMsg;
-  u.cg.pVtab->zErrMsg = 0;
+  p->zErrMsg = u.cf.pVtab->zErrMsg;
+  u.cf.pVtab->zErrMsg = 0;
   if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
   if( SQLITE_OK==rc ){
     /* Initialize sqlite3_vtab_cursor base class */
-    u.cg.pVtabCursor->pVtab = u.cg.pVtab;
+    u.cf.pVtabCursor->pVtab = u.cf.pVtab;
 
     /* Initialise vdbe cursor object */
-    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;
+    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;
     }else{
       db->mallocFailed = 1;
-      u.cg.pModule->xClose(u.cg.pVtabCursor);
+      u.cf.pModule->xClose(u.cf.pVtabCursor);
     }
   }
   break;
@@ -57309,7 +57575,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.ch */
+#if 0  /* local variables moved into u.cg */
   int nArg;
   int iQuery;
   const sqlite3_module *pModule;
@@ -57321,48 +57587,48 @@ case OP_VFilter: {   /* jump */
   int res;
   int i;
   Mem **apArg;
-#endif /* local variables moved into u.ch */
+#endif /* local variables moved into u.cg */
 
-  u.ch.pQuery = &p->aMem[pOp->p3];
-  u.ch.pArgc = &u.ch.pQuery[1];
-  u.ch.pCur = p->apCsr[pOp->p1];
-  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;
+  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;
 
   /* Grab the index number and argc parameters */
-  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;
+  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;
 
   /* Invoke the xFilter method */
   {
-    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];
-      storeTypeInfo(u.ch.apArg[u.ch.i], 0);
+    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]);
     }
 
     if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
     p->inVtabMethod = 1;
-    rc = u.ch.pModule->xFilter(u.ch.pVtabCursor, u.ch.iQuery, pOp->p4.z, u.ch.nArg, u.ch.apArg);
+    rc = u.cg.pModule->xFilter(u.cg.pVtabCursor, u.cg.iQuery, pOp->p4.z, u.cg.nArg, u.cg.apArg);
     p->inVtabMethod = 0;
     sqlite3DbFree(db, p->zErrMsg);
-    p->zErrMsg = u.ch.pVtab->zErrMsg;
-    u.ch.pVtab->zErrMsg = 0;
+    p->zErrMsg = u.cg.pVtab->zErrMsg;
+    u.cg.pVtab->zErrMsg = 0;
     if( rc==SQLITE_OK ){
-      u.ch.res = u.ch.pModule->xEof(u.ch.pVtabCursor);
+      u.cg.res = u.cg.pModule->xEof(u.cg.pVtabCursor);
     }
     if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
 
-    if( u.ch.res ){
+    if( u.cg.res ){
       pc = pOp->p2 - 1;
     }
   }
-  u.ch.pCur->nullRow = 0;
+  u.cg.pCur->nullRow = 0;
 
   break;
 }
@@ -57376,56 +57642,56 @@ case OP_VFilter: {   /* jump */
 ** P1 cursor is pointing to into register P3.
 */
 case OP_VColumn: {
-#if 0  /* local variables moved into u.ci */
+#if 0  /* local variables moved into u.ch */
   sqlite3_vtab *pVtab;
   const sqlite3_module *pModule;
   Mem *pDest;
   sqlite3_context sContext;
-#endif /* local variables moved into u.ci */
+#endif /* local variables moved into u.ch */
 
   VdbeCursor *pCur = p->apCsr[pOp->p1];
   assert( pCur->pVtabCursor );
   assert( pOp->p3>0 && pOp->p3<=p->nMem );
-  u.ci.pDest = &p->aMem[pOp->p3];
+  u.ch.pDest = &aMem[pOp->p3];
   if( pCur->nullRow ){
-    sqlite3VdbeMemSetNull(u.ci.pDest);
+    sqlite3VdbeMemSetNull(u.ch.pDest);
     break;
   }
-  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));
+  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));
 
   /* The output cell may already have a buffer allocated. Move
-  ** the current contents to u.ci.sContext.s so in case the user-function
+  ** the current contents to u.ch.sContext.s so in case the user-function
   ** can use the already allocated buffer instead of allocating a
   ** new one.
   */
-  sqlite3VdbeMemMove(&u.ci.sContext.s, u.ci.pDest);
-  MemSetTypeFlag(&u.ci.sContext.s, MEM_Null);
+  sqlite3VdbeMemMove(&u.ch.sContext.s, u.ch.pDest);
+  MemSetTypeFlag(&u.ch.sContext.s, MEM_Null);
 
   if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
-  rc = u.ci.pModule->xColumn(pCur->pVtabCursor, &u.ci.sContext, pOp->p2);
+  rc = u.ch.pModule->xColumn(pCur->pVtabCursor, &u.ch.sContext, pOp->p2);
   sqlite3DbFree(db, p->zErrMsg);
-  p->zErrMsg = u.ci.pVtab->zErrMsg;
-  u.ci.pVtab->zErrMsg = 0;
-  if( u.ci.sContext.isError ){
-    rc = u.ci.sContext.isError;
+  p->zErrMsg = u.ch.pVtab->zErrMsg;
+  u.ch.pVtab->zErrMsg = 0;
+  if( u.ch.sContext.isError ){
+    rc = u.ch.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.ci.sContext.s (a Mem struct) is  released.
+  ** dynamic allocation in u.ch.sContext.s (a Mem struct) is  released.
   */
-  sqlite3VdbeChangeEncoding(&u.ci.sContext.s, encoding);
-  REGISTER_TRACE(pOp->p3, u.ci.pDest);
-  sqlite3VdbeMemMove(u.ci.pDest, &u.ci.sContext.s);
-  UPDATE_MAX_BLOBSIZE(u.ci.pDest);
+  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);
 
   if( sqlite3SafetyOn(db) ){
     goto abort_due_to_misuse;
   }
-  if( sqlite3VdbeMemTooBig(u.ci.pDest) ){
+  if( sqlite3VdbeMemTooBig(u.ch.pDest) ){
     goto too_big;
   }
   break;
@@ -57440,22 +57706,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.cj */
+#if 0  /* local variables moved into u.ci */
   sqlite3_vtab *pVtab;
   const sqlite3_module *pModule;
   int res;
   VdbeCursor *pCur;
-#endif /* local variables moved into u.cj */
+#endif /* local variables moved into u.ci */
 
-  u.cj.res = 0;
-  u.cj.pCur = p->apCsr[pOp->p1];
-  assert( u.cj.pCur->pVtabCursor );
-  if( u.cj.pCur->nullRow ){
+  u.ci.res = 0;
+  u.ci.pCur = p->apCsr[pOp->p1];
+  assert( u.ci.pCur->pVtabCursor );
+  if( u.ci.pCur->nullRow ){
     break;
   }
-  u.cj.pVtab = u.cj.pCur->pVtabCursor->pVtab;
-  u.cj.pModule = u.cj.pVtab->pModule;
-  assert( u.cj.pModule->xNext );
+  u.ci.pVtab = u.ci.pCur->pVtabCursor->pVtab;
+  u.ci.pModule = u.ci.pVtab->pModule;
+  assert( u.ci.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
@@ -57465,17 +57731,17 @@ case OP_VNext: {   /* jump */
   */
   if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
   p->inVtabMethod = 1;
-  rc = u.cj.pModule->xNext(u.cj.pCur->pVtabCursor);
+  rc = u.ci.pModule->xNext(u.ci.pCur->pVtabCursor);
   p->inVtabMethod = 0;
   sqlite3DbFree(db, p->zErrMsg);
-  p->zErrMsg = u.cj.pVtab->zErrMsg;
-  u.cj.pVtab->zErrMsg = 0;
+  p->zErrMsg = u.ci.pVtab->zErrMsg;
+  u.ci.pVtab->zErrMsg = 0;
   if( rc==SQLITE_OK ){
-    u.cj.res = u.cj.pModule->xEof(u.cj.pCur->pVtabCursor);
+    u.ci.res = u.ci.pModule->xEof(u.ci.pCur->pVtabCursor);
   }
   if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
 
-  if( !u.cj.res ){
+  if( !u.ci.res ){
     /* If there is data, jump to P2 */
     pc = pOp->p2 - 1;
   }
@@ -57491,21 +57757,21 @@ 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.ck */
+#if 0  /* local variables moved into u.cj */
   sqlite3_vtab *pVtab;
   Mem *pName;
-#endif /* local variables moved into u.ck */
+#endif /* local variables moved into u.cj */
 
-  u.ck.pVtab = pOp->p4.pVtab->pVtab;
-  u.ck.pName = &p->aMem[pOp->p1];
-  assert( u.ck.pVtab->pModule->xRename );
-  REGISTER_TRACE(pOp->p1, u.ck.pName);
-  assert( u.ck.pName->flags & MEM_Str );
+  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 );
   if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
-  rc = u.ck.pVtab->pModule->xRename(u.ck.pVtab, u.ck.pName->z);
+  rc = u.cj.pVtab->pModule->xRename(u.cj.pVtab, u.cj.pName->z);
   sqlite3DbFree(db, p->zErrMsg);
-  p->zErrMsg = u.ck.pVtab->zErrMsg;
-  u.ck.pVtab->zErrMsg = 0;
+  p->zErrMsg = u.cj.pVtab->zErrMsg;
+  u.cj.pVtab->zErrMsg = 0;
   if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
 
   break;
@@ -57537,7 +57803,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.cl */
+#if 0  /* local variables moved into u.ck */
   sqlite3_vtab *pVtab;
   sqlite3_module *pModule;
   int nArg;
@@ -57545,29 +57811,29 @@ case OP_VUpdate: {
   sqlite_int64 rowid;
   Mem **apArg;
   Mem *pX;
-#endif /* local variables moved into u.cl */
+#endif /* local variables moved into u.ck */
 
-  u.cl.pVtab = pOp->p4.pVtab->pVtab;
-  u.cl.pModule = (sqlite3_module *)u.cl.pVtab->pModule;
-  u.cl.nArg = pOp->p2;
+  u.ck.pVtab = pOp->p4.pVtab->pVtab;
+  u.ck.pModule = (sqlite3_module *)u.ck.pVtab->pModule;
+  u.ck.nArg = pOp->p2;
   assert( pOp->p4type==P4_VTAB );
-  if( ALWAYS(u.cl.pModule->xUpdate) ){
-    u.cl.apArg = p->apArg;
-    u.cl.pX = &p->aMem[pOp->p3];
-    for(u.cl.i=0; u.cl.i<u.cl.nArg; u.cl.i++){
-      storeTypeInfo(u.cl.pX, 0);
-      u.cl.apArg[u.cl.i] = u.cl.pX;
-      u.cl.pX++;
+  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++;
     }
     if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
-    rc = u.cl.pModule->xUpdate(u.cl.pVtab, u.cl.nArg, u.cl.apArg, &u.cl.rowid);
+    rc = u.ck.pModule->xUpdate(u.ck.pVtab, u.ck.nArg, u.ck.apArg, &u.ck.rowid);
     sqlite3DbFree(db, p->zErrMsg);
-    p->zErrMsg = u.cl.pVtab->zErrMsg;
-    u.cl.pVtab->zErrMsg = 0;
+    p->zErrMsg = u.ck.pVtab->zErrMsg;
+    u.ck.pVtab->zErrMsg = 0;
     if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
     if( rc==SQLITE_OK && pOp->p1 ){
-      assert( u.cl.nArg>1 && u.cl.apArg[0] && (u.cl.apArg[0]->flags&MEM_Null) );
-      db->lastRowid = u.cl.rowid;
+      assert( u.ck.nArg>1 && u.ck.apArg[0] && (u.ck.apArg[0]->flags&MEM_Null) );
+      db->lastRowid = u.ck.rowid;
     }
     p->nChange++;
   }
@@ -57581,21 +57847,20 @@ 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.cm */
+#if 0  /* local variables moved into u.cl */
   int p1;
   int nPage;
   Pager *pPager;
-#endif /* local variables moved into u.cm */
+#endif /* local variables moved into u.cl */
 
-  u.cm.p1 = pOp->p1;
-  u.cm.pPager = sqlite3BtreePager(db->aDb[u.cm.p1].pBt);
-  rc = sqlite3PagerPagecount(u.cm.pPager, &u.cm.nPage);
+  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->flags = MEM_Int;
-    pOut->u.i = u.cm.nPage;
+    pOut->u.i = u.cl.nPage;
   }
   break;
 }
@@ -57608,18 +57873,20 @@ case OP_Pagecount: {            /* out2-prerelease */
 ** the UTF-8 string contained in P4 is emitted on the trace callback.
 */
 case OP_Trace: {
-#if 0  /* local variables moved into u.cn */
+#if 0  /* local variables moved into u.cm */
   char *zTrace;
-#endif /* local variables moved into u.cn */
+#endif /* local variables moved into u.cm */
 
-  u.cn.zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
-  if( u.cn.zTrace ){
+  u.cm.zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
+  if( u.cm.zTrace ){
     if( db->xTrace ){
-      db->xTrace(db->pTraceArg, u.cn.zTrace);
+      char *z = sqlite3VdbeExpandSql(p, u.cm.zTrace);
+      db->xTrace(db->pTraceArg, z);
+      sqlite3DbFree(db, z);
     }
 #ifdef SQLITE_DEBUG
     if( (db->flags & SQLITE_SqlTrace)!=0 ){
-      sqlite3DebugPrintf("SQL-trace: %s\n", u.cn.zTrace);
+      sqlite3DebugPrintf("SQL-trace: %s\n", u.cm.zTrace);
     }
 #endif /* SQLITE_DEBUG */
   }
@@ -57658,7 +57925,7 @@ default: {          /* This is really OP_Noop and OP_Explain */
       pOp->cnt++;
 #if 0
         fprintf(stdout, "%10llu ", elapsed);
-        sqlite3VdbePrintOp(stdout, origPc, &p->aOp[origPc]);
+        sqlite3VdbePrintOp(stdout, origPc, &aOp[origPc]);
 #endif
     }
 #endif
@@ -57674,11 +57941,11 @@ default: {          /* This is really OP_Noop and OP_Explain */
 #ifdef SQLITE_DEBUG
     if( p->trace ){
       if( rc!=0 ) fprintf(p->trace,"rc=%d\n",rc);
-      if( opProperty & OPFLG_OUT2_PRERELEASE ){
-        registerTrace(p->trace, pOp->p2, pOut);
+      if( pOp->opflags & (OPFLG_OUT2_PRERELEASE|OPFLG_OUT2) ){
+        registerTrace(p->trace, pOp->p2, &aMem[pOp->p2]);
       }
-      if( opProperty & OPFLG_OUT3 ){
-        registerTrace(p->trace, pOp->p3, pOut);
+      if( pOp->opflags & OPFLG_OUT3 ){
+        registerTrace(p->trace, pOp->p3, &aMem[pOp->p3]);
       }
     }
 #endif  /* SQLITE_DEBUG */
@@ -57694,6 +57961,7 @@ vdbe_error_halt:
   sqlite3VdbeHalt(p);
   if( rc==SQLITE_IOERR_NOMEM ) db->mallocFailed = 1;
   rc = SQLITE_ERROR;
+  if( resetSchemaOnFault ) sqlite3ResetInternalSchema(db, 0);
 
   /* This is the only way out of this procedure.  We have to
   ** release the mutexes on btrees that were acquired at the
@@ -57761,8 +58029,6 @@ abort_due_to_interrupt:
 *************************************************************************
 **
 ** This file contains code used to implement incremental BLOB I/O.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -58155,12 +58421,6 @@ SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){
 **
 *************************************************************************
 **
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
-*/
-
-#ifdef SQLITE_ENABLE_ATOMIC_WRITE
-
-/*
 ** This file implements a special kind of sqlite3_file object used
 ** by SQLite to create journal files if the atomic-write optimization
 ** is enabled.
@@ -58175,7 +58435,7 @@ SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){
 **      buffer, or
 **   2) The sqlite3JournalCreate() function is called.
 */
-
+#ifdef SQLITE_ENABLE_ATOMIC_WRITE
 
 
 /*
@@ -58400,8 +58660,6 @@ SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *pVfs){
 ** This file contains code use to implement an in-memory rollback journal.
 ** The in-memory rollback journal is used to journal transactions for
 ** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /* Forward references to internal structures */
@@ -58659,8 +58917,6 @@ SQLITE_PRIVATE int sqlite3MemJournalSize(void){
 *************************************************************************
 ** This file contains routines used for walking the parser tree for
 ** an SQL statement.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -58799,8 +59055,6 @@ SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
 ** This file contains routines used for walking the parser tree and
 ** resolve all identifiers by associating them with a particular
 ** table and column.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -58872,7 +59126,13 @@ static void resolveAlias(
     pDup->pColl = pExpr->pColl;
     pDup->flags |= EP_ExpCollate;
   }
-  sqlite3ExprClear(db, pExpr);
+
+  /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This 
+  ** prevents ExprDelete() from deleting the Expr structure itself,
+  ** allowing it to be repopulated by the memcpy() on the following line.
+  */
+  ExprSetProperty(pExpr, EP_Static);
+  sqlite3ExprDelete(db, pExpr);
   memcpy(pExpr, pDup, sizeof(*pExpr));
   sqlite3DbFree(db, pDup);
 }
@@ -59022,19 +59282,18 @@ static int lookupName(
         int iCol;
         pSchema = pTab->pSchema;
         cntTab++;
-        if( sqlite3IsRowid(zCol) ){
-          iCol = -1;
-        }else{
-          for(iCol=0; iCol<pTab->nCol; iCol++){
-            Column *pCol = &pTab->aCol[iCol];
-            if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
-              if( iCol==pTab->iPKey ){
-                iCol = -1;
-              }
-              break;
+        for(iCol=0; iCol<pTab->nCol; iCol++){
+          Column *pCol = &pTab->aCol[iCol];
+          if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
+            if( iCol==pTab->iPKey ){
+              iCol = -1;
             }
+            break;
           }
         }
+        if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) ){
+          iCol = -1;        /* IMP: R-44911-55124 */
+        }
         if( iCol<pTab->nCol ){
           cnt++;
           if( iCol<0 ){
@@ -59043,6 +59302,10 @@ static int lookupName(
             testcase( iCol==31 );
             testcase( iCol==32 );
             pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
+          }else{
+            testcase( iCol==31 );
+            testcase( iCol==32 );
+            pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
           }
           pExpr->iColumn = (i16)iCol;
           pExpr->pTab = pTab;
@@ -59057,7 +59320,7 @@ static int lookupName(
     */
     if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){
       cnt = 1;
-      pExpr->iColumn = -1;
+      pExpr->iColumn = -1;     /* IMP: R-44911-55124 */
       pExpr->affinity = SQLITE_AFF_INTEGER;
     }
 
@@ -59178,6 +59441,27 @@ lookupname_end:
 }
 
 /*
+** Allocate and return a pointer to an expression to load the column iCol
+** from datasource iSrc datasource in SrcList pSrc.
+*/
+SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){
+  Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);
+  if( p ){
+    struct SrcList_item *pItem = &pSrc->a[iSrc];
+    p->pTab = pItem->pTab;
+    p->iTable = pItem->iCursor;
+    if( p->pTab->iPKey==iCol ){
+      p->iColumn = -1;
+    }else{
+      p->iColumn = (ynVar)iCol;
+      pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);
+    }
+    ExprSetProperty(p, EP_Resolved);
+  }
+  return p;
+}
+
+/*
 ** This routine is callback for sqlite3WalkExpr().
 **
 ** Resolve symbolic names into TK_COLUMN operators for the current
@@ -60181,30 +60465,6 @@ SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(
 }
 
 /*
-** Generate the operands for a comparison operation.  Before
-** generating the code for each operand, set the EP_AnyAff
-** flag on the expression so that it will be able to used a
-** cached column value that has previously undergone an
-** affinity change.
-*/
-static void codeCompareOperands(
-  Parse *pParse,    /* Parsing and code generating context */
-  Expr *pLeft,      /* The left operand */
-  int *pRegLeft,    /* Register where left operand is stored */
-  int *pFreeLeft,   /* Free this register when done */
-  Expr *pRight,     /* The right operand */
-  int *pRegRight,   /* Register where right operand is stored */
-  int *pFreeRight   /* Write temp register for right operand there */
-){
-  while( pLeft->op==TK_UPLUS ) pLeft = pLeft->pLeft;
-  pLeft->flags |= EP_AnyAff;
-  *pRegLeft = sqlite3ExprCodeTemp(pParse, pLeft, pFreeLeft);
-  while( pRight->op==TK_UPLUS ) pRight = pRight->pLeft;
-  pRight->flags |= EP_AnyAff;
-  *pRegRight = sqlite3ExprCodeTemp(pParse, pRight, pFreeRight);
-}
-
-/*
 ** Generate code for a comparison operator.
 */
 static int codeCompare(
@@ -60524,12 +60784,12 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
   if( z[1]==0 ){
     /* Wildcard of the form "?".  Assign the next variable number */
     assert( z[0]=='?' );
-    pExpr->iTable = ++pParse->nVar;
+    pExpr->iColumn = (ynVar)(++pParse->nVar);
   }else if( z[0]=='?' ){
     /* Wildcard of the form "?nnn".  Convert "nnn" to an integer and
     ** use it as the variable number */
-    int i;
-    pExpr->iTable = i = atoi((char*)&z[1]);
+    int i = atoi((char*)&z[1]);
+    pExpr->iColumn = (ynVar)i;
     testcase( i==0 );
     testcase( i==1 );
     testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 );
@@ -60553,12 +60813,12 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
       Expr *pE = pParse->apVarExpr[i];
       assert( pE!=0 );
       if( memcmp(pE->u.zToken, z, n)==0 && pE->u.zToken[n]==0 ){
-        pExpr->iTable = pE->iTable;
+        pExpr->iColumn = pE->iColumn;
         break;
       }
     }
     if( i>=pParse->nVarExpr ){
-      pExpr->iTable = ++pParse->nVar;
+      pExpr->iColumn = (ynVar)(++pParse->nVar);
       if( pParse->nVarExpr>=pParse->nVarExprAlloc-1 ){
         pParse->nVarExprAlloc += pParse->nVarExprAlloc + 10;
         pParse->apVarExpr =
@@ -60580,11 +60840,10 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
 }
 
 /*
-** Clear an expression structure without deleting the structure itself.
-** Substructure is deleted.
+** Recursively delete an expression tree.
 */
-SQLITE_PRIVATE void sqlite3ExprClear(sqlite3 *db, Expr *p){
-  assert( p!=0 );
+SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){
+  if( p==0 ) return;
   if( !ExprHasAnyProperty(p, EP_TokenOnly) ){
     sqlite3ExprDelete(db, p->pLeft);
     sqlite3ExprDelete(db, p->pRight);
@@ -60597,14 +60856,6 @@ SQLITE_PRIVATE void sqlite3ExprClear(sqlite3 *db, Expr *p){
       sqlite3ExprListDelete(db, p->x.pList);
     }
   }
-}
-
-/*
-** Recursively delete an expression tree.
-*/
-SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){
-  if( p==0 ) return;
-  sqlite3ExprClear(db, p);
   if( !ExprHasProperty(p, EP_Static) ){
     sqlite3DbFree(db, p);
   }
@@ -61212,6 +61463,94 @@ SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){
 }
 
 /*
+** Return FALSE if there is no chance that the expression can be NULL.
+**
+** If the expression might be NULL or if the expression is too complex
+** to tell return TRUE.  
+**
+** This routine is used as an optimization, to skip OP_IsNull opcodes
+** when we know that a value cannot be NULL.  Hence, a false positive
+** (returning TRUE when in fact the expression can never be NULL) might
+** be a small performance hit but is otherwise harmless.  On the other
+** hand, a false negative (returning FALSE when the result could be NULL)
+** will likely result in an incorrect answer.  So when in doubt, return
+** TRUE.
+*/
+SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
+  u8 op;
+  while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }
+  op = p->op;
+  if( op==TK_REGISTER ) op = p->op2;
+  switch( op ){
+    case TK_INTEGER:
+    case TK_STRING:
+    case TK_FLOAT:
+    case TK_BLOB:
+      return 0;
+    default:
+      return 1;
+  }
+}
+
+/*
+** Generate an OP_IsNull instruction that tests register iReg and jumps
+** to location iDest if the value in iReg is NULL.  The value in iReg 
+** was computed by pExpr.  If we can look at pExpr at compile-time and
+** determine that it can never generate a NULL, then the OP_IsNull operation
+** can be omitted.
+*/
+SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(
+  Vdbe *v,            /* The VDBE under construction */
+  const Expr *pExpr,  /* Only generate OP_IsNull if this expr can be NULL */
+  int iReg,           /* Test the value in this register for NULL */
+  int iDest           /* Jump here if the value is null */
+){
+  if( sqlite3ExprCanBeNull(pExpr) ){
+    sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iDest);
+  }
+}
+
+/*
+** Return TRUE if the given expression is a constant which would be
+** unchanged by OP_Affinity with the affinity given in the second
+** argument.
+**
+** This routine is used to determine if the OP_Affinity operation
+** can be omitted.  When in doubt return FALSE.  A false negative
+** is harmless.  A false positive, however, can result in the wrong
+** answer.
+*/
+SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr *p, char aff){
+  u8 op;
+  if( aff==SQLITE_AFF_NONE ) return 1;
+  while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }
+  op = p->op;
+  if( op==TK_REGISTER ) op = p->op2;
+  switch( op ){
+    case TK_INTEGER: {
+      return aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC;
+    }
+    case TK_FLOAT: {
+      return aff==SQLITE_AFF_REAL || aff==SQLITE_AFF_NUMERIC;
+    }
+    case TK_STRING: {
+      return aff==SQLITE_AFF_TEXT;
+    }
+    case TK_BLOB: {
+      return 1;
+    }
+    case TK_COLUMN: {
+      assert( p->iTable>=0 );  /* p cannot be part of a CHECK constraint */
+      return p->iColumn<0
+          && (aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC);
+    }
+    default: {
+      return 0;
+    }
+  }
+}
+
+/*
 ** Return TRUE if the given string is a row-id column name.
 */
 SQLITE_PRIVATE int sqlite3IsRowid(const char *z){
@@ -61298,16 +61637,16 @@ static int isCandidateForInOpt(Select *p){
 ** When the b-tree is being used for membership tests, the calling function
 ** needs to know whether or not the structure contains an SQL NULL 
 ** value in order to correctly evaluate expressions like "X IN (Y, Z)".
-** If there is a chance that the b-tree might contain a NULL value at
+** If there is any chance that the (...) might contain a NULL value at
 ** runtime, then a register is allocated and the register number written
-** to *prNotFound. If there is no chance that the b-tree contains a
+** to *prNotFound. If there is no chance that the (...) contains a
 ** NULL value, then *prNotFound is left unchanged.
 **
 ** If a register is allocated and its location stored in *prNotFound, then
-** its initial value is NULL. If the b-tree does not remain constant
-** for the duration of the query (i.e. the SELECT that generates the b-tree
+** its initial value is NULL.  If the (...) does not remain constant
+** for the duration of the query (i.e. the SELECT within the (...)
 ** is a correlated subquery) then the value of the allocated register is
-** reset to NULL each time the b-tree is repopulated. This allows the
+** reset to NULL each time the subquery is rerun. This allows the
 ** caller to use vdbe code equivalent to the following:
 **
 **   if( register==NULL ){
@@ -61325,6 +61664,8 @@ SQLITE_PRIVATE int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){
   int iTab = pParse->nTab++;            /* Cursor of the RHS table */
   int mustBeUnique = (prNotFound==0);   /* True if RHS must be unique */
 
+  assert( pX->op==TK_IN );
+
   /* Check to see if an existing table or index can be used to
   ** satisfy the query.  This is preferable to generating a new 
   ** ephemeral table.
@@ -61402,7 +61743,7 @@ SQLITE_PRIVATE int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){
   }
 
   if( eType==0 ){
-    /* Could not found an existing able or index to use as the RHS b-tree.
+    /* 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.
     */
     int rMayHaveNull = 0;
@@ -61449,17 +61790,21 @@ SQLITE_PRIVATE int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){
 ** If rMayHaveNull is zero, that means that the subquery is being used
 ** for membership testing only.  There is no need to initialize any
 ** registers to indicate the presense or absence of NULLs on the RHS.
+**
+** For a SELECT or EXISTS operator, return the register that holds the
+** result.  For IN operators or if an error occurs, the return value is 0.
 */
 #ifndef SQLITE_OMIT_SUBQUERY
-SQLITE_PRIVATE void sqlite3CodeSubselect(
+SQLITE_PRIVATE int sqlite3CodeSubselect(
   Parse *pParse,          /* Parsing context */
   Expr *pExpr,            /* The IN, SELECT, or EXISTS operator */
   int rMayHaveNull,       /* Register that records whether NULLs exist in RHS */
   int isRowid             /* If true, LHS of IN operator is a rowid */
 ){
   int testAddr = 0;                       /* One-time test address */
+  int rReg = 0;                           /* Register storing resulting */
   Vdbe *v = sqlite3GetVdbe(pParse);
-  if( NEVER(v==0) ) return;
+  if( NEVER(v==0) ) return 0;
   sqlite3ExprCachePush(pParse);
 
   /* This code must be run in its entirety every time it is encountered
@@ -61493,7 +61838,7 @@ SQLITE_PRIVATE void sqlite3CodeSubselect(
       affinity = sqlite3ExprAffinity(pLeft);
 
       /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
-      ** expression it is handled the same way. A virtual table is 
+      ** expression it is handled the same way.  An ephemeral table is 
       ** filled with single-field index keys representing the results
       ** from the SELECT or the <exprlist>.
       **
@@ -61524,7 +61869,7 @@ SQLITE_PRIVATE void sqlite3CodeSubselect(
         dest.affinity = (u8)affinity;
         assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
         if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
-          return;
+          return 0;
         }
         pEList = pExpr->x.pSelect->pEList;
         if( ALWAYS(pEList!=0 && pEList->nExpr>0) ){ 
@@ -61555,6 +61900,7 @@ SQLITE_PRIVATE void sqlite3CodeSubselect(
         sqlite3VdbeAddOp2(v, OP_Null, 0, r2);
         for(i=pList->nExpr, pItem=pList->a; i>0; i--, pItem++){
           Expr *pE2 = pItem->pExpr;
+          int iValToIns;
 
           /* If the expression is not constant then we will need to
           ** disable the test that was generated above that makes sure
@@ -61567,14 +61913,19 @@ SQLITE_PRIVATE void sqlite3CodeSubselect(
           }
 
           /* Evaluate the expression and insert it into the temp table */
-          r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
-          if( isRowid ){
-            sqlite3VdbeAddOp2(v, OP_MustBeInt, r3, sqlite3VdbeCurrentAddr(v)+2);
-            sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);
+          if( isRowid && sqlite3ExprIsInteger(pE2, &iValToIns) ){
+            sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr->iTable, r2, iValToIns);
           }else{
-            sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
-            sqlite3ExprCacheAffinityChange(pParse, r3, 1);
-            sqlite3VdbeAddOp2(v, OP_IdxInsert, pExpr->iTable, r2);
+            r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
+            if( isRowid ){
+              sqlite3VdbeAddOp2(v, OP_MustBeInt, r3,
+                                sqlite3VdbeCurrentAddr(v)+2);
+              sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);
+            }else{
+              sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
+              sqlite3ExprCacheAffinityChange(pParse, r3, 1);
+              sqlite3VdbeAddOp2(v, OP_IdxInsert, pExpr->iTable, r2);
+            }
           }
         }
         sqlite3ReleaseTempReg(pParse, r1);
@@ -61618,9 +61969,9 @@ SQLITE_PRIVATE void sqlite3CodeSubselect(
       sqlite3ExprDelete(pParse->db, pSel->pLimit);
       pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &one);
       if( sqlite3Select(pParse, pSel, &dest) ){
-        return;
+        return 0;
       }
-      pExpr->iColumn = (i16)dest.iParm;
+      rReg = dest.iParm;
       ExprSetIrreducible(pExpr);
       break;
     }
@@ -61631,7 +61982,129 @@ SQLITE_PRIVATE void sqlite3CodeSubselect(
   }
   sqlite3ExprCachePop(pParse, 1);
 
-  return;
+  return rReg;
+}
+#endif /* SQLITE_OMIT_SUBQUERY */
+
+#ifndef SQLITE_OMIT_SUBQUERY
+/*
+** Generate code for an IN expression.
+**
+**      x IN (SELECT ...)
+**      x IN (value, value, ...)
+**
+** The left-hand side (LHS) is a scalar expression.  The right-hand side (RHS)
+** is an array of zero or more values.  The expression is true if the LHS is
+** contained within the RHS.  The value of the expression is unknown (NULL)
+** if the LHS is NULL or if the LHS is not contained within the RHS and the
+** RHS contains one or more NULL values.
+**
+** This routine generates code will jump to destIfFalse if the LHS is not 
+** contained within the RHS.  If due to NULLs we cannot determine if the LHS
+** is contained in the RHS then jump to destIfNull.  If the LHS is contained
+** within the RHS then fall through.
+*/
+static void sqlite3ExprCodeIN(
+  Parse *pParse,        /* Parsing and code generating context */
+  Expr *pExpr,          /* The IN expression */
+  int destIfFalse,      /* Jump here if LHS is not contained in the RHS */
+  int destIfNull        /* Jump here if the results are unknown due to NULLs */
+){
+  int rRhsHasNull = 0;  /* Register that is true if RHS contains NULL values */
+  char affinity;        /* Comparison affinity to use */
+  int eType;            /* Type of the RHS */
+  int r1;               /* Temporary use register */
+  Vdbe *v;              /* Statement under construction */
+
+  /* Compute the RHS.   After this step, the table with cursor
+  ** pExpr->iTable will contains the values that make up the RHS.
+  */
+  v = pParse->pVdbe;
+  assert( v!=0 );       /* OOM detected prior to this routine */
+  VdbeNoopComment((v, "begin IN expr"));
+  eType = sqlite3FindInIndex(pParse, pExpr, &rRhsHasNull);
+
+  /* Figure out the affinity to use to create a key from the results
+  ** of the expression. affinityStr stores a static string suitable for
+  ** P4 of OP_MakeRecord.
+  */
+  affinity = comparisonAffinity(pExpr);
+
+  /* Code the LHS, the <expr> from "<expr> IN (...)".
+  */
+  sqlite3ExprCachePush(pParse);
+  r1 = sqlite3GetTempReg(pParse);
+  sqlite3ExprCode(pParse, pExpr->pLeft, r1);
+  sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull);
+
+
+  if( eType==IN_INDEX_ROWID ){
+    /* In this case, the RHS is the ROWID of table b-tree
+    */
+    sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, destIfFalse);
+    sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, destIfFalse, r1);
+  }else{
+    /* In this case, the RHS is an index b-tree.
+    */
+    sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, &affinity, 1);
+
+    /* If the set membership test fails, then the result of the 
+    ** "x IN (...)" expression must be either 0 or NULL. If the set
+    ** contains no NULL values, then the result is 0. If the set 
+    ** contains one or more NULL values, then the result of the
+    ** expression is also NULL.
+    */
+    if( rRhsHasNull==0 || destIfFalse==destIfNull ){
+      /* This branch runs if it is known at compile time that the RHS
+      ** cannot contain NULL values. This happens as the result
+      ** of a "NOT NULL" constraint in the database schema.
+      **
+      ** Also run this branch if NULL is equivalent to FALSE
+      ** for this particular IN operator.
+      */
+      sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse, r1, 1);
+
+    }else{
+      /* In this branch, the RHS of the IN might contain a NULL and
+      ** the presence of a NULL on the RHS makes a difference in the
+      ** outcome.
+      */
+      int j1, j2, j3;
+
+      /* First check to see if the LHS is contained in the RHS.  If so,
+      ** then the presence of NULLs in the RHS does not matter, so jump
+      ** over all of the code that follows.
+      */
+      j1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, r1, 1);
+
+      /* Here we begin generating code that runs if the LHS is not
+      ** contained within the RHS.  Generate additional code that
+      ** tests the RHS for NULLs.  If the RHS contains a NULL then
+      ** jump to destIfNull.  If there are no NULLs in the RHS then
+      ** jump to destIfFalse.
+      */
+      j2 = sqlite3VdbeAddOp1(v, OP_NotNull, rRhsHasNull);
+      j3 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, rRhsHasNull, 1);
+      sqlite3VdbeAddOp2(v, OP_Integer, -1, rRhsHasNull);
+      sqlite3VdbeJumpHere(v, j3);
+      sqlite3VdbeAddOp2(v, OP_AddImm, rRhsHasNull, 1);
+      sqlite3VdbeJumpHere(v, j2);
+
+      /* Jump to the appropriate target depending on whether or not
+      ** the RHS contains a NULL
+      */
+      sqlite3VdbeAddOp2(v, OP_If, rRhsHasNull, destIfNull);
+      sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse);
+
+      /* The OP_Found at the top of this branch jumps here when true, 
+      ** causing the overall IN expression evaluation to fall through.
+      */
+      sqlite3VdbeJumpHere(v, j1);
+    }
+  }
+  sqlite3ReleaseTempReg(pParse, r1);
+  sqlite3ExprCachePop(pParse, 1);
+  VdbeComment((v, "end IN expr"));
 }
 #endif /* SQLITE_OMIT_SUBQUERY */
 
@@ -61722,17 +62195,31 @@ SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int
   assert( iReg>0 );  /* Register numbers are always positive */
   assert( iCol>=-1 && iCol<32768 );  /* Finite column numbers */
 
-  /* First replace any existing entry */
+  /* The SQLITE_ColumnCache flag disables the column cache.  This is used
+  ** for testing only - to verify that SQLite always gets the same answer
+  ** with and without the column cache.
+  */
+  if( pParse->db->flags & SQLITE_ColumnCache ) return;
+
+  /* First replace any existing entry.
+  **
+  ** Actually, the way the column cache is currently used, we are guaranteed
+  ** that the object will never already be in cache.  Verify this guarantee.
+  */
+#ifndef NDEBUG
   for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
+#if 0 /* This code wold remove the entry from the cache if it existed */
     if( p->iReg && p->iTable==iTab && p->iColumn==iCol ){
       cacheEntryClear(pParse, p);
       p->iLevel = pParse->iCacheLevel;
       p->iReg = iReg;
-      p->affChange = 0;
       p->lru = pParse->iCacheCnt++;
       return;
     }
+#endif
+    assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol );
   }
+#endif
 
   /* Find an empty slot and replace it */
   for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
@@ -61741,7 +62228,6 @@ SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int
       p->iTable = iTab;
       p->iColumn = iCol;
       p->iReg = iReg;
-      p->affChange = 0;
       p->tempReg = 0;
       p->lru = pParse->iCacheCnt++;
       return;
@@ -61763,7 +62249,6 @@ SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int
     p->iTable = iTab;
     p->iColumn = iCol;
     p->iReg = iReg;
-    p->affChange = 0;
     p->tempReg = 0;
     p->lru = pParse->iCacheCnt++;
     return;
@@ -61771,14 +62256,16 @@ SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int
 }
 
 /*
-** Indicate that a register is being overwritten.  Purge the register
-** from the column cache.
+** Indicate that registers between iReg..iReg+nReg-1 are being overwritten.
+** Purge the range of registers from the column cache.
 */
-SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg){
+SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg, int nReg){
   int i;
+  int iLast = iReg + nReg - 1;
   struct yColCache *p;
   for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
-    if( p->iReg==iReg ){
+    int r = p->iReg;
+    if( r>=iReg && r<=iLast ){
       cacheEntryClear(pParse, p);
       p->iReg = 0;
     }
@@ -61837,28 +62324,20 @@ static void sqlite3ExprCachePinRegister(Parse *pParse, int iReg){
 **
 ** There must be an open cursor to pTab in iTable when this routine
 ** is called.  If iColumn<0 then code is generated that extracts the rowid.
-**
-** This routine might attempt to reuse the value of the column that
-** has already been loaded into a register.  The value will always
-** be used if it has not undergone any affinity changes.  But if
-** an affinity change has occurred, then the cached value will only be
-** used if allowAffChng is true.
 */
 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
   Parse *pParse,   /* Parsing and code generating context */
   Table *pTab,     /* Description of the table we are reading from */
   int iColumn,     /* Index of the table column */
   int iTable,      /* The cursor pointing to the table */
-  int iReg,        /* Store results here */
-  int allowAffChng /* True if prior affinity changes are OK */
+  int iReg         /* Store results here */
 ){
   Vdbe *v = pParse->pVdbe;
   int i;
   struct yColCache *p;
 
   for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
-    if( p->iReg>0 && p->iTable==iTable && p->iColumn==iColumn
-           && (!p->affChange || allowAffChng) ){
+    if( p->iReg>0 && p->iTable==iTable && p->iColumn==iColumn ){
       p->lru = pParse->iCacheCnt++;
       sqlite3ExprCachePinRegister(pParse, p->iReg);
       return p->iReg;
@@ -61896,15 +62375,7 @@ SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){
 ** registers starting with iStart.
 */
 SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse *pParse, int iStart, int iCount){
-  int iEnd = iStart + iCount - 1;
-  int i;
-  struct yColCache *p;
-  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
-    int r = p->iReg;
-    if( r>=iStart && r<=iEnd ){
-      p->affChange = 1;
-    }
-  }
+  sqlite3ExprCacheRemove(pParse, iStart, iCount);
 }
 
 /*
@@ -61936,19 +62407,24 @@ SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse *pParse, int iFrom, int iTo, int n
   }
 }
 
+#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
 /*
 ** Return true if any register in the range iFrom..iTo (inclusive)
 ** is used as part of the column cache.
+**
+** This routine is used within assert() and testcase() macros only
+** and does not appear in a normal build.
 */
 static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){
   int i;
   struct yColCache *p;
   for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
     int r = p->iReg;
-    if( r>=iFrom && r<=iTo ) return 1;
+    if( r>=iFrom && r<=iTo ) return 1;    /*NO_TEST*/
   }
   return 0;
 }
+#endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */
 
 /*
 ** If the last instruction coded is an ephemeral copy of any of
@@ -62069,10 +62545,8 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
         assert( pParse->ckBase>0 );
         inReg = pExpr->iColumn + pParse->ckBase;
       }else{
-        testcase( (pExpr->flags & EP_AnyAff)!=0 );
         inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
-                                 pExpr->iColumn, pExpr->iTable, target,
-                                 pExpr->flags & EP_AnyAff);
+                                 pExpr->iColumn, pExpr->iTable, target);
       }
       break;
     }
@@ -62117,7 +62591,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
       assert( pExpr->u.zToken[0]!=0 );
       if( pExpr->u.zToken[1]==0
          && (pOp = sqlite3VdbeGetOp(v, -1))->opcode==OP_Variable
-         && pOp->p1+pOp->p3==pExpr->iTable
+         && pOp->p1+pOp->p3==pExpr->iColumn
          && pOp->p2+pOp->p3==target
          && pOp->p4.z==0
       ){
@@ -62128,7 +62602,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
         */
         pOp->p3++;
       }else{
-        sqlite3VdbeAddOp3(v, OP_Variable, pExpr->iTable, target, 1);
+        sqlite3VdbeAddOp3(v, OP_Variable, pExpr->iColumn, target, 1);
         if( pExpr->u.zToken[1]!=0 ){
           sqlite3VdbeChangeP4(v, -1, pExpr->u.zToken, 0);
         }
@@ -62189,8 +62663,8 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
       testcase( op==TK_GE );
       testcase( op==TK_EQ );
       testcase( op==TK_NE );
-      codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
-                                  pExpr->pRight, &r2, &regFree2);
+      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
+      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
       codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
                   r1, r2, inReg, SQLITE_STOREP2);
       testcase( regFree1==0 );
@@ -62201,8 +62675,8 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
     case TK_ISNOT: {
       testcase( op==TK_IS );
       testcase( op==TK_ISNOT );
-      codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
-                                  pExpr->pRight, &r2, &regFree2);
+      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
+      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
       op = (op==TK_IS) ? TK_EQ : TK_NE;
       codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
                   r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ);
@@ -62335,6 +62809,27 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
         sqlite3ErrorMsg(pParse, "unknown function: %.*s()", nId, zId);
         break;
       }
+
+      /* Attempt a direct implementation of the built-in COALESCE() and
+      ** IFNULL() functions.  This avoids unnecessary evalation of
+      ** arguments past the first non-NULL argument.
+      */
+      if( pDef->flags & SQLITE_FUNC_COALESCE ){
+        int endCoalesce = sqlite3VdbeMakeLabel(v);
+        assert( nFarg>=2 );
+        sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
+        for(i=1; i<nFarg; i++){
+          sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);
+          sqlite3ExprCacheRemove(pParse, target, 1);
+          sqlite3ExprCachePush(pParse);
+          sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
+          sqlite3ExprCachePop(pParse, 1);
+        }
+        sqlite3VdbeResolveLabel(v, endCoalesce);
+        break;
+      }
+
+
       if( pFarg ){
         r1 = sqlite3GetTempRange(pParse, nFarg);
         sqlite3ExprCachePush(pParse);     /* Ticket 2ea2425d34be */
@@ -62380,7 +62875,6 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
       if( nFarg ){
         sqlite3ReleaseTempRange(pParse, r1, nFarg);
       }
-      sqlite3ExprCacheAffinityChange(pParse, r1, nFarg);
       break;
     }
 #ifndef SQLITE_OMIT_SUBQUERY
@@ -62388,100 +62882,23 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
     case TK_SELECT: {
       testcase( op==TK_EXISTS );
       testcase( op==TK_SELECT );
-      sqlite3CodeSubselect(pParse, pExpr, 0, 0);
-      inReg = pExpr->iColumn;
+      inReg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
       break;
     }
     case TK_IN: {
-      int rNotFound = 0;
-      int rMayHaveNull = 0;
-      int j2, j3, j4, j5;
-      char affinity;
-      int eType;
-
-      VdbeNoopComment((v, "begin IN expr r%d", target));
-      eType = sqlite3FindInIndex(pParse, pExpr, &rMayHaveNull);
-      if( rMayHaveNull ){
-        rNotFound = ++pParse->nMem;
-      }
-
-      /* Figure out the affinity to use to create a key from the results
-      ** of the expression. affinityStr stores a static string suitable for
-      ** P4 of OP_MakeRecord.
-      */
-      affinity = comparisonAffinity(pExpr);
-
-
-      /* Code the <expr> from "<expr> IN (...)". The temporary table
-      ** pExpr->iTable contains the values that make up the (...) set.
-      */
-      sqlite3ExprCachePush(pParse);
-      sqlite3ExprCode(pParse, pExpr->pLeft, target);
-      j2 = sqlite3VdbeAddOp1(v, OP_IsNull, target);
-      if( eType==IN_INDEX_ROWID ){
-        j3 = sqlite3VdbeAddOp1(v, OP_MustBeInt, target);
-        j4 = sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, 0, target);
-        sqlite3VdbeAddOp2(v, OP_Integer, 1, target);
-        j5 = sqlite3VdbeAddOp0(v, OP_Goto);
-        sqlite3VdbeJumpHere(v, j3);
-        sqlite3VdbeJumpHere(v, j4);
-        sqlite3VdbeAddOp2(v, OP_Integer, 0, target);
-      }else{
-        r2 = regFree2 = sqlite3GetTempReg(pParse);
-
-        /* Create a record and test for set membership. If the set contains
-        ** the value, then jump to the end of the test code. The target
-        ** register still contains the true (1) value written to it earlier.
-        */
-        sqlite3VdbeAddOp4(v, OP_MakeRecord, target, 1, r2, &affinity, 1);
-        sqlite3VdbeAddOp2(v, OP_Integer, 1, target);
-        j5 = sqlite3VdbeAddOp3(v, OP_Found, pExpr->iTable, 0, r2);
-
-        /* If the set membership test fails, then the result of the 
-        ** "x IN (...)" expression must be either 0 or NULL. If the set
-        ** contains no NULL values, then the result is 0. If the set 
-        ** contains one or more NULL values, then the result of the
-        ** expression is also NULL.
-        */
-        if( rNotFound==0 ){
-          /* This branch runs if it is known at compile time (now) that 
-          ** the set contains no NULL values. This happens as the result
-          ** of a "NOT NULL" constraint in the database schema. No need
-          ** to test the data structure at runtime in this case.
-          */
-          sqlite3VdbeAddOp2(v, OP_Integer, 0, target);
-        }else{
-          /* This block populates the rNotFound register with either NULL
-          ** or 0 (an integer value). If the data structure contains one
-          ** or more NULLs, then set rNotFound to NULL. Otherwise, set it
-          ** to 0. If register rMayHaveNull is already set to some value
-          ** other than NULL, then the test has already been run and 
-          ** rNotFound is already populated.
-          */
-          static const char nullRecord[] = { 0x02, 0x00 };
-          j3 = sqlite3VdbeAddOp1(v, OP_NotNull, rMayHaveNull);
-          sqlite3VdbeAddOp2(v, OP_Null, 0, rNotFound);
-          sqlite3VdbeAddOp4(v, OP_Blob, 2, rMayHaveNull, 0, 
-                             nullRecord, P4_STATIC);
-          j4 = sqlite3VdbeAddOp3(v, OP_Found, pExpr->iTable, 0, rMayHaveNull);
-          sqlite3VdbeAddOp2(v, OP_Integer, 0, rNotFound);
-          sqlite3VdbeJumpHere(v, j4);
-          sqlite3VdbeJumpHere(v, j3);
-
-          /* Copy the value of register rNotFound (which is either NULL or 0)
-          ** into the target register. This will be the result of the
-          ** expression.
-          */
-          sqlite3VdbeAddOp2(v, OP_Copy, rNotFound, target);
-        }
-      }
-      sqlite3VdbeJumpHere(v, j2);
-      sqlite3VdbeJumpHere(v, j5);
-      sqlite3ExprCachePop(pParse, 1);
-      VdbeComment((v, "end IN expr r%d", target));
+      int destIfFalse = sqlite3VdbeMakeLabel(v);
+      int destIfNull = sqlite3VdbeMakeLabel(v);
+      sqlite3VdbeAddOp2(v, OP_Null, 0, target);
+      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
+      sqlite3VdbeAddOp2(v, OP_Integer, 1, target);
+      sqlite3VdbeResolveLabel(v, destIfFalse);
+      sqlite3VdbeAddOp2(v, OP_AddImm, target, 0);
+      sqlite3VdbeResolveLabel(v, destIfNull);
       break;
     }
-#endif
+#endif /* SQLITE_OMIT_SUBQUERY */
+
+
     /*
     **    x BETWEEN y AND z
     **
@@ -62498,8 +62915,8 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
       struct ExprList_item *pLItem = pExpr->x.pList->a;
       Expr *pRight = pLItem->pExpr;
 
-      codeCompareOperands(pParse, pLeft, &r1, &regFree1,
-                                  pRight, &r2, &regFree2);
+      r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);
+      r2 = sqlite3ExprCodeTemp(pParse, pRight, &regFree2);
       testcase( regFree1==0 );
       testcase( regFree2==0 );
       r3 = sqlite3GetTempReg(pParse);
@@ -62754,6 +63171,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int targe
     iMem = ++pParse->nMem;
     sqlite3VdbeAddOp2(v, OP_Copy, inReg, iMem);
     pExpr->iTable = iMem;
+    pExpr->op2 = pExpr->op;
     pExpr->op = TK_REGISTER;
   }
   return inReg;
@@ -62827,6 +63245,7 @@ static int isAppropriateForFactoring(Expr *p){
 static int evalConstExpr(Walker *pWalker, Expr *pExpr){
   Parse *pParse = pWalker->pParse;
   switch( pExpr->op ){
+    case TK_IN:
     case TK_REGISTER: {
       return WRC_Prune;
     }
@@ -62911,6 +63330,62 @@ SQLITE_PRIVATE int sqlite3ExprCodeExprList(
 }
 
 /*
+** Generate code for a BETWEEN operator.
+**
+**    x BETWEEN y AND z
+**
+** The above is equivalent to 
+**
+**    x>=y AND x<=z
+**
+** Code it as such, taking care to do the common subexpression
+** elementation of x.
+*/
+static void exprCodeBetween(
+  Parse *pParse,    /* Parsing and code generating context */
+  Expr *pExpr,      /* The BETWEEN expression */
+  int dest,         /* Jump here if the jump is taken */
+  int jumpIfTrue,   /* Take the jump if the BETWEEN is true */
+  int jumpIfNull    /* Take the jump if the BETWEEN is NULL */
+){
+  Expr exprAnd;     /* The AND operator in  x>=y AND x<=z  */
+  Expr compLeft;    /* The  x>=y  term */
+  Expr compRight;   /* The  x<=z  term */
+  Expr exprX;       /* The  x  subexpression */
+  int regFree1 = 0; /* Temporary use register */
+
+  assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
+  exprX = *pExpr->pLeft;
+  exprAnd.op = TK_AND;
+  exprAnd.pLeft = &compLeft;
+  exprAnd.pRight = &compRight;
+  compLeft.op = TK_GE;
+  compLeft.pLeft = &exprX;
+  compLeft.pRight = pExpr->x.pList->a[0].pExpr;
+  compRight.op = TK_LE;
+  compRight.pLeft = &exprX;
+  compRight.pRight = pExpr->x.pList->a[1].pExpr;
+  exprX.iTable = sqlite3ExprCodeTemp(pParse, &exprX, &regFree1);
+  exprX.op = TK_REGISTER;
+  if( jumpIfTrue ){
+    sqlite3ExprIfTrue(pParse, &exprAnd, dest, jumpIfNull);
+  }else{
+    sqlite3ExprIfFalse(pParse, &exprAnd, dest, jumpIfNull);
+  }
+  sqlite3ReleaseTempReg(pParse, regFree1);
+
+  /* Ensure adequate test coverage */
+  testcase( jumpIfTrue==0 && jumpIfNull==0 && regFree1==0 );
+  testcase( jumpIfTrue==0 && jumpIfNull==0 && regFree1!=0 );
+  testcase( jumpIfTrue==0 && jumpIfNull!=0 && regFree1==0 );
+  testcase( jumpIfTrue==0 && jumpIfNull!=0 && regFree1!=0 );
+  testcase( jumpIfTrue!=0 && jumpIfNull==0 && regFree1==0 );
+  testcase( jumpIfTrue!=0 && jumpIfNull==0 && regFree1!=0 );
+  testcase( jumpIfTrue!=0 && jumpIfNull!=0 && regFree1==0 );
+  testcase( jumpIfTrue!=0 && jumpIfNull!=0 && regFree1!=0 );
+}
+
+/*
 ** Generate code for a boolean expression such that a jump is made
 ** to the label "dest" if the expression is true but execution
 ** continues straight thru if the expression is false.
@@ -62976,8 +63451,8 @@ SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int
       testcase( op==TK_EQ );
       testcase( op==TK_NE );
       testcase( jumpIfNull==0 );
-      codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
-                                  pExpr->pRight, &r2, &regFree2);
+      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
+      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
       codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
                   r1, r2, dest, jumpIfNull);
       testcase( regFree1==0 );
@@ -62988,8 +63463,8 @@ SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int
     case TK_ISNOT: {
       testcase( op==TK_IS );
       testcase( op==TK_ISNOT );
-      codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
-                                  pExpr->pRight, &r2, &regFree2);
+      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
+      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
       op = (op==TK_IS) ? TK_EQ : TK_NE;
       codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
                   r1, r2, dest, SQLITE_NULLEQ);
@@ -63009,36 +63484,16 @@ SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int
       break;
     }
     case TK_BETWEEN: {
-      /*    x BETWEEN y AND z
-      **
-      ** Is equivalent to 
-      **
-      **    x>=y AND x<=z
-      **
-      ** Code it as such, taking care to do the common subexpression
-      ** elementation of x.
-      */
-      Expr exprAnd;
-      Expr compLeft;
-      Expr compRight;
-      Expr exprX;
-
-      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
-      exprX = *pExpr->pLeft;
-      exprAnd.op = TK_AND;
-      exprAnd.pLeft = &compLeft;
-      exprAnd.pRight = &compRight;
-      compLeft.op = TK_GE;
-      compLeft.pLeft = &exprX;
-      compLeft.pRight = pExpr->x.pList->a[0].pExpr;
-      compRight.op = TK_LE;
-      compRight.pLeft = &exprX;
-      compRight.pRight = pExpr->x.pList->a[1].pExpr;
-      exprX.iTable = sqlite3ExprCodeTemp(pParse, &exprX, &regFree1);
-      testcase( regFree1==0 );
-      exprX.op = TK_REGISTER;
       testcase( jumpIfNull==0 );
-      sqlite3ExprIfTrue(pParse, &exprAnd, dest, jumpIfNull);
+      exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull);
+      break;
+    }
+    case TK_IN: {
+      int destIfFalse = sqlite3VdbeMakeLabel(v);
+      int destIfNull = jumpIfNull ? dest : destIfFalse;
+      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
+      sqlite3VdbeAddOp2(v, OP_Goto, 0, dest);
+      sqlite3VdbeResolveLabel(v, destIfFalse);
       break;
     }
     default: {
@@ -63122,6 +63577,7 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
       break;
     }
     case TK_NOT: {
+      testcase( jumpIfNull==0 );
       sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
       break;
     }
@@ -63138,8 +63594,8 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
       testcase( op==TK_EQ );
       testcase( op==TK_NE );
       testcase( jumpIfNull==0 );
-      codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
-                                  pExpr->pRight, &r2, &regFree2);
+      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
+      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
       codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
                   r1, r2, dest, jumpIfNull);
       testcase( regFree1==0 );
@@ -63150,8 +63606,8 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
     case TK_ISNOT: {
       testcase( pExpr->op==TK_IS );
       testcase( pExpr->op==TK_ISNOT );
-      codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
-                                  pExpr->pRight, &r2, &regFree2);
+      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
+      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
       op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
       codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
                   r1, r2, dest, SQLITE_NULLEQ);
@@ -63169,36 +63625,18 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
       break;
     }
     case TK_BETWEEN: {
-      /*    x BETWEEN y AND z
-      **
-      ** Is equivalent to 
-      **
-      **    x>=y AND x<=z
-      **
-      ** Code it as such, taking care to do the common subexpression
-      ** elementation of x.
-      */
-      Expr exprAnd;
-      Expr compLeft;
-      Expr compRight;
-      Expr exprX;
-
-      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
-      exprX = *pExpr->pLeft;
-      exprAnd.op = TK_AND;
-      exprAnd.pLeft = &compLeft;
-      exprAnd.pRight = &compRight;
-      compLeft.op = TK_GE;
-      compLeft.pLeft = &exprX;
-      compLeft.pRight = pExpr->x.pList->a[0].pExpr;
-      compRight.op = TK_LE;
-      compRight.pLeft = &exprX;
-      compRight.pRight = pExpr->x.pList->a[1].pExpr;
-      exprX.iTable = sqlite3ExprCodeTemp(pParse, &exprX, &regFree1);
-      testcase( regFree1==0 );
-      exprX.op = TK_REGISTER;
       testcase( jumpIfNull==0 );
-      sqlite3ExprIfFalse(pParse, &exprAnd, dest, jumpIfNull);
+      exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull);
+      break;
+    }
+    case TK_IN: {
+      if( jumpIfNull ){
+        sqlite3ExprCodeIN(pParse, pExpr, dest, dest);
+      }else{
+        int destIfNull = sqlite3VdbeMakeLabel(v);
+        sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);
+        sqlite3VdbeResolveLabel(v, destIfNull);
+      }
       break;
     }
     default: {
@@ -63516,7 +63954,8 @@ SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
   int i, n;
   i = pParse->iRangeReg;
   n = pParse->nRangeReg;
-  if( nReg<=n && !usedAsColumnCache(pParse, i, i+n-1) ){
+  if( nReg<=n ){
+    assert( !usedAsColumnCache(pParse, i, i+n-1) );
     pParse->iRangeReg += nReg;
     pParse->nRangeReg -= nReg;
   }else{
@@ -63526,6 +63965,7 @@ SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
   return i;
 }
 SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
+  sqlite3ExprCacheRemove(pParse, iReg, nReg);
   if( nReg>pParse->nRangeReg ){
     pParse->nRangeReg = nReg;
     pParse->iRangeReg = iReg;
@@ -63547,8 +63987,6 @@ SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
 *************************************************************************
 ** This file contains C code routines that used to generate VDBE code
 ** that implements the ALTER TABLE command.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -64343,8 +64781,6 @@ exit_begin_add_column:
 **
 *************************************************************************
 ** This file contains code associated with the ANALYZE command.
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef SQLITE_OMIT_ANALYZE
 
@@ -64998,8 +65434,6 @@ SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
 **
 *************************************************************************
 ** This file contains code used to implement the ATTACH and DETACH commands.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 #ifndef SQLITE_OMIT_ATTACH
@@ -65138,7 +65572,7 @@ static void attachFunc(
   aNew->safety_level = 3;
 
 #if SQLITE_HAS_CODEC
-  {
+  if( rc==SQLITE_OK ){
     extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);
     extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);
     int nKey;
@@ -65155,13 +65589,13 @@ static void attachFunc(
       case SQLITE_BLOB:
         nKey = sqlite3_value_bytes(argv[2]);
         zKey = (char *)sqlite3_value_blob(argv[2]);
-        sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
+        rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
         break;
 
       case SQLITE_NULL:
         /* No key specified.  Use the key from the main database */
         sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
-        sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
+        rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
         break;
     }
   }
@@ -65540,8 +65974,6 @@ SQLITE_PRIVATE int sqlite3FixTriggerStep(
 ** API.  This facility is an optional feature of the library.  Embedded
 ** systems that do not need this facility may omit it by recompiling
 ** the library with -DSQLITE_OMIT_AUTHORIZATION=1
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -65801,8 +66233,6 @@ SQLITE_PRIVATE void sqlite3AuthContextPop(AuthContext *pContext){
 **     BEGIN TRANSACTION
 **     COMMIT
 **     ROLLBACK
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -66330,7 +66760,8 @@ SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char
 
   assert( db!=0 );
   assert( iDb>=0 && iDb<db->nDb );
-  assert( zTabName && zTabName[0] );
+  assert( zTabName );
+  testcase( zTabName[0]==0 );  /* Zero-length table names are allowed */
   pDb = &db->aDb[iDb];
   p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName,
                         sqlite3Strlen30(zTabName),0);
@@ -69197,7 +69628,6 @@ SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *pParse){
       pParse->rc = rc;
       return 1;
     }
-    assert( (db->flags & SQLITE_InTrans)==0 || db->autoCommit );
     assert( db->aDb[1].pSchema );
     sqlite3PagerJournalMode(sqlite3BtreePager(db->aDb[1].pBt),
                             db->dfltJournalMode);
@@ -69500,8 +69930,6 @@ SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
 **
 ** This file contains functions used to access the internal hash tables
 ** of user defined functions and collation sequences.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -69953,8 +70381,6 @@ SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
 *************************************************************************
 ** This file contains C code routines that are called by the parser
 ** in order to generate code for DELETE FROM statements.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -70307,7 +70733,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
     sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
     pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere,0,WHERE_DUPLICATES_OK);
     if( pWInfo==0 ) goto delete_from_cleanup;
-    regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0);
+    regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid);
     sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);
     if( db->flags & SQLITE_CountRows ){
       sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
@@ -70439,7 +70865,9 @@ SQLITE_PRIVATE void sqlite3GenerateRowDelete(
 
     /* TODO: Could use temporary registers here. Also could attempt to
     ** avoid copying the contents of the rowid register.  */
-    mask = sqlite3TriggerOldmask(pParse, pTrigger, 0, pTab, onconf);
+    mask = sqlite3TriggerColmask(
+        pParse, pTrigger, 0, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onconf
+    );
     mask |= sqlite3FkOldmask(pParse, pTab);
     iOld = pParse->nMem+1;
     pParse->nMem += (1 + pTab->nCol);
@@ -70571,13 +70999,11 @@ SQLITE_PRIVATE int sqlite3GenerateIndexKey(
   if( doMakeRec ){
     sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut);
     sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
-    sqlite3ExprCacheAffinityChange(pParse, regBase, nCol+1);
   }
   sqlite3ReleaseTempRange(pParse, regBase, nCol+1);
   return regBase;
 }
 
-
 /************** End of delete.c **********************************************/
 /************** Begin file func.c ********************************************/
 /*
@@ -70695,7 +71121,10 @@ static void lengthFunc(
 }
 
 /*
-** Implementation of the abs() function
+** Implementation of the abs() function.
+**
+** IMP: R-23979-26855 The abs(X) function returns the absolute value of
+** the numeric argument X. 
 */
 static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
   assert( argc==1 );
@@ -70705,6 +71134,9 @@ static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
       i64 iVal = sqlite3_value_int64(argv[0]);
       if( iVal<0 ){
         if( (iVal<<1)==0 ){
+          /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then
+          ** abs(X) throws an integer overflow error since there is no
+          ** equivalent positive 64-bit two complement value. */
           sqlite3_result_error(context, "integer overflow", -1);
           return;
         }
@@ -70714,10 +71146,16 @@ static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
       break;
     }
     case SQLITE_NULL: {
+      /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */
       sqlite3_result_null(context);
       break;
     }
     default: {
+      /* Because sqlite3_value_double() returns 0.0 if the argument is not
+      ** something that can be converted into a number, we have:
+      ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that
+      ** cannot be converted to a numeric value. 
+      */
       double rVal = sqlite3_value_double(argv[0]);
       if( rVal<0 ) rVal = -rVal;
       sqlite3_result_double(context, rVal);
@@ -70735,6 +71173,8 @@ static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
 ** If x is a blob, then we count bytes.
 **
 ** If p1 is negative, then we begin abs(p1) from the end of x[].
+**
+** If p2 is negative, return the p2 characters preceeding p1.
 */
 static void substrFunc(
   sqlite3_context *context,
@@ -70755,6 +71195,7 @@ static void substrFunc(
     return;
   }
   p0type = sqlite3_value_type(argv[0]);
+  p1 = sqlite3_value_int(argv[1]);
   if( p0type==SQLITE_BLOB ){
     len = sqlite3_value_bytes(argv[0]);
     z = sqlite3_value_blob(argv[0]);
@@ -70764,11 +71205,12 @@ static void substrFunc(
     z = sqlite3_value_text(argv[0]);
     if( z==0 ) return;
     len = 0;
-    for(z2=z; *z2; len++){
-      SQLITE_SKIP_UTF8(z2);
+    if( p1<0 ){
+      for(z2=z; *z2; len++){
+        SQLITE_SKIP_UTF8(z2);
+      }
     }
   }
-  p1 = sqlite3_value_int(argv[1]);
   if( argc==3 ){
     p2 = sqlite3_value_int(argv[2]);
     if( p2<0 ){
@@ -70798,10 +71240,6 @@ static void substrFunc(
     }
   }
   assert( p1>=0 && p2>=0 );
-  if( p1+p2>len ){
-    p2 = len-p1;
-    if( p2<0 ) p2 = 0;
-  }
   if( p0type!=SQLITE_BLOB ){
     while( *z && p1 ){
       SQLITE_SKIP_UTF8(z);
@@ -70812,6 +71250,10 @@ static void substrFunc(
     }
     sqlite3_result_text(context, (char*)z, (int)(z2-z), SQLITE_TRANSIENT);
   }else{
+    if( p1+p2>len ){
+      p2 = len-p1;
+      if( p2<0 ) p2 = 0;
+    }
     sqlite3_result_blob(context, (char*)&z[p1], (int)p2, SQLITE_TRANSIENT);
   }
 }
@@ -70913,6 +71355,14 @@ static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
   }
 }
 
+
+#if 0  /* This function is never used. */
+/*
+** The COALESCE() and IFNULL() functions used to be implemented as shown
+** here.  But now they are implemented as VDBE code so that unused arguments
+** do not have to be computed.  This legacy implementation is retained as
+** comment.
+*/
 /*
 ** Implementation of the IFNULL(), NVL(), and COALESCE() functions.  
 ** All three do the same thing.  They return the first non-NULL
@@ -70931,6 +71381,8 @@ static void ifnullFunc(
     }
   }
 }
+#endif /* NOT USED */
+#define ifnullFunc versionFunc   /* Substitute function - never called */
 
 /*
 ** Implementation of random().  Return a random integer.  
@@ -71605,9 +72057,16 @@ static void trimFunc(
 }
 
 
+/* IMP: R-25361-16150 This function is omitted from SQLite by default. It
+** is only available if the SQLITE_SOUNDEX compile-time option is used
+** when SQLite is built.
+*/
 #ifdef SQLITE_SOUNDEX
 /*
 ** Compute the soundex encoding of a word.
+**
+** IMP: R-59782-00072 The soundex(X) function returns a string that is the
+** soundex encoding of the string X. 
 */
 static void soundexFunc(
   sqlite3_context *context,
@@ -71651,10 +72110,12 @@ static void soundexFunc(
     zResult[j] = 0;
     sqlite3_result_text(context, zResult, 4, SQLITE_TRANSIENT);
   }else{
+    /* IMP: R-64894-50321 The string "?000" is returned if the argument
+    ** is NULL or contains no ASCII alphabetic characters. */
     sqlite3_result_text(context, "?000", 4, SQLITE_STATIC);
   }
 }
-#endif
+#endif /* SQLITE_SOUNDEX */
 
 #ifndef SQLITE_OMIT_LOAD_EXTENSION
 /*
@@ -72015,10 +72476,12 @@ SQLITE_PRIVATE void sqlite3RegisterGlobalFunctions(void){
     FUNCTION(upper,              1, 0, 0, upperFunc        ),
     FUNCTION(lower,              1, 0, 0, lowerFunc        ),
     FUNCTION(coalesce,           1, 0, 0, 0                ),
-    FUNCTION(coalesce,          -1, 0, 0, ifnullFunc       ),
     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},
     FUNCTION(hex,                1, 0, 0, hexFunc          ),
-    FUNCTION(ifnull,             2, 0, 1, ifnullFunc       ),
+/*  FUNCTION(ifnull,             2, 0, 0, ifnullFunc       ), */
+    {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0},
     FUNCTION(random,             0, 0, 0, randomFunc       ),
     FUNCTION(randomblob,         1, 0, 0, randomBlob       ),
     FUNCTION(nullif,             2, 0, 1, nullifFunc       ),
@@ -72468,7 +72931,7 @@ static void fkLookupParent(
   
       sqlite3VdbeAddOp3(v, OP_MakeRecord, regTemp, nCol, regRec);
       sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
-      sqlite3VdbeAddOp3(v, OP_Found, iCur, iOk, regRec);
+      sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0);
   
       sqlite3ReleaseTempReg(pParse, regRec);
       sqlite3ReleaseTempRange(pParse, regTemp, nCol);
@@ -73274,8 +73737,6 @@ SQLITE_PRIVATE void sqlite3FkDelete(Table *pTab){
 *************************************************************************
 ** This file contains C code routines that are called by the parser
 ** to handle INSERT statements in SQLite.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -75095,8 +75556,6 @@ static int xferOptimization(
 ** implement the programmer interface to the library.  Routines in
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -75241,8 +75700,6 @@ exec_out:
 *************************************************************************
 ** This file contains code used to dynamically load extensions into
 ** the SQLite library.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 #ifndef SQLITE_CORE
@@ -75266,8 +75723,6 @@ exec_out:
 ** an SQLite instance.  Shared libraries that intend to be loaded
 ** as extensions by SQLite should #include this file instead of 
 ** sqlite3.h.
-**
-** @(#) $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef _SQLITE3EXT_H_
 #define _SQLITE3EXT_H_
@@ -76235,8 +76690,6 @@ SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
 **
 *************************************************************************
 ** This file contains code used to implement the PRAGMA command.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /* Ignore this whole file if pragmas are disabled
@@ -77354,6 +77807,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
         sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1);   /* increment entry count */
         for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
           int jmp2;
+          int r1;
           static const VdbeOpList idxErr[] = {
             { OP_AddImm,      1, -1,  0},
             { OP_String8,     0,  3,  0},    /* 1 */
@@ -77367,8 +77821,8 @@ SQLITE_PRIVATE void sqlite3Pragma(
             { OP_IfPos,       1,  0,  0},    /* 9 */
             { OP_Halt,        0,  0,  0},
           };
-          sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 1);
-          jmp2 = sqlite3VdbeAddOp3(v, OP_Found, j+2, 0, 3);
+          r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);
+          jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
           addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
           sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
           sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
@@ -77675,8 +78129,6 @@ pragma_out:
 ** This file contains the implementation of the sqlite3_prepare()
 ** interface, and routines that contribute to loading the database schema
 ** from disk.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -78133,7 +78585,7 @@ static void schemaIsValid(Parse *pParse){
     }
 
     /* Read the schema cookie from the database. If it does not match the 
-    ** value stored as part of the in the in-memory schema representation,
+    ** value stored as part of the in-memory schema representation,
     ** set Parse.rc to SQLITE_SCHEMA. */
     sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie);
     if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){
@@ -78187,6 +78639,7 @@ static int sqlite3Prepare(
   const char *zSql,         /* UTF-8 encoded SQL statement. */
   int nBytes,               /* Length of zSql in bytes. */
   int saveSqlFlag,          /* True to copy SQL text into the sqlite3_stmt */
+  Vdbe *pReprepare,         /* VM being reprepared */
   sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */
   const char **pzTail       /* OUT: End of parsed string */
 ){
@@ -78201,6 +78654,7 @@ static int sqlite3Prepare(
     rc = SQLITE_NOMEM;
     goto end_prepare;
   }
+  pParse->pReprepare = pReprepare;
 
   if( sqlite3SafetyOn(db) ){
     rc = SQLITE_MISUSE;
@@ -78358,6 +78812,7 @@ static int sqlite3LockAndPrepare(
   const char *zSql,         /* UTF-8 encoded SQL statement. */
   int nBytes,               /* Length of zSql in bytes. */
   int saveSqlFlag,          /* True to copy SQL text into the sqlite3_stmt */
+  Vdbe *pOld,               /* VM being reprepared */
   sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */
   const char **pzTail       /* OUT: End of parsed string */
 ){
@@ -78369,10 +78824,10 @@ static int sqlite3LockAndPrepare(
   }
   sqlite3_mutex_enter(db->mutex);
   sqlite3BtreeEnterAll(db);
-  rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, ppStmt, pzTail);
+  rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);
   if( rc==SQLITE_SCHEMA ){
     sqlite3_finalize(*ppStmt);
-    rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, ppStmt, pzTail);
+    rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);
   }
   sqlite3BtreeLeaveAll(db);
   sqlite3_mutex_leave(db->mutex);
@@ -78398,7 +78853,7 @@ SQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){
   assert( zSql!=0 );  /* Reprepare only called for prepare_v2() statements */
   db = sqlite3VdbeDb(p);
   assert( sqlite3_mutex_held(db->mutex) );
-  rc = sqlite3LockAndPrepare(db, zSql, -1, 0, &pNew, 0);
+  rc = sqlite3LockAndPrepare(db, zSql, -1, 0, p, &pNew, 0);
   if( rc ){
     if( rc==SQLITE_NOMEM ){
       db->mallocFailed = 1;
@@ -78432,7 +78887,7 @@ SQLITE_API int sqlite3_prepare(
   const char **pzTail       /* OUT: End of parsed string */
 ){
   int rc;
-  rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,ppStmt,pzTail);
+  rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);
   assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */
   return rc;
 }
@@ -78444,7 +78899,7 @@ SQLITE_API int sqlite3_prepare_v2(
   const char **pzTail       /* OUT: End of parsed string */
 ){
   int rc;
-  rc = sqlite3LockAndPrepare(db,zSql,nBytes,1,ppStmt,pzTail);
+  rc = sqlite3LockAndPrepare(db,zSql,nBytes,1,0,ppStmt,pzTail);
   assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */
   return rc;
 }
@@ -78478,7 +78933,7 @@ static int sqlite3Prepare16(
   sqlite3_mutex_enter(db->mutex);
   zSql8 = sqlite3Utf16to8(db, zSql, nBytes);
   if( zSql8 ){
-    rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, ppStmt, &zTail8);
+    rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);
   }
 
   if( zTail8 && pzTail ){
@@ -78546,8 +79001,6 @@ SQLITE_API int sqlite3_prepare16_v2(
 *************************************************************************
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 
@@ -78726,51 +79179,80 @@ static int columnIndex(Table *pTab, const char *zCol){
 }
 
 /*
-** Create an expression node for an identifier with the name of zName
+** Search the first N tables in pSrc, from left to right, looking for a
+** table that has a column named zCol.  
+**
+** When found, set *piTab and *piCol to the table index and column index
+** of the matching column and return TRUE.
+**
+** If not found, return FALSE.
 */
-SQLITE_PRIVATE Expr *sqlite3CreateIdExpr(Parse *pParse, const char *zName){
-  return sqlite3Expr(pParse->db, TK_ID, zName);
+static int tableAndColumnIndex(
+  SrcList *pSrc,       /* Array of tables to search */
+  int N,               /* Number of tables in pSrc->a[] to search */
+  const char *zCol,    /* Name of the column we are looking for */
+  int *piTab,          /* Write index of pSrc->a[] here */
+  int *piCol           /* Write index of pSrc->a[*piTab].pTab->aCol[] here */
+){
+  int i;               /* For looping over tables in pSrc */
+  int iCol;            /* Index of column matching zCol */
+
+  assert( (piTab==0)==(piCol==0) );  /* Both or neither are NULL */
+  for(i=0; i<N; i++){
+    iCol = columnIndex(pSrc->a[i].pTab, zCol);
+    if( iCol>=0 ){
+      if( piTab ){
+        *piTab = i;
+        *piCol = iCol;
+      }
+      return 1;
+    }
+  }
+  return 0;
 }
 
 /*
-** Add a term to the WHERE expression in *ppExpr that requires the
-** zCol column to be equal in the two tables pTab1 and pTab2.
+** This function is used to add terms implied by JOIN syntax to the
+** WHERE clause expression of a SELECT statement. The new term, which
+** is ANDed with the existing WHERE clause, is of the form:
+**
+**    (tab1.col1 = tab2.col2)
+**
+** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the 
+** (iSrc+1)'th. Column col1 is column iColLeft of tab1, and col2 is
+** column iColRight of tab2.
 */
 static void addWhereTerm(
-  Parse *pParse,           /* Parsing context */
-  const char *zCol,        /* Name of the column */
-  const Table *pTab1,      /* First table */
-  const char *zAlias1,     /* Alias for first table.  May be NULL */
-  const Table *pTab2,      /* Second table */
-  const char *zAlias2,     /* Alias for second table.  May be NULL */
-  int iRightJoinTable,     /* VDBE cursor for the right table */
-  Expr **ppExpr,           /* Add the equality term to this expression */
-  int isOuterJoin          /* True if dealing with an OUTER join */
+  Parse *pParse,                  /* Parsing context */
+  SrcList *pSrc,                  /* List of tables in FROM clause */
+  int iLeft,                      /* Index of first table to join in pSrc */
+  int iColLeft,                   /* Index of column in first table */
+  int iRight,                     /* Index of second table in pSrc */
+  int iColRight,                  /* Index of column in second table */
+  int isOuterJoin,                /* True if this is an OUTER join */
+  Expr **ppWhere                  /* IN/OUT: The WHERE clause to add to */
 ){
-  Expr *pE1a, *pE1b, *pE1c;
-  Expr *pE2a, *pE2b, *pE2c;
-  Expr *pE;
+  sqlite3 *db = pParse->db;
+  Expr *pE1;
+  Expr *pE2;
+  Expr *pEq;
 
-  pE1a = sqlite3CreateIdExpr(pParse, zCol);
-  pE2a = sqlite3CreateIdExpr(pParse, zCol);
-  if( zAlias1==0 ){
-    zAlias1 = pTab1->zName;
-  }
-  pE1b = sqlite3CreateIdExpr(pParse, zAlias1);
-  if( zAlias2==0 ){
-    zAlias2 = pTab2->zName;
-  }
-  pE2b = sqlite3CreateIdExpr(pParse, zAlias2);
-  pE1c = sqlite3PExpr(pParse, TK_DOT, pE1b, pE1a, 0);
-  pE2c = sqlite3PExpr(pParse, TK_DOT, pE2b, pE2a, 0);
-  pE = sqlite3PExpr(pParse, TK_EQ, pE1c, pE2c, 0);
-  if( pE && isOuterJoin ){
-    ExprSetProperty(pE, EP_FromJoin);
-    assert( !ExprHasAnyProperty(pE, EP_TokenOnly|EP_Reduced) );
-    ExprSetIrreducible(pE);
-    pE->iRightJoinTable = (i16)iRightJoinTable;
+  assert( iLeft<iRight );
+  assert( pSrc->nSrc>iRight );
+  assert( pSrc->a[iLeft].pTab );
+  assert( pSrc->a[iRight].pTab );
+
+  pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft);
+  pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight);
+
+  pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0);
+  if( pEq && isOuterJoin ){
+    ExprSetProperty(pEq, EP_FromJoin);
+    assert( !ExprHasAnyProperty(pEq, EP_TokenOnly|EP_Reduced) );
+    ExprSetIrreducible(pEq);
+    pEq->iRightJoinTable = (i16)pE2->iTable;
   }
-  *ppExpr = sqlite3ExprAnd(pParse->db,*ppExpr, pE);
+  *ppWhere = sqlite3ExprAnd(db, *ppWhere, pEq);
 }
 
 /*
@@ -78850,13 +79332,15 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){
            "an ON or USING clause", 0);
         return 1;
       }
-      for(j=0; j<pLeftTab->nCol; j++){
-        char *zName = pLeftTab->aCol[j].zName;
-        if( columnIndex(pRightTab, zName)>=0 ){
-          addWhereTerm(pParse, zName, pLeftTab, pLeft->zAlias, 
-                              pRightTab, pRight->zAlias,
-                              pRight->iCursor, &p->pWhere, isOuter);
-          
+      for(j=0; j<pRightTab->nCol; j++){
+        char *zName;   /* Name of column in the right table */
+        int iLeft;     /* Matching left table */
+        int iLeftCol;  /* Matching column in the left table */
+
+        zName = pRightTab->aCol[j].zName;
+        if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol) ){
+          addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j,
+                       isOuter, &p->pWhere);
         }
       }
     }
@@ -78888,15 +79372,22 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){
     if( pRight->pUsing ){
       IdList *pList = pRight->pUsing;
       for(j=0; j<pList->nId; j++){
-        char *zName = pList->a[j].zName;
-        if( columnIndex(pLeftTab, zName)<0 || columnIndex(pRightTab, zName)<0 ){
+        char *zName;     /* Name of the term in the USING clause */
+        int iLeft;       /* Table on the left with matching column name */
+        int iLeftCol;    /* Column number of matching column on the left */
+        int iRightCol;   /* Column number of matching column on the right */
+
+        zName = pList->a[j].zName;
+        iRightCol = columnIndex(pRightTab, zName);
+        if( iRightCol<0
+         || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol)
+        ){
           sqlite3ErrorMsg(pParse, "cannot join using column %s - column "
             "not present in both tables", zName);
           return 1;
         }
-        addWhereTerm(pParse, zName, pLeftTab, pLeft->zAlias, 
-                            pRightTab, pRight->zAlias,
-                            pRight->iCursor, &p->pWhere, isOuter);
+        addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, iRightCol,
+                     isOuter, &p->pWhere);
       }
     }
   }
@@ -78983,8 +79474,8 @@ static void codeDistinct(
 
   v = pParse->pVdbe;
   r1 = sqlite3GetTempReg(pParse);
+  sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N);
   sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);
-  sqlite3VdbeAddOp3(v, OP_Found, iTab, addrRepeat, r1);
   sqlite3VdbeAddOp2(v, OP_IdxInsert, iTab, r1);
   sqlite3ReleaseTempReg(pParse, r1);
 }
@@ -79225,8 +79716,7 @@ static void selectInnerLoop(
   if( p->iLimit ){
     assert( pOrderBy==0 );  /* If there is an ORDER BY, the call to
                             ** pushOntoSorter() would have cleared p->iLimit */
-    sqlite3VdbeAddOp2(v, OP_AddImm, p->iLimit, -1);
-    sqlite3VdbeAddOp2(v, OP_IfZero, p->iLimit, iBreak);
+    sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
   }
 }
 
@@ -79456,7 +79946,7 @@ static const char *columnType(
         ** of the SELECT statement. Return the declaration type and origin
         ** data for the result-set column of the sub-select.
         */
-        if( ALWAYS(iCol>=0 && iCol<pS->pEList->nExpr) ){
+        if( iCol>=0 && ALWAYS(iCol<pS->pEList->nExpr) ){
           /* If iCol is less than zero, then the expression requests the
           ** rowid of the sub-select or view. This expression is legal (see 
           ** test case misc2.2.2) - it always evaluates to NULL.
@@ -79852,7 +80342,7 @@ static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){
   Vdbe *v = 0;
   int iLimit = 0;
   int iOffset;
-  int addr1;
+  int addr1, n;
   if( p->iLimit ) return;
 
   /* 
@@ -79867,10 +80357,18 @@ static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){
     p->iLimit = iLimit = ++pParse->nMem;
     v = sqlite3GetVdbe(pParse);
     if( NEVER(v==0) ) return;  /* VDBE should have already been allocated */
-    sqlite3ExprCode(pParse, p->pLimit, iLimit);
-    sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit);
-    VdbeComment((v, "LIMIT counter"));
-    sqlite3VdbeAddOp2(v, OP_IfZero, iLimit, iBreak);
+    if( sqlite3ExprIsInteger(p->pLimit, &n) ){
+      sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit);
+      VdbeComment((v, "LIMIT counter"));
+      if( n==0 ){
+        sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);
+      }
+    }else{
+      sqlite3ExprCode(pParse, p->pLimit, iLimit);
+      sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit);
+      VdbeComment((v, "LIMIT counter"));
+      sqlite3VdbeAddOp2(v, OP_IfZero, iLimit, iBreak);
+    }
     if( p->pOffset ){
       p->iOffset = iOffset = ++pParse->nMem;
       pParse->nMem++;   /* Allocate an extra register for limit+offset */
@@ -80206,7 +80704,7 @@ static int multiSelect(
       sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak);
       r1 = sqlite3GetTempReg(pParse);
       iStart = sqlite3VdbeAddOp2(v, OP_RowKey, tab1, r1);
-      sqlite3VdbeAddOp3(v, OP_NotFound, tab2, iCont, r1);
+      sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
       sqlite3ReleaseTempReg(pParse, r1);
       selectInnerLoop(pParse, p, p->pEList, tab1, p->pEList->nExpr,
                       0, -1, &dest, iCont, iBreak);
@@ -80425,8 +80923,7 @@ static int generateOutputSubroutine(
   /* Jump to the end of the loop if the LIMIT is reached.
   */
   if( p->iLimit ){
-    sqlite3VdbeAddOp2(v, OP_AddImm, p->iLimit, -1);
-    sqlite3VdbeAddOp2(v, OP_IfZero, p->iLimit, iBreak);
+    sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
   }
 
   /* Generate the subroutine return
@@ -81010,7 +81507,7 @@ static void substSelect(
 **
 **  (11)  The subquery and the outer query do not both have ORDER BY clauses.
 **
-**  (12)  Not implemented.  Subsumed into restriction (3).  Was previously
+**  (**)  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
@@ -81084,6 +81581,7 @@ static int flattenSubquery(
   */
   assert( p!=0 );
   assert( p->pPrior==0 );  /* Unable to flatten compound queries */
+  if( db->flags & SQLITE_QueryFlattener ) return 0;
   pSrc = p->pSrc;
   assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );
   pSubitem = &pSrc->a[iFrom];
@@ -81707,14 +82205,14 @@ static int selectExpander(Walker *pWalker, Select *p){
             }
 
             if( i>0 && zTName==0 ){
-              struct SrcList_item *pLeft = &pTabList->a[i-1];
-              if( (pLeft[1].jointype & JT_NATURAL)!=0 &&
-                        columnIndex(pLeft->pTab, zName)>=0 ){
+              if( (pFrom->jointype & JT_NATURAL)!=0
+                && tableAndColumnIndex(pTabList, i, zName, 0, 0)
+              ){
                 /* In a NATURAL join, omit the join columns from the 
-                ** table on the right */
+                ** table to the right of the join */
                 continue;
               }
-              if( sqlite3IdListIndex(pLeft[1].pUsing, zName)>=0 ){
+              if( sqlite3IdListIndex(pFrom->pUsing, zName)>=0 ){
                 /* In a join with a USING clause, omit columns in the
                 ** using clause from the table on the right. */
                 continue;
@@ -81981,8 +82479,8 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
     sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF->iMem,
                       (void*)pF->pFunc, P4_FUNCDEF);
     sqlite3VdbeChangeP5(v, (u8)nArg);
-    sqlite3ReleaseTempRange(pParse, regAgg, nArg);
     sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
+    sqlite3ReleaseTempRange(pParse, regAgg, nArg);
     if( addrNext ){
       sqlite3VdbeResolveLabel(v, addrNext);
       sqlite3ExprCacheClear(pParse);
@@ -82408,7 +82906,7 @@ SQLITE_PRIVATE int sqlite3Select(
             int r2;
 
             r2 = sqlite3ExprCodeGetColumn(pParse, 
-                               pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0);
+                               pCol->pTab, pCol->iColumn, pCol->iTable, r1);
             if( r1!=r2 ){
               sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
             }
@@ -82794,8 +83292,6 @@ SQLITE_PRIVATE void sqlite3PrintSelect(Select *p, int indent){
 **
 ** These routines are in a separate files so that they will not be linked
 ** if they are not used.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 #ifndef SQLITE_OMIT_GET_TABLE
@@ -82986,9 +83482,7 @@ SQLITE_API void sqlite3_free_table(
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-**
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
+** This file contains the implementation for TRIGGERs
 */
 
 #ifndef SQLITE_OMIT_TRIGGER
@@ -83790,7 +84284,8 @@ static TriggerPrg *codeRowTrigger(
   pProgram->nRef = 1;
   pPrg->pTrigger = pTrigger;
   pPrg->orconf = orconf;
-  pPrg->oldmask = 0xffffffff;
+  pPrg->aColmask[0] = 0xffffffff;
+  pPrg->aColmask[1] = 0xffffffff;
 
   /* Allocate and populate a new Parse context to use for coding the 
   ** trigger sub-program.  */
@@ -83851,7 +84346,8 @@ static TriggerPrg *codeRowTrigger(
     pProgram->nMem = pSubParse->nMem;
     pProgram->nCsr = pSubParse->nTab;
     pProgram->token = (void *)pTrigger;
-    pPrg->oldmask = pSubParse->oldmask;
+    pPrg->aColmask[0] = pSubParse->oldmask;
+    pPrg->aColmask[1] = pSubParse->newmask;
     sqlite3VdbeDelete(v);
   }
 
@@ -84011,28 +84507,36 @@ SQLITE_PRIVATE void sqlite3CodeRowTrigger(
 }
 
 /*
-** Triggers fired by UPDATE or DELETE statements may access values stored
-** in the old.* pseudo-table. This function returns a 32-bit bitmask
-** indicating which columns of the old.* table actually are used by
-** triggers. This information may be used by the caller to avoid having
-** to load the entire old.* record into memory when executing an UPDATE
-** or DELETE command.
+** Triggers may access values stored in the old.* or new.* pseudo-table. 
+** This function returns a 32-bit bitmask indicating which columns of the 
+** old.* or new.* tables actually are used by triggers. This information 
+** may be used by the caller, for example, to avoid having to load the entire
+** old.* record into memory when executing an UPDATE or DELETE command.
 **
 ** Bit 0 of the returned mask is set if the left-most column of the
-** table may be accessed using an old.<col> reference. Bit 1 is set if
+** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
 ** the second leftmost column value is required, and so on. If there
 ** are more than 32 columns in the table, and at least one of the columns
 ** with an index greater than 32 may be accessed, 0xffffffff is returned.
 **
-** It is not possible to determine if the old.rowid column is accessed
-** by triggers. The caller must always assume that it is.
+** It is not possible to determine if the old.rowid or new.rowid column is 
+** accessed by triggers. The caller must always assume that it is.
 **
-** There is no equivalent function for new.* references.
+** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned
+** applies to the old.* table. If 1, the new.* table.
+**
+** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE
+** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only
+** included in the returned mask if the TRIGGER_BEFORE bit is set in the
+** tr_tm parameter. Similarly, values accessed by AFTER triggers are only
+** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm.
 */
-SQLITE_PRIVATE u32 sqlite3TriggerOldmask(
+SQLITE_PRIVATE u32 sqlite3TriggerColmask(
   Parse *pParse,       /* Parse context */
   Trigger *pTrigger,   /* List of triggers on table pTab */
   ExprList *pChanges,  /* Changes list for any UPDATE OF triggers */
+  int isNew,           /* 1 for new.* ref mask, 0 for old.* ref mask */
+  int tr_tm,           /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */
   Table *pTab,         /* The table to code triggers from */
   int orconf           /* Default ON CONFLICT policy for trigger steps */
 ){
@@ -84040,12 +84544,15 @@ SQLITE_PRIVATE u32 sqlite3TriggerOldmask(
   u32 mask = 0;
   Trigger *p;
 
+  assert( isNew==1 || isNew==0 );
   for(p=pTrigger; p; p=p->pNext){
-    if( p->op==op && checkColumnOverlap(p->pColumns,pChanges) ){
+    if( p->op==op && (tr_tm&p->tr_tm)
+     && checkColumnOverlap(p->pColumns,pChanges)
+    ){
       TriggerPrg *pPrg;
       pPrg = getRowTrigger(pParse, p, pTab, orconf);
       if( pPrg ){
-        mask |= pPrg->oldmask;
+        mask |= pPrg->aColmask[isNew];
       }
     }
   }
@@ -84070,8 +84577,6 @@ SQLITE_PRIVATE u32 sqlite3TriggerOldmask(
 *************************************************************************
 ** This file contains C code routines that are called by the parser
 ** to handle UPDATE statements.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -84171,14 +84676,15 @@ SQLITE_PRIVATE void sqlite3Update(
   AuthContext sContext;  /* The authorization context */
   NameContext sNC;       /* The name-context to resolve expressions in */
   int iDb;               /* Database containing the table being updated */
-  int j1;                /* Addresses of jump instructions */
   int okOnePass;         /* True for one-pass algorithm without the FIFO */
   int hasFK;             /* True if foreign key processing is required */
 
 #ifndef SQLITE_OMIT_TRIGGER
-  int isView;                  /* Trying to update a view */
-  Trigger *pTrigger;           /* List of triggers on pTab, if required */
+  int isView;            /* True when updating a view (INSTEAD OF trigger) */
+  Trigger *pTrigger;     /* List of triggers on pTab, if required */
+  int tmask;             /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */
 #endif
+  int newmask;           /* Mask of NEW.* columns accessed by BEFORE triggers */
 
   /* Register Allocations */
   int regRowCount = 0;   /* A count of rows changed */
@@ -84206,11 +84712,13 @@ SQLITE_PRIVATE void sqlite3Update(
   ** updated is a view.
   */
 #ifndef SQLITE_OMIT_TRIGGER
-  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, 0);
+  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, &tmask);
   isView = pTab->pSelect!=0;
+  assert( pTrigger || tmask==0 );
 #else
 # define pTrigger 0
 # define isView 0
+# define tmask 0
 #endif
 #ifdef SQLITE_OMIT_VIEW
 # undef isView
@@ -84220,7 +84728,7 @@ SQLITE_PRIVATE void sqlite3Update(
   if( sqlite3ViewGetColumnNames(pParse, pTab) ){
     goto update_cleanup;
   }
-  if( sqlite3IsReadOnly(pParse, pTab, (pTrigger?1:0)) ){
+  if( sqlite3IsReadOnly(pParse, pTab, tmask) ){
     goto update_cleanup;
   }
   aXRef = sqlite3DbMallocRaw(db, sizeof(int) * pTab->nCol );
@@ -84448,7 +84956,9 @@ SQLITE_PRIVATE void sqlite3Update(
   ** with the required old.* column data.  */
   if( hasFK || pTrigger ){
     u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);
-    oldmask |= sqlite3TriggerOldmask(pParse, pTrigger, pChanges, pTab, onError);
+    oldmask |= sqlite3TriggerColmask(pParse, 
+        pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError
+    );
     for(i=0; i<pTab->nCol; i++){
       if( aXRef[i]<0 || oldmask==0xffffffff || (oldmask & (1<<i)) ){
         sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regOld+i);
@@ -84465,24 +84975,44 @@ SQLITE_PRIVATE void sqlite3Update(
   /* Populate the array of registers beginning at regNew with the new
   ** row data. This array is used to check constaints, create the new
   ** table and index records, and as the values for any new.* references
-  ** made by triggers.  */
+  ** made by triggers.
+  **
+  ** If there are one or more BEFORE triggers, then do not populate the
+  ** registers associated with columns that are (a) not modified by
+  ** this UPDATE statement and (b) not accessed by new.* references. The
+  ** values for registers not modified by the UPDATE must be reloaded from 
+  ** the database after the BEFORE triggers are fired anyway (as the trigger 
+  ** may have modified them). So not loading those that are not going to
+  ** be used eliminates some redundant opcodes.
+  */
+  newmask = sqlite3TriggerColmask(
+      pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError
+  );
   for(i=0; i<pTab->nCol; i++){
     if( i==pTab->iPKey ){
       sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
     }else{
       j = aXRef[i];
-      if( j<0 ){
+      if( j>=0 ){
+        sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
+      }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask&(1<<i)) ){
+        /* This branch loads the value of a column that will not be changed 
+        ** into a register. This is done if there are no BEFORE triggers, or
+        ** if there are one or more BEFORE triggers that use this value via
+        ** a new.* reference in a trigger program.
+        */
+        testcase( i==31 );
+        testcase( i==32 );
         sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew+i);
         sqlite3ColumnDefault(v, pTab, i, regNew+i);
-      }else{
-        sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
       }
     }
   }
 
   /* Fire any BEFORE UPDATE triggers. This happens before constraints are
-  ** verified. One could argue that this is wrong.  */
-  if( pTrigger ){
+  ** verified. One could argue that this is wrong.
+  */
+  if( tmask&TRIGGER_BEFORE ){
     sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab->nCol);
     sqlite3TableAffinityStr(v, pTab);
     sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, 
@@ -84492,11 +85022,25 @@ SQLITE_PRIVATE void sqlite3Update(
     ** case, jump to the next row. No updates or AFTER triggers are 
     ** required. This behaviour - what happens when the row being updated
     ** is deleted or renamed by a BEFORE trigger - is left undefined in the
-    ** documentation.  */
+    ** documentation.
+    */
     sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid);
+
+    /* If it did not delete it, the row-trigger may still have modified 
+    ** some of the columns of the row being updated. Load the values for 
+    ** all columns not modified by the update statement into their 
+    ** registers in case this has happened.
+    */
+    for(i=0; i<pTab->nCol; i++){
+      if( aXRef[i]<0 && i!=pTab->iPKey ){
+        sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew+i);
+        sqlite3ColumnDefault(v, pTab, i, regNew+i);
+      }
+    }
   }
 
   if( !isView ){
+    int j1;                       /* Address of jump instruction */
 
     /* Do constraint checks. */
     sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid,
@@ -84637,8 +85181,7 @@ static void updateVirtualTable(
   /* Construct the SELECT statement that will find the new values for
   ** all updated rows. 
   */
-  pEList = sqlite3ExprListAppend(pParse, 0, 
-                                 sqlite3CreateIdExpr(pParse, "_rowid_"));
+  pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, "_rowid_"));
   if( pRowid ){
     pEList = sqlite3ExprListAppend(pParse, pEList,
                                    sqlite3ExprDup(db, pRowid, 0));
@@ -84648,7 +85191,7 @@ static void updateVirtualTable(
     if( aXRef[i]>=0 ){
       pExpr = sqlite3ExprDup(db, pChanges->a[aXRef[i]].pExpr, 0);
     }else{
-      pExpr = sqlite3CreateIdExpr(pParse, pTab->aCol[i].zName);
+      pExpr = sqlite3Expr(db, TK_ID, pTab->aCol[i].zName);
     }
     pEList = sqlite3ExprListAppend(pParse, pEList, pExpr);
   }
@@ -84704,8 +85247,6 @@ static void updateVirtualTable(
 **
 ** Most of the code in this file may be omitted by defining the
 ** SQLITE_OMIT_VACUUM macro.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
@@ -84777,6 +85318,7 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   int saved_flags;        /* Saved value of the db->flags */
   int saved_nChange;      /* Saved value of db->nChange */
   int saved_nTotalChange; /* Saved value of db->nTotalChange */
+  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;
@@ -84792,8 +85334,10 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   saved_flags = db->flags;
   saved_nChange = db->nChange;
   saved_nTotalChange = db->nTotalChange;
+  saved_xTrace = db->xTrace;
   db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
   db->flags &= ~SQLITE_ForeignKeys;
+  db->xTrace = 0;
 
   pMain = db->aDb[0].pBt;
   isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
@@ -84819,6 +85363,12 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   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
+  ** locked (as there was more than one active statement when the transaction
+  ** to read the schema was concluded. Unlock it here so that this doesn't
+  ** cause problems for the call to BtreeSetPageSize() below.  */
+  sqlite3BtreeCommit(pTemp);
+
   nRes = sqlite3BtreeGetReserve(pMain);
 
   /* A VACUUM cannot change the pagesize of an encrypted database. */
@@ -84872,13 +85422,13 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   if( rc!=SQLITE_OK ) goto end_of_vacuum;
 
   /* Loop through the tables in the main database. For each, do
-  ** an "INSERT INTO vacuum_db.xxx SELECT * FROM xxx;" to copy
+  ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
   ** the contents to the temporary database.
   */
   rc = execExecSql(db, 
       "SELECT 'INSERT INTO vacuum_db.' || quote(name) "
-      "|| ' SELECT * FROM ' || quote(name) || ';'"
-      "FROM sqlite_master "
+      "|| ' SELECT * FROM main.' || quote(name) || ';'"
+      "FROM main.sqlite_master "
       "WHERE type = 'table' AND name!='sqlite_sequence' "
       "  AND rootpage>0"
 
@@ -84894,7 +85444,7 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   if( rc!=SQLITE_OK ) goto end_of_vacuum;
   rc = execExecSql(db, 
       "SELECT 'INSERT INTO vacuum_db.' || quote(name) "
-      "|| ' SELECT * FROM ' || quote(name) || ';' "
+      "|| ' SELECT * FROM main.' || quote(name) || ';' "
       "FROM vacuum_db.sqlite_master WHERE name=='sqlite_sequence';"
   );
   if( rc!=SQLITE_OK ) goto end_of_vacuum;
@@ -84908,7 +85458,7 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   rc = execSql(db,
       "INSERT INTO vacuum_db.sqlite_master "
       "  SELECT type, name, tbl_name, rootpage, sql"
-      "    FROM sqlite_master"
+      "    FROM main.sqlite_master"
       "   WHERE type='view' OR type='trigger'"
       "      OR (type='table' AND rootpage=0)"
   );
@@ -84968,6 +85518,7 @@ end_of_vacuum:
   db->flags = saved_flags;
   db->nChange = saved_nChange;
   db->nTotalChange = saved_nTotalChange;
+  db->xTrace = saved_xTrace;
 
   /* Currently there is an SQL level transaction open on the vacuum
   ** database. No locks are held on any other files (since the main file
@@ -85004,8 +85555,6 @@ end_of_vacuum:
 **
 *************************************************************************
 ** This file contains code used to help implement virtual tables.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef SQLITE_OMIT_VIRTUALTABLE
 
@@ -85664,11 +86213,11 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
     pParse->declareVtab = 1;
     pParse->db = db;
   
-    if( 
-        SQLITE_OK == sqlite3RunParser(pParse, zCreateTable, &zErr) && 
-        pParse->pNewTable && 
-        !pParse->pNewTable->pSelect && 
-        (pParse->pNewTable->tabFlags & TF_Virtual)==0
+    if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr) 
+     && pParse->pNewTable
+     && !db->mallocFailed
+     && !pParse->pNewTable->pSelect
+     && (pParse->pNewTable->tabFlags & TF_Virtual)==0
     ){
       if( !pTab->aCol ){
         pTab->aCol = pParse->pNewTable->aCol;
@@ -85677,7 +86226,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
         pParse->pNewTable->aCol = 0;
       }
       db->pVTab = 0;
-    } else {
+    }else{
       sqlite3Error(db, SQLITE_ERROR, zErr);
       sqlite3DbFree(db, zErr);
       rc = SQLITE_ERROR;
@@ -85973,8 +86522,6 @@ SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){
 ** rows.  Indices are selected and used to speed the search when doing
 ** so is applicable.  Because this module is responsible for selecting
 ** indices, you might also think of this module as the "query optimizer".
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -86582,11 +87129,11 @@ static void exprAnalyzeAll(
 static int isLikeOrGlob(
   Parse *pParse,    /* Parsing and code generating context */
   Expr *pExpr,      /* Test this expression */
-  int *pnPattern,   /* Number of non-wildcard prefix characters */
+  Expr **ppPrefix,  /* Pointer to TK_STRING expression with pattern prefix */
   int *pisComplete, /* True if the only wildcard is % in the last character */
   int *pnoCase      /* True if uppercase is equivalent to lowercase */
 ){
-  const char *z;             /* String on RHS of LIKE operator */
+  const char *z = 0;         /* String on RHS of LIKE operator */
   Expr *pRight, *pLeft;      /* Right and left size of LIKE operator */
   ExprList *pList;           /* List of operands to the LIKE operator */
   int c;                     /* One character in z[] */
@@ -86594,6 +87141,8 @@ static int isLikeOrGlob(
   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 */
 
   if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){
     return 0;
@@ -86602,35 +87151,77 @@ static int isLikeOrGlob(
   if( *pnoCase ) return 0;
 #endif
   pList = pExpr->x.pList;
-  pRight = pList->a[0].pExpr;
-  if( pRight->op!=TK_STRING ){
-    return 0;
-  }
   pLeft = pList->a[1].pExpr;
-  if( pLeft->op!=TK_COLUMN ){
+  if( pLeft->op!=TK_COLUMN || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT ){
+    /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
+    ** be the name of an indexed column with TEXT affinity. */
     return 0;
   }
+  assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
   pColl = sqlite3ExprCollSeq(pParse, pLeft);
-  assert( pColl!=0 || pLeft->iColumn==-1 );
-  if( pColl==0 ) return 0;
+  assert( pColl!=0 );  /* Every non-IPK column has a collating sequence */
   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;
   }
-  if( sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT ) return 0;
-  z = pRight->u.zToken;
-  if( ALWAYS(z) ){
+
+  pRight = pList->a[0].pExpr;
+  op = pRight->op;
+  if( op==TK_REGISTER ){
+    op = pRight->op2;
+  }
+  if( op==TK_VARIABLE ){
+    Vdbe *pReprepare = pParse->pReprepare;
+    pVal = sqlite3VdbeGetValue(pReprepare, pRight->iColumn, SQLITE_AFF_NONE);
+    if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
+      z = (char *)sqlite3_value_text(pVal);
+    }
+    sqlite3VdbeSetVarmask(pParse->pVdbe, pRight->iColumn);
+    assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
+  }else if( op==TK_STRING ){
+    z = pRight->u.zToken;
+  }
+  if( z ){
     cnt = 0;
     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] ){
+      Expr *pPrefix;
       *pisComplete = z[cnt]==wc[0] && z[cnt+1]==0;
-      *pnPattern = cnt;
-      return 1;
+      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);
+        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
+          ** function, then no OP_Variable will be added to the program.
+          ** This causes problems for the sqlite3_bind_parameter_name()
+          ** API. To workaround them, add a dummy OP_Variable here.
+          */ 
+          int r1 = sqlite3GetTempReg(pParse);
+          sqlite3ExprCodeTarget(pParse, pRight, r1);
+          sqlite3VdbeChangeP3(v, sqlite3VdbeCurrentAddr(v)-1, 0);
+          sqlite3ReleaseTempReg(pParse, r1);
+        }
+      }
+    }else{
+      z = 0;
     }
   }
-  return 0;
+
+  sqlite3ValueFree(pVal);
+  return (z!=0);
 }
 #endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */
 
@@ -87011,10 +87602,10 @@ static void exprAnalyze(
   Expr *pExpr;                     /* The expression to be analyzed */
   Bitmask prereqLeft;              /* Prerequesites of the pExpr->pLeft */
   Bitmask prereqAll;               /* Prerequesites of pExpr */
-  Bitmask extraRight = 0;
-  int nPattern;
-  int isComplete;
-  int noCase;
+  Bitmask extraRight = 0;          /* */
+  Expr *pStr1 = 0;                 /* RHS of LIKE/GLOB operator */
+  int isComplete = 0;              /* RHS of LIKE/GLOB ends with wildcard */
+  int noCase = 0;                  /* LIKE/GLOB distinguishes case */
   int op;                          /* Top-level operator.  pExpr->op */
   Parse *pParse = pWC->pParse;     /* Parsing context */
   sqlite3 *db = pParse->db;        /* Database connection */
@@ -87149,21 +87740,21 @@ static void exprAnalyze(
   ** The last character of the prefix "abc" is incremented to form the
   ** termination condition "abd".
   */
-  if( isLikeOrGlob(pParse, pExpr, &nPattern, &isComplete, &noCase)
-         && pWC->op==TK_AND ){
-    Expr *pLeft, *pRight;
-    Expr *pStr1, *pStr2;
-    Expr *pNewExpr1, *pNewExpr2;
-    int idxNew1, idxNew2;
+  if( pWC->op==TK_AND 
+   && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
+  ){
+    Expr *pLeft;       /* LHS of LIKE/GLOB operator */
+    Expr *pStr2;       /* Copy of pStr1 - RHS of LIKE/GLOB operator */
+    Expr *pNewExpr1;
+    Expr *pNewExpr2;
+    int idxNew1;
+    int idxNew2;
 
     pLeft = pExpr->x.pList->a[1].pExpr;
-    pRight = pExpr->x.pList->a[0].pExpr;
-    pStr1 = sqlite3Expr(db, TK_STRING, pRight->u.zToken);
-    if( pStr1 ) pStr1->u.zToken[nPattern] = 0;
     pStr2 = sqlite3ExprDup(db, pStr1, 0);
     if( !db->mallocFailed ){
       u8 c, *pC;       /* Last character before the first wildcard */
-      pC = (u8*)&pStr2->u.zToken[nPattern-1];
+      pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];
       c = *pC;
       if( noCase ){
         /* The point is to increment the last character before the first
@@ -87942,6 +88533,42 @@ static int whereRangeRegion(
 #endif   /* #ifdef SQLITE_ENABLE_STAT2 */
 
 /*
+** If expression pExpr represents a literal value, set *pp to point to
+** an sqlite3_value structure containing the same value, with affinity
+** aff applied to it, before returning. It is the responsibility of the 
+** caller to eventually release this structure by passing it to 
+** sqlite3ValueFree().
+**
+** If the current parse is a recompile (sqlite3Reprepare()) and pExpr
+** is an SQL variable that currently has a non-NULL value bound to it,
+** create an sqlite3_value structure containing this value, again with
+** affinity aff applied to it, instead.
+**
+** If neither of the above apply, set *pp to NULL.
+**
+** If an error occurs, return an error code. Otherwise, SQLITE_OK.
+*/
+#ifdef SQLITE_ENABLE_STAT2
+static int valueFromExpr(
+  Parse *pParse, 
+  Expr *pExpr, 
+  u8 aff, 
+  sqlite3_value **pp
+){
+  /* The evalConstExpr() function will have already converted any TK_VARIABLE
+  ** expression involved in an comparison into a TK_REGISTER. */
+  assert( pExpr->op!=TK_VARIABLE );
+  if( pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE ){
+    int iVar = pExpr->iColumn;
+    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
+    *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
+    return SQLITE_OK;
+  }
+  return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
+}
+#endif
+
+/*
 ** This function is used to estimate the number of rows that will be visited
 ** by scanning an index for a range of values. The range may have an upper
 ** bound, a lower bound, or both. The WHERE clause terms that set the upper
@@ -87993,23 +88620,22 @@ static int whereRangeScanEst(
   int rc = SQLITE_OK;
 
 #ifdef SQLITE_ENABLE_STAT2
-  sqlite3 *db = pParse->db;
-  sqlite3_value *pLowerVal = 0;
-  sqlite3_value *pUpperVal = 0;
 
   if( nEq==0 && p->aSample ){
+    sqlite3_value *pLowerVal = 0;
+    sqlite3_value *pUpperVal = 0;
     int iEst;
     int iLower = 0;
     int iUpper = SQLITE_INDEX_SAMPLES;
-    u8 aff = p->pTable->aCol[0].affinity;
+    u8 aff = p->pTable->aCol[p->aiColumn[0]].affinity;
 
     if( pLower ){
       Expr *pExpr = pLower->pExpr->pRight;
-      rc = sqlite3ValueFromExpr(db, pExpr, SQLITE_UTF8, aff, &pLowerVal);
+      rc = valueFromExpr(pParse, pExpr, aff, &pLowerVal);
     }
     if( rc==SQLITE_OK && pUpper ){
       Expr *pExpr = pUpper->pExpr->pRight;
-      rc = sqlite3ValueFromExpr(db, pExpr, SQLITE_UTF8, aff, &pUpperVal);
+      rc = valueFromExpr(pParse, pExpr, aff, &pUpperVal);
     }
 
     if( rc!=SQLITE_OK || (pLowerVal==0 && pUpperVal==0) ){
@@ -88474,16 +89100,39 @@ static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){
 ** Code an OP_Affinity opcode to apply the column affinity string zAff
 ** to the n registers starting at base. 
 **
-** Buffer zAff was allocated using sqlite3DbMalloc(). It is the 
-** responsibility of this function to arrange for it to be eventually
-** freed using sqlite3DbFree().
+** As an optimization, SQLITE_AFF_NONE entries (which are no-ops) at the
+** beginning and end of zAff are ignored.  If all entries in zAff are
+** SQLITE_AFF_NONE, then no code gets generated.
+**
+** This routine makes its own copy of zAff so that the caller is free
+** to modify zAff after this routine returns.
 */
 static void codeApplyAffinity(Parse *pParse, int base, int n, char *zAff){
   Vdbe *v = pParse->pVdbe;
+  if( zAff==0 ){
+    assert( pParse->db->mallocFailed );
+    return;
+  }
   assert( v!=0 );
-  sqlite3VdbeAddOp2(v, OP_Affinity, base, n);
-  sqlite3VdbeChangeP4(v, -1, zAff, P4_DYNAMIC);
-  sqlite3ExprCacheAffinityChange(pParse, base, n);
+
+  /* Adjust base and n to skip over SQLITE_AFF_NONE entries at the beginning
+  ** and end of the affinity string.
+  */
+  while( n>0 && zAff[0]==SQLITE_AFF_NONE ){
+    n--;
+    base++;
+    zAff++;
+  }
+  while( n>1 && zAff[n-1]==SQLITE_AFF_NONE ){
+    n--;
+  }
+
+  /* Code the OP_Affinity opcode if there is anything left to do. */
+  if( n>0 ){
+    sqlite3VdbeAddOp2(v, OP_Affinity, base, n);
+    sqlite3VdbeChangeP4(v, -1, zAff, n);
+    sqlite3ExprCacheAffinityChange(pParse, base, n);
+  }
 }
 
 
@@ -88554,7 +89203,7 @@ static int codeEqualityTerm(
 
 /*
 ** Generate code that will evaluate all == and IN constraints for an
-** index.  The values for all constraints are left on the stack.
+** index.
 **
 ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).
 ** Suppose the WHERE clause is this:  a==5 AND b IN (1,2,3) AND c>5 AND c<10
@@ -88566,7 +89215,8 @@ static int codeEqualityTerm(
 **
 ** In the example above nEq==2.  But this subroutine works for any value
 ** of nEq including 0.  If nEq==0, this routine is nearly a no-op.
-** The only thing it does is allocate the pLevel->iMem memory cell.
+** The only thing it does is allocate the pLevel->iMem memory cell and
+** compute the affinity string.
 **
 ** This routine always allocates at least one memory cell and returns
 ** the index of that memory cell. The code that
@@ -88644,11 +89294,15 @@ static int codeAllEqualityTerms(
     testcase( pTerm->eOperator & WO_ISNULL );
     testcase( pTerm->eOperator & WO_IN );
     if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){
-      sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
-      if( zAff 
-       && sqlite3CompareAffinity(pTerm->pExpr->pRight, zAff[j])==SQLITE_AFF_NONE
-      ){
-        zAff[j] = SQLITE_AFF_NONE;
+      Expr *pRight = pTerm->pExpr->pRight;
+      sqlite3ExprCodeIsNullJump(v, pRight, regBase+j, pLevel->addrBrk);
+      if( zAff ){
+        if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_NONE ){
+          zAff[j] = SQLITE_AFF_NONE;
+        }
+        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
+          zAff[j] = SQLITE_AFF_NONE;
+        }
       }
     }
   }
@@ -88728,6 +89382,7 @@ static Bitmask codeOneLoopStart(
     const struct sqlite3_index_constraint *aConstraint =
                                                 pVtabIdx->aConstraint;
 
+    sqlite3ExprCachePush(pParse);
     iReg = sqlite3GetTempRange(pParse, nConstraint+2);
     for(j=1; j<=nConstraint; j++){
       for(k=0; k<nConstraint; k++){
@@ -88754,6 +89409,7 @@ static Bitmask codeOneLoopStart(
     pLevel->p1 = iCur;
     pLevel->p2 = sqlite3VdbeCurrentAddr(v);
     sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2);
+    sqlite3ExprCachePop(pParse, 1);
   }else
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
 
@@ -88974,15 +89630,18 @@ static Bitmask codeOneLoopStart(
     if( pRangeStart ){
       Expr *pRight = pRangeStart->pExpr->pRight;
       sqlite3ExprCode(pParse, pRight, regBase+nEq);
-      sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
-      if( zAff 
-       && sqlite3CompareAffinity(pRight, zAff[nConstraint])==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;
-      }
+      sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);
+      if( zAff ){
+        if( sqlite3CompareAffinity(pRight, zAff[nConstraint])==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;
+        }
+        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[nConstraint]) ){
+          zAff[nConstraint] = SQLITE_AFF_NONE;
+        }
+      }  
       nConstraint++;
     }else if( isMinQuery ){
       sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
@@ -88999,8 +89658,7 @@ static Bitmask codeOneLoopStart(
     testcase( op==OP_SeekGe );
     testcase( op==OP_SeekLe );
     testcase( op==OP_SeekLt );
-    sqlite3VdbeAddOp4(v, op, iIdxCur, addrNxt, regBase, 
-                      SQLITE_INT_TO_PTR(nConstraint), P4_INT32);
+    sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
 
     /* Load the value for the inequality constraint at the end of the
     ** range (if any).
@@ -89008,21 +89666,24 @@ static Bitmask codeOneLoopStart(
     nConstraint = nEq;
     if( pRangeEnd ){
       Expr *pRight = pRangeEnd->pExpr->pRight;
-      sqlite3ExprCacheRemove(pParse, regBase+nEq);
+      sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
       sqlite3ExprCode(pParse, pRight, regBase+nEq);
-      sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
-      zAff = sqlite3DbStrDup(pParse->db, zAff);
-      if( zAff 
-       && sqlite3CompareAffinity(pRight, zAff[nConstraint])==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;
-      }
+      sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);
+      if( zAff ){
+        if( sqlite3CompareAffinity(pRight, zAff[nConstraint])==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;
+        }
+        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[nConstraint]) ){
+          zAff[nConstraint] = SQLITE_AFF_NONE;
+        }
+      }  
       codeApplyAffinity(pParse, regBase, nEq+1, zAff);
       nConstraint++;
     }
+    sqlite3DbFree(pParse->db, zAff);
 
     /* Top of the loop body */
     pLevel->p2 = sqlite3VdbeCurrentAddr(v);
@@ -89033,8 +89694,7 @@ static Bitmask codeOneLoopStart(
     testcase( op==OP_IdxGE );
     testcase( op==OP_IdxLT );
     if( op!=OP_Noop ){
-      sqlite3VdbeAddOp4(v, op, iIdxCur, addrNxt, regBase,
-                        SQLITE_INT_TO_PTR(nConstraint), P4_INT32);
+      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
       sqlite3VdbeChangeP5(v, endEq!=bRev ?1:0);
     }
 
@@ -89111,13 +89771,14 @@ static Bitmask codeOneLoopStart(
     */
     WhereClause *pOrWc;    /* The OR-clause broken out into subterms */
     WhereTerm *pFinal;     /* Final subterm within the OR-clause. */
-    SrcList oneTab;        /* Shortened table list */
+    SrcList *pOrTab;       /* Shortened table list or OR-clause generation */
 
     int regReturn = ++pParse->nMem;           /* Register used with OP_Gosub */
     int regRowset = 0;                        /* Register for RowSet object */
     int regRowid = 0;                         /* Register holding rowid */
     int iLoopBody = sqlite3VdbeMakeLabel(v);  /* Start of loop body */
     int iRetInit;                             /* Address of regReturn init */
+    int untestedTerms = 0;             /* Some terms not completely tested */
     int ii;
    
     pTerm = pLevel->plan.u.pTerm;
@@ -89126,11 +89787,30 @@ static Bitmask codeOneLoopStart(
     assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );
     pOrWc = &pTerm->u.pOrInfo->wc;
     pFinal = &pOrWc->a[pOrWc->nTerm-1];
+    pLevel->op = OP_Return;
+    pLevel->p1 = regReturn;
 
-    /* Set up a SrcList containing just the table being scanned by this loop. */
-    oneTab.nSrc = 1;
-    oneTab.nAlloc = 1;
-    oneTab.a[0] = *pTabItem;
+    /* Set up a new SrcList ni pOrTab containing the table being scanned
+    ** by this loop in the a[0] slot and all notReady tables in a[1..] slots.
+    ** This becomes the SrcList in the recursive call to sqlite3WhereBegin().
+    */
+    if( pWInfo->nLevel>1 ){
+      int nNotReady;                 /* The number of notReady tables */
+      struct SrcList_item *origSrc;     /* Original list of tables */
+      nNotReady = pWInfo->nLevel - iLevel - 1;
+      pOrTab = sqlite3StackAllocRaw(pParse->db,
+                            sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
+      if( pOrTab==0 ) return notReady;
+      pOrTab->nAlloc = (i16)(nNotReady + 1);
+      pOrTab->nSrc = pOrTab->nAlloc;
+      memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
+      origSrc = pWInfo->pTabList->a;
+      for(k=1; k<=nNotReady; k++){
+        memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));
+      }
+    }else{
+      pOrTab = pWInfo->pTabList;
+    }
 
     /* Initialize the rowset register to contain NULL. An SQL NULL is 
     ** equivalent to an empty rowset.
@@ -89155,33 +89835,38 @@ static Bitmask codeOneLoopStart(
       if( pOrTerm->leftCursor==iCur || pOrTerm->eOperator==WO_AND ){
         WhereInfo *pSubWInfo;          /* Info for single OR-term scan */
         /* Loop through table entries that match term pOrTerm. */
-        pSubWInfo = sqlite3WhereBegin(pParse, &oneTab, pOrTerm->pExpr, 0,
-                        WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE | WHERE_FORCE_TABLE);
+        pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrTerm->pExpr, 0,
+                        WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE |
+                        WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY);
         if( pSubWInfo ){
           if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
             int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
             int r;
             r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur, 
-                                         regRowid, 0);
-            sqlite3VdbeAddOp4(v, OP_RowSetTest, regRowset,
-                              sqlite3VdbeCurrentAddr(v)+2,
-                              r, SQLITE_INT_TO_PTR(iSet), P4_INT32);
+                                         regRowid);
+            sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,
+                                 sqlite3VdbeCurrentAddr(v)+2, r, iSet);
           }
           sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
 
+          /* The pSubWInfo->untestedTerms flag means that this OR term
+          ** contained one or more AND term from a notReady table.  The
+          ** terms from the notReady table could not be tested and will
+          ** need to be tested later.
+          */
+          if( pSubWInfo->untestedTerms ) untestedTerms = 1;
+
           /* Finish the loop through table entries that match term pOrTerm. */
           sqlite3WhereEnd(pSubWInfo);
         }
       }
     }
     sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
-    /* sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset); */
     sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
     sqlite3VdbeResolveLabel(v, iLoopBody);
 
-    pLevel->op = OP_Return;
-    pLevel->p1 = regReturn;
-    disableTerm(pLevel, pTerm);
+    if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
+    if( !untestedTerms ) disableTerm(pLevel, pTerm);
   }else
 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
 
@@ -89209,7 +89894,12 @@ static Bitmask codeOneLoopStart(
     testcase( pTerm->wtFlags & TERM_VIRTUAL );
     testcase( pTerm->wtFlags & TERM_CODED );
     if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
-    if( (pTerm->prereqAll & notReady)!=0 ) continue;
+    if( (pTerm->prereqAll & notReady)!=0 ){
+      testcase( pWInfo->untestedTerms==0
+               && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
+      pWInfo->untestedTerms = 1;
+      continue;
+    }
     pE = pTerm->pExpr;
     assert( pE!=0 );
     if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
@@ -89232,7 +89922,10 @@ static Bitmask codeOneLoopStart(
       testcase( pTerm->wtFlags & TERM_VIRTUAL );
       testcase( pTerm->wtFlags & TERM_CODED );
       if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
-      if( (pTerm->prereqAll & notReady)!=0 ) continue;
+      if( (pTerm->prereqAll & notReady)!=0 ){
+        assert( pWInfo->untestedTerms );
+        continue;
+      }
       assert( pTerm->pExpr );
       sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
       pTerm->wtFlags |= TERM_CODED;
@@ -89375,6 +90068,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
 ){
   int i;                     /* Loop counter */
   int nByteWInfo;            /* Num. bytes allocated for WhereInfo struct */
+  int nTabList;              /* Number of elements in pTabList */
   WhereInfo *pWInfo;         /* Will become the return value of this function */
   Vdbe *v = pParse->pVdbe;   /* The virtual database engine */
   Bitmask notReady;          /* Cursors that are not yet positioned */
@@ -89394,6 +90088,13 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
     return 0;
   }
 
+  /* This function normally generates a nested loop for all tables in 
+  ** pTabList.  But if the WHERE_ONETABLE_ONLY flag is set, then we should
+  ** only generate code for the first table in pTabList and assume that
+  ** any cursors associated with subsequent tables are uninitialized.
+  */
+  nTabList = (wctrlFlags & WHERE_ONETABLE_ONLY) ? 1 : pTabList->nSrc;
+
   /* Allocate and initialize the WhereInfo structure that will become the
   ** return value. A single allocation is used to store the WhereInfo
   ** struct, the contents of WhereInfo.a[], the WhereClause structure
@@ -89402,7 +90103,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   ** some architectures. Hence the ROUND8() below.
   */
   db = pParse->db;
-  nByteWInfo = ROUND8(sizeof(WhereInfo)+(pTabList->nSrc-1)*sizeof(WhereLevel));
+  nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel));
   pWInfo = sqlite3DbMallocZero(db, 
       nByteWInfo + 
       sizeof(WhereClause) +
@@ -89411,7 +90112,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   if( db->mallocFailed ){
     goto whereBeginError;
   }
-  pWInfo->nLevel = pTabList->nSrc;
+  pWInfo->nLevel = nTabList;
   pWInfo->pParse = pParse;
   pWInfo->pTabList = pTabList;
   pWInfo->iBreak = sqlite3VdbeMakeLabel(v);
@@ -89430,7 +90131,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   /* Special case: a WHERE clause that is constant.  Evaluate the
   ** expression and either jump over all of the code or fall thru.
   */
-  if( pWhere && (pTabList->nSrc==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){
+  if( pWhere && (nTabList==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){
     sqlite3ExprIfFalse(pParse, pWhere, pWInfo->iBreak, SQLITE_JUMPIFNULL);
     pWhere = 0;
   }
@@ -89450,6 +90151,11 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   ** to virtual table cursors are set. This is used to selectively disable 
   ** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful 
   ** with virtual tables.
+  **
+  ** Note that bitmasks are created for all pTabList->nSrc tables in
+  ** pTabList, not just the first nTabList tables.  nTabList is normally
+  ** equal to pTabList->nSrc but might be shortened to 1 if the
+  ** WHERE_ONETABLE_ONLY flag is set.
   */
   assert( pWC->vmask==0 && pMaskSet->n==0 );
   for(i=0; i<pTabList->nSrc; i++){
@@ -89501,7 +90207,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   pLevel = pWInfo->a;
   andFlags = ~0;
   WHERETRACE(("*** Optimizer Start ***\n"));
-  for(i=iFrom=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
+  for(i=iFrom=0, pLevel=pWInfo->a; i<nTabList; i++, pLevel++){
     WhereCost bestPlan;         /* Most efficient plan seen so far */
     Index *pIdx;                /* Index for FROM table at pTabItem */
     int j;                      /* For looping over FROM tables */
@@ -89546,8 +90252,8 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
     */
     for(isOptimal=1; isOptimal>=0 && bestJ<0; isOptimal--){
       Bitmask mask = (isOptimal ? 0 : notReady);
-      assert( (pTabList->nSrc-iFrom)>1 || isOptimal );
-      for(j=iFrom, pTabItem=&pTabList->a[j]; j<pTabList->nSrc; j++, pTabItem++){
+      assert( (nTabList-iFrom)>1 || isOptimal );
+      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() */
         ExprList *pOrderBy;  /* ORDER BY clause for index to optimize */
@@ -89644,7 +90350,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   ** searching those tables.
   */
   sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
-  for(i=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
+  for(i=0, pLevel=pWInfo->a; i<nTabList; i++, pLevel++){
     Table *pTab;     /* Table to open */
     int iDb;         /* Index of database containing table/index */
 
@@ -89696,7 +90402,8 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
         Bitmask b = pTabItem->colUsed;
         int n = 0;
         for(; b; b=b>>1, n++){}
-        sqlite3VdbeChangeP4(v, sqlite3VdbeCurrentAddr(v)-1, SQLITE_INT_TO_PTR(n), P4_INT32);
+        sqlite3VdbeChangeP4(v, sqlite3VdbeCurrentAddr(v)-1, 
+                            SQLITE_INT_TO_PTR(n), P4_INT32);
         assert( n<=pTab->nCol );
       }
     }else{
@@ -89722,7 +90429,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   ** program.
   */
   notReady = ~(Bitmask)0;
-  for(i=0; i<pTabList->nSrc; i++){
+  for(i=0; i<nTabList; i++){
     notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady);
     pWInfo->iContinue = pWInfo->a[i].addrCont;
   }
@@ -89734,7 +90441,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   ** the index is listed as "{}".  If the primary key is used the
   ** index name is '*'.
   */
-  for(i=0; i<pTabList->nSrc; i++){
+  for(i=0; i<nTabList; i++){
     char *z;
     int n;
     pLevel = &pWInfo->a[i];
@@ -89802,7 +90509,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
   /* Generate loop termination code.
   */
   sqlite3ExprCacheClear(pParse);
-  for(i=pTabList->nSrc-1; i>=0; i--){
+  for(i=pWInfo->nLevel-1; i>=0; i--){
     pLevel = &pWInfo->a[i];
     sqlite3VdbeResolveLabel(v, pLevel->addrCont);
     if( pLevel->op!=OP_Noop ){
@@ -89824,7 +90531,11 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
     if( pLevel->iLeftJoin ){
       int addr;
       addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin);
-      sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
+      assert( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0
+           || (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 );
+      if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0 ){
+        sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
+      }
       if( pLevel->iIdxCur>=0 ){
         sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
       }
@@ -89844,7 +90555,8 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
 
   /* Close all of the cursors that were opened by sqlite3WhereBegin.
   */
-  for(i=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
+  assert( pWInfo->nLevel==1 || pWInfo->nLevel==pTabList->nSrc );
+  for(i=0, pLevel=pWInfo->a; i<pWInfo->nLevel; i++, pLevel++){
     struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];
     Table *pTab = pTabItem->pTab;
     assert( pTab!=0 );
@@ -89875,7 +90587,6 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
       int k, j, last;
       VdbeOp *pOp;
       Index *pIdx = pLevel->plan.u.pIdx;
-      int useIndexOnly = pLevel->plan.wsFlags & WHERE_IDX_ONLY;
 
       assert( pIdx!=0 );
       pOp = sqlite3VdbeGetOp(v, pWInfo->iTop);
@@ -89890,12 +90601,11 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
               break;
             }
           }
-          assert(!useIndexOnly || j<pIdx->nColumn);
+          assert( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0
+               || j<pIdx->nColumn );
         }else if( pOp->opcode==OP_Rowid ){
           pOp->p1 = pLevel->iIdxCur;
           pOp->opcode = OP_IdxRowid;
-        }else if( pOp->opcode==OP_NullRow && useIndexOnly ){
-          pOp->opcode = OP_Noop;
         }
       }
     }
@@ -90016,6 +90726,17 @@ struct AttachKey { int type;  Token key; };
     pOut->zEnd = &pPostOp->z[pPostOp->n];
   }                           
 
+  /* A routine to convert a binary TK_IS or TK_ISNOT expression into a
+  ** unary TK_ISNULL or TK_NOTNULL expression. */
+  static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){
+    sqlite3 *db = pParse->db;
+    if( db->mallocFailed==0 && pY->op==TK_NULL ){
+      pA->op = (u8)op;
+      sqlite3ExprDelete(db, pA->pRight);
+      pA->pRight = 0;
+    }
+  }
+
   /* Construct an expression node for a unary prefix operator
   */
   static void spanUnaryPrefix(
@@ -90107,8 +90828,8 @@ typedef union {
 #define sqlite3ParserARG_PDECL ,Parse *pParse
 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
-#define YYNSTATE 629
-#define YYNRULE 329
+#define YYNSTATE 631
+#define YYNRULE 330
 #define YYFALLBACK 1
 #define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)
 #define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1)
@@ -90178,468 +90899,473 @@ static const YYMINORTYPE yyzerominor = { 0 };
 **                     shifting non-terminals after a reduce.
 **  yy_default[]       Default action for each state.
 */
+#define YY_ACTTAB_COUNT (1543)
 static const YYACTIONTYPE yy_action[] = {
- /*     0 */   312,  959,  182,  628,    2,  157,  219,  450,   24,   24,
- /*    10 */    24,   24,  221,   26,   26,   26,   26,   27,   27,   28,
- /*    20 */    28,   28,   29,  221,  424,  425,   30,  492,   33,  141,
- /*    30 */   457,  463,   31,   26,   26,   26,   26,   27,   27,   28,
- /*    40 */    28,   28,   29,  221,   28,   28,   28,   29,  221,   23,
- /*    50 */    22,   32,  465,  466,  464,  464,   25,   25,   24,   24,
- /*    60 */    24,   24,  293,   26,   26,   26,   26,   27,   27,   28,
- /*    70 */    28,   28,   29,  221,  312,  450,  319,  479,  344,  208,
- /*    80 */    47,   26,   26,   26,   26,   27,   27,   28,   28,   28,
- /*    90 */    29,  221,  427,  428,  163,  339,  543,  368,  371,  372,
- /*   100 */   521,  317,  472,  473,  457,  463,  296,  373,  294,   21,
- /*   110 */   336,  367,  419,  416,  424,  425,  523,    1,  544,  446,
- /*   120 */    80,  424,  425,   23,   22,   32,  465,  466,  464,  464,
- /*   130 */    25,   25,   24,   24,   24,   24,  564,   26,   26,   26,
- /*   140 */    26,   27,   27,   28,   28,   28,   29,  221,  312,  233,
- /*   150 */   319,  441,  554,  152,  139,  263,  365,  268,  366,  160,
- /*   160 */   551,  352,  332,  421,  222,  272,  362,  322,  218,  557,
- /*   170 */   116,  339,  248,  574,  477,  223,  216,  573,  457,  463,
- /*   180 */   450,   59,  427,  428,  295,  610,  336,  563,  538,  427,
- /*   190 */   428,  385,  608,  609,  562,  446,   87,   23,   22,   32,
- /*   200 */   465,  466,  464,  464,   25,   25,   24,   24,   24,   24,
- /*   210 */   447,   26,   26,   26,   26,   27,   27,   28,   28,   28,
- /*   220 */    29,  221,  312,  233,  477,  223,  576,  134,  139,  263,
- /*   230 */   365,  268,  366,  160,  406,  354,  226,  498,  481,  272,
- /*   240 */   339,   27,   27,   28,   28,   28,   29,  221,  450,  442,
- /*   250 */   199,  540,  457,  463,  349,  336,  163,  551,   66,  368,
- /*   260 */   371,  372,  450,  415,  446,   80,  522,  581,  401,  373,
- /*   270 */   452,   23,   22,   32,  465,  466,  464,  464,   25,   25,
- /*   280 */    24,   24,   24,   24,  447,   26,   26,   26,   26,   27,
- /*   290 */    27,   28,   28,   28,   29,  221,  312,  339,  556,  607,
- /*   300 */   197,  454,  454,  454,  546,  578,  352,  198,  607,  440,
- /*   310 */    65,  351,  336,  426,  426,  399,  289,  424,  425,  606,
- /*   320 */   605,  446,   73,  426,  214,  219,  457,  463,  606,  410,
- /*   330 */   450,  241,  306,  196,  565,  479,  555,  208,  288,   29,
- /*   340 */   221,  447,    4,  874,  504,   23,   22,   32,  465,  466,
- /*   350 */   464,  464,   25,   25,   24,   24,   24,   24,  447,   26,
- /*   360 */    26,   26,   26,   27,   27,   28,   28,   28,   29,  221,
- /*   370 */   312,  163,  582,  339,  368,  371,  372,  314,  424,  425,
- /*   380 */   604,  222,  397,  227,  373,  427,  428,  339,  336,  409,
- /*   390 */   222,  478,  339,   30,  396,   33,  141,  446,   81,   62,
- /*   400 */   457,  463,  336,  157,  400,  450,  504,  336,  438,  426,
- /*   410 */   500,  446,   87,   41,  380,  613,  446,   80,  581,   23,
- /*   420 */    22,   32,  465,  466,  464,  464,   25,   25,   24,   24,
- /*   430 */    24,   24,  213,   26,   26,   26,   26,   27,   27,   28,
- /*   440 */    28,   28,   29,  221,  312,  513,  427,  428,  517,  254,
- /*   450 */   524,  386,  225,  339,  486,  363,  389,  339,  356,  443,
- /*   460 */   494,  236,   30,  497,   33,  141,  399,  289,  336,  495,
- /*   470 */   487,  501,  336,  450,  457,  463,  219,  446,   95,  445,
- /*   480 */    68,  446,   95,  444,  424,  425,  488,   44,  348,  288,
- /*   490 */   504,  424,  425,   23,   22,   32,  465,  466,  464,  464,
- /*   500 */    25,   25,   24,   24,   24,   24,  391,   26,   26,   26,
- /*   510 */    26,   27,   27,   28,   28,   28,   29,  221,  312,  361,
- /*   520 */   556,  426,  520,  328,  191,  271,  339,  329,  247,  259,
- /*   530 */   339,  566,   65,  249,  336,  426,  424,  425,  445,  516,
- /*   540 */   426,  336,  444,  446,    9,  336,  556,  451,  457,  463,
- /*   550 */   446,   74,  427,  428,  446,   69,  192,  618,   65,  427,
- /*   560 */   428,  426,  323,  277,   16,  202,  189,   23,   22,   32,
- /*   570 */   465,  466,  464,  464,   25,   25,   24,   24,   24,   24,
- /*   580 */   255,   26,   26,   26,   26,   27,   27,   28,   28,   28,
- /*   590 */    29,  221,  312,  339,  486,  426,  537,  235,  515,  447,
- /*   600 */   339,  629,  419,  416,  427,  428,  217,  281,  336,  279,
- /*   610 */   487,  203,  144,  526,  527,  336,  391,  446,   78,  429,
- /*   620 */   430,  431,  457,  463,  446,   99,  488,  341,  528,  468,
- /*   630 */   468,  426,  343,  472,  473,  626,  949,  474,  949,  529,
- /*   640 */   447,   23,   22,   32,  465,  466,  464,  464,   25,   25,
- /*   650 */    24,   24,   24,   24,  339,   26,   26,   26,   26,   27,
- /*   660 */    27,   28,   28,   28,   29,  221,  312,  339,  162,  336,
- /*   670 */   275,  283,  476,  376,  339,  579,  527,  346,  446,   98,
- /*   680 */   622,   30,  336,   33,  141,  339,  426,  339,  508,  336,
- /*   690 */   469,  446,  105,  418,    2,  222,  457,  463,  446,  101,
- /*   700 */   336,  219,  336,  426,  161,  626,  948,  290,  948,  446,
- /*   710 */   108,  446,  109,  398,  284,   23,   22,   32,  465,  466,
- /*   720 */   464,  464,   25,   25,   24,   24,   24,   24,  339,   26,
- /*   730 */    26,   26,   26,   27,   27,   28,   28,   28,   29,  221,
- /*   740 */   312,  339,  271,  336,  339,   58,  535,  482,  143,  339,
- /*   750 */   622,  318,  446,  133,  408,  257,  336,  426,  321,  336,
- /*   760 */   357,  339,  272,  426,  336,  446,  135,  184,  446,   61,
- /*   770 */   457,  463,  219,  446,  106,  426,  336,  493,  341,  234,
- /*   780 */   468,  468,  621,  310,  407,  446,  102,  209,  144,   23,
- /*   790 */    22,   32,  465,  466,  464,  464,   25,   25,   24,   24,
- /*   800 */    24,   24,  339,   26,   26,   26,   26,   27,   27,   28,
- /*   810 */    28,   28,   29,  221,  312,  339,  271,  336,  339,  341,
- /*   820 */   538,  468,  468,  572,  383,  496,  446,   79,  499,  549,
- /*   830 */   336,  426,  508,  336,  508,  341,  339,  468,  468,  446,
- /*   840 */   103,  391,  446,   70,  457,  463,  572,  426,   40,  426,
- /*   850 */    42,  336,  220,  324,  504,  341,  426,  468,  468,   18,
- /*   860 */   446,  100,  266,   23,   22,   32,  465,  466,  464,  464,
- /*   870 */    25,   25,   24,   24,   24,   24,  339,   26,   26,   26,
- /*   880 */    26,   27,   27,   28,   28,   28,   29,  221,  312,  339,
- /*   890 */   283,  336,  339,  261,  548,  384,  339,  327,  142,  550,
- /*   900 */   446,  136,  475,  475,  336,  426,  185,  336,  499,  396,
- /*   910 */   339,  336,  370,  446,  137,  256,  446,  138,  457,  463,
- /*   920 */   446,   71,  499,  360,  426,  336,  161,  311,  623,  215,
- /*   930 */   426,  359,  237,  412,  446,   82,  200,   23,   34,   32,
- /*   940 */   465,  466,  464,  464,   25,   25,   24,   24,   24,   24,
- /*   950 */   339,   26,   26,   26,   26,   27,   27,   28,   28,   28,
- /*   960 */    29,  221,  312,  447,  271,  336,  339,  271,  340,  210,
- /*   970 */   447,  172,  625,  211,  446,   83,  240,  552,  142,  426,
- /*   980 */   321,  336,  426,  426,  339,  414,  331,  181,  458,  459,
- /*   990 */   446,   72,  457,  463,  470,  506,   67,  158,  394,  336,
- /*  1000 */   587,  325,  499,  447,  326,  311,  624,  447,  446,   84,
- /*  1010 */   461,  462,   22,   32,  465,  466,  464,  464,   25,   25,
- /*  1020 */    24,   24,   24,   24,  339,   26,   26,   26,   26,   27,
- /*  1030 */    27,   28,   28,   28,   29,  221,  312,  460,  339,  336,
- /*  1040 */   339,  283,  423,  393,  532,  533,  204,  205,  446,   85,
- /*  1050 */   625,  392,  547,  336,  162,  336,  426,  426,  339,  435,
- /*  1060 */   436,  339,  446,  104,  446,   86,  457,  463,  264,  291,
- /*  1070 */   274,   49,  162,  336,  426,  426,  336,  297,  265,  542,
- /*  1080 */   541,  405,  446,   88,  594,  446,   89,   32,  465,  466,
- /*  1090 */   464,  464,   25,   25,   24,   24,   24,   24,  600,   26,
- /*  1100 */    26,   26,   26,   27,   27,   28,   28,   28,   29,  221,
- /*  1110 */    36,  345,  339,    3,  214,    8,  422,  335,  425,  437,
- /*  1120 */   375,  148,  162,   36,  345,  339,    3,  336,  342,  432,
- /*  1130 */   335,  425,  149,  577,  426,  162,  446,   90,  151,  339,
- /*  1140 */   336,  342,  434,  339,  283,  433,  333,  347,  447,  446,
- /*  1150 */    75,  588,    6,  158,  336,  448,  140,  481,  336,  426,
- /*  1160 */   347,  453,  334,  446,   76,   49,  350,  446,   91,    7,
- /*  1170 */   481,  426,  397,  283,  355,  250,  426,   39,   38,  251,
- /*  1180 */   339,  426,   48,  353,   37,  337,  338,  596,  426,  452,
- /*  1190 */    39,   38,  514,  252,  390,  336,   20,   37,  337,  338,
- /*  1200 */   253,   43,  452,  206,  446,   92,  219,  449,  242,  243,
- /*  1210 */   244,  150,  246,  283,  491,  593,  597,  490,  224,  258,
- /*  1220 */   454,  454,  454,  455,  456,   10,  503,  183,  426,  178,
- /*  1230 */   156,  301,  426,  454,  454,  454,  455,  456,   10,  339,
- /*  1240 */   302,  426,   36,  345,   50,    3,  339,  505,  260,  335,
- /*  1250 */   425,  262,  339,  176,  336,  581,  598,  358,  364,  175,
- /*  1260 */   342,  336,  177,  446,   93,   46,  345,  336,    3,  339,
- /*  1270 */   446,   94,  335,  425,  525,  339,  446,   77,  320,  347,
- /*  1280 */   511,  339,  507,  342,  336,  589,  601,   56,   56,  481,
- /*  1290 */   336,  512,  283,  446,   17,  531,  336,  426,  530,  446,
- /*  1300 */    96,  534,  347,  404,  298,  446,   97,  426,  313,   39,
- /*  1310 */    38,  267,  481,  219,  535,  536,   37,  337,  338,  283,
- /*  1320 */   620,  452,  309,  283,  111,   19,  288,  509,  269,  424,
- /*  1330 */   425,  539,   39,   38,  426,  238,  270,  411,  426,   37,
- /*  1340 */   337,  338,  426,  426,  452,  558,  426,  307,  231,  276,
- /*  1350 */   278,  426,  454,  454,  454,  455,  456,   10,  553,  280,
- /*  1360 */   426,  559,  239,  230,  426,  426,  299,  282,  287,  481,
- /*  1370 */   560,  388,  584,  232,  426,  454,  454,  454,  455,  456,
- /*  1380 */    10,  561,  426,  426,  585,  395,  426,  426,  292,  194,
- /*  1390 */   195,  592,  603,  300,  303,  308,  377,  522,  381,  426,
- /*  1400 */   426,  452,  567,  426,  304,  617,  426,  426,  426,  426,
- /*  1410 */   379,   53,  147,  165,  166,  167,  580,  212,  569,  426,
- /*  1420 */   426,  285,  168,  570,  387,  120,  123,  187,  590,  402,
- /*  1430 */   403,  125,  454,  454,  454,  330,  599,  614,  186,  126,
- /*  1440 */   127,  128,  615,  616,   57,   60,  619,  107,  229,   64,
- /*  1450 */   115,  420,  245,  130,  439,  180,  315,  207,  670,  316,
- /*  1460 */   671,  467,  672,  153,  154,   35,  483,  471,  480,  188,
- /*  1470 */   201,  155,  484,    5,  485,  489,   12,  502,   45,   11,
- /*  1480 */   110,  145,  518,  519,  510,  228,   51,  112,  369,  273,
- /*  1490 */   113,  159,  545,   52,  374,  114,  164,  265,  378,  190,
- /*  1500 */   146,  568,  117,  158,  286,  382,  169,  119,   15,  583,
- /*  1510 */   170,  171,  121,  586,  122,   54,   55,   13,  124,  591,
- /*  1520 */   173,  174,  118,  575,  129,  595,  571,  131,   14,  132,
- /*  1530 */   611,   63,  612,  193,  602,  179,  305,  413,  417,  960,
- /*  1540 */   627,
+ /*     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,
+ /*    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,
+ /*   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,
+ /*   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,
+ /*   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,
+ /*   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,
+ /*   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,
+ /*   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,
+ /*  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,
+ /*  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,  117,  347,  116,
+ /*  1490 */   115,  114,  448,  112,  182,  320,   22,  433,   19,  432,
+ /*  1500 */   431,   63,  428,  610,  193,  298,  597,  574,  572,  404,
+ /*  1510 */   555,  552,  290,  281,  510,  499,  498,  497,  495,  380,
+ /*  1520 */   356,  460,  256,  250,  345,  447,  306,    5,  570,  550,
+ /*  1530 */   299,  211,  370,  401,  550,  508,  502,  501,  490,  527,
+ /*  1540 */   525,  483,  238,
 };
 static const YYCODETYPE yy_lookahead[] = {
- /*     0 */    19,  142,  143,  144,  145,   24,  115,   26,   77,   78,
- /*    10 */    79,   80,   92,   82,   83,   84,   85,   86,   87,   88,
- /*    20 */    89,   90,   91,   92,   26,   27,  222,  223,  224,  225,
+ /*     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,
  /*    50 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
- /*    60 */    79,   80,   16,   82,   83,   84,   85,   86,   87,   88,
- /*    70 */    89,   90,   91,   92,   19,   94,   19,  166,  167,  168,
+ /*    60 */    79,   80,   23,   82,   83,   84,   85,   86,   87,   88,
+ /*    70 */    89,   90,   91,   92,   19,   94,  118,   19,  150,   22,
  /*    80 */    25,   82,   83,   84,   85,   86,   87,   88,   89,   90,
- /*    90 */    91,   92,   94,   95,   96,  150,   36,   99,  100,  101,
- /*   100 */   174,  169,  170,  171,   49,   50,   60,  109,   62,   54,
- /*   110 */   165,   51,    1,    2,   26,   27,  174,   22,   58,  174,
- /*   120 */   175,   26,   27,   68,   69,   70,   71,   72,   73,   74,
- /*   130 */    75,   76,   77,   78,   79,   80,  186,   82,   83,   84,
- /*   140 */    85,   86,   87,   88,   89,   90,   91,   92,   19,   92,
- /*   150 */    19,  172,  173,   96,   97,   98,   99,  100,  101,  102,
- /*   160 */   181,  216,  146,  147,  232,  108,  221,  107,  152,  186,
- /*   170 */   154,  150,  195,   30,   86,   87,  160,   34,   49,   50,
- /*   180 */    26,   52,   94,   95,  138,   97,  165,  181,  182,   94,
- /*   190 */    95,   48,  104,  105,  188,  174,  175,   68,   69,   70,
+ /*    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,
+ /*   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,
  /*   200 */    71,   72,   73,   74,   75,   76,   77,   78,   79,   80,
- /*   210 */   194,   82,   83,   84,   85,   86,   87,   88,   89,   90,
- /*   220 */    91,   92,   19,   92,   86,   87,   21,   24,   97,   98,
- /*   230 */    99,  100,  101,  102,  218,  214,  215,  208,   66,  108,
- /*   240 */   150,   86,   87,   88,   89,   90,   91,   92,   94,  173,
- /*   250 */   160,  183,   49,   50,  191,  165,   96,  181,   22,   99,
- /*   260 */   100,  101,   26,  247,  174,  175,   94,   57,   63,  109,
- /*   270 */    98,   68,   69,   70,   71,   72,   73,   74,   75,   76,
- /*   280 */    77,   78,   79,   80,  194,   82,   83,   84,   85,   86,
- /*   290 */    87,   88,   89,   90,   91,   92,   19,  150,  150,  150,
- /*   300 */    25,  129,  130,  131,  183,  100,  216,  160,  150,  161,
- /*   310 */   162,  221,  165,  165,  165,  105,  106,   26,   27,  170,
- /*   320 */   171,  174,  175,  165,  160,  115,   49,   50,  170,  171,
- /*   330 */    94,  148,  163,  185,  186,  166,  167,  168,  128,   91,
- /*   340 */    92,  194,  196,  138,  166,   68,   69,   70,   71,   72,
- /*   350 */    73,   74,   75,   76,   77,   78,   79,   80,  194,   82,
+ /*   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,
+ /*   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,
  /*   360 */    83,   84,   85,   86,   87,   88,   89,   90,   91,   92,
- /*   370 */    19,   96,   11,  150,   99,  100,  101,  155,   26,   27,
- /*   380 */   231,  232,  218,  205,  109,   94,   95,  150,  165,  231,
- /*   390 */   232,  166,  150,  222,  150,  224,  225,  174,  175,  235,
- /*   400 */    49,   50,  165,   24,  240,   26,  166,  165,  153,  165,
- /*   410 */   119,  174,  175,  136,  237,  244,  174,  175,   57,   68,
+ /*   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,
  /*   420 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
- /*   430 */    79,   80,  236,   82,   83,   84,   85,   86,   87,   88,
- /*   440 */    89,   90,   91,   92,   19,  205,   94,   95,   23,  226,
- /*   450 */   165,  229,  215,  150,   12,   88,  234,  150,  216,  174,
- /*   460 */    32,  217,  222,   25,  224,  225,  105,  106,  165,   41,
- /*   470 */    28,  119,  165,   94,   49,   50,  115,  174,  175,  112,
- /*   480 */    22,  174,  175,  116,   26,   27,   44,  136,   46,  128,
- /*   490 */   166,   26,   27,   68,   69,   70,   71,   72,   73,   74,
- /*   500 */    75,   76,   77,   78,   79,   80,  150,   82,   83,   84,
- /*   510 */    85,   86,   87,   88,   89,   90,   91,   92,   19,  150,
- /*   520 */   150,  165,   23,  220,  196,  150,  150,  220,  158,  205,
- /*   530 */   150,  161,  162,  198,  165,  165,   26,   27,  112,   23,
- /*   540 */   165,  165,  116,  174,  175,  165,  150,  166,   49,   50,
- /*   550 */   174,  175,   94,   95,  174,  175,  118,  161,  162,   94,
- /*   560 */    95,  165,  187,   16,   22,  160,   24,   68,   69,   70,
+ /*   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,
  /*   570 */    71,   72,   73,   74,   75,   76,   77,   78,   79,   80,
- /*   580 */   150,   82,   83,   84,   85,   86,   87,   88,   89,   90,
- /*   590 */    91,   92,   19,  150,   12,  165,   23,  241,   88,  194,
- /*   600 */   150,    0,    1,    2,   94,   95,  160,   60,  165,   62,
- /*   610 */    28,  206,  207,  190,  191,  165,  150,  174,  175,    7,
- /*   620 */     8,    9,   49,   50,  174,  175,   44,  111,   46,  113,
- /*   630 */   114,  165,  169,  170,  171,   22,   23,  233,   25,   57,
- /*   640 */   194,   68,   69,   70,   71,   72,   73,   74,   75,   76,
- /*   650 */    77,   78,   79,   80,  150,   82,   83,   84,   85,   86,
- /*   660 */    87,   88,   89,   90,   91,   92,   19,  150,   25,  165,
- /*   670 */    23,  150,  233,   19,  150,  190,  191,  228,  174,  175,
- /*   680 */    67,  222,  165,  224,  225,  150,  165,  150,  150,  165,
- /*   690 */    23,  174,  175,  144,  145,  232,   49,   50,  174,  175,
- /*   700 */   165,  115,  165,  165,   50,   22,   23,  241,   25,  174,
- /*   710 */   175,  174,  175,  127,  193,   68,   69,   70,   71,   72,
+ /*   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,
  /*   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,  150,  165,  150,   24,  103,   23,  150,  150,
- /*   750 */    67,  213,  174,  175,   97,  209,  165,  165,  104,  165,
- /*   760 */   150,  150,  108,  165,  165,  174,  175,   23,  174,  175,
- /*   770 */    49,   50,  115,  174,  175,  165,  165,  177,  111,  187,
- /*   780 */   113,  114,  250,  251,  127,  174,  175,  206,  207,   68,
+ /*   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,
  /*   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,  150,  111,
- /*   820 */   182,  113,  114,  105,  106,  177,  174,  175,   25,  166,
- /*   830 */   165,  165,  150,  165,  150,  111,  150,  113,  114,  174,
- /*   840 */   175,  150,  174,  175,   49,   50,  128,  165,  135,  165,
- /*   850 */   137,  165,  197,  187,  166,  111,  165,  113,  114,  204,
- /*   860 */   174,  175,  177,   68,   69,   70,   71,   72,   73,   74,
+ /*   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,
  /*   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,  205,  177,  213,  150,  213,   95,  177,
- /*   900 */   174,  175,  129,  130,  165,  165,   23,  165,   25,  150,
- /*   910 */   150,  165,  178,  174,  175,  150,  174,  175,   49,   50,
- /*   920 */   174,  175,  119,   19,  165,  165,   50,   22,   23,  160,
- /*   930 */   165,   27,  241,  193,  174,  175,  160,   68,   69,   70,
+ /*   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,
  /*   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,  194,  150,  165,  150,  150,  150,  160,
- /*   970 */   194,   25,   67,  160,  174,  175,  217,  166,   95,  165,
- /*   980 */   104,  165,  165,  165,  150,  245,  248,  249,   49,   50,
- /*   990 */   174,  175,   49,   50,   23,   23,   25,   25,  242,  165,
- /*  1000 */   199,  187,  119,  194,  187,   22,   23,  194,  174,  175,
+ /*   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,
  /*  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,   19,    7,    8,  105,  106,  174,  175,
- /*  1050 */    67,   27,   23,  165,   25,  165,  165,  165,  150,  150,
- /*  1060 */   150,  150,  174,  175,  174,  175,   49,   50,   98,  242,
- /*  1070 */    23,  125,   25,  165,  165,  165,  165,  209,  108,   97,
- /*  1080 */    98,  209,  174,  175,  193,  174,  175,   70,   71,   72,
- /*  1090 */    73,   74,   75,   76,   77,   78,   79,   80,  199,   82,
+ /*  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,
  /*  1100 */    83,   84,   85,   86,   87,   88,   89,   90,   91,   92,
- /*  1110 */    19,   20,  150,   22,  160,   22,  149,   26,   27,  150,
- /*  1120 */    23,    6,   25,   19,   20,  150,   22,  165,   37,  149,
- /*  1130 */    26,   27,  151,   23,  165,   25,  174,  175,  151,  150,
- /*  1140 */   165,   37,   13,  150,  150,  149,  149,   56,  194,  174,
- /*  1150 */   175,   23,   25,   25,  165,  194,  150,   66,  165,  165,
- /*  1160 */    56,  150,  159,  174,  175,  125,  150,  174,  175,   76,
- /*  1170 */    66,  165,  218,  150,  122,  199,  165,   86,   87,  200,
- /*  1180 */   150,  165,  123,  121,   93,   94,   95,  193,  165,   98,
- /*  1190 */    86,   87,   88,  201,  240,  165,  124,   93,   94,   95,
- /*  1200 */   202,  135,   98,    5,  174,  175,  115,  203,   10,   11,
- /*  1210 */    12,   13,   14,  150,  157,   17,  193,  150,  227,  210,
- /*  1220 */   129,  130,  131,  132,  133,  134,  150,  157,  165,   31,
- /*  1230 */   117,   33,  165,  129,  130,  131,  132,  133,  134,  150,
- /*  1240 */    42,  165,   19,   20,  104,   22,  150,  211,  210,   26,
- /*  1250 */    27,  210,  150,   55,  165,   57,  193,  120,  104,   61,
- /*  1260 */    37,  165,   64,  174,  175,   19,   20,  165,   22,  150,
- /*  1270 */   174,  175,   26,   27,  176,  150,  174,  175,   47,   56,
- /*  1280 */   211,  150,  150,   37,  165,   23,   23,   25,   25,   66,
- /*  1290 */   165,  211,  150,  174,  175,  184,  165,  165,  176,  174,
- /*  1300 */   175,  178,   56,  105,  106,  174,  175,  165,  110,   86,
- /*  1310 */    87,  176,   66,  115,  103,  176,   93,   94,   95,  150,
- /*  1320 */    23,   98,   25,  150,   22,   22,  128,  150,  150,   26,
- /*  1330 */    27,  150,   86,   87,  165,  193,  150,  139,  165,   93,
- /*  1340 */    94,   95,  165,  165,   98,  150,  165,  179,   92,  150,
- /*  1350 */   150,  165,  129,  130,  131,  132,  133,  134,  184,  150,
- /*  1360 */   165,  176,  193,  230,  165,  165,  193,  150,  150,   66,
- /*  1370 */   176,  150,  150,  230,  165,  129,  130,  131,  132,  133,
- /*  1380 */   134,  176,  165,  165,  150,  150,  165,  165,  150,   86,
- /*  1390 */    87,  150,  150,  150,  150,  179,   18,   94,   45,  165,
- /*  1400 */   165,   98,  157,  165,  150,  150,  165,  165,  165,  165,
- /*  1410 */   157,  135,   68,  156,  156,  156,  189,  157,  157,  165,
- /*  1420 */   165,  238,  156,  239,  157,  189,   22,  219,  199,  157,
- /*  1430 */    18,  192,  129,  130,  131,  157,  199,   40,  219,  192,
- /*  1440 */   192,  192,  157,  157,  243,  243,   38,  164,  180,  246,
- /*  1450 */   180,    1,   15,  189,   23,  249,  252,   22,  117,  252,
- /*  1460 */   117,  112,  117,  117,  117,   22,   11,   23,   23,   22,
- /*  1470 */    22,   25,   23,   35,   23,   23,   35,  119,   25,   25,
- /*  1480 */    22,  117,   23,   23,   27,   52,   22,   22,   52,   23,
- /*  1490 */    22,   35,   29,   22,   52,   22,  102,  108,   19,   24,
- /*  1500 */    39,   20,  104,   25,  138,   43,  104,   22,    5,    1,
- /*  1510 */   117,   35,  107,   27,  126,   76,   76,   22,  118,    1,
- /*  1520 */    16,  120,   53,   53,  118,   20,   59,  107,   22,  126,
- /*  1530 */    23,   16,   23,   22,  127,   15,  140,   65,    3,  253,
- /*  1540 */     4,
+ /*  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,
+ /*  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,
+ /*  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,  192,   18,  192,
+ /*  1490 */   192,  192,  199,  189,  219,  157,  243,   40,  243,  157,
+ /*  1500 */   157,  246,   38,  153,  196,  198,  166,  233,  233,  228,
+ /*  1510 */   177,  177,  209,  177,  182,  177,  166,  177,  166,  178,
+ /*  1520 */   242,  199,  242,  209,  209,  199,  148,  196,  166,  208,
+ /*  1530 */   195,  236,  237,  191,  208,  183,  183,  183,  186,  174,
+ /*  1540 */   174,  186,   92,
 };
-#define YY_SHIFT_USE_DFLT (-110)
-#define YY_SHIFT_MAX 417
+#define YY_SHIFT_USE_DFLT (-90)
+#define YY_SHIFT_COUNT (418)
+#define YY_SHIFT_MIN   (-89)
+#define YY_SHIFT_MAX   (1470)
 static const short yy_shift_ofst[] = {
- /*     0 */   111, 1091, 1198, 1091, 1223, 1223,   -2,   88,   88,  -19,
- /*    10 */  1223, 1223, 1223, 1223, 1223,  210,  465,  129, 1104, 1223,
- /*    20 */  1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
- /*    30 */  1223, 1223, 1246, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
- /*    40 */  1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
- /*    50 */  1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
- /*    60 */  1223,  -49,  361,  465,  465,  154,  138,  138, -109,   55,
- /*    70 */   203,  277,  351,  425,  499,  573,  647,  721,  795,  869,
+ /*     0 */   993, 1114, 1343, 1114, 1213, 1213,   90,   90,    0,  -19,
+ /*    10 */  1213, 1213, 1213, 1213, 1213,  352,  517,  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,
  /*    80 */   795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
- /*    90 */   795,  795,  795,  795,  795,  795,  795,  795,  943, 1017,
- /*   100 */  1017,  -69,  -69,  -69,  -69,   -1,   -1,   57,  155,  -44,
- /*   110 */   465,  465,  465,  465,  465,  654,  205,  465,  465,  465,
- /*   120 */   465,  465,  465,  465,  465,  465,  465,  465,  465,  465,
- /*   130 */   465,  465,  465,  248,  154,  -80, -110, -110, -110, 1303,
- /*   140 */   131,   95,  291,  352,  458,  510,  582,  582,  465,  465,
- /*   150 */   465,  465,  465,  465,  465,  465,  465,  465,  465,  465,
- /*   160 */   465,  465,  465,  465,  465,  465,  465,  465,  465,  465,
- /*   170 */   465,  465,  465,  465,  465,  465,  465,  465,  465,  465,
- /*   180 */   613,  683,  601,  379,  379,  379,  657,  586, -109, -109,
- /*   190 */  -109, -110, -110, -110,  172,  172,  275,  160,  516,  667,
- /*   200 */   724,  442,  744,  883,   60,   60,  612,  367,  236,  803,
- /*   210 */   708,  708,  143,  718,  708,  708,  708,  708,  542,  426,
- /*   220 */   438,  154,  773,  773,  713,  428,  428,  904,  428,  876,
- /*   230 */   428,  154,  428,  154,  643, 1024,  946, 1024,  904,  904,
- /*   240 */   946, 1115, 1115, 1115, 1115, 1129, 1129, 1127, -109, 1040,
- /*   250 */  1052, 1059, 1062, 1072, 1066, 1113, 1113, 1140, 1137, 1140,
- /*   260 */  1137, 1140, 1137, 1154, 1154, 1231, 1154, 1211, 1154, 1302,
- /*   270 */  1256, 1256, 1231, 1154, 1154, 1154, 1302, 1378, 1113, 1378,
- /*   280 */  1113, 1378, 1113, 1113, 1353, 1276, 1378, 1113, 1344, 1344,
- /*   290 */  1404, 1040, 1113, 1412, 1412, 1412, 1412, 1040, 1344, 1404,
- /*   300 */  1113, 1397, 1397, 1113, 1113, 1408, -110, -110, -110, -110,
- /*   310 */  -110, -110,  939,   46,  547,  905,  983,  971,  972,  970,
- /*   320 */  1037,  941,  982, 1029, 1047, 1097, 1110, 1128, 1262, 1263,
- /*   330 */  1093, 1297, 1450, 1437, 1431, 1435, 1341, 1343, 1345, 1346,
- /*   340 */  1347, 1349, 1443, 1444, 1445, 1447, 1455, 1448, 1449, 1446,
- /*   350 */  1451, 1452, 1453, 1438, 1454, 1441, 1453, 1358, 1458, 1456,
- /*   360 */  1457, 1364, 1459, 1460, 1461, 1433, 1464, 1463, 1436, 1465,
- /*   370 */  1466, 1468, 1471, 1442, 1473, 1394, 1389, 1479, 1481, 1475,
- /*   380 */  1398, 1462, 1467, 1469, 1478, 1470, 1366, 1402, 1485, 1503,
- /*   390 */  1508, 1393, 1476, 1486, 1405, 1439, 1440, 1388, 1495, 1400,
- /*   400 */  1518, 1504, 1401, 1505, 1406, 1420, 1403, 1506, 1407, 1507,
- /*   410 */  1509, 1515, 1472, 1520, 1396, 1511, 1535, 1536,
+ /*    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, 1450,  -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, 1464, 1244, 1244, 1457, 1457, 1244, 1462, 1412,
+ /*   250 */  1188, 1470, 1470, 1470, 1470, 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,
 };
-#define YY_REDUCE_USE_DFLT (-197)
-#define YY_REDUCE_MAX 311
+#define YY_REDUCE_USE_DFLT (-222)
+#define YY_REDUCE_COUNT (312)
+#define YY_REDUCE_MIN   (-221)
+#define YY_REDUCE_MAX   (1378)
 static const short yy_reduce_ofst[] = {
- /*     0 */  -141,   90,   16,  147,  -55,   21,  148,  149,  158,  240,
- /*    10 */   223,  237,  242,  303,  307,  164,  370,  171,  369,  376,
- /*    20 */   380,  443,  450,  504,  517,  524,  535,  537,  578,  591,
- /*    30 */   594,  599,  611,  652,  665,  668,  686,  726,  739,  742,
- /*    40 */   746,  760,  800,  816,  834,  874,  888,  890,  908,  911,
- /*    50 */   962,  975,  989,  993, 1030, 1089, 1096, 1102, 1119, 1125,
- /*    60 */  1131, -196,  954,  740,  396,  169,  -68,  463,  405,  459,
- /*    70 */   459,  459,  459,  459,  459,  459,  459,  459,  459,  459,
- /*    80 */   459,  459,  459,  459,  459,  459,  459,  459,  459,  459,
- /*    90 */   459,  459,  459,  459,  459,  459,  459,  459,  459,  459,
- /*   100 */   459,  459,  459,  459,  459,  459,  459,  -21,  459,  459,
- /*   110 */   538,  375,  592,  666,  814,    6,  222,  521,  682,  817,
- /*   120 */   356,  244,  466,  684,  691,  891,  994, 1023, 1063, 1142,
- /*   130 */  1169,  759, 1173,  459,  -89,  459,  459,  459,  459,  285,
- /*   140 */    76,  430,  598,  610,  765,  818,  423,  485,  892,  909,
- /*   150 */   910,  969, 1006,  818, 1011, 1016, 1067, 1076, 1132, 1177,
- /*   160 */  1178, 1181, 1186, 1195, 1199, 1200, 1209, 1217, 1218, 1221,
- /*   170 */  1222, 1234, 1235, 1238, 1241, 1242, 1243, 1244, 1254, 1255,
- /*   180 */   532,  532,  549,  178,  324,  688,  446,  769,  776,  809,
- /*   190 */   813,  655,  581,  738,  -74,  -58,  -50,  -17,  -23,  -23,
- /*   200 */   -23,   63,  -23,   29,   68,  121,  183,  146,  225,   29,
- /*   210 */   -23,  -23,  196,  177,  -23,  -23,  -23,  -23,  255,  328,
- /*   220 */   335,  381,  404,  439,  449,  600,  648,  546,  685,  638,
- /*   230 */   717,  663,  722,  811,  734,  756,  801,  827,  868,  872,
- /*   240 */   899,  967,  980,  996,  997,  981,  987, 1003,  961,  976,
- /*   250 */   979,  992,  998, 1004,  991, 1057, 1070, 1009, 1036, 1038,
- /*   260 */  1069, 1041, 1080, 1098, 1122, 1111, 1135, 1123, 1139, 1168,
- /*   270 */  1133, 1143, 1174, 1185, 1194, 1205, 1216, 1257, 1245, 1258,
- /*   280 */  1253, 1259, 1260, 1261, 1183, 1184, 1266, 1267, 1227, 1236,
- /*   290 */  1208, 1229, 1272, 1239, 1247, 1248, 1249, 1237, 1264, 1219,
- /*   300 */  1278, 1201, 1202, 1285, 1286, 1203, 1283, 1268, 1270, 1206,
- /*   310 */  1204, 1207,
+ /*     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, 1355, 1366, 1365, 1352, 1354, 1353,
+ /*   200 */  1352, 1326, 1335, 1342, 1335, 1335, 1335, 1335, 1335, 1335,
+ /*   210 */  1335, 1295, 1295, 1335, 1335, 1321, 1362, 1331, 1378, 1326,
+ /*   220 */  1315, 1314, 1280, 1322, 1278, 1341, 1352, 1340, 1350, 1338,
+ /*   230 */  1332, 1336, 1303, 1334, 1333, 1281, 1275, 1274, 1340, 1307,
+ /*   240 */  1308, 1350, 1255, 1343, 1342, 1255, 1253, 1338, 1275, 1304,
+ /*   250 */  1293, 1299, 1298, 1297, 1295, 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,
 };
 static const YYACTIONTYPE yy_default[] = {
- /*     0 */   634,  869,  958,  958,  869,  958,  958,  898,  898,  757,
- /*    10 */   867,  958,  958,  958,  958,  958,  958,  932,  958,  958,
- /*    20 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*    30 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*    40 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*    50 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*    60 */   958,  841,  958,  958,  958,  673,  898,  898,  761,  792,
- /*    70 */   958,  958,  958,  958,  958,  958,  958,  958,  793,  958,
- /*    80 */   871,  866,  862,  864,  863,  870,  794,  783,  790,  797,
- /*    90 */   772,  911,  799,  800,  806,  807,  933,  931,  829,  828,
- /*   100 */   847,  831,  845,  853,  846,  830,  840,  665,  832,  833,
- /*   110 */   958,  958,  958,  958,  958,  726,  660,  958,  958,  958,
- /*   120 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*   130 */   958,  958,  958,  834,  958,  835,  848,  849,  850,  958,
- /*   140 */   958,  958,  958,  958,  958,  958,  958,  958,  640,  958,
- /*   150 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*   160 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*   170 */   958,  958,  958,  958,  958,  882,  958,  936,  938,  958,
- /*   180 */   958,  958,  634,  757,  757,  757,  958,  958,  958,  958,
- /*   190 */   958,  751,  761,  950,  958,  958,  717,  958,  958,  958,
- /*   200 */   958,  958,  958,  958,  958,  958,  642,  749,  675,  759,
- /*   210 */   662,  738,  904,  958,  923,  921,  740,  802,  958,  749,
- /*   220 */   758,  958,  958,  958,  865,  786,  786,  774,  786,  696,
- /*   230 */   786,  958,  786,  958,  699,  916,  796,  916,  774,  774,
- /*   240 */   796,  639,  639,  639,  639,  650,  650,  716,  958,  796,
- /*   250 */   787,  789,  779,  791,  958,  765,  765,  773,  778,  773,
- /*   260 */   778,  773,  778,  728,  728,  713,  728,  699,  728,  875,
- /*   270 */   879,  879,  713,  728,  728,  728,  875,  657,  765,  657,
- /*   280 */   765,  657,  765,  765,  908,  910,  657,  765,  730,  730,
- /*   290 */   808,  796,  765,  737,  737,  737,  737,  796,  730,  808,
- /*   300 */   765,  935,  935,  765,  765,  943,  683,  701,  701,  950,
- /*   310 */   955,  955,  958,  958,  958,  958,  958,  958,  958,  958,
- /*   320 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*   330 */   884,  958,  958,  648,  958,  667,  815,  820,  816,  958,
- /*   340 */   817,  743,  958,  958,  958,  958,  958,  958,  958,  958,
- /*   350 */   958,  958,  868,  958,  780,  958,  788,  958,  958,  958,
- /*   360 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*   370 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*   380 */   958,  958,  958,  906,  907,  958,  958,  958,  958,  958,
- /*   390 */   958,  914,  958,  958,  958,  958,  958,  958,  958,  958,
- /*   400 */   958,  958,  958,  958,  958,  958,  958,  958,  958,  958,
- /*   410 */   958,  958,  942,  958,  958,  945,  635,  958,  630,  632,
- /*   420 */   633,  637,  638,  641,  667,  668,  670,  671,  672,  643,
- /*   430 */   644,  645,  646,  647,  649,  653,  651,  652,  654,  661,
- /*   440 */   663,  682,  684,  686,  747,  748,  812,  741,  742,  746,
- /*   450 */   669,  823,  814,  818,  819,  821,  822,  836,  837,  839,
- /*   460 */   844,  852,  855,  838,  843,  851,  854,  744,  745,  858,
- /*   470 */   676,  677,  680,  681,  894,  896,  895,  897,  679,  678,
- /*   480 */   824,  827,  860,  861,  924,  925,  926,  927,  928,  856,
- /*   490 */   766,  859,  842,  781,  784,  785,  782,  750,  760,  768,
- /*   500 */   769,  770,  771,  755,  756,  762,  777,  810,  811,  775,
- /*   510 */   776,  763,  764,  752,  753,  754,  857,  813,  825,  826,
- /*   520 */   687,  688,  820,  689,  690,  691,  729,  732,  733,  734,
- /*   530 */   692,  711,  714,  715,  693,  700,  694,  695,  702,  703,
- /*   540 */   704,  706,  707,  708,  709,  710,  705,  876,  877,  880,
- /*   550 */   878,  697,  698,  712,  685,  674,  666,  718,  721,  722,
- /*   560 */   723,  724,  725,  727,  719,  720,  664,  655,  658,  767,
- /*   570 */   900,  909,  905,  901,  902,  903,  659,  872,  873,  731,
- /*   580 */   804,  805,  899,  912,  915,  917,  918,  919,  809,  920,
- /*   590 */   922,  913,  947,  656,  735,  736,  739,  881,  929,  795,
- /*   600 */   798,  801,  803,  883,  885,  887,  889,  890,  891,  892,
- /*   610 */   893,  886,  888,  930,  934,  937,  939,  940,  941,  944,
- /*   620 */   946,  951,  952,  953,  956,  957,  954,  636,  631,
+ /*     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,
 };
-#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
 
 /* The next table maps tokens into fallback tokens.  If a construct
 ** like the following:
@@ -90823,13 +91549,13 @@ static const char *const yyTokenName[] = {
   "COLLATE",       "BITNOT",        "STRING",        "JOIN_KW",     
   "CONSTRAINT",    "DEFAULT",       "NULL",          "PRIMARY",     
   "UNIQUE",        "CHECK",         "REFERENCES",    "AUTOINCR",    
-  "ON",            "DELETE",        "UPDATE",        "SET",         
-  "DEFERRABLE",    "FOREIGN",       "DROP",          "UNION",       
-  "ALL",           "EXCEPT",        "INTERSECT",     "SELECT",      
-  "DISTINCT",      "DOT",           "FROM",          "JOIN",        
-  "USING",         "ORDER",         "GROUP",         "HAVING",      
-  "LIMIT",         "WHERE",         "INTO",          "VALUES",      
-  "INSERT",        "INTEGER",       "FLOAT",         "BLOB",        
+  "ON",            "INSERT",        "DELETE",        "UPDATE",      
+  "SET",           "DEFERRABLE",    "FOREIGN",       "DROP",        
+  "UNION",         "ALL",           "EXCEPT",        "INTERSECT",   
+  "SELECT",        "DISTINCT",      "DOT",           "FROM",        
+  "JOIN",          "USING",         "ORDER",         "GROUP",       
+  "HAVING",        "LIMIT",         "WHERE",         "INTO",        
+  "VALUES",        "INTEGER",       "FLOAT",         "BLOB",        
   "REGISTER",      "VARIABLE",      "CASE",          "WHEN",        
   "THEN",          "ELSE",          "INDEX",         "ALTER",       
   "ADD",           "error",         "input",         "cmdlist",     
@@ -90943,260 +91669,261 @@ static const char *const yyRuleName[] = {
  /*  72 */ "refargs ::=",
  /*  73 */ "refargs ::= refargs refarg",
  /*  74 */ "refarg ::= MATCH nm",
- /*  75 */ "refarg ::= ON DELETE refact",
- /*  76 */ "refarg ::= ON UPDATE refact",
- /*  77 */ "refact ::= SET NULL",
- /*  78 */ "refact ::= SET DEFAULT",
- /*  79 */ "refact ::= CASCADE",
- /*  80 */ "refact ::= RESTRICT",
- /*  81 */ "refact ::= NO ACTION",
- /*  82 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
- /*  83 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
- /*  84 */ "init_deferred_pred_opt ::=",
- /*  85 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
- /*  86 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
- /*  87 */ "conslist_opt ::=",
- /*  88 */ "conslist_opt ::= COMMA conslist",
- /*  89 */ "conslist ::= conslist COMMA tcons",
- /*  90 */ "conslist ::= conslist tcons",
- /*  91 */ "conslist ::= tcons",
- /*  92 */ "tcons ::= CONSTRAINT nm",
- /*  93 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
- /*  94 */ "tcons ::= UNIQUE LP idxlist RP onconf",
- /*  95 */ "tcons ::= CHECK LP expr RP onconf",
- /*  96 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
- /*  97 */ "defer_subclause_opt ::=",
- /*  98 */ "defer_subclause_opt ::= defer_subclause",
- /*  99 */ "onconf ::=",
- /* 100 */ "onconf ::= ON CONFLICT resolvetype",
- /* 101 */ "orconf ::=",
- /* 102 */ "orconf ::= OR resolvetype",
- /* 103 */ "resolvetype ::= raisetype",
- /* 104 */ "resolvetype ::= IGNORE",
- /* 105 */ "resolvetype ::= REPLACE",
- /* 106 */ "cmd ::= DROP TABLE ifexists fullname",
- /* 107 */ "ifexists ::= IF EXISTS",
- /* 108 */ "ifexists ::=",
- /* 109 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
- /* 110 */ "cmd ::= DROP VIEW ifexists fullname",
- /* 111 */ "cmd ::= select",
- /* 112 */ "select ::= oneselect",
- /* 113 */ "select ::= select multiselect_op oneselect",
- /* 114 */ "multiselect_op ::= UNION",
- /* 115 */ "multiselect_op ::= UNION ALL",
- /* 116 */ "multiselect_op ::= EXCEPT|INTERSECT",
- /* 117 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
- /* 118 */ "distinct ::= DISTINCT",
- /* 119 */ "distinct ::= ALL",
- /* 120 */ "distinct ::=",
- /* 121 */ "sclp ::= selcollist COMMA",
- /* 122 */ "sclp ::=",
- /* 123 */ "selcollist ::= sclp expr as",
- /* 124 */ "selcollist ::= sclp STAR",
- /* 125 */ "selcollist ::= sclp nm DOT STAR",
- /* 126 */ "as ::= AS nm",
- /* 127 */ "as ::= ids",
- /* 128 */ "as ::=",
- /* 129 */ "from ::=",
- /* 130 */ "from ::= FROM seltablist",
- /* 131 */ "stl_prefix ::= seltablist joinop",
- /* 132 */ "stl_prefix ::=",
- /* 133 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
- /* 134 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
- /* 135 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
- /* 136 */ "dbnm ::=",
- /* 137 */ "dbnm ::= DOT nm",
- /* 138 */ "fullname ::= nm dbnm",
- /* 139 */ "joinop ::= COMMA|JOIN",
- /* 140 */ "joinop ::= JOIN_KW JOIN",
- /* 141 */ "joinop ::= JOIN_KW nm JOIN",
- /* 142 */ "joinop ::= JOIN_KW nm nm JOIN",
- /* 143 */ "on_opt ::= ON expr",
- /* 144 */ "on_opt ::=",
- /* 145 */ "indexed_opt ::=",
- /* 146 */ "indexed_opt ::= INDEXED BY nm",
- /* 147 */ "indexed_opt ::= NOT INDEXED",
- /* 148 */ "using_opt ::= USING LP inscollist RP",
- /* 149 */ "using_opt ::=",
- /* 150 */ "orderby_opt ::=",
- /* 151 */ "orderby_opt ::= ORDER BY sortlist",
- /* 152 */ "sortlist ::= sortlist COMMA sortitem sortorder",
- /* 153 */ "sortlist ::= sortitem sortorder",
- /* 154 */ "sortitem ::= expr",
- /* 155 */ "sortorder ::= ASC",
- /* 156 */ "sortorder ::= DESC",
- /* 157 */ "sortorder ::=",
- /* 158 */ "groupby_opt ::=",
- /* 159 */ "groupby_opt ::= GROUP BY nexprlist",
- /* 160 */ "having_opt ::=",
- /* 161 */ "having_opt ::= HAVING expr",
- /* 162 */ "limit_opt ::=",
- /* 163 */ "limit_opt ::= LIMIT expr",
- /* 164 */ "limit_opt ::= LIMIT expr OFFSET expr",
- /* 165 */ "limit_opt ::= LIMIT expr COMMA expr",
- /* 166 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
- /* 167 */ "where_opt ::=",
- /* 168 */ "where_opt ::= WHERE expr",
- /* 169 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
- /* 170 */ "setlist ::= setlist COMMA nm EQ expr",
- /* 171 */ "setlist ::= nm EQ expr",
- /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP",
- /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
- /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
- /* 175 */ "insert_cmd ::= INSERT orconf",
- /* 176 */ "insert_cmd ::= REPLACE",
- /* 177 */ "itemlist ::= itemlist COMMA expr",
- /* 178 */ "itemlist ::= expr",
- /* 179 */ "inscollist_opt ::=",
- /* 180 */ "inscollist_opt ::= LP inscollist RP",
- /* 181 */ "inscollist ::= inscollist COMMA nm",
- /* 182 */ "inscollist ::= nm",
- /* 183 */ "expr ::= term",
- /* 184 */ "expr ::= LP expr RP",
- /* 185 */ "term ::= NULL",
- /* 186 */ "expr ::= id",
- /* 187 */ "expr ::= JOIN_KW",
- /* 188 */ "expr ::= nm DOT nm",
- /* 189 */ "expr ::= nm DOT nm DOT nm",
- /* 190 */ "term ::= INTEGER|FLOAT|BLOB",
- /* 191 */ "term ::= STRING",
- /* 192 */ "expr ::= REGISTER",
- /* 193 */ "expr ::= VARIABLE",
- /* 194 */ "expr ::= expr COLLATE ids",
- /* 195 */ "expr ::= CAST LP expr AS typetoken RP",
- /* 196 */ "expr ::= ID LP distinct exprlist RP",
- /* 197 */ "expr ::= ID LP STAR RP",
- /* 198 */ "term ::= CTIME_KW",
- /* 199 */ "expr ::= expr AND expr",
- /* 200 */ "expr ::= expr OR expr",
- /* 201 */ "expr ::= expr LT|GT|GE|LE expr",
- /* 202 */ "expr ::= expr EQ|NE expr",
- /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
- /* 204 */ "expr ::= expr PLUS|MINUS expr",
- /* 205 */ "expr ::= expr STAR|SLASH|REM expr",
- /* 206 */ "expr ::= expr CONCAT expr",
- /* 207 */ "likeop ::= LIKE_KW",
- /* 208 */ "likeop ::= NOT LIKE_KW",
- /* 209 */ "likeop ::= MATCH",
- /* 210 */ "likeop ::= NOT MATCH",
- /* 211 */ "escape ::= ESCAPE expr",
- /* 212 */ "escape ::=",
- /* 213 */ "expr ::= expr likeop expr escape",
- /* 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",
+ /*  75 */ "refarg ::= ON INSERT refact",
+ /*  76 */ "refarg ::= ON DELETE refact",
+ /*  77 */ "refarg ::= ON UPDATE refact",
+ /*  78 */ "refact ::= SET NULL",
+ /*  79 */ "refact ::= SET DEFAULT",
+ /*  80 */ "refact ::= CASCADE",
+ /*  81 */ "refact ::= RESTRICT",
+ /*  82 */ "refact ::= NO ACTION",
+ /*  83 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
+ /*  84 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
+ /*  85 */ "init_deferred_pred_opt ::=",
+ /*  86 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
+ /*  87 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
+ /*  88 */ "conslist_opt ::=",
+ /*  89 */ "conslist_opt ::= COMMA conslist",
+ /*  90 */ "conslist ::= conslist COMMA tcons",
+ /*  91 */ "conslist ::= conslist tcons",
+ /*  92 */ "conslist ::= tcons",
+ /*  93 */ "tcons ::= CONSTRAINT nm",
+ /*  94 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
+ /*  95 */ "tcons ::= UNIQUE LP idxlist RP onconf",
+ /*  96 */ "tcons ::= CHECK LP expr RP onconf",
+ /*  97 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
+ /*  98 */ "defer_subclause_opt ::=",
+ /*  99 */ "defer_subclause_opt ::= defer_subclause",
+ /* 100 */ "onconf ::=",
+ /* 101 */ "onconf ::= ON CONFLICT resolvetype",
+ /* 102 */ "orconf ::=",
+ /* 103 */ "orconf ::= OR resolvetype",
+ /* 104 */ "resolvetype ::= raisetype",
+ /* 105 */ "resolvetype ::= IGNORE",
+ /* 106 */ "resolvetype ::= REPLACE",
+ /* 107 */ "cmd ::= DROP TABLE ifexists fullname",
+ /* 108 */ "ifexists ::= IF EXISTS",
+ /* 109 */ "ifexists ::=",
+ /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
+ /* 111 */ "cmd ::= DROP VIEW ifexists fullname",
+ /* 112 */ "cmd ::= select",
+ /* 113 */ "select ::= oneselect",
+ /* 114 */ "select ::= select multiselect_op oneselect",
+ /* 115 */ "multiselect_op ::= UNION",
+ /* 116 */ "multiselect_op ::= UNION ALL",
+ /* 117 */ "multiselect_op ::= EXCEPT|INTERSECT",
+ /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
+ /* 119 */ "distinct ::= DISTINCT",
+ /* 120 */ "distinct ::= ALL",
+ /* 121 */ "distinct ::=",
+ /* 122 */ "sclp ::= selcollist COMMA",
+ /* 123 */ "sclp ::=",
+ /* 124 */ "selcollist ::= sclp expr as",
+ /* 125 */ "selcollist ::= sclp STAR",
+ /* 126 */ "selcollist ::= sclp nm DOT STAR",
+ /* 127 */ "as ::= AS nm",
+ /* 128 */ "as ::= ids",
+ /* 129 */ "as ::=",
+ /* 130 */ "from ::=",
+ /* 131 */ "from ::= FROM seltablist",
+ /* 132 */ "stl_prefix ::= seltablist joinop",
+ /* 133 */ "stl_prefix ::=",
+ /* 134 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
+ /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
+ /* 136 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
+ /* 137 */ "dbnm ::=",
+ /* 138 */ "dbnm ::= DOT nm",
+ /* 139 */ "fullname ::= nm dbnm",
+ /* 140 */ "joinop ::= COMMA|JOIN",
+ /* 141 */ "joinop ::= JOIN_KW JOIN",
+ /* 142 */ "joinop ::= JOIN_KW nm JOIN",
+ /* 143 */ "joinop ::= JOIN_KW nm nm JOIN",
+ /* 144 */ "on_opt ::= ON expr",
+ /* 145 */ "on_opt ::=",
+ /* 146 */ "indexed_opt ::=",
+ /* 147 */ "indexed_opt ::= INDEXED BY nm",
+ /* 148 */ "indexed_opt ::= NOT INDEXED",
+ /* 149 */ "using_opt ::= USING LP inscollist RP",
+ /* 150 */ "using_opt ::=",
+ /* 151 */ "orderby_opt ::=",
+ /* 152 */ "orderby_opt ::= ORDER BY sortlist",
+ /* 153 */ "sortlist ::= sortlist COMMA sortitem sortorder",
+ /* 154 */ "sortlist ::= sortitem sortorder",
+ /* 155 */ "sortitem ::= expr",
+ /* 156 */ "sortorder ::= ASC",
+ /* 157 */ "sortorder ::= DESC",
+ /* 158 */ "sortorder ::=",
+ /* 159 */ "groupby_opt ::=",
+ /* 160 */ "groupby_opt ::= GROUP BY nexprlist",
+ /* 161 */ "having_opt ::=",
+ /* 162 */ "having_opt ::= HAVING expr",
+ /* 163 */ "limit_opt ::=",
+ /* 164 */ "limit_opt ::= LIMIT expr",
+ /* 165 */ "limit_opt ::= LIMIT expr OFFSET expr",
+ /* 166 */ "limit_opt ::= LIMIT expr COMMA expr",
+ /* 167 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
+ /* 168 */ "where_opt ::=",
+ /* 169 */ "where_opt ::= WHERE expr",
+ /* 170 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
+ /* 171 */ "setlist ::= setlist COMMA nm EQ expr",
+ /* 172 */ "setlist ::= nm EQ expr",
+ /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP",
+ /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
+ /* 175 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
+ /* 176 */ "insert_cmd ::= INSERT orconf",
+ /* 177 */ "insert_cmd ::= REPLACE",
+ /* 178 */ "itemlist ::= itemlist COMMA expr",
+ /* 179 */ "itemlist ::= expr",
+ /* 180 */ "inscollist_opt ::=",
+ /* 181 */ "inscollist_opt ::= LP inscollist RP",
+ /* 182 */ "inscollist ::= inscollist COMMA nm",
+ /* 183 */ "inscollist ::= nm",
+ /* 184 */ "expr ::= term",
+ /* 185 */ "expr ::= LP expr RP",
+ /* 186 */ "term ::= NULL",
+ /* 187 */ "expr ::= id",
+ /* 188 */ "expr ::= JOIN_KW",
+ /* 189 */ "expr ::= nm DOT nm",
+ /* 190 */ "expr ::= nm DOT nm DOT nm",
+ /* 191 */ "term ::= INTEGER|FLOAT|BLOB",
+ /* 192 */ "term ::= STRING",
+ /* 193 */ "expr ::= REGISTER",
+ /* 194 */ "expr ::= VARIABLE",
+ /* 195 */ "expr ::= expr COLLATE ids",
+ /* 196 */ "expr ::= CAST LP expr AS typetoken RP",
+ /* 197 */ "expr ::= ID LP distinct exprlist RP",
+ /* 198 */ "expr ::= ID LP STAR RP",
+ /* 199 */ "term ::= CTIME_KW",
+ /* 200 */ "expr ::= expr AND expr",
+ /* 201 */ "expr ::= expr OR expr",
+ /* 202 */ "expr ::= expr LT|GT|GE|LE expr",
+ /* 203 */ "expr ::= expr EQ|NE expr",
+ /* 204 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
+ /* 205 */ "expr ::= expr PLUS|MINUS expr",
+ /* 206 */ "expr ::= expr STAR|SLASH|REM expr",
+ /* 207 */ "expr ::= expr CONCAT expr",
+ /* 208 */ "likeop ::= LIKE_KW",
+ /* 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",
 };
 #endif /* NDEBUG */
 
@@ -91426,14 +92153,13 @@ static int yy_find_shift_action(
   int i;
   int stateno = pParser->yystack[pParser->yyidx].stateno;
  
-  if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
+  if( stateno>YY_SHIFT_COUNT
+   || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
     return yy_default[stateno];
   }
   assert( iLookAhead!=YYNOCODE );
   i += iLookAhead;
-  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
-    /* The user of ";" instead of "\000" as a statement terminator in SQLite
-    ** means that we always have a look-ahead token. */
+  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
     if( iLookAhead>0 ){
 #ifdef YYFALLBACK
       YYCODETYPE iFallback;            /* Fallback token */
@@ -91451,7 +92177,15 @@ static int yy_find_shift_action(
 #ifdef YYWILDCARD
       {
         int j = i - iLookAhead + YYWILDCARD;
-        if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
+        if( 
+#if YY_SHIFT_MIN+YYWILDCARD<0
+          j>=0 &&
+#endif
+#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
+          j<YY_ACTTAB_COUNT &&
+#endif
+          yy_lookahead[j]==YYWILDCARD
+        ){
 #ifndef NDEBUG
           if( yyTraceFILE ){
             fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
@@ -91483,22 +92217,22 @@ static int yy_find_reduce_action(
 ){
   int i;
 #ifdef YYERRORSYMBOL
-  if( stateno>YY_REDUCE_MAX ){
+  if( stateno>YY_REDUCE_COUNT ){
     return yy_default[stateno];
   }
 #else
-  assert( stateno<=YY_REDUCE_MAX );
+  assert( stateno<=YY_REDUCE_COUNT );
 #endif
   i = yy_reduce_ofst[stateno];
   assert( i!=YY_REDUCE_USE_DFLT );
   assert( iLookAhead!=YYNOCODE );
   i += iLookAhead;
 #ifdef YYERRORSYMBOL
-  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
+  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
     return yy_default[stateno];
   }
 #else
-  assert( i>=0 && i<YY_SZ_ACTTAB );
+  assert( i>=0 && i<YY_ACTTAB_COUNT );
   assert( yy_lookahead[i]==iLookAhead );
 #endif
   return yy_action[i];
@@ -91655,6 +92389,7 @@ static const struct {
   { 182, 2 },
   { 182, 3 },
   { 182, 3 },
+  { 182, 3 },
   { 183, 2 },
   { 183, 2 },
   { 183, 1 },
@@ -91982,8 +92717,8 @@ static void yy_reduce(
       case 14: /* transtype ::= DEFERRED */
       case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
       case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
-      case 114: /* multiselect_op ::= UNION */ yytestcase(yyruleno==114);
-      case 116: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==116);
+      case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115);
+      case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117);
 {yygotominor.yy328 = yymsp[0].major;}
         break;
       case 17: /* cmd ::= COMMIT trans_opt */
@@ -92022,25 +92757,25 @@ static void yy_reduce(
       case 28: /* ifnotexists ::= */
       case 31: /* temp ::= */ yytestcase(yyruleno==31);
       case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
-      case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==82);
-      case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84);
-      case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86);
-      case 97: /* defer_subclause_opt ::= */ yytestcase(yyruleno==97);
-      case 108: /* ifexists ::= */ yytestcase(yyruleno==108);
-      case 119: /* distinct ::= ALL */ yytestcase(yyruleno==119);
-      case 120: /* distinct ::= */ yytestcase(yyruleno==120);
-      case 222: /* between_op ::= BETWEEN */ yytestcase(yyruleno==222);
-      case 225: /* in_op ::= IN */ yytestcase(yyruleno==225);
+      case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
+      case 85: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==85);
+      case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==87);
+      case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98);
+      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;}
         break;
       case 29: /* ifnotexists ::= IF NOT EXISTS */
       case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
       case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71);
-      case 85: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==85);
-      case 107: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==107);
-      case 118: /* distinct ::= DISTINCT */ yytestcase(yyruleno==118);
-      case 223: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==223);
-      case 226: /* in_op ::= NOT IN */ yytestcase(yyruleno==226);
+      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;}
         break;
       case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
@@ -92074,20 +92809,20 @@ static void yy_reduce(
       case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);
       case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);
       case 49: /* typename ::= ids */ yytestcase(yyruleno==49);
-      case 126: /* as ::= AS nm */ yytestcase(yyruleno==126);
-      case 127: /* as ::= ids */ yytestcase(yyruleno==127);
-      case 137: /* dbnm ::= DOT nm */ yytestcase(yyruleno==137);
-      case 146: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==146);
-      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);
+      case 127: /* as ::= AS nm */ yytestcase(yyruleno==127);
+      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);
 {yygotominor.yy0 = yymsp[0].minor.yy0;}
         break;
       case 45: /* type ::= typetoken */
@@ -92153,103 +92888,104 @@ static void yy_reduce(
 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
         break;
       case 72: /* refargs ::= */
-{ yygotominor.yy328 = OE_None * 0x000101; }
+{ yygotominor.yy328 = 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; }
         break;
       case 74: /* refarg ::= MATCH nm */
+      case 75: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==75);
 { yygotominor.yy429.value = 0;     yygotominor.yy429.mask = 0x000000; }
         break;
-      case 75: /* refarg ::= ON DELETE refact */
+      case 76: /* refarg ::= ON DELETE refact */
 { yygotominor.yy429.value = yymsp[0].minor.yy328;     yygotominor.yy429.mask = 0x0000ff; }
         break;
-      case 76: /* refarg ::= ON UPDATE refact */
+      case 77: /* refarg ::= ON UPDATE refact */
 { yygotominor.yy429.value = yymsp[0].minor.yy328<<8;  yygotominor.yy429.mask = 0x00ff00; }
         break;
-      case 77: /* refact ::= SET NULL */
-{ yygotominor.yy328 = OE_SetNull; }
+      case 78: /* refact ::= SET NULL */
+{ yygotominor.yy328 = OE_SetNull;  /* EV: R-33326-45252 */}
         break;
-      case 78: /* refact ::= SET DEFAULT */
-{ yygotominor.yy328 = OE_SetDflt; }
+      case 79: /* refact ::= SET DEFAULT */
+{ yygotominor.yy328 = OE_SetDflt;  /* EV: R-33326-45252 */}
         break;
-      case 79: /* refact ::= CASCADE */
-{ yygotominor.yy328 = OE_Cascade; }
+      case 80: /* refact ::= CASCADE */
+{ yygotominor.yy328 = OE_Cascade;  /* EV: R-33326-45252 */}
         break;
-      case 80: /* refact ::= RESTRICT */
-{ yygotominor.yy328 = OE_Restrict; }
+      case 81: /* refact ::= RESTRICT */
+{ yygotominor.yy328 = OE_Restrict; /* EV: R-33326-45252 */}
         break;
-      case 81: /* refact ::= NO ACTION */
-{ yygotominor.yy328 = OE_None; }
+      case 82: /* refact ::= NO ACTION */
+{ yygotominor.yy328 = OE_None;     /* EV: R-33326-45252 */}
         break;
-      case 83: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
-      case 98: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==98);
-      case 100: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==100);
-      case 103: /* resolvetype ::= raisetype */ yytestcase(yyruleno==103);
+      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;}
         break;
-      case 87: /* conslist_opt ::= */
+      case 88: /* conslist_opt ::= */
 {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
         break;
-      case 88: /* conslist_opt ::= COMMA conslist */
+      case 89: /* conslist_opt ::= COMMA conslist */
 {yygotominor.yy0 = yymsp[-1].minor.yy0;}
         break;
-      case 93: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
+      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);}
         break;
-      case 94: /* tcons ::= UNIQUE LP idxlist RP onconf */
+      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);}
         break;
-      case 95: /* tcons ::= CHECK LP expr RP onconf */
+      case 96: /* tcons ::= CHECK LP expr RP onconf */
 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy346.pExpr);}
         break;
-      case 96: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
+      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);
 }
         break;
-      case 99: /* onconf ::= */
+      case 100: /* onconf ::= */
 {yygotominor.yy328 = OE_Default;}
         break;
-      case 101: /* orconf ::= */
+      case 102: /* orconf ::= */
 {yygotominor.yy186 = OE_Default;}
         break;
-      case 102: /* orconf ::= OR resolvetype */
+      case 103: /* orconf ::= OR resolvetype */
 {yygotominor.yy186 = (u8)yymsp[0].minor.yy328;}
         break;
-      case 104: /* resolvetype ::= IGNORE */
+      case 105: /* resolvetype ::= IGNORE */
 {yygotominor.yy328 = OE_Ignore;}
         break;
-      case 105: /* resolvetype ::= REPLACE */
+      case 106: /* resolvetype ::= REPLACE */
 {yygotominor.yy328 = OE_Replace;}
         break;
-      case 106: /* cmd ::= DROP TABLE ifexists fullname */
+      case 107: /* cmd ::= DROP TABLE ifexists fullname */
 {
   sqlite3DropTable(pParse, yymsp[0].minor.yy65, 0, yymsp[-1].minor.yy328);
 }
         break;
-      case 109: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
+      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);
 }
         break;
-      case 110: /* cmd ::= DROP VIEW ifexists fullname */
+      case 111: /* cmd ::= DROP VIEW ifexists fullname */
 {
   sqlite3DropTable(pParse, yymsp[0].minor.yy65, 1, yymsp[-1].minor.yy328);
 }
         break;
-      case 111: /* cmd ::= select */
+      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);
 }
         break;
-      case 112: /* select ::= oneselect */
+      case 113: /* select ::= oneselect */
 {yygotominor.yy3 = yymsp[0].minor.yy3;}
         break;
-      case 113: /* select ::= select multiselect_op oneselect */
+      case 114: /* select ::= select multiselect_op oneselect */
 {
   if( yymsp[0].minor.yy3 ){
     yymsp[0].minor.yy3->op = (u8)yymsp[-1].minor.yy328;
@@ -92260,39 +92996,39 @@ static void yy_reduce(
   yygotominor.yy3 = yymsp[0].minor.yy3;
 }
         break;
-      case 115: /* multiselect_op ::= UNION ALL */
+      case 116: /* multiselect_op ::= UNION ALL */
 {yygotominor.yy328 = TK_ALL;}
         break;
-      case 117: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
+      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);
 }
         break;
-      case 121: /* sclp ::= selcollist COMMA */
-      case 247: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==247);
+      case 122: /* sclp ::= selcollist COMMA */
+      case 248: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==248);
 {yygotominor.yy14 = yymsp[-1].minor.yy14;}
         break;
-      case 122: /* sclp ::= */
-      case 150: /* orderby_opt ::= */ yytestcase(yyruleno==150);
-      case 158: /* groupby_opt ::= */ yytestcase(yyruleno==158);
-      case 240: /* exprlist ::= */ yytestcase(yyruleno==240);
-      case 246: /* idxlist_opt ::= */ yytestcase(yyruleno==246);
+      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;}
         break;
-      case 123: /* selcollist ::= sclp expr as */
+      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);
 }
         break;
-      case 124: /* selcollist ::= sclp STAR */
+      case 125: /* selcollist ::= sclp STAR */
 {
   Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
   yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy14, p);
 }
         break;
-      case 125: /* selcollist ::= sclp nm DOT STAR */
+      case 126: /* selcollist ::= sclp nm DOT STAR */
 {
   Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
   Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
@@ -92300,39 +93036,39 @@ static void yy_reduce(
   yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, pDot);
 }
         break;
-      case 128: /* as ::= */
+      case 129: /* as ::= */
 {yygotominor.yy0.n = 0;}
         break;
-      case 129: /* from ::= */
+      case 130: /* from ::= */
 {yygotominor.yy65 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy65));}
         break;
-      case 130: /* from ::= FROM seltablist */
+      case 131: /* from ::= FROM seltablist */
 {
   yygotominor.yy65 = yymsp[0].minor.yy65;
   sqlite3SrcListShiftJoinType(yygotominor.yy65);
 }
         break;
-      case 131: /* stl_prefix ::= seltablist joinop */
+      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;
 }
         break;
-      case 132: /* stl_prefix ::= */
+      case 133: /* stl_prefix ::= */
 {yygotominor.yy65 = 0;}
         break;
-      case 133: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
+      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);
 }
         break;
-      case 134: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
+      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);
   }
         break;
-      case 135: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
+      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;
@@ -92344,158 +93080,158 @@ static void yy_reduce(
     }
   }
         break;
-      case 136: /* dbnm ::= */
-      case 145: /* indexed_opt ::= */ yytestcase(yyruleno==145);
+      case 137: /* dbnm ::= */
+      case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146);
 {yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
         break;
-      case 138: /* fullname ::= nm dbnm */
+      case 139: /* fullname ::= nm dbnm */
 {yygotominor.yy65 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
         break;
-      case 139: /* joinop ::= COMMA|JOIN */
+      case 140: /* joinop ::= COMMA|JOIN */
 { yygotominor.yy328 = JT_INNER; }
         break;
-      case 140: /* joinop ::= JOIN_KW JOIN */
+      case 141: /* joinop ::= JOIN_KW JOIN */
 { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
         break;
-      case 141: /* joinop ::= JOIN_KW nm JOIN */
+      case 142: /* joinop ::= JOIN_KW nm JOIN */
 { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
         break;
-      case 142: /* joinop ::= JOIN_KW nm nm JOIN */
+      case 143: /* joinop ::= JOIN_KW nm nm JOIN */
 { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
         break;
-      case 143: /* on_opt ::= ON expr */
-      case 154: /* sortitem ::= expr */ yytestcase(yyruleno==154);
-      case 161: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==161);
-      case 168: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==168);
-      case 235: /* case_else ::= ELSE expr */ yytestcase(yyruleno==235);
-      case 237: /* case_operand ::= expr */ yytestcase(yyruleno==237);
+      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;}
         break;
-      case 144: /* on_opt ::= */
-      case 160: /* having_opt ::= */ yytestcase(yyruleno==160);
-      case 167: /* where_opt ::= */ yytestcase(yyruleno==167);
-      case 236: /* case_else ::= */ yytestcase(yyruleno==236);
-      case 238: /* case_operand ::= */ yytestcase(yyruleno==238);
+      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;}
         break;
-      case 147: /* indexed_opt ::= NOT INDEXED */
+      case 148: /* indexed_opt ::= NOT INDEXED */
 {yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
         break;
-      case 148: /* using_opt ::= USING LP inscollist RP */
-      case 180: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==180);
+      case 149: /* using_opt ::= USING LP inscollist RP */
+      case 181: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==181);
 {yygotominor.yy408 = yymsp[-1].minor.yy408;}
         break;
-      case 149: /* using_opt ::= */
-      case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179);
+      case 150: /* using_opt ::= */
+      case 180: /* inscollist_opt ::= */ yytestcase(yyruleno==180);
 {yygotominor.yy408 = 0;}
         break;
-      case 151: /* orderby_opt ::= ORDER BY sortlist */
-      case 159: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==159);
-      case 239: /* exprlist ::= nexprlist */ yytestcase(yyruleno==239);
+      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;}
         break;
-      case 152: /* sortlist ::= sortlist COMMA sortitem sortorder */
+      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;
 }
         break;
-      case 153: /* sortlist ::= sortitem sortorder */
+      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;
 }
         break;
-      case 155: /* sortorder ::= ASC */
-      case 157: /* sortorder ::= */ yytestcase(yyruleno==157);
+      case 156: /* sortorder ::= ASC */
+      case 158: /* sortorder ::= */ yytestcase(yyruleno==158);
 {yygotominor.yy328 = SQLITE_SO_ASC;}
         break;
-      case 156: /* sortorder ::= DESC */
+      case 157: /* sortorder ::= DESC */
 {yygotominor.yy328 = SQLITE_SO_DESC;}
         break;
-      case 162: /* limit_opt ::= */
+      case 163: /* limit_opt ::= */
 {yygotominor.yy476.pLimit = 0; yygotominor.yy476.pOffset = 0;}
         break;
-      case 163: /* limit_opt ::= LIMIT expr */
+      case 164: /* limit_opt ::= LIMIT expr */
 {yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr; yygotominor.yy476.pOffset = 0;}
         break;
-      case 164: /* limit_opt ::= LIMIT expr OFFSET expr */
+      case 165: /* limit_opt ::= LIMIT expr OFFSET expr */
 {yygotominor.yy476.pLimit = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pOffset = yymsp[0].minor.yy346.pExpr;}
         break;
-      case 165: /* limit_opt ::= LIMIT expr COMMA expr */
+      case 166: /* limit_opt ::= LIMIT expr COMMA expr */
 {yygotominor.yy476.pOffset = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr;}
         break;
-      case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
+      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);
 }
         break;
-      case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
+      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);
 }
         break;
-      case 170: /* setlist ::= setlist COMMA nm EQ expr */
+      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);
 }
         break;
-      case 171: /* setlist ::= nm EQ expr */
+      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);
 }
         break;
-      case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */
+      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);}
         break;
-      case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
+      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);}
         break;
-      case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
+      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);}
         break;
-      case 175: /* insert_cmd ::= INSERT orconf */
+      case 176: /* insert_cmd ::= INSERT orconf */
 {yygotominor.yy186 = yymsp[0].minor.yy186;}
         break;
-      case 176: /* insert_cmd ::= REPLACE */
+      case 177: /* insert_cmd ::= REPLACE */
 {yygotominor.yy186 = OE_Replace;}
         break;
-      case 177: /* itemlist ::= itemlist COMMA expr */
-      case 241: /* nexprlist ::= nexprlist COMMA expr */ yytestcase(yyruleno==241);
+      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);}
         break;
-      case 178: /* itemlist ::= expr */
-      case 242: /* nexprlist ::= expr */ yytestcase(yyruleno==242);
+      case 179: /* itemlist ::= expr */
+      case 243: /* nexprlist ::= expr */ yytestcase(yyruleno==243);
 {yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy346.pExpr);}
         break;
-      case 181: /* inscollist ::= inscollist COMMA nm */
+      case 182: /* inscollist ::= inscollist COMMA nm */
 {yygotominor.yy408 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy408,&yymsp[0].minor.yy0);}
         break;
-      case 182: /* inscollist ::= nm */
+      case 183: /* inscollist ::= nm */
 {yygotominor.yy408 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
         break;
-      case 183: /* expr ::= term */
-      case 211: /* escape ::= ESCAPE expr */ yytestcase(yyruleno==211);
+      case 184: /* expr ::= term */
+      case 212: /* escape ::= ESCAPE expr */ yytestcase(yyruleno==212);
 {yygotominor.yy346 = yymsp[0].minor.yy346;}
         break;
-      case 184: /* expr ::= LP expr RP */
+      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);}
         break;
-      case 185: /* term ::= NULL */
-      case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190);
-      case 191: /* term ::= STRING */ yytestcase(yyruleno==191);
+      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);}
         break;
-      case 186: /* expr ::= id */
-      case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187);
+      case 187: /* expr ::= id */
+      case 188: /* expr ::= JOIN_KW */ yytestcase(yyruleno==188);
 {spanExpr(&yygotominor.yy346, pParse, TK_ID, &yymsp[0].minor.yy0);}
         break;
-      case 188: /* expr ::= nm DOT nm */
+      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);
@@ -92503,7 +93239,7 @@ static void yy_reduce(
   spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
 }
         break;
-      case 189: /* expr ::= nm DOT nm DOT nm */
+      case 190: /* expr ::= nm DOT nm DOT nm */
 {
   Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
   Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
@@ -92513,7 +93249,7 @@ static void yy_reduce(
   spanSet(&yygotominor.yy346,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
 }
         break;
-      case 192: /* expr ::= REGISTER */
+      case 193: /* expr ::= REGISTER */
 {
   /* When doing a nested parse, one can include terms in an expression
   ** that look like this:   #1 #2 ...  These terms refer to registers
@@ -92528,27 +93264,27 @@ static void yy_reduce(
   spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
 }
         break;
-      case 193: /* expr ::= VARIABLE */
+      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);
 }
         break;
-      case 194: /* expr ::= expr COLLATE ids */
+      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];
 }
         break;
-      case 195: /* expr ::= CAST LP expr AS typetoken RP */
+      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);
 }
         break;
-      case 196: /* expr ::= ID LP distinct exprlist RP */
+      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] ){
     sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
@@ -92560,13 +93296,13 @@ static void yy_reduce(
   }
 }
         break;
-      case 197: /* expr ::= ID LP STAR RP */
+      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);
 }
         break;
-      case 198: /* term ::= CTIME_KW */
+      case 199: /* term ::= CTIME_KW */
 {
   /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
   ** treated as functions that return constants */
@@ -92577,28 +93313,28 @@ static void yy_reduce(
   spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
 }
         break;
-      case 199: /* expr ::= expr AND expr */
-      case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200);
-      case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201);
-      case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202);
-      case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203);
-      case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204);
-      case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205);
-      case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206);
+      case 200: /* expr ::= expr AND expr */
+      case 201: /* expr ::= expr OR expr */ yytestcase(yyruleno==201);
+      case 202: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==202);
+      case 203: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==203);
+      case 204: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==204);
+      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);}
         break;
-      case 207: /* likeop ::= LIKE_KW */
-      case 209: /* likeop ::= MATCH */ yytestcase(yyruleno==209);
+      case 208: /* likeop ::= LIKE_KW */
+      case 210: /* likeop ::= MATCH */ yytestcase(yyruleno==210);
 {yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 0;}
         break;
-      case 208: /* likeop ::= NOT LIKE_KW */
-      case 210: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==210);
+      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;}
         break;
-      case 212: /* escape ::= */
+      case 213: /* escape ::= */
 {memset(&yygotominor.yy346,0,sizeof(yygotominor.yy346));}
         break;
-      case 213: /* expr ::= expr likeop expr escape */
+      case 214: /* expr ::= expr likeop expr escape */
 {
   ExprList *pList;
   pList = sqlite3ExprListAppend(pParse,0, yymsp[-1].minor.yy346.pExpr);
@@ -92613,39 +93349,35 @@ static void yy_reduce(
   if( yygotominor.yy346.pExpr ) yygotominor.yy346.pExpr->flags |= EP_InfixFunc;
 }
         break;
-      case 214: /* expr ::= expr ISNULL|NOTNULL */
+      case 215: /* expr ::= expr ISNULL|NOTNULL */
 {spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);}
         break;
-      case 215: /* expr ::= expr NOT NULL */
+      case 216: /* expr ::= expr NOT NULL */
 {spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
         break;
-      case 216: /* expr ::= expr IS expr */
+      case 217: /* expr ::= expr IS expr */
 {
   spanBinaryExpr(&yygotominor.yy346,pParse,TK_IS,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);
-  if( pParse->db->mallocFailed==0  && yymsp[0].minor.yy346.pExpr->op==TK_NULL ){
-    yygotominor.yy346.pExpr->op = TK_ISNULL;
-  }
+  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_ISNULL);
 }
         break;
-      case 217: /* expr ::= expr IS NOT expr */
+      case 218: /* expr ::= expr IS NOT expr */
 {
   spanBinaryExpr(&yygotominor.yy346,pParse,TK_ISNOT,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy346);
-  if( pParse->db->mallocFailed==0  && yymsp[0].minor.yy346.pExpr->op==TK_NULL ){
-    yygotominor.yy346.pExpr->op = TK_NOTNULL;
-  }
+  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_NOTNULL);
 }
         break;
-      case 218: /* expr ::= NOT expr */
-      case 219: /* expr ::= BITNOT expr */ yytestcase(yyruleno==219);
+      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);}
         break;
-      case 220: /* expr ::= MINUS expr */
+      case 221: /* expr ::= MINUS expr */
 {spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UMINUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
         break;
-      case 221: /* expr ::= PLUS expr */
+      case 222: /* expr ::= PLUS expr */
 {spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UPLUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
         break;
-      case 224: /* expr ::= expr between_op expr AND expr */
+      case 225: /* 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);
@@ -92660,7 +93392,7 @@ static void yy_reduce(
   yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd;
 }
         break;
-      case 227: /* expr ::= expr in_op LP exprlist RP */
+      case 228: /* 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 ){
@@ -92674,7 +93406,7 @@ static void yy_reduce(
     yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
   }
         break;
-      case 228: /* expr ::= LP select RP */
+      case 229: /* expr ::= LP select RP */
 {
     yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
     if( yygotominor.yy346.pExpr ){
@@ -92688,7 +93420,7 @@ static void yy_reduce(
     yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
   }
         break;
-      case 229: /* expr ::= expr in_op LP select RP */
+      case 230: /* 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 ){
@@ -92703,7 +93435,7 @@ static void yy_reduce(
     yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
   }
         break;
-      case 230: /* expr ::= expr in_op nm dbnm */
+      case 231: /* 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);
@@ -92719,7 +93451,7 @@ static void yy_reduce(
     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];
   }
         break;
-      case 231: /* expr ::= EXISTS LP select RP */
+      case 232: /* expr ::= EXISTS LP select RP */
 {
     Expr *p = yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
     if( p ){
@@ -92733,7 +93465,7 @@ static void yy_reduce(
     yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
   }
         break;
-      case 232: /* expr ::= CASE case_operand case_exprlist case_else END */
+      case 233: /* 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 ){
@@ -92746,33 +93478,33 @@ static void yy_reduce(
   yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
 }
         break;
-      case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
+      case 234: /* 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);
 }
         break;
-      case 234: /* case_exprlist ::= WHEN expr THEN expr */
+      case 235: /* 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);
 }
         break;
-      case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
+      case 244: /* 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);
 }
         break;
-      case 244: /* uniqueflag ::= UNIQUE */
-      case 298: /* raisetype ::= ABORT */ yytestcase(yyruleno==298);
+      case 245: /* uniqueflag ::= UNIQUE */
+      case 299: /* raisetype ::= ABORT */ yytestcase(yyruleno==299);
 {yygotominor.yy328 = OE_Abort;}
         break;
-      case 245: /* uniqueflag ::= */
+      case 246: /* uniqueflag ::= */
 {yygotominor.yy328 = OE_None;}
         break;
-      case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */
+      case 249: /* idxlist ::= idxlist COMMA nm collate sortorder */
 {
   Expr *p = 0;
   if( yymsp[-1].minor.yy0.n>0 ){
@@ -92785,7 +93517,7 @@ static void yy_reduce(
   if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
 }
         break;
-      case 249: /* idxlist ::= nm collate sortorder */
+      case 250: /* idxlist ::= nm collate sortorder */
 {
   Expr *p = 0;
   if( yymsp[-1].minor.yy0.n>0 ){
@@ -92798,32 +93530,32 @@ static void yy_reduce(
   if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
 }
         break;
-      case 250: /* collate ::= */
+      case 251: /* collate ::= */
 {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
         break;
-      case 252: /* cmd ::= DROP INDEX ifexists fullname */
+      case 253: /* cmd ::= DROP INDEX ifexists fullname */
 {sqlite3DropIndex(pParse, yymsp[0].minor.yy65, yymsp[-1].minor.yy328);}
         break;
-      case 253: /* cmd ::= VACUUM */
-      case 254: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==254);
+      case 254: /* cmd ::= VACUUM */
+      case 255: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==255);
 {sqlite3Vacuum(pParse);}
         break;
-      case 255: /* cmd ::= PRAGMA nm dbnm */
+      case 256: /* cmd ::= PRAGMA nm dbnm */
 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
         break;
-      case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
+      case 257: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
         break;
-      case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
+      case 258: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
         break;
-      case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
+      case 259: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
         break;
-      case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
+      case 260: /* 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 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+      case 271: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
 {
   Token all;
   all.z = yymsp[-3].minor.yy0.z;
@@ -92831,38 +93563,38 @@ static void yy_reduce(
   sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy473, &all);
 }
         break;
-      case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+      case 272: /* 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);
   yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
 }
         break;
-      case 272: /* trigger_time ::= BEFORE */
-      case 275: /* trigger_time ::= */ yytestcase(yyruleno==275);
+      case 273: /* trigger_time ::= BEFORE */
+      case 276: /* trigger_time ::= */ yytestcase(yyruleno==276);
 { yygotominor.yy328 = TK_BEFORE; }
         break;
-      case 273: /* trigger_time ::= AFTER */
+      case 274: /* trigger_time ::= AFTER */
 { yygotominor.yy328 = TK_AFTER;  }
         break;
-      case 274: /* trigger_time ::= INSTEAD OF */
+      case 275: /* trigger_time ::= INSTEAD OF */
 { yygotominor.yy328 = TK_INSTEAD;}
         break;
-      case 276: /* trigger_event ::= DELETE|INSERT */
-      case 277: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==277);
+      case 277: /* trigger_event ::= DELETE|INSERT */
+      case 278: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==278);
 {yygotominor.yy378.a = yymsp[0].major; yygotominor.yy378.b = 0;}
         break;
-      case 278: /* trigger_event ::= UPDATE OF inscollist */
+      case 279: /* trigger_event ::= UPDATE OF inscollist */
 {yygotominor.yy378.a = TK_UPDATE; yygotominor.yy378.b = yymsp[0].minor.yy408;}
         break;
-      case 281: /* when_clause ::= */
-      case 303: /* key_opt ::= */ yytestcase(yyruleno==303);
+      case 282: /* when_clause ::= */
+      case 304: /* key_opt ::= */ yytestcase(yyruleno==304);
 { yygotominor.yy132 = 0; }
         break;
-      case 282: /* when_clause ::= WHEN expr */
-      case 304: /* key_opt ::= KEY expr */ yytestcase(yyruleno==304);
+      case 283: /* when_clause ::= WHEN expr */
+      case 305: /* key_opt ::= KEY expr */ yytestcase(yyruleno==305);
 { yygotominor.yy132 = yymsp[0].minor.yy346.pExpr; }
         break;
-      case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+      case 284: /* 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;
@@ -92870,14 +93602,14 @@ static void yy_reduce(
   yygotominor.yy473 = yymsp[-2].minor.yy473;
 }
         break;
-      case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */
+      case 285: /* 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;
 }
         break;
-      case 286: /* trnm ::= nm DOT nm */
+      case 287: /* trnm ::= nm DOT nm */
 {
   yygotominor.yy0 = yymsp[0].minor.yy0;
   sqlite3ErrorMsg(pParse, 
@@ -92885,36 +93617,36 @@ static void yy_reduce(
         "statements within triggers");
 }
         break;
-      case 288: /* tridxby ::= INDEXED BY nm */
+      case 289: /* tridxby ::= INDEXED BY nm */
 {
   sqlite3ErrorMsg(pParse,
         "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
         "within triggers");
 }
         break;
-      case 289: /* tridxby ::= NOT INDEXED */
+      case 290: /* tridxby ::= NOT INDEXED */
 {
   sqlite3ErrorMsg(pParse,
         "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
         "within triggers");
 }
         break;
-      case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
+      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); }
         break;
-      case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */
+      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);}
         break;
-      case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
+      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);}
         break;
-      case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
+      case 294: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
 {yygotominor.yy473 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy132);}
         break;
-      case 294: /* trigger_cmd ::= select */
+      case 295: /* trigger_cmd ::= select */
 {yygotominor.yy473 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy3); }
         break;
-      case 295: /* expr ::= RAISE LP IGNORE RP */
+      case 296: /* expr ::= RAISE LP IGNORE RP */
 {
   yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); 
   if( yygotominor.yy346.pExpr ){
@@ -92924,7 +93656,7 @@ static void yy_reduce(
   yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
 }
         break;
-      case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */
+      case 297: /* expr ::= RAISE LP raisetype COMMA nm RP */
 {
   yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); 
   if( yygotominor.yy346.pExpr ) {
@@ -92934,72 +93666,72 @@ static void yy_reduce(
   yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
 }
         break;
-      case 297: /* raisetype ::= ROLLBACK */
+      case 298: /* raisetype ::= ROLLBACK */
 {yygotominor.yy328 = OE_Rollback;}
         break;
-      case 299: /* raisetype ::= FAIL */
+      case 300: /* raisetype ::= FAIL */
 {yygotominor.yy328 = OE_Fail;}
         break;
-      case 300: /* cmd ::= DROP TRIGGER ifexists fullname */
+      case 301: /* cmd ::= DROP TRIGGER ifexists fullname */
 {
   sqlite3DropTrigger(pParse,yymsp[0].minor.yy65,yymsp[-1].minor.yy328);
 }
         break;
-      case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+      case 302: /* 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);
 }
         break;
-      case 302: /* cmd ::= DETACH database_kw_opt expr */
+      case 303: /* cmd ::= DETACH database_kw_opt expr */
 {
   sqlite3Detach(pParse, yymsp[0].minor.yy346.pExpr);
 }
         break;
-      case 307: /* cmd ::= REINDEX */
+      case 308: /* cmd ::= REINDEX */
 {sqlite3Reindex(pParse, 0, 0);}
         break;
-      case 308: /* cmd ::= REINDEX nm dbnm */
+      case 309: /* cmd ::= REINDEX nm dbnm */
 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
         break;
-      case 309: /* cmd ::= ANALYZE */
+      case 310: /* cmd ::= ANALYZE */
 {sqlite3Analyze(pParse, 0, 0);}
         break;
-      case 310: /* cmd ::= ANALYZE nm dbnm */
+      case 311: /* cmd ::= ANALYZE nm dbnm */
 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
         break;
-      case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
+      case 312: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
 {
   sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy65,&yymsp[0].minor.yy0);
 }
         break;
-      case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
+      case 313: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
 {
   sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
 }
         break;
-      case 313: /* add_column_fullname ::= fullname */
+      case 314: /* add_column_fullname ::= fullname */
 {
   pParse->db->lookaside.bEnabled = 0;
   sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy65);
 }
         break;
-      case 316: /* cmd ::= create_vtab */
+      case 317: /* cmd ::= create_vtab */
 {sqlite3VtabFinishParse(pParse,0);}
         break;
-      case 317: /* cmd ::= create_vtab LP vtabarglist RP */
+      case 318: /* cmd ::= create_vtab LP vtabarglist RP */
 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
         break;
-      case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
+      case 319: /* 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 321: /* vtabarg ::= */
+      case 322: /* vtabarg ::= */
 {sqlite3VtabArgInit(pParse);}
         break;
-      case 323: /* vtabargtoken ::= ANY */
-      case 324: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==324);
-      case 325: /* lp ::= LP */ yytestcase(yyruleno==325);
+      case 324: /* vtabargtoken ::= ANY */
+      case 325: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==325);
+      case 326: /* lp ::= LP */ yytestcase(yyruleno==326);
 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
         break;
       default:
@@ -93024,25 +93756,25 @@ static void yy_reduce(
       /* (55) carg ::= CONSTRAINT nm ccons */ yytestcase(yyruleno==55);
       /* (56) carg ::= ccons */ yytestcase(yyruleno==56);
       /* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62);
-      /* (89) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==89);
-      /* (90) conslist ::= conslist tcons */ yytestcase(yyruleno==90);
-      /* (91) conslist ::= tcons */ yytestcase(yyruleno==91);
-      /* (92) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==92);
-      /* (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);
+      /* (90) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==90);
+      /* (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);
         break;
   };
   yygoto = yyRuleInfo[yyruleno].lhs;
@@ -93316,8 +94048,6 @@ SQLITE_PRIVATE void sqlite3Parser(
 ** This file contains C code that splits an SQL input string up into
 ** individual tokens and sends those tokens one-by-one over to the
 ** parser for analysis.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /*
@@ -93370,7 +94100,7 @@ const unsigned char ebcdicToAscii[] = {
 **
 ** The code in this file has been automatically generated by
 **
-**     $Header: /home/drh/sqlite/trans/cvs/sqlite/sqlite/tool/mkkeywordhash.c,v 1.38 2009/06/09 14:27:41 drh Exp $
+**   sqlite/tool/mkkeywordhash.c
 **
 ** The code in this file implements a function that determines whether
 ** or not a given identifier is really an SQL keyword.  The same thing
@@ -93425,23 +94155,23 @@ static int keywordCode(const char *z, int n){
     'A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y',
   };
   static const unsigned char aHash[127] = {
-      72, 101, 114,  70,   0,  44,   0,   0,  78,   0,  73,   0,   0,
+      72, 101, 114,  70,   0,  45,   0,   0,  78,   0,  73,   0,   0,
       42,  12,  74,  15,   0, 113,  81,  50, 108,   0,  19,   0,   0,
      118,   0, 116, 111,   0,  22,  89,   0,   9,   0,   0,  66,  67,
-       0,  65,   6,   0,  48,  86,  98,   0, 115,  97,   0,   0,  45,
+       0,  65,   6,   0,  48,  86,  98,   0, 115,  97,   0,   0,  44,
        0,  99,  24,   0,  17,   0, 119,  49,  23,   0,   5, 106,  25,
       92,   0,   0, 121, 102,  56, 120,  53,  28,  51,   0,  87,   0,
       96,  26,   0,  95,   0,   0,   0,  91,  88,  93,  84, 105,  14,
       39, 104,   0,  77,   0,  18,  85, 107,  32,   0, 117,  76, 109,
-      59,  46,  80,   0,   0,  90,  40,   0, 112,   0,  36,   0,   0,
-      29,   0,  82,  58,  60,   0,  20,  57,   0,  52,
+      58,  46,  80,   0,   0,  90,  40,   0, 112,   0,  36,   0,   0,
+      29,   0,  82,  59,  60,   0,  20,  57,   0,  52,
   };
   static const unsigned char aNext[121] = {
        0,   0,   0,   0,   4,   0,   0,   0,   0,   0,   0,   0,   0,
        0,   2,   0,   0,   0,   0,   0,   0,  13,   0,   0,   0,   0,
        0,   7,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-       0,   0,   0,   0,   0,  33,  21,   0,   0,   0,  43,   3,  47,
-       0,   0,   0,   0,  30,  54,   0,   0,  38,   0,   0,   0,   1,
+       0,   0,   0,   0,  33,   0,  21,   0,   0,   0,  43,   3,  47,
+       0,   0,   0,   0,  30,   0,  54,   0,  38,   0,   0,   0,   1,
       62,   0,   0,  63,   0,  41,   0,   0,   0,   0,   0,   0,   0,
       61,   0,   0,   0,   0,  31,  55,  16,  34,  10,   0,   0,   0,
        0,   0,   0,   0,  11,  68,  75,   0,   8,   0, 100,  94,   0,
@@ -93452,8 +94182,8 @@ static int keywordCode(const char *z, int n){
        7,   7,   5,   4,   6,   4,   5,   3,   6,   7,   3,   6,   6,
        7,   7,   3,   8,   2,   6,   5,   4,   4,   3,  10,   4,   6,
       11,   6,   2,   7,   5,   5,   9,   6,   9,   9,   7,  10,  10,
-       4,   6,   2,   3,   4,   9,   2,   6,   5,   6,   6,   5,   6,
-       5,   5,   7,   7,   7,   2,   3,   4,   4,   7,   3,   6,   4,
+       4,   6,   2,   3,   9,   4,   2,   6,   5,   6,   6,   5,   6,
+       5,   5,   7,   7,   7,   3,   2,   4,   4,   7,   3,   6,   4,
        7,   6,  12,   6,   9,   4,   6,   5,   4,   7,   6,   5,   6,
        7,   5,   4,   5,   6,   5,   7,   3,   7,  13,   2,   2,   4,
        6,   6,   8,   5,  17,  12,   7,   8,   8,   2,   4,   4,   4,
@@ -93484,7 +94214,7 @@ static int keywordCode(const char *z, int n){
     TK_OFFSET,     TK_OF,         TK_SET,        TK_TEMP,       TK_TEMP,       
     TK_OR,         TK_UNIQUE,     TK_QUERY,      TK_ATTACH,     TK_HAVING,     
     TK_GROUP,      TK_UPDATE,     TK_BEGIN,      TK_JOIN_KW,    TK_RELEASE,    
-    TK_BETWEEN,    TK_NOTNULL,    TK_NO,         TK_NOT,        TK_NULL,       
+    TK_BETWEEN,    TK_NOTNULL,    TK_NOT,        TK_NO,         TK_NULL,       
     TK_LIKE_KW,    TK_CASCADE,    TK_ASC,        TK_DELETE,     TK_CASE,       
     TK_COLLATE,    TK_CREATE,     TK_CTIME_KW,   TK_DETACH,     TK_IMMEDIATE,  
     TK_JOIN,       TK_INSERT,     TK_MATCH,      TK_PLAN,       TK_ANALYZE,    
@@ -93549,8 +94279,8 @@ static int keywordCode(const char *z, int n){
       testcase( i==40 ); /* OFFSET */
       testcase( i==41 ); /* OF */
       testcase( i==42 ); /* SET */
-      testcase( i==43 ); /* TEMP */
-      testcase( i==44 ); /* TEMPORARY */
+      testcase( i==43 ); /* TEMPORARY */
+      testcase( i==44 ); /* TEMP */
       testcase( i==45 ); /* OR */
       testcase( i==46 ); /* UNIQUE */
       testcase( i==47 ); /* QUERY */
@@ -93563,8 +94293,8 @@ static int keywordCode(const char *z, int n){
       testcase( i==54 ); /* RELEASE */
       testcase( i==55 ); /* BETWEEN */
       testcase( i==56 ); /* NOTNULL */
-      testcase( i==57 ); /* NO */
-      testcase( i==58 ); /* NOT */
+      testcase( i==57 ); /* NOT */
+      testcase( i==58 ); /* NO */
       testcase( i==59 ); /* NULL */
       testcase( i==60 ); /* LIKE */
       testcase( i==61 ); /* CASCADE */
@@ -93635,6 +94365,7 @@ static int keywordCode(const char *z, int n){
 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
   return keywordCode((char*)z, n);
 }
+#define SQLITE_N_KEYWORD 121
 
 /************** End of keywordhash.h *****************************************/
 /************** Continuing where we left off in tokenize.c *******************/
@@ -93657,16 +94388,7 @@ SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
 ** But the feature is undocumented.
 */
 #ifdef SQLITE_ASCII
-SQLITE_PRIVATE const char sqlite3IsAsciiIdChar[] = {
-/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */
-    0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */
-    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */
-    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */
-};
-#define IdChar(C)  (((c=C)&0x80)!=0 || (c>0x1f && sqlite3IsAsciiIdChar[c-0x20]))
+#define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)
 #endif
 #ifdef SQLITE_EBCDIC
 SQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[] = {
@@ -93707,8 +94429,9 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
     }
     case '-': {
       if( z[1]=='-' ){
+        /* IMP: R-15891-05542 -- syntax diagram for comments */
         for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
-        *tokenType = TK_SPACE;
+        *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */
         return i;
       }
       *tokenType = TK_MINUS;
@@ -93739,9 +94462,10 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
         *tokenType = TK_SLASH;
         return 1;
       }
+      /* IMP: R-15891-05542 -- syntax diagram for comments */
       for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
       if( c ) i++;
-      *tokenType = TK_SPACE;
+      *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */
       return i;
     }
     case '%': {
@@ -94126,8 +94850,6 @@ abort_parse:
 ** This code used to be part of the tokenizer.c source file.  But by
 ** separating it out, the code will be automatically omitted from
 ** static links that do not use it.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 #ifndef SQLITE_OMIT_COMPLETE
 
@@ -94136,8 +94858,7 @@ abort_parse:
 */
 #ifndef SQLITE_AMALGAMATION
 #ifdef SQLITE_ASCII
-SQLITE_PRIVATE const char sqlite3IsAsciiIdChar[];
-#define IdChar(C)  (((c=C)&0x80)!=0 || (c>0x1f && sqlite3IsAsciiIdChar[c-0x20]))
+#define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)
 #endif
 #ifdef SQLITE_EBCDIC
 SQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[];
@@ -94153,11 +94874,13 @@ SQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[];
 #define tkSEMI    0
 #define tkWS      1
 #define tkOTHER   2
+#ifndef SQLITE_OMIT_TRIGGER
 #define tkEXPLAIN 3
 #define tkCREATE  4
 #define tkTEMP    5
 #define tkTRIGGER 6
 #define tkEND     7
+#endif
 
 /*
 ** Return TRUE if the given SQL string ends in a semicolon.
@@ -94166,36 +94889,38 @@ SQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[];
 ** Whenever the CREATE TRIGGER keywords are seen, the statement
 ** must end with ";END;".
 **
-** This implementation uses a state machine with 7 states:
+** This implementation uses a state machine with 8 states:
+**
+**   (0) INVALID   We have not yet seen a non-whitespace character.
 **
-**   (0) START     At the beginning or end of an SQL statement.  This routine
+**   (1) START     At the beginning or end of an SQL statement.  This routine
 **                 returns 1 if it ends in the START state and 0 if it ends
 **                 in any other state.
 **
-**   (1) NORMAL    We are in the middle of statement which ends with a single
+**   (2) NORMAL    We are in the middle of statement which ends with a single
 **                 semicolon.
 **
-**   (2) EXPLAIN   The keyword EXPLAIN has been seen at the beginning of 
+**   (3) EXPLAIN   The keyword EXPLAIN has been seen at the beginning of 
 **                 a statement.
 **
-**   (3) CREATE    The keyword CREATE has been seen at the beginning of a
+**   (4) CREATE    The keyword CREATE has been seen at the beginning of a
 **                 statement, possibly preceeded by EXPLAIN and/or followed by
 **                 TEMP or TEMPORARY
 **
-**   (4) TRIGGER   We are in the middle of a trigger definition that must be
+**   (5) TRIGGER   We are in the middle of a trigger definition that must be
 **                 ended by a semicolon, the keyword END, and another semicolon.
 **
-**   (5) SEMI      We've seen the first semicolon in the ";END;" that occurs at
+**   (6) SEMI      We've seen the first semicolon in the ";END;" that occurs at
 **                 the end of a trigger definition.
 **
-**   (6) END       We've seen the ";END" of the ";END;" that occurs at the end
+**   (7) END       We've seen the ";END" of the ";END;" that occurs at the end
 **                 of a trigger difinition.
 **
 ** Transitions between states above are determined by tokens extracted
 ** from the input.  The following tokens are significant:
 **
 **   (0) tkSEMI      A semicolon.
-**   (1) tkWS        Whitespace
+**   (1) tkWS        Whitespace.
 **   (2) tkOTHER     Any other SQL token.
 **   (3) tkEXPLAIN   The "explain" keyword.
 **   (4) tkCREATE    The "create" keyword.
@@ -94204,6 +94929,7 @@ SQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[];
 **   (7) tkEND       The "end" keyword.
 **
 ** Whitespace never causes a state transition and is always ignored.
+** This means that a SQL string of all whitespace is invalid.
 **
 ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
 ** to recognize the end of a trigger can be omitted.  All we have to do
@@ -94217,26 +94943,28 @@ SQLITE_API int sqlite3_complete(const char *zSql){
   /* A complex statement machine used to detect the end of a CREATE TRIGGER
   ** statement.  This is the normal case.
   */
-  static const u8 trans[7][8] = {
+  static const u8 trans[8][8] = {
                      /* Token:                                                */
-     /* State:       **  SEMI  WS  OTHER EXPLAIN  CREATE  TEMP  TRIGGER  END  */
-     /* 0   START: */ {    0,  0,     1,      2,      3,    1,       1,   1,  },
-     /* 1  NORMAL: */ {    0,  1,     1,      1,      1,    1,       1,   1,  },
-     /* 2 EXPLAIN: */ {    0,  2,     2,      1,      3,    1,       1,   1,  },
-     /* 3  CREATE: */ {    0,  3,     1,      1,      1,    3,       4,   1,  },
-     /* 4 TRIGGER: */ {    5,  4,     4,      4,      4,    4,       4,   4,  },
-     /* 5    SEMI: */ {    5,  5,     4,      4,      4,    4,       4,   6,  },
-     /* 6     END: */ {    0,  6,     4,      4,      4,    4,       4,   4,  },
+     /* State:       **  SEMI  WS  OTHER  EXPLAIN  CREATE  TEMP  TRIGGER  END */
+     /* 0 INVALID: */ {    1,  0,     2,       3,      4,    2,       2,   2, },
+     /* 1   START: */ {    1,  1,     2,       3,      4,    2,       2,   2, },
+     /* 2  NORMAL: */ {    1,  2,     2,       2,      2,    2,       2,   2, },
+     /* 3 EXPLAIN: */ {    1,  3,     3,       2,      4,    2,       2,   2, },
+     /* 4  CREATE: */ {    1,  4,     2,       2,      2,    4,       5,   2, },
+     /* 5 TRIGGER: */ {    6,  5,     5,       5,      5,    5,       5,   5, },
+     /* 6    SEMI: */ {    6,  6,     5,       5,      5,    5,       5,   7, },
+     /* 7     END: */ {    1,  7,     5,       5,      5,    5,       5,   5, },
   };
 #else
-  /* If triggers are not suppored by this compile then the statement machine
+  /* If triggers are not supported by this compile then the statement machine
   ** used to detect the end of a statement is much simplier
   */
-  static const u8 trans[2][3] = {
+  static const u8 trans[3][3] = {
                      /* Token:           */
      /* State:       **  SEMI  WS  OTHER */
-     /* 0   START: */ {    0,  0,     1, },
-     /* 1  NORMAL: */ {    0,  1,     1, },
+     /* 0 INVALID: */ {    1,  0,     2, },
+     /* 1   START: */ {    1,  1,     2, },
+     /* 2  NORMAL: */ {    1,  2,     2, },
   };
 #endif /* SQLITE_OMIT_TRIGGER */
 
@@ -94272,7 +95000,7 @@ SQLITE_API int sqlite3_complete(const char *zSql){
           break;
         }
         while( *zSql && *zSql!='\n' ){ zSql++; }
-        if( *zSql==0 ) return state==0;
+        if( *zSql==0 ) return state==1;
         token = tkWS;
         break;
       }
@@ -94294,7 +95022,9 @@ SQLITE_API int sqlite3_complete(const char *zSql){
         break;
       }
       default: {
-        int c;
+#ifdef SQLITE_EBCDIC
+        unsigned char c;
+#endif
         if( IdChar((u8)*zSql) ){
           /* Keywords and unquoted identifiers */
           int nId;
@@ -94354,7 +95084,7 @@ SQLITE_API int sqlite3_complete(const char *zSql){
     state = trans[state][token];
     zSql++;
   }
-  return state==0;
+  return state==1;
 }
 
 #ifndef SQLITE_OMIT_UTF16
@@ -94742,7 +95472,7 @@ SQLITE_API int sqlite3_config(int op, ...){
     /* Mutex configuration options are only available in a threadsafe
     ** compile. 
     */
-#if SQLITE_THREADSAFE
+#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0
     case SQLITE_CONFIG_SINGLETHREAD: {
       /* Disable all mutexing */
       sqlite3GlobalConfig.bCoreMutex = 0;
@@ -95696,7 +96426,7 @@ SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3 *db){
 ** The sqlite3TempInMemory() function is used to determine which.
 */
 SQLITE_PRIVATE int sqlite3BtreeFactory(
-  const sqlite3 *db,        /* Main database when opening aux otherwise 0 */
+  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 */
@@ -95958,9 +96688,6 @@ static const int aHardLimit[] = {
 #if SQLITE_MAX_LIKE_PATTERN_LENGTH<1
 # error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1
 #endif
-#if SQLITE_MAX_VARIABLE_NUMBER<1
-# error SQLITE_MAX_VARIABLE_NUMBER must be at least 1
-#endif
 #if SQLITE_MAX_COLUMN>32767
 # error SQLITE_MAX_COLUMN must not exceed 32767
 #endif
@@ -96761,6 +97488,40 @@ SQLITE_API int sqlite3_test_control(int op, ...){
       break;
     }
 
+    /*  sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 *db, int N)
+    **
+    ** Enable or disable various optimizations for testing purposes.  The 
+    ** argument N is a bitmask of optimizations to be disabled.  For normal
+    ** operation N should be 0.  The idea is that a test program (like the
+    ** SQL Logic Test or SLT test module) can run the same SQL multiple times
+    ** with various optimizations disabled to verify that the same answer
+    ** is obtained in every case.
+    */
+    case SQLITE_TESTCTRL_OPTIMIZATIONS: {
+      sqlite3 *db = va_arg(ap, sqlite3*);
+      int x = va_arg(ap,int);
+      db->flags = (x & SQLITE_OptMask) | (db->flags & ~SQLITE_OptMask);
+      break;
+    }
+
+#ifdef SQLITE_N_KEYWORD
+    /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const char *zWord)
+    **
+    ** If zWord is a keyword recognized by the parser, then return the
+    ** number of keywords.  Or if zWord is not a keyword, return 0.
+    ** 
+    ** This test feature is only available in the amalgamation since
+    ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite
+    ** is built using separate source files.
+    */
+    case SQLITE_TESTCTRL_ISKEYWORD: {
+      const char *zWord = va_arg(ap, const char*);
+      int n = sqlite3Strlen30(zWord);
+      rc = (sqlite3KeywordCode((u8*)zWord, n)!=TK_ID) ? SQLITE_N_KEYWORD : 0;
+      break;
+    }
+#endif 
+
   }
   va_end(ap);
 #endif /* SQLITE_OMIT_BUILTIN_TEST */
@@ -96783,8 +97544,6 @@ SQLITE_API int sqlite3_test_control(int op, ...){
 **
 ** This file contains the implementation of the sqlite3_unlock_notify()
 ** API method and its associated functionality.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */
@@ -97383,11 +98142,10 @@ SQLITE_PRIVATE void sqlite3ConnectionClosed(sqlite3 *db){
 # define SQLITE_CORE 1
 #endif
 
-
-/************** Include fts3_expr.h in the middle of fts3.c ******************/
-/************** Begin file fts3_expr.h ***************************************/
+/************** Include fts3Int.h in the middle of fts3.c ********************/
+/************** Begin file fts3Int.h *****************************************/
 /*
-** 2008 Nov 28
+** 2009 Nov 12
 **
 ** The author disclaims copyright to this source code.  In place of
 ** a legal notice, here is a blessing:
@@ -97400,7 +98158,14 @@ SQLITE_PRIVATE void sqlite3ConnectionClosed(sqlite3 *db){
 **
 */
 
-/************** Include fts3_tokenizer.h in the middle of fts3_expr.h ********/
+#ifndef _FTSINT_H
+#define _FTSINT_H
+
+#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) 
+# define NDEBUG 1
+#endif
+
+/************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/
 /************** Begin file fts3_tokenizer.h **********************************/
 /*
 ** 2006 July 10
@@ -97548,94 +98313,15 @@ struct sqlite3_tokenizer_cursor {
   /* Tokenizer implementations will typically add additional fields */
 };
 
-#endif /* _FTS3_TOKENIZER_H_ */
-
-/************** End of fts3_tokenizer.h **************************************/
-/************** Continuing where we left off in fts3_expr.h ******************/
+int fts3_global_term_cnt(int iTerm, int iCol);
+int fts3_term_cnt(int iTerm, int iCol);
 
-/*
-** The following describes the syntax supported by the fts3 MATCH
-** operator in a similar format to that used by the lemon parser
-** generator. This module does not use actually lemon, it uses a
-** custom parser.
-**
-**   query ::= andexpr (OR andexpr)*.
-**
-**   andexpr ::= notexpr (AND? notexpr)*.
-**
-**   notexpr ::= nearexpr (NOT nearexpr|-TOKEN)*.
-**   notexpr ::= LP query RP.
-**
-**   nearexpr ::= phrase (NEAR distance_opt nearexpr)*.
-**
-**   distance_opt ::= .
-**   distance_opt ::= / INTEGER.
-**
-**   phrase ::= TOKEN.
-**   phrase ::= COLUMN:TOKEN.
-**   phrase ::= "TOKEN TOKEN TOKEN...".
-*/
-
-typedef struct Fts3Expr Fts3Expr;
-typedef struct Fts3Phrase Fts3Phrase;
-
-/*
-** A "phrase" is a sequence of one or more tokens that must match in
-** sequence.  A single token is the base case and the most common case.
-** For a sequence of tokens contained in "...", nToken will be the number
-** of tokens in the string.
-*/
-struct Fts3Phrase {
-  int nToken;          /* Number of tokens in the phrase */
-  int iColumn;         /* Index of column this phrase must match */
-  int isNot;           /* Phrase prefixed by unary not (-) operator */
-  struct PhraseToken {
-    char *z;              /* Text of the token */
-    int n;                /* Number of bytes in buffer pointed to by z */
-    int isPrefix;         /* True if token ends in with a "*" character */
-  } aToken[1];         /* One entry for each token in the phrase */
-};
-
-/*
-** A tree of these objects forms the RHS of a MATCH operator.
-*/
-struct Fts3Expr {
-  int eType;                 /* One of the FTSQUERY_XXX values defined below */
-  int nNear;                 /* Valid if eType==FTSQUERY_NEAR */
-  Fts3Expr *pParent;         /* pParent->pLeft==this or pParent->pRight==this */
-  Fts3Expr *pLeft;           /* Left operand */
-  Fts3Expr *pRight;          /* Right operand */
-  Fts3Phrase *pPhrase;       /* Valid if eType==FTSQUERY_PHRASE */
-};
-
-SQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *, char **, int, int, 
-                         const char *, int, Fts3Expr **);
-SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *);
-
-/*
-** Candidate values for Fts3Query.eType. Note that the order of the first
-** four values is in order of precedence when parsing expressions. For 
-** example, the following:
-**
-**   "a OR b AND c NOT d NEAR e"
-**
-** is equivalent to:
-**
-**   "a OR (b AND (c NOT (d NEAR e)))"
-*/
-#define FTSQUERY_NEAR   1
-#define FTSQUERY_NOT    2
-#define FTSQUERY_AND    3
-#define FTSQUERY_OR     4
-#define FTSQUERY_PHRASE 5
 
-#ifdef SQLITE_TEST
-SQLITE_PRIVATE void sqlite3Fts3ExprInitTestInterface(sqlite3 *db);
-#endif
+#endif /* _FTS3_TOKENIZER_H_ */
 
-/************** End of fts3_expr.h *******************************************/
-/************** Continuing where we left off in fts3.c ***********************/
-/************** Include fts3_hash.h in the middle of fts3.c ******************/
+/************** End of fts3_tokenizer.h **************************************/
+/************** Continuing where we left off in fts3Int.h ********************/
+/************** Include fts3_hash.h in the middle of fts3Int.h ***************/
 /************** Begin file fts3_hash.h ***************************************/
 /*
 ** 2001 September 22
@@ -97657,8 +98343,8 @@ SQLITE_PRIVATE void sqlite3Fts3ExprInitTestInterface(sqlite3 *db);
 #define _FTS3_HASH_H_
 
 /* Forward declarations of structures. */
-typedef struct fts3Hash fts3Hash;
-typedef struct fts3HashElem fts3HashElem;
+typedef struct Fts3Hash Fts3Hash;
+typedef struct Fts3HashElem Fts3HashElem;
 
 /* A complete hash table is an instance of the following structure.
 ** The internals of this structure are intended to be opaque -- client
@@ -97668,15 +98354,15 @@ typedef struct fts3HashElem fts3HashElem;
 ** accessing this structure are really macros, so we can't really make
 ** this structure opaque.
 */
-struct fts3Hash {
+struct Fts3Hash {
   char keyClass;          /* HASH_INT, _POINTER, _STRING, _BINARY */
   char copyKey;           /* True if copy of key made on insert */
   int count;              /* Number of entries in this table */
-  fts3HashElem *first;    /* The first element of the array */
+  Fts3HashElem *first;    /* The first element of the array */
   int htsize;             /* Number of buckets in the hash table */
   struct _fts3ht {        /* the hash table */
     int count;               /* Number of entries with this hash */
-    fts3HashElem *chain;     /* Pointer to first entry with this hash */
+    Fts3HashElem *chain;     /* Pointer to first entry with this hash */
   } *ht;
 };
 
@@ -97686,8 +98372,8 @@ struct fts3Hash {
 ** Again, this structure is intended to be opaque, but it can't really
 ** be opaque because it is used by macros.
 */
-struct fts3HashElem {
-  fts3HashElem *next, *prev; /* Next and previous elements in the table */
+struct Fts3HashElem {
+  Fts3HashElem *next, *prev; /* Next and previous elements in the table */
   void *data;                /* Data associated with this element */
   void *pKey; int nKey;      /* Key associated with this element */
 };
@@ -97710,25 +98396,27 @@ struct fts3HashElem {
 /*
 ** Access routines.  To delete, insert a NULL pointer.
 */
-SQLITE_PRIVATE void sqlite3Fts3HashInit(fts3Hash*, int keytype, int copyKey);
-SQLITE_PRIVATE void *sqlite3Fts3HashInsert(fts3Hash*, const void *pKey, int nKey, void *pData);
-SQLITE_PRIVATE void *sqlite3Fts3HashFind(const fts3Hash*, const void *pKey, int nKey);
-SQLITE_PRIVATE void sqlite3Fts3HashClear(fts3Hash*);
+SQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey);
+SQLITE_PRIVATE void *sqlite3Fts3HashInsert(Fts3Hash*, const void *pKey, int nKey, void *pData);
+SQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash*, const void *pKey, int nKey);
+SQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash*);
+SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const void *, int);
 
 /*
 ** Shorthand for the functions above
 */
-#define fts3HashInit   sqlite3Fts3HashInit
-#define fts3HashInsert sqlite3Fts3HashInsert
-#define fts3HashFind   sqlite3Fts3HashFind
-#define fts3HashClear  sqlite3Fts3HashClear
+#define fts3HashInit     sqlite3Fts3HashInit
+#define fts3HashInsert   sqlite3Fts3HashInsert
+#define fts3HashFind     sqlite3Fts3HashFind
+#define fts3HashClear    sqlite3Fts3HashClear
+#define fts3HashFindElem sqlite3Fts3HashFindElem
 
 /*
 ** Macros for looping over all elements of a hash table.  The idiom is
 ** like this:
 **
-**   fts3Hash h;
-**   fts3HashElem *p;
+**   Fts3Hash h;
+**   Fts3HashElem *p;
 **   ...
 **   for(p=fts3HashFirst(&h); p; p=fts3HashNext(p)){
 **     SomeStructure *pData = fts3HashData(p);
@@ -97749,105 +98437,307 @@ SQLITE_PRIVATE void sqlite3Fts3HashClear(fts3Hash*);
 #endif /* _FTS3_HASH_H_ */
 
 /************** End of fts3_hash.h *******************************************/
-/************** Continuing where we left off in fts3.c ***********************/
-#ifndef SQLITE_CORE 
-  SQLITE_EXTENSION_INIT1
-#endif
+/************** Continuing where we left off in fts3Int.h ********************/
 
+/*
+** This constant controls how often segments are merged. Once there are
+** FTS3_MERGE_COUNT segments of level N, they are merged into a single
+** segment of level N+1.
+*/
+#define FTS3_MERGE_COUNT 16
 
-/* TODO(shess) MAN, this thing needs some refactoring.  At minimum, it
-** would be nice to order the file better, perhaps something along the
-** lines of:
-**
-**  - utility functions
-**  - table setup functions
-**  - table update functions
-**  - table query functions
-**
-** Put the query functions last because they're likely to reference
-** typedefs or functions from the table update section.
+/*
+** This is the maximum amount of data (in bytes) to store in the 
+** Fts3Table.pendingTerms hash table. Normally, the hash table is
+** populated as documents are inserted/updated/deleted in a transaction
+** and used to create a new segment when the transaction is committed.
+** However if this limit is reached midway through a transaction, a new 
+** segment is created and the hash table cleared immediately.
 */
+#define FTS3_MAX_PENDING_DATA (1*1024*1024)
 
-#if 0
-# define FTSTRACE(A)  printf A; fflush(stdout)
-#else
-# define FTSTRACE(A)
-#endif
+/*
+** Macro to return the number of elements in an array. SQLite has a
+** similar macro called ArraySize(). Use a different name to avoid
+** a collision when building an amalgamation with built-in FTS3.
+*/
+#define SizeofArray(X) ((int)(sizeof(X)/sizeof(X[0])))
 
-/* It is not safe to call isspace(), tolower(), or isalnum() on
-** hi-bit-set characters.  This is the same solution used in the
-** tokenizer.
+/*
+** Maximum length of a varint encoded integer. The varint format is different
+** from that used by SQLite, so the maximum length is 10, not 9.
 */
-/* TODO(shess) The snippet-generation code should be using the
-** tokenizer-generated tokens rather than doing its own local
-** tokenization.
+#define FTS3_VARINT_MAX 10
+
+/*
+** This section provides definitions to allow the
+** FTS3 extension to be compiled outside of the 
+** amalgamation.
 */
-/* TODO(shess) Is __isascii() a portable version of (c&0x80)==0? */
-static int safe_isspace(char c){
-  return (c&0x80)==0 ? isspace(c) : 0;
-}
-static int safe_tolower(char c){
-  return (c&0x80)==0 ? tolower(c) : c;
-}
-static int safe_isalnum(char c){
-  return (c&0x80)==0 ? isalnum(c) : 0;
-}
+#ifndef SQLITE_AMALGAMATION
+/*
+** Macros indicating that conditional expressions are always true or
+** false.
+*/
+# define ALWAYS(x) (x)
+# define NEVER(X)  (x)
+/*
+** Internal types used by SQLite.
+*/
+typedef unsigned char u8;         /* 1-byte (or larger) unsigned integer */
+typedef short int i16;            /* 2-byte (or larger) signed integer */
+typedef unsigned int u32;         /* 4-byte unsigned integer */
+typedef sqlite3_uint64 u64;       /* 8-byte unsigned integer */
+/*
+** Macro used to suppress compiler warnings for unused parameters.
+*/
+#define UNUSED_PARAMETER(x) (void)(x)
+#endif
 
-typedef enum DocListType {
-  DL_DOCIDS,              /* docids only */
-  DL_POSITIONS,           /* docids + positions */
-  DL_POSITIONS_OFFSETS    /* docids + positions + offsets */
-} DocListType;
+typedef struct Fts3Table Fts3Table;
+typedef struct Fts3Cursor Fts3Cursor;
+typedef struct Fts3Expr Fts3Expr;
+typedef struct Fts3Phrase Fts3Phrase;
+typedef struct Fts3SegReader Fts3SegReader;
+typedef struct Fts3SegFilter Fts3SegFilter;
 
 /*
-** By default, only positions and not offsets are stored in the doclists.
-** To change this so that offsets are stored too, compile with
-**
-**          -DDL_DEFAULT=DL_POSITIONS_OFFSETS
+** A connection to a fulltext index is an instance of the following
+** structure. The xCreate and xConnect methods create an instance
+** of this structure and xDestroy and xDisconnect free that instance.
+** All other methods receive a pointer to the structure as one of their
+** arguments.
+*/
+struct Fts3Table {
+  sqlite3_vtab base;              /* Base class used by SQLite core */
+  sqlite3 *db;                    /* The database connection */
+  const char *zDb;                /* logical database name */
+  const char *zName;              /* virtual table name */
+  int nColumn;                    /* number of named columns in virtual table */
+  char **azColumn;                /* column names.  malloced */
+  sqlite3_tokenizer *pTokenizer;  /* tokenizer for inserts and queries */
+
+  /* Precompiled statements used by the implementation. Each of these 
+  ** statements is run and reset within a single virtual table API call. 
+  */
+  sqlite3_stmt *aStmt[18];
+
+  /* Pointer to string containing the SQL:
+  **
+  ** "SELECT block FROM %_segments WHERE blockid BETWEEN ? AND ? 
+  **    ORDER BY blockid"
+  */
+  char *zSelectLeaves;
+  int nLeavesStmt;                /* Valid statements in aLeavesStmt */
+  int nLeavesTotal;               /* Total number of prepared leaves stmts */
+  int nLeavesAlloc;               /* Allocated size of aLeavesStmt */
+  sqlite3_stmt **aLeavesStmt;     /* Array of prepared zSelectLeaves stmts */
+
+  int nNodeSize;                  /* Soft limit for node size */
+
+  /* The following hash table is used to buffer pending index updates during
+  ** transactions. Variable nPendingData estimates the memory size of the 
+  ** pending data, including hash table overhead, but not malloc overhead. 
+  ** When nPendingData exceeds nMaxPendingData, the buffer is flushed 
+  ** automatically. Variable iPrevDocid is the docid of the most recently
+  ** inserted record.
+  */
+  int nMaxPendingData;
+  int nPendingData;
+  sqlite_int64 iPrevDocid;
+  Fts3Hash pendingTerms;
+};
+
+/*
+** When the core wants to read from the virtual table, it creates a
+** virtual table cursor (an instance of the following structure) using
+** the xOpen method. Cursors are destroyed using the xClose method.
+*/
+struct Fts3Cursor {
+  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */
+  i16 eSearch;                    /* Search strategy (see below) */
+  u8 isEof;                       /* True if at End Of Results */
+  u8 isRequireSeek;               /* True if must seek pStmt to %_content row */
+  sqlite3_stmt *pStmt;            /* Prepared statement in use by the cursor */
+  Fts3Expr *pExpr;                /* Parsed MATCH query string */
+  sqlite3_int64 iPrevId;          /* Previous id read from aDoclist */
+  char *pNextId;                  /* Pointer into the body of aDoclist */
+  char *aDoclist;                 /* List of docids for full-text queries */
+  int nDoclist;                   /* Size of buffer at aDoclist */
+  int isMatchinfoOk;              /* True when aMatchinfo[] matches iPrevId */
+  u32 *aMatchinfo;
+};
+
+/*
+** The Fts3Cursor.eSearch member is always set to one of the following.
+** Actualy, Fts3Cursor.eSearch can be greater than or equal to
+** FTS3_FULLTEXT_SEARCH.  If so, then Fts3Cursor.eSearch - 2 is the index
+** of the column to be searched.  For example, in
 **
-** If DL_DEFAULT is set to DL_DOCIDS, your table can only be inserted
-** into (no deletes or updates).
+**     CREATE VIRTUAL TABLE ex1 USING fts3(a,b,c,d);
+**     SELECT docid FROM ex1 WHERE b MATCH 'one two three';
+** 
+** Because the LHS of the MATCH operator is 2nd column "b",
+** Fts3Cursor.eSearch will be set to FTS3_FULLTEXT_SEARCH+1.  (+0 for a,
+** +1 for b, +2 for c, +3 for d.)  If the LHS of MATCH were "ex1" 
+** indicating that all columns should be searched,
+** then eSearch would be set to FTS3_FULLTEXT_SEARCH+4.
 */
-#ifndef DL_DEFAULT
-# define DL_DEFAULT DL_POSITIONS
-#endif
+#define FTS3_FULLSCAN_SEARCH 0    /* Linear scan of %_content table */
+#define FTS3_DOCID_SEARCH    1    /* Lookup by rowid on %_content table */
+#define FTS3_FULLTEXT_SEARCH 2    /* Full-text index search */
 
-enum {
-  POS_END = 0,        /* end of this position list */
-  POS_COLUMN,         /* followed by new column number */
-  POS_BASE
+/*
+** A "phrase" is a sequence of one or more tokens that must match in
+** sequence.  A single token is the base case and the most common case.
+** For a sequence of tokens contained in "...", nToken will be the number
+** of tokens in the string.
+*/
+struct Fts3Phrase {
+  int nToken;                /* Number of tokens in the phrase */
+  int iColumn;               /* Index of column this phrase must match */
+  int isNot;                 /* Phrase prefixed by unary not (-) operator */
+  struct PhraseToken {
+    char *z;                 /* Text of the token */
+    int n;                   /* Number of bytes in buffer pointed to by z */
+    int isPrefix;            /* True if token ends in with a "*" character */
+  } aToken[1];               /* One entry for each token in the phrase */
 };
 
-/* MERGE_COUNT controls how often we merge segments (see comment at
-** top of file).
+/*
+** A tree of these objects forms the RHS of a MATCH operator.
+**
+** If Fts3Expr.eType is either FTSQUERY_NEAR or FTSQUERY_PHRASE and isLoaded
+** is true, then aDoclist points to a malloced buffer, size nDoclist bytes, 
+** containing the results of the NEAR or phrase query in FTS3 doclist
+** format. As usual, the initial "Length" field found in doclists stored
+** on disk is omitted from this buffer.
+**
+** Variable pCurrent always points to the start of a docid field within
+** aDoclist. Since the doclist is usually scanned in docid order, this can
+** be used to accelerate seeking to the required docid within the doclist.
 */
-#define MERGE_COUNT 16
+struct Fts3Expr {
+  int eType;                 /* One of the FTSQUERY_XXX values defined below */
+  int nNear;                 /* Valid if eType==FTSQUERY_NEAR */
+  Fts3Expr *pParent;         /* pParent->pLeft==this or pParent->pRight==this */
+  Fts3Expr *pLeft;           /* Left operand */
+  Fts3Expr *pRight;          /* Right operand */
+  Fts3Phrase *pPhrase;       /* Valid if eType==FTSQUERY_PHRASE */
 
-/* utility functions */
+  int isLoaded;              /* True if aDoclist/nDoclist are initialized. */
+  char *aDoclist;            /* Buffer containing doclist */
+  int nDoclist;              /* Size of aDoclist in bytes */
 
-/* CLEAR() and SCRAMBLE() abstract memset() on a pointer to a single
-** record to prevent errors of the form:
+  sqlite3_int64 iCurrent;
+  char *pCurrent;
+};
+
+/*
+** Candidate values for Fts3Query.eType. Note that the order of the first
+** four values is in order of precedence when parsing expressions. For 
+** example, the following:
 **
-** my_function(SomeType *b){
-**   memset(b, '\0', sizeof(b));  // sizeof(b)!=sizeof(*b)
-** }
+**   "a OR b AND c NOT d NEAR e"
+**
+** is equivalent to:
+**
+**   "a OR (b AND (c NOT (d NEAR e)))"
 */
-/* TODO(shess) Obvious candidates for a header file. */
-#define CLEAR(b) memset(b, '\0', sizeof(*(b)))
+#define FTSQUERY_NEAR   1
+#define FTSQUERY_NOT    2
+#define FTSQUERY_AND    3
+#define FTSQUERY_OR     4
+#define FTSQUERY_PHRASE 5
 
-#ifndef NDEBUG
-#  define SCRAMBLE(b) memset(b, 0x55, sizeof(*(b)))
-#else
-#  define SCRAMBLE(b)
+
+/* fts3_init.c */
+SQLITE_PRIVATE int sqlite3Fts3DeleteVtab(int, sqlite3_vtab *);
+SQLITE_PRIVATE int sqlite3Fts3InitVtab(int, sqlite3*, void*, int, const char*const*, 
+                        sqlite3_vtab **, char **);
+
+/* fts3_write.c */
+SQLITE_PRIVATE int sqlite3Fts3UpdateMethod(sqlite3_vtab*,int,sqlite3_value**,sqlite3_int64*);
+SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *);
+SQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *);
+SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *);
+SQLITE_PRIVATE int sqlite3Fts3SegReaderNew(Fts3Table *,int, sqlite3_int64,
+  sqlite3_int64, sqlite3_int64, const char *, int, Fts3SegReader**);
+SQLITE_PRIVATE int sqlite3Fts3SegReaderPending(Fts3Table*,const char*,int,int,Fts3SegReader**);
+SQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3Table *, Fts3SegReader *);
+SQLITE_PRIVATE int sqlite3Fts3SegReaderIterate(
+  Fts3Table *, Fts3SegReader **, int, Fts3SegFilter *,
+  int (*)(Fts3Table *, void *, char *, int, char *, int),  void *
+);
+SQLITE_PRIVATE int sqlite3Fts3ReadBlock(Fts3Table*, sqlite3_int64, char const**, int*);
+SQLITE_PRIVATE int sqlite3Fts3AllSegdirs(Fts3Table*, sqlite3_stmt **);
+
+/* Flags allowed as part of the 4th argument to SegmentReaderIterate() */
+#define FTS3_SEGMENT_REQUIRE_POS   0x00000001
+#define FTS3_SEGMENT_IGNORE_EMPTY  0x00000002
+#define FTS3_SEGMENT_COLUMN_FILTER 0x00000004
+#define FTS3_SEGMENT_PREFIX        0x00000008
+
+/* Type passed as 4th argument to SegmentReaderIterate() */
+struct Fts3SegFilter {
+  const char *zTerm;
+  int nTerm;
+  int iCol;
+  int flags;
+};
+
+/* fts3.c */
+SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
+SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
+SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
+SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
+SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
+
+SQLITE_PRIVATE char *sqlite3Fts3FindPositions(Fts3Expr *, sqlite3_int64, int);
+SQLITE_PRIVATE int sqlite3Fts3ExprLoadDoclist(Fts3Table *, Fts3Expr *);
+
+/* fts3_tokenizer.c */
+SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);
+SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
+SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, 
+  const char *, sqlite3_tokenizer **, const char **, char **
+);
+
+/* fts3_snippet.c */
+SQLITE_PRIVATE void sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*);
+SQLITE_PRIVATE void sqlite3Fts3Snippet(sqlite3_context*, Fts3Cursor*, 
+  const char *, const char *, const char *
+);
+SQLITE_PRIVATE void sqlite3Fts3Snippet2(sqlite3_context *, Fts3Cursor *, const char *,
+  const char *, const char *, int, int
+);
+SQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *);
+
+/* fts3_expr.c */
+SQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *, 
+  char **, int, int, const char *, int, Fts3Expr **
+);
+SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *);
+#ifdef SQLITE_TEST
+SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db);
 #endif
 
-/* We may need up to VARINT_MAX bytes to store an encoded 64-bit integer. */
-#define VARINT_MAX 10
+#endif /* _FTSINT_H */
+
+/************** End of fts3Int.h *********************************************/
+/************** Continuing where we left off in fts3.c ***********************/
+
+
+#ifndef SQLITE_CORE 
+  SQLITE_EXTENSION_INIT1
+#endif
 
-/* Write a 64-bit variable-length integer to memory starting at p[0].
- * The length of data written will be between 1 and VARINT_MAX bytes.
- * The number of bytes written is returned. */
-static int fts3PutVarint(char *p, sqlite_int64 v){
+/* 
+** Write a 64-bit variable-length integer to memory starting at p[0].
+** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
+** The number of bytes written is returned.
+*/
+SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *p, sqlite_int64 v){
   unsigned char *q = (unsigned char *) p;
   sqlite_uint64 vu = v;
   do{
@@ -97855,6493 +98745,2014 @@ static int fts3PutVarint(char *p, sqlite_int64 v){
     vu >>= 7;
   }while( vu!=0 );
   q[-1] &= 0x7f;  /* turn off high bit in final byte */
-  assert( q - (unsigned char *)p <= VARINT_MAX );
+  assert( q - (unsigned char *)p <= FTS3_VARINT_MAX );
   return (int) (q - (unsigned char *)p);
 }
 
-/* Read a 64-bit variable-length integer from memory starting at p[0].
- * Return the number of bytes read, or 0 on error.
- * The value is stored in *v. */
-static int fts3GetVarint(const char *p, sqlite_int64 *v){
+/* 
+** Read a 64-bit variable-length integer from memory starting at p[0].
+** Return the number of bytes read, or 0 on error.
+** The value is stored in *v.
+*/
+SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *p, sqlite_int64 *v){
   const unsigned char *q = (const unsigned char *) p;
   sqlite_uint64 x = 0, y = 1;
-  while( (*q & 0x80) == 0x80 ){
+  while( (*q&0x80)==0x80 && q-(unsigned char *)p<FTS3_VARINT_MAX ){
     x += y * (*q++ & 0x7f);
     y <<= 7;
-    if( q - (unsigned char *)p >= VARINT_MAX ){  /* bad data */
-      assert( 0 );
-      return 0;
-    }
   }
   x += y * (*q++);
   *v = (sqlite_int64) x;
   return (int) (q - (unsigned char *)p);
 }
 
-static int fts3GetVarint32(const char *p, int *pi){
+/*
+** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to a
+** 32-bit integer before it is returned.
+*/
+SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){
  sqlite_int64 i;
- int ret = fts3GetVarint(p, &i);
+ int ret = sqlite3Fts3GetVarint(p, &i);
  *pi = (int) i;
- assert( *pi==i );
  return ret;
 }
 
-/*******************************************************************/
-/* DataBuffer is used to collect data into a buffer in piecemeal
-** fashion.  It implements the usual distinction between amount of
-** data currently stored (nData) and buffer capacity (nCapacity).
-**
-** dataBufferInit - create a buffer with given initial capacity.
-** dataBufferReset - forget buffer's data, retaining capacity.
-** dataBufferDestroy - free buffer's data.
-** dataBufferSwap - swap contents of two buffers.
-** dataBufferExpand - expand capacity without adding data.
-** dataBufferAppend - append data.
-** dataBufferAppend2 - append two pieces of data at once.
-** dataBufferReplace - replace buffer's data.
-*/
-typedef struct DataBuffer {
-  char *pData;          /* Pointer to malloc'ed buffer. */
-  int nCapacity;        /* Size of pData buffer. */
-  int nData;            /* End of data loaded into pData. */
-} DataBuffer;
-
-static void dataBufferInit(DataBuffer *pBuffer, int nCapacity){
-  assert( nCapacity>=0 );
-  pBuffer->nData = 0;
-  pBuffer->nCapacity = nCapacity;
-  pBuffer->pData = nCapacity==0 ? NULL : sqlite3_malloc(nCapacity);
-}
-static void dataBufferReset(DataBuffer *pBuffer){
-  pBuffer->nData = 0;
-}
-static void dataBufferDestroy(DataBuffer *pBuffer){
-  if( pBuffer->pData!=NULL ) sqlite3_free(pBuffer->pData);
-  SCRAMBLE(pBuffer);
-}
-static void dataBufferSwap(DataBuffer *pBuffer1, DataBuffer *pBuffer2){
-  DataBuffer tmp = *pBuffer1;
-  *pBuffer1 = *pBuffer2;
-  *pBuffer2 = tmp;
-}
-static void dataBufferExpand(DataBuffer *pBuffer, int nAddCapacity){
-  assert( nAddCapacity>0 );
-  /* TODO(shess) Consider expanding more aggressively.  Note that the
-  ** underlying malloc implementation may take care of such things for
-  ** us already.
-  */
-  if( pBuffer->nData+nAddCapacity>pBuffer->nCapacity ){
-    pBuffer->nCapacity = pBuffer->nData+nAddCapacity;
-    pBuffer->pData = sqlite3_realloc(pBuffer->pData, pBuffer->nCapacity);
-  }
-}
-static void dataBufferAppend(DataBuffer *pBuffer,
-                             const char *pSource, int nSource){
-  assert( nSource>0 && pSource!=NULL );
-  dataBufferExpand(pBuffer, nSource);
-  memcpy(pBuffer->pData+pBuffer->nData, pSource, nSource);
-  pBuffer->nData += nSource;
-}
-static void dataBufferAppend2(DataBuffer *pBuffer,
-                              const char *pSource1, int nSource1,
-                              const char *pSource2, int nSource2){
-  assert( nSource1>0 && pSource1!=NULL );
-  assert( nSource2>0 && pSource2!=NULL );
-  dataBufferExpand(pBuffer, nSource1+nSource2);
-  memcpy(pBuffer->pData+pBuffer->nData, pSource1, nSource1);
-  memcpy(pBuffer->pData+pBuffer->nData+nSource1, pSource2, nSource2);
-  pBuffer->nData += nSource1+nSource2;
-}
-static void dataBufferReplace(DataBuffer *pBuffer,
-                              const char *pSource, int nSource){
-  dataBufferReset(pBuffer);
-  dataBufferAppend(pBuffer, pSource, nSource);
-}
-
-/* StringBuffer is a null-terminated version of DataBuffer. */
-typedef struct StringBuffer {
-  DataBuffer b;            /* Includes null terminator. */
-} StringBuffer;
-
-static void initStringBuffer(StringBuffer *sb){
-  dataBufferInit(&sb->b, 100);
-  dataBufferReplace(&sb->b, "", 1);
-}
-static int stringBufferLength(StringBuffer *sb){
-  return sb->b.nData-1;
-}
-static char *stringBufferData(StringBuffer *sb){
-  return sb->b.pData;
-}
-static void stringBufferDestroy(StringBuffer *sb){
-  dataBufferDestroy(&sb->b);
-}
-
-static void nappend(StringBuffer *sb, const char *zFrom, int nFrom){
-  assert( sb->b.nData>0 );
-  if( nFrom>0 ){
-    sb->b.nData--;
-    dataBufferAppend2(&sb->b, zFrom, nFrom, "", 1);
-  }
-}
-static void append(StringBuffer *sb, const char *zFrom){
-  nappend(sb, zFrom, strlen(zFrom));
-}
-
-/* Append a list of strings separated by commas. */
-static void appendList(StringBuffer *sb, int nString, char **azString){
-  int i;
-  for(i=0; i<nString; ++i){
-    if( i>0 ) append(sb, ", ");
-    append(sb, azString[i]);
-  }
-}
-
-static int endsInWhiteSpace(StringBuffer *p){
-  return stringBufferLength(p)>0 &&
-    safe_isspace(stringBufferData(p)[stringBufferLength(p)-1]);
-}
-
-/* If the StringBuffer ends in something other than white space, add a
-** single space character to the end.
+/*
+** Return the number of bytes required to store the value passed as the
+** first argument in varint form.
 */
-static void appendWhiteSpace(StringBuffer *p){
-  if( stringBufferLength(p)==0 ) return;
-  if( !endsInWhiteSpace(p) ) append(p, " ");
+SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64 v){
+  int i = 0;
+  do{
+    i++;
+    v >>= 7;
+  }while( v!=0 );
+  return i;
 }
 
-/* Remove white space from the end of the StringBuffer */
-static void trimWhiteSpace(StringBuffer *p){
-  while( endsInWhiteSpace(p) ){
-    p->b.pData[--p->b.nData-1] = '\0';
-  }
-}
-
-/*******************************************************************/
-/* DLReader is used to read document elements from a doclist.  The
-** current docid is cached, so dlrDocid() is fast.  DLReader does not
-** own the doclist buffer.
-**
-** dlrAtEnd - true if there's no more data to read.
-** dlrDocid - docid of current document.
-** dlrDocData - doclist data for current document (including docid).
-** dlrDocDataBytes - length of same.
-** dlrAllDataBytes - length of all remaining data.
-** dlrPosData - position data for current document.
-** dlrPosDataLen - length of pos data for current document (incl POS_END).
-** dlrStep - step to current document.
-** dlrInit - initial for doclist of given type against given data.
-** dlrDestroy - clean up.
-**
-** Expected usage is something like:
-**
-**   DLReader reader;
-**   dlrInit(&reader, pData, nData);
-**   while( !dlrAtEnd(&reader) ){
-**     // calls to dlrDocid() and kin.
-**     dlrStep(&reader);
-**   }
-**   dlrDestroy(&reader);
+/*
+** Convert an SQL-style quoted string into a normal string by removing
+** the quote characters.  The conversion is done in-place.  If the
+** input does not begin with a quote character, then this routine
+** is a no-op.
+**
+** Examples:
+**
+**     "abc"   becomes   abc
+**     'xyz'   becomes   xyz
+**     [pqr]   becomes   pqr
+**     `mno`   becomes   mno
+**
 */
-typedef struct DLReader {
-  DocListType iType;
-  const char *pData;
-  int nData;
+SQLITE_PRIVATE void sqlite3Fts3Dequote(char *z){
+  char quote;                     /* Quote character (if any ) */
 
-  sqlite_int64 iDocid;
-  int nElement;
-} DLReader;
-
-static int dlrAtEnd(DLReader *pReader){
-  assert( pReader->nData>=0 );
-  return pReader->nData==0;
-}
-static sqlite_int64 dlrDocid(DLReader *pReader){
-  assert( !dlrAtEnd(pReader) );
-  return pReader->iDocid;
-}
-static const char *dlrDocData(DLReader *pReader){
-  assert( !dlrAtEnd(pReader) );
-  return pReader->pData;
-}
-static int dlrDocDataBytes(DLReader *pReader){
-  assert( !dlrAtEnd(pReader) );
-  return pReader->nElement;
-}
-static int dlrAllDataBytes(DLReader *pReader){
-  assert( !dlrAtEnd(pReader) );
-  return pReader->nData;
-}
-/* TODO(shess) Consider adding a field to track iDocid varint length
-** to make these two functions faster.  This might matter (a tiny bit)
-** for queries.
-*/
-static const char *dlrPosData(DLReader *pReader){
-  sqlite_int64 iDummy;
-  int n = fts3GetVarint(pReader->pData, &iDummy);
-  assert( !dlrAtEnd(pReader) );
-  return pReader->pData+n;
-}
-static int dlrPosDataLen(DLReader *pReader){
-  sqlite_int64 iDummy;
-  int n = fts3GetVarint(pReader->pData, &iDummy);
-  assert( !dlrAtEnd(pReader) );
-  return pReader->nElement-n;
-}
-static void dlrStep(DLReader *pReader){
-  assert( !dlrAtEnd(pReader) );
-
-  /* Skip past current doclist element. */
-  assert( pReader->nElement<=pReader->nData );
-  pReader->pData += pReader->nElement;
-  pReader->nData -= pReader->nElement;
-
-  /* If there is more data, read the next doclist element. */
-  if( pReader->nData!=0 ){
-    sqlite_int64 iDocidDelta;
-    int iDummy, n = fts3GetVarint(pReader->pData, &iDocidDelta);
-    pReader->iDocid += iDocidDelta;
-    if( pReader->iType>=DL_POSITIONS ){
-      assert( n<pReader->nData );
-      while( 1 ){
-        n += fts3GetVarint32(pReader->pData+n, &iDummy);
-        assert( n<=pReader->nData );
-        if( iDummy==POS_END ) break;
-        if( iDummy==POS_COLUMN ){
-          n += fts3GetVarint32(pReader->pData+n, &iDummy);
-          assert( n<pReader->nData );
-        }else if( pReader->iType==DL_POSITIONS_OFFSETS ){
-          n += fts3GetVarint32(pReader->pData+n, &iDummy);
-          n += fts3GetVarint32(pReader->pData+n, &iDummy);
-          assert( n<pReader->nData );
-        }
+  quote = z[0];
+  if( quote=='[' || quote=='\'' || quote=='"' || quote=='`' ){
+    int iIn = 1;                  /* Index of next byte to read from input */
+    int iOut = 0;                 /* Index of next byte to write to output */
+
+    /* If the first byte was a '[', then the close-quote character is a ']' */
+    if( quote=='[' ) quote = ']';  
+
+    while( ALWAYS(z[iIn]) ){
+      if( z[iIn]==quote ){
+        if( z[iIn+1]!=quote ) break;
+        z[iOut++] = quote;
+        iIn += 2;
+      }else{
+        z[iOut++] = z[iIn++];
       }
     }
-    pReader->nElement = n;
-    assert( pReader->nElement<=pReader->nData );
+    z[iOut] = '\0';
   }
 }
-static void dlrInit(DLReader *pReader, DocListType iType,
-                    const char *pData, int nData){
-  assert( pData!=NULL && nData!=0 );
-  pReader->iType = iType;
-  pReader->pData = pData;
-  pReader->nData = nData;
-  pReader->nElement = 0;
-  pReader->iDocid = 0;
 
-  /* Load the first element's data.  There must be a first element. */
-  dlrStep(pReader);
-}
-static void dlrDestroy(DLReader *pReader){
-  SCRAMBLE(pReader);
-}
-
-#ifndef NDEBUG
-/* Verify that the doclist can be validly decoded.  Also returns the
-** last docid found because it is convenient in other assertions for
-** DLWriter.
-*/
-static void docListValidate(DocListType iType, const char *pData, int nData,
-                            sqlite_int64 *pLastDocid){
-  sqlite_int64 iPrevDocid = 0;
-  assert( nData>0 );
-  assert( pData!=0 );
-  assert( pData+nData>pData );
-  while( nData!=0 ){
-    sqlite_int64 iDocidDelta;
-    int n = fts3GetVarint(pData, &iDocidDelta);
-    iPrevDocid += iDocidDelta;
-    if( iType>DL_DOCIDS ){
-      int iDummy;
-      while( 1 ){
-        n += fts3GetVarint32(pData+n, &iDummy);
-        if( iDummy==POS_END ) break;
-        if( iDummy==POS_COLUMN ){
-          n += fts3GetVarint32(pData+n, &iDummy);
-        }else if( iType>DL_POSITIONS ){
-          n += fts3GetVarint32(pData+n, &iDummy);
-          n += fts3GetVarint32(pData+n, &iDummy);
-        }
-        assert( n<=nData );
-      }
-    }
-    assert( n<=nData );
-    pData += n;
-    nData -= n;
-  }
-  if( pLastDocid ) *pLastDocid = iPrevDocid;
+static void fts3GetDeltaVarint(char **pp, sqlite3_int64 *pVal){
+  sqlite3_int64 iVal;
+  *pp += sqlite3Fts3GetVarint(*pp, &iVal);
+  *pVal += iVal;
 }
-#define ASSERT_VALID_DOCLIST(i, p, n, o) docListValidate(i, p, n, o)
-#else
-#define ASSERT_VALID_DOCLIST(i, p, n, o) assert( 1 )
-#endif
-
-/*******************************************************************/
-/* DLWriter is used to write doclist data to a DataBuffer.  DLWriter
-** always appends to the buffer and does not own it.
-**
-** dlwInit - initialize to write a given type doclistto a buffer.
-** dlwDestroy - clear the writer's memory.  Does not free buffer.
-** dlwAppend - append raw doclist data to buffer.
-** dlwCopy - copy next doclist from reader to writer.
-** dlwAdd - construct doclist element and append to buffer.
-**    Only apply dlwAdd() to DL_DOCIDS doclists (else use PLWriter).
-*/
-typedef struct DLWriter {
-  DocListType iType;
-  DataBuffer *b;
-  sqlite_int64 iPrevDocid;
-#ifndef NDEBUG
-  int has_iPrevDocid;
-#endif
-} DLWriter;
 
-static void dlwInit(DLWriter *pWriter, DocListType iType, DataBuffer *b){
-  pWriter->b = b;
-  pWriter->iType = iType;
-  pWriter->iPrevDocid = 0;
-#ifndef NDEBUG
-  pWriter->has_iPrevDocid = 0;
-#endif
-}
-static void dlwDestroy(DLWriter *pWriter){
-  SCRAMBLE(pWriter);
-}
-/* iFirstDocid is the first docid in the doclist in pData.  It is
-** needed because pData may point within a larger doclist, in which
-** case the first item would be delta-encoded.
-**
-** iLastDocid is the final docid in the doclist in pData.  It is
-** needed to create the new iPrevDocid for future delta-encoding.  The
-** code could decode the passed doclist to recreate iLastDocid, but
-** the only current user (docListMerge) already has decoded this
-** information.
-*/
-/* TODO(shess) This has become just a helper for docListMerge.
-** Consider a refactor to make this cleaner.
-*/
-static void dlwAppend(DLWriter *pWriter,
-                      const char *pData, int nData,
-                      sqlite_int64 iFirstDocid, sqlite_int64 iLastDocid){
-  sqlite_int64 iDocid = 0;
-  char c[VARINT_MAX];
-  int nFirstOld, nFirstNew;     /* Old and new varint len of first docid. */
-#ifndef NDEBUG
-  sqlite_int64 iLastDocidDelta;
-#endif
-
-  /* Recode the initial docid as delta from iPrevDocid. */
-  nFirstOld = fts3GetVarint(pData, &iDocid);
-  assert( nFirstOld<nData || (nFirstOld==nData && pWriter->iType==DL_DOCIDS) );
-  nFirstNew = fts3PutVarint(c, iFirstDocid-pWriter->iPrevDocid);
-
-  /* Verify that the incoming doclist is valid AND that it ends with
-  ** the expected docid.  This is essential because we'll trust this
-  ** docid in future delta-encoding.
-  */
-  ASSERT_VALID_DOCLIST(pWriter->iType, pData, nData, &iLastDocidDelta);
-  assert( iLastDocid==iFirstDocid-iDocid+iLastDocidDelta );
-
-  /* Append recoded initial docid and everything else.  Rest of docids
-  ** should have been delta-encoded from previous initial docid.
-  */
-  if( nFirstOld<nData ){
-    dataBufferAppend2(pWriter->b, c, nFirstNew,
-                      pData+nFirstOld, nData-nFirstOld);
+static void fts3GetDeltaVarint2(char **pp, char *pEnd, sqlite3_int64 *pVal){
+  if( *pp>=pEnd ){
+    *pp = 0;
   }else{
-    dataBufferAppend(pWriter->b, c, nFirstNew);
+    fts3GetDeltaVarint(pp, pVal);
   }
-  pWriter->iPrevDocid = iLastDocid;
-}
-static void dlwCopy(DLWriter *pWriter, DLReader *pReader){
-  dlwAppend(pWriter, dlrDocData(pReader), dlrDocDataBytes(pReader),
-            dlrDocid(pReader), dlrDocid(pReader));
-}
-static void dlwAdd(DLWriter *pWriter, sqlite_int64 iDocid){
-  char c[VARINT_MAX];
-  int n = fts3PutVarint(c, iDocid-pWriter->iPrevDocid);
-
-  /* Docids must ascend. */
-  assert( !pWriter->has_iPrevDocid || iDocid>pWriter->iPrevDocid );
-  assert( pWriter->iType==DL_DOCIDS );
-
-  dataBufferAppend(pWriter->b, c, n);
-  pWriter->iPrevDocid = iDocid;
-#ifndef NDEBUG
-  pWriter->has_iPrevDocid = 1;
-#endif
 }
 
-/*******************************************************************/
-/* PLReader is used to read data from a document's position list.  As
-** the caller steps through the list, data is cached so that varints
-** only need to be decoded once.
-**
-** plrInit, plrDestroy - create/destroy a reader.
-** plrColumn, plrPosition, plrStartOffset, plrEndOffset - accessors
-** plrAtEnd - at end of stream, only call plrDestroy once true.
-** plrStep - step to the next element.
+/*
+** The xDisconnect() virtual table method.
 */
-typedef struct PLReader {
-  /* These refer to the next position's data.  nData will reach 0 when
-  ** reading the last position, so plrStep() signals EOF by setting
-  ** pData to NULL.
-  */
-  const char *pData;
-  int nData;
-
-  DocListType iType;
-  int iColumn;         /* the last column read */
-  int iPosition;       /* the last position read */
-  int iStartOffset;    /* the last start offset read */
-  int iEndOffset;      /* the last end offset read */
-} PLReader;
-
-static int plrAtEnd(PLReader *pReader){
-  return pReader->pData==NULL;
-}
-static int plrColumn(PLReader *pReader){
-  assert( !plrAtEnd(pReader) );
-  return pReader->iColumn;
-}
-static int plrPosition(PLReader *pReader){
-  assert( !plrAtEnd(pReader) );
-  return pReader->iPosition;
-}
-static int plrStartOffset(PLReader *pReader){
-  assert( !plrAtEnd(pReader) );
-  return pReader->iStartOffset;
-}
-static int plrEndOffset(PLReader *pReader){
-  assert( !plrAtEnd(pReader) );
-  return pReader->iEndOffset;
-}
-static void plrStep(PLReader *pReader){
-  int i, n;
+static int fts3DisconnectMethod(sqlite3_vtab *pVtab){
+  Fts3Table *p = (Fts3Table *)pVtab;
+  int i;
 
-  assert( !plrAtEnd(pReader) );
+  assert( p->nPendingData==0 );
 
-  if( pReader->nData==0 ){
-    pReader->pData = NULL;
-    return;
+  /* Free any prepared statements held */
+  for(i=0; i<SizeofArray(p->aStmt); i++){
+    sqlite3_finalize(p->aStmt[i]);
   }
-
-  n = fts3GetVarint32(pReader->pData, &i);
-  if( i==POS_COLUMN ){
-    n += fts3GetVarint32(pReader->pData+n, &pReader->iColumn);
-    pReader->iPosition = 0;
-    pReader->iStartOffset = 0;
-    n += fts3GetVarint32(pReader->pData+n, &i);
+  for(i=0; i<p->nLeavesStmt; i++){
+    sqlite3_finalize(p->aLeavesStmt[i]);
   }
-  /* Should never see adjacent column changes. */
-  assert( i!=POS_COLUMN );
+  sqlite3_free(p->zSelectLeaves);
+  sqlite3_free(p->aLeavesStmt);
 
-  if( i==POS_END ){
-    pReader->nData = 0;
-    pReader->pData = NULL;
-    return;
-  }
+  /* Invoke the tokenizer destructor to free the tokenizer. */
+  p->pTokenizer->pModule->xDestroy(p->pTokenizer);
 
-  pReader->iPosition += i-POS_BASE;
-  if( pReader->iType==DL_POSITIONS_OFFSETS ){
-    n += fts3GetVarint32(pReader->pData+n, &i);
-    pReader->iStartOffset += i;
-    n += fts3GetVarint32(pReader->pData+n, &i);
-    pReader->iEndOffset = pReader->iStartOffset+i;
-  }
-  assert( n<=pReader->nData );
-  pReader->pData += n;
-  pReader->nData -= n;
-}
-
-static void plrInit(PLReader *pReader, DLReader *pDLReader){
-  pReader->pData = dlrPosData(pDLReader);
-  pReader->nData = dlrPosDataLen(pDLReader);
-  pReader->iType = pDLReader->iType;
-  pReader->iColumn = 0;
-  pReader->iPosition = 0;
-  pReader->iStartOffset = 0;
-  pReader->iEndOffset = 0;
-  plrStep(pReader);
-}
-static void plrDestroy(PLReader *pReader){
-  SCRAMBLE(pReader);
+  sqlite3_free(p);
+  return SQLITE_OK;
 }
 
-/*******************************************************************/
-/* PLWriter is used in constructing a document's position list.  As a
-** convenience, if iType is DL_DOCIDS, PLWriter becomes a no-op.
-** PLWriter writes to the associated DLWriter's buffer.
-**
-** plwInit - init for writing a document's poslist.
-** plwDestroy - clear a writer.
-** plwAdd - append position and offset information.
-** plwCopy - copy next position's data from reader to writer.
-** plwTerminate - add any necessary doclist terminator.
-**
-** Calling plwAdd() after plwTerminate() may result in a corrupt
-** doclist.
-*/
-/* TODO(shess) Until we've written the second item, we can cache the
-** first item's information.  Then we'd have three states:
-**
-** - initialized with docid, no positions.
-** - docid and one position.
-** - docid and multiple positions.
-**
-** Only the last state needs to actually write to dlw->b, which would
-** be an improvement in the DLCollector case.
+/*
+** The xDestroy() virtual table method.
 */
-typedef struct PLWriter {
-  DLWriter *dlw;
+static int fts3DestroyMethod(sqlite3_vtab *pVtab){
+  int rc;                         /* Return code */
+  Fts3Table *p = (Fts3Table *)pVtab;
 
-  int iColumn;    /* the last column written */
-  int iPos;       /* the last position written */
-  int iOffset;    /* the last start offset written */
-} PLWriter;
+  /* Create a script to drop the underlying three storage tables. */
+  char *zSql = sqlite3_mprintf(
+      "DROP TABLE IF EXISTS %Q.'%q_content';"
+      "DROP TABLE IF EXISTS %Q.'%q_segments';"
+      "DROP TABLE IF EXISTS %Q.'%q_segdir';", 
+      p->zDb, p->zName, p->zDb, p->zName, p->zDb, p->zName
+  );
 
-/* TODO(shess) In the case where the parent is reading these values
-** from a PLReader, we could optimize to a copy if that PLReader has
-** the same type as pWriter.
-*/
-static void plwAdd(PLWriter *pWriter, int iColumn, int iPos,
-                   int iStartOffset, int iEndOffset){
-  /* Worst-case space for POS_COLUMN, iColumn, iPosDelta,
-  ** iStartOffsetDelta, and iEndOffsetDelta.
+  /* If malloc has failed, set rc to SQLITE_NOMEM. Otherwise, try to
+  ** execute the SQL script created above.
   */
-  char c[5*VARINT_MAX];
-  int n = 0;
-
-  /* Ban plwAdd() after plwTerminate(). */
-  assert( pWriter->iPos!=-1 );
-
-  if( pWriter->dlw->iType==DL_DOCIDS ) return;
-
-  if( iColumn!=pWriter->iColumn ){
-    n += fts3PutVarint(c+n, POS_COLUMN);
-    n += fts3PutVarint(c+n, iColumn);
-    pWriter->iColumn = iColumn;
-    pWriter->iPos = 0;
-    pWriter->iOffset = 0;
-  }
-  assert( iPos>=pWriter->iPos );
-  n += fts3PutVarint(c+n, POS_BASE+(iPos-pWriter->iPos));
-  pWriter->iPos = iPos;
-  if( pWriter->dlw->iType==DL_POSITIONS_OFFSETS ){
-    assert( iStartOffset>=pWriter->iOffset );
-    n += fts3PutVarint(c+n, iStartOffset-pWriter->iOffset);
-    pWriter->iOffset = iStartOffset;
-    assert( iEndOffset>=iStartOffset );
-    n += fts3PutVarint(c+n, iEndOffset-iStartOffset);
-  }
-  dataBufferAppend(pWriter->dlw->b, c, n);
-}
-static void plwCopy(PLWriter *pWriter, PLReader *pReader){
-  plwAdd(pWriter, plrColumn(pReader), plrPosition(pReader),
-         plrStartOffset(pReader), plrEndOffset(pReader));
-}
-static void plwInit(PLWriter *pWriter, DLWriter *dlw, sqlite_int64 iDocid){
-  char c[VARINT_MAX];
-  int n;
-
-  pWriter->dlw = dlw;
-
-  /* Docids must ascend. */
-  assert( !pWriter->dlw->has_iPrevDocid || iDocid>pWriter->dlw->iPrevDocid );
-  n = fts3PutVarint(c, iDocid-pWriter->dlw->iPrevDocid);
-  dataBufferAppend(pWriter->dlw->b, c, n);
-  pWriter->dlw->iPrevDocid = iDocid;
-#ifndef NDEBUG
-  pWriter->dlw->has_iPrevDocid = 1;
-#endif
-
-  pWriter->iColumn = 0;
-  pWriter->iPos = 0;
-  pWriter->iOffset = 0;
-}
-/* TODO(shess) Should plwDestroy() also terminate the doclist?  But
-** then plwDestroy() would no longer be just a destructor, it would
-** also be doing work, which isn't consistent with the overall idiom.
-** Another option would be for plwAdd() to always append any necessary
-** terminator, so that the output is always correct.  But that would
-** add incremental work to the common case with the only benefit being
-** API elegance.  Punt for now.
-*/
-static void plwTerminate(PLWriter *pWriter){
-  if( pWriter->dlw->iType>DL_DOCIDS ){
-    char c[VARINT_MAX];
-    int n = fts3PutVarint(c, POS_END);
-    dataBufferAppend(pWriter->dlw->b, c, n);
-  }
-#ifndef NDEBUG
-  /* Mark as terminated for assert in plwAdd(). */
-  pWriter->iPos = -1;
-#endif
-}
-static void plwDestroy(PLWriter *pWriter){
-  SCRAMBLE(pWriter);
-}
-
-/*******************************************************************/
-/* DLCollector wraps PLWriter and DLWriter to provide a
-** dynamically-allocated doclist area to use during tokenization.
-**
-** dlcNew - malloc up and initialize a collector.
-** dlcDelete - destroy a collector and all contained items.
-** dlcAddPos - append position and offset information.
-** dlcAddDoclist - add the collected doclist to the given buffer.
-** dlcNext - terminate the current document and open another.
-*/
-typedef struct DLCollector {
-  DataBuffer b;
-  DLWriter dlw;
-  PLWriter plw;
-} DLCollector;
-
-/* TODO(shess) This could also be done by calling plwTerminate() and
-** dataBufferAppend().  I tried that, expecting nominal performance
-** differences, but it seemed to pretty reliably be worth 1% to code
-** it this way.  I suspect it is the incremental malloc overhead (some
-** percentage of the plwTerminate() calls will cause a realloc), so
-** this might be worth revisiting if the DataBuffer implementation
-** changes.
-*/
-static void dlcAddDoclist(DLCollector *pCollector, DataBuffer *b){
-  if( pCollector->dlw.iType>DL_DOCIDS ){
-    char c[VARINT_MAX];
-    int n = fts3PutVarint(c, POS_END);
-    dataBufferAppend2(b, pCollector->b.pData, pCollector->b.nData, c, n);
+  if( zSql ){
+    rc = sqlite3_exec(p->db, zSql, 0, 0, 0);
+    sqlite3_free(zSql);
   }else{
-    dataBufferAppend(b, pCollector->b.pData, pCollector->b.nData);
-  }
-}
-static void dlcNext(DLCollector *pCollector, sqlite_int64 iDocid){
-  plwTerminate(&pCollector->plw);
-  plwDestroy(&pCollector->plw);
-  plwInit(&pCollector->plw, &pCollector->dlw, iDocid);
-}
-static void dlcAddPos(DLCollector *pCollector, int iColumn, int iPos,
-                      int iStartOffset, int iEndOffset){
-  plwAdd(&pCollector->plw, iColumn, iPos, iStartOffset, iEndOffset);
-}
-
-static DLCollector *dlcNew(sqlite_int64 iDocid, DocListType iType){
-  DLCollector *pCollector = sqlite3_malloc(sizeof(DLCollector));
-  dataBufferInit(&pCollector->b, 0);
-  dlwInit(&pCollector->dlw, iType, &pCollector->b);
-  plwInit(&pCollector->plw, &pCollector->dlw, iDocid);
-  return pCollector;
-}
-static void dlcDelete(DLCollector *pCollector){
-  plwDestroy(&pCollector->plw);
-  dlwDestroy(&pCollector->dlw);
-  dataBufferDestroy(&pCollector->b);
-  SCRAMBLE(pCollector);
-  sqlite3_free(pCollector);
-}
-
-
-/* Copy the doclist data of iType in pData/nData into *out, trimming
-** unnecessary data as we go.  Only columns matching iColumn are
-** copied, all columns copied if iColumn is -1.  Elements with no
-** matching columns are dropped.  The output is an iOutType doclist.
-*/
-/* NOTE(shess) This code is only valid after all doclists are merged.
-** If this is run before merges, then doclist items which represent
-** deletion will be trimmed, and will thus not effect a deletion
-** during the merge.
-*/
-static void docListTrim(DocListType iType, const char *pData, int nData,
-                        int iColumn, DocListType iOutType, DataBuffer *out){
-  DLReader dlReader;
-  DLWriter dlWriter;
-
-  assert( iOutType<=iType );
-
-  dlrInit(&dlReader, iType, pData, nData);
-  dlwInit(&dlWriter, iOutType, out);
-
-  while( !dlrAtEnd(&dlReader) ){
-    PLReader plReader;
-    PLWriter plWriter;
-    int match = 0;
-
-    plrInit(&plReader, &dlReader);
-
-    while( !plrAtEnd(&plReader) ){
-      if( iColumn==-1 || plrColumn(&plReader)==iColumn ){
-        if( !match ){
-          plwInit(&plWriter, &dlWriter, dlrDocid(&dlReader));
-          match = 1;
-        }
-        plwAdd(&plWriter, plrColumn(&plReader), plrPosition(&plReader),
-               plrStartOffset(&plReader), plrEndOffset(&plReader));
-      }
-      plrStep(&plReader);
-    }
-    if( match ){
-      plwTerminate(&plWriter);
-      plwDestroy(&plWriter);
-    }
-
-    plrDestroy(&plReader);
-    dlrStep(&dlReader);
+    rc = SQLITE_NOMEM;
   }
-  dlwDestroy(&dlWriter);
-  dlrDestroy(&dlReader);
-}
 
-/* Used by docListMerge() to keep doclists in the ascending order by
-** docid, then ascending order by age (so the newest comes first).
-*/
-typedef struct OrderedDLReader {
-  DLReader *pReader;
-
-  /* TODO(shess) If we assume that docListMerge pReaders is ordered by
-  ** age (which we do), then we could use pReader comparisons to break
-  ** ties.
+  /* If everything has worked, invoke fts3DisconnectMethod() to free the
+  ** memory associated with the Fts3Table structure and return SQLITE_OK.
+  ** Otherwise, return an SQLite error code.
   */
-  int idx;
-} OrderedDLReader;
-
-/* Order eof to end, then by docid asc, idx desc. */
-static int orderedDLReaderCmp(OrderedDLReader *r1, OrderedDLReader *r2){
-  if( dlrAtEnd(r1->pReader) ){
-    if( dlrAtEnd(r2->pReader) ) return 0;  /* Both atEnd(). */
-    return 1;                              /* Only r1 atEnd(). */
-  }
-  if( dlrAtEnd(r2->pReader) ) return -1;   /* Only r2 atEnd(). */
-
-  if( dlrDocid(r1->pReader)<dlrDocid(r2->pReader) ) return -1;
-  if( dlrDocid(r1->pReader)>dlrDocid(r2->pReader) ) return 1;
-
-  /* Descending on idx. */
-  return r2->idx-r1->idx;
+  return (rc==SQLITE_OK ? fts3DisconnectMethod(pVtab) : rc);
 }
 
-/* Bubble p[0] to appropriate place in p[1..n-1].  Assumes that
-** p[1..n-1] is already sorted.
-*/
-/* TODO(shess) Is this frequent enough to warrant a binary search?
-** Before implementing that, instrument the code to check.  In most
-** current usage, I expect that p[0] will be less than p[1] a very
-** high proportion of the time.
-*/
-static void orderedDLReaderReorder(OrderedDLReader *p, int n){
-  while( n>1 && orderedDLReaderCmp(p, p+1)>0 ){
-    OrderedDLReader tmp = p[0];
-    p[0] = p[1];
-    p[1] = tmp;
-    n--;
-    p++;
-  }
-}
 
-/* Given an array of doclist readers, merge their doclist elements
-** into out in sorted order (by docid), dropping elements from older
-** readers when there is a duplicate docid.  pReaders is assumed to be
-** ordered by age, oldest first.
-*/
-/* TODO(shess) nReaders must be <= MERGE_COUNT.  This should probably
-** be fixed.
+/*
+** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table
+** passed as the first argument. This is done as part of the xConnect()
+** and xCreate() methods.
 */
-static void docListMerge(DataBuffer *out,
-                         DLReader *pReaders, int nReaders){
-  OrderedDLReader readers[MERGE_COUNT];
-  DLWriter writer;
-  int i, n;
-  const char *pStart = 0;
-  int nStart = 0;
-  sqlite_int64 iFirstDocid = 0, iLastDocid = 0;
-
-  assert( nReaders>0 );
-  if( nReaders==1 ){
-    dataBufferAppend(out, dlrDocData(pReaders), dlrAllDataBytes(pReaders));
-    return;
-  }
-
-  assert( nReaders<=MERGE_COUNT );
-  n = 0;
-  for(i=0; i<nReaders; i++){
-    assert( pReaders[i].iType==pReaders[0].iType );
-    readers[i].pReader = pReaders+i;
-    readers[i].idx = i;
-    n += dlrAllDataBytes(&pReaders[i]);
-  }
-  /* Conservatively size output to sum of inputs.  Output should end
-  ** up strictly smaller than input.
-  */
-  dataBufferExpand(out, n);
-
-  /* Get the readers into sorted order. */
-  while( i-->0 ){
-    orderedDLReaderReorder(readers+i, nReaders-i);
-  }
-
-  dlwInit(&writer, pReaders[0].iType, out);
-  while( !dlrAtEnd(readers[0].pReader) ){
-    sqlite_int64 iDocid = dlrDocid(readers[0].pReader);
-
-    /* If this is a continuation of the current buffer to copy, extend
-    ** that buffer.  memcpy() seems to be more efficient if it has a
-    ** lots of data to copy.
-    */
-    if( dlrDocData(readers[0].pReader)==pStart+nStart ){
-      nStart += dlrDocDataBytes(readers[0].pReader);
-    }else{
-      if( pStart!=0 ){
-        dlwAppend(&writer, pStart, nStart, iFirstDocid, iLastDocid);
-      }
-      pStart = dlrDocData(readers[0].pReader);
-      nStart = dlrDocDataBytes(readers[0].pReader);
-      iFirstDocid = iDocid;
-    }
-    iLastDocid = iDocid;
-    dlrStep(readers[0].pReader);
-
-    /* Drop all of the older elements with the same docid. */
-    for(i=1; i<nReaders &&
-             !dlrAtEnd(readers[i].pReader) &&
-             dlrDocid(readers[i].pReader)==iDocid; i++){
-      dlrStep(readers[i].pReader);
-    }
+static int fts3DeclareVtab(Fts3Table *p){
+  int i;                          /* Iterator variable */
+  int rc;                         /* Return code */
+  char *zSql;                     /* SQL statement passed to declare_vtab() */
+  char *zCols;                    /* List of user defined columns */
 
-    /* Get the readers back into order. */
-    while( i-->0 ){
-      orderedDLReaderReorder(readers+i, nReaders-i);
-    }
+  /* Create a list of user columns for the virtual table */
+  zCols = sqlite3_mprintf("%Q, ", p->azColumn[0]);
+  for(i=1; zCols && i<p->nColumn; i++){
+    zCols = sqlite3_mprintf("%z%Q, ", zCols, p->azColumn[i]);
   }
 
-  /* Copy over any remaining elements. */
-  if( nStart>0 ) dlwAppend(&writer, pStart, nStart, iFirstDocid, iLastDocid);
-  dlwDestroy(&writer);
-}
-
-/* Helper function for posListUnion().  Compares the current position
-** between left and right, returning as standard C idiom of <0 if
-** left<right, >0 if left>right, and 0 if left==right.  "End" always
-** compares greater.
-*/
-static int posListCmp(PLReader *pLeft, PLReader *pRight){
-  assert( pLeft->iType==pRight->iType );
-  if( pLeft->iType==DL_DOCIDS ) return 0;
-
-  if( plrAtEnd(pLeft) ) return plrAtEnd(pRight) ? 0 : 1;
-  if( plrAtEnd(pRight) ) return -1;
-
-  if( plrColumn(pLeft)<plrColumn(pRight) ) return -1;
-  if( plrColumn(pLeft)>plrColumn(pRight) ) return 1;
-
-  if( plrPosition(pLeft)<plrPosition(pRight) ) return -1;
-  if( plrPosition(pLeft)>plrPosition(pRight) ) return 1;
-  if( pLeft->iType==DL_POSITIONS ) return 0;
-
-  if( plrStartOffset(pLeft)<plrStartOffset(pRight) ) return -1;
-  if( plrStartOffset(pLeft)>plrStartOffset(pRight) ) return 1;
-
-  if( plrEndOffset(pLeft)<plrEndOffset(pRight) ) return -1;
-  if( plrEndOffset(pLeft)>plrEndOffset(pRight) ) return 1;
-
-  return 0;
-}
-
-/* Write the union of position lists in pLeft and pRight to pOut.
-** "Union" in this case meaning "All unique position tuples".  Should
-** work with any doclist type, though both inputs and the output
-** should be the same type.
-*/
-static void posListUnion(DLReader *pLeft, DLReader *pRight, DLWriter *pOut){
-  PLReader left, right;
-  PLWriter writer;
-
-  assert( dlrDocid(pLeft)==dlrDocid(pRight) );
-  assert( pLeft->iType==pRight->iType );
-  assert( pLeft->iType==pOut->iType );
-
-  plrInit(&left, pLeft);
-  plrInit(&right, pRight);
-  plwInit(&writer, pOut, dlrDocid(pLeft));
+  /* Create the whole "CREATE TABLE" statement to pass to SQLite */
+  zSql = sqlite3_mprintf(
+      "CREATE TABLE x(%s %Q HIDDEN, docid HIDDEN)", zCols, p->zName
+  );
 
-  while( !plrAtEnd(&left) || !plrAtEnd(&right) ){
-    int c = posListCmp(&left, &right);
-    if( c<0 ){
-      plwCopy(&writer, &left);
-      plrStep(&left);
-    }else if( c>0 ){
-      plwCopy(&writer, &right);
-      plrStep(&right);
-    }else{
-      plwCopy(&writer, &left);
-      plrStep(&left);
-      plrStep(&right);
-    }
+  if( !zCols || !zSql ){
+    rc = SQLITE_NOMEM;
+  }else{
+    rc = sqlite3_declare_vtab(p->db, zSql);
   }
 
-  plwTerminate(&writer);
-  plwDestroy(&writer);
-  plrDestroy(&left);
-  plrDestroy(&right);
+  sqlite3_free(zSql);
+  sqlite3_free(zCols);
+  return rc;
 }
 
-/* Write the union of doclists in pLeft and pRight to pOut.  For
-** docids in common between the inputs, the union of the position
-** lists is written.  Inputs and outputs are always type DL_DEFAULT.
+/*
+** 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.
 */
-static void docListUnion(
-  const char *pLeft, int nLeft,
-  const char *pRight, int nRight,
-  DataBuffer *pOut      /* Write the combined doclist here */
-){
-  DLReader left, right;
-  DLWriter writer;
-
-  if( nLeft==0 ){
-    if( nRight!=0) dataBufferAppend(pOut, pRight, nRight);
-    return;
-  }
-  if( nRight==0 ){
-    dataBufferAppend(pOut, pLeft, nLeft);
-    return;
-  }
-
-  dlrInit(&left, DL_DEFAULT, pLeft, nLeft);
-  dlrInit(&right, DL_DEFAULT, pRight, nRight);
-  dlwInit(&writer, DL_DEFAULT, pOut);
-
-  while( !dlrAtEnd(&left) || !dlrAtEnd(&right) ){
-    if( dlrAtEnd(&right) ){
-      dlwCopy(&writer, &left);
-      dlrStep(&left);
-    }else if( dlrAtEnd(&left) ){
-      dlwCopy(&writer, &right);
-      dlrStep(&right);
-    }else if( dlrDocid(&left)<dlrDocid(&right) ){
-      dlwCopy(&writer, &left);
-      dlrStep(&left);
-    }else if( dlrDocid(&left)>dlrDocid(&right) ){
-      dlwCopy(&writer, &right);
-      dlrStep(&right);
-    }else{
-      posListUnion(&left, &right, &writer);
-      dlrStep(&left);
-      dlrStep(&right);
-    }
-  }
-
-  dlrDestroy(&left);
-  dlrDestroy(&right);
-  dlwDestroy(&writer);
-}
-
-/* 
-** This function is used as part of the implementation of phrase and
-** NEAR matching.
-**
-** pLeft and pRight are DLReaders positioned to the same docid in
-** lists of type DL_POSITION. This function writes an entry to the
-** DLWriter pOut for each position in pRight that is less than
-** (nNear+1) greater (but not equal to or smaller) than a position 
-** in pLeft. For example, if nNear is 0, and the positions contained
-** by pLeft and pRight are:
-**
-**    pLeft:  5 10 15 20
-**    pRight: 6  9 17 21
-**
-** then the docid is added to pOut. If pOut is of type DL_POSITIONS,
-** then a positionids "6" and "21" are also added to pOut.
-**
-** If boolean argument isSaveLeft is true, then positionids are copied
-** from pLeft instead of pRight. In the example above, the positions "5"
-** and "20" would be added instead of "6" and "21".
-*/
-static void posListPhraseMerge(
-  DLReader *pLeft, 
-  DLReader *pRight,
-  int nNear,
-  int isSaveLeft,
-  DLWriter *pOut
-){
-  PLReader left, right;
-  PLWriter writer;
-  int match = 0;
-
-  assert( dlrDocid(pLeft)==dlrDocid(pRight) );
-  assert( pOut->iType!=DL_POSITIONS_OFFSETS );
-
-  plrInit(&left, pLeft);
-  plrInit(&right, pRight);
-
-  while( !plrAtEnd(&left) && !plrAtEnd(&right) ){
-    if( plrColumn(&left)<plrColumn(&right) ){
-      plrStep(&left);
-    }else if( plrColumn(&left)>plrColumn(&right) ){
-      plrStep(&right);
-    }else if( plrPosition(&left)>=plrPosition(&right) ){
-      plrStep(&right);
-    }else{
-      if( (plrPosition(&right)-plrPosition(&left))<=(nNear+1) ){
-        if( !match ){
-          plwInit(&writer, pOut, dlrDocid(pLeft));
-          match = 1;
-        }
-        if( !isSaveLeft ){
-          plwAdd(&writer, plrColumn(&right), plrPosition(&right), 0, 0);
-        }else{
-          plwAdd(&writer, plrColumn(&left), plrPosition(&left), 0, 0);
-        }
-        plrStep(&right);
-      }else{
-        plrStep(&left);
-      }
-    }
-  }
+static int fts3CreateTables(Fts3Table *p){
+  int rc;                         /* Return code */
+  int i;                          /* Iterator variable */
+  char *zContentCols;             /* Columns of %_content table */
+  char *zSql;                     /* SQL script to create required tables */
+
+  /* Create a list of user columns for the content table */
+  zContentCols = sqlite3_mprintf("docid INTEGER PRIMARY KEY");
+  for(i=0; zContentCols && i<p->nColumn; i++){
+    char *z = p->azColumn[i];
+    zContentCols = sqlite3_mprintf("%z, 'c%d%q'", zContentCols, i, z);
+  }
+
+  /* Create the whole SQL script */
+  zSql = sqlite3_mprintf(
+      "CREATE TABLE %Q.'%q_content'(%s);"
+      "CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB);"
+      "CREATE TABLE %Q.'%q_segdir'("
+        "level INTEGER,"
+        "idx INTEGER,"
+        "start_block INTEGER,"
+        "leaves_end_block INTEGER,"
+        "end_block INTEGER,"
+        "root BLOB,"
+        "PRIMARY KEY(level, idx)"
+      ");",
+      p->zDb, p->zName, zContentCols, p->zDb, p->zName, p->zDb, p->zName
+  );
 
-  if( match ){
-    plwTerminate(&writer);
-    plwDestroy(&writer);
+  /* Unless a malloc() failure has occurred, execute the SQL script to 
+  ** create the tables used to store data for this FTS3 virtual table.
+  */
+  if( zContentCols==0 || zSql==0 ){
+    rc = SQLITE_NOMEM;
+  }else{
+    rc = sqlite3_exec(p->db, zSql, 0, 0, 0);
   }
 
-  plrDestroy(&left);
-  plrDestroy(&right);
+  sqlite3_free(zSql);
+  sqlite3_free(zContentCols);
+  return rc;
 }
 
 /*
-** Compare the values pointed to by the PLReaders passed as arguments. 
-** Return -1 if the value pointed to by pLeft is considered less than
-** the value pointed to by pRight, +1 if it is considered greater
-** than it, or 0 if it is equal. i.e.
-**
-**     (*pLeft - *pRight)
-**
-** A PLReader that is in the EOF condition is considered greater than
-** any other. If neither argument is in EOF state, the return value of
-** plrColumn() is used. If the plrColumn() values are equal, the
-** comparison is on the basis of plrPosition().
-*/
-static int plrCompare(PLReader *pLeft, PLReader *pRight){
-  assert(!plrAtEnd(pLeft) || !plrAtEnd(pRight));
-
-  if( plrAtEnd(pRight) || plrAtEnd(pLeft) ){
-    return (plrAtEnd(pRight) ? -1 : 1);
-  }
-  if( plrColumn(pLeft)!=plrColumn(pRight) ){
-    return ((plrColumn(pLeft)<plrColumn(pRight)) ? -1 : 1);
-  }
-  if( plrPosition(pLeft)!=plrPosition(pRight) ){
-    return ((plrPosition(pLeft)<plrPosition(pRight)) ? -1 : 1);
-  }
-  return 0;
-}
-
-/* We have two doclists with positions:  pLeft and pRight. Depending
-** on the value of the nNear parameter, perform either a phrase
-** intersection (if nNear==0) or a NEAR intersection (if nNear>0)
-** and write the results into pOut.
-**
-** A phrase intersection means that two documents only match
-** if pLeft.iPos+1==pRight.iPos.
-**
-** A NEAR intersection means that two documents only match if 
-** (abs(pLeft.iPos-pRight.iPos)<nNear).
-**
-** If a NEAR intersection is requested, then the nPhrase argument should
-** be passed the number of tokens in the two operands to the NEAR operator
-** combined. For example:
+** This function is the implementation of both the xConnect and xCreate
+** methods of the FTS3 virtual table.
 **
-**       Query syntax               nPhrase
-**      ------------------------------------
-**       "A B C" NEAR "D E"         5
-**       A NEAR B                   2
+** The argv[] array contains the following:
 **
-** iType controls the type of data written to pOut.  If iType is
-** DL_POSITIONS, the positions are those from pRight.
-*/
-static void docListPhraseMerge(
-  const char *pLeft, int nLeft,
-  const char *pRight, int nRight,
-  int nNear,            /* 0 for a phrase merge, non-zero for a NEAR merge */
-  int nPhrase,          /* Number of tokens in left+right operands to NEAR */
-  DocListType iType,    /* Type of doclist to write to pOut */
-  DataBuffer *pOut      /* Write the combined doclist here */
+**   argv[0]   -> module name
+**   argv[1]   -> database name
+**   argv[2]   -> table name
+**   argv[...] -> "column name" and other module argument fields.
+*/
+static int fts3InitVtab(
+  int isCreate,                   /* True for xCreate, false for xConnect */
+  sqlite3 *db,                    /* The SQLite database connection */
+  void *pAux,                     /* Hash table containing tokenizers */
+  int argc,                       /* Number of elements in argv array */
+  const char * const *argv,       /* xCreate/xConnect argument array */
+  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */
+  char **pzErr                    /* Write any error message here */
 ){
-  DLReader left, right;
-  DLWriter writer;
-
-  if( nLeft==0 || nRight==0 ) return;
-
-  assert( iType!=DL_POSITIONS_OFFSETS );
+  Fts3Hash *pHash = (Fts3Hash *)pAux;
+  Fts3Table *p;                   /* Pointer to allocated vtab */
+  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;
 
-  dlrInit(&left, DL_POSITIONS, pLeft, nLeft);
-  dlrInit(&right, DL_POSITIONS, pRight, nRight);
-  dlwInit(&writer, iType, pOut);
+  const char *zTokenizer = 0;               /* Name of tokenizer to use */
+  sqlite3_tokenizer *pTokenizer = 0;        /* Tokenizer for this table */
 
-  while( !dlrAtEnd(&left) && !dlrAtEnd(&right) ){
-    if( dlrDocid(&left)<dlrDocid(&right) ){
-      dlrStep(&left);
-    }else if( dlrDocid(&right)<dlrDocid(&left) ){
-      dlrStep(&right);
-    }else{
-      if( nNear==0 ){
-        posListPhraseMerge(&left, &right, 0, 0, &writer);
-      }else{
-        /* This case occurs when two terms (simple terms or phrases) are
-         * connected by a NEAR operator, span (nNear+1). i.e.
-         *
-         *     '"terrible company" NEAR widget'
-         */
-        DataBuffer one = {0, 0, 0};
-        DataBuffer two = {0, 0, 0};
-
-        DLWriter dlwriter2;
-        DLReader dr1 = {0, 0, 0, 0, 0}; 
-        DLReader dr2 = {0, 0, 0, 0, 0};
-
-        dlwInit(&dlwriter2, iType, &one);
-        posListPhraseMerge(&right, &left, nNear-3+nPhrase, 1, &dlwriter2);
-        dlwInit(&dlwriter2, iType, &two);
-        posListPhraseMerge(&left, &right, nNear-1, 0, &dlwriter2);
-
-        if( one.nData) dlrInit(&dr1, iType, one.pData, one.nData);
-        if( two.nData) dlrInit(&dr2, iType, two.pData, two.nData);
-
-        if( !dlrAtEnd(&dr1) || !dlrAtEnd(&dr2) ){
-          PLReader pr1 = {0};
-          PLReader pr2 = {0};
-
-          PLWriter plwriter;
-          plwInit(&plwriter, &writer, dlrDocid(dlrAtEnd(&dr1)?&dr2:&dr1));
-
-          if( one.nData ) plrInit(&pr1, &dr1);
-          if( two.nData ) plrInit(&pr2, &dr2);
-          while( !plrAtEnd(&pr1) || !plrAtEnd(&pr2) ){
-            int iCompare = plrCompare(&pr1, &pr2);
-            switch( iCompare ){
-              case -1:
-                plwCopy(&plwriter, &pr1);
-                plrStep(&pr1);
-                break;
-              case 1:
-                plwCopy(&plwriter, &pr2);
-                plrStep(&pr2);
-                break;
-              case 0:
-                plwCopy(&plwriter, &pr1);
-                plrStep(&pr1);
-                plrStep(&pr2);
-                break;
-            }
-          }
-          plwTerminate(&plwriter);
-        }
-        dataBufferDestroy(&one);
-        dataBufferDestroy(&two);
-      }
-      dlrStep(&left);
-      dlrStep(&right);
+  nDb = (int)strlen(argv[1]) + 1;
+  nName = (int)strlen(argv[2]) + 1;
+  for(i=3; i<argc; i++){
+    char const *z = argv[i];
+    rc = sqlite3Fts3InitTokenizer(pHash, z, &pTokenizer, &zTokenizer, pzErr);
+    if( rc!=SQLITE_OK ){
+      return rc;
+    }
+    if( z!=zTokenizer ){
+      nString += (int)(strlen(z) + 1);
     }
   }
-
-  dlrDestroy(&left);
-  dlrDestroy(&right);
-  dlwDestroy(&writer);
-}
-
-/* We have two DL_DOCIDS doclists:  pLeft and pRight.
-** Write the intersection of these two doclists into pOut as a
-** DL_DOCIDS doclist.
-*/
-static void docListAndMerge(
-  const char *pLeft, int nLeft,
-  const char *pRight, int nRight,
-  DataBuffer *pOut      /* Write the combined doclist here */
-){
-  DLReader left, right;
-  DLWriter writer;
-
-  if( nLeft==0 || nRight==0 ) return;
-
-  dlrInit(&left, DL_DOCIDS, pLeft, nLeft);
-  dlrInit(&right, DL_DOCIDS, pRight, nRight);
-  dlwInit(&writer, DL_DOCIDS, pOut);
-
-  while( !dlrAtEnd(&left) && !dlrAtEnd(&right) ){
-    if( dlrDocid(&left)<dlrDocid(&right) ){
-      dlrStep(&left);
-    }else if( dlrDocid(&right)<dlrDocid(&left) ){
-      dlrStep(&right);
-    }else{
-      dlwAdd(&writer, dlrDocid(&left));
-      dlrStep(&left);
-      dlrStep(&right);
+  nCol = argc - 3 - (zTokenizer!=0);
+  if( zTokenizer==0 ){
+    rc = sqlite3Fts3InitTokenizer(pHash, 0, &pTokenizer, 0, pzErr);
+    if( rc!=SQLITE_OK ){
+      return rc;
     }
+    assert( pTokenizer );
   }
 
-  dlrDestroy(&left);
-  dlrDestroy(&right);
-  dlwDestroy(&writer);
-}
-
-/* We have two DL_DOCIDS doclists:  pLeft and pRight.
-** Write the union of these two doclists into pOut as a
-** DL_DOCIDS doclist.
-*/
-static void docListOrMerge(
-  const char *pLeft, int nLeft,
-  const char *pRight, int nRight,
-  DataBuffer *pOut      /* Write the combined doclist here */
-){
-  DLReader left, right;
-  DLWriter writer;
-
-  if( nLeft==0 ){
-    if( nRight!=0 ) dataBufferAppend(pOut, pRight, nRight);
-    return;
+  if( nCol==0 ){
+    nCol = 1;
   }
-  if( nRight==0 ){
-    dataBufferAppend(pOut, pLeft, nLeft);
-    return;
+
+  /* Allocate and populate the Fts3Table structure. */
+  nByte = sizeof(Fts3Table) +              /* Fts3Table */
+          nCol * sizeof(char *) +              /* azColumn */
+          nName +                              /* zName */
+          nDb +                                /* zDb */
+          nString;                             /* Space for azColumn strings */
+  p = (Fts3Table*)sqlite3_malloc(nByte);
+  if( p==0 ){
+    rc = SQLITE_NOMEM;
+    goto fts3_init_out;
   }
+  memset(p, 0, nByte);
 
-  dlrInit(&left, DL_DOCIDS, pLeft, nLeft);
-  dlrInit(&right, DL_DOCIDS, pRight, nRight);
-  dlwInit(&writer, DL_DOCIDS, pOut);
-
-  while( !dlrAtEnd(&left) || !dlrAtEnd(&right) ){
-    if( dlrAtEnd(&right) ){
-      dlwAdd(&writer, dlrDocid(&left));
-      dlrStep(&left);
-    }else if( dlrAtEnd(&left) ){
-      dlwAdd(&writer, dlrDocid(&right));
-      dlrStep(&right);
-    }else if( dlrDocid(&left)<dlrDocid(&right) ){
-      dlwAdd(&writer, dlrDocid(&left));
-      dlrStep(&left);
-    }else if( dlrDocid(&right)<dlrDocid(&left) ){
-      dlwAdd(&writer, dlrDocid(&right));
-      dlrStep(&right);
-    }else{
-      dlwAdd(&writer, dlrDocid(&left));
-      dlrStep(&left);
-      dlrStep(&right);
+  p->db = db;
+  p->nColumn = nCol;
+  p->nPendingData = 0;
+  p->azColumn = (char **)&p[1];
+  p->pTokenizer = pTokenizer;
+  p->nNodeSize = 1000;
+  p->nMaxPendingData = FTS3_MAX_PENDING_DATA;
+  zCsr = (char *)&p->azColumn[nCol];
+
+  fts3HashInit(&p->pendingTerms, FTS3_HASH_STRING, 1);
+
+  /* Fill in the zName and zDb fields of the vtab structure. */
+  p->zName = zCsr;
+  memcpy(zCsr, argv[2], nName);
+  zCsr += nName;
+  p->zDb = zCsr;
+  memcpy(zCsr, argv[1], nDb);
+  zCsr += nDb;
+
+  /* Fill in the azColumn array */
+  iCol = 0;
+  for(i=3; i<argc; i++){
+    if( argv[i]!=zTokenizer ){
+      char *z; 
+      int n;
+      z = (char *)sqlite3Fts3NextToken(argv[i], &n);
+      memcpy(zCsr, z, n);
+      zCsr[n] = '\0';
+      sqlite3Fts3Dequote(zCsr);
+      p->azColumn[iCol++] = zCsr;
+      zCsr += n+1;
+      assert( zCsr <= &((char *)p)[nByte] );
     }
   }
-
-  dlrDestroy(&left);
-  dlrDestroy(&right);
-  dlwDestroy(&writer);
-}
-
-/* We have two DL_DOCIDS doclists:  pLeft and pRight.
-** Write into pOut as DL_DOCIDS doclist containing all documents that
-** occur in pLeft but not in pRight.
-*/
-static void docListExceptMerge(
-  const char *pLeft, int nLeft,
-  const char *pRight, int nRight,
-  DataBuffer *pOut      /* Write the combined doclist here */
-){
-  DLReader left, right;
-  DLWriter writer;
-
-  if( nLeft==0 ) return;
-  if( nRight==0 ){
-    dataBufferAppend(pOut, pLeft, nLeft);
-    return;
+  if( iCol==0 ){
+    assert( nCol==1 );
+    p->azColumn[0] = "content";
   }
 
-  dlrInit(&left, DL_DOCIDS, pLeft, nLeft);
-  dlrInit(&right, DL_DOCIDS, pRight, nRight);
-  dlwInit(&writer, DL_DOCIDS, pOut);
-
-  while( !dlrAtEnd(&left) ){
-    while( !dlrAtEnd(&right) && dlrDocid(&right)<dlrDocid(&left) ){
-      dlrStep(&right);
-    }
-    if( dlrAtEnd(&right) || dlrDocid(&left)<dlrDocid(&right) ){
-      dlwAdd(&writer, dlrDocid(&left));
-    }
-    dlrStep(&left);
+  /* If this is an xCreate call, create the underlying tables in the 
+  ** database. TODO: For xConnect(), it could verify that said tables exist.
+  */
+  if( isCreate ){
+    rc = fts3CreateTables(p);
+    if( rc!=SQLITE_OK ) goto fts3_init_out;
   }
 
-  dlrDestroy(&left);
-  dlrDestroy(&right);
-  dlwDestroy(&writer);
-}
-
-static char *string_dup_n(const char *s, int n){
-  char *str = sqlite3_malloc(n + 1);
-  memcpy(str, s, n);
-  str[n] = '\0';
-  return str;
-}
-
-/* Duplicate a string; the caller must free() the returned string.
- * (We don't use strdup() since it is not part of the standard C library and
- * may not be available everywhere.) */
-static char *string_dup(const char *s){
-  return string_dup_n(s, strlen(s));
-}
+  rc = fts3DeclareVtab(p);
+  if( rc!=SQLITE_OK ) goto fts3_init_out;
 
-/* Format a string, replacing each occurrence of the % character with
- * zDb.zName.  This may be more convenient than sqlite_mprintf()
- * when one string is used repeatedly in a format string.
- * The caller must free() the returned string. */
-static char *string_format(const char *zFormat,
-                           const char *zDb, const char *zName){
-  const char *p;
-  size_t len = 0;
-  size_t nDb = strlen(zDb);
-  size_t nName = strlen(zName);
-  size_t nFullTableName = nDb+1+nName;
-  char *result;
-  char *r;
+  *ppVTab = &p->base;
 
-  /* first compute length needed */
-  for(p = zFormat ; *p ; ++p){
-    len += (*p=='%' ? nFullTableName : 1);
-  }
-  len += 1;  /* for null terminator */
-
-  r = result = sqlite3_malloc(len);
-  for(p = zFormat; *p; ++p){
-    if( *p=='%' ){
-      memcpy(r, zDb, nDb);
-      r += nDb;
-      *r++ = '.';
-      memcpy(r, zName, nName);
-      r += nName;
-    } else {
-      *r++ = *p;
+fts3_init_out:
+  assert( p || (pTokenizer && rc!=SQLITE_OK) );
+  if( rc!=SQLITE_OK ){
+    if( p ){
+      fts3DisconnectMethod((sqlite3_vtab *)p);
+    }else{
+      pTokenizer->pModule->xDestroy(pTokenizer);
     }
   }
-  *r++ = '\0';
-  assert( r == result + len );
-  return result;
-}
-
-static int sql_exec(sqlite3 *db, const char *zDb, const char *zName,
-                    const char *zFormat){
-  char *zCommand = string_format(zFormat, zDb, zName);
-  int rc;
-  FTSTRACE(("FTS3 sql: %s\n", zCommand));
-  rc = sqlite3_exec(db, zCommand, NULL, 0, NULL);
-  sqlite3_free(zCommand);
   return rc;
 }
 
-static int sql_prepare(sqlite3 *db, const char *zDb, const char *zName,
-                       sqlite3_stmt **ppStmt, const char *zFormat){
-  char *zCommand = string_format(zFormat, zDb, zName);
-  int rc;
-  FTSTRACE(("FTS3 prepare: %s\n", zCommand));
-  rc = sqlite3_prepare_v2(db, zCommand, -1, ppStmt, NULL);
-  sqlite3_free(zCommand);
-  return rc;
-}
-
-/* end utility functions */
-
-/* Forward reference */
-typedef struct fulltext_vtab fulltext_vtab;
-
-/*
-** An instance of the following structure keeps track of generated
-** matching-word offset information and snippets.
-*/
-typedef struct Snippet {
-  int nMatch;     /* Total number of matches */
-  int nAlloc;     /* Space allocated for aMatch[] */
-  struct snippetMatch { /* One entry for each matching term */
-    char snStatus;       /* Status flag for use while constructing snippets */
-    short int iCol;      /* The column that contains the match */
-    short int iTerm;     /* The index in Query.pTerms[] of the matching term */
-    int iToken;          /* The index of the matching document token */
-    short int nByte;     /* Number of bytes in the term */
-    int iStart;          /* The offset to the first character of the term */
-  } *aMatch;      /* Points to space obtained from malloc */
-  char *zOffset;  /* Text rendering of aMatch[] */
-  int nOffset;    /* strlen(zOffset) */
-  char *zSnippet; /* Snippet text */
-  int nSnippet;   /* strlen(zSnippet) */
-} Snippet;
-
-
-typedef enum QueryType {
-  QUERY_GENERIC,   /* table scan */
-  QUERY_DOCID,     /* lookup by docid */
-  QUERY_FULLTEXT   /* QUERY_FULLTEXT + [i] is a full-text search for column i*/
-} QueryType;
-
-typedef enum fulltext_statement {
-  CONTENT_INSERT_STMT,
-  CONTENT_SELECT_STMT,
-  CONTENT_UPDATE_STMT,
-  CONTENT_DELETE_STMT,
-  CONTENT_EXISTS_STMT,
-
-  BLOCK_INSERT_STMT,
-  BLOCK_SELECT_STMT,
-  BLOCK_DELETE_STMT,
-  BLOCK_DELETE_ALL_STMT,
-
-  SEGDIR_MAX_INDEX_STMT,
-  SEGDIR_SET_STMT,
-  SEGDIR_SELECT_LEVEL_STMT,
-  SEGDIR_SPAN_STMT,
-  SEGDIR_DELETE_STMT,
-  SEGDIR_SELECT_SEGMENT_STMT,
-  SEGDIR_SELECT_ALL_STMT,
-  SEGDIR_DELETE_ALL_STMT,
-  SEGDIR_COUNT_STMT,
-
-  MAX_STMT                     /* Always at end! */
-} fulltext_statement;
-
-/* These must exactly match the enum above. */
-/* TODO(shess): Is there some risk that a statement will be used in two
-** cursors at once, e.g.  if a query joins a virtual table to itself?
-** If so perhaps we should move some of these to the cursor object.
-*/
-static const char *const fulltext_zStatement[MAX_STMT] = {
-  /* CONTENT_INSERT */ NULL,  /* generated in contentInsertStatement() */
-  /* CONTENT_SELECT */ NULL,  /* generated in contentSelectStatement() */
-  /* CONTENT_UPDATE */ NULL,  /* generated in contentUpdateStatement() */
-  /* CONTENT_DELETE */ "delete from %_content where docid = ?",
-  /* CONTENT_EXISTS */ "select docid from %_content limit 1",
-
-  /* BLOCK_INSERT */
-  "insert into %_segments (blockid, block) values (null, ?)",
-  /* BLOCK_SELECT */ "select block from %_segments where blockid = ?",
-  /* BLOCK_DELETE */ "delete from %_segments where blockid between ? and ?",
-  /* BLOCK_DELETE_ALL */ "delete from %_segments",
-
-  /* SEGDIR_MAX_INDEX */ "select max(idx) from %_segdir where level = ?",
-  /* SEGDIR_SET */ "insert into %_segdir values (?, ?, ?, ?, ?, ?)",
-  /* SEGDIR_SELECT_LEVEL */
-  "select start_block, leaves_end_block, root from %_segdir "
-  " where level = ? order by idx",
-  /* SEGDIR_SPAN */
-  "select min(start_block), max(end_block) from %_segdir "
-  " where level = ? and start_block <> 0",
-  /* SEGDIR_DELETE */ "delete from %_segdir where level = ?",
-
-  /* NOTE(shess): The first three results of the following two
-  ** statements must match.
-  */
-  /* SEGDIR_SELECT_SEGMENT */
-  "select start_block, leaves_end_block, root from %_segdir "
-  " where level = ? and idx = ?",
-  /* SEGDIR_SELECT_ALL */
-  "select start_block, leaves_end_block, root from %_segdir "
-  " order by level desc, idx asc",
-  /* SEGDIR_DELETE_ALL */ "delete from %_segdir",
-  /* SEGDIR_COUNT */ "select count(*), ifnull(max(level),0) from %_segdir",
-};
-
-/*
-** A connection to a fulltext index is an instance of the following
-** structure.  The xCreate and xConnect methods create an instance
-** of this structure and xDestroy and xDisconnect free that instance.
-** All other methods receive a pointer to the structure as one of their
-** arguments.
-*/
-struct fulltext_vtab {
-  sqlite3_vtab base;               /* Base class used by SQLite core */
-  sqlite3 *db;                     /* The database connection */
-  const char *zDb;                 /* logical database name */
-  const char *zName;               /* virtual table name */
-  int nColumn;                     /* number of columns in virtual table */
-  char **azColumn;                 /* column names.  malloced */
-  char **azContentColumn;          /* column names in content table; malloced */
-  sqlite3_tokenizer *pTokenizer;   /* tokenizer for inserts and queries */
-
-  /* Precompiled statements which we keep as long as the table is
-  ** open.
-  */
-  sqlite3_stmt *pFulltextStatements[MAX_STMT];
-
-  /* Precompiled statements used for segment merges.  We run a
-  ** separate select across the leaf level of each tree being merged.
-  */
-  sqlite3_stmt *pLeafSelectStmts[MERGE_COUNT];
-  /* The statement used to prepare pLeafSelectStmts. */
-#define LEAF_SELECT \
-  "select block from %_segments where blockid between ? and ? order by blockid"
-
-  /* These buffer pending index updates during transactions.
-  ** nPendingData estimates the memory size of the pending data.  It
-  ** doesn't include the hash-bucket overhead, nor any malloc
-  ** overhead.  When nPendingData exceeds kPendingThreshold, the
-  ** buffer is flushed even before the transaction closes.
-  ** pendingTerms stores the data, and is only valid when nPendingData
-  ** is >=0 (nPendingData<0 means pendingTerms has not been
-  ** initialized).  iPrevDocid is the last docid written, used to make
-  ** certain we're inserting in sorted order.
-  */
-  int nPendingData;
-#define kPendingThreshold (1*1024*1024)
-  sqlite_int64 iPrevDocid;
-  fts3Hash pendingTerms;
-};
-
 /*
-** When the core wants to do a query, it create a cursor using a
-** call to xOpen.  This structure is an instance of a cursor.  It
-** is destroyed by xClose.
+** The xConnect() and xCreate() methods for the virtual table. All the
+** work is done in function fts3InitVtab().
 */
-typedef struct fulltext_cursor {
-  sqlite3_vtab_cursor base;        /* Base class used by SQLite core */
-  QueryType iCursorType;           /* Copy of sqlite3_index_info.idxNum */
-  sqlite3_stmt *pStmt;             /* Prepared statement in use by the cursor */
-  int eof;                         /* True if at End Of Results */
-  Fts3Expr *pExpr;                 /* Parsed MATCH query string */
-  Snippet snippet;                 /* Cached snippet for the current row */
-  int iColumn;                     /* Column being searched */
-  DataBuffer result;               /* Doclist results from fulltextQuery */
-  DLReader reader;                 /* Result reader if result not empty */
-} fulltext_cursor;
-
-static fulltext_vtab *cursor_vtab(fulltext_cursor *c){
-  return (fulltext_vtab *) c->base.pVtab;
-}
-
-static const sqlite3_module fts3Module;   /* forward declaration */
-
-/* Return a dynamically generated statement of the form
- *   insert into %_content (docid, ...) values (?, ...)
- */
-static const char *contentInsertStatement(fulltext_vtab *v){
-  StringBuffer sb;
-  int i;
-
-  initStringBuffer(&sb);
-  append(&sb, "insert into %_content (docid, ");
-  appendList(&sb, v->nColumn, v->azContentColumn);
-  append(&sb, ") values (?");
-  for(i=0; i<v->nColumn; ++i)
-    append(&sb, ", ?");
-  append(&sb, ")");
-  return stringBufferData(&sb);
+static int fts3ConnectMethod(
+  sqlite3 *db,                    /* Database connection */
+  void *pAux,                     /* Pointer to tokenizer hash table */
+  int argc,                       /* Number of elements in argv array */
+  const char * const *argv,       /* xCreate/xConnect argument array */
+  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */
+  char **pzErr                    /* OUT: sqlite3_malloc'd error message */
+){
+  return fts3InitVtab(0, db, pAux, argc, argv, ppVtab, pzErr);
+}
+static int fts3CreateMethod(
+  sqlite3 *db,                    /* Database connection */
+  void *pAux,                     /* Pointer to tokenizer hash table */
+  int argc,                       /* Number of elements in argv array */
+  const char * const *argv,       /* xCreate/xConnect argument array */
+  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */
+  char **pzErr                    /* OUT: sqlite3_malloc'd error message */
+){
+  return fts3InitVtab(1, db, pAux, argc, argv, ppVtab, pzErr);
 }
 
-/* Return a dynamically generated statement of the form
- *   select <content columns> from %_content where docid = ?
- */
-static const char *contentSelectStatement(fulltext_vtab *v){
-  StringBuffer sb;
-  initStringBuffer(&sb);
-  append(&sb, "SELECT ");
-  appendList(&sb, v->nColumn, v->azContentColumn);
-  append(&sb, " FROM %_content WHERE docid = ?");
-  return stringBufferData(&sb);
-}
+/* 
+** Implementation of the xBestIndex method for FTS3 tables. There
+** are three possible strategies, in order of preference:
+**
+**   1. Direct lookup by rowid or docid. 
+**   2. Full-text search using a MATCH operator on a non-docid column.
+**   3. Linear scan of %_content table.
+*/
+static int fts3BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
+  Fts3Table *p = (Fts3Table *)pVTab;
+  int i;                          /* Iterator variable */
+  int iCons = -1;                 /* Index of constraint to use */
 
-/* Return a dynamically generated statement of the form
- *   update %_content set [col_0] = ?, [col_1] = ?, ...
- *                    where docid = ?
- */
-static const char *contentUpdateStatement(fulltext_vtab *v){
-  StringBuffer sb;
-  int i;
+  /* By default use a full table scan. This is an expensive option,
+  ** so search through the constraints to see if a more efficient 
+  ** strategy is possible.
+  */
+  pInfo->idxNum = FTS3_FULLSCAN_SEARCH;
+  pInfo->estimatedCost = 500000;
+  for(i=0; i<pInfo->nConstraint; i++){
+    struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];
+    if( pCons->usable==0 ) continue;
 
-  initStringBuffer(&sb);
-  append(&sb, "update %_content set ");
-  for(i=0; i<v->nColumn; ++i) {
-    if( i>0 ){
-      append(&sb, ", ");
+    /* A direct lookup on the rowid or docid column. Assign a cost of 1.0. */
+    if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ 
+     && (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1 )
+    ){
+      pInfo->idxNum = FTS3_DOCID_SEARCH;
+      pInfo->estimatedCost = 1.0;
+      iCons = i;
     }
-    append(&sb, v->azContentColumn[i]);
-    append(&sb, " = ?");
-  }
-  append(&sb, " where docid = ?");
-  return stringBufferData(&sb);
-}
 
-/* Puts a freshly-prepared statement determined by iStmt in *ppStmt.
-** If the indicated statement has never been prepared, it is prepared
-** and cached, otherwise the cached version is reset.
-*/
-static int sql_get_statement(fulltext_vtab *v, fulltext_statement iStmt,
-                             sqlite3_stmt **ppStmt){
-  assert( iStmt<MAX_STMT );
-  if( v->pFulltextStatements[iStmt]==NULL ){
-    const char *zStmt;
-    int rc;
-    switch( iStmt ){
-      case CONTENT_INSERT_STMT:
-        zStmt = contentInsertStatement(v); break;
-      case CONTENT_SELECT_STMT:
-        zStmt = contentSelectStatement(v); break;
-      case CONTENT_UPDATE_STMT:
-        zStmt = contentUpdateStatement(v); break;
-      default:
-        zStmt = fulltext_zStatement[iStmt];
+    /* A MATCH constraint. Use a full-text search.
+    **
+    ** If there is more than one MATCH constraint available, use the first
+    ** one encountered. If there is both a MATCH constraint and a direct
+    ** rowid/docid lookup, prefer the MATCH strategy. This is done even 
+    ** though the rowid/docid lookup is faster than a MATCH query, selecting
+    ** it would lead to an "unable to use function MATCH in the requested 
+    ** context" error.
+    */
+    if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH 
+     && pCons->iColumn>=0 && pCons->iColumn<=p->nColumn
+    ){
+      pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn;
+      pInfo->estimatedCost = 2.0;
+      iCons = i;
+      break;
     }
-    rc = sql_prepare(v->db, v->zDb, v->zName, &v->pFulltextStatements[iStmt],
-                         zStmt);
-    if( zStmt != fulltext_zStatement[iStmt]) sqlite3_free((void *) zStmt);
-    if( rc!=SQLITE_OK ) return rc;
-  } else {
-    int rc = sqlite3_reset(v->pFulltextStatements[iStmt]);
-    if( rc!=SQLITE_OK ) return rc;
-  }
-
-  *ppStmt = v->pFulltextStatements[iStmt];
-  return SQLITE_OK;
-}
-
-/* Like sqlite3_step(), but convert SQLITE_DONE to SQLITE_OK and
-** SQLITE_ROW to SQLITE_ERROR.  Useful for statements like UPDATE,
-** where we expect no results.
-*/
-static int sql_single_step(sqlite3_stmt *s){
-  int rc = sqlite3_step(s);
-  return (rc==SQLITE_DONE) ? SQLITE_OK : rc;
-}
-
-/* Like sql_get_statement(), but for special replicated LEAF_SELECT
-** statements.  idx -1 is a special case for an uncached version of
-** the statement (used in the optimize implementation).
-*/
-/* TODO(shess) Write version for generic statements and then share
-** that between the cached-statement functions.
-*/
-static int sql_get_leaf_statement(fulltext_vtab *v, int idx,
-                                  sqlite3_stmt **ppStmt){
-  assert( idx>=-1 && idx<MERGE_COUNT );
-  if( idx==-1 ){
-    return sql_prepare(v->db, v->zDb, v->zName, ppStmt, LEAF_SELECT);
-  }else if( v->pLeafSelectStmts[idx]==NULL ){
-    int rc = sql_prepare(v->db, v->zDb, v->zName, &v->pLeafSelectStmts[idx],
-                         LEAF_SELECT);
-    if( rc!=SQLITE_OK ) return rc;
-  }else{
-    int rc = sqlite3_reset(v->pLeafSelectStmts[idx]);
-    if( rc!=SQLITE_OK ) return rc;
   }
 
-  *ppStmt = v->pLeafSelectStmts[idx];
+  if( iCons>=0 ){
+    pInfo->aConstraintUsage[iCons].argvIndex = 1;
+    pInfo->aConstraintUsage[iCons].omit = 1;
+  } 
   return SQLITE_OK;
 }
 
-/* insert into %_content (docid, ...) values ([docid], [pValues])
-** If the docid contains SQL NULL, then a unique docid will be
-** generated.
+/*
+** Implementation of xOpen method.
 */
-static int content_insert(fulltext_vtab *v, sqlite3_value *docid,
-                          sqlite3_value **pValues){
-  sqlite3_stmt *s;
-  int i;
-  int rc = sql_get_statement(v, CONTENT_INSERT_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
+static int fts3OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){
+  sqlite3_vtab_cursor *pCsr;               /* Allocated cursor */
 
-  rc = sqlite3_bind_value(s, 1, docid);
-  if( rc!=SQLITE_OK ) return rc;
+  UNUSED_PARAMETER(pVTab);
 
-  for(i=0; i<v->nColumn; ++i){
-    rc = sqlite3_bind_value(s, 2+i, pValues[i]);
-    if( rc!=SQLITE_OK ) return rc;
+  /* Allocate a buffer large enough for an Fts3Cursor structure. If the
+  ** allocation succeeds, zero it and return SQLITE_OK. Otherwise, 
+  ** if the allocation fails, return SQLITE_NOMEM.
+  */
+  *ppCsr = pCsr = (sqlite3_vtab_cursor *)sqlite3_malloc(sizeof(Fts3Cursor));
+  if( !pCsr ){
+    return SQLITE_NOMEM;
   }
-
-  return sql_single_step(s);
+  memset(pCsr, 0, sizeof(Fts3Cursor));
+  return SQLITE_OK;
 }
 
-/* update %_content set col0 = pValues[0], col1 = pValues[1], ...
- *                  where docid = [iDocid] */
-static int content_update(fulltext_vtab *v, sqlite3_value **pValues,
-                          sqlite_int64 iDocid){
-  sqlite3_stmt *s;
-  int i;
-  int rc = sql_get_statement(v, CONTENT_UPDATE_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  for(i=0; i<v->nColumn; ++i){
-    rc = sqlite3_bind_value(s, 1+i, pValues[i]);
-    if( rc!=SQLITE_OK ) return rc;
-  }
-
-  rc = sqlite3_bind_int64(s, 1+v->nColumn, iDocid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  return sql_single_step(s);
-}
+/****************************************************************/
+/****************************************************************/
+/****************************************************************/
+/****************************************************************/
 
-static void freeStringArray(int nString, const char **pString){
-  int i;
 
-  for (i=0 ; i < nString ; ++i) {
-    if( pString[i]!=NULL ) sqlite3_free((void *) pString[i]);
-  }
-  sqlite3_free((void *) pString);
+/*
+** Close the cursor.  For additional information see the documentation
+** on the xClose method of the virtual table interface.
+*/
+static int fulltextClose(sqlite3_vtab_cursor *pCursor){
+  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
+  sqlite3_finalize(pCsr->pStmt);
+  sqlite3Fts3ExprFree(pCsr->pExpr);
+  sqlite3_free(pCsr->aDoclist);
+  sqlite3_free(pCsr->aMatchinfo);
+  sqlite3_free(pCsr);
+  return SQLITE_OK;
 }
 
-/* select * from %_content where docid = [iDocid]
- * The caller must delete the returned array and all strings in it.
- * null fields will be NULL in the returned array.
- *
- * TODO: Perhaps we should return pointer/length strings here for consistency
- * with other code which uses pointer/length. */
-static int content_select(fulltext_vtab *v, sqlite_int64 iDocid,
-                          const char ***pValues){
-  sqlite3_stmt *s;
-  const char **values;
-  int i;
-  int rc;
-
-  *pValues = NULL;
-
-  rc = sql_get_statement(v, CONTENT_SELECT_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int64(s, 1, iDocid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_step(s);
-  if( rc!=SQLITE_ROW ) return rc;
-
-  values = (const char **) sqlite3_malloc(v->nColumn * sizeof(const char *));
-  for(i=0; i<v->nColumn; ++i){
-    if( sqlite3_column_type(s, i)==SQLITE_NULL ){
-      values[i] = NULL;
+static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){
+  if( pCsr->isRequireSeek ){
+    pCsr->isRequireSeek = 0;
+    sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);
+    if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){
+      return SQLITE_OK;
     }else{
-      values[i] = string_dup((char*)sqlite3_column_text(s, i));
+      int rc = sqlite3_reset(pCsr->pStmt);
+      if( rc==SQLITE_OK ){
+        /* If no row was found and no error has occured, then the %_content
+        ** table is missing a row that is present in the full-text index.
+        ** The data structures are corrupt.
+        */
+        rc = SQLITE_CORRUPT;
+      }
+      pCsr->isEof = 1;
+      if( pContext ){
+        sqlite3_result_error_code(pContext, rc);
+      }
+      return rc;
     }
-  }
-
-  /* We expect only one row.  We must execute another sqlite3_step()
-   * to complete the iteration; otherwise the table will remain locked. */
-  rc = sqlite3_step(s);
-  if( rc==SQLITE_DONE ){
-    *pValues = values;
+  }else{
     return SQLITE_OK;
   }
-
-  freeStringArray(v->nColumn, values);
-  return rc;
-}
-
-/* delete from %_content where docid = [iDocid ] */
-static int content_delete(fulltext_vtab *v, sqlite_int64 iDocid){
-  sqlite3_stmt *s;
-  int rc = sql_get_statement(v, CONTENT_DELETE_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int64(s, 1, iDocid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  return sql_single_step(s);
 }
 
-/* Returns SQLITE_ROW if any rows exist in %_content, SQLITE_DONE if
-** no rows exist, and any error in case of failure.
-*/
-static int content_exists(fulltext_vtab *v){
-  sqlite3_stmt *s;
-  int rc = sql_get_statement(v, CONTENT_EXISTS_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_step(s);
-  if( rc!=SQLITE_ROW ) return rc;
+static int fts3NextMethod(sqlite3_vtab_cursor *pCursor){
+  int rc = SQLITE_OK;             /* Return code */
+  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
 
-  /* We expect only one row.  We must execute another sqlite3_step()
-   * to complete the iteration; otherwise the table will remain locked. */
-  rc = sqlite3_step(s);
-  if( rc==SQLITE_DONE ) return SQLITE_ROW;
-  if( rc==SQLITE_ROW ) return SQLITE_ERROR;
+  if( pCsr->aDoclist==0 ){
+    if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){
+      pCsr->isEof = 1;
+      rc = sqlite3_reset(pCsr->pStmt);
+    }
+  }else if( pCsr->pNextId>=&pCsr->aDoclist[pCsr->nDoclist] ){
+    pCsr->isEof = 1;
+  }else{
+    sqlite3_reset(pCsr->pStmt);
+    fts3GetDeltaVarint(&pCsr->pNextId, &pCsr->iPrevId);
+    pCsr->isRequireSeek = 1;
+    pCsr->isMatchinfoOk = 1;
+  }
   return rc;
 }
 
-/* insert into %_segments values ([pData])
-**   returns assigned blockid in *piBlockid
-*/
-static int block_insert(fulltext_vtab *v, const char *pData, int nData,
-                        sqlite_int64 *piBlockid){
-  sqlite3_stmt *s;
-  int rc = sql_get_statement(v, BLOCK_INSERT_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_blob(s, 1, pData, nData, SQLITE_STATIC);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_step(s);
-  if( rc==SQLITE_ROW ) return SQLITE_ERROR;
-  if( rc!=SQLITE_DONE ) return rc;
-
-  /* blockid column is an alias for rowid. */
-  *piBlockid = sqlite3_last_insert_rowid(v->db);
-  return SQLITE_OK;
-}
 
-/* delete from %_segments
-**   where blockid between [iStartBlockid] and [iEndBlockid]
+/*
+** The buffer pointed to by argument zNode (size nNode bytes) contains the
+** root node of a b-tree segment. The segment is guaranteed to be at least
+** one level high (i.e. the root node is not also a leaf). If successful,
+** this function locates the leaf node of the segment that may contain the 
+** term specified by arguments zTerm and nTerm and writes its block number 
+** to *piLeaf.
 **
-** Deletes the range of blocks, inclusive, used to delete the blocks
-** which form a segment.
-*/
-static int block_delete(fulltext_vtab *v,
-                        sqlite_int64 iStartBlockid, sqlite_int64 iEndBlockid){
-  sqlite3_stmt *s;
-  int rc = sql_get_statement(v, BLOCK_DELETE_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int64(s, 1, iStartBlockid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int64(s, 2, iEndBlockid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  return sql_single_step(s);
-}
-
-/* Returns SQLITE_ROW with *pidx set to the maximum segment idx found
-** at iLevel.  Returns SQLITE_DONE if there are no segments at
-** iLevel.  Otherwise returns an error.
-*/
-static int segdir_max_index(fulltext_vtab *v, int iLevel, int *pidx){
-  sqlite3_stmt *s;
-  int rc = sql_get_statement(v, SEGDIR_MAX_INDEX_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int(s, 1, iLevel);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_step(s);
-  /* Should always get at least one row due to how max() works. */
-  if( rc==SQLITE_DONE ) return SQLITE_DONE;
-  if( rc!=SQLITE_ROW ) return rc;
-
-  /* NULL means that there were no inputs to max(). */
-  if( SQLITE_NULL==sqlite3_column_type(s, 0) ){
-    rc = sqlite3_step(s);
-    if( rc==SQLITE_ROW ) return SQLITE_ERROR;
-    return rc;
-  }
-
-  *pidx = sqlite3_column_int(s, 0);
-
-  /* We expect only one row.  We must execute another sqlite3_step()
-   * to complete the iteration; otherwise the table will remain locked. */
-  rc = sqlite3_step(s);
-  if( rc==SQLITE_ROW ) return SQLITE_ERROR;
-  if( rc!=SQLITE_DONE ) return rc;
-  return SQLITE_ROW;
-}
-
-/* insert into %_segdir values (
-**   [iLevel], [idx],
-**   [iStartBlockid], [iLeavesEndBlockid], [iEndBlockid],
-**   [pRootData]
-** )
-*/
-static int segdir_set(fulltext_vtab *v, int iLevel, int idx,
-                      sqlite_int64 iStartBlockid,
-                      sqlite_int64 iLeavesEndBlockid,
-                      sqlite_int64 iEndBlockid,
-                      const char *pRootData, int nRootData){
-  sqlite3_stmt *s;
-  int rc = sql_get_statement(v, SEGDIR_SET_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int(s, 1, iLevel);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int(s, 2, idx);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int64(s, 3, iStartBlockid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int64(s, 4, iLeavesEndBlockid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int64(s, 5, iEndBlockid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_blob(s, 6, pRootData, nRootData, SQLITE_STATIC);
-  if( rc!=SQLITE_OK ) return rc;
-
-  return sql_single_step(s);
-}
-
-/* Queries %_segdir for the block span of the segments in level
-** iLevel.  Returns SQLITE_DONE if there are no blocks for iLevel,
-** SQLITE_ROW if there are blocks, else an error.
-*/
-static int segdir_span(fulltext_vtab *v, int iLevel,
-                       sqlite_int64 *piStartBlockid,
-                       sqlite_int64 *piEndBlockid){
-  sqlite3_stmt *s;
-  int rc = sql_get_statement(v, SEGDIR_SPAN_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int(s, 1, iLevel);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_step(s);
-  if( rc==SQLITE_DONE ) return SQLITE_DONE;  /* Should never happen */
-  if( rc!=SQLITE_ROW ) return rc;
-
-  /* This happens if all segments at this level are entirely inline. */
-  if( SQLITE_NULL==sqlite3_column_type(s, 0) ){
-    /* We expect only one row.  We must execute another sqlite3_step()
-     * to complete the iteration; otherwise the table will remain locked. */
-    int rc2 = sqlite3_step(s);
-    if( rc2==SQLITE_ROW ) return SQLITE_ERROR;
-    return rc2;
-  }
-
-  *piStartBlockid = sqlite3_column_int64(s, 0);
-  *piEndBlockid = sqlite3_column_int64(s, 1);
-
-  /* We expect only one row.  We must execute another sqlite3_step()
-   * to complete the iteration; otherwise the table will remain locked. */
-  rc = sqlite3_step(s);
-  if( rc==SQLITE_ROW ) return SQLITE_ERROR;
-  if( rc!=SQLITE_DONE ) return rc;
-  return SQLITE_ROW;
-}
-
-/* Delete the segment blocks and segment directory records for all
-** segments at iLevel.
-*/
-static int segdir_delete(fulltext_vtab *v, int iLevel){
-  sqlite3_stmt *s;
-  sqlite_int64 iStartBlockid, iEndBlockid;
-  int rc = segdir_span(v, iLevel, &iStartBlockid, &iEndBlockid);
-  if( rc!=SQLITE_ROW && rc!=SQLITE_DONE ) return rc;
-
-  if( rc==SQLITE_ROW ){
-    rc = block_delete(v, iStartBlockid, iEndBlockid);
-    if( rc!=SQLITE_OK ) return rc;
-  }
-
-  /* Delete the segment directory itself. */
-  rc = sql_get_statement(v, SEGDIR_DELETE_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int64(s, 1, iLevel);
-  if( rc!=SQLITE_OK ) return rc;
-
-  return sql_single_step(s);
-}
-
-/* Delete entire fts index, SQLITE_OK on success, relevant error on
-** failure.
-*/
-static int segdir_delete_all(fulltext_vtab *v){
-  sqlite3_stmt *s;
-  int rc = sql_get_statement(v, SEGDIR_DELETE_ALL_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sql_single_step(s);
-  if( rc!=SQLITE_OK ) return rc;
+** It is possible that the returned leaf node does not contain the specified
+** term. However, if the segment does contain said term, it is stored on
+** the identified leaf node. Because this function only inspects interior
+** segment nodes (and never loads leaf nodes into memory), it is not possible
+** to be sure.
+**
+** If an error occurs, an error code other than SQLITE_OK is returned.
+*/ 
+static int fts3SelectLeaf(
+  Fts3Table *p,                   /* Virtual table handle */
+  const char *zTerm,              /* Term to select leaves for */
+  int nTerm,                      /* Size of term zTerm in bytes */
+  const char *zNode,              /* Buffer containing segment interior node */
+  int nNode,                      /* Size of buffer at zNode */
+  sqlite3_int64 *piLeaf           /* Selected leaf node */
+){
+  int rc = SQLITE_OK;             /* Return code */
+  const char *zCsr = zNode;       /* Cursor to iterate through node */
+  const char *zEnd = &zCsr[nNode];/* End of interior node buffer */
+  char *zBuffer = 0;              /* Buffer to load terms into */
+  int nAlloc = 0;                 /* Size of allocated buffer */
 
-  rc = sql_get_statement(v, BLOCK_DELETE_ALL_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
+  while( 1 ){
+    int isFirstTerm = 1;          /* True when processing first term on page */
+    int iHeight;                  /* Height of this node in tree */
+    sqlite3_int64 iChild;         /* Block id of child node to descend to */
+    int nBlock;                   /* Size of child node in bytes */
 
-  return sql_single_step(s);
-}
+    zCsr += sqlite3Fts3GetVarint32(zCsr, &iHeight);
+    zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);
+  
+    while( zCsr<zEnd ){
+      int cmp;                    /* memcmp() result */
+      int nSuffix;                /* Size of term suffix */
+      int nPrefix = 0;            /* Size of term prefix */
+      int nBuffer;                /* Total term size */
+  
+      /* Load the next term on the node into zBuffer */
+      if( !isFirstTerm ){
+        zCsr += sqlite3Fts3GetVarint32(zCsr, &nPrefix);
+      }
+      isFirstTerm = 0;
+      zCsr += sqlite3Fts3GetVarint32(zCsr, &nSuffix);
+      if( nPrefix+nSuffix>nAlloc ){
+        char *zNew;
+        nAlloc = (nPrefix+nSuffix) * 2;
+        zNew = (char *)sqlite3_realloc(zBuffer, nAlloc);
+        if( !zNew ){
+          sqlite3_free(zBuffer);
+          return SQLITE_NOMEM;
+        }
+        zBuffer = zNew;
+      }
+      memcpy(&zBuffer[nPrefix], zCsr, nSuffix);
+      nBuffer = nPrefix + nSuffix;
+      zCsr += nSuffix;
+  
+      /* Compare the term we are searching for with the term just loaded from
+      ** the interior node. If the specified term is greater than or equal
+      ** to the term from the interior node, then all terms on the sub-tree 
+      ** headed by node iChild are smaller than zTerm. No need to search 
+      ** iChild.
+      **
+      ** If the interior node term is larger than the specified term, then
+      ** the tree headed by iChild may contain the specified term.
+      */
+      cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer));
+      if( cmp<0 || (cmp==0 && nBuffer>nTerm) ) break;
+      iChild++;
+    };
 
-/* Returns SQLITE_OK with *pnSegments set to the number of entries in
-** %_segdir and *piMaxLevel set to the highest level which has a
-** segment.  Otherwise returns the SQLite error which caused failure.
-*/
-static int segdir_count(fulltext_vtab *v, int *pnSegments, int *piMaxLevel){
-  sqlite3_stmt *s;
-  int rc = sql_get_statement(v, SEGDIR_COUNT_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
+    /* If (iHeight==1), the children of this interior node are leaves. The
+    ** specified term may be present on leaf node iChild.
+    */
+    if( iHeight==1 ){
+      *piLeaf = iChild;
+      break;
+    }
 
-  rc = sqlite3_step(s);
-  /* TODO(shess): This case should not be possible?  Should stronger
-  ** measures be taken if it happens?
-  */
-  if( rc==SQLITE_DONE ){
-    *pnSegments = 0;
-    *piMaxLevel = 0;
-    return SQLITE_OK;
+    /* Descend to interior node iChild. */
+    rc = sqlite3Fts3ReadBlock(p, iChild, &zCsr, &nBlock);
+    if( rc!=SQLITE_OK ) break;
+    zEnd = &zCsr[nBlock];
   }
-  if( rc!=SQLITE_ROW ) return rc;
-
-  *pnSegments = sqlite3_column_int(s, 0);
-  *piMaxLevel = sqlite3_column_int(s, 1);
-
-  /* We expect only one row.  We must execute another sqlite3_step()
-   * to complete the iteration; otherwise the table will remain locked. */
-  rc = sqlite3_step(s);
-  if( rc==SQLITE_DONE ) return SQLITE_OK;
-  if( rc==SQLITE_ROW ) return SQLITE_ERROR;
+  sqlite3_free(zBuffer);
   return rc;
 }
 
-/* TODO(shess) clearPendingTerms() is far down the file because
-** writeZeroSegment() is far down the file because LeafWriter is far
-** down the file.  Consider refactoring the code to move the non-vtab
-** code above the vtab code so that we don't need this forward
-** reference.
-*/
-static int clearPendingTerms(fulltext_vtab *v);
-
 /*
-** Free the memory used to contain a fulltext_vtab structure.
+** This function is used to create delta-encoded serialized lists of FTS3 
+** varints. Each call to this function appends a single varint to a list.
 */
-static void fulltext_vtab_destroy(fulltext_vtab *v){
-  int iStmt, i;
-
-  FTSTRACE(("FTS3 Destroy %p\n", v));
-  for( iStmt=0; iStmt<MAX_STMT; iStmt++ ){
-    if( v->pFulltextStatements[iStmt]!=NULL ){
-      sqlite3_finalize(v->pFulltextStatements[iStmt]);
-      v->pFulltextStatements[iStmt] = NULL;
-    }
-  }
-
-  for( i=0; i<MERGE_COUNT; i++ ){
-    if( v->pLeafSelectStmts[i]!=NULL ){
-      sqlite3_finalize(v->pLeafSelectStmts[i]);
-      v->pLeafSelectStmts[i] = NULL;
-    }
-  }
-
-  if( v->pTokenizer!=NULL ){
-    v->pTokenizer->pModule->xDestroy(v->pTokenizer);
-    v->pTokenizer = NULL;
-  }
-
-  clearPendingTerms(v);
-
-  sqlite3_free(v->azColumn);
-  for(i = 0; i < v->nColumn; ++i) {
-    sqlite3_free(v->azContentColumn[i]);
-  }
-  sqlite3_free(v->azContentColumn);
-  sqlite3_free(v);
+static void fts3PutDeltaVarint(
+  char **pp,                      /* IN/OUT: Output pointer */
+  sqlite3_int64 *piPrev,          /* IN/OUT: Previous value written to list */
+  sqlite3_int64 iVal              /* Write this value to the list */
+){
+  assert( iVal-*piPrev > 0 || (*piPrev==0 && iVal==0) );
+  *pp += sqlite3Fts3PutVarint(*pp, iVal-*piPrev);
+  *piPrev = iVal;
 }
 
 /*
-** Token types for parsing the arguments to xConnect or xCreate.
+** When this function is called, *ppPoslist is assumed to point to the 
+** start of a position-list.
 */
-#define TOKEN_EOF         0    /* End of file */
-#define TOKEN_SPACE       1    /* Any kind of whitespace */
-#define TOKEN_ID          2    /* An identifier */
-#define TOKEN_STRING      3    /* A string literal */
-#define TOKEN_PUNCT       4    /* A single punctuation character */
-
-/*
-** If X is a character that can be used in an identifier then
-** ftsIdChar(X) will be true.  Otherwise it is false.
-**
-** For ASCII, any character with the high-order bit set is
-** allowed in an identifier.  For 7-bit characters, 
-** isFtsIdChar[X] must be 1.
-**
-** Ticket #1066.  the SQL standard does not allow '$' in the
-** middle of identfiers.  But many SQL implementations do. 
-** SQLite will allow '$' in identifiers for compatibility.
-** But the feature is undocumented.
-*/
-static const char isFtsIdChar[] = {
-/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */
-    0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */
-    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */
-    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */
-};
-#define ftsIdChar(C)  (((c=C)&0x80)!=0 || (c>0x1f && isFtsIdChar[c-0x20]))
+static void fts3PoslistCopy(char **pp, char **ppPoslist){
+  char *pEnd = *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
+  ** 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 
+  ** 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++;
 
-/*
-** Return the length of the token that begins at z[0]. 
-** Store the token type in *tokenType before returning.
-*/
-static int ftsGetToken(const char *z, int *tokenType){
-  int i, c;
-  switch( *z ){
-    case 0: {
-      *tokenType = TOKEN_EOF;
-      return 0;
-    }
-    case ' ': case '\t': case '\n': case '\f': case '\r': {
-      for(i=1; safe_isspace(z[i]); i++){}
-      *tokenType = TOKEN_SPACE;
-      return i;
-    }
-    case '`':
-    case '\'':
-    case '"': {
-      int delim = z[0];
-      for(i=1; (c=z[i])!=0; i++){
-        if( c==delim ){
-          if( z[i+1]==delim ){
-            i++;
-          }else{
-            break;
-          }
-        }
-      }
-      *tokenType = TOKEN_STRING;
-      return i + (c!=0);
-    }
-    case '[': {
-      for(i=1, c=z[0]; c!=']' && (c=z[i])!=0; i++){}
-      *tokenType = TOKEN_ID;
-      return i;
-    }
-    default: {
-      if( !ftsIdChar(*z) ){
-        break;
-      }
-      for(i=1; ftsIdChar(z[i]); i++){}
-      *tokenType = TOKEN_ID;
-      return i;
-    }
+  if( pp ){
+    int n = (int)(pEnd - *ppPoslist);
+    char *p = *pp;
+    memcpy(p, *ppPoslist, n);
+    p += n;
+    *pp = p;
   }
-  *tokenType = TOKEN_PUNCT;
-  return 1;
+  *ppPoslist = pEnd;
 }
 
-/*
-** A token extracted from a string is an instance of the following
-** structure.
-*/
-typedef struct FtsToken {
-  const char *z;       /* Pointer to token text.  Not '\000' terminated */
-  short int n;         /* Length of the token text in bytes. */
-} FtsToken;
+static void fts3ColumnlistCopy(char **pp, char **ppPoslist){
+  char *pEnd = *ppPoslist;
+  char c = 0;
 
-/*
-** Given a input string (which is really one of the argv[] parameters
-** passed into xConnect or xCreate) split the string up into tokens.
-** Return an array of pointers to '\000' terminated strings, one string
-** for each non-whitespace token.
-**
-** The returned array is terminated by a single NULL pointer.
-**
-** Space to hold the returned array is obtained from a single
-** malloc and should be freed by passing the return value to free().
-** The individual strings within the token list are all a part of
-** the single memory allocation and will all be freed at once.
-*/
-static char **tokenizeString(const char *z, int *pnToken){
-  int nToken = 0;
-  FtsToken *aToken = sqlite3_malloc( strlen(z) * sizeof(aToken[0]) );
-  int n = 1;
-  int e, i;
-  int totalSize = 0;
-  char **azToken;
-  char *zCopy;
-  while( n>0 ){
-    n = ftsGetToken(z, &e);
-    if( e!=TOKEN_SPACE ){
-      aToken[nToken].z = z;
-      aToken[nToken].n = n;
-      nToken++;
-      totalSize += n+1;
-    }
-    z += n;
-  }
-  azToken = (char**)sqlite3_malloc( nToken*sizeof(char*) + totalSize );
-  zCopy = (char*)&azToken[nToken];
-  nToken--;
-  for(i=0; i<nToken; i++){
-    azToken[i] = zCopy;
-    n = aToken[i].n;
-    memcpy(zCopy, aToken[i].z, n);
-    zCopy[n] = 0;
-    zCopy += n+1;
+  /* A column-list is terminated by either a 0x01 or 0x00. */
+  while( 0xFE & (*pEnd | c) ) c = *pEnd++ & 0x80;
+  if( pp ){
+    int n = (int)(pEnd - *ppPoslist);
+    char *p = *pp;
+    memcpy(p, *ppPoslist, n);
+    p += n;
+    *pp = p;
   }
-  azToken[nToken] = 0;
-  sqlite3_free(aToken);
-  *pnToken = nToken;
-  return azToken;
+  *ppPoslist = pEnd;
 }
 
 /*
-** Convert an SQL-style quoted string into a normal string by removing
-** the quote characters.  The conversion is done in-place.  If the
-** input does not begin with a quote character, then this routine
-** is a no-op.
-**
-** Examples:
-**
-**     "abc"   becomes   abc
-**     'xyz'   becomes   xyz
-**     [pqr]   becomes   pqr
-**     `mno`   becomes   mno
+** Value used to signify the end of an offset-list. This is safe because
+** it is not possible to have a document with 2^31 terms.
 */
-static void dequoteString(char *z){
-  int quote;
-  int i, j;
-  if( z==0 ) return;
-  quote = z[0];
-  switch( quote ){
-    case '\'':  break;
-    case '"':   break;
-    case '`':   break;                /* For MySQL compatibility */
-    case '[':   quote = ']';  break;  /* For MS SqlServer compatibility */
-    default:    return;
-  }
-  for(i=1, j=0; z[i]; i++){
-    if( z[i]==quote ){
-      if( z[i+1]==quote ){
-        z[j++] = quote;
-        i++;
-      }else{
-        z[j++] = 0;
-        break;
-      }
-    }else{
-      z[j++] = z[i];
-    }
-  }
-}
+#define OFFSET_LIST_END 0x7fffffff
 
 /*
-** The input azIn is a NULL-terminated list of tokens.  Remove the first
-** token and all punctuation tokens.  Remove the quotes from
-** around string literal tokens.
-**
-** Example:
+** 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).
 **
-**     input:      tokenize chinese ( 'simplifed' , 'mixed' )
-**     output:     chinese simplifed mixed
-**
-** Another example:
-**
-**     input:      delimiters ( '[' , ']' , '...' )
-**     output:     [ ] ...
+** 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,
+** increment the current value of *pi by the value read, and set *pp to
+** point to the next value before returning.
 */
-static void tokenListToIdList(char **azIn){
-  int i, j;
-  if( azIn ){
-    for(i=0, j=-1; azIn[i]; i++){
-      if( safe_isalnum(azIn[i][0]) || azIn[i][1] ){
-        dequoteString(azIn[i]);
-        if( j>=0 ){
-          azIn[j] = azIn[i];
-        }
-        j++;
-      }
-    }
-    azIn[j] = 0;
+static void fts3ReadNextPos(
+  char **pp,                      /* IN/OUT: Pointer into offset-list buffer */
+  sqlite3_int64 *pi               /* IN/OUT: Value read from offset-list */
+){
+  if( **pp&0xFE ){
+    fts3GetDeltaVarint(pp, pi);
+    *pi -= 2;
+  }else{
+    *pi = OFFSET_LIST_END;
   }
 }
 
-
 /*
-** Find the first alphanumeric token in the string zIn.  Null-terminate
-** this token.  Remove any quotation marks.  And return a pointer to
-** the result.
-*/
-static char *firstToken(char *zIn, char **pzTail){
-  int n, ttype;
-  while(1){
-    n = ftsGetToken(zIn, &ttype);
-    if( ttype==TOKEN_SPACE ){
-      zIn += n;
-    }else if( ttype==TOKEN_EOF ){
-      *pzTail = zIn;
-      return 0;
-    }else{
-      zIn[n] = 0;
-      *pzTail = &zIn[1];
-      dequoteString(zIn);
-      return zIn;
-    }
-  }
-  /*NOTREACHED*/
-}
-
-/* Return true if...
-**
-**   *  s begins with the string t, ignoring case
-**   *  s is longer than t
-**   *  The first character of s beyond t is not a alphanumeric
-** 
-** Ignore leading space in *s.
+** If parameter iCol is not 0, write an 0x01 byte followed by the value of
+** iCol encoded as a varint to *pp. 
 **
-** To put it another way, return true if the first token of
-** s[] is t[].
+** 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
+** written (0 if iCol==0).
 */
-static int startsWith(const char *s, const char *t){
-  while( safe_isspace(*s) ){ s++; }
-  while( *t ){
-    if( safe_tolower(*s++)!=safe_tolower(*t++) ) return 0;
+static int fts3PutColNumber(char **pp, int iCol){
+  int n = 0;                      /* Number of bytes written */
+  if( iCol ){
+    char *p = *pp;                /* Output pointer */
+    n = 1 + sqlite3Fts3PutVarint(&p[1], iCol);
+    *p = 0x01;
+    *pp = &p[n];
   }
-  return *s!='_' && !safe_isalnum(*s);
+  return n;
 }
 
 /*
-** An instance of this structure defines the "spec" of a
-** full text index.  This structure is populated by parseSpec
-** and use by fulltextConnect and fulltextCreate.
-*/
-typedef struct TableSpec {
-  const char *zDb;         /* Logical database name */
-  const char *zName;       /* Name of the full-text index */
-  int nColumn;             /* Number of columns to be indexed */
-  char **azColumn;         /* Original names of columns to be indexed */
-  char **azContentColumn;  /* Column names for %_content */
-  char **azTokenizer;      /* Name of tokenizer and its arguments */
-} TableSpec;
-
-/*
-** Reclaim all of the memory used by a TableSpec
+**
 */
-static void clearTableSpec(TableSpec *p) {
-  sqlite3_free(p->azColumn);
-  sqlite3_free(p->azContentColumn);
-  sqlite3_free(p->azTokenizer);
-}
-
-/* Parse a CREATE VIRTUAL TABLE statement, which looks like this:
- *
- * CREATE VIRTUAL TABLE email
- *        USING fts3(subject, body, tokenize mytokenizer(myarg))
- *
- * We return parsed information in a TableSpec structure.
- * 
- */
-static int parseSpec(TableSpec *pSpec, int argc, const char *const*argv,
-                     char**pzErr){
-  int i, n;
-  char *z, *zDummy;
-  char **azArg;
-  const char *zTokenizer = 0;    /* argv[] entry describing the tokenizer */
-
-  assert( argc>=3 );
-  /* Current interface:
-  ** argv[0] - module name
-  ** argv[1] - database name
-  ** argv[2] - table name
-  ** argv[3..] - columns, optionally followed by tokenizer specification
-  **             and snippet delimiters specification.
-  */
-
-  /* Make a copy of the complete argv[][] array in a single allocation.
-  ** The argv[][] array is read-only and transient.  We can write to the
-  ** copy in order to modify things and the copy is persistent.
-  */
-  CLEAR(pSpec);
-  for(i=n=0; i<argc; i++){
-    n += strlen(argv[i]) + 1;
-  }
-  azArg = sqlite3_malloc( sizeof(char*)*argc + n );
-  if( azArg==0 ){
-    return SQLITE_NOMEM;
-  }
-  z = (char*)&azArg[argc];
-  for(i=0; i<argc; i++){
-    azArg[i] = z;
-    strcpy(z, argv[i]);
-    z += strlen(z)+1;
-  }
-
-  /* Identify the column names and the tokenizer and delimiter arguments
-  ** in the argv[][] array.
-  */
-  pSpec->zDb = azArg[1];
-  pSpec->zName = azArg[2];
-  pSpec->nColumn = 0;
-  pSpec->azColumn = azArg;
-  zTokenizer = "tokenize simple";
-  for(i=3; i<argc; ++i){
-    if( startsWith(azArg[i],"tokenize") ){
-      zTokenizer = azArg[i];
+static void fts3PoslistMerge(
+  char **pp,                      /* Output buffer */
+  char **pp1,                     /* Left input list */
+  char **pp2                      /* Right input list */
+){
+  char *p = *pp;
+  char *p1 = *pp1;
+  char *p2 = *pp2;
+
+  while( *p1 || *p2 ){
+    int iCol1;
+    int iCol2;
+
+    if( *p1==0x01 ) sqlite3Fts3GetVarint32(&p1[1], &iCol1);
+    else if( *p1==0x00 ) iCol1 = OFFSET_LIST_END;
+    else iCol1 = 0;
+
+    if( *p2==0x01 ) sqlite3Fts3GetVarint32(&p2[1], &iCol2);
+    else if( *p2==0x00 ) iCol2 = OFFSET_LIST_END;
+    else iCol2 = 0;
+
+    if( iCol1==iCol2 ){
+      sqlite3_int64 i1 = 0;
+      sqlite3_int64 i2 = 0;
+      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
+      ** 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.
+      */
+      fts3GetDeltaVarint(&p1, &i1);
+      fts3GetDeltaVarint(&p2, &i2);
+      do {
+        fts3PutDeltaVarint(&p, &iPrev, (i1<i2) ? i1 : i2); 
+        iPrev -= 2;
+        if( i1==i2 ){
+          fts3ReadNextPos(&p1, &i1);
+          fts3ReadNextPos(&p2, &i2);
+        }else if( i1<i2 ){
+          fts3ReadNextPos(&p1, &i1);
+        }else{
+          fts3ReadNextPos(&p2, &i2);
+        }
+      }while( i1!=OFFSET_LIST_END || i2!=OFFSET_LIST_END );
+    }else if( iCol1<iCol2 ){
+      p1 += fts3PutColNumber(&p, iCol1);
+      fts3ColumnlistCopy(&p, &p1);
     }else{
-      z = azArg[pSpec->nColumn] = firstToken(azArg[i], &zDummy);
-      pSpec->nColumn++;
-    }
-  }
-  if( pSpec->nColumn==0 ){
-    azArg[0] = "content";
-    pSpec->nColumn = 1;
-  }
-
-  /*
-  ** Construct the list of content column names.
-  **
-  ** Each content column name will be of the form cNNAAAA
-  ** where NN is the column number and AAAA is the sanitized
-  ** column name.  "sanitized" means that special characters are
-  ** converted to "_".  The cNN prefix guarantees that all column
-  ** names are unique.
-  **
-  ** The AAAA suffix is not strictly necessary.  It is included
-  ** for the convenience of people who might examine the generated
-  ** %_content table and wonder what the columns are used for.
-  */
-  pSpec->azContentColumn = sqlite3_malloc( pSpec->nColumn * sizeof(char *) );
-  if( pSpec->azContentColumn==0 ){
-    clearTableSpec(pSpec);
-    return SQLITE_NOMEM;
-  }
-  for(i=0; i<pSpec->nColumn; i++){
-    char *p;
-    pSpec->azContentColumn[i] = sqlite3_mprintf("c%d%s", i, azArg[i]);
-    for (p = pSpec->azContentColumn[i]; *p ; ++p) {
-      if( !safe_isalnum(*p) ) *p = '_';
+      p2 += fts3PutColNumber(&p, iCol2);
+      fts3ColumnlistCopy(&p, &p2);
     }
   }
 
-  /*
-  ** Parse the tokenizer specification string.
-  */
-  pSpec->azTokenizer = tokenizeString(zTokenizer, &n);
-  tokenListToIdList(pSpec->azTokenizer);
-
-  return SQLITE_OK;
+  *p++ = '\0';
+  *pp = p;
+  *pp1 = p1 + 1;
+  *pp2 = p2 + 1;
 }
 
 /*
-** Generate a CREATE TABLE statement that describes the schema of
-** the virtual table.  Return a pointer to this schema string.
-**
-** Space is obtained from sqlite3_mprintf() and should be freed
-** using sqlite3_free().
+** nToken==1 searches for adjacent positions.
 */
-static char *fulltextSchema(
-  int nColumn,                  /* Number of columns */
-  const char *const* azColumn,  /* List of columns */
-  const char *zTableName        /* Name of the table */
-){
-  int i;
-  char *zSchema, *zNext;
-  const char *zSep = "(";
-  zSchema = sqlite3_mprintf("CREATE TABLE x");
-  for(i=0; i<nColumn; i++){
-    zNext = sqlite3_mprintf("%s%s%Q", zSchema, zSep, azColumn[i]);
-    sqlite3_free(zSchema);
-    zSchema = zNext;
-    zSep = ",";
-  }
-  zNext = sqlite3_mprintf("%s,%Q HIDDEN", zSchema, zTableName);
-  sqlite3_free(zSchema);
-  zSchema = zNext;
-  zNext = sqlite3_mprintf("%s,docid HIDDEN)", zSchema);
-  sqlite3_free(zSchema);
-  return zNext;
-}
-
-/*
-** Build a new sqlite3_vtab structure that will describe the
-** fulltext index defined by spec.
-*/
-static int constructVtab(
-  sqlite3 *db,              /* The SQLite database connection */
-  fts3Hash *pHash,          /* Hash table containing tokenizers */
-  TableSpec *spec,          /* Parsed spec information from parseSpec() */
-  sqlite3_vtab **ppVTab,    /* Write the resulting vtab structure here */
-  char **pzErr              /* Write any error message here */
+static int fts3PoslistPhraseMerge(
+  char **pp,                      /* Output buffer */
+  int nToken,                     /* Maximum difference in token positions */
+  int isSaveLeft,                 /* Save the left position */
+  char **pp1,                     /* Left input list */
+  char **pp2                      /* Right input list */
 ){
-  int rc;
-  int n;
-  fulltext_vtab *v = 0;
-  const sqlite3_tokenizer_module *m = NULL;
-  char *schema;
-
-  char const *zTok;         /* Name of tokenizer to use for this fts table */
-  int nTok;                 /* Length of zTok, including nul terminator */
-
-  v = (fulltext_vtab *) sqlite3_malloc(sizeof(fulltext_vtab));
-  if( v==0 ) return SQLITE_NOMEM;
-  CLEAR(v);
-  /* sqlite will initialize v->base */
-  v->db = db;
-  v->zDb = spec->zDb;       /* Freed when azColumn is freed */
-  v->zName = spec->zName;   /* Freed when azColumn is freed */
-  v->nColumn = spec->nColumn;
-  v->azContentColumn = spec->azContentColumn;
-  spec->azContentColumn = 0;
-  v->azColumn = spec->azColumn;
-  spec->azColumn = 0;
-
-  if( spec->azTokenizer==0 ){
-    return SQLITE_NOMEM;
-  }
+  char *p = (pp ? *pp : 0);
+  char *p1 = *pp1;
+  char *p2 = *pp2;
 
-  zTok = spec->azTokenizer[0]; 
-  if( !zTok ){
-    zTok = "simple";
+  int iCol1 = 0;
+  int iCol2 = 0;
+  assert( *p1!=0 && *p2!=0 );
+  if( *p1==0x01 ){ 
+    p1++;
+    p1 += sqlite3Fts3GetVarint32(p1, &iCol1);
   }
-  nTok = strlen(zTok)+1;
-
-  m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zTok, nTok);
-  if( !m ){
-    *pzErr = sqlite3_mprintf("unknown tokenizer: %s", spec->azTokenizer[0]);
-    rc = SQLITE_ERROR;
-    goto err;
+  if( *p2==0x01 ){ 
+    p2++;
+    p2 += sqlite3Fts3GetVarint32(p2, &iCol2);
   }
 
-  for(n=0; spec->azTokenizer[n]; n++){}
-  if( n ){
-    rc = m->xCreate(n-1, (const char*const*)&spec->azTokenizer[1],
-                    &v->pTokenizer);
-  }else{
-    rc = m->xCreate(0, 0, &v->pTokenizer);
-  }
-  if( rc!=SQLITE_OK ) goto err;
-  v->pTokenizer->pModule = m;
-
-  /* TODO: verify the existence of backing tables foo_content, foo_term */
-
-  schema = fulltextSchema(v->nColumn, (const char*const*)v->azColumn,
-                          spec->zName);
-  rc = sqlite3_declare_vtab(db, schema);
-  sqlite3_free(schema);
-  if( rc!=SQLITE_OK ) goto err;
-
-  memset(v->pFulltextStatements, 0, sizeof(v->pFulltextStatements));
-
-  /* Indicate that the buffer is not live. */
-  v->nPendingData = -1;
-
-  *ppVTab = &v->base;
-  FTSTRACE(("FTS3 Connect %p\n", v));
-
-  return rc;
-
-err:
-  fulltext_vtab_destroy(v);
-  return rc;
-}
+  while( 1 ){
+    if( iCol1==iCol2 ){
+      char *pSave = p;
+      sqlite3_int64 iPrev = 0;
+      sqlite3_int64 iPos1 = 0;
+      sqlite3_int64 iPos2 = 0;
 
-static int fulltextConnect(
-  sqlite3 *db,
-  void *pAux,
-  int argc, const char *const*argv,
-  sqlite3_vtab **ppVTab,
-  char **pzErr
-){
-  TableSpec spec;
-  int rc = parseSpec(&spec, argc, argv, pzErr);
-  if( rc!=SQLITE_OK ) return rc;
+      if( pp && iCol1 ){
+        *p++ = 0x01;
+        p += sqlite3Fts3PutVarint(p, iCol1);
+      }
 
-  rc = constructVtab(db, (fts3Hash *)pAux, &spec, ppVTab, pzErr);
-  clearTableSpec(&spec);
-  return rc;
-}
+      assert( *p1!=0x00 && *p2!=0x00 && *p1!=0x01 && *p2!=0x01 );
+      fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;
+      fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;
 
-/* The %_content table holds the text of each document, with
-** the docid column exposed as the SQLite rowid for the table.
-*/
-/* TODO(shess) This comment needs elaboration to match the updated
-** code.  Work it into the top-of-file comment at that time.
-*/
-static int fulltextCreate(sqlite3 *db, void *pAux,
-                          int argc, const char * const *argv,
-                          sqlite3_vtab **ppVTab, char **pzErr){
-  int rc;
-  TableSpec spec;
-  StringBuffer schema;
-  FTSTRACE(("FTS3 Create\n"));
+      while( 1 ){
+        if( iPos2>iPos1 && iPos2<=iPos1+nToken ){
+          sqlite3_int64 iSave;
+          if( !pp ){
+            fts3PoslistCopy(0, &p2);
+            fts3PoslistCopy(0, &p1);
+            *pp1 = p1;
+            *pp2 = p2;
+            return 1;
+          }
+          iSave = isSaveLeft ? iPos1 : iPos2;
+          fts3PutDeltaVarint(&p, &iPrev, iSave+2); iPrev -= 2;
+          pSave = 0;
+        }
+        if( (!isSaveLeft && iPos2<=(iPos1+nToken)) || iPos2<=iPos1 ){
+          if( (*p2&0xFE)==0 ) break;
+          fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;
+        }else{
+          if( (*p1&0xFE)==0 ) break;
+          fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;
+        }
+      }
 
-  rc = parseSpec(&spec, argc, argv, pzErr);
-  if( rc!=SQLITE_OK ) return rc;
+      if( pSave ){
+        assert( pp && p );
+        p = pSave;
+      }
 
-  initStringBuffer(&schema);
-  append(&schema, "CREATE TABLE %_content(");
-  append(&schema, "  docid INTEGER PRIMARY KEY,");
-  appendList(&schema, spec.nColumn, spec.azContentColumn);
-  append(&schema, ")");
-  rc = sql_exec(db, spec.zDb, spec.zName, stringBufferData(&schema));
-  stringBufferDestroy(&schema);
-  if( rc!=SQLITE_OK ) goto out;
-
-  rc = sql_exec(db, spec.zDb, spec.zName,
-                "create table %_segments("
-                "  blockid INTEGER PRIMARY KEY,"
-                "  block blob"
-                ");"
-                );
-  if( rc!=SQLITE_OK ) goto out;
-
-  rc = sql_exec(db, spec.zDb, spec.zName,
-                "create table %_segdir("
-                "  level integer,"
-                "  idx integer,"
-                "  start_block integer,"
-                "  leaves_end_block integer,"
-                "  end_block integer,"
-                "  root blob,"
-                "  primary key(level, idx)"
-                ");");
-  if( rc!=SQLITE_OK ) goto out;
-
-  rc = constructVtab(db, (fts3Hash *)pAux, &spec, ppVTab, pzErr);
-
-out:
-  clearTableSpec(&spec);
-  return rc;
-}
+      fts3ColumnlistCopy(0, &p1);
+      fts3ColumnlistCopy(0, &p2);
+      assert( (*p1&0xFE)==0 && (*p2&0xFE)==0 );
+      if( 0==*p1 || 0==*p2 ) break;
 
-/* Decide how to handle an SQL query. */
-static int fulltextBestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
-  fulltext_vtab *v = (fulltext_vtab *)pVTab;
-  int i;
-  FTSTRACE(("FTS3 BestIndex\n"));
-
-  for(i=0; i<pInfo->nConstraint; ++i){
-    const struct sqlite3_index_constraint *pConstraint;
-    pConstraint = &pInfo->aConstraint[i];
-    if( pConstraint->usable ) {
-      if( (pConstraint->iColumn==-1 || pConstraint->iColumn==v->nColumn+1) &&
-          pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){
-        pInfo->idxNum = QUERY_DOCID;      /* lookup by docid */
-        FTSTRACE(("FTS3 QUERY_DOCID\n"));
-      } else if( pConstraint->iColumn>=0 && pConstraint->iColumn<=v->nColumn &&
-                 pConstraint->op==SQLITE_INDEX_CONSTRAINT_MATCH ){
-        /* full-text search */
-        pInfo->idxNum = QUERY_FULLTEXT + pConstraint->iColumn;
-        FTSTRACE(("FTS3 QUERY_FULLTEXT %d\n", pConstraint->iColumn));
-      } else continue;
-
-      pInfo->aConstraintUsage[i].argvIndex = 1;
-      pInfo->aConstraintUsage[i].omit = 1;
-
-      /* An arbitrary value for now.
-       * TODO: Perhaps docid matches should be considered cheaper than
-       * full-text searches. */
-      pInfo->estimatedCost = 1.0;   
+      p1++;
+      p1 += sqlite3Fts3GetVarint32(p1, &iCol1);
+      p2++;
+      p2 += sqlite3Fts3GetVarint32(p2, &iCol2);
+    }
 
-      return SQLITE_OK;
+    /* Advance pointer p1 or p2 (whichever corresponds to the smaller of
+    ** iCol1 and iCol2) so that it points to either the 0x00 that marks the
+    ** end of the position list, or the 0x01 that precedes the next 
+    ** column-number in the position list. 
+    */
+    else if( iCol1<iCol2 ){
+      fts3ColumnlistCopy(0, &p1);
+      if( 0==*p1 ) break;
+      p1++;
+      p1 += sqlite3Fts3GetVarint32(p1, &iCol1);
+    }else{
+      fts3ColumnlistCopy(0, &p2);
+      if( 0==*p2 ) break;
+      p2++;
+      p2 += sqlite3Fts3GetVarint32(p2, &iCol2);
     }
   }
-  pInfo->idxNum = QUERY_GENERIC;
-  return SQLITE_OK;
-}
 
-static int fulltextDisconnect(sqlite3_vtab *pVTab){
-  FTSTRACE(("FTS3 Disconnect %p\n", pVTab));
-  fulltext_vtab_destroy((fulltext_vtab *)pVTab);
-  return SQLITE_OK;
-}
-
-static int fulltextDestroy(sqlite3_vtab *pVTab){
-  fulltext_vtab *v = (fulltext_vtab *)pVTab;
-  int rc;
-
-  FTSTRACE(("FTS3 Destroy %p\n", pVTab));
-  rc = sql_exec(v->db, v->zDb, v->zName,
-                "drop table if exists %_content;"
-                "drop table if exists %_segments;"
-                "drop table if exists %_segdir;"
-                );
-  if( rc!=SQLITE_OK ) return rc;
-
-  fulltext_vtab_destroy((fulltext_vtab *)pVTab);
-  return SQLITE_OK;
-}
-
-static int fulltextOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
-  fulltext_cursor *c;
-
-  c = (fulltext_cursor *) sqlite3_malloc(sizeof(fulltext_cursor));
-  if( c ){
-    memset(c, 0, sizeof(fulltext_cursor));
-    /* sqlite will initialize c->base */
-    *ppCursor = &c->base;
-    FTSTRACE(("FTS3 Open %p: %p\n", pVTab, c));
-    return SQLITE_OK;
-  }else{
-    return SQLITE_NOMEM;
+  fts3PoslistCopy(0, &p2);
+  fts3PoslistCopy(0, &p1);
+  *pp1 = p1;
+  *pp2 = p2;
+  if( !pp || *pp==p ){
+    return 0;
   }
-}
-
-/* Free all of the dynamically allocated memory held by the
-** Snippet
-*/
-static void snippetClear(Snippet *p){
-  sqlite3_free(p->aMatch);
-  sqlite3_free(p->zOffset);
-  sqlite3_free(p->zSnippet);
-  CLEAR(p);
+  *p++ = 0x00;
+  *pp = p;
+  return 1;
 }
 
 /*
-** Append a single entry to the p->aMatch[] log.
+** Merge two position-lists as required by the NEAR operator.
 */
-static void snippetAppendMatch(
-  Snippet *p,               /* Append the entry to this snippet */
-  int iCol, int iTerm,      /* The column and query term */
-  int iToken,               /* Matching token in document */
-  int iStart, int nByte     /* Offset and size of the match */
+static int fts3PoslistNearMerge(
+  char **pp,                      /* Output buffer */
+  char *aTmp,                     /* Temporary buffer space */
+  int nRight,                     /* Maximum difference in token positions */
+  int nLeft,                      /* Maximum difference in token positions */
+  char **pp1,                     /* IN/OUT: Left input list */
+  char **pp2                      /* IN/OUT: Right input list */
 ){
-  int i;
-  struct snippetMatch *pMatch;
-  if( p->nMatch+1>=p->nAlloc ){
-    p->nAlloc = p->nAlloc*2 + 10;
-    p->aMatch = sqlite3_realloc(p->aMatch, p->nAlloc*sizeof(p->aMatch[0]) );
-    if( p->aMatch==0 ){
-      p->nMatch = 0;
-      p->nAlloc = 0;
-      return;
-    }
-  }
-  i = p->nMatch++;
-  pMatch = &p->aMatch[i];
-  pMatch->iCol = iCol;
-  pMatch->iTerm = iTerm;
-  pMatch->iToken = iToken;
-  pMatch->iStart = iStart;
-  pMatch->nByte = nByte;
-}
-
-/*
-** Sizing information for the circular buffer used in snippetOffsetsOfColumn()
-*/
-#define FTS3_ROTOR_SZ   (32)
-#define FTS3_ROTOR_MASK (FTS3_ROTOR_SZ-1)
-
-/*
-** Function to iterate through the tokens of a compiled expression.
-**
-** Except, skip all tokens on the right-hand side of a NOT operator.
-** This function is used to find tokens as part of snippet and offset
-** generation and we do nt want snippets and offsets to report matches
-** for tokens on the RHS of a NOT.
-*/
-static int fts3NextExprToken(Fts3Expr **ppExpr, int *piToken){
-  Fts3Expr *p = *ppExpr;
-  int iToken = *piToken;
-  if( iToken<0 ){
-    /* In this case the expression p is the root of an expression tree.
-    ** Move to the first token in the expression tree.
-    */
-    while( p->pLeft ){
-      p = p->pLeft;
-    }
-    iToken = 0;
+  char *p1 = *pp1;
+  char *p2 = *pp2;
+
+  if( !pp ){
+    if( fts3PoslistPhraseMerge(0, nRight, 0, pp1, pp2) ) return 1;
+    *pp1 = p1;
+    *pp2 = p2;
+    return fts3PoslistPhraseMerge(0, nLeft, 0, pp2, pp1);
   }else{
-    assert(p && p->eType==FTSQUERY_PHRASE );
-    if( iToken<(p->pPhrase->nToken-1) ){
-      iToken++;
+    char *pTmp1 = aTmp;
+    char *pTmp2;
+    char *aTmp2;
+    int res = 1;
+
+    fts3PoslistPhraseMerge(&pTmp1, nRight, 0, pp1, pp2);
+    aTmp2 = pTmp2 = pTmp1;
+    *pp1 = p1;
+    *pp2 = p2;
+    fts3PoslistPhraseMerge(&pTmp2, nLeft, 1, pp2, pp1);
+    if( pTmp1!=aTmp && pTmp2!=aTmp2 ){
+      fts3PoslistMerge(pp, &aTmp, &aTmp2);
+    }else if( pTmp1!=aTmp ){
+      fts3PoslistCopy(pp, &aTmp);
+    }else if( pTmp2!=aTmp2 ){
+      fts3PoslistCopy(pp, &aTmp2);
     }else{
-      iToken = 0;
-      while( p->pParent && p->pParent->pLeft!=p ){
-        assert( p->pParent->pRight==p );
-        p = p->pParent;
-      }
-      p = p->pParent;
-      if( p ){
-        assert( p->pRight!=0 );
-        p = p->pRight;
-        while( p->pLeft ){
-          p = p->pLeft;
-        }
-      }
+      res = 0;
     }
-  }
 
-  *ppExpr = p;
-  *piToken = iToken;
-  return p?1:0;
+    return res;
+  }
 }
 
 /*
-** Return TRUE if the expression node pExpr is located beneath the
-** RHS of a NOT operator.
+** Values that may be used as the first parameter to fts3DoclistMerge().
 */
-static int fts3ExprBeneathNot(Fts3Expr *p){
-  Fts3Expr *pParent;
-  while( p ){
-    pParent = p->pParent;
-    if( pParent && pParent->eType==FTSQUERY_NOT && pParent->pRight==p ){
-      return 1;
-    }
-    p = pParent;
-  }
-  return 0;
-}
+#define MERGE_NOT        2        /* D + D -> D */
+#define MERGE_AND        3        /* D + D -> D */
+#define MERGE_OR         4        /* D + D -> D */
+#define MERGE_POS_OR     5        /* P + P -> P */
+#define MERGE_PHRASE     6        /* P + P -> D */
+#define MERGE_POS_PHRASE 7        /* P + P -> P */
+#define MERGE_NEAR       8        /* P + P -> D */
+#define MERGE_POS_NEAR   9        /* P + P -> P */
 
 /*
-** Add entries to pSnippet->aMatch[] for every match that occurs against
-** document zDoc[0..nDoc-1] which is stored in column iColumn.
+** Merge the two doclists passed in buffer a1 (size n1 bytes) and a2
+** (size n2 bytes). The output is written to pre-allocated buffer aBuffer,
+** which is guaranteed to be large enough to hold the results. The number
+** of bytes written to aBuffer is stored in *pnBuffer before returning.
+**
+** If successful, SQLITE_OK is returned. Otherwise, if a malloc error
+** occurs while allocating a temporary buffer as part of the merge operation,
+** SQLITE_NOMEM is returned.
 */
-static void snippetOffsetsOfColumn(
-  fulltext_cursor *pCur,         /* The fulltest search cursor */
-  Snippet *pSnippet,             /* The Snippet object to be filled in */
-  int iColumn,                   /* Index of fulltext table column */
-  const char *zDoc,              /* Text of the fulltext table column */
-  int nDoc                       /* Length of zDoc in bytes */
+static int fts3DoclistMerge(
+  int mergetype,                  /* One of the MERGE_XXX constants */
+  int nParam1,                    /* Used by MERGE_NEAR and MERGE_POS_NEAR */
+  int nParam2,                    /* Used by MERGE_NEAR and MERGE_POS_NEAR */
+  char *aBuffer,                  /* Pre-allocated output buffer */
+  int *pnBuffer,                  /* OUT: Bytes written to aBuffer */
+  char *a1,                       /* Buffer containing first doclist */
+  int n1,                         /* Size of buffer a1 */
+  char *a2,                       /* Buffer containing second doclist */
+  int n2                          /* Size of buffer a2 */
 ){
-  const sqlite3_tokenizer_module *pTModule;  /* The tokenizer module */
-  sqlite3_tokenizer *pTokenizer;             /* The specific tokenizer */
-  sqlite3_tokenizer_cursor *pTCursor;        /* Tokenizer cursor */
-  fulltext_vtab *pVtab;                /* The full text index */
-  int nColumn;                         /* Number of columns in the index */
-  int i, j;                            /* Loop counters */
-  int rc;                              /* Return code */
-  unsigned int match, prevMatch;       /* Phrase search bitmasks */
-  const char *zToken;                  /* Next token from the tokenizer */
-  int nToken;                          /* Size of zToken */
-  int iBegin, iEnd, iPos;              /* Offsets of beginning and end */
+  sqlite3_int64 i1 = 0;
+  sqlite3_int64 i2 = 0;
+  sqlite3_int64 iPrev = 0;
+
+  char *p = aBuffer;
+  char *p1 = a1;
+  char *p2 = a2;
+  char *pEnd1 = &a1[n1];
+  char *pEnd2 = &a2[n2];
+
+  assert( mergetype==MERGE_OR     || mergetype==MERGE_POS_OR 
+       || mergetype==MERGE_AND    || mergetype==MERGE_NOT
+       || mergetype==MERGE_PHRASE || mergetype==MERGE_POS_PHRASE
+       || mergetype==MERGE_NEAR   || mergetype==MERGE_POS_NEAR
+  );
 
-  /* The following variables keep a circular buffer of the last
-  ** few tokens */
-  unsigned int iRotor = 0;             /* Index of current token */
-  int iRotorBegin[FTS3_ROTOR_SZ];      /* Beginning offset of token */
-  int iRotorLen[FTS3_ROTOR_SZ];        /* Length of token */
+  if( !aBuffer ){
+    *pnBuffer = 0;
+    return SQLITE_NOMEM;
+  }
 
-  pVtab = cursor_vtab(pCur);
-  nColumn = pVtab->nColumn;
-  pTokenizer = pVtab->pTokenizer;
-  pTModule = pTokenizer->pModule;
-  rc = pTModule->xOpen(pTokenizer, zDoc, nDoc, &pTCursor);
-  if( rc ) return;
-  pTCursor->pTokenizer = pTokenizer;
+  /* Read the first docid from each doclist */
+  fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+  fts3GetDeltaVarint2(&p2, pEnd2, &i2);
+
+  switch( mergetype ){
+    case MERGE_OR:
+    case MERGE_POS_OR:
+      while( p1 || p2 ){
+        if( p2 && p1 && i1==i2 ){
+          fts3PutDeltaVarint(&p, &iPrev, i1);
+          if( mergetype==MERGE_POS_OR ) fts3PoslistMerge(&p, &p1, &p2);
+          fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+          fts3GetDeltaVarint2(&p2, pEnd2, &i2);
+        }else if( !p2 || (p1 && i1<i2) ){
+          fts3PutDeltaVarint(&p, &iPrev, i1);
+          if( mergetype==MERGE_POS_OR ) fts3PoslistCopy(&p, &p1);
+          fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+        }else{
+          fts3PutDeltaVarint(&p, &iPrev, i2);
+          if( mergetype==MERGE_POS_OR ) fts3PoslistCopy(&p, &p2);
+          fts3GetDeltaVarint2(&p2, pEnd2, &i2);
+        }
+      }
+      break;
 
-  prevMatch = 0;
-  while( !pTModule->xNext(pTCursor, &zToken, &nToken, &iBegin, &iEnd, &iPos) ){
-    Fts3Expr *pIter = pCur->pExpr;
-    int iIter = -1;
-    iRotorBegin[iRotor&FTS3_ROTOR_MASK] = iBegin;
-    iRotorLen[iRotor&FTS3_ROTOR_MASK] = iEnd-iBegin;
-    match = 0;
-    for(i=0; i<(FTS3_ROTOR_SZ-1) && fts3NextExprToken(&pIter, &iIter); i++){
-      int nPhrase;                    /* Number of tokens in current phrase */
-      struct PhraseToken *pToken;     /* Current token */
-      int iCol;                       /* Column index */
+    case MERGE_AND:
+      while( p1 && p2 ){
+        if( i1==i2 ){
+          fts3PutDeltaVarint(&p, &iPrev, i1);
+          fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+          fts3GetDeltaVarint2(&p2, pEnd2, &i2);
+        }else if( i1<i2 ){
+          fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+        }else{
+          fts3GetDeltaVarint2(&p2, pEnd2, &i2);
+        }
+      }
+      break;
 
-      if( fts3ExprBeneathNot(pIter) ) continue;
-      nPhrase = pIter->pPhrase->nToken;
-      pToken = &pIter->pPhrase->aToken[iIter];
-      iCol = pIter->pPhrase->iColumn;
-      if( iCol>=0 && iCol<nColumn && iCol!=iColumn ) continue;
-      if( pToken->n>nToken ) continue;
-      if( !pToken->isPrefix && pToken->n<nToken ) continue;
-      assert( pToken->n<=nToken );
-      if( memcmp(pToken->z, zToken, pToken->n) ) continue;
-      if( iIter>0 && (prevMatch & (1<<i))==0 ) continue;
-      match |= 1<<i;
-      if( i==(FTS3_ROTOR_SZ-2) || nPhrase==iIter+1 ){
-        for(j=nPhrase-1; j>=0; j--){
-          int k = (iRotor-j) & FTS3_ROTOR_MASK;
-          snippetAppendMatch(pSnippet, iColumn, i-j, iPos-j,
-                iRotorBegin[k], iRotorLen[k]);
+    case MERGE_NOT:
+      while( p1 ){
+        if( p2 && i1==i2 ){
+          fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+          fts3GetDeltaVarint2(&p2, pEnd2, &i2);
+        }else if( !p2 || i1<i2 ){
+          fts3PutDeltaVarint(&p, &iPrev, i1);
+          fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+        }else{
+          fts3GetDeltaVarint2(&p2, pEnd2, &i2);
         }
       }
-    }
-    prevMatch = match<<1;
-    iRotor++;
-  }
-  pTModule->xClose(pTCursor);  
-}
+      break;
 
-/*
-** Remove entries from the pSnippet structure to account for the NEAR
-** operator. When this is called, pSnippet contains the list of token 
-** offsets produced by treating all NEAR operators as AND operators.
-** This function removes any entries that should not be present after
-** accounting for the NEAR restriction. For example, if the queried
-** document is:
-**
-**     "A B C D E A"
-**
-** and the query is:
-** 
-**     A NEAR/0 E
-**
-** then when this function is called the Snippet contains token offsets
-** 0, 4 and 5. This function removes the "0" entry (because the first A
-** is not near enough to an E).
-**
-** When this function is called, the value pointed to by parameter piLeft is
-** the integer id of the left-most token in the expression tree headed by
-** pExpr. This function increments *piLeft by the total number of tokens
-** in the expression tree headed by pExpr.
-**
-** Return 1 if any trimming occurs.  Return 0 if no trimming is required.
-*/
-static int trimSnippetOffsets(
-  Fts3Expr *pExpr,      /* The search expression */
-  Snippet *pSnippet,    /* The set of snippet offsets to be trimmed */
-  int *piLeft           /* Index of left-most token in pExpr */
-){
-  if( pExpr ){
-    if( trimSnippetOffsets(pExpr->pLeft, pSnippet, piLeft) ){
-      return 1;
+    case MERGE_POS_PHRASE:
+    case MERGE_PHRASE: {
+      char **ppPos = (mergetype==MERGE_PHRASE ? 0 : &p);
+      while( p1 && p2 ){
+        if( i1==i2 ){
+          char *pSave = p;
+          sqlite3_int64 iPrevSave = iPrev;
+          fts3PutDeltaVarint(&p, &iPrev, i1);
+          if( 0==fts3PoslistPhraseMerge(ppPos, 1, 0, &p1, &p2) ){
+            p = pSave;
+            iPrev = iPrevSave;
+          }
+          fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+          fts3GetDeltaVarint2(&p2, pEnd2, &i2);
+        }else if( i1<i2 ){
+          fts3PoslistCopy(0, &p1);
+          fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+        }else{
+          fts3PoslistCopy(0, &p2);
+          fts3GetDeltaVarint2(&p2, pEnd2, &i2);
+        }
+      }
+      break;
     }
 
-    switch( pExpr->eType ){
-      case FTSQUERY_PHRASE:
-        *piLeft += pExpr->pPhrase->nToken;
-        break;
-      case FTSQUERY_NEAR: {
-        /* The right-hand-side of a NEAR operator is always a phrase. The
-        ** left-hand-side is either a phrase or an expression tree that is 
-        ** itself headed by a NEAR operator. The following initializations
-        ** set local variable iLeft to the token number of the left-most
-        ** token in the right-hand phrase, and iRight to the right most
-        ** token in the same phrase. For example, if we had:
-        **
-        **     <col> MATCH '"abc def" NEAR/2 "ghi jkl"'
-        **
-        ** then iLeft will be set to 2 (token number of ghi) and nToken will
-        ** be set to 4.
-        */
-        Fts3Expr *pLeft = pExpr->pLeft;
-        Fts3Expr *pRight = pExpr->pRight;
-        int iLeft = *piLeft;
-        int nNear = pExpr->nNear;
-        int nToken = pRight->pPhrase->nToken;
-        int jj, ii;
-        if( pLeft->eType==FTSQUERY_NEAR ){
-          pLeft = pLeft->pRight;
+    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));
+        if( !aTmp ){
+          return SQLITE_NOMEM;
         }
-        assert( pRight->eType==FTSQUERY_PHRASE );
-        assert( pLeft->eType==FTSQUERY_PHRASE );
-        nToken += pLeft->pPhrase->nToken;
+      }
 
-        for(ii=0; ii<pSnippet->nMatch; ii++){
-          struct snippetMatch *p = &pSnippet->aMatch[ii];
-          if( p->iTerm==iLeft ){
-            int isOk = 0;
-            /* Snippet ii is an occurence of query term iLeft in the document.
-            ** It occurs at position (p->iToken) of the document. We now
-            ** search for an instance of token (iLeft-1) somewhere in the 
-            ** range (p->iToken - nNear)...(p->iToken + nNear + nToken) within 
-            ** the set of snippetMatch structures. If one is found, proceed. 
-            ** If one cannot be found, then remove snippets ii..(ii+N-1) 
-            ** from the matching snippets, where N is the number of tokens 
-            ** in phrase pRight->pPhrase.
-            */
-            for(jj=0; isOk==0 && jj<pSnippet->nMatch; jj++){
-              struct snippetMatch *p2 = &pSnippet->aMatch[jj];
-              if( p2->iTerm==(iLeft-1) ){
-                if( p2->iToken>=(p->iToken-nNear-1) 
-                 && p2->iToken<(p->iToken+nNear+nToken) 
-                ){
-                  isOk = 1;
-                }
-              }
-            }
-            if( !isOk ){
-              int kk;
-              for(kk=0; kk<pRight->pPhrase->nToken; kk++){
-                pSnippet->aMatch[kk+ii].iTerm = -2;
-              }
-              return 1;
-            }
-          }
-          if( p->iTerm==(iLeft-1) ){
-            int isOk = 0;
-            for(jj=0; isOk==0 && jj<pSnippet->nMatch; jj++){
-              struct snippetMatch *p2 = &pSnippet->aMatch[jj];
-              if( p2->iTerm==iLeft ){
-                if( p2->iToken<=(p->iToken+nNear+1) 
-                 && p2->iToken>(p->iToken-nNear-nToken) 
-                ){
-                  isOk = 1;
-                }
-              }
-            }
-            if( !isOk ){
-              int kk;
-              for(kk=0; kk<pLeft->pPhrase->nToken; kk++){
-                pSnippet->aMatch[ii-kk].iTerm = -2;
-              }
-              return 1;
-            }
+      while( p1 && p2 ){
+        if( i1==i2 ){
+          char *pSave = p;
+          sqlite3_int64 iPrevSave = iPrev;
+          fts3PutDeltaVarint(&p, &iPrev, i1);
+
+          if( !fts3PoslistNearMerge(ppPos, aTmp, nParam1, nParam2, &p1, &p2) ){
+            iPrev = iPrevSave;
+            p = pSave;
           }
+
+          fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+          fts3GetDeltaVarint2(&p2, pEnd2, &i2);
+        }else if( i1<i2 ){
+          fts3PoslistCopy(0, &p1);
+          fts3GetDeltaVarint2(&p1, pEnd1, &i1);
+        }else{
+          fts3PoslistCopy(0, &p2);
+          fts3GetDeltaVarint2(&p2, pEnd2, &i2);
         }
-        break;
       }
-    }
-
-    if( trimSnippetOffsets(pExpr->pRight, pSnippet, piLeft) ){
-      return 1;
+      sqlite3_free(aTmp);
+      break;
     }
   }
-  return 0;
+
+  *pnBuffer = (int)(p-aBuffer);
+  return SQLITE_OK;
 }
 
+/* 
+** A pointer to an instance of this structure is used as the context 
+** argument to sqlite3Fts3SegReaderIterate()
+*/
+typedef struct TermSelect TermSelect;
+struct TermSelect {
+  int isReqPos;
+  char *aOutput;                  /* Malloc'd output buffer */
+  int nOutput;                    /* Size of output in bytes */
+};
+
 /*
-** Compute all offsets for the current row of the query.  
-** If the offsets have already been computed, this routine is a no-op.
+** This function is used as the sqlite3Fts3SegReaderIterate() callback when
+** querying the full-text index for a doclist associated with a term or
+** term-prefix.
 */
-static void snippetAllOffsets(fulltext_cursor *p){
-  int nColumn;
-  int iColumn, i;
-  int iFirst, iLast;
-  int iTerm = 0;
-  fulltext_vtab *pFts = cursor_vtab(p);
+static int fts3TermSelectCb(
+  Fts3Table *p,                   /* Virtual table object */
+  void *pContext,                 /* Pointer to TermSelect structure */
+  char *zTerm,
+  int nTerm,
+  char *aDoclist,
+  int nDoclist
+){
+  TermSelect *pTS = (TermSelect *)pContext;
+  int nNew = pTS->nOutput + nDoclist;
+  char *aNew = sqlite3_malloc(nNew);
 
-  if( p->snippet.nMatch || p->pExpr==0 ){
-    return;
+  UNUSED_PARAMETER(p);
+  UNUSED_PARAMETER(zTerm);
+  UNUSED_PARAMETER(nTerm);
+
+  if( !aNew ){
+    return SQLITE_NOMEM;
   }
-  nColumn = pFts->nColumn;
-  iColumn = (p->iCursorType - QUERY_FULLTEXT);
-  if( iColumn<0 || iColumn>=nColumn ){
-    /* Look for matches over all columns of the full-text index */
-    iFirst = 0;
-    iLast = nColumn-1;
+
+  if( pTS->nOutput==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);
   }else{
-    /* Look for matches in the iColumn-th column of the index only */
-    iFirst = iColumn;
-    iLast = iColumn;
-  }
-  for(i=iFirst; i<=iLast; i++){
-    const char *zDoc;
-    int nDoc;
-    zDoc = (const char*)sqlite3_column_text(p->pStmt, i+1);
-    nDoc = sqlite3_column_bytes(p->pStmt, i+1);
-    snippetOffsetsOfColumn(p, &p->snippet, i, zDoc, nDoc);
+    /* 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
+    );
   }
 
-  while( trimSnippetOffsets(p->pExpr, &p->snippet, &iTerm) ){
-    iTerm = 0;
-  }
-}
+  sqlite3_free(pTS->aOutput);
+  pTS->aOutput = aNew;
+  pTS->nOutput = nNew;
 
-/*
-** Convert the information in the aMatch[] array of the snippet
-** into the string zOffset[0..nOffset-1]. This string is used as
-** the return of the SQL offsets() function.
-*/
-static void snippetOffsetText(Snippet *p){
-  int i;
-  int cnt = 0;
-  StringBuffer sb;
-  char zBuf[200];
-  if( p->zOffset ) return;
-  initStringBuffer(&sb);
-  for(i=0; i<p->nMatch; i++){
-    struct snippetMatch *pMatch = &p->aMatch[i];
-    if( pMatch->iTerm>=0 ){
-      /* If snippetMatch.iTerm is less than 0, then the match was 
-      ** discarded as part of processing the NEAR operator (see the 
-      ** trimSnippetOffsetsForNear() function for details). Ignore 
-      ** it in this case
-      */
-      zBuf[0] = ' ';
-      sqlite3_snprintf(sizeof(zBuf)-1, &zBuf[cnt>0], "%d %d %d %d",
-          pMatch->iCol, pMatch->iTerm, pMatch->iStart, pMatch->nByte);
-      append(&sb, zBuf);
-      cnt++;
-    }
-  }
-  p->zOffset = stringBufferData(&sb);
-  p->nOffset = stringBufferLength(&sb);
+  return SQLITE_OK;
 }
 
 /*
-** zDoc[0..nDoc-1] is phrase of text.  aMatch[0..nMatch-1] are a set
-** of matching words some of which might be in zDoc.  zDoc is column
-** number iCol.
+** This function retreives the doclist for the specified term (or term
+** prefix) from the database. 
 **
-** iBreak is suggested spot in zDoc where we could begin or end an
-** excerpt.  Return a value similar to iBreak but possibly adjusted
-** to be a little left or right so that the break point is better.
+** 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
+** doclists.
 */
-static int wordBoundary(
-  int iBreak,                   /* The suggested break point */
-  const char *zDoc,             /* Document text */
-  int nDoc,                     /* Number of bytes in zDoc[] */
-  struct snippetMatch *aMatch,  /* Matching words */
-  int nMatch,                   /* Number of entries in aMatch[] */
-  int iCol                      /* The column number for zDoc[] */
+static int fts3TermSelect(
+  Fts3Table *p,                   /* Virtual table handle */
+  int iColumn,                    /* Column to query (or -ve for all columns) */
+  const char *zTerm,              /* Term to query for */
+  int nTerm,                      /* Size of zTerm in bytes */
+  int isPrefix,                   /* True for a prefix search */
+  int isReqPos,                   /* True to include position lists in output */
+  int *pnOut,                     /* OUT: Size of buffer at *ppOut */
+  char **ppOut                    /* OUT: Malloced result buffer */
 ){
   int i;
-  if( iBreak<=10 ){
-    return 0;
-  }
-  if( iBreak>=nDoc-10 ){
-    return nDoc;
-  }
-  for(i=0; i<nMatch && aMatch[i].iCol<iCol; i++){}
-  while( i<nMatch && aMatch[i].iStart+aMatch[i].nByte<iBreak ){ i++; }
-  if( i<nMatch ){
-    if( aMatch[i].iStart<iBreak+10 ){
-      return aMatch[i].iStart;
-    }
-    if( i>0 && aMatch[i-1].iStart+aMatch[i-1].nByte>=iBreak ){
-      return aMatch[i-1].iStart;
-    }
-  }
-  for(i=1; i<=10; i++){
-    if( safe_isspace(zDoc[iBreak-i]) ){
-      return iBreak - i + 1;
-    }
-    if( safe_isspace(zDoc[iBreak+i]) ){
-      return iBreak + i + 1;
-    }
-  }
-  return iBreak;
-}
-
-
-
-/*
-** Allowed values for Snippet.aMatch[].snStatus
-*/
-#define SNIPPET_IGNORE  0   /* It is ok to omit this match from the snippet */
-#define SNIPPET_DESIRED 1   /* We want to include this match in the snippet */
-
-/*
-** Generate the text of a snippet.
-*/
-static void snippetText(
-  fulltext_cursor *pCursor,   /* The cursor we need the snippet for */
-  const char *zStartMark,     /* Markup to appear before each match */
-  const char *zEndMark,       /* Markup to appear after each match */
-  const char *zEllipsis       /* Ellipsis mark */
-){
-  int i, j;
-  struct snippetMatch *aMatch;
-  int nMatch;
-  int nDesired;
-  StringBuffer sb;
-  int tailCol;
-  int tailOffset;
-  int iCol;
-  int nDoc;
-  const char *zDoc;
-  int iStart, iEnd;
-  int tailEllipsis = 0;
-  int iMatch;
-  
-
-  sqlite3_free(pCursor->snippet.zSnippet);
-  pCursor->snippet.zSnippet = 0;
-  aMatch = pCursor->snippet.aMatch;
-  nMatch = pCursor->snippet.nMatch;
-  initStringBuffer(&sb);
+  TermSelect tsc;
+  Fts3SegFilter filter;           /* Segment term filter configuration */
+  Fts3SegReader **apSegment;      /* Array of segments to read data from */
+  int nSegment = 0;               /* Size of apSegment array */
+  int nAlloc = 16;                /* Allocated size of segment array */
+  int rc;                         /* Return code */
+  sqlite3_stmt *pStmt = 0;        /* SQL statement to scan %_segdir table */
+  int iAge = 0;                   /* Used to assign ages to segments */
+
+  apSegment = (Fts3SegReader **)sqlite3_malloc(sizeof(Fts3SegReader*)*nAlloc);
+  if( !apSegment ) return SQLITE_NOMEM;
+  rc = sqlite3Fts3SegReaderPending(p, zTerm, nTerm, isPrefix, &apSegment[0]);
+  if( rc!=SQLITE_OK ) goto finished;
+  if( apSegment[0] ){
+    nSegment = 1;
+  }
+
+  /* Loop through the entire %_segdir table. For each segment, create a
+  ** Fts3SegReader to iterate through the subset of the segment leaves
+  ** that may contain a term that matches zTerm/nTerm. For non-prefix
+  ** searches, this is always a single leaf. For prefix searches, this
+  ** may be a contiguous block of leaves.
+  **
+  ** The code in this loop does not actually load any leaves into memory
+  ** (unless the root node happens to be a leaf). It simply examines the
+  ** b-tree structure to determine which leaves need to be inspected.
+  */
+  rc = sqlite3Fts3AllSegdirs(p, &pStmt);
+  while( rc==SQLITE_OK && SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){
+    Fts3SegReader *pNew = 0;
+    int nRoot = sqlite3_column_bytes(pStmt, 4);
+    char const *zRoot = sqlite3_column_blob(pStmt, 4);
+    if( sqlite3_column_int64(pStmt, 1)==0 ){
+      /* The entire segment is stored on the root node (which must be a
+      ** leaf). Do not bother inspecting any data in this case, just
+      ** create a Fts3SegReader to scan the single leaf. 
+      */
+      rc = sqlite3Fts3SegReaderNew(p, iAge, 0, 0, 0, zRoot, nRoot, &pNew);
+    }else{
+      int rc2;                    /* Return value of sqlite3Fts3ReadBlock() */
+      sqlite3_int64 i1;           /* Blockid of leaf that may contain zTerm */
+      rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &i1);
+      if( rc==SQLITE_OK ){
+        sqlite3_int64 i2 = sqlite3_column_int64(pStmt, 2);
+        rc = sqlite3Fts3SegReaderNew(p, iAge, i1, i2, 0, 0, 0, &pNew);
+      }
 
-  for(i=0; i<nMatch; i++){
-    aMatch[i].snStatus = SNIPPET_IGNORE;
-  }
-  nDesired = 0;
-  for(i=0; i<FTS3_ROTOR_SZ; i++){
-    for(j=0; j<nMatch; j++){
-      if( aMatch[j].iTerm==i ){
-        aMatch[j].snStatus = SNIPPET_DESIRED;
-        nDesired++;
-        break;
+      /* The following call to ReadBlock() serves to reset the SQL statement
+      ** used to retrieve blocks of data from the %_segments table. If it is
+      ** not reset here, then it may remain classified as an active statement 
+      ** by SQLite, which may lead to "DROP TABLE" or "DETACH" commands 
+      ** failing.
+      */ 
+      rc2 = sqlite3Fts3ReadBlock(p, 0, 0, 0);
+      if( rc==SQLITE_OK ){
+        rc = rc2;
       }
     }
-  }
+    iAge++;
 
-  iMatch = 0;
-  tailCol = -1;
-  tailOffset = 0;
-  for(i=0; i<nMatch && nDesired>0; i++){
-    if( aMatch[i].snStatus!=SNIPPET_DESIRED ) continue;
-    nDesired--;
-    iCol = aMatch[i].iCol;
-    zDoc = (const char*)sqlite3_column_text(pCursor->pStmt, iCol+1);
-    nDoc = sqlite3_column_bytes(pCursor->pStmt, iCol+1);
-    iStart = aMatch[i].iStart - 40;
-    iStart = wordBoundary(iStart, zDoc, nDoc, aMatch, nMatch, iCol);
-    if( iStart<=10 ){
-      iStart = 0;
-    }
-    if( iCol==tailCol && iStart<=tailOffset+20 ){
-      iStart = tailOffset;
-    }
-    if( (iCol!=tailCol && tailCol>=0) || iStart!=tailOffset ){
-      trimWhiteSpace(&sb);
-      appendWhiteSpace(&sb);
-      append(&sb, zEllipsis);
-      appendWhiteSpace(&sb);
-    }
-    iEnd = aMatch[i].iStart + aMatch[i].nByte + 40;
-    iEnd = wordBoundary(iEnd, zDoc, nDoc, aMatch, nMatch, iCol);
-    if( iEnd>=nDoc-10 ){
-      iEnd = nDoc;
-      tailEllipsis = 0;
-    }else{
-      tailEllipsis = 1;
-    }
-    while( iMatch<nMatch && aMatch[iMatch].iCol<iCol ){ iMatch++; }
-    while( iStart<iEnd ){
-      while( iMatch<nMatch && aMatch[iMatch].iStart<iStart
-             && aMatch[iMatch].iCol<=iCol ){
-        iMatch++;
-      }
-      if( iMatch<nMatch && aMatch[iMatch].iStart<iEnd
-             && aMatch[iMatch].iCol==iCol ){
-        nappend(&sb, &zDoc[iStart], aMatch[iMatch].iStart - iStart);
-        iStart = aMatch[iMatch].iStart;
-        append(&sb, zStartMark);
-        nappend(&sb, &zDoc[iStart], aMatch[iMatch].nByte);
-        append(&sb, zEndMark);
-        iStart += aMatch[iMatch].nByte;
-        for(j=iMatch+1; j<nMatch; j++){
-          if( aMatch[j].iTerm==aMatch[iMatch].iTerm
-              && aMatch[j].snStatus==SNIPPET_DESIRED ){
-            nDesired--;
-            aMatch[j].snStatus = SNIPPET_IGNORE;
-          }
+    /* If a new Fts3SegReader was allocated, add it to the apSegment array. */
+    assert( pNew!=0 || rc!=SQLITE_OK );
+    if( pNew ){
+      if( nSegment==nAlloc ){
+        Fts3SegReader **pArray;
+        nAlloc += 16;
+        pArray = (Fts3SegReader **)sqlite3_realloc(
+            apSegment, nAlloc*sizeof(Fts3SegReader *)
+        );
+        if( !pArray ){
+          sqlite3Fts3SegReaderFree(p, pNew);
+          rc = SQLITE_NOMEM;
+          goto finished;
         }
-      }else{
-        nappend(&sb, &zDoc[iStart], iEnd - iStart);
-        iStart = iEnd;
+        apSegment = pArray;
       }
+      apSegment[nSegment++] = pNew;
     }
-    tailCol = iCol;
-    tailOffset = iEnd;
   }
-  trimWhiteSpace(&sb);
-  if( tailEllipsis ){
-    appendWhiteSpace(&sb);
-    append(&sb, zEllipsis);
+  if( rc!=SQLITE_DONE ){
+    assert( rc!=SQLITE_OK );
+    goto finished;
   }
-  pCursor->snippet.zSnippet = stringBufferData(&sb);
-  pCursor->snippet.nSnippet = stringBufferLength(&sb);
-}
 
+  memset(&tsc, 0, sizeof(TermSelect));
+  tsc.isReqPos = isReqPos;
 
-/*
-** Close the cursor.  For additional information see the documentation
-** on the xClose method of the virtual table interface.
-*/
-static int fulltextClose(sqlite3_vtab_cursor *pCursor){
-  fulltext_cursor *c = (fulltext_cursor *) pCursor;
-  FTSTRACE(("FTS3 Close %p\n", c));
-  sqlite3_finalize(c->pStmt);
-  sqlite3Fts3ExprFree(c->pExpr);
-  snippetClear(&c->snippet);
-  if( c->result.nData!=0 ){
-    dlrDestroy(&c->reader);
-  }
-  dataBufferDestroy(&c->result);
-  sqlite3_free(c);
-  return SQLITE_OK;
-}
+  filter.flags = FTS3_SEGMENT_IGNORE_EMPTY 
+        | (isPrefix ? FTS3_SEGMENT_PREFIX : 0)
+        | (isReqPos ? FTS3_SEGMENT_REQUIRE_POS : 0)
+        | (iColumn<p->nColumn ? FTS3_SEGMENT_COLUMN_FILTER : 0);
+  filter.iCol = iColumn;
+  filter.zTerm = zTerm;
+  filter.nTerm = nTerm;
 
-static int fulltextNext(sqlite3_vtab_cursor *pCursor){
-  fulltext_cursor *c = (fulltext_cursor *) pCursor;
-  int rc;
+  rc = sqlite3Fts3SegReaderIterate(p, apSegment, nSegment, &filter,
+      fts3TermSelectCb, (void *)&tsc
+  );
 
-  FTSTRACE(("FTS3 Next %p\n", pCursor));
-  snippetClear(&c->snippet);
-  if( c->iCursorType < QUERY_FULLTEXT ){
-    /* TODO(shess) Handle SQLITE_SCHEMA AND SQLITE_BUSY. */
-    rc = sqlite3_step(c->pStmt);
-    switch( rc ){
-      case SQLITE_ROW:
-        c->eof = 0;
-        return SQLITE_OK;
-      case SQLITE_DONE:
-        c->eof = 1;
-        return SQLITE_OK;
-      default:
-        c->eof = 1;
-        return rc;
-    }
-  } else {  /* full-text query */
-    rc = sqlite3_reset(c->pStmt);
-    if( rc!=SQLITE_OK ) return rc;
+  if( rc==SQLITE_OK ){
+    *ppOut = tsc.aOutput;
+    *pnOut = tsc.nOutput;
+  }else{
+    sqlite3_free(tsc.aOutput);
+  }
 
-    if( c->result.nData==0 || dlrAtEnd(&c->reader) ){
-      c->eof = 1;
-      return SQLITE_OK;
-    }
-    rc = sqlite3_bind_int64(c->pStmt, 1, dlrDocid(&c->reader));
-    dlrStep(&c->reader);
-    if( rc!=SQLITE_OK ) return rc;
-    /* TODO(shess) Handle SQLITE_SCHEMA AND SQLITE_BUSY. */
-    rc = sqlite3_step(c->pStmt);
-    if( rc==SQLITE_ROW ){   /* the case we expect */
-      c->eof = 0;
-      return SQLITE_OK;
-    }
-    /* an error occurred; abort */
-    return rc==SQLITE_DONE ? SQLITE_ERROR : rc;
+finished:
+  sqlite3_reset(pStmt);
+  for(i=0; i<nSegment; i++){
+    sqlite3Fts3SegReaderFree(p, apSegment[i]);
   }
+  sqlite3_free(apSegment);
+  return rc;
 }
 
 
-/* TODO(shess) If we pushed LeafReader to the top of the file, or to
-** another file, term_select() could be pushed above
-** docListOfTerm().
-*/
-static int termSelect(fulltext_vtab *v, int iColumn,
-                      const char *pTerm, int nTerm, int isPrefix,
-                      DocListType iType, DataBuffer *out);
-
 /* 
 ** Return a DocList corresponding to the phrase *pPhrase.
-**
-** The resulting DL_DOCIDS doclist is stored in pResult, which is
-** overwritten.
 */
-static int docListOfPhrase(
-  fulltext_vtab *pTab,   /* The full text index */
-  Fts3Phrase *pPhrase,   /* Phrase to return a doclist corresponding to */
-  DocListType eListType, /* Either DL_DOCIDS or DL_POSITIONS */
-  DataBuffer *pResult    /* Write the result here */
+static int fts3PhraseSelect(
+  Fts3Table *p,                   /* Virtual table handle */
+  Fts3Phrase *pPhrase,            /* Phrase to return a doclist for */
+  int isReqPos,                   /* True if output should contain positions */
+  char **paOut,                   /* OUT: Pointer to malloc'd result buffer */
+  int *pnOut                      /* OUT: Size of buffer at *paOut */
 ){
-  int ii;
+  char *pOut = 0;
+  int nOut = 0;
   int rc = SQLITE_OK;
+  int ii;
   int iCol = pPhrase->iColumn;
-  DocListType eType = eListType;
-  assert( eType==DL_POSITIONS || eType==DL_DOCIDS );
-  if( pPhrase->nToken>1 ){
-    eType = DL_POSITIONS;
-  }
+  int isTermPos = (pPhrase->nToken>1 || isReqPos);
 
-  /* This code should never be called with buffered updates. */
-  assert( pTab->nPendingData<0 );
+  for(ii=0; ii<pPhrase->nToken; ii++){
+    struct PhraseToken *pTok = &pPhrase->aToken[ii];
+    char *z = pTok->z;            /* Next token of the phrase */
+    int n = pTok->n;              /* Size of z in bytes */
+    int isPrefix = pTok->isPrefix;/* True if token is a prefix */
+    char *pList;                  /* Pointer to token doclist */
+    int nList;                    /* Size of buffer at pList */
 
-  for(ii=0; rc==SQLITE_OK && ii<pPhrase->nToken; ii++){
-    DataBuffer tmp;
-    struct PhraseToken *p = &pPhrase->aToken[ii];
-    rc = termSelect(pTab, iCol, p->z, p->n, p->isPrefix, eType, &tmp);
-    if( rc==SQLITE_OK ){
-      if( ii==0 ){
-        *pResult = tmp;
-      }else{
-        DataBuffer res = *pResult;
-        dataBufferInit(pResult, 0);
-        if( ii==(pPhrase->nToken-1) ){
-          eType = eListType;
-        }
-        docListPhraseMerge(
-          res.pData, res.nData, tmp.pData, tmp.nData, 0, 0, eType, pResult
-        );
-        dataBufferDestroy(&res);
-        dataBufferDestroy(&tmp);
+    rc = fts3TermSelect(p, iCol, z, n, isPrefix, isTermPos, &nList, &pList);
+    if( rc!=SQLITE_OK ) break;
+
+    if( ii==0 ){
+      pOut = pList;
+      nOut = nList;
+    }else{
+      /* Merge the new term list and the current output. If this is the
+      ** last term in the phrase, and positions are not required in the
+      ** output of this function, the positions can be dropped as part
+      ** of this merge. Either way, the result of this merge will be
+      ** smaller than nList bytes. The code in fts3DoclistMerge() is written
+      ** so that it is safe to use pList as the output as well as an input
+      ** in this case.
+      */
+      int mergetype = MERGE_POS_PHRASE;
+      if( ii==pPhrase->nToken-1 && !isReqPos ){
+        mergetype = MERGE_PHRASE;
       }
+      fts3DoclistMerge(mergetype, 0, 0, pList, &nOut, pOut, nOut, pList, nList);
+      sqlite3_free(pOut);
+      pOut = pList;
     }
+    assert( nOut==0 || pOut!=0 );
   }
 
+  if( rc==SQLITE_OK ){
+    *paOut = pOut;
+    *pnOut = nOut;
+  }else{
+    sqlite3_free(pOut);
+  }
   return rc;
 }
 
 /*
-** Evaluate the full-text expression pExpr against fts3 table pTab. Write
-** the results into pRes.
+** Evaluate the full-text expression pExpr against fts3 table pTab. Store
+** the resulting doclist in *paOut and *pnOut.
 */
 static int evalFts3Expr(
-  fulltext_vtab *pTab,           /* Fts3 Virtual table object */
-  Fts3Expr *pExpr,               /* Parsed fts3 expression */
-  DataBuffer *pRes               /* OUT: Write results of the expression here */
+  Fts3Table *p,                   /* Virtual table handle */
+  Fts3Expr *pExpr,                /* Parsed fts3 expression */
+  char **paOut,                   /* OUT: Pointer to malloc'd result buffer */
+  int *pnOut,                     /* OUT: Size of buffer at *paOut */
+  int isReqPos                    /* Require positions in output buffer */
 ){
-  int rc = SQLITE_OK;
+  int rc = SQLITE_OK;             /* Return code */
 
-  /* Initialize the output buffer. If this is an empty query (pExpr==0), 
-  ** this is all that needs to be done. Empty queries produce empty 
-  ** result sets.
-  */
-  dataBufferInit(pRes, 0);
+  /* Zero the output parameters. */
+  *paOut = 0;
+  *pnOut = 0;
 
   if( pExpr ){
+    assert( pExpr->eType==FTSQUERY_PHRASE 
+         || pExpr->eType==FTSQUERY_NEAR 
+         || isReqPos==0
+    );
     if( pExpr->eType==FTSQUERY_PHRASE ){
-      DocListType eType = DL_DOCIDS;
-      if( pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR ){
-        eType = DL_POSITIONS;
-      }
-      rc = docListOfPhrase(pTab, pExpr->pPhrase, eType, pRes);
+      rc = fts3PhraseSelect(p, pExpr->pPhrase, 
+          isReqPos || (pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR),
+          paOut, pnOut
+      );
     }else{
-      DataBuffer lhs;
-      DataBuffer rhs;
+      char *aLeft;
+      char *aRight;
+      int nLeft;
+      int nRight;
 
-      dataBufferInit(&rhs, 0);
-      if( SQLITE_OK==(rc = evalFts3Expr(pTab, pExpr->pLeft, &lhs)) 
-       && SQLITE_OK==(rc = evalFts3Expr(pTab, pExpr->pRight, &rhs)) 
+      if( 0==(rc = evalFts3Expr(p, pExpr->pRight, &aRight, &nRight, isReqPos))
+       && 0==(rc = evalFts3Expr(p, pExpr->pLeft, &aLeft, &nLeft, isReqPos))
       ){
+        assert( pExpr->eType==FTSQUERY_NEAR || pExpr->eType==FTSQUERY_OR     
+            || pExpr->eType==FTSQUERY_AND  || pExpr->eType==FTSQUERY_NOT
+        );
         switch( pExpr->eType ){
           case FTSQUERY_NEAR: {
-            int nToken;
             Fts3Expr *pLeft;
-            DocListType eType = DL_DOCIDS;
+            Fts3Expr *pRight;
+            int mergetype = isReqPos ? MERGE_POS_NEAR : MERGE_NEAR;
+            int nParam1;
+            int nParam2;
+            char *aBuffer;
+           
             if( pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR ){
-              eType = DL_POSITIONS;
+              mergetype = MERGE_POS_NEAR;
             }
             pLeft = pExpr->pLeft;
             while( pLeft->eType==FTSQUERY_NEAR ){ 
               pLeft=pLeft->pRight;
             }
-            assert( pExpr->pRight->eType==FTSQUERY_PHRASE );
+            pRight = pExpr->pRight;
+            assert( pRight->eType==FTSQUERY_PHRASE );
             assert( pLeft->eType==FTSQUERY_PHRASE );
-            nToken = pLeft->pPhrase->nToken + pExpr->pRight->pPhrase->nToken;
-            docListPhraseMerge(lhs.pData, lhs.nData, rhs.pData, rhs.nData, 
-                pExpr->nNear+1, nToken, eType, pRes
+
+            nParam1 = pExpr->nNear+1;
+            nParam2 = nParam1+pLeft->pPhrase->nToken+pRight->pPhrase->nToken-2;
+            aBuffer = sqlite3_malloc(nLeft+nRight+1);
+            rc = fts3DoclistMerge(mergetype, nParam1, nParam2, aBuffer,
+                pnOut, aLeft, nLeft, aRight, nRight
             );
+            if( rc!=SQLITE_OK ){
+              sqlite3_free(aBuffer);
+            }else{
+              *paOut = aBuffer;
+            }
+            sqlite3_free(aLeft);
             break;
           }
-          case FTSQUERY_NOT: {
-            docListExceptMerge(lhs.pData, lhs.nData, rhs.pData, rhs.nData,pRes);
-            break;
-          }
-          case FTSQUERY_AND: {
-            docListAndMerge(lhs.pData, lhs.nData, rhs.pData, rhs.nData, pRes);
+
+          case FTSQUERY_OR: {
+            /* Allocate a buffer for the output. The maximum size is the
+            ** sum of the sizes of the two input buffers. The +1 term is
+            ** so that a buffer of zero bytes is never allocated - this can
+            ** cause fts3DoclistMerge() to incorrectly return SQLITE_NOMEM.
+            */
+            char *aBuffer = sqlite3_malloc(nRight+nLeft+1);
+            rc = fts3DoclistMerge(MERGE_OR, 0, 0, aBuffer, pnOut,
+                aLeft, nLeft, aRight, nRight
+            );
+            *paOut = aBuffer;
+            sqlite3_free(aLeft);
             break;
           }
-          case FTSQUERY_OR: {
-            docListOrMerge(lhs.pData, lhs.nData, rhs.pData, rhs.nData, pRes);
+
+          default: {
+            assert( FTSQUERY_NOT==MERGE_NOT && FTSQUERY_AND==MERGE_AND );
+            fts3DoclistMerge(pExpr->eType, 0, 0, aLeft, pnOut,
+                aLeft, nLeft, aRight, nRight
+            );
+            *paOut = aLeft;
             break;
           }
         }
       }
-      dataBufferDestroy(&lhs);
-      dataBufferDestroy(&rhs);
+      sqlite3_free(aRight);
     }
   }
 
   return rc;
 }
 
-/* TODO(shess) Refactor the code to remove this forward decl. */
-static int flushPendingTerms(fulltext_vtab *v);
-
-/* Perform a full-text query using the search expression in
-** zInput[0..nInput-1].  Return a list of matching documents
-** in pResult.
-**
-** Queries must match column iColumn.  Or if iColumn>=nColumn
-** they are allowed to match against any column.
-*/
-static int fulltextQuery(
-  fulltext_vtab *v,      /* The full text index */
-  int iColumn,           /* Match against this column by default */
-  const char *zInput,    /* The query string */
-  int nInput,            /* Number of bytes in zInput[] */
-  DataBuffer *pResult,   /* Write the result doclist here */
-  Fts3Expr **ppExpr        /* Put parsed query string here */
-){
-  int rc;
-
-  /* TODO(shess) Instead of flushing pendingTerms, we could query for
-  ** the relevant term and merge the doclist into what we receive from
-  ** the database.  Wait and see if this is a common issue, first.
-  **
-  ** A good reason not to flush is to not generate update-related
-  ** error codes from here.
-  */
-
-  /* Flush any buffered updates before executing the query. */
-  rc = flushPendingTerms(v);
-  if( rc!=SQLITE_OK ){
-    return rc;
-  }
-
-  /* Parse the query passed to the MATCH operator. */
-  rc = sqlite3Fts3ExprParse(v->pTokenizer, 
-      v->azColumn, v->nColumn, iColumn, zInput, nInput, ppExpr
-  );
-  if( rc!=SQLITE_OK ){
-    assert( 0==(*ppExpr) );
-    return rc;
-  }
-
-  return evalFts3Expr(v, *ppExpr, pResult);
-}
-
 /*
 ** This is the xFilter interface for the virtual table.  See
 ** the virtual table xFilter method documentation for additional
 ** information.
 **
-** If idxNum==QUERY_GENERIC then do a full table scan against
+** If idxNum==FTS3_FULLSCAN_SEARCH then do a full table scan against
 ** the %_content table.
 **
-** If idxNum==QUERY_DOCID then do a docid lookup for a single entry
+** If idxNum==FTS3_DOCID_SEARCH then do a docid lookup for a single entry
 ** in the %_content table.
 **
-** If idxNum>=QUERY_FULLTEXT then use the full text index.  The
+** If idxNum>=FTS3_FULLTEXT_SEARCH then use the full text index.  The
 ** column on the left-hand side of the MATCH operator is column
-** number idxNum-QUERY_FULLTEXT, 0 indexed.  argv[0] is the right-hand
+** number idxNum-FTS3_FULLTEXT_SEARCH, 0 indexed.  argv[0] is the right-hand
 ** side of the MATCH operator.
 */
 /* TODO(shess) Upgrade the cursor initialization and destruction to
-** account for fulltextFilter() being called multiple times on the
-** same cursor.  The current solution is very fragile.  Apply fix to
+** account for fts3FilterMethod() being called multiple times on the
+** same cursor. The current solution is very fragile. Apply fix to
 ** fts3 as appropriate.
 */
-static int fulltextFilter(
-  sqlite3_vtab_cursor *pCursor,     /* The cursor used for this query */
-  int idxNum, const char *idxStr,   /* Which indexing scheme to use */
-  int argc, sqlite3_value **argv    /* Arguments for the indexing scheme */
+static int fts3FilterMethod(
+  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */
+  int idxNum,                     /* Strategy index */
+  const char *idxStr,             /* Unused */
+  int nVal,                       /* Number of elements in apVal */
+  sqlite3_value **apVal           /* Arguments for the indexing scheme */
 ){
-  fulltext_cursor *c = (fulltext_cursor *) pCursor;
-  fulltext_vtab *v = cursor_vtab(c);
-  int rc;
-
-  FTSTRACE(("FTS3 Filter %p\n",pCursor));
-
-  /* If the cursor has a statement that was not prepared according to
-  ** idxNum, clear it.  I believe all calls to fulltextFilter with a
-  ** given cursor will have the same idxNum , but in this case it's
-  ** easy to be safe.
-  */
-  if( c->pStmt && c->iCursorType!=idxNum ){
-    sqlite3_finalize(c->pStmt);
-    c->pStmt = NULL;
-  }
-
-  /* Get a fresh statement appropriate to idxNum. */
-  /* TODO(shess): Add a prepared-statement cache in the vt structure.
-  ** The cache must handle multiple open cursors.  Easier to cache the
-  ** statement variants at the vt to reduce malloc/realloc/free here.
-  ** Or we could have a StringBuffer variant which allowed stack
-  ** construction for small values.
-  */
-  if( !c->pStmt ){
-    StringBuffer sb;
-    initStringBuffer(&sb);
-    append(&sb, "SELECT docid, ");
-    appendList(&sb, v->nColumn, v->azContentColumn);
-    append(&sb, " FROM %_content");
-    if( idxNum!=QUERY_GENERIC ) append(&sb, " WHERE docid = ?");
-    rc = sql_prepare(v->db, v->zDb, v->zName, &c->pStmt,
-                     stringBufferData(&sb));
-    stringBufferDestroy(&sb);
-    if( rc!=SQLITE_OK ) return rc;
-    c->iCursorType = idxNum;
+  const char *azSql[] = {
+    "SELECT * FROM %Q.'%q_content' WHERE docid = ?", /* non-full-table-scan */
+    "SELECT * FROM %Q.'%q_content'",                 /* full-table-scan */
+  };
+  int rc;                         /* Return code */
+  char *zSql;                     /* SQL statement used to access %_content */
+  Fts3Table *p = (Fts3Table *)pCursor->pVtab;
+  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
+
+  UNUSED_PARAMETER(idxStr);
+  UNUSED_PARAMETER(nVal);
+
+  assert( idxNum>=0 && idxNum<=(FTS3_FULLTEXT_SEARCH+p->nColumn) );
+  assert( nVal==0 || nVal==1 );
+  assert( (nVal==0)==(idxNum==FTS3_FULLSCAN_SEARCH) );
+
+  /* In case the cursor has been used before, clear it now. */
+  sqlite3_finalize(pCsr->pStmt);
+  sqlite3_free(pCsr->aDoclist);
+  sqlite3Fts3ExprFree(pCsr->pExpr);
+  memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));
+
+  /* Compile a SELECT statement for this cursor. For a full-table-scan, the
+  ** statement loops through all rows of the %_content table. For a
+  ** full-text query or docid lookup, the statement retrieves a single
+  ** row by docid.
+  */
+  zSql = sqlite3_mprintf(azSql[idxNum==FTS3_FULLSCAN_SEARCH], p->zDb, p->zName);
+  if( !zSql ){
+    rc = SQLITE_NOMEM;
   }else{
-    sqlite3_reset(c->pStmt);
-    assert( c->iCursorType==idxNum );
-  }
-
-  switch( idxNum ){
-    case QUERY_GENERIC:
-      break;
-
-    case QUERY_DOCID:
-      rc = sqlite3_bind_int64(c->pStmt, 1, sqlite3_value_int64(argv[0]));
-      if( rc!=SQLITE_OK ) return rc;
-      break;
-
-    default:   /* full-text search */
-    {
-      int iCol = idxNum-QUERY_FULLTEXT;
-      const char *zQuery = (const char *)sqlite3_value_text(argv[0]);
-      assert( idxNum<=QUERY_FULLTEXT+v->nColumn);
-      assert( argc==1 );
-      if( c->result.nData!=0 ){
-        /* This case happens if the same cursor is used repeatedly. */
-        dlrDestroy(&c->reader);
-        dataBufferReset(&c->result);
-      }else{
-        dataBufferInit(&c->result, 0);
-      }
-      rc = fulltextQuery(v, iCol, zQuery, -1, &c->result, &c->pExpr);
-      if( rc!=SQLITE_OK ) return rc;
-      if( c->result.nData!=0 ){
-        dlrInit(&c->reader, DL_DOCIDS, c->result.pData, c->result.nData);
-      }
-      break;
-    }
-  }
-
-  return fulltextNext(pCursor);
-}
-
-/* This is the xEof method of the virtual table.  The SQLite core
-** calls this routine to find out if it has reached the end of
-** a query's results set.
-*/
-static int fulltextEof(sqlite3_vtab_cursor *pCursor){
-  fulltext_cursor *c = (fulltext_cursor *) pCursor;
-  return c->eof;
-}
-
-/* This is the xColumn method of the virtual table.  The SQLite
-** core calls this method during a query when it needs the value
-** of a column from the virtual table.  This method needs to use
-** one of the sqlite3_result_*() routines to store the requested
-** value back in the pContext.
-*/
-static int fulltextColumn(sqlite3_vtab_cursor *pCursor,
-                          sqlite3_context *pContext, int idxCol){
-  fulltext_cursor *c = (fulltext_cursor *) pCursor;
-  fulltext_vtab *v = cursor_vtab(c);
-
-  if( idxCol<v->nColumn ){
-    sqlite3_value *pVal = sqlite3_column_value(c->pStmt, idxCol+1);
-    sqlite3_result_value(pContext, pVal);
-  }else if( idxCol==v->nColumn ){
-    /* The extra column whose name is the same as the table.
-    ** Return a blob which is a pointer to the cursor
-    */
-    sqlite3_result_blob(pContext, &c, sizeof(c), SQLITE_TRANSIENT);
-  }else if( idxCol==v->nColumn+1 ){
-    /* The docid column, which is an alias for rowid. */
-    sqlite3_value *pVal = sqlite3_column_value(c->pStmt, 0);
-    sqlite3_result_value(pContext, pVal);
+    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
+    sqlite3_free(zSql);
   }
-  return SQLITE_OK;
-}
-
-/* This is the xRowid method.  The SQLite core calls this routine to
-** retrieve the rowid for the current row of the result set.  fts3
-** exposes %_content.docid as the rowid for the virtual table.  The
-** rowid should be written to *pRowid.
-*/
-static int fulltextRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
-  fulltext_cursor *c = (fulltext_cursor *) pCursor;
-
-  *pRowid = sqlite3_column_int64(c->pStmt, 0);
-  return SQLITE_OK;
-}
-
-/* Add all terms in [zText] to pendingTerms table.  If [iColumn] > 0,
-** we also store positions and offsets in the hash table using that
-** column number.
-*/
-static int buildTerms(fulltext_vtab *v, sqlite_int64 iDocid,
-                      const char *zText, int iColumn){
-  sqlite3_tokenizer *pTokenizer = v->pTokenizer;
-  sqlite3_tokenizer_cursor *pCursor;
-  const char *pToken;
-  int nTokenBytes;
-  int iStartOffset, iEndOffset, iPosition;
-  int rc;
-
-  rc = pTokenizer->pModule->xOpen(pTokenizer, zText, -1, &pCursor);
   if( rc!=SQLITE_OK ) return rc;
+  pCsr->eSearch = (i16)idxNum;
 
-  pCursor->pTokenizer = pTokenizer;
-  while( SQLITE_OK==(rc=pTokenizer->pModule->xNext(pCursor,
-                                                   &pToken, &nTokenBytes,
-                                                   &iStartOffset, &iEndOffset,
-                                                   &iPosition)) ){
-    DLCollector *p;
-    int nData;                   /* Size of doclist before our update. */
-
-    /* Positions can't be negative; we use -1 as a terminator
-     * internally.  Token can't be NULL or empty. */
-    if( iPosition<0 || pToken == NULL || nTokenBytes == 0 ){
-      rc = SQLITE_ERROR;
-      break;
-    }
+  if( idxNum==FTS3_DOCID_SEARCH ){
+    rc = sqlite3_bind_value(pCsr->pStmt, 1, apVal[0]);
+  }else if( idxNum!=FTS3_FULLSCAN_SEARCH ){
+    int iCol = idxNum-FTS3_FULLTEXT_SEARCH;
+    const char *zQuery = (const char *)sqlite3_value_text(apVal[0]);
 
-    p = fts3HashFind(&v->pendingTerms, pToken, nTokenBytes);
-    if( p==NULL ){
-      nData = 0;
-      p = dlcNew(iDocid, DL_DEFAULT);
-      fts3HashInsert(&v->pendingTerms, pToken, nTokenBytes, p);
-
-      /* Overhead for our hash table entry, the key, and the value. */
-      v->nPendingData += sizeof(struct fts3HashElem)+sizeof(*p)+nTokenBytes;
-    }else{
-      nData = p->b.nData;
-      if( p->dlw.iPrevDocid!=iDocid ) dlcNext(p, iDocid);
-    }
-    if( iColumn>=0 ){
-      dlcAddPos(p, iColumn, iPosition, iStartOffset, iEndOffset);
+    if( zQuery==0 && sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
+      return SQLITE_NOMEM;
     }
 
-    /* Accumulate data added by dlcNew or dlcNext, and dlcAddPos. */
-    v->nPendingData += p->b.nData-nData;
-  }
-
-  /* TODO(shess) Check return?  Should this be able to cause errors at
-  ** this point?  Actually, same question about sqlite3_finalize(),
-  ** though one could argue that failure there means that the data is
-  ** not durable.  *ponder*
-  */
-  pTokenizer->pModule->xClose(pCursor);
-  if( SQLITE_DONE == rc ) return SQLITE_OK;
-  return rc;
-}
-
-/* Add doclists for all terms in [pValues] to pendingTerms table. */
-static int insertTerms(fulltext_vtab *v, sqlite_int64 iDocid,
-                       sqlite3_value **pValues){
-  int i;
-  for(i = 0; i < v->nColumn ; ++i){
-    char *zText = (char*)sqlite3_value_text(pValues[i]);
-    int rc = buildTerms(v, iDocid, zText, i);
+    rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn, 
+        iCol, zQuery, -1, &pCsr->pExpr
+    );
     if( rc!=SQLITE_OK ) return rc;
-  }
-  return SQLITE_OK;
-}
-
-/* Add empty doclists for all terms in the given row's content to
-** pendingTerms.
-*/
-static int deleteTerms(fulltext_vtab *v, sqlite_int64 iDocid){
-  const char **pValues;
-  int i, rc;
-
-  /* TODO(shess) Should we allow such tables at all? */
-  if( DL_DEFAULT==DL_DOCIDS ) return SQLITE_ERROR;
-
-  rc = content_select(v, iDocid, &pValues);
-  if( rc!=SQLITE_OK ) return rc;
-
-  for(i = 0 ; i < v->nColumn; ++i) {
-    rc = buildTerms(v, iDocid, pValues[i], -1);
-    if( rc!=SQLITE_OK ) break;
-  }
-
-  freeStringArray(v->nColumn, pValues);
-  return SQLITE_OK;
-}
-
-/* TODO(shess) Refactor the code to remove this forward decl. */
-static int initPendingTerms(fulltext_vtab *v, sqlite_int64 iDocid);
-
-/* Insert a row into the %_content table; set *piDocid to be the ID of the
-** new row.  Add doclists for terms to pendingTerms.
-*/
-static int index_insert(fulltext_vtab *v, sqlite3_value *pRequestDocid,
-                        sqlite3_value **pValues, sqlite_int64 *piDocid){
-  int rc;
-
-  rc = content_insert(v, pRequestDocid, pValues);  /* execute an SQL INSERT */
-  if( rc!=SQLITE_OK ) return rc;
-
-  /* docid column is an alias for rowid. */
-  *piDocid = sqlite3_last_insert_rowid(v->db);
-  rc = initPendingTerms(v, *piDocid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  return insertTerms(v, *piDocid, pValues);
-}
-
-/* Delete a row from the %_content table; add empty doclists for terms
-** to pendingTerms.
-*/
-static int index_delete(fulltext_vtab *v, sqlite_int64 iRow){
-  int rc = initPendingTerms(v, iRow);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = deleteTerms(v, iRow);
-  if( rc!=SQLITE_OK ) return rc;
-
-  return content_delete(v, iRow);  /* execute an SQL DELETE */
-}
-
-/* Update a row in the %_content table; add delete doclists to
-** pendingTerms for old terms not in the new data, add insert doclists
-** to pendingTerms for terms in the new data.
-*/
-static int index_update(fulltext_vtab *v, sqlite_int64 iRow,
-                        sqlite3_value **pValues){
-  int rc = initPendingTerms(v, iRow);
-  if( rc!=SQLITE_OK ) return rc;
-
-  /* Generate an empty doclist for each term that previously appeared in this
-   * row. */
-  rc = deleteTerms(v, iRow);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = content_update(v, pValues, iRow);  /* execute an SQL UPDATE */
-  if( rc!=SQLITE_OK ) return rc;
-
-  /* Now add positions for terms which appear in the updated row. */
-  return insertTerms(v, iRow, pValues);
-}
-
-/*******************************************************************/
-/* InteriorWriter is used to collect terms and block references into
-** interior nodes in %_segments.  See commentary at top of file for
-** format.
-*/
-
-/* How large interior nodes can grow. */
-#define INTERIOR_MAX 2048
-
-/* Minimum number of terms per interior node (except the root). This
-** prevents large terms from making the tree too skinny - must be >0
-** so that the tree always makes progress.  Note that the min tree
-** fanout will be INTERIOR_MIN_TERMS+1.
-*/
-#define INTERIOR_MIN_TERMS 7
-#if INTERIOR_MIN_TERMS<1
-# error INTERIOR_MIN_TERMS must be greater than 0.
-#endif
-
-/* ROOT_MAX controls how much data is stored inline in the segment
-** directory.
-*/
-/* TODO(shess) Push ROOT_MAX down to whoever is writing things.  It's
-** only here so that interiorWriterRootInfo() and leafWriterRootInfo()
-** can both see it, but if the caller passed it in, we wouldn't even
-** need a define.
-*/
-#define ROOT_MAX 1024
-#if ROOT_MAX<VARINT_MAX*2
-# error ROOT_MAX must have enough space for a header.
-#endif
-
-/* InteriorBlock stores a linked-list of interior blocks while a lower
-** layer is being constructed.
-*/
-typedef struct InteriorBlock {
-  DataBuffer term;           /* Leftmost term in block's subtree. */
-  DataBuffer data;           /* Accumulated data for the block. */
-  struct InteriorBlock *next;
-} InteriorBlock;
-
-static InteriorBlock *interiorBlockNew(int iHeight, sqlite_int64 iChildBlock,
-                                       const char *pTerm, int nTerm){
-  InteriorBlock *block = sqlite3_malloc(sizeof(InteriorBlock));
-  char c[VARINT_MAX+VARINT_MAX];
-  int n;
-
-  if( block ){
-    memset(block, 0, sizeof(*block));
-    dataBufferInit(&block->term, 0);
-    dataBufferReplace(&block->term, pTerm, nTerm);
-
-    n = fts3PutVarint(c, iHeight);
-    n += fts3PutVarint(c+n, iChildBlock);
-    dataBufferInit(&block->data, INTERIOR_MAX);
-    dataBufferReplace(&block->data, c, n);
-  }
-  return block;
-}
 
-#ifndef NDEBUG
-/* Verify that the data is readable as an interior node. */
-static void interiorBlockValidate(InteriorBlock *pBlock){
-  const char *pData = pBlock->data.pData;
-  int nData = pBlock->data.nData;
-  int n, iDummy;
-  sqlite_int64 iBlockid;
-
-  assert( nData>0 );
-  assert( pData!=0 );
-  assert( pData+nData>pData );
-
-  /* Must lead with height of node as a varint(n), n>0 */
-  n = fts3GetVarint32(pData, &iDummy);
-  assert( n>0 );
-  assert( iDummy>0 );
-  assert( n<nData );
-  pData += n;
-  nData -= n;
-
-  /* Must contain iBlockid. */
-  n = fts3GetVarint(pData, &iBlockid);
-  assert( n>0 );
-  assert( n<=nData );
-  pData += n;
-  nData -= n;
-
-  /* Zero or more terms of positive length */
-  if( nData!=0 ){
-    /* First term is not delta-encoded. */
-    n = fts3GetVarint32(pData, &iDummy);
-    assert( n>0 );
-    assert( iDummy>0 );
-    assert( n+iDummy>0);
-    assert( n+iDummy<=nData );
-    pData += n+iDummy;
-    nData -= n+iDummy;
-
-    /* Following terms delta-encoded. */
-    while( nData!=0 ){
-      /* Length of shared prefix. */
-      n = fts3GetVarint32(pData, &iDummy);
-      assert( n>0 );
-      assert( iDummy>=0 );
-      assert( n<nData );
-      pData += n;
-      nData -= n;
-
-      /* Length and data of distinct suffix. */
-      n = fts3GetVarint32(pData, &iDummy);
-      assert( n>0 );
-      assert( iDummy>0 );
-      assert( n+iDummy>0);
-      assert( n+iDummy<=nData );
-      pData += n+iDummy;
-      nData -= n+iDummy;
-    }
-  }
-}
-#define ASSERT_VALID_INTERIOR_BLOCK(x) interiorBlockValidate(x)
-#else
-#define ASSERT_VALID_INTERIOR_BLOCK(x) assert( 1 )
-#endif
-
-typedef struct InteriorWriter {
-  int iHeight;                   /* from 0 at leaves. */
-  InteriorBlock *first, *last;
-  struct InteriorWriter *parentWriter;
-
-  DataBuffer term;               /* Last term written to block "last". */
-  sqlite_int64 iOpeningChildBlock; /* First child block in block "last". */
-#ifndef NDEBUG
-  sqlite_int64 iLastChildBlock;  /* for consistency checks. */
-#endif
-} InteriorWriter;
-
-/* Initialize an interior node where pTerm[nTerm] marks the leftmost
-** term in the tree.  iChildBlock is the leftmost child block at the
-** next level down the tree.
-*/
-static void interiorWriterInit(int iHeight, const char *pTerm, int nTerm,
-                               sqlite_int64 iChildBlock,
-                               InteriorWriter *pWriter){
-  InteriorBlock *block;
-  assert( iHeight>0 );
-  CLEAR(pWriter);
-
-  pWriter->iHeight = iHeight;
-  pWriter->iOpeningChildBlock = iChildBlock;
-#ifndef NDEBUG
-  pWriter->iLastChildBlock = iChildBlock;
-#endif
-  block = interiorBlockNew(iHeight, iChildBlock, pTerm, nTerm);
-  pWriter->last = pWriter->first = block;
-  ASSERT_VALID_INTERIOR_BLOCK(pWriter->last);
-  dataBufferInit(&pWriter->term, 0);
-}
-
-/* Append the child node rooted at iChildBlock to the interior node,
-** with pTerm[nTerm] as the leftmost term in iChildBlock's subtree.
-*/
-static void interiorWriterAppend(InteriorWriter *pWriter,
-                                 const char *pTerm, int nTerm,
-                                 sqlite_int64 iChildBlock){
-  char c[VARINT_MAX+VARINT_MAX];
-  int n, nPrefix = 0;
-
-  ASSERT_VALID_INTERIOR_BLOCK(pWriter->last);
-
-  /* The first term written into an interior node is actually
-  ** associated with the second child added (the first child was added
-  ** in interiorWriterInit, or in the if clause at the bottom of this
-  ** function).  That term gets encoded straight up, with nPrefix left
-  ** at 0.
-  */
-  if( pWriter->term.nData==0 ){
-    n = fts3PutVarint(c, nTerm);
-  }else{
-    while( nPrefix<pWriter->term.nData &&
-           pTerm[nPrefix]==pWriter->term.pData[nPrefix] ){
-      nPrefix++;
-    }
-
-    n = fts3PutVarint(c, nPrefix);
-    n += fts3PutVarint(c+n, nTerm-nPrefix);
-  }
-
-#ifndef NDEBUG
-  pWriter->iLastChildBlock++;
-#endif
-  assert( pWriter->iLastChildBlock==iChildBlock );
-
-  /* Overflow to a new block if the new term makes the current block
-  ** too big, and the current block already has enough terms.
-  */
-  if( pWriter->last->data.nData+n+nTerm-nPrefix>INTERIOR_MAX &&
-      iChildBlock-pWriter->iOpeningChildBlock>INTERIOR_MIN_TERMS ){
-    pWriter->last->next = interiorBlockNew(pWriter->iHeight, iChildBlock,
-                                           pTerm, nTerm);
-    pWriter->last = pWriter->last->next;
-    pWriter->iOpeningChildBlock = iChildBlock;
-    dataBufferReset(&pWriter->term);
-  }else{
-    dataBufferAppend2(&pWriter->last->data, c, n,
-                      pTerm+nPrefix, nTerm-nPrefix);
-    dataBufferReplace(&pWriter->term, pTerm, nTerm);
-  }
-  ASSERT_VALID_INTERIOR_BLOCK(pWriter->last);
-}
-
-/* Free the space used by pWriter, including the linked-list of
-** InteriorBlocks, and parentWriter, if present.
-*/
-static int interiorWriterDestroy(InteriorWriter *pWriter){
-  InteriorBlock *block = pWriter->first;
-
-  while( block!=NULL ){
-    InteriorBlock *b = block;
-    block = block->next;
-    dataBufferDestroy(&b->term);
-    dataBufferDestroy(&b->data);
-    sqlite3_free(b);
-  }
-  if( pWriter->parentWriter!=NULL ){
-    interiorWriterDestroy(pWriter->parentWriter);
-    sqlite3_free(pWriter->parentWriter);
-  }
-  dataBufferDestroy(&pWriter->term);
-  SCRAMBLE(pWriter);
-  return SQLITE_OK;
-}
-
-/* If pWriter can fit entirely in ROOT_MAX, return it as the root info
-** directly, leaving *piEndBlockid unchanged.  Otherwise, flush
-** pWriter to %_segments, building a new layer of interior nodes, and
-** recursively ask for their root into.
-*/
-static int interiorWriterRootInfo(fulltext_vtab *v, InteriorWriter *pWriter,
-                                  char **ppRootInfo, int *pnRootInfo,
-                                  sqlite_int64 *piEndBlockid){
-  InteriorBlock *block = pWriter->first;
-  sqlite_int64 iBlockid = 0;
-  int rc;
-
-  /* If we can fit the segment inline */
-  if( block==pWriter->last && block->data.nData<ROOT_MAX ){
-    *ppRootInfo = block->data.pData;
-    *pnRootInfo = block->data.nData;
-    return SQLITE_OK;
+    rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist, 0);
+    pCsr->pNextId = pCsr->aDoclist;
+    pCsr->iPrevId = 0;
   }
 
-  /* Flush the first block to %_segments, and create a new level of
-  ** interior node.
-  */
-  ASSERT_VALID_INTERIOR_BLOCK(block);
-  rc = block_insert(v, block->data.pData, block->data.nData, &iBlockid);
   if( rc!=SQLITE_OK ) return rc;
-  *piEndBlockid = iBlockid;
-
-  pWriter->parentWriter = sqlite3_malloc(sizeof(*pWriter->parentWriter));
-  interiorWriterInit(pWriter->iHeight+1,
-                     block->term.pData, block->term.nData,
-                     iBlockid, pWriter->parentWriter);
-
-  /* Flush additional blocks and append to the higher interior
-  ** node.
-  */
-  for(block=block->next; block!=NULL; block=block->next){
-    ASSERT_VALID_INTERIOR_BLOCK(block);
-    rc = block_insert(v, block->data.pData, block->data.nData, &iBlockid);
-    if( rc!=SQLITE_OK ) return rc;
-    *piEndBlockid = iBlockid;
-
-    interiorWriterAppend(pWriter->parentWriter,
-                         block->term.pData, block->term.nData, iBlockid);
-  }
-
-  /* Parent node gets the chance to be the root. */
-  return interiorWriterRootInfo(v, pWriter->parentWriter,
-                                ppRootInfo, pnRootInfo, piEndBlockid);
-}
-
-/****************************************************************/
-/* InteriorReader is used to read off the data from an interior node
-** (see comment at top of file for the format).
-*/
-typedef struct InteriorReader {
-  const char *pData;
-  int nData;
-
-  DataBuffer term;          /* previous term, for decoding term delta. */
-
-  sqlite_int64 iBlockid;
-} InteriorReader;
-
-static void interiorReaderDestroy(InteriorReader *pReader){
-  dataBufferDestroy(&pReader->term);
-  SCRAMBLE(pReader);
-}
-
-/* TODO(shess) The assertions are great, but what if we're in NDEBUG
-** and the blob is empty or otherwise contains suspect data?
-*/
-static void interiorReaderInit(const char *pData, int nData,
-                               InteriorReader *pReader){
-  int n, nTerm;
-
-  /* Require at least the leading flag byte */
-  assert( nData>0 );
-  assert( pData[0]!='\0' );
-
-  CLEAR(pReader);
-
-  /* Decode the base blockid, and set the cursor to the first term. */
-  n = fts3GetVarint(pData+1, &pReader->iBlockid);
-  assert( 1+n<=nData );
-  pReader->pData = pData+1+n;
-  pReader->nData = nData-(1+n);
-
-  /* A single-child interior node (such as when a leaf node was too
-  ** large for the segment directory) won't have any terms.
-  ** Otherwise, decode the first term.
-  */
-  if( pReader->nData==0 ){
-    dataBufferInit(&pReader->term, 0);
-  }else{
-    n = fts3GetVarint32(pReader->pData, &nTerm);
-    dataBufferInit(&pReader->term, nTerm);
-    dataBufferReplace(&pReader->term, pReader->pData+n, nTerm);
-    assert( n+nTerm<=pReader->nData );
-    pReader->pData += n+nTerm;
-    pReader->nData -= n+nTerm;
-  }
-}
-
-static int interiorReaderAtEnd(InteriorReader *pReader){
-  return pReader->term.nData==0;
-}
-
-static sqlite_int64 interiorReaderCurrentBlockid(InteriorReader *pReader){
-  return pReader->iBlockid;
+  return fts3NextMethod(pCursor);
 }
 
-static int interiorReaderTermBytes(InteriorReader *pReader){
-  assert( !interiorReaderAtEnd(pReader) );
-  return pReader->term.nData;
-}
-static const char *interiorReaderTerm(InteriorReader *pReader){
-  assert( !interiorReaderAtEnd(pReader) );
-  return pReader->term.pData;
-}
-
-/* Step forward to the next term in the node. */
-static void interiorReaderStep(InteriorReader *pReader){
-  assert( !interiorReaderAtEnd(pReader) );
-
-  /* If the last term has been read, signal eof, else construct the
-  ** next term.
-  */
-  if( pReader->nData==0 ){
-    dataBufferReset(&pReader->term);
-  }else{
-    int n, nPrefix, nSuffix;
-
-    n = fts3GetVarint32(pReader->pData, &nPrefix);
-    n += fts3GetVarint32(pReader->pData+n, &nSuffix);
-
-    /* Truncate the current term and append suffix data. */
-    pReader->term.nData = nPrefix;
-    dataBufferAppend(&pReader->term, pReader->pData+n, nSuffix);
-
-    assert( n+nSuffix<=pReader->nData );
-    pReader->pData += n+nSuffix;
-    pReader->nData -= n+nSuffix;
-  }
-  pReader->iBlockid++;
-}
-
-/* Compare the current term to pTerm[nTerm], returning strcmp-style
-** results.  If isPrefix, equality means equal through nTerm bytes.
-*/
-static int interiorReaderTermCmp(InteriorReader *pReader,
-                                 const char *pTerm, int nTerm, int isPrefix){
-  const char *pReaderTerm = interiorReaderTerm(pReader);
-  int nReaderTerm = interiorReaderTermBytes(pReader);
-  int c, n = nReaderTerm<nTerm ? nReaderTerm : nTerm;
-
-  if( n==0 ){
-    if( nReaderTerm>0 ) return -1;
-    if( nTerm>0 ) return 1;
-    return 0;
-  }
-
-  c = memcmp(pReaderTerm, pTerm, n);
-  if( c!=0 ) return c;
-  if( isPrefix && n==nTerm ) return 0;
-  return nReaderTerm - nTerm;
-}
-
-/****************************************************************/
-/* LeafWriter is used to collect terms and associated doclist data
-** into leaf blocks in %_segments (see top of file for format info).
-** Expected usage is:
-**
-** LeafWriter writer;
-** leafWriterInit(0, 0, &writer);
-** while( sorted_terms_left_to_process ){
-**   // data is doclist data for that term.
-**   rc = leafWriterStep(v, &writer, pTerm, nTerm, pData, nData);
-**   if( rc!=SQLITE_OK ) goto err;
-** }
-** rc = leafWriterFinalize(v, &writer);
-**err:
-** leafWriterDestroy(&writer);
-** return rc;
-**
-** leafWriterStep() may write a collected leaf out to %_segments.
-** leafWriterFinalize() finishes writing any buffered data and stores
-** a root node in %_segdir.  leafWriterDestroy() frees all buffers and
-** InteriorWriters allocated as part of writing this segment.
-**
-** TODO(shess) Document leafWriterStepMerge().
+/* 
+** This is the xEof method of the virtual table. SQLite calls this 
+** routine to find out if it has reached the end of a result set.
 */
-
-/* Put terms with data this big in their own block. */
-#define STANDALONE_MIN 1024
-
-/* Keep leaf blocks below this size. */
-#define LEAF_MAX 2048
-
-typedef struct LeafWriter {
-  int iLevel;
-  int idx;
-  sqlite_int64 iStartBlockid;     /* needed to create the root info */
-  sqlite_int64 iEndBlockid;       /* when we're done writing. */
-
-  DataBuffer term;                /* previous encoded term */
-  DataBuffer data;                /* encoding buffer */
-
-  /* bytes of first term in the current node which distinguishes that
-  ** term from the last term of the previous node.
-  */
-  int nTermDistinct;
-
-  InteriorWriter parentWriter;    /* if we overflow */
-  int has_parent;
-} LeafWriter;
-
-static void leafWriterInit(int iLevel, int idx, LeafWriter *pWriter){
-  CLEAR(pWriter);
-  pWriter->iLevel = iLevel;
-  pWriter->idx = idx;
-
-  dataBufferInit(&pWriter->term, 32);
-
-  /* Start out with a reasonably sized block, though it can grow. */
-  dataBufferInit(&pWriter->data, LEAF_MAX);
-}
-
-#ifndef NDEBUG
-/* Verify that the data is readable as a leaf node. */
-static void leafNodeValidate(const char *pData, int nData){
-  int n, iDummy;
-
-  if( nData==0 ) return;
-  assert( nData>0 );
-  assert( pData!=0 );
-  assert( pData+nData>pData );
-
-  /* Must lead with a varint(0) */
-  n = fts3GetVarint32(pData, &iDummy);
-  assert( iDummy==0 );
-  assert( n>0 );
-  assert( n<nData );
-  pData += n;
-  nData -= n;
-
-  /* Leading term length and data must fit in buffer. */
-  n = fts3GetVarint32(pData, &iDummy);
-  assert( n>0 );
-  assert( iDummy>0 );
-  assert( n+iDummy>0 );
-  assert( n+iDummy<nData );
-  pData += n+iDummy;
-  nData -= n+iDummy;
-
-  /* Leading term's doclist length and data must fit. */
-  n = fts3GetVarint32(pData, &iDummy);
-  assert( n>0 );
-  assert( iDummy>0 );
-  assert( n+iDummy>0 );
-  assert( n+iDummy<=nData );
-  ASSERT_VALID_DOCLIST(DL_DEFAULT, pData+n, iDummy, NULL);
-  pData += n+iDummy;
-  nData -= n+iDummy;
-
-  /* Verify that trailing terms and doclists also are readable. */
-  while( nData!=0 ){
-    n = fts3GetVarint32(pData, &iDummy);
-    assert( n>0 );
-    assert( iDummy>=0 );
-    assert( n<nData );
-    pData += n;
-    nData -= n;
-    n = fts3GetVarint32(pData, &iDummy);
-    assert( n>0 );
-    assert( iDummy>0 );
-    assert( n+iDummy>0 );
-    assert( n+iDummy<nData );
-    pData += n+iDummy;
-    nData -= n+iDummy;
-
-    n = fts3GetVarint32(pData, &iDummy);
-    assert( n>0 );
-    assert( iDummy>0 );
-    assert( n+iDummy>0 );
-    assert( n+iDummy<=nData );
-    ASSERT_VALID_DOCLIST(DL_DEFAULT, pData+n, iDummy, NULL);
-    pData += n+iDummy;
-    nData -= n+iDummy;
-  }
+static int fts3EofMethod(sqlite3_vtab_cursor *pCursor){
+  return ((Fts3Cursor *)pCursor)->isEof;
 }
-#define ASSERT_VALID_LEAF_NODE(p, n) leafNodeValidate(p, n)
-#else
-#define ASSERT_VALID_LEAF_NODE(p, n) assert( 1 )
-#endif
 
-/* Flush the current leaf node to %_segments, and adding the resulting
-** blockid and the starting term to the interior node which will
-** contain it.
+/* 
+** This is the xRowid method. The SQLite core calls this routine to
+** retrieve the rowid for the current row of the result set. fts3
+** exposes %_content.docid as the rowid for the virtual table. The
+** rowid should be written to *pRowid.
 */
-static int leafWriterInternalFlush(fulltext_vtab *v, LeafWriter *pWriter,
-                                   int iData, int nData){
-  sqlite_int64 iBlockid = 0;
-  const char *pStartingTerm;
-  int nStartingTerm, rc, n;
-
-  /* Must have the leading varint(0) flag, plus at least some
-  ** valid-looking data.
-  */
-  assert( nData>2 );
-  assert( iData>=0 );
-  assert( iData+nData<=pWriter->data.nData );
-  ASSERT_VALID_LEAF_NODE(pWriter->data.pData+iData, nData);
-
-  rc = block_insert(v, pWriter->data.pData+iData, nData, &iBlockid);
-  if( rc!=SQLITE_OK ) return rc;
-  assert( iBlockid!=0 );
-
-  /* Reconstruct the first term in the leaf for purposes of building
-  ** the interior node.
-  */
-  n = fts3GetVarint32(pWriter->data.pData+iData+1, &nStartingTerm);
-  pStartingTerm = pWriter->data.pData+iData+1+n;
-  assert( pWriter->data.nData>iData+1+n+nStartingTerm );
-  assert( pWriter->nTermDistinct>0 );
-  assert( pWriter->nTermDistinct<=nStartingTerm );
-  nStartingTerm = pWriter->nTermDistinct;
-
-  if( pWriter->has_parent ){
-    interiorWriterAppend(&pWriter->parentWriter,
-                         pStartingTerm, nStartingTerm, iBlockid);
-  }else{
-    interiorWriterInit(1, pStartingTerm, nStartingTerm, iBlockid,
-                       &pWriter->parentWriter);
-    pWriter->has_parent = 1;
-  }
-
-  /* Track the span of this segment's leaf nodes. */
-  if( pWriter->iEndBlockid==0 ){
-    pWriter->iEndBlockid = pWriter->iStartBlockid = iBlockid;
+static int fts3RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
+  Fts3Cursor *pCsr = (Fts3Cursor *) pCursor;
+  if( pCsr->aDoclist ){
+    *pRowid = pCsr->iPrevId;
   }else{
-    pWriter->iEndBlockid++;
-    assert( iBlockid==pWriter->iEndBlockid );
+    *pRowid = sqlite3_column_int64(pCsr->pStmt, 0);
   }
-
-  return SQLITE_OK;
-}
-static int leafWriterFlush(fulltext_vtab *v, LeafWriter *pWriter){
-  int rc = leafWriterInternalFlush(v, pWriter, 0, pWriter->data.nData);
-  if( rc!=SQLITE_OK ) return rc;
-
-  /* Re-initialize the output buffer. */
-  dataBufferReset(&pWriter->data);
-
   return SQLITE_OK;
 }
 
-/* Fetch the root info for the segment.  If the entire leaf fits
-** within ROOT_MAX, then it will be returned directly, otherwise it
-** will be flushed and the root info will be returned from the
-** interior node.  *piEndBlockid is set to the blockid of the last
-** interior or leaf node written to disk (0 if none are written at
-** all).
-*/
-static int leafWriterRootInfo(fulltext_vtab *v, LeafWriter *pWriter,
-                              char **ppRootInfo, int *pnRootInfo,
-                              sqlite_int64 *piEndBlockid){
-  /* we can fit the segment entirely inline */
-  if( !pWriter->has_parent && pWriter->data.nData<ROOT_MAX ){
-    *ppRootInfo = pWriter->data.pData;
-    *pnRootInfo = pWriter->data.nData;
-    *piEndBlockid = 0;
-    return SQLITE_OK;
-  }
-
-  /* Flush remaining leaf data. */
-  if( pWriter->data.nData>0 ){
-    int rc = leafWriterFlush(v, pWriter);
-    if( rc!=SQLITE_OK ) return rc;
-  }
-
-  /* We must have flushed a leaf at some point. */
-  assert( pWriter->has_parent );
-
-  /* Tenatively set the end leaf blockid as the end blockid.  If the
-  ** interior node can be returned inline, this will be the final
-  ** blockid, otherwise it will be overwritten by
-  ** interiorWriterRootInfo().
-  */
-  *piEndBlockid = pWriter->iEndBlockid;
-
-  return interiorWriterRootInfo(v, &pWriter->parentWriter,
-                                ppRootInfo, pnRootInfo, piEndBlockid);
-}
-
-/* Collect the rootInfo data and store it into the segment directory.
-** This has the effect of flushing the segment's leaf data to
-** %_segments, and also flushing any interior nodes to %_segments.
-*/
-static int leafWriterFinalize(fulltext_vtab *v, LeafWriter *pWriter){
-  sqlite_int64 iEndBlockid;
-  char *pRootInfo;
-  int rc, nRootInfo;
-
-  rc = leafWriterRootInfo(v, pWriter, &pRootInfo, &nRootInfo, &iEndBlockid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  /* Don't bother storing an entirely empty segment. */
-  if( iEndBlockid==0 && nRootInfo==0 ) return SQLITE_OK;
-
-  return segdir_set(v, pWriter->iLevel, pWriter->idx,
-                    pWriter->iStartBlockid, pWriter->iEndBlockid,
-                    iEndBlockid, pRootInfo, nRootInfo);
-}
-
-static void leafWriterDestroy(LeafWriter *pWriter){
-  if( pWriter->has_parent ) interiorWriterDestroy(&pWriter->parentWriter);
-  dataBufferDestroy(&pWriter->term);
-  dataBufferDestroy(&pWriter->data);
-}
-
-/* Encode a term into the leafWriter, delta-encoding as appropriate.
-** Returns the length of the new term which distinguishes it from the
-** previous term, which can be used to set nTermDistinct when a node
-** boundary is crossed.
+/* 
+** This is the xColumn method, called by SQLite to request a value from
+** the row that the supplied cursor currently points to.
 */
-static int leafWriterEncodeTerm(LeafWriter *pWriter,
-                                const char *pTerm, int nTerm){
-  char c[VARINT_MAX+VARINT_MAX];
-  int n, nPrefix = 0;
+static int fts3ColumnMethod(
+  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */
+  sqlite3_context *pContext,      /* Context for sqlite3_result_xxx() calls */
+  int iCol                        /* Index of column to read value from */
+){
+  int rc;                         /* Return Code */
+  Fts3Cursor *pCsr = (Fts3Cursor *) pCursor;
+  Fts3Table *p = (Fts3Table *)pCursor->pVtab;
 
-  assert( nTerm>0 );
-  while( nPrefix<pWriter->term.nData &&
-         pTerm[nPrefix]==pWriter->term.pData[nPrefix] ){
-    nPrefix++;
-    /* Failing this implies that the terms weren't in order. */
-    assert( nPrefix<nTerm );
-  }
+  /* The column value supplied by SQLite must be in range. */
+  assert( iCol>=0 && iCol<=p->nColumn+1 );
 
-  if( pWriter->data.nData==0 ){
-    /* Encode the node header and leading term as:
-    **  varint(0)
-    **  varint(nTerm)
-    **  char pTerm[nTerm]
+  if( iCol==p->nColumn+1 ){
+    /* This call is a request for the "docid" column. Since "docid" is an 
+    ** alias for "rowid", use the xRowid() method to obtain the value.
     */
-    n = fts3PutVarint(c, '\0');
-    n += fts3PutVarint(c+n, nTerm);
-    dataBufferAppend2(&pWriter->data, c, n, pTerm, nTerm);
-  }else{
-    /* Delta-encode the term as:
-    **  varint(nPrefix)
-    **  varint(nSuffix)
-    **  char pTermSuffix[nSuffix]
+    sqlite3_int64 iRowid;
+    rc = fts3RowidMethod(pCursor, &iRowid);
+    sqlite3_result_int64(pContext, iRowid);
+  }else if( iCol==p->nColumn ){
+    /* The extra column whose name is the same as the table.
+    ** Return a blob which is a pointer to the cursor.
     */
-    n = fts3PutVarint(c, nPrefix);
-    n += fts3PutVarint(c+n, nTerm-nPrefix);
-    dataBufferAppend2(&pWriter->data, c, n, pTerm+nPrefix, nTerm-nPrefix);
-  }
-  dataBufferReplace(&pWriter->term, pTerm, nTerm);
-
-  return nPrefix+1;
-}
-
-/* Used to avoid a memmove when a large amount of doclist data is in
-** the buffer.  This constructs a node and term header before
-** iDoclistData and flushes the resulting complete node using
-** leafWriterInternalFlush().
-*/
-static int leafWriterInlineFlush(fulltext_vtab *v, LeafWriter *pWriter,
-                                 const char *pTerm, int nTerm,
-                                 int iDoclistData){
-  char c[VARINT_MAX+VARINT_MAX];
-  int iData, n = fts3PutVarint(c, 0);
-  n += fts3PutVarint(c+n, nTerm);
-
-  /* There should always be room for the header.  Even if pTerm shared
-  ** a substantial prefix with the previous term, the entire prefix
-  ** could be constructed from earlier data in the doclist, so there
-  ** should be room.
-  */
-  assert( iDoclistData>=n+nTerm );
-
-  iData = iDoclistData-(n+nTerm);
-  memcpy(pWriter->data.pData+iData, c, n);
-  memcpy(pWriter->data.pData+iData+n, pTerm, nTerm);
-
-  return leafWriterInternalFlush(v, pWriter, iData, pWriter->data.nData-iData);
-}
-
-/* Push pTerm[nTerm] along with the doclist data to the leaf layer of
-** %_segments.
-*/
-static int leafWriterStepMerge(fulltext_vtab *v, LeafWriter *pWriter,
-                               const char *pTerm, int nTerm,
-                               DLReader *pReaders, int nReaders){
-  char c[VARINT_MAX+VARINT_MAX];
-  int iTermData = pWriter->data.nData, iDoclistData;
-  int i, nData, n, nActualData, nActual, rc, nTermDistinct;
-
-  ASSERT_VALID_LEAF_NODE(pWriter->data.pData, pWriter->data.nData);
-  nTermDistinct = leafWriterEncodeTerm(pWriter, pTerm, nTerm);
-
-  /* Remember nTermDistinct if opening a new node. */
-  if( iTermData==0 ) pWriter->nTermDistinct = nTermDistinct;
-
-  iDoclistData = pWriter->data.nData;
-
-  /* Estimate the length of the merged doclist so we can leave space
-  ** to encode it.
-  */
-  for(i=0, nData=0; i<nReaders; i++){
-    nData += dlrAllDataBytes(&pReaders[i]);
-  }
-  n = fts3PutVarint(c, nData);
-  dataBufferAppend(&pWriter->data, c, n);
-
-  docListMerge(&pWriter->data, pReaders, nReaders);
-  ASSERT_VALID_DOCLIST(DL_DEFAULT,
-                       pWriter->data.pData+iDoclistData+n,
-                       pWriter->data.nData-iDoclistData-n, NULL);
-
-  /* The actual amount of doclist data at this point could be smaller
-  ** than the length we encoded.  Additionally, the space required to
-  ** encode this length could be smaller.  For small doclists, this is
-  ** not a big deal, we can just use memmove() to adjust things.
-  */
-  nActualData = pWriter->data.nData-(iDoclistData+n);
-  nActual = fts3PutVarint(c, nActualData);
-  assert( nActualData<=nData );
-  assert( nActual<=n );
-
-  /* If the new doclist is big enough for force a standalone leaf
-  ** node, we can immediately flush it inline without doing the
-  ** memmove().
-  */
-  /* TODO(shess) This test matches leafWriterStep(), which does this
-  ** test before it knows the cost to varint-encode the term and
-  ** doclist lengths.  At some point, change to
-  ** pWriter->data.nData-iTermData>STANDALONE_MIN.
-  */
-  if( nTerm+nActualData>STANDALONE_MIN ){
-    /* Push leaf node from before this term. */
-    if( iTermData>0 ){
-      rc = leafWriterInternalFlush(v, pWriter, 0, iTermData);
-      if( rc!=SQLITE_OK ) return rc;
-
-      pWriter->nTermDistinct = nTermDistinct;
+    sqlite3_result_blob(pContext, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);
+    rc = SQLITE_OK;
+  }else{
+    rc = fts3CursorSeek(0, pCsr);
+    if( rc==SQLITE_OK ){
+      sqlite3_result_value(pContext, sqlite3_column_value(pCsr->pStmt, iCol+1));
     }
-
-    /* Fix the encoded doclist length. */
-    iDoclistData += n - nActual;
-    memcpy(pWriter->data.pData+iDoclistData, c, nActual);
-
-    /* Push the standalone leaf node. */
-    rc = leafWriterInlineFlush(v, pWriter, pTerm, nTerm, iDoclistData);
-    if( rc!=SQLITE_OK ) return rc;
-
-    /* Leave the node empty. */
-    dataBufferReset(&pWriter->data);
-
-    return rc;
-  }
-
-  /* At this point, we know that the doclist was small, so do the
-  ** memmove if indicated.
-  */
-  if( nActual<n ){
-    memmove(pWriter->data.pData+iDoclistData+nActual,
-            pWriter->data.pData+iDoclistData+n,
-            pWriter->data.nData-(iDoclistData+n));
-    pWriter->data.nData -= n-nActual;
-  }
-
-  /* Replace written length with actual length. */
-  memcpy(pWriter->data.pData+iDoclistData, c, nActual);
-
-  /* If the node is too large, break things up. */
-  /* TODO(shess) This test matches leafWriterStep(), which does this
-  ** test before it knows the cost to varint-encode the term and
-  ** doclist lengths.  At some point, change to
-  ** pWriter->data.nData>LEAF_MAX.
-  */
-  if( iTermData+nTerm+nActualData>LEAF_MAX ){
-    /* Flush out the leading data as a node */
-    rc = leafWriterInternalFlush(v, pWriter, 0, iTermData);
-    if( rc!=SQLITE_OK ) return rc;
-
-    pWriter->nTermDistinct = nTermDistinct;
-
-    /* Rebuild header using the current term */
-    n = fts3PutVarint(pWriter->data.pData, 0);
-    n += fts3PutVarint(pWriter->data.pData+n, nTerm);
-    memcpy(pWriter->data.pData+n, pTerm, nTerm);
-    n += nTerm;
-
-    /* There should always be room, because the previous encoding
-    ** included all data necessary to construct the term.
-    */
-    assert( n<iDoclistData );
-    /* So long as STANDALONE_MIN is half or less of LEAF_MAX, the
-    ** following memcpy() is safe (as opposed to needing a memmove).
-    */
-    assert( 2*STANDALONE_MIN<=LEAF_MAX );
-    assert( n+pWriter->data.nData-iDoclistData<iDoclistData );
-    memcpy(pWriter->data.pData+n,
-           pWriter->data.pData+iDoclistData,
-           pWriter->data.nData-iDoclistData);
-    pWriter->data.nData -= iDoclistData-n;
   }
-  ASSERT_VALID_LEAF_NODE(pWriter->data.pData, pWriter->data.nData);
-
-  return SQLITE_OK;
-}
-
-/* Push pTerm[nTerm] along with the doclist data to the leaf layer of
-** %_segments.
-*/
-/* TODO(shess) Revise writeZeroSegment() so that doclists are
-** constructed directly in pWriter->data.
-*/
-static int leafWriterStep(fulltext_vtab *v, LeafWriter *pWriter,
-                          const char *pTerm, int nTerm,
-                          const char *pData, int nData){
-  int rc;
-  DLReader reader;
-
-  dlrInit(&reader, DL_DEFAULT, pData, nData);
-  rc = leafWriterStepMerge(v, pWriter, pTerm, nTerm, &reader, 1);
-  dlrDestroy(&reader);
-
   return rc;
 }
 
-
-/****************************************************************/
-/* LeafReader is used to iterate over an individual leaf node. */
-typedef struct LeafReader {
-  DataBuffer term;          /* copy of current term. */
-
-  const char *pData;        /* data for current term. */
-  int nData;
-} LeafReader;
-
-static void leafReaderDestroy(LeafReader *pReader){
-  dataBufferDestroy(&pReader->term);
-  SCRAMBLE(pReader);
-}
-
-static int leafReaderAtEnd(LeafReader *pReader){
-  return pReader->nData<=0;
-}
-
-/* Access the current term. */
-static int leafReaderTermBytes(LeafReader *pReader){
-  return pReader->term.nData;
-}
-static const char *leafReaderTerm(LeafReader *pReader){
-  assert( pReader->term.nData>0 );
-  return pReader->term.pData;
-}
-
-/* Access the doclist data for the current term. */
-static int leafReaderDataBytes(LeafReader *pReader){
-  int nData;
-  assert( pReader->term.nData>0 );
-  fts3GetVarint32(pReader->pData, &nData);
-  return nData;
-}
-static const char *leafReaderData(LeafReader *pReader){
-  int n, nData;
-  assert( pReader->term.nData>0 );
-  n = fts3GetVarint32(pReader->pData, &nData);
-  return pReader->pData+n;
-}
-
-static void leafReaderInit(const char *pData, int nData,
-                           LeafReader *pReader){
-  int nTerm, n;
-
-  assert( nData>0 );
-  assert( pData[0]=='\0' );
-
-  CLEAR(pReader);
-
-  /* Read the first term, skipping the header byte. */
-  n = fts3GetVarint32(pData+1, &nTerm);
-  dataBufferInit(&pReader->term, nTerm);
-  dataBufferReplace(&pReader->term, pData+1+n, nTerm);
-
-  /* Position after the first term. */
-  assert( 1+n+nTerm<nData );
-  pReader->pData = pData+1+n+nTerm;
-  pReader->nData = nData-1-n-nTerm;
-}
-
-/* Step the reader forward to the next term. */
-static void leafReaderStep(LeafReader *pReader){
-  int n, nData, nPrefix, nSuffix;
-  assert( !leafReaderAtEnd(pReader) );
-
-  /* Skip previous entry's data block. */
-  n = fts3GetVarint32(pReader->pData, &nData);
-  assert( n+nData<=pReader->nData );
-  pReader->pData += n+nData;
-  pReader->nData -= n+nData;
-
-  if( !leafReaderAtEnd(pReader) ){
-    /* Construct the new term using a prefix from the old term plus a
-    ** suffix from the leaf data.
-    */
-    n = fts3GetVarint32(pReader->pData, &nPrefix);
-    n += fts3GetVarint32(pReader->pData+n, &nSuffix);
-    assert( n+nSuffix<pReader->nData );
-    pReader->term.nData = nPrefix;
-    dataBufferAppend(&pReader->term, pReader->pData+n, nSuffix);
-
-    pReader->pData += n+nSuffix;
-    pReader->nData -= n+nSuffix;
-  }
-}
-
-/* strcmp-style comparison of pReader's current term against pTerm.
-** If isPrefix, equality means equal through nTerm bytes.
-*/
-static int leafReaderTermCmp(LeafReader *pReader,
-                             const char *pTerm, int nTerm, int isPrefix){
-  int c, n = pReader->term.nData<nTerm ? pReader->term.nData : nTerm;
-  if( n==0 ){
-    if( pReader->term.nData>0 ) return -1;
-    if(nTerm>0 ) return 1;
-    return 0;
-  }
-
-  c = memcmp(pReader->term.pData, pTerm, n);
-  if( c!=0 ) return c;
-  if( isPrefix && n==nTerm ) return 0;
-  return pReader->term.nData - nTerm;
-}
-
-
-/****************************************************************/
-/* LeavesReader wraps LeafReader to allow iterating over the entire
-** leaf layer of the tree.
-*/
-typedef struct LeavesReader {
-  int idx;                  /* Index within the segment. */
-
-  sqlite3_stmt *pStmt;      /* Statement we're streaming leaves from. */
-  int eof;                  /* we've seen SQLITE_DONE from pStmt. */
-
-  LeafReader leafReader;    /* reader for the current leaf. */
-  DataBuffer rootData;      /* root data for inline. */
-} LeavesReader;
-
-/* Access the current term. */
-static int leavesReaderTermBytes(LeavesReader *pReader){
-  assert( !pReader->eof );
-  return leafReaderTermBytes(&pReader->leafReader);
-}
-static const char *leavesReaderTerm(LeavesReader *pReader){
-  assert( !pReader->eof );
-  return leafReaderTerm(&pReader->leafReader);
-}
-
-/* Access the doclist data for the current term. */
-static int leavesReaderDataBytes(LeavesReader *pReader){
-  assert( !pReader->eof );
-  return leafReaderDataBytes(&pReader->leafReader);
-}
-static const char *leavesReaderData(LeavesReader *pReader){
-  assert( !pReader->eof );
-  return leafReaderData(&pReader->leafReader);
-}
-
-static int leavesReaderAtEnd(LeavesReader *pReader){
-  return pReader->eof;
+/* 
+** This function is the implementation of the xUpdate callback used by 
+** FTS3 virtual tables. It is invoked by SQLite each time a row is to be
+** inserted, updated or deleted.
+*/
+static int fts3UpdateMethod(
+  sqlite3_vtab *pVtab,            /* Virtual table handle */
+  int nArg,                       /* Size of argument array */
+  sqlite3_value **apVal,          /* Array of arguments */
+  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */
+){
+  return sqlite3Fts3UpdateMethod(pVtab, nArg, apVal, pRowid);
 }
 
-/* loadSegmentLeaves() may not read all the way to SQLITE_DONE, thus
-** leaving the statement handle open, which locks the table.
-*/
-/* TODO(shess) This "solution" is not satisfactory.  Really, there
-** should be check-in function for all statement handles which
-** arranges to call sqlite3_reset().  This most likely will require
-** modification to control flow all over the place, though, so for now
-** just punt.
-**
-** Note the the current system assumes that segment merges will run to
-** completion, which is why this particular probably hasn't arisen in
-** this case.  Probably a brittle assumption.
+/*
+** Implementation of xSync() method. Flush the contents of the pending-terms
+** hash-table to the database.
 */
-static int leavesReaderReset(LeavesReader *pReader){
-  return sqlite3_reset(pReader->pStmt);
+static int fts3SyncMethod(sqlite3_vtab *pVtab){
+  return sqlite3Fts3PendingTermsFlush((Fts3Table *)pVtab);
 }
 
-static void leavesReaderDestroy(LeavesReader *pReader){
-  /* If idx is -1, that means we're using a non-cached statement
-  ** handle in the optimize() case, so we need to release it.
-  */
-  if( pReader->pStmt!=NULL && pReader->idx==-1 ){
-    sqlite3_finalize(pReader->pStmt);
-  }
-  leafReaderDestroy(&pReader->leafReader);
-  dataBufferDestroy(&pReader->rootData);
-  SCRAMBLE(pReader);
-}
-
-/* Initialize pReader with the given root data (if iStartBlockid==0
-** the leaf data was entirely contained in the root), or from the
-** stream of blocks between iStartBlockid and iEndBlockid, inclusive.
+/*
+** Implementation of xBegin() method. This is a no-op.
 */
-static int leavesReaderInit(fulltext_vtab *v,
-                            int idx,
-                            sqlite_int64 iStartBlockid,
-                            sqlite_int64 iEndBlockid,
-                            const char *pRootData, int nRootData,
-                            LeavesReader *pReader){
-  CLEAR(pReader);
-  pReader->idx = idx;
-
-  dataBufferInit(&pReader->rootData, 0);
-  if( iStartBlockid==0 ){
-    /* Entire leaf level fit in root data. */
-    dataBufferReplace(&pReader->rootData, pRootData, nRootData);
-    leafReaderInit(pReader->rootData.pData, pReader->rootData.nData,
-                   &pReader->leafReader);
-  }else{
-    sqlite3_stmt *s;
-    int rc = sql_get_leaf_statement(v, idx, &s);
-    if( rc!=SQLITE_OK ) return rc;
-
-    rc = sqlite3_bind_int64(s, 1, iStartBlockid);
-    if( rc!=SQLITE_OK ) return rc;
-
-    rc = sqlite3_bind_int64(s, 2, iEndBlockid);
-    if( rc!=SQLITE_OK ) return rc;
-
-    rc = sqlite3_step(s);
-    if( rc==SQLITE_DONE ){
-      pReader->eof = 1;
-      return SQLITE_OK;
-    }
-    if( rc!=SQLITE_ROW ) return rc;
-
-    pReader->pStmt = s;
-    leafReaderInit(sqlite3_column_blob(pReader->pStmt, 0),
-                   sqlite3_column_bytes(pReader->pStmt, 0),
-                   &pReader->leafReader);
-  }
+static int fts3BeginMethod(sqlite3_vtab *pVtab){
+  UNUSED_PARAMETER(pVtab);
+  assert( ((Fts3Table *)pVtab)->nPendingData==0 );
   return SQLITE_OK;
 }
 
-/* Step the current leaf forward to the next term.  If we reach the
-** end of the current leaf, step forward to the next leaf block.
+/*
+** Implementation of xCommit() method. This is a no-op. The contents of
+** the pending-terms hash-table have already been flushed into the database
+** by fts3SyncMethod().
 */
-static int leavesReaderStep(fulltext_vtab *v, LeavesReader *pReader){
-  assert( !leavesReaderAtEnd(pReader) );
-  leafReaderStep(&pReader->leafReader);
-
-  if( leafReaderAtEnd(&pReader->leafReader) ){
-    int rc;
-    if( pReader->rootData.pData ){
-      pReader->eof = 1;
-      return SQLITE_OK;
-    }
-    rc = sqlite3_step(pReader->pStmt);
-    if( rc!=SQLITE_ROW ){
-      pReader->eof = 1;
-      return rc==SQLITE_DONE ? SQLITE_OK : rc;
-    }
-    leafReaderDestroy(&pReader->leafReader);
-    leafReaderInit(sqlite3_column_blob(pReader->pStmt, 0),
-                   sqlite3_column_bytes(pReader->pStmt, 0),
-                   &pReader->leafReader);
-  }
+static int fts3CommitMethod(sqlite3_vtab *pVtab){
+  UNUSED_PARAMETER(pVtab);
+  assert( ((Fts3Table *)pVtab)->nPendingData==0 );
   return SQLITE_OK;
 }
 
-/* Order LeavesReaders by their term, ignoring idx.  Readers at eof
-** always sort to the end.
-*/
-static int leavesReaderTermCmp(LeavesReader *lr1, LeavesReader *lr2){
-  if( leavesReaderAtEnd(lr1) ){
-    if( leavesReaderAtEnd(lr2) ) return 0;
-    return 1;
-  }
-  if( leavesReaderAtEnd(lr2) ) return -1;
-
-  return leafReaderTermCmp(&lr1->leafReader,
-                           leavesReaderTerm(lr2), leavesReaderTermBytes(lr2),
-                           0);
-}
-
-/* Similar to leavesReaderTermCmp(), with additional ordering by idx
-** so that older segments sort before newer segments.
-*/
-static int leavesReaderCmp(LeavesReader *lr1, LeavesReader *lr2){
-  int c = leavesReaderTermCmp(lr1, lr2);
-  if( c!=0 ) return c;
-  return lr1->idx-lr2->idx;
-}
-
-/* Assume that pLr[1]..pLr[nLr] are sorted.  Bubble pLr[0] into its
-** sorted position.
-*/
-static void leavesReaderReorder(LeavesReader *pLr, int nLr){
-  while( nLr>1 && leavesReaderCmp(pLr, pLr+1)>0 ){
-    LeavesReader tmp = pLr[0];
-    pLr[0] = pLr[1];
-    pLr[1] = tmp;
-    nLr--;
-    pLr++;
-  }
-}
-
-/* Initializes pReaders with the segments from level iLevel, returning
-** the number of segments in *piReaders.  Leaves pReaders in sorted
-** order.
+/*
+** Implementation of xRollback(). Discard the contents of the pending-terms
+** hash-table. Any changes made to the database are reverted by SQLite.
 */
-static int leavesReadersInit(fulltext_vtab *v, int iLevel,
-                             LeavesReader *pReaders, int *piReaders){
-  sqlite3_stmt *s;
-  int i, rc = sql_get_statement(v, SEGDIR_SELECT_LEVEL_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int(s, 1, iLevel);
-  if( rc!=SQLITE_OK ) return rc;
-
-  i = 0;
-  while( (rc = sqlite3_step(s))==SQLITE_ROW ){
-    sqlite_int64 iStart = sqlite3_column_int64(s, 0);
-    sqlite_int64 iEnd = sqlite3_column_int64(s, 1);
-    const char *pRootData = sqlite3_column_blob(s, 2);
-    int nRootData = sqlite3_column_bytes(s, 2);
-
-    assert( i<MERGE_COUNT );
-    rc = leavesReaderInit(v, i, iStart, iEnd, pRootData, nRootData,
-                          &pReaders[i]);
-    if( rc!=SQLITE_OK ) break;
-
-    i++;
-  }
-  if( rc!=SQLITE_DONE ){
-    while( i-->0 ){
-      leavesReaderDestroy(&pReaders[i]);
-    }
-    return rc;
-  }
-
-  *piReaders = i;
-
-  /* Leave our results sorted by term, then age. */
-  while( i-- ){
-    leavesReaderReorder(pReaders+i, *piReaders-i);
-  }
+static int fts3RollbackMethod(sqlite3_vtab *pVtab){
+  sqlite3Fts3PendingTermsClear((Fts3Table *)pVtab);
   return SQLITE_OK;
 }
 
-/* Merge doclists from pReaders[nReaders] into a single doclist, which
-** is written to pWriter.  Assumes pReaders is ordered oldest to
-** newest.
-*/
-/* TODO(shess) Consider putting this inline in segmentMerge(). */
-static int leavesReadersMerge(fulltext_vtab *v,
-                              LeavesReader *pReaders, int nReaders,
-                              LeafWriter *pWriter){
-  DLReader dlReaders[MERGE_COUNT];
-  const char *pTerm = leavesReaderTerm(pReaders);
-  int i, nTerm = leavesReaderTermBytes(pReaders);
-
-  assert( nReaders<=MERGE_COUNT );
-
-  for(i=0; i<nReaders; i++){
-    dlrInit(&dlReaders[i], DL_DEFAULT,
-            leavesReaderData(pReaders+i),
-            leavesReaderDataBytes(pReaders+i));
-  }
-
-  return leafWriterStepMerge(v, pWriter, pTerm, nTerm, dlReaders, nReaders);
-}
-
-/* Forward ref due to mutual recursion with segdirNextIndex(). */
-static int segmentMerge(fulltext_vtab *v, int iLevel);
-
-/* Put the next available index at iLevel into *pidx.  If iLevel
-** already has MERGE_COUNT segments, they are merged to a higher
-** level to make room.
-*/
-static int segdirNextIndex(fulltext_vtab *v, int iLevel, int *pidx){
-  int rc = segdir_max_index(v, iLevel, pidx);
-  if( rc==SQLITE_DONE ){              /* No segments at iLevel. */
-    *pidx = 0;
-  }else if( rc==SQLITE_ROW ){
-    if( *pidx==(MERGE_COUNT-1) ){
-      rc = segmentMerge(v, iLevel);
-      if( rc!=SQLITE_OK ) return rc;
-      *pidx = 0;
-    }else{
-      (*pidx)++;
-    }
-  }else{
-    return rc;
-  }
-  return SQLITE_OK;
-}
-
-/* Merge MERGE_COUNT segments at iLevel into a new segment at
-** iLevel+1.  If iLevel+1 is already full of segments, those will be
-** merged to make room.
+/*
+** Load the doclist associated with expression pExpr to pExpr->aDoclist.
+** The loaded doclist contains positions as well as the document ids.
+** This is used by the matchinfo(), snippet() and offsets() auxillary
+** functions.
 */
-static int segmentMerge(fulltext_vtab *v, int iLevel){
-  LeafWriter writer;
-  LeavesReader lrs[MERGE_COUNT];
-  int i, rc, idx = 0;
-
-  /* Determine the next available segment index at the next level,
-  ** merging as necessary.
-  */
-  rc = segdirNextIndex(v, iLevel+1, &idx);
-  if( rc!=SQLITE_OK ) return rc;
-
-  /* TODO(shess) This assumes that we'll always see exactly
-  ** MERGE_COUNT segments to merge at a given level.  That will be
-  ** broken if we allow the developer to request preemptive or
-  ** deferred merging.
-  */
-  memset(&lrs, '\0', sizeof(lrs));
-  rc = leavesReadersInit(v, iLevel, lrs, &i);
-  if( rc!=SQLITE_OK ) return rc;
-  assert( i==MERGE_COUNT );
-
-  leafWriterInit(iLevel+1, idx, &writer);
-
-  /* Since leavesReaderReorder() pushes readers at eof to the end,
-  ** when the first reader is empty, all will be empty.
-  */
-  while( !leavesReaderAtEnd(lrs) ){
-    /* Figure out how many readers share their next term. */
-    for(i=1; i<MERGE_COUNT && !leavesReaderAtEnd(lrs+i); i++){
-      if( 0!=leavesReaderTermCmp(lrs, lrs+i) ) break;
-    }
-
-    rc = leavesReadersMerge(v, lrs, i, &writer);
-    if( rc!=SQLITE_OK ) goto err;
-
-    /* Step forward those that were merged. */
-    while( i-->0 ){
-      rc = leavesReaderStep(v, lrs+i);
-      if( rc!=SQLITE_OK ) goto err;
-
-      /* Reorder by term, then by age. */
-      leavesReaderReorder(lrs+i, MERGE_COUNT-i);
-    }
-  }
-
-  for(i=0; i<MERGE_COUNT; i++){
-    leavesReaderDestroy(&lrs[i]);
-  }
-
-  rc = leafWriterFinalize(v, &writer);
-  leafWriterDestroy(&writer);
-  if( rc!=SQLITE_OK ) return rc;
-
-  /* Delete the merged segment data. */
-  return segdir_delete(v, iLevel);
-
- err:
-  for(i=0; i<MERGE_COUNT; i++){
-    leavesReaderDestroy(&lrs[i]);
-  }
-  leafWriterDestroy(&writer);
-  return rc;
-}
-
-/* Accumulate the union of *acc and *pData into *acc. */
-static void docListAccumulateUnion(DataBuffer *acc,
-                                   const char *pData, int nData) {
-  DataBuffer tmp = *acc;
-  dataBufferInit(acc, tmp.nData+nData);
-  docListUnion(tmp.pData, tmp.nData, pData, nData, acc);
-  dataBufferDestroy(&tmp);
+SQLITE_PRIVATE int sqlite3Fts3ExprLoadDoclist(Fts3Table *pTab, Fts3Expr *pExpr){
+  return evalFts3Expr(pTab, pExpr, &pExpr->aDoclist, &pExpr->nDoclist, 1);
 }
 
-/* TODO(shess) It might be interesting to explore different merge
-** strategies, here.  For instance, since this is a sorted merge, we
-** could easily merge many doclists in parallel.  With some
-** comprehension of the storage format, we could merge all of the
-** doclists within a leaf node directly from the leaf node's storage.
-** It may be worthwhile to merge smaller doclists before larger
-** doclists, since they can be traversed more quickly - but the
-** results may have less overlap, making them more expensive in a
-** different way.
-*/
-
-/* Scan pReader for pTerm/nTerm, and merge the term's doclist over
-** *out (any doclists with duplicate docids overwrite those in *out).
-** Internal function for loadSegmentLeaf().
+/*
+** After ExprLoadDoclist() (see above) has been called, this function is
+** used to iterate through the position lists that make up the doclist
+** stored in pExpr->aDoclist.
 */
-static int loadSegmentLeavesInt(fulltext_vtab *v, LeavesReader *pReader,
-                                const char *pTerm, int nTerm, int isPrefix,
-                                DataBuffer *out){
-  /* doclist data is accumulated into pBuffers similar to how one does
-  ** increment in binary arithmetic.  If index 0 is empty, the data is
-  ** stored there.  If there is data there, it is merged and the
-  ** results carried into position 1, with further merge-and-carry
-  ** until an empty position is found.
-  */
-  DataBuffer *pBuffers = NULL;
-  int nBuffers = 0, nMaxBuffers = 0, rc;
-
-  assert( nTerm>0 );
-
-  for(rc=SQLITE_OK; rc==SQLITE_OK && !leavesReaderAtEnd(pReader);
-      rc=leavesReaderStep(v, pReader)){
-    /* TODO(shess) Really want leavesReaderTermCmp(), but that name is
-    ** already taken to compare the terms of two LeavesReaders.  Think
-    ** on a better name.  [Meanwhile, break encapsulation rather than
-    ** use a confusing name.]
-    */
-    int c = leafReaderTermCmp(&pReader->leafReader, pTerm, nTerm, isPrefix);
-    if( c>0 ) break;      /* Past any possible matches. */
-    if( c==0 ){
-      const char *pData = leavesReaderData(pReader);
-      int iBuffer, nData = leavesReaderDataBytes(pReader);
-
-      /* Find the first empty buffer. */
-      for(iBuffer=0; iBuffer<nBuffers; ++iBuffer){
-        if( 0==pBuffers[iBuffer].nData ) break;
-      }
-
-      /* Out of buffers, add an empty one. */
-      if( iBuffer==nBuffers ){
-        if( nBuffers==nMaxBuffers ){
-          DataBuffer *p;
-          nMaxBuffers += 20;
-
-          /* Manual realloc so we can handle NULL appropriately. */
-          p = sqlite3_malloc(nMaxBuffers*sizeof(*pBuffers));
-          if( p==NULL ){
-            rc = SQLITE_NOMEM;
-            break;
-          }
-
-          if( nBuffers>0 ){
-            assert(pBuffers!=NULL);
-            memcpy(p, pBuffers, nBuffers*sizeof(*pBuffers));
-            sqlite3_free(pBuffers);
-          }
-          pBuffers = p;
-        }
-        dataBufferInit(&(pBuffers[nBuffers]), 0);
-        nBuffers++;
-      }
-
-      /* At this point, must have an empty at iBuffer. */
-      assert(iBuffer<nBuffers && pBuffers[iBuffer].nData==0);
-
-      /* If empty was first buffer, no need for merge logic. */
-      if( iBuffer==0 ){
-        dataBufferReplace(&(pBuffers[0]), pData, nData);
+SQLITE_PRIVATE char *sqlite3Fts3FindPositions(
+  Fts3Expr *pExpr,                /* Access this expressions doclist */
+  sqlite3_int64 iDocid,           /* Docid associated with requested pos-list */
+  int iCol                        /* Column of requested pos-list */
+){
+  assert( pExpr->isLoaded );
+  if( pExpr->aDoclist ){
+    char *pEnd = &pExpr->aDoclist[pExpr->nDoclist];
+    char *pCsr = pExpr->pCurrent;
+
+    assert( pCsr );
+    while( pCsr<pEnd ){
+      if( pExpr->iCurrent<iDocid ){
+        fts3PoslistCopy(0, &pCsr);
+        fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent);
+        pExpr->pCurrent = pCsr;
       }else{
-        /* pAcc is the empty buffer the merged data will end up in. */
-        DataBuffer *pAcc = &(pBuffers[iBuffer]);
-        DataBuffer *p = &(pBuffers[0]);
-
-        /* Handle position 0 specially to avoid need to prime pAcc
-        ** with pData/nData.
-        */
-        dataBufferSwap(p, pAcc);
-        docListAccumulateUnion(pAcc, pData, nData);
-
-        /* Accumulate remaining doclists into pAcc. */
-        for(++p; p<pAcc; ++p){
-          docListAccumulateUnion(pAcc, p->pData, p->nData);
-
-          /* dataBufferReset() could allow a large doclist to blow up
-          ** our memory requirements.
-          */
-          if( p->nCapacity<1024 ){
-            dataBufferReset(p);
-          }else{
-            dataBufferDestroy(p);
-            dataBufferInit(p, 0);
+        if( pExpr->iCurrent==iDocid ){
+          int iThis = 0;
+          if( iCol<0 ){
+            /* If iCol is negative, return a pointer to the start of the
+            ** position-list (instead of a pointer to the start of a list
+            ** of offsets associated with a specific column).
+            */
+            return pCsr;
           }
+          while( iThis<iCol ){
+            fts3ColumnlistCopy(0, &pCsr);
+            if( *pCsr==0x00 ) return 0;
+            pCsr++;
+            pCsr += sqlite3Fts3GetVarint32(pCsr, &iThis);
+          }
+          if( iCol==iThis ) return pCsr;
         }
+        return 0;
       }
     }
   }
 
-  /* Union all the doclists together into *out. */
-  /* TODO(shess) What if *out is big?  Sigh. */
-  if( rc==SQLITE_OK && nBuffers>0 ){
-    int iBuffer;
-    for(iBuffer=0; iBuffer<nBuffers; ++iBuffer){
-      if( pBuffers[iBuffer].nData>0 ){
-        if( out->nData==0 ){
-          dataBufferSwap(out, &(pBuffers[iBuffer]));
-        }else{
-          docListAccumulateUnion(out, pBuffers[iBuffer].pData,
-                                 pBuffers[iBuffer].nData);
-        }
-      }
-    }
-  }
-
-  while( nBuffers-- ){
-    dataBufferDestroy(&(pBuffers[nBuffers]));
-  }
-  if( pBuffers!=NULL ) sqlite3_free(pBuffers);
-
-  return rc;
-}
-
-/* Call loadSegmentLeavesInt() with pData/nData as input. */
-static int loadSegmentLeaf(fulltext_vtab *v, const char *pData, int nData,
-                           const char *pTerm, int nTerm, int isPrefix,
-                           DataBuffer *out){
-  LeavesReader reader;
-  int rc;
-
-  assert( nData>1 );
-  assert( *pData=='\0' );
-  rc = leavesReaderInit(v, 0, 0, 0, pData, nData, &reader);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = loadSegmentLeavesInt(v, &reader, pTerm, nTerm, isPrefix, out);
-  leavesReaderReset(&reader);
-  leavesReaderDestroy(&reader);
-  return rc;
-}
-
-/* Call loadSegmentLeavesInt() with the leaf nodes from iStartLeaf to
-** iEndLeaf (inclusive) as input, and merge the resulting doclist into
-** out.
-*/
-static int loadSegmentLeaves(fulltext_vtab *v,
-                             sqlite_int64 iStartLeaf, sqlite_int64 iEndLeaf,
-                             const char *pTerm, int nTerm, int isPrefix,
-                             DataBuffer *out){
-  int rc;
-  LeavesReader reader;
-
-  assert( iStartLeaf<=iEndLeaf );
-  rc = leavesReaderInit(v, 0, iStartLeaf, iEndLeaf, NULL, 0, &reader);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = loadSegmentLeavesInt(v, &reader, pTerm, nTerm, isPrefix, out);
-  leavesReaderReset(&reader);
-  leavesReaderDestroy(&reader);
-  return rc;
-}
-
-/* Taking pData/nData as an interior node, find the sequence of child
-** nodes which could include pTerm/nTerm/isPrefix.  Note that the
-** interior node terms logically come between the blocks, so there is
-** one more blockid than there are terms (that block contains terms >=
-** the last interior-node term).
-*/
-/* TODO(shess) The calling code may already know that the end child is
-** not worth calculating, because the end may be in a later sibling
-** node.  Consider whether breaking symmetry is worthwhile.  I suspect
-** it is not worthwhile.
-*/
-static void getChildrenContaining(const char *pData, int nData,
-                                  const char *pTerm, int nTerm, int isPrefix,
-                                  sqlite_int64 *piStartChild,
-                                  sqlite_int64 *piEndChild){
-  InteriorReader reader;
-
-  assert( nData>1 );
-  assert( *pData!='\0' );
-  interiorReaderInit(pData, nData, &reader);
-
-  /* Scan for the first child which could contain pTerm/nTerm. */
-  while( !interiorReaderAtEnd(&reader) ){
-    if( interiorReaderTermCmp(&reader, pTerm, nTerm, 0)>0 ) break;
-    interiorReaderStep(&reader);
-  }
-  *piStartChild = interiorReaderCurrentBlockid(&reader);
-
-  /* Keep scanning to find a term greater than our term, using prefix
-  ** comparison if indicated.  If isPrefix is false, this will be the
-  ** same blockid as the starting block.
-  */
-  while( !interiorReaderAtEnd(&reader) ){
-    if( interiorReaderTermCmp(&reader, pTerm, nTerm, isPrefix)>0 ) break;
-    interiorReaderStep(&reader);
-  }
-  *piEndChild = interiorReaderCurrentBlockid(&reader);
-
-  interiorReaderDestroy(&reader);
-
-  /* Children must ascend, and if !prefix, both must be the same. */
-  assert( *piEndChild>=*piStartChild );
-  assert( isPrefix || *piStartChild==*piEndChild );
+  return 0;
 }
 
-/* Read block at iBlockid and pass it with other params to
-** getChildrenContaining().
+/*
+** Helper function used by the implementation of the overloaded snippet(),
+** offsets() and optimize() SQL functions.
+**
+** If the value passed as the third argument is a blob of size
+** sizeof(Fts3Cursor*), then the blob contents are copied to the 
+** output variable *ppCsr and SQLITE_OK is returned. Otherwise, an error
+** message is written to context pContext and SQLITE_ERROR returned. The
+** string passed via zFunc is used as part of the error message.
 */
-static int loadAndGetChildrenContaining(
-  fulltext_vtab *v,
-  sqlite_int64 iBlockid,
-  const char *pTerm, int nTerm, int isPrefix,
-  sqlite_int64 *piStartChild, sqlite_int64 *piEndChild
+static int fts3FunctionArg(
+  sqlite3_context *pContext,      /* SQL function call context */
+  const char *zFunc,              /* Function name */
+  sqlite3_value *pVal,            /* argv[0] passed to function */
+  Fts3Cursor **ppCsr         /* OUT: Store cursor handle here */
 ){
-  sqlite3_stmt *s = NULL;
-  int rc;
-
-  assert( iBlockid!=0 );
-  assert( pTerm!=NULL );
-  assert( nTerm!=0 );        /* TODO(shess) Why not allow this? */
-  assert( piStartChild!=NULL );
-  assert( piEndChild!=NULL );
-
-  rc = sql_get_statement(v, BLOCK_SELECT_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_bind_int64(s, 1, iBlockid);
-  if( rc!=SQLITE_OK ) return rc;
-
-  rc = sqlite3_step(s);
-  if( rc==SQLITE_DONE ) return SQLITE_ERROR;
-  if( rc!=SQLITE_ROW ) return rc;
-
-  getChildrenContaining(sqlite3_column_blob(s, 0), sqlite3_column_bytes(s, 0),
-                        pTerm, nTerm, isPrefix, piStartChild, piEndChild);
-
-  /* We expect only one row.  We must execute another sqlite3_step()
-   * to complete the iteration; otherwise the table will remain
-   * locked. */
-  rc = sqlite3_step(s);
-  if( rc==SQLITE_ROW ) return SQLITE_ERROR;
-  if( rc!=SQLITE_DONE ) return rc;
-
-  return SQLITE_OK;
-}
-
-/* Traverse the tree represented by pData[nData] looking for
-** pTerm[nTerm], placing its doclist into *out.  This is internal to
-** loadSegment() to make error-handling cleaner.
-*/
-static int loadSegmentInt(fulltext_vtab *v, const char *pData, int nData,
-                          sqlite_int64 iLeavesEnd,
-                          const char *pTerm, int nTerm, int isPrefix,
-                          DataBuffer *out){
-  /* Special case where root is a leaf. */
-  if( *pData=='\0' ){
-    return loadSegmentLeaf(v, pData, nData, pTerm, nTerm, isPrefix, out);
-  }else{
-    int rc;
-    sqlite_int64 iStartChild, iEndChild;
-
-    /* Process pData as an interior node, then loop down the tree
-    ** until we find the set of leaf nodes to scan for the term.
-    */
-    getChildrenContaining(pData, nData, pTerm, nTerm, isPrefix,
-                          &iStartChild, &iEndChild);
-    while( iStartChild>iLeavesEnd ){
-      sqlite_int64 iNextStart, iNextEnd;
-      rc = loadAndGetChildrenContaining(v, iStartChild, pTerm, nTerm, isPrefix,
-                                        &iNextStart, &iNextEnd);
-      if( rc!=SQLITE_OK ) return rc;
-
-      /* If we've branched, follow the end branch, too. */
-      if( iStartChild!=iEndChild ){
-        sqlite_int64 iDummy;
-        rc = loadAndGetChildrenContaining(v, iEndChild, pTerm, nTerm, isPrefix,
-                                          &iDummy, &iNextEnd);
-        if( rc!=SQLITE_OK ) return rc;
-      }
-
-      assert( iNextStart<=iNextEnd );
-      iStartChild = iNextStart;
-      iEndChild = iNextEnd;
-    }
-    assert( iStartChild<=iLeavesEnd );
-    assert( iEndChild<=iLeavesEnd );
-
-    /* Scan through the leaf segments for doclists. */
-    return loadSegmentLeaves(v, iStartChild, iEndChild,
-                             pTerm, nTerm, isPrefix, out);
-  }
-}
-
-/* Call loadSegmentInt() to collect the doclist for pTerm/nTerm, then
-** merge its doclist over *out (any duplicate doclists read from the
-** segment rooted at pData will overwrite those in *out).
-*/
-/* TODO(shess) Consider changing this to determine the depth of the
-** leaves using either the first characters of interior nodes (when
-** ==1, we're one level above the leaves), or the first character of
-** the root (which will describe the height of the tree directly).
-** Either feels somewhat tricky to me.
-*/
-/* TODO(shess) The current merge is likely to be slow for large
-** doclists (though it should process from newest/smallest to
-** oldest/largest, so it may not be that bad).  It might be useful to
-** modify things to allow for N-way merging.  This could either be
-** within a segment, with pairwise merges across segments, or across
-** all segments at once.
-*/
-static int loadSegment(fulltext_vtab *v, const char *pData, int nData,
-                       sqlite_int64 iLeavesEnd,
-                       const char *pTerm, int nTerm, int isPrefix,
-                       DataBuffer *out){
-  DataBuffer result;
-  int rc;
-
-  assert( nData>1 );
-
-  /* This code should never be called with buffered updates. */
-  assert( v->nPendingData<0 );
-
-  dataBufferInit(&result, 0);
-  rc = loadSegmentInt(v, pData, nData, iLeavesEnd,
-                      pTerm, nTerm, isPrefix, &result);
-  if( rc==SQLITE_OK && result.nData>0 ){
-    if( out->nData==0 ){
-      DataBuffer tmp = *out;
-      *out = result;
-      result = tmp;
-    }else{
-      DataBuffer merged;
-      DLReader readers[2];
-
-      dlrInit(&readers[0], DL_DEFAULT, out->pData, out->nData);
-      dlrInit(&readers[1], DL_DEFAULT, result.pData, result.nData);
-      dataBufferInit(&merged, out->nData+result.nData);
-      docListMerge(&merged, readers, 2);
-      dataBufferDestroy(out);
-      *out = merged;
-      dlrDestroy(&readers[0]);
-      dlrDestroy(&readers[1]);
-    }
+  Fts3Cursor *pRet;
+  if( sqlite3_value_type(pVal)!=SQLITE_BLOB 
+   || sqlite3_value_bytes(pVal)!=sizeof(Fts3Cursor *)
+  ){
+    char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
+    sqlite3_result_error(pContext, zErr, -1);
+    sqlite3_free(zErr);
+    return SQLITE_ERROR;
   }
-  dataBufferDestroy(&result);
-  return rc;
+  memcpy(&pRet, sqlite3_value_blob(pVal), sizeof(Fts3Cursor *));
+  *ppCsr = pRet;
+  return SQLITE_OK;
 }
 
-/* Scan the database and merge together the posting lists for the term
-** into *out.
+/*
+** Implementation of the snippet() function for FTS3
 */
-static int termSelect(
-  fulltext_vtab *v, 
-  int iColumn,
-  const char *pTerm, int nTerm,             /* Term to query for */
-  int isPrefix,                             /* True for a prefix search */
-  DocListType iType, 
-  DataBuffer *out                           /* Write results here */
+static void fts3SnippetFunc(
+  sqlite3_context *pContext,      /* SQLite function call context */
+  int nVal,                       /* Size of apVal[] array */
+  sqlite3_value **apVal           /* Array of arguments */
 ){
-  DataBuffer doclist;
-  sqlite3_stmt *s;
-  int rc = sql_get_statement(v, SEGDIR_SELECT_ALL_STMT, &s);
-  if( rc!=SQLITE_OK ) return rc;
-
-  /* This code should never be called with buffered updates. */
-  assert( v->nPendingData<0 );
-
-  dataBufferInit(&doclist, 0);
-  dataBufferInit(out, 0);
-
-  /* Traverse the segments from oldest to newest so that newer doclist
-  ** elements for given docids overwrite older elements.
-  */
-  while( (rc = sqlite3_step(s))==SQLITE_ROW ){
-    const char *pData = sqlite3_column_blob(s, 2);
-    const int nData = sqlite3_column_bytes(s, 2);
-    const sqlite_int64 iLeavesEnd = sqlite3_column_int64(s, 1);
-    rc = loadSegment(v, pData, nData, iLeavesEnd, pTerm, nTerm, isPrefix,
-                     &doclist);
-    if( rc!=SQLITE_OK ) goto err;
-  }
-  if( rc==SQLITE_DONE ){
-    if( doclist.nData!=0 ){
-      /* TODO(shess) The old term_select_all() code applied the column
-      ** restrict as we merged segments, leading to smaller buffers.
-      ** This is probably worthwhile to bring back, once the new storage
-      ** system is checked in.
-      */
-      if( iColumn==v->nColumn) iColumn = -1;
-      docListTrim(DL_DEFAULT, doclist.pData, doclist.nData,
-                  iColumn, iType, out);
-    }
-    rc = SQLITE_OK;
-  }
-
- err:
-  dataBufferDestroy(&doclist);
-  return rc;
-}
-
-/****************************************************************/
-/* Used to hold hashtable data for sorting. */
-typedef struct TermData {
-  const char *pTerm;
-  int nTerm;
-  DLCollector *pCollector;
-} TermData;
-
-/* Orders TermData elements in strcmp fashion ( <0 for less-than, 0
-** for equal, >0 for greater-than).
-*/
-static int termDataCmp(const void *av, const void *bv){
-  const TermData *a = (const TermData *)av;
-  const TermData *b = (const TermData *)bv;
-  int n = a->nTerm<b->nTerm ? a->nTerm : b->nTerm;
-  int c = memcmp(a->pTerm, b->pTerm, n);
-  if( c!=0 ) return c;
-  return a->nTerm-b->nTerm;
-}
-
-/* Order pTerms data by term, then write a new level 0 segment using
-** LeafWriter.
-*/
-static int writeZeroSegment(fulltext_vtab *v, fts3Hash *pTerms){
-  fts3HashElem *e;
-  int idx, rc, i, n;
-  TermData *pData;
-  LeafWriter writer;
-  DataBuffer dl;
-
-  /* Determine the next index at level 0, merging as necessary. */
-  rc = segdirNextIndex(v, 0, &idx);
-  if( rc!=SQLITE_OK ) return rc;
-
-  n = fts3HashCount(pTerms);
-  pData = sqlite3_malloc(n*sizeof(TermData));
-
-  for(i = 0, e = fts3HashFirst(pTerms); e; i++, e = fts3HashNext(e)){
-    assert( i<n );
-    pData[i].pTerm = fts3HashKey(e);
-    pData[i].nTerm = fts3HashKeysize(e);
-    pData[i].pCollector = fts3HashData(e);
-  }
-  assert( i==n );
-
-  /* TODO(shess) Should we allow user-defined collation sequences,
-  ** here?  I think we only need that once we support prefix searches.
-  */
-  if( n>1 ) qsort(pData, n, sizeof(*pData), termDataCmp);
+  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */
+  const char *zStart = "<b>";
+  const char *zEnd = "</b>";
+  const char *zEllipsis = "<b>...</b>";
 
-  /* TODO(shess) Refactor so that we can write directly to the segment
-  ** DataBuffer, as happens for segment merges.
+  /* There must be at least one argument passed to this function (otherwise
+  ** the non-overloaded version would have been called instead of this one).
   */
-  leafWriterInit(0, idx, &writer);
-  dataBufferInit(&dl, 0);
-  for(i=0; i<n; i++){
-    dataBufferReset(&dl);
-    dlcAddDoclist(pData[i].pCollector, &dl);
-    rc = leafWriterStep(v, &writer,
-                        pData[i].pTerm, pData[i].nTerm, dl.pData, dl.nData);
-    if( rc!=SQLITE_OK ) goto err;
-  }
-  rc = leafWriterFinalize(v, &writer);
-
- err:
-  dataBufferDestroy(&dl);
-  sqlite3_free(pData);
-  leafWriterDestroy(&writer);
-  return rc;
-}
-
-/* If pendingTerms has data, free it. */
-static int clearPendingTerms(fulltext_vtab *v){
-  if( v->nPendingData>=0 ){
-    fts3HashElem *e;
-    for(e=fts3HashFirst(&v->pendingTerms); e; e=fts3HashNext(e)){
-      dlcDelete(fts3HashData(e));
-    }
-    fts3HashClear(&v->pendingTerms);
-    v->nPendingData = -1;
-  }
-  return SQLITE_OK;
-}
-
-/* If pendingTerms has data, flush it to a level-zero segment, and
-** free it.
-*/
-static int flushPendingTerms(fulltext_vtab *v){
-  if( v->nPendingData>=0 ){
-    int rc = writeZeroSegment(v, &v->pendingTerms);
-    if( rc==SQLITE_OK ) clearPendingTerms(v);
-    return rc;
-  }
-  return SQLITE_OK;
-}
+  assert( nVal>=1 );
 
-/* If pendingTerms is "too big", or docid is out of order, flush it.
-** Regardless, be certain that pendingTerms is initialized for use.
-*/
-static int initPendingTerms(fulltext_vtab *v, sqlite_int64 iDocid){
-  /* TODO(shess) Explore whether partially flushing the buffer on
-  ** forced-flush would provide better performance.  I suspect that if
-  ** we ordered the doclists by size and flushed the largest until the
-  ** buffer was half empty, that would let the less frequent terms
-  ** generate longer doclists.
-  */
-  if( iDocid<=v->iPrevDocid || v->nPendingData>kPendingThreshold ){
-    int rc = flushPendingTerms(v);
-    if( rc!=SQLITE_OK ) return rc;
-  }
-  if( v->nPendingData<0 ){
-    fts3HashInit(&v->pendingTerms, FTS3_HASH_STRING, 1);
-    v->nPendingData = 0;
+  if( nVal>4 ){
+    sqlite3_result_error(pContext, 
+        "wrong number of arguments to function snippet()", -1);
+    return;
   }
-  v->iPrevDocid = iDocid;
-  return SQLITE_OK;
-}
+  if( fts3FunctionArg(pContext, "snippet", apVal[0], &pCsr) ) return;
 
-/* This function implements the xUpdate callback; it is the top-level entry
- * point for inserting, deleting or updating a row in a full-text table. */
-static int fulltextUpdate(sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg,
-                          sqlite_int64 *pRowid){
-  fulltext_vtab *v = (fulltext_vtab *) pVtab;
-  int rc;
-
-  FTSTRACE(("FTS3 Update %p\n", pVtab));
-
-  if( nArg<2 ){
-    rc = index_delete(v, sqlite3_value_int64(ppArg[0]));
-    if( rc==SQLITE_OK ){
-      /* If we just deleted the last row in the table, clear out the
-      ** index data.
-      */
-      rc = content_exists(v);
-      if( rc==SQLITE_ROW ){
-        rc = SQLITE_OK;
-      }else if( rc==SQLITE_DONE ){
-        /* Clear the pending terms so we don't flush a useless level-0
-        ** segment when the transaction closes.
-        */
-        rc = clearPendingTerms(v);
-        if( rc==SQLITE_OK ){
-          rc = segdir_delete_all(v);
-        }
-      }
-    }
-  } else if( sqlite3_value_type(ppArg[0]) != SQLITE_NULL ){
-    /* An update:
-     * ppArg[0] = old rowid
-     * ppArg[1] = new rowid
-     * ppArg[2..2+v->nColumn-1] = values
-     * ppArg[2+v->nColumn] = value for magic column (we ignore this)
-     * ppArg[2+v->nColumn+1] = value for docid
-     */
-    sqlite_int64 rowid = sqlite3_value_int64(ppArg[0]);
-    if( sqlite3_value_type(ppArg[1]) != SQLITE_INTEGER ||
-        sqlite3_value_int64(ppArg[1]) != rowid ){
-      rc = SQLITE_ERROR;  /* we don't allow changing the rowid */
-    }else if( sqlite3_value_type(ppArg[2+v->nColumn+1]) != SQLITE_INTEGER ||
-              sqlite3_value_int64(ppArg[2+v->nColumn+1]) != rowid ){
-      rc = SQLITE_ERROR;  /* we don't allow changing the docid */
-    }else{
-      assert( nArg==2+v->nColumn+2);
-      rc = index_update(v, rowid, &ppArg[2]);
-    }
-  } else {
-    /* An insert:
-     * ppArg[1] = requested rowid
-     * ppArg[2..2+v->nColumn-1] = values
-     * ppArg[2+v->nColumn] = value for magic column (we ignore this)
-     * ppArg[2+v->nColumn+1] = value for docid
-     */
-    sqlite3_value *pRequestDocid = ppArg[2+v->nColumn+1];
-    assert( nArg==2+v->nColumn+2);
-    if( SQLITE_NULL != sqlite3_value_type(pRequestDocid) &&
-        SQLITE_NULL != sqlite3_value_type(ppArg[1]) ){
-      /* TODO(shess) Consider allowing this to work if the values are
-      ** identical.  I'm inclined to discourage that usage, though,
-      ** given that both rowid and docid are special columns.  Better
-      ** would be to define one or the other as the default winner,
-      ** but should it be fts3-centric (docid) or SQLite-centric
-      ** (rowid)?
-      */
-      rc = SQLITE_ERROR;
-    }else{
-      if( SQLITE_NULL == sqlite3_value_type(pRequestDocid) ){
-        pRequestDocid = ppArg[1];
-      }
-      rc = index_insert(v, pRequestDocid, &ppArg[2], pRowid);
-    }
+  switch( nVal ){
+    case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);
+    case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
+    case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
   }
-
-  return rc;
-}
-
-static int fulltextSync(sqlite3_vtab *pVtab){
-  FTSTRACE(("FTS3 xSync()\n"));
-  return flushPendingTerms((fulltext_vtab *)pVtab);
-}
-
-static int fulltextBegin(sqlite3_vtab *pVtab){
-  fulltext_vtab *v = (fulltext_vtab *) pVtab;
-  FTSTRACE(("FTS3 xBegin()\n"));
-
-  /* Any buffered updates should have been cleared by the previous
-  ** transaction.
-  */
-  assert( v->nPendingData<0 );
-  return clearPendingTerms(v);
-}
-
-static int fulltextCommit(sqlite3_vtab *pVtab){
-  fulltext_vtab *v = (fulltext_vtab *) pVtab;
-  FTSTRACE(("FTS3 xCommit()\n"));
-
-  /* Buffered updates should have been cleared by fulltextSync(). */
-  assert( v->nPendingData<0 );
-  return clearPendingTerms(v);
-}
-
-static int fulltextRollback(sqlite3_vtab *pVtab){
-  FTSTRACE(("FTS3 xRollback()\n"));
-  return clearPendingTerms((fulltext_vtab *)pVtab);
-}
-
-/*
-** Implementation of the snippet() function for FTS3
-*/
-static void snippetFunc(
-  sqlite3_context *pContext,
-  int argc,
-  sqlite3_value **argv
-){
-  fulltext_cursor *pCursor;
-  if( argc<1 ) return;
-  if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||
-      sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){
-    sqlite3_result_error(pContext, "illegal first argument to html_snippet",-1);
-  }else{
-    const char *zStart = "<b>";
-    const char *zEnd = "</b>";
-    const char *zEllipsis = "<b>...</b>";
-    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));
-    if( argc>=2 ){
-      zStart = (const char*)sqlite3_value_text(argv[1]);
-      if( argc>=3 ){
-        zEnd = (const char*)sqlite3_value_text(argv[2]);
-        if( argc>=4 ){
-          zEllipsis = (const char*)sqlite3_value_text(argv[3]);
-        }
-      }
-    }
-    snippetAllOffsets(pCursor);
-    snippetText(pCursor, zStart, zEnd, zEllipsis);
-    sqlite3_result_text(pContext, pCursor->snippet.zSnippet,
-                        pCursor->snippet.nSnippet, SQLITE_STATIC);
+  if( !zEllipsis || !zEnd || !zStart ){
+    sqlite3_result_error_nomem(pContext);
+  }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
+    sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis);
   }
 }
 
 /*
-** Implementation of the offsets() function for FTS3
+** Implementation of the snippet2() function for FTS3
 */
-static void snippetOffsetsFunc(
-  sqlite3_context *pContext,
-  int argc,
-  sqlite3_value **argv
+static void fts3Snippet2Func(
+  sqlite3_context *pContext,      /* SQLite function call context */
+  int nVal,                       /* Size of apVal[] array */
+  sqlite3_value **apVal           /* Array of arguments */
 ){
-  fulltext_cursor *pCursor;
-  if( argc<1 ) return;
-  if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||
-      sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){
-    sqlite3_result_error(pContext, "illegal first argument to offsets",-1);
-  }else{
-    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));
-    snippetAllOffsets(pCursor);
-    snippetOffsetText(&pCursor->snippet);
-    sqlite3_result_text(pContext,
-                        pCursor->snippet.zOffset, pCursor->snippet.nOffset,
-                        SQLITE_STATIC);
-  }
-}
-
-/* OptLeavesReader is nearly identical to LeavesReader, except that
-** where LeavesReader is geared towards the merging of complete
-** segment levels (with exactly MERGE_COUNT segments), OptLeavesReader
-** is geared towards implementation of the optimize() function, and
-** can merge all segments simultaneously.  This version may be
-** somewhat less efficient than LeavesReader because it merges into an
-** accumulator rather than doing an N-way merge, but since segment
-** size grows exponentially (so segment count logrithmically) this is
-** probably not an immediate problem.
-*/
-/* TODO(shess): Prove that assertion, or extend the merge code to
-** merge tree fashion (like the prefix-searching code does).
-*/
-/* TODO(shess): OptLeavesReader and LeavesReader could probably be
-** merged with little or no loss of performance for LeavesReader.  The
-** merged code would need to handle >MERGE_COUNT segments, and would
-** also need to be able to optionally optimize away deletes.
-*/
-typedef struct OptLeavesReader {
-  /* Segment number, to order readers by age. */
-  int segment;
-  LeavesReader reader;
-} OptLeavesReader;
+  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */
+  const char *zStart = "<b>";
+  const char *zEnd = "</b>";
+  const char *zEllipsis = "<b>...</b>";
+  int iCol = -1;
+  int nToken = 10;
 
-static int optLeavesReaderAtEnd(OptLeavesReader *pReader){
-  return leavesReaderAtEnd(&pReader->reader);
-}
-static int optLeavesReaderTermBytes(OptLeavesReader *pReader){
-  return leavesReaderTermBytes(&pReader->reader);
-}
-static const char *optLeavesReaderData(OptLeavesReader *pReader){
-  return leavesReaderData(&pReader->reader);
-}
-static int optLeavesReaderDataBytes(OptLeavesReader *pReader){
-  return leavesReaderDataBytes(&pReader->reader);
-}
-static const char *optLeavesReaderTerm(OptLeavesReader *pReader){
-  return leavesReaderTerm(&pReader->reader);
-}
-static int optLeavesReaderStep(fulltext_vtab *v, OptLeavesReader *pReader){
-  return leavesReaderStep(v, &pReader->reader);
-}
-static int optLeavesReaderTermCmp(OptLeavesReader *lr1, OptLeavesReader *lr2){
-  return leavesReaderTermCmp(&lr1->reader, &lr2->reader);
-}
-/* Order by term ascending, segment ascending (oldest to newest), with
-** exhausted readers to the end.
-*/
-static int optLeavesReaderCmp(OptLeavesReader *lr1, OptLeavesReader *lr2){
-  int c = optLeavesReaderTermCmp(lr1, lr2);
-  if( c!=0 ) return c;
-  return lr1->segment-lr2->segment;
-}
-/* Bubble pLr[0] to appropriate place in pLr[1..nLr-1].  Assumes that
-** pLr[1..nLr-1] is already sorted.
-*/
-static void optLeavesReaderReorder(OptLeavesReader *pLr, int nLr){
-  while( nLr>1 && optLeavesReaderCmp(pLr, pLr+1)>0 ){
-    OptLeavesReader tmp = pLr[0];
-    pLr[0] = pLr[1];
-    pLr[1] = tmp;
-    nLr--;
-    pLr++;
-  }
-}
-
-/* optimize() helper function.  Put the readers in order and iterate
-** through them, merging doclists for matching terms into pWriter.
-** Returns SQLITE_OK on success, or the SQLite error code which
-** prevented success.
-*/
-static int optimizeInternal(fulltext_vtab *v,
-                            OptLeavesReader *readers, int nReaders,
-                            LeafWriter *pWriter){
-  int i, rc = SQLITE_OK;
-  DataBuffer doclist, merged, tmp;
-
-  /* Order the readers. */
-  i = nReaders;
-  while( i-- > 0 ){
-    optLeavesReaderReorder(&readers[i], nReaders-i);
-  }
-
-  dataBufferInit(&doclist, LEAF_MAX);
-  dataBufferInit(&merged, LEAF_MAX);
-
-  /* Exhausted readers bubble to the end, so when the first reader is
-  ** at eof, all are at eof.
+  /* There must be at least one argument passed to this function (otherwise
+  ** the non-overloaded version would have been called instead of this one).
   */
-  while( !optLeavesReaderAtEnd(&readers[0]) ){
-
-    /* Figure out how many readers share the next term. */
-    for(i=1; i<nReaders && !optLeavesReaderAtEnd(&readers[i]); i++){
-      if( 0!=optLeavesReaderTermCmp(&readers[0], &readers[i]) ) break;
-    }
-
-    /* Special-case for no merge. */
-    if( i==1 ){
-      /* Trim deletions from the doclist. */
-      dataBufferReset(&merged);
-      docListTrim(DL_DEFAULT,
-                  optLeavesReaderData(&readers[0]),
-                  optLeavesReaderDataBytes(&readers[0]),
-                  -1, DL_DEFAULT, &merged);
-    }else{
-      DLReader dlReaders[MERGE_COUNT];
-      int iReader, nReaders;
-
-      /* Prime the pipeline with the first reader's doclist.  After
-      ** one pass index 0 will reference the accumulated doclist.
-      */
-      dlrInit(&dlReaders[0], DL_DEFAULT,
-              optLeavesReaderData(&readers[0]),
-              optLeavesReaderDataBytes(&readers[0]));
-      iReader = 1;
-
-      assert( iReader<i );  /* Must execute the loop at least once. */
-      while( iReader<i ){
-        /* Merge 16 inputs per pass. */
-        for( nReaders=1; iReader<i && nReaders<MERGE_COUNT;
-             iReader++, nReaders++ ){
-          dlrInit(&dlReaders[nReaders], DL_DEFAULT,
-                  optLeavesReaderData(&readers[iReader]),
-                  optLeavesReaderDataBytes(&readers[iReader]));
-        }
-
-        /* Merge doclists and swap result into accumulator. */
-        dataBufferReset(&merged);
-        docListMerge(&merged, dlReaders, nReaders);
-        tmp = merged;
-        merged = doclist;
-        doclist = tmp;
-
-        while( nReaders-- > 0 ){
-          dlrDestroy(&dlReaders[nReaders]);
-        }
-
-        /* Accumulated doclist to reader 0 for next pass. */
-        dlrInit(&dlReaders[0], DL_DEFAULT, doclist.pData, doclist.nData);
-      }
-
-      /* Destroy reader that was left in the pipeline. */
-      dlrDestroy(&dlReaders[0]);
-
-      /* Trim deletions from the doclist. */
-      dataBufferReset(&merged);
-      docListTrim(DL_DEFAULT, doclist.pData, doclist.nData,
-                  -1, DL_DEFAULT, &merged);
-    }
-
-    /* Only pass doclists with hits (skip if all hits deleted). */
-    if( merged.nData>0 ){
-      rc = leafWriterStep(v, pWriter,
-                          optLeavesReaderTerm(&readers[0]),
-                          optLeavesReaderTermBytes(&readers[0]),
-                          merged.pData, merged.nData);
-      if( rc!=SQLITE_OK ) goto err;
-    }
-
-    /* Step merged readers to next term and reorder. */
-    while( i-- > 0 ){
-      rc = optLeavesReaderStep(v, &readers[i]);
-      if( rc!=SQLITE_OK ) goto err;
-
-      optLeavesReaderReorder(&readers[i], nReaders-i);
-    }
-  }
-
- err:
-  dataBufferDestroy(&doclist);
-  dataBufferDestroy(&merged);
-  return rc;
-}
-
-/* Implement optimize() function for FTS3.  optimize(t) merges all
-** segments in the fts index into a single segment.  't' is the magic
-** table-named column.
-*/
-static void optimizeFunc(sqlite3_context *pContext,
-                         int argc, sqlite3_value **argv){
-  fulltext_cursor *pCursor;
-  if( argc>1 ){
-    sqlite3_result_error(pContext, "excess arguments to optimize()",-1);
-  }else if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||
-            sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){
-    sqlite3_result_error(pContext, "illegal first argument to optimize",-1);
-  }else{
-    fulltext_vtab *v;
-    int i, rc, iMaxLevel;
-    OptLeavesReader *readers;
-    int nReaders;
-    LeafWriter writer;
-    sqlite3_stmt *s;
-
-    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));
-    v = cursor_vtab(pCursor);
-
-    /* Flush any buffered updates before optimizing. */
-    rc = flushPendingTerms(v);
-    if( rc!=SQLITE_OK ) goto err;
-
-    rc = segdir_count(v, &nReaders, &iMaxLevel);
-    if( rc!=SQLITE_OK ) goto err;
-    if( nReaders==0 || nReaders==1 ){
-      sqlite3_result_text(pContext, "Index already optimal", -1,
-                          SQLITE_STATIC);
-      return;
-    }
-
-    rc = sql_get_statement(v, SEGDIR_SELECT_ALL_STMT, &s);
-    if( rc!=SQLITE_OK ) goto err;
+  assert( nVal>=1 );
 
-    readers = sqlite3_malloc(nReaders*sizeof(readers[0]));
-    if( readers==NULL ) goto err;
-
-    /* Note that there will already be a segment at this position
-    ** until we call segdir_delete() on iMaxLevel.
-    */
-    leafWriterInit(iMaxLevel, 0, &writer);
-
-    i = 0;
-    while( (rc = sqlite3_step(s))==SQLITE_ROW ){
-      sqlite_int64 iStart = sqlite3_column_int64(s, 0);
-      sqlite_int64 iEnd = sqlite3_column_int64(s, 1);
-      const char *pRootData = sqlite3_column_blob(s, 2);
-      int nRootData = sqlite3_column_bytes(s, 2);
-
-      assert( i<nReaders );
-      rc = leavesReaderInit(v, -1, iStart, iEnd, pRootData, nRootData,
-                            &readers[i].reader);
-      if( rc!=SQLITE_OK ) break;
-
-      readers[i].segment = i;
-      i++;
-    }
-
-    /* If we managed to successfully read them all, optimize them. */
-    if( rc==SQLITE_DONE ){
-      assert( i==nReaders );
-      rc = optimizeInternal(v, readers, nReaders, &writer);
-    }
-
-    while( i-- > 0 ){
-      leavesReaderDestroy(&readers[i].reader);
-    }
-    sqlite3_free(readers);
-
-    /* If we've successfully gotten to here, delete the old segments
-    ** and flush the interior structure of the new segment.
-    */
-    if( rc==SQLITE_OK ){
-      for( i=0; i<=iMaxLevel; i++ ){
-        rc = segdir_delete(v, i);
-        if( rc!=SQLITE_OK ) break;
-      }
-
-      if( rc==SQLITE_OK ) rc = leafWriterFinalize(v, &writer);
-    }
-
-    leafWriterDestroy(&writer);
-
-    if( rc!=SQLITE_OK ) goto err;
-
-    sqlite3_result_text(pContext, "Index optimized", -1, SQLITE_STATIC);
+  if( nVal>6 ){
+    sqlite3_result_error(pContext, 
+        "wrong number of arguments to function snippet()", -1);
     return;
-
-    /* TODO(shess): Error-handling needs to be improved along the
-    ** lines of the dump_ functions.
-    */
- err:
-    {
-      char buf[512];
-      sqlite3_snprintf(sizeof(buf), buf, "Error in optimize: %s",
-                       sqlite3_errmsg(sqlite3_context_db_handle(pContext)));
-      sqlite3_result_error(pContext, buf, -1);
-    }
-  }
-}
-
-#ifdef SQLITE_TEST
-/* Generate an error of the form "<prefix>: <msg>".  If msg is NULL,
-** pull the error from the context's db handle.
-*/
-static void generateError(sqlite3_context *pContext,
-                          const char *prefix, const char *msg){
-  char buf[512];
-  if( msg==NULL ) msg = sqlite3_errmsg(sqlite3_context_db_handle(pContext));
-  sqlite3_snprintf(sizeof(buf), buf, "%s: %s", prefix, msg);
-  sqlite3_result_error(pContext, buf, -1);
-}
-
-/* Helper function to collect the set of terms in the segment into
-** pTerms.  The segment is defined by the leaf nodes between
-** iStartBlockid and iEndBlockid, inclusive, or by the contents of
-** pRootData if iStartBlockid is 0 (in which case the entire segment
-** fit in a leaf).
-*/
-static int collectSegmentTerms(fulltext_vtab *v, sqlite3_stmt *s,
-                               fts3Hash *pTerms){
-  const sqlite_int64 iStartBlockid = sqlite3_column_int64(s, 0);
-  const sqlite_int64 iEndBlockid = sqlite3_column_int64(s, 1);
-  const char *pRootData = sqlite3_column_blob(s, 2);
-  const int nRootData = sqlite3_column_bytes(s, 2);
-  LeavesReader reader;
-  int rc = leavesReaderInit(v, 0, iStartBlockid, iEndBlockid,
-                            pRootData, nRootData, &reader);
-  if( rc!=SQLITE_OK ) return rc;
-
-  while( rc==SQLITE_OK && !leavesReaderAtEnd(&reader) ){
-    const char *pTerm = leavesReaderTerm(&reader);
-    const int nTerm = leavesReaderTermBytes(&reader);
-    void *oldValue = sqlite3Fts3HashFind(pTerms, pTerm, nTerm);
-    void *newValue = (void *)((char *)oldValue+1);
-
-    /* From the comment before sqlite3Fts3HashInsert in fts3_hash.c,
-    ** the data value passed is returned in case of malloc failure.
-    */
-    if( newValue==sqlite3Fts3HashInsert(pTerms, pTerm, nTerm, newValue) ){
-      rc = SQLITE_NOMEM;
-    }else{
-      rc = leavesReaderStep(v, &reader);
-    }
-  }
-
-  leavesReaderDestroy(&reader);
-  return rc;
-}
-
-/* Helper function to build the result string for dump_terms(). */
-static int generateTermsResult(sqlite3_context *pContext, fts3Hash *pTerms){
-  int iTerm, nTerms, nResultBytes, iByte;
-  char *result;
-  TermData *pData;
-  fts3HashElem *e;
-
-  /* Iterate pTerms to generate an array of terms in pData for
-  ** sorting.
-  */
-  nTerms = fts3HashCount(pTerms);
-  assert( nTerms>0 );
-  pData = sqlite3_malloc(nTerms*sizeof(TermData));
-  if( pData==NULL ) return SQLITE_NOMEM;
-
-  nResultBytes = 0;
-  for(iTerm = 0, e = fts3HashFirst(pTerms); e; iTerm++, e = fts3HashNext(e)){
-    nResultBytes += fts3HashKeysize(e)+1;   /* Term plus trailing space */
-    assert( iTerm<nTerms );
-    pData[iTerm].pTerm = fts3HashKey(e);
-    pData[iTerm].nTerm = fts3HashKeysize(e);
-    pData[iTerm].pCollector = fts3HashData(e);  /* unused */
   }
-  assert( iTerm==nTerms );
+  if( fts3FunctionArg(pContext, "snippet", apVal[0], &pCsr) ) return;
 
-  assert( nResultBytes>0 );   /* nTerms>0, nResultsBytes must be, too. */
-  result = sqlite3_malloc(nResultBytes);
-  if( result==NULL ){
-    sqlite3_free(pData);
-    return SQLITE_NOMEM;
+  switch( nVal ){
+    case 6: nToken = sqlite3_value_int(apVal[5]);
+    case 5: iCol = sqlite3_value_int(apVal[4]);
+    case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);
+    case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
+    case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
   }
-
-  if( nTerms>1 ) qsort(pData, nTerms, sizeof(*pData), termDataCmp);
-
-  /* Read the terms in order to build the result. */
-  iByte = 0;
-  for(iTerm=0; iTerm<nTerms; ++iTerm){
-    memcpy(result+iByte, pData[iTerm].pTerm, pData[iTerm].nTerm);
-    iByte += pData[iTerm].nTerm;
-    result[iByte++] = ' ';
+  if( !zEllipsis || !zEnd || !zStart ){
+    sqlite3_result_error_nomem(pContext);
+  }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
+    sqlite3Fts3Snippet2(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);
   }
-  assert( iByte==nResultBytes );
-  assert( result[nResultBytes-1]==' ' );
-  result[nResultBytes-1] = '\0';
-
-  /* Passes away ownership of result. */
-  sqlite3_result_text(pContext, result, nResultBytes-1, sqlite3_free);
-  sqlite3_free(pData);
-  return SQLITE_OK;
 }
 
-/* Implements dump_terms() for use in inspecting the fts3 index from
-** tests.  TEXT result containing the ordered list of terms joined by
-** spaces.  dump_terms(t, level, idx) dumps the terms for the segment
-** specified by level, idx (in %_segdir), while dump_terms(t) dumps
-** all terms in the index.  In both cases t is the fts table's magic
-** table-named column.
+/*
+** Implementation of the offsets() function for FTS3
 */
-static void dumpTermsFunc(
-  sqlite3_context *pContext,
-  int argc, sqlite3_value **argv
+static void fts3OffsetsFunc(
+  sqlite3_context *pContext,      /* SQLite function call context */
+  int nVal,                       /* Size of argument array */
+  sqlite3_value **apVal           /* Array of arguments */
 ){
-  fulltext_cursor *pCursor;
-  if( argc!=3 && argc!=1 ){
-    generateError(pContext, "dump_terms", "incorrect arguments");
-  }else if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||
-            sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){
-    generateError(pContext, "dump_terms", "illegal first argument");
-  }else{
-    fulltext_vtab *v;
-    fts3Hash terms;
-    sqlite3_stmt *s = NULL;
-    int rc;
-
-    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));
-    v = cursor_vtab(pCursor);
-
-    /* If passed only the cursor column, get all segments.  Otherwise
-    ** get the segment described by the following two arguments.
-    */
-    if( argc==1 ){
-      rc = sql_get_statement(v, SEGDIR_SELECT_ALL_STMT, &s);
-    }else{
-      rc = sql_get_statement(v, SEGDIR_SELECT_SEGMENT_STMT, &s);
-      if( rc==SQLITE_OK ){
-        rc = sqlite3_bind_int(s, 1, sqlite3_value_int(argv[1]));
-        if( rc==SQLITE_OK ){
-          rc = sqlite3_bind_int(s, 2, sqlite3_value_int(argv[2]));
-        }
-      }
-    }
-
-    if( rc!=SQLITE_OK ){
-      generateError(pContext, "dump_terms", NULL);
-      return;
-    }
+  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */
 
-    /* Collect the terms for each segment. */
-    sqlite3Fts3HashInit(&terms, FTS3_HASH_STRING, 1);
-    while( (rc = sqlite3_step(s))==SQLITE_ROW ){
-      rc = collectSegmentTerms(v, s, &terms);
-      if( rc!=SQLITE_OK ) break;
-    }
+  UNUSED_PARAMETER(nVal);
 
-    if( rc!=SQLITE_DONE ){
-      sqlite3_reset(s);
-      generateError(pContext, "dump_terms", NULL);
-    }else{
-      const int nTerms = fts3HashCount(&terms);
-      if( nTerms>0 ){
-        rc = generateTermsResult(pContext, &terms);
-        if( rc==SQLITE_NOMEM ){
-          generateError(pContext, "dump_terms", "out of memory");
-        }else{
-          assert( rc==SQLITE_OK );
-        }
-      }else if( argc==3 ){
-        /* The specific segment asked for could not be found. */
-        generateError(pContext, "dump_terms", "segment not found");
-      }else{
-        /* No segments found. */
-        /* TODO(shess): It should be impossible to reach this.  This
-        ** case can only happen for an empty table, in which case
-        ** SQLite has no rows to call this function on.
-        */
-        sqlite3_result_null(pContext);
-      }
-    }
-    sqlite3Fts3HashClear(&terms);
+  assert( nVal==1 );
+  if( fts3FunctionArg(pContext, "offsets", apVal[0], &pCsr) ) return;
+  assert( pCsr );
+  if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
+    sqlite3Fts3Offsets(pContext, pCsr);
   }
 }
 
-/* Expand the DL_DEFAULT doclist in pData into a text result in
-** pContext.
+/* 
+** Implementation of the special optimize() function for FTS3. This 
+** function merges all segments in the database to a single segment.
+** Example usage is:
+**
+**   SELECT optimize(t) FROM t LIMIT 1;
+**
+** where 't' is the name of an FTS3 table.
 */
-static void createDoclistResult(sqlite3_context *pContext,
-                                const char *pData, int nData){
-  DataBuffer dump;
-  DLReader dlReader;
+static void fts3OptimizeFunc(
+  sqlite3_context *pContext,      /* SQLite function call context */
+  int nVal,                       /* Size of argument array */
+  sqlite3_value **apVal           /* Array of arguments */
+){
+  int rc;                         /* Return code */
+  Fts3Table *p;                   /* Virtual table handle */
+  Fts3Cursor *pCursor;            /* Cursor handle passed through apVal[0] */
 
-  assert( pData!=NULL && nData>0 );
+  UNUSED_PARAMETER(nVal);
 
-  dataBufferInit(&dump, 0);
-  dlrInit(&dlReader, DL_DEFAULT, pData, nData);
-  for( ; !dlrAtEnd(&dlReader); dlrStep(&dlReader) ){
-    char buf[256];
-    PLReader plReader;
+  assert( nVal==1 );
+  if( fts3FunctionArg(pContext, "optimize", apVal[0], &pCursor) ) return;
+  p = (Fts3Table *)pCursor->base.pVtab;
+  assert( p );
 
-    plrInit(&plReader, &dlReader);
-    if( DL_DEFAULT==DL_DOCIDS || plrAtEnd(&plReader) ){
-      sqlite3_snprintf(sizeof(buf), buf, "[%lld] ", dlrDocid(&dlReader));
-      dataBufferAppend(&dump, buf, strlen(buf));
-    }else{
-      int iColumn = plrColumn(&plReader);
-
-      sqlite3_snprintf(sizeof(buf), buf, "[%lld %d[",
-                       dlrDocid(&dlReader), iColumn);
-      dataBufferAppend(&dump, buf, strlen(buf));
-
-      for( ; !plrAtEnd(&plReader); plrStep(&plReader) ){
-        if( plrColumn(&plReader)!=iColumn ){
-          iColumn = plrColumn(&plReader);
-          sqlite3_snprintf(sizeof(buf), buf, "] %d[", iColumn);
-          assert( dump.nData>0 );
-          dump.nData--;                     /* Overwrite trailing space. */
-          assert( dump.pData[dump.nData]==' ');
-          dataBufferAppend(&dump, buf, strlen(buf));
-        }
-        if( DL_DEFAULT==DL_POSITIONS_OFFSETS ){
-          sqlite3_snprintf(sizeof(buf), buf, "%d,%d,%d ",
-                           plrPosition(&plReader),
-                           plrStartOffset(&plReader), plrEndOffset(&plReader));
-        }else if( DL_DEFAULT==DL_POSITIONS ){
-          sqlite3_snprintf(sizeof(buf), buf, "%d ", plrPosition(&plReader));
-        }else{
-          assert( NULL=="Unhandled DL_DEFAULT value");
-        }
-        dataBufferAppend(&dump, buf, strlen(buf));
-      }
-      plrDestroy(&plReader);
+  rc = sqlite3Fts3Optimize(p);
 
-      assert( dump.nData>0 );
-      dump.nData--;                     /* Overwrite trailing space. */
-      assert( dump.pData[dump.nData]==' ');
-      dataBufferAppend(&dump, "]] ", 3);
-    }
+  switch( rc ){
+    case SQLITE_OK:
+      sqlite3_result_text(pContext, "Index optimized", -1, SQLITE_STATIC);
+      break;
+    case SQLITE_DONE:
+      sqlite3_result_text(pContext, "Index already optimal", -1, SQLITE_STATIC);
+      break;
+    default:
+      sqlite3_result_error_code(pContext, rc);
+      break;
   }
-  dlrDestroy(&dlReader);
-
-  assert( dump.nData>0 );
-  dump.nData--;                     /* Overwrite trailing space. */
-  assert( dump.pData[dump.nData]==' ');
-  dump.pData[dump.nData] = '\0';
-  assert( dump.nData>0 );
-
-  /* Passes ownership of dump's buffer to pContext. */
-  sqlite3_result_text(pContext, dump.pData, dump.nData, sqlite3_free);
-  dump.pData = NULL;
-  dump.nData = dump.nCapacity = 0;
 }
 
-/* Implements dump_doclist() for use in inspecting the fts3 index from
-** tests.  TEXT result containing a string representation of the
-** doclist for the indicated term.  dump_doclist(t, term, level, idx)
-** dumps the doclist for term from the segment specified by level, idx
-** (in %_segdir), while dump_doclist(t, term) dumps the logical
-** doclist for the term across all segments.  The per-segment doclist
-** can contain deletions, while the full-index doclist will not
-** (deletions are omitted).
-**
-** Result formats differ with the setting of DL_DEFAULTS.  Examples:
-**
-** DL_DOCIDS: [1] [3] [7]
-** DL_POSITIONS: [1 0[0 4] 1[17]] [3 1[5]]
-** DL_POSITIONS_OFFSETS: [1 0[0,0,3 4,23,26] 1[17,102,105]] [3 1[5,20,23]]
-**
-** In each case the number after the outer '[' is the docid.  In the
-** latter two cases, the number before the inner '[' is the column
-** associated with the values within.  For DL_POSITIONS the numbers
-** within are the positions, for DL_POSITIONS_OFFSETS they are the
-** position, the start offset, and the end offset.
+/*
+** Implementation of the matchinfo() function for FTS3
 */
-static void dumpDoclistFunc(
-  sqlite3_context *pContext,
-  int argc, sqlite3_value **argv
+static void fts3MatchinfoFunc(
+  sqlite3_context *pContext,      /* SQLite function call context */
+  int nVal,                       /* Size of argument array */
+  sqlite3_value **apVal           /* Array of arguments */
 ){
-  fulltext_cursor *pCursor;
-  if( argc!=2 && argc!=4 ){
-    generateError(pContext, "dump_doclist", "incorrect arguments");
-  }else if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||
-            sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){
-    generateError(pContext, "dump_doclist", "illegal first argument");
-  }else if( sqlite3_value_text(argv[1])==NULL ||
-            sqlite3_value_text(argv[1])[0]=='\0' ){
-    generateError(pContext, "dump_doclist", "empty second argument");
-  }else{
-    const char *pTerm = (const char *)sqlite3_value_text(argv[1]);
-    const int nTerm = strlen(pTerm);
-    fulltext_vtab *v;
-    int rc;
-    DataBuffer doclist;
-
-    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));
-    v = cursor_vtab(pCursor);
-
-    dataBufferInit(&doclist, 0);
-
-    /* termSelect() yields the same logical doclist that queries are
-    ** run against.
-    */
-    if( argc==2 ){
-      rc = termSelect(v, v->nColumn, pTerm, nTerm, 0, DL_DEFAULT, &doclist);
-    }else{
-      sqlite3_stmt *s = NULL;
-
-      /* Get our specific segment's information. */
-      rc = sql_get_statement(v, SEGDIR_SELECT_SEGMENT_STMT, &s);
-      if( rc==SQLITE_OK ){
-        rc = sqlite3_bind_int(s, 1, sqlite3_value_int(argv[2]));
-        if( rc==SQLITE_OK ){
-          rc = sqlite3_bind_int(s, 2, sqlite3_value_int(argv[3]));
-        }
-      }
-
-      if( rc==SQLITE_OK ){
-        rc = sqlite3_step(s);
-
-        if( rc==SQLITE_DONE ){
-          dataBufferDestroy(&doclist);
-          generateError(pContext, "dump_doclist", "segment not found");
-          return;
-        }
-
-        /* Found a segment, load it into doclist. */
-        if( rc==SQLITE_ROW ){
-          const sqlite_int64 iLeavesEnd = sqlite3_column_int64(s, 1);
-          const char *pData = sqlite3_column_blob(s, 2);
-          const int nData = sqlite3_column_bytes(s, 2);
-
-          /* loadSegment() is used by termSelect() to load each
-          ** segment's data.
-          */
-          rc = loadSegment(v, pData, nData, iLeavesEnd, pTerm, nTerm, 0,
-                           &doclist);
-          if( rc==SQLITE_OK ){
-            rc = sqlite3_step(s);
-
-            /* Should not have more than one matching segment. */
-            if( rc!=SQLITE_DONE ){
-              sqlite3_reset(s);
-              dataBufferDestroy(&doclist);
-              generateError(pContext, "dump_doclist", "invalid segdir");
-              return;
-            }
-            rc = SQLITE_OK;
-          }
-        }
-      }
+  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */
 
-      sqlite3_reset(s);
-    }
-
-    if( rc==SQLITE_OK ){
-      if( doclist.nData>0 ){
-        createDoclistResult(pContext, doclist.pData, doclist.nData);
-      }else{
-        /* TODO(shess): This can happen if the term is not present, or
-        ** if all instances of the term have been deleted and this is
-        ** an all-index dump.  It may be interesting to distinguish
-        ** these cases.
-        */
-        sqlite3_result_text(pContext, "", 0, SQLITE_STATIC);
-      }
-    }else if( rc==SQLITE_NOMEM ){
-      /* Handle out-of-memory cases specially because if they are
-      ** generated in fts3 code they may not be reflected in the db
-      ** handle.
-      */
-      /* TODO(shess): Handle this more comprehensively.
-      ** sqlite3ErrStr() has what I need, but is internal.
-      */
-      generateError(pContext, "dump_doclist", "out of memory");
-    }else{
-      generateError(pContext, "dump_doclist", NULL);
-    }
+  if( nVal!=1 ){
+    sqlite3_result_error(pContext,
+        "wrong number of arguments to function matchinfo()", -1);
+    return;
+  }
 
-    dataBufferDestroy(&doclist);
+  if( SQLITE_OK==fts3FunctionArg(pContext, "matchinfo", apVal[0], &pCsr) ){
+    sqlite3Fts3Matchinfo(pContext, pCsr);
   }
 }
-#endif
 
 /*
 ** This routine implements the xFindFunction method for the FTS3
 ** virtual table.
 */
-static int fulltextFindFunction(
-  sqlite3_vtab *pVtab,
-  int nArg,
-  const char *zName,
-  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
-  void **ppArg
+static int fts3FindFunctionMethod(
+  sqlite3_vtab *pVtab,            /* Virtual table handle */
+  int nArg,                       /* Number of SQL function arguments */
+  const char *zName,              /* Name of SQL function */
+  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */
+  void **ppArg                    /* Unused */
 ){
-  if( strcmp(zName,"snippet")==0 ){
-    *pxFunc = snippetFunc;
-    return 1;
-  }else if( strcmp(zName,"offsets")==0 ){
-    *pxFunc = snippetOffsetsFunc;
-    return 1;
-  }else if( strcmp(zName,"optimize")==0 ){
-    *pxFunc = optimizeFunc;
-    return 1;
-#ifdef SQLITE_TEST
-    /* NOTE(shess): These functions are present only for testing
-    ** purposes.  No particular effort is made to optimize their
-    ** execution or how they build their results.
-    */
-  }else if( strcmp(zName,"dump_terms")==0 ){
-    /* fprintf(stderr, "Found dump_terms\n"); */
-    *pxFunc = dumpTermsFunc;
-    return 1;
-  }else if( strcmp(zName,"dump_doclist")==0 ){
-    /* fprintf(stderr, "Found dump_doclist\n"); */
-    *pxFunc = dumpDoclistFunc;
-    return 1;
-#endif
+  struct Overloaded {
+    const char *zName;
+    void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
+  } aOverload[] = {
+    { "snippet", fts3SnippetFunc },
+    { "snippet2", fts3Snippet2Func },
+    { "offsets", fts3OffsetsFunc },
+    { "optimize", fts3OptimizeFunc },
+    { "matchinfo", fts3MatchinfoFunc },
+  };
+  int i;                          /* Iterator variable */
+
+  UNUSED_PARAMETER(pVtab);
+  UNUSED_PARAMETER(nArg);
+  UNUSED_PARAMETER(ppArg);
+
+  for(i=0; i<SizeofArray(aOverload); i++){
+    if( strcmp(zName, aOverload[i].zName)==0 ){
+      *pxFunc = aOverload[i].xFunc;
+      return 1;
+    }
   }
+
+  /* No function of the specified name was found. Return 0. */
   return 0;
 }
 
 /*
-** Rename an fts3 table.
+** Implementation of FTS3 xRename method. Rename an fts3 table.
 */
-static int fulltextRename(
-  sqlite3_vtab *pVtab,
-  const char *zName
+static int fts3RenameMethod(
+  sqlite3_vtab *pVtab,            /* Virtual table handle */
+  const char *zName               /* New name of table */
 ){
-  fulltext_vtab *p = (fulltext_vtab *)pVtab;
-  int rc = SQLITE_NOMEM;
-  char *zSql = sqlite3_mprintf(
+  Fts3Table *p = (Fts3Table *)pVtab;     
+  int rc = SQLITE_NOMEM;          /* Return Code */
+  char *zSql;                     /* SQL script to run to rename tables */
+ 
+  zSql = sqlite3_mprintf(
     "ALTER TABLE %Q.'%q_content'  RENAME TO '%q_content';"
     "ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';"
     "ALTER TABLE %Q.'%q_segdir'   RENAME TO '%q_segdir';"
@@ -104358,29 +100769,34 @@ static int fulltextRename(
 
 static const sqlite3_module fts3Module = {
   /* iVersion      */ 0,
-  /* xCreate       */ fulltextCreate,
-  /* xConnect      */ fulltextConnect,
-  /* xBestIndex    */ fulltextBestIndex,
-  /* xDisconnect   */ fulltextDisconnect,
-  /* xDestroy      */ fulltextDestroy,
-  /* xOpen         */ fulltextOpen,
+  /* xCreate       */ fts3CreateMethod,
+  /* xConnect      */ fts3ConnectMethod,
+  /* xBestIndex    */ fts3BestIndexMethod,
+  /* xDisconnect   */ fts3DisconnectMethod,
+  /* xDestroy      */ fts3DestroyMethod,
+  /* xOpen         */ fts3OpenMethod,
   /* xClose        */ fulltextClose,
-  /* xFilter       */ fulltextFilter,
-  /* xNext         */ fulltextNext,
-  /* xEof          */ fulltextEof,
-  /* xColumn       */ fulltextColumn,
-  /* xRowid        */ fulltextRowid,
-  /* xUpdate       */ fulltextUpdate,
-  /* xBegin        */ fulltextBegin,
-  /* xSync         */ fulltextSync,
-  /* xCommit       */ fulltextCommit,
-  /* xRollback     */ fulltextRollback,
-  /* xFindFunction */ fulltextFindFunction,
-  /* xRename */       fulltextRename,
+  /* xFilter       */ fts3FilterMethod,
+  /* xNext         */ fts3NextMethod,
+  /* xEof          */ fts3EofMethod,
+  /* xColumn       */ fts3ColumnMethod,
+  /* xRowid        */ fts3RowidMethod,
+  /* xUpdate       */ fts3UpdateMethod,
+  /* xBegin        */ fts3BeginMethod,
+  /* xSync         */ fts3SyncMethod,
+  /* xCommit       */ fts3CommitMethod,
+  /* xRollback     */ fts3RollbackMethod,
+  /* xFindFunction */ fts3FindFunctionMethod,
+  /* xRename */       fts3RenameMethod,
 };
 
+/*
+** This function is registered as the module destructor (called when an
+** FTS3 enabled database connection is closed). It frees the memory
+** allocated for the tokenizer hash table.
+*/
 static void hashDestroy(void *p){
-  fts3Hash *pHash = (fts3Hash *)p;
+  Fts3Hash *pHash = (Fts3Hash *)p;
   sqlite3Fts3HashClear(pHash);
   sqlite3_free(pHash);
 }
@@ -104400,8 +100816,6 @@ SQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module co
 SQLITE_PRIVATE void sqlite3Fts3PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule);
 SQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule);
 
-SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, fts3Hash *, const char *);
-
 /*
 ** Initialise the fts3 extension. If this extension is built as part
 ** of the sqlite library, then this function is called directly by
@@ -104410,19 +100824,20 @@ SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, fts3Hash *, const char *)
 */
 SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
   int rc = SQLITE_OK;
-  fts3Hash *pHash = 0;
+  Fts3Hash *pHash = 0;
   const sqlite3_tokenizer_module *pSimple = 0;
   const sqlite3_tokenizer_module *pPorter = 0;
-  const sqlite3_tokenizer_module *pIcu = 0;
 
-  sqlite3Fts3SimpleTokenizerModule(&pSimple);
-  sqlite3Fts3PorterTokenizerModule(&pPorter);
 #ifdef SQLITE_ENABLE_ICU
+  const sqlite3_tokenizer_module *pIcu = 0;
   sqlite3Fts3IcuTokenizerModule(&pIcu);
 #endif
 
+  sqlite3Fts3SimpleTokenizerModule(&pSimple);
+  sqlite3Fts3PorterTokenizerModule(&pPorter);
+
   /* Allocate and initialise the hash-table used to store tokenizers. */
-  pHash = sqlite3_malloc(sizeof(fts3Hash));
+  pHash = sqlite3_malloc(sizeof(Fts3Hash));
   if( !pHash ){
     rc = SQLITE_NOMEM;
   }else{
@@ -104433,14 +100848,18 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
   if( rc==SQLITE_OK ){
     if( sqlite3Fts3HashInsert(pHash, "simple", 7, (void *)pSimple)
      || sqlite3Fts3HashInsert(pHash, "porter", 7, (void *)pPorter) 
+#ifdef SQLITE_ENABLE_ICU
      || (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu))
+#endif
     ){
       rc = SQLITE_NOMEM;
     }
   }
 
 #ifdef SQLITE_TEST
-  sqlite3Fts3ExprInitTestInterface(db);
+  if( rc==SQLITE_OK ){
+    rc = sqlite3Fts3ExprInitTestInterface(db);
+  }
 #endif
 
   /* Create the virtual table wrapper around the hash-table and overload 
@@ -104450,12 +100869,10 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
   if( SQLITE_OK==rc 
    && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
    && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
-   && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", -1))
-   && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", -1))
-#ifdef SQLITE_TEST
-   && SQLITE_OK==(rc = sqlite3_overload_function(db, "dump_terms", -1))
-   && SQLITE_OK==(rc = sqlite3_overload_function(db, "dump_doclist", -1))
-#endif
+   && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet2", -1))
+   && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
+   && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", -1))
+   && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
   ){
     return sqlite3_create_module_v2(
         db, "fts3", &fts3Module, (void *)pHash, hashDestroy
@@ -104482,7 +100899,7 @@ SQLITE_API int sqlite3_extension_init(
 }
 #endif
 
-#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */
+#endif
 
 /************** End of fts3.c ************************************************/
 /************** Begin file fts3_expr.c ***************************************/
@@ -104501,8 +100918,7 @@ SQLITE_API int sqlite3_extension_init(
 ** This module contains code that implements a parser for fts3 query strings
 ** (the right-hand argument to the MATCH operator). Because the supported 
 ** syntax is relatively simple, the whole tokenizer/parser system is
-** hand-coded. The public interface to this module is declared in source
-** code file "fts3_expr.h".
+** hand-coded. 
 */
 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
 
@@ -104528,7 +100944,29 @@ SQLITE_API int sqlite3_extension_init(
 ** to zero causes the module to use the old syntax. If it is set to 
 ** non-zero the new syntax is activated. This is so both syntaxes can
 ** be tested using a single build of testfixture.
+**
+** The following describes the syntax supported by the fts3 MATCH
+** operator in a similar format to that used by the lemon parser
+** generator. This module does not use actually lemon, it uses a
+** custom parser.
+**
+**   query ::= andexpr (OR andexpr)*.
+**
+**   andexpr ::= notexpr (AND? notexpr)*.
+**
+**   notexpr ::= nearexpr (NOT nearexpr|-TOKEN)*.
+**   notexpr ::= LP query RP.
+**
+**   nearexpr ::= phrase (NEAR distance_opt nearexpr)*.
+**
+**   distance_opt ::= .
+**   distance_opt ::= / INTEGER.
+**
+**   phrase ::= TOKEN.
+**   phrase ::= COLUMN:TOKEN.
+**   phrase ::= "TOKEN TOKEN TOKEN...".
 */
+
 #ifdef SQLITE_TEST
 SQLITE_API int sqlite3_fts3_enable_parentheses = 0;
 #else
@@ -104644,7 +101082,7 @@ static int getNextToken(
 ** Enlarge a memory allocation.  If an out-of-memory allocation occurs,
 ** then free the old allocation.
 */
-void *fts3ReallocOrFree(void *pOrig, int nNew){
+static void *fts3ReallocOrFree(void *pOrig, int nNew){
   void *pRet = sqlite3_realloc(pOrig, nNew);
   if( !pRet ){
     sqlite3_free(pOrig);
@@ -104715,7 +101153,7 @@ static int getNextString(
 
   if( rc==SQLITE_DONE ){
     int jj;
-    char *zNew;
+    char *zNew = NULL;
     int nNew = 0;
     int nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase);
     nByte += (p?(p->pPhrase->nToken-1):0) * sizeof(struct PhraseToken);
@@ -104774,7 +101212,7 @@ static int getNextNode(
   int *pnConsumed                         /* OUT: Number of bytes consumed */
 ){
   static const struct Fts3Keyword {
-    char z[4];                            /* Keyword text */
+    char *z;                              /* Keyword text */
     unsigned char n;                      /* Length of the keyword */
     unsigned char parenOnly;              /* Only valid in paren mode */
     unsigned char eType;                  /* Keyword code */
@@ -104837,11 +101275,14 @@ static int getNextNode(
        || cNext=='"' || cNext=='(' || cNext==')' || cNext==0
       ){
         pRet = (Fts3Expr *)sqlite3_malloc(sizeof(Fts3Expr));
+        if( !pRet ){
+          return SQLITE_NOMEM;
+        }
         memset(pRet, 0, sizeof(Fts3Expr));
         pRet->eType = pKey->eType;
         pRet->nNear = nNear;
         *ppExpr = pRet;
-        *pnConsumed = (zInput - z) + nKey;
+        *pnConsumed = (int)((zInput - z) + nKey);
         return SQLITE_OK;
       }
 
@@ -104861,14 +101302,14 @@ static int getNextNode(
       if( rc==SQLITE_OK && !*ppExpr ){
         rc = SQLITE_DONE;
       }
-      *pnConsumed = (zInput - z) + 1 + nConsumed;
+      *pnConsumed = (int)((zInput - z) + 1 + nConsumed);
       return rc;
     }
   
     /* Check for a close bracket. */
     if( *zInput==')' ){
       pParse->nNest--;
-      *pnConsumed = (zInput - z) + 1;
+      *pnConsumed = (int)((zInput - z) + 1);
       return SQLITE_DONE;
     }
   }
@@ -104880,7 +101321,7 @@ static int getNextNode(
   */
   if( *zInput=='"' ){
     for(ii=1; ii<nInput && zInput[ii]!='"'; ii++);
-    *pnConsumed = (zInput - z) + ii + 1;
+    *pnConsumed = (int)((zInput - z) + ii + 1);
     if( ii==nInput ){
       return SQLITE_ERROR;
     }
@@ -104903,12 +101344,12 @@ static int getNextNode(
   iColLen = 0;
   for(ii=0; ii<pParse->nCol; ii++){
     const char *zStr = pParse->azCol[ii];
-    int nStr = strlen(zStr);
+    int nStr = (int)strlen(zStr);
     if( nInput>nStr && zInput[nStr]==':' 
      && sqlite3_strnicmp(zStr, zInput, nStr)==0 
     ){
       iCol = ii;
-      iColLen = ((zInput - z) + nStr + 1);
+      iColLen = (int)((zInput - z) + nStr + 1);
       break;
     }
   }
@@ -105174,7 +101615,7 @@ SQLITE_PRIVATE int sqlite3Fts3ExprParse(
     return SQLITE_OK;
   }
   if( n<0 ){
-    n = strlen(z);
+    n = (int)strlen(z);
   }
   rc = fts3ExprParse(&sParse, z, n, ppExpr, &nParsed);
 
@@ -105195,6 +101636,7 @@ SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *p){
   if( p ){
     sqlite3Fts3ExprFree(p->pLeft);
     sqlite3Fts3ExprFree(p->pRight);
+    sqlite3_free(p->aDoclist);
     sqlite3_free(p);
   }
 }
@@ -105228,7 +101670,7 @@ static int queryTestTokenizer(
   sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);
   if( SQLITE_ROW==sqlite3_step(pStmt) ){
     if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){
-      memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));
+      memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));
     }
   }
 
@@ -105372,8 +101814,8 @@ exprtest_out:
 ** Register the query expression parser test function fts3_exprtest() 
 ** with database connection db. 
 */
-SQLITE_PRIVATE void sqlite3Fts3ExprInitTestInterface(sqlite3* db){
-  sqlite3_create_function(
+SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3* db){
+  return sqlite3_create_function(
       db, "fts3_exprtest", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0
   );
 }
@@ -105436,7 +101878,7 @@ static void fts3HashFree(void *p){
 ** true if the hash table should make its own private copy of keys and
 ** false if it should just use the supplied pointer.
 */
-SQLITE_PRIVATE void sqlite3Fts3HashInit(fts3Hash *pNew, int keyClass, int copyKey){
+SQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey){
   assert( pNew!=0 );
   assert( keyClass>=FTS3_HASH_STRING && keyClass<=FTS3_HASH_BINARY );
   pNew->keyClass = keyClass;
@@ -105451,8 +101893,8 @@ SQLITE_PRIVATE void sqlite3Fts3HashInit(fts3Hash *pNew, int keyClass, int copyKe
 ** Call this routine to delete a hash table or to reset a hash table
 ** to the empty state.
 */
-SQLITE_PRIVATE void sqlite3Fts3HashClear(fts3Hash *pH){
-  fts3HashElem *elem;         /* For looping over all elements of the table */
+SQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash *pH){
+  Fts3HashElem *elem;         /* For looping over all elements of the table */
 
   assert( pH!=0 );
   elem = pH->first;
@@ -105461,7 +101903,7 @@ SQLITE_PRIVATE void sqlite3Fts3HashClear(fts3Hash *pH){
   pH->ht = 0;
   pH->htsize = 0;
   while( elem ){
-    fts3HashElem *next_elem = elem->next;
+    Fts3HashElem *next_elem = elem->next;
     if( pH->copyKey && elem->pKey ){
       fts3HashFree(elem->pKey);
     }
@@ -105544,11 +101986,11 @@ static int (*ftsCompareFunction(int keyClass))(const void*,int,const void*,int){
 /* Link an element into the hash table
 */
 static void fts3HashInsertElement(
-  fts3Hash *pH,            /* The complete hash table */
+  Fts3Hash *pH,            /* The complete hash table */
   struct _fts3ht *pEntry,  /* The entry into which pNew is inserted */
-  fts3HashElem *pNew       /* The element to be inserted */
+  Fts3HashElem *pNew       /* The element to be inserted */
 ){
-  fts3HashElem *pHead;     /* First element already in pEntry */
+  Fts3HashElem *pHead;     /* First element already in pEntry */
   pHead = pEntry->chain;
   if( pHead ){
     pNew->next = pHead;
@@ -105570,15 +102012,17 @@ static void fts3HashInsertElement(
 /* Resize the hash table so that it cantains "new_size" buckets.
 ** "new_size" must be a power of 2.  The hash table might fail 
 ** to resize if sqliteMalloc() fails.
+**
+** Return non-zero if a memory allocation error occurs.
 */
-static void fts3Rehash(fts3Hash *pH, int new_size){
+static int fts3Rehash(Fts3Hash *pH, int new_size){
   struct _fts3ht *new_ht;          /* The new hash table */
-  fts3HashElem *elem, *next_elem;  /* For looping over existing elements */
+  Fts3HashElem *elem, *next_elem;  /* For looping over existing elements */
   int (*xHash)(const void*,int);   /* The hash function */
 
   assert( (new_size & (new_size-1))==0 );
   new_ht = (struct _fts3ht *)fts3HashMalloc( new_size*sizeof(struct _fts3ht) );
-  if( new_ht==0 ) return;
+  if( new_ht==0 ) return 1;
   fts3HashFree(pH->ht);
   pH->ht = new_ht;
   pH->htsize = new_size;
@@ -105588,19 +102032,20 @@ static void fts3Rehash(fts3Hash *pH, int new_size){
     next_elem = elem->next;
     fts3HashInsertElement(pH, &new_ht[h], elem);
   }
+  return 0;
 }
 
 /* This function (for internal use only) locates an element in an
 ** hash table that matches the given key.  The hash for this key has
 ** already been computed and is passed as the 4th parameter.
 */
-static fts3HashElem *fts3FindElementByHash(
-  const fts3Hash *pH, /* The pH to be searched */
+static Fts3HashElem *fts3FindElementByHash(
+  const Fts3Hash *pH, /* The pH to be searched */
   const void *pKey,   /* The key we are searching for */
   int nKey,
   int h               /* The hash for this key. */
 ){
-  fts3HashElem *elem;            /* Used to loop thru the element list */
+  Fts3HashElem *elem;            /* Used to loop thru the element list */
   int count;                     /* Number of elements left to test */
   int (*xCompare)(const void*,int,const void*,int);  /* comparison function */
 
@@ -105623,8 +102068,8 @@ static fts3HashElem *fts3FindElementByHash(
 ** element and a hash on the element's key.
 */
 static void fts3RemoveElementByHash(
-  fts3Hash *pH,         /* The pH containing "elem" */
-  fts3HashElem* elem,   /* The element to be removed from the pH */
+  Fts3Hash *pH,         /* The pH containing "elem" */
+  Fts3HashElem* elem,   /* The element to be removed from the pH */
   int h                 /* Hash value for the element */
 ){
   struct _fts3ht *pEntry;
@@ -105656,13 +102101,12 @@ static void fts3RemoveElementByHash(
   }
 }
 
-/* Attempt to locate an element of the hash table pH with a key
-** that matches pKey,nKey.  Return the data for this element if it is
-** found, or NULL if there is no match.
-*/
-SQLITE_PRIVATE void *sqlite3Fts3HashFind(const fts3Hash *pH, const void *pKey, int nKey){
-  int h;                 /* A hash on key */
-  fts3HashElem *elem;    /* The element that matches key */
+SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(
+  const Fts3Hash *pH, 
+  const void *pKey, 
+  int nKey
+){
+  int h;                          /* A hash on key */
   int (*xHash)(const void*,int);  /* The hash function */
 
   if( pH==0 || pH->ht==0 ) return 0;
@@ -105670,8 +102114,19 @@ SQLITE_PRIVATE void *sqlite3Fts3HashFind(const fts3Hash *pH, const void *pKey, i
   assert( xHash!=0 );
   h = (*xHash)(pKey,nKey);
   assert( (pH->htsize & (pH->htsize-1))==0 );
-  elem = fts3FindElementByHash(pH,pKey,nKey, h & (pH->htsize-1));
-  return elem ? elem->data : 0;
+  return fts3FindElementByHash(pH,pKey,nKey, h & (pH->htsize-1));
+}
+
+/* 
+** Attempt to locate an element of the hash table pH with a key
+** that matches pKey,nKey.  Return the data for this element if it is
+** found, or NULL if there is no match.
+*/
+SQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash *pH, const void *pKey, int nKey){
+  Fts3HashElem *pElem;            /* The element that matches key (if any) */
+
+  pElem = sqlite3Fts3HashFindElem(pH, pKey, nKey);
+  return pElem ? pElem->data : 0;
 }
 
 /* Insert an element into the hash table pH.  The key is pKey,nKey
@@ -105690,15 +102145,15 @@ SQLITE_PRIVATE void *sqlite3Fts3HashFind(const fts3Hash *pH, const void *pKey, i
 ** element corresponding to "key" is removed from the hash table.
 */
 SQLITE_PRIVATE void *sqlite3Fts3HashInsert(
-  fts3Hash *pH,        /* The hash table to insert into */
+  Fts3Hash *pH,        /* The hash table to insert into */
   const void *pKey,    /* The key */
   int nKey,            /* Number of bytes in the key */
   void *data           /* The data */
 ){
   int hraw;                 /* Raw hash value of the key */
   int h;                    /* the hash of the key modulo hash table size */
-  fts3HashElem *elem;       /* Used to loop thru the element list */
-  fts3HashElem *new_elem;   /* New element added to the pH */
+  Fts3HashElem *elem;       /* Used to loop thru the element list */
+  Fts3HashElem *new_elem;   /* New element added to the pH */
   int (*xHash)(const void*,int);  /* The hash function */
 
   assert( pH!=0 );
@@ -105718,14 +102173,14 @@ SQLITE_PRIVATE void *sqlite3Fts3HashInsert(
     return old_data;
   }
   if( data==0 ) return 0;
-  if( pH->htsize==0 ){
-    fts3Rehash(pH,8);
-    if( pH->htsize==0 ){
-      pH->count = 0;
-      return data;
-    }
+  if( (pH->htsize==0 && fts3Rehash(pH,8))
+   || (pH->count>=pH->htsize && fts3Rehash(pH, pH->htsize*2))
+  ){
+    pH->count = 0;
+    return data;
   }
-  new_elem = (fts3HashElem*)fts3HashMalloc( sizeof(fts3HashElem) );
+  assert( pH->htsize>0 );
+  new_elem = (Fts3HashElem*)fts3HashMalloc( sizeof(Fts3HashElem) );
   if( new_elem==0 ) return data;
   if( pH->copyKey && pKey!=0 ){
     new_elem->pKey = fts3HashMalloc( nKey );
@@ -105739,9 +102194,6 @@ SQLITE_PRIVATE void *sqlite3Fts3HashInsert(
   }
   new_elem->nKey = nKey;
   pH->count++;
-  if( pH->count > pH->htsize ){
-    fts3Rehash(pH,pH->htsize*2);
-  }
   assert( pH->htsize>0 );
   assert( (pH->htsize & (pH->htsize-1))==0 );
   h = hraw & (pH->htsize-1);
@@ -105804,10 +102256,6 @@ typedef struct porter_tokenizer_cursor {
 } porter_tokenizer_cursor;
 
 
-/* Forward declaration */
-static const sqlite3_tokenizer_module porterTokenizerModule;
-
-
 /*
 ** Create a new tokenizer instance.
 */
@@ -105816,6 +102264,10 @@ static int porterCreate(
   sqlite3_tokenizer **ppTokenizer
 ){
   porter_tokenizer *t;
+
+  UNUSED_PARAMETER(argc);
+  UNUSED_PARAMETER(argv);
+
   t = (porter_tokenizer *) sqlite3_malloc(sizeof(*t));
   if( t==NULL ) return SQLITE_NOMEM;
   memset(t, 0, sizeof(*t));
@@ -105844,6 +102296,8 @@ static int porterOpen(
 ){
   porter_tokenizer_cursor *c;
 
+  UNUSED_PARAMETER(pTokenizer);
+
   c = (porter_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));
   if( c==NULL ) return SQLITE_NOMEM;
 
@@ -105984,7 +102438,7 @@ static int hasVowel(const char *z){
 ** the first two characters of z[].
 */
 static int doubleConsonant(const char *z){
-  return isConsonant(z) && z[0]==z[1] && isConsonant(z+1);
+  return isConsonant(z) && z[0]==z[1];
 }
 
 /*
@@ -105997,10 +102451,10 @@ static int doubleConsonant(const char *z){
 */
 static int star_oh(const char *z){
   return
-    z[0]!=0 && isConsonant(z) &&
+    isConsonant(z) &&
     z[0]!='w' && z[0]!='x' && z[0]!='y' &&
-    z[1]!=0 && isVowel(z+1) &&
-    z[2]!=0 && isConsonant(z+2);
+    isVowel(z+1) &&
+    isConsonant(z+2);
 }
 
 /*
@@ -106044,7 +102498,7 @@ static void copy_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){
   int i, mx, j;
   int hasDigit = 0;
   for(i=0; i<nIn; i++){
-    int c = zIn[i];
+    char c = zIn[i];
     if( c>='A' && c<='Z' ){
       zOut[i] = c - 'A' + 'a';
     }else{
@@ -106088,7 +102542,7 @@ static void copy_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){
 ** no chance of overflowing the zOut buffer.
 */
 static void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){
-  int i, j, c;
+  int i, j;
   char zReverse[28];
   char *z, *z2;
   if( nIn<3 || nIn>=sizeof(zReverse)-7 ){
@@ -106098,7 +102552,7 @@ static void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){
     return;
   }
   for(i=0, j=sizeof(zReverse)-6; i<nIn; i++, j--){
-    c = zIn[i];
+    char c = zIn[i];
     if( c>='A' && c<='Z' ){
       zReverse[j] = c + 'a' - 'A';
     }else if( c>='a' && c<='z' ){
@@ -106297,7 +102751,7 @@ static void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){
   /* z[] is now the stemmed word in reverse order.  Flip it back
   ** around into forward order and return.
   */
-  *pnOut = i = strlen(z);
+  *pnOut = i = (int)strlen(z);
   zOut[i] = 0;
   while( *z ){
     zOut[--i] = *(z++);
@@ -106450,14 +102904,14 @@ static void scalarFunc(
   int argc,
   sqlite3_value **argv
 ){
-  fts3Hash *pHash;
+  Fts3Hash *pHash;
   void *pPtr = 0;
   const unsigned char *zName;
   int nName;
 
   assert( argc==1 || argc==2 );
 
-  pHash = (fts3Hash *)sqlite3_user_data(context);
+  pHash = (Fts3Hash *)sqlite3_user_data(context);
 
   zName = sqlite3_value_text(argv[0]);
   nName = sqlite3_value_bytes(argv[0])+1;
@@ -106488,6 +102942,127 @@ static void scalarFunc(
   sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);
 }
 
+static int fts3IsIdChar(char c){
+  static const char isFtsIdChar[] = {
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 0x */
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 1x */
+      0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */
+      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */
+      0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */
+      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */
+      0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */
+      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */
+  };
+  return (c&0x80 || isFtsIdChar[(int)(c)]);
+}
+
+SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *zStr, int *pn){
+  const char *z1;
+  const char *z2 = 0;
+
+  /* Find the start of the next token. */
+  z1 = zStr;
+  while( z2==0 ){
+    char c = *z1;
+    switch( c ){
+      case '\0': return 0;        /* No more tokens here */
+      case '\'':
+      case '"':
+      case '`': {
+        z2 = z1;
+        while( *++z2 && (*z2!=c || *++z2==c) );
+        break;
+      }
+      case '[':
+        z2 = &z1[1];
+        while( *z2 && z2[0]!=']' ) z2++;
+        if( *z2 ) z2++;
+        break;
+
+      default:
+        if( fts3IsIdChar(*z1) ){
+          z2 = &z1[1];
+          while( fts3IsIdChar(*z2) ) z2++;
+        }else{
+          z1++;
+        }
+    }
+  }
+
+  *pn = (int)(z2-z1);
+  return z1;
+}
+
+SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(
+  Fts3Hash *pHash,                /* Tokenizer hash table */
+  const char *zArg,               /* Possible tokenizer specification */
+  sqlite3_tokenizer **ppTok,      /* OUT: Tokenizer (if applicable) */
+  const char **pzTokenizer,       /* OUT: Set to zArg if is tokenizer */
+  char **pzErr                    /* OUT: Set to malloced error message */
+){
+  int rc;
+  char *z = (char *)zArg;
+  int n;
+  char *zCopy;
+  char *zEnd;                     /* Pointer to nul-term of zCopy */
+  sqlite3_tokenizer_module *m;
+
+  if( !z ){
+    zCopy = sqlite3_mprintf("simple");
+  }else{
+    if( sqlite3_strnicmp(z, "tokenize", 8) || fts3IsIdChar(z[8])){
+      return SQLITE_OK;
+    }
+    zCopy = sqlite3_mprintf("%s", &z[8]);
+    *pzTokenizer = zArg;
+  }
+  if( !zCopy ){
+    return SQLITE_NOMEM;
+  }
+
+  zEnd = &zCopy[strlen(zCopy)];
+
+  z = (char *)sqlite3Fts3NextToken(zCopy, &n);
+  z[n] = '\0';
+  sqlite3Fts3Dequote(z);
+
+  m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, z, (int)strlen(z)+1);
+  if( !m ){
+    *pzErr = sqlite3_mprintf("unknown tokenizer: %s", z);
+    rc = SQLITE_ERROR;
+  }else{
+    char const **aArg = 0;
+    int iArg = 0;
+    z = &z[n+1];
+    while( z<zEnd && (NULL!=(z = (char *)sqlite3Fts3NextToken(z, &n))) ){
+      int nNew = sizeof(char *)*(iArg+1);
+      char const **aNew = (const char **)sqlite3_realloc((void *)aArg, nNew);
+      if( !aNew ){
+        sqlite3_free(zCopy);
+        sqlite3_free((void *)aArg);
+        return SQLITE_NOMEM;
+      }
+      aArg = aNew;
+      aArg[iArg++] = z;
+      z[n] = '\0';
+      sqlite3Fts3Dequote(z);
+      z = &z[n+1];
+    }
+    rc = m->xCreate(iArg, aArg, ppTok);
+    assert( rc!=SQLITE_OK || *ppTok );
+    if( rc!=SQLITE_OK ){
+      *pzErr = sqlite3_mprintf("unknown tokenizer");
+    }else{
+      (*ppTok)->pModule = m; 
+    }
+    sqlite3_free((void *)aArg);
+  }
+
+  sqlite3_free(zCopy);
+  return rc;
+}
+
+
 #ifdef SQLITE_TEST
 
 
@@ -106522,7 +103097,7 @@ static void testFunc(
   int argc,
   sqlite3_value **argv
 ){
-  fts3Hash *pHash;
+  Fts3Hash *pHash;
   sqlite3_tokenizer_module *p;
   sqlite3_tokenizer *pTokenizer = 0;
   sqlite3_tokenizer_cursor *pCsr = 0;
@@ -106555,7 +103130,7 @@ static void testFunc(
     zArg = (const char *)sqlite3_value_text(argv[1]);
   }
 
-  pHash = (fts3Hash *)sqlite3_user_data(context);
+  pHash = (Fts3Hash *)sqlite3_user_data(context);
   p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);
 
   if( !p ){
@@ -106646,7 +103221,7 @@ int queryTokenizer(
   sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);
   if( SQLITE_ROW==sqlite3_step(pStmt) ){
     if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){
-      memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));
+      memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));
     }
   }
 
@@ -106683,6 +103258,9 @@ static void intTestFunc(
   const sqlite3_tokenizer_module *p2;
   sqlite3 *db = (sqlite3 *)sqlite3_user_data(context);
 
+  UNUSED_PARAMETER(argc);
+  UNUSED_PARAMETER(argv);
+
   /* Test the query function */
   sqlite3Fts3SimpleTokenizerModule(&p1);
   rc = queryTokenizer(db, "simple", &p2);
@@ -106724,16 +103302,16 @@ static void intTestFunc(
 */
 SQLITE_PRIVATE int sqlite3Fts3InitHashTable(
   sqlite3 *db, 
-  fts3Hash *pHash, 
+  Fts3Hash *pHash, 
   const char *zName
 ){
   int rc = SQLITE_OK;
   void *p = (void *)pHash;
   const int any = SQLITE_ANY;
-  char *zTest = 0;
-  char *zTest2 = 0;
 
 #ifdef SQLITE_TEST
+  char *zTest = 0;
+  char *zTest2 = 0;
   void *pdb = (void *)db;
   zTest = sqlite3_mprintf("%s_test", zName);
   zTest2 = sqlite3_mprintf("%s_internal_test", zName);
@@ -106742,18 +103320,21 @@ SQLITE_PRIVATE int sqlite3Fts3InitHashTable(
   }
 #endif
 
-  if( rc!=SQLITE_OK
-   || (rc = sqlite3_create_function(db, zName, 1, any, p, scalarFunc, 0, 0))
-   || (rc = sqlite3_create_function(db, zName, 2, any, p, scalarFunc, 0, 0))
+  if( SQLITE_OK!=rc
+   || SQLITE_OK!=(rc = sqlite3_create_function(db, zName, 1, any, p, scalarFunc, 0, 0))
+   || SQLITE_OK!=(rc = sqlite3_create_function(db, zName, 2, any, p, scalarFunc, 0, 0))
 #ifdef SQLITE_TEST
-   || (rc = sqlite3_create_function(db, zTest, 2, any, p, testFunc, 0, 0))
-   || (rc = sqlite3_create_function(db, zTest, 3, any, p, testFunc, 0, 0))
-   || (rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0))
+   || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 2, any, p, testFunc, 0, 0))
+   || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 3, any, p, testFunc, 0, 0))
+   || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0))
 #endif
-  );
+   );
 
+#ifdef SQLITE_TEST
   sqlite3_free(zTest);
   sqlite3_free(zTest2);
+#endif
+
   return rc;
 }
 
@@ -106806,9 +103387,6 @@ typedef struct simple_tokenizer_cursor {
 } simple_tokenizer_cursor;
 
 
-/* Forward declaration */
-static const sqlite3_tokenizer_module simpleTokenizerModule;
-
 static int simpleDelim(simple_tokenizer *t, unsigned char c){
   return c<0x80 && t->delim[c];
 }
@@ -106832,7 +103410,7 @@ static int simpleCreate(
   ** information on the initial create.
   */
   if( argc>1 ){
-    int i, n = strlen(argv[1]);
+    int i, n = (int)strlen(argv[1]);
     for(i=0; i<n; i++){
       unsigned char ch = argv[1][i];
       /* We explicitly don't support UTF-8 delimiters for now. */
@@ -106846,7 +103424,7 @@ static int simpleCreate(
     /* Mark non-alphanumeric ASCII characters as delimiters */
     int i;
     for(i=1; i<0x80; i++){
-      t->delim[i] = !isalnum(i);
+      t->delim[i] = !isalnum(i) ? -1 : 0;
     }
   }
 
@@ -106875,6 +103453,8 @@ static int simpleOpen(
 ){
   simple_tokenizer_cursor *c;
 
+  UNUSED_PARAMETER(pTokenizer);
+
   c = (simple_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));
   if( c==NULL ) return SQLITE_NOMEM;
 
@@ -106948,7 +103528,7 @@ static int simpleNext(
         ** case-insensitivity.
         */
         unsigned char ch = p[iStartOffset+i];
-        c->pToken[i] = ch<0x80 ? tolower(ch) : ch;
+        c->pToken[i] = (char)(ch<0x80 ? tolower(ch) : ch);
       }
       *ppToken = c->pToken;
       *pnBytes = n;
@@ -106987,6 +103567,3679 @@ SQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(
 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */
 
 /************** End of fts3_tokenizer1.c *************************************/
+/************** Begin file fts3_write.c **************************************/
+/*
+** 2009 Oct 23
+**
+** 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 is part of the SQLite FTS3 extension module. Specifically,
+** this file contains code to insert, update and delete rows from FTS3
+** tables. It also contains code to merge FTS3 b-tree segments. Some
+** of the sub-routines used to merge segments are also used by the query 
+** code in fts3.c.
+*/
+
+#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
+
+
+typedef struct PendingList PendingList;
+typedef struct SegmentNode SegmentNode;
+typedef struct SegmentWriter SegmentWriter;
+
+/*
+** Data structure used while accumulating terms in the pending-terms hash
+** table. The hash table entry maps from term (a string) to a malloc'd
+** instance of this structure.
+*/
+struct PendingList {
+  int nData;
+  char *aData;
+  int nSpace;
+  sqlite3_int64 iLastDocid;
+  sqlite3_int64 iLastCol;
+  sqlite3_int64 iLastPos;
+};
+
+/*
+** An instance of this structure is used to iterate through the terms on
+** a contiguous set of segment b-tree leaf nodes. Although the details of
+** this structure are only manipulated by code in this file, opaque handles
+** of type Fts3SegReader* are also used by code in fts3.c to iterate through
+** terms when querying the full-text index. See functions:
+**
+**   sqlite3Fts3SegReaderNew()
+**   sqlite3Fts3SegReaderFree()
+**   sqlite3Fts3SegReaderIterate()
+**
+** Methods used to manipulate Fts3SegReader structures:
+**
+**   fts3SegReaderNext()
+**   fts3SegReaderFirstDocid()
+**   fts3SegReaderNextDocid()
+*/
+struct Fts3SegReader {
+  int iIdx;                       /* Index within level, or 0x7FFFFFFF for PT */
+  sqlite3_int64 iStartBlock;
+  sqlite3_int64 iEndBlock;
+  sqlite3_stmt *pStmt;            /* SQL Statement to access leaf nodes */
+  char *aNode;                    /* Pointer to node data (or NULL) */
+  int nNode;                      /* Size of buffer at aNode (or 0) */
+  int nTermAlloc;                 /* Allocated size of zTerm buffer */
+  Fts3HashElem **ppNextElem;
+
+  /* Variables set by fts3SegReaderNext(). These may be read directly
+  ** by the caller. They are valid from the time SegmentReaderNew() returns
+  ** until SegmentReaderNext() returns something other than SQLITE_OK
+  ** (i.e. SQLITE_DONE).
+  */
+  int nTerm;                      /* Number of bytes in current term */
+  char *zTerm;                    /* Pointer to current term */
+  char *aDoclist;                 /* Pointer to doclist of current entry */
+  int nDoclist;                   /* Size of doclist in current entry */
+
+  /* The following variables are used to iterate through the current doclist */
+  char *pOffsetList;
+  sqlite3_int64 iDocid;
+};
+
+#define fts3SegReaderIsPending(p) ((p)->ppNextElem!=0)
+
+/*
+** An instance of this structure is used to create a segment b-tree in the
+** database. The internal details of this type are only accessed by the
+** following functions:
+**
+**   fts3SegWriterAdd()
+**   fts3SegWriterFlush()
+**   fts3SegWriterFree()
+*/
+struct SegmentWriter {
+  SegmentNode *pTree;             /* Pointer to interior tree structure */
+  sqlite3_int64 iFirst;           /* First slot in %_segments written */
+  sqlite3_int64 iFree;            /* Next free slot in %_segments */
+  char *zTerm;                    /* Pointer to previous term buffer */
+  int nTerm;                      /* Number of bytes in zTerm */
+  int nMalloc;                    /* Size of malloc'd buffer at zMalloc */
+  char *zMalloc;                  /* Malloc'd space (possibly) used for zTerm */
+  int nSize;                      /* Size of allocation at aData */
+  int nData;                      /* Bytes of data in aData */
+  char *aData;                    /* Pointer to block from malloc() */
+};
+
+/*
+** Type SegmentNode is used by the following three functions to create
+** the interior part of the segment b+-tree structures (everything except
+** the leaf nodes). These functions and type are only ever used by code
+** within the fts3SegWriterXXX() family of functions described above.
+**
+**   fts3NodeAddTerm()
+**   fts3NodeWrite()
+**   fts3NodeFree()
+*/
+struct SegmentNode {
+  SegmentNode *pParent;           /* Parent node (or NULL for root node) */
+  SegmentNode *pRight;            /* Pointer to right-sibling */
+  SegmentNode *pLeftmost;         /* Pointer to left-most node of this depth */
+  int nEntry;                     /* Number of terms written to node so far */
+  char *zTerm;                    /* Pointer to previous term buffer */
+  int nTerm;                      /* Number of bytes in zTerm */
+  int nMalloc;                    /* Size of malloc'd buffer at zMalloc */
+  char *zMalloc;                  /* Malloc'd space (possibly) used for zTerm */
+  int nData;                      /* Bytes of valid data so far */
+  char *aData;                    /* Node data */
+};
+
+/*
+** Valid values for the second argument to fts3SqlStmt().
+*/
+#define SQL_DELETE_CONTENT             0
+#define SQL_IS_EMPTY                   1
+#define SQL_DELETE_ALL_CONTENT         2 
+#define SQL_DELETE_ALL_SEGMENTS        3
+#define SQL_DELETE_ALL_SEGDIR          4
+#define SQL_SELECT_CONTENT_BY_ROWID    5
+#define SQL_NEXT_SEGMENT_INDEX         6
+#define SQL_INSERT_SEGMENTS            7
+#define SQL_NEXT_SEGMENTS_ID           8
+#define SQL_INSERT_SEGDIR              9
+#define SQL_SELECT_LEVEL              10
+#define SQL_SELECT_ALL_LEVEL          11
+#define SQL_SELECT_LEVEL_COUNT        12
+#define SQL_SELECT_SEGDIR_COUNT_MAX   13
+#define SQL_DELETE_SEGDIR_BY_LEVEL    14
+#define SQL_DELETE_SEGMENTS_RANGE     15
+#define SQL_CONTENT_INSERT            16
+#define SQL_GET_BLOCK                 17
+
+/*
+** This function is used to obtain an SQLite prepared statement handle
+** for the statement identified by the second argument. If successful,
+** *pp is set to the requested statement handle and SQLITE_OK returned.
+** Otherwise, an SQLite error code is returned and *pp is set to 0.
+**
+** If argument apVal is not NULL, then it must point to an array with
+** at least as many entries as the requested statement has bound 
+** parameters. The values are bound to the statements parameters before
+** returning.
+*/
+static int fts3SqlStmt(
+  Fts3Table *p,                   /* Virtual table handle */
+  int eStmt,                      /* One of the SQL_XXX constants above */
+  sqlite3_stmt **pp,              /* OUT: Statement handle */
+  sqlite3_value **apVal           /* Values to bind to statement */
+){
+  const char *azSql[] = {
+/* 0  */  "DELETE FROM %Q.'%q_content' WHERE rowid = ?",
+/* 1  */  "SELECT NOT EXISTS(SELECT docid FROM %Q.'%q_content' WHERE rowid!=?)",
+/* 2  */  "DELETE FROM %Q.'%q_content'",
+/* 3  */  "DELETE FROM %Q.'%q_segments'",
+/* 4  */  "DELETE FROM %Q.'%q_segdir'",
+/* 5  */  "SELECT * FROM %Q.'%q_content' WHERE rowid=?",
+/* 6  */  "SELECT coalesce(max(idx)+1, 0) FROM %Q.'%q_segdir' WHERE level=?",
+/* 7  */  "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
+/* 8  */  "SELECT coalesce(max(blockid)+1, 1) FROM %Q.'%q_segments'",
+/* 9  */  "INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
+
+          /* Return segments in order from oldest to newest.*/ 
+/* 10 */  "SELECT idx, start_block, leaves_end_block, end_block, root "
+            "FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
+/* 11 */  "SELECT idx, start_block, leaves_end_block, end_block, root "
+            "FROM %Q.'%q_segdir' ORDER BY level DESC, idx ASC",
+
+/* 12 */  "SELECT count(*) FROM %Q.'%q_segdir' WHERE level = ?",
+/* 13 */  "SELECT count(*), max(level) FROM %Q.'%q_segdir'",
+
+/* 14 */  "DELETE FROM %Q.'%q_segdir' WHERE level = ?",
+/* 15 */  "DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?",
+/* 16 */  "INSERT INTO %Q.'%q_content' VALUES(%z)",
+/* 17 */  "SELECT block FROM %Q.'%q_segments' WHERE blockid = ?",
+  };
+  int rc = SQLITE_OK;
+  sqlite3_stmt *pStmt;
+
+  assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );
+  assert( eStmt<SizeofArray(azSql) && eStmt>=0 );
+  
+  pStmt = p->aStmt[eStmt];
+  if( !pStmt ){
+    char *zSql;
+    if( eStmt==SQL_CONTENT_INSERT ){
+      int i;                      /* Iterator variable */  
+      char *zVarlist;             /* The "?, ?, ..." string */
+      zVarlist = (char *)sqlite3_malloc(2*p->nColumn+2);
+      if( !zVarlist ){
+        *pp = 0;
+        return SQLITE_NOMEM;
+      }
+      zVarlist[0] = '?';
+      zVarlist[p->nColumn*2+1] = '\0';
+      for(i=1; i<=p->nColumn; i++){
+        zVarlist[i*2-1] = ',';
+        zVarlist[i*2] = '?';
+      }
+      zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, zVarlist);
+    }else{
+      zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
+    }
+    if( !zSql ){
+      rc = SQLITE_NOMEM;
+    }else{
+      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, NULL);
+      sqlite3_free(zSql);
+      assert( rc==SQLITE_OK || pStmt==0 );
+      p->aStmt[eStmt] = pStmt;
+    }
+  }
+  if( apVal ){
+    int i;
+    int nParam = sqlite3_bind_parameter_count(pStmt);
+    for(i=0; rc==SQLITE_OK && i<nParam; i++){
+      rc = sqlite3_bind_value(pStmt, i+1, apVal[i]);
+    }
+  }
+  *pp = pStmt;
+  return rc;
+}
+
+/*
+** Similar to fts3SqlStmt(). Except, after binding the parameters in
+** array apVal[] to the SQL statement identified by eStmt, the statement
+** is executed.
+**
+** Returns SQLITE_OK if the statement is successfully executed, or an
+** SQLite error code otherwise.
+*/
+static int fts3SqlExec(Fts3Table *p, int eStmt, sqlite3_value **apVal){
+  sqlite3_stmt *pStmt;
+  int rc = fts3SqlStmt(p, eStmt, &pStmt, apVal); 
+  if( rc==SQLITE_OK ){
+    sqlite3_step(pStmt);
+    rc = sqlite3_reset(pStmt);
+  }
+  return rc;
+}
+
+
+/*
+** Read a single block from the %_segments table. If the specified block
+** does not exist, return SQLITE_CORRUPT. If some other error (malloc, IO 
+** etc.) occurs, return the appropriate SQLite error code.
+**
+** Otherwise, if successful, set *pzBlock to point to a buffer containing
+** the block read from the database, and *pnBlock to the size of the read
+** block in bytes.
+**
+** WARNING: The returned buffer is only valid until the next call to 
+** sqlite3Fts3ReadBlock().
+*/
+SQLITE_PRIVATE int sqlite3Fts3ReadBlock(
+  Fts3Table *p,
+  sqlite3_int64 iBlock,
+  char const **pzBlock,
+  int *pnBlock
+){
+  sqlite3_stmt *pStmt;
+  int rc = fts3SqlStmt(p, SQL_GET_BLOCK, &pStmt, 0);
+  if( rc!=SQLITE_OK ) return rc;
+  sqlite3_reset(pStmt);
+
+  if( pzBlock ){
+    sqlite3_bind_int64(pStmt, 1, iBlock);
+    rc = sqlite3_step(pStmt); 
+    if( rc!=SQLITE_ROW ){
+      return (rc==SQLITE_DONE ? SQLITE_CORRUPT : rc);
+    }
+  
+    *pnBlock = sqlite3_column_bytes(pStmt, 0);
+    *pzBlock = (char *)sqlite3_column_blob(pStmt, 0);
+    if( sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){
+      return SQLITE_CORRUPT;
+    }
+  }
+  return SQLITE_OK;
+}
+
+/*
+** 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, 
+** return an SQLite error code.
+**
+** There is only ever one instance of this SQL statement compiled for
+** each FTS3 table.
+**
+** The statement returns the following columns from the %_segdir table:
+**
+**   0: idx
+**   1: start_block
+**   2: leaves_end_block
+**   3: end_block
+**   4: root
+*/
+SQLITE_PRIVATE int sqlite3Fts3AllSegdirs(Fts3Table *p, sqlite3_stmt **ppStmt){
+  return fts3SqlStmt(p, SQL_SELECT_ALL_LEVEL, ppStmt, 0);
+}
+
+
+/*
+** Append a single varint to a PendingList buffer. SQLITE_OK is returned
+** if successful, or an SQLite error code otherwise.
+**
+** This function also serves to allocate the PendingList structure itself.
+** For example, to create a new PendingList structure containing two
+** varints:
+**
+**   PendingList *p = 0;
+**   fts3PendingListAppendVarint(&p, 1);
+**   fts3PendingListAppendVarint(&p, 2);
+*/
+static int fts3PendingListAppendVarint(
+  PendingList **pp,               /* IN/OUT: Pointer to PendingList struct */
+  sqlite3_int64 i                 /* Value to append to data */
+){
+  PendingList *p = *pp;
+
+  /* Allocate or grow the PendingList as required. */
+  if( !p ){
+    p = sqlite3_malloc(sizeof(*p) + 100);
+    if( !p ){
+      return SQLITE_NOMEM;
+    }
+    p->nSpace = 100;
+    p->aData = (char *)&p[1];
+    p->nData = 0;
+  }
+  else if( p->nData+FTS3_VARINT_MAX+1>p->nSpace ){
+    int nNew = p->nSpace * 2;
+    p = sqlite3_realloc(p, sizeof(*p) + nNew);
+    if( !p ){
+      sqlite3_free(*pp);
+      *pp = 0;
+      return SQLITE_NOMEM;
+    }
+    p->nSpace = nNew;
+    p->aData = (char *)&p[1];
+  }
+
+  /* Append the new serialized varint to the end of the list. */
+  p->nData += sqlite3Fts3PutVarint(&p->aData[p->nData], i);
+  p->aData[p->nData] = '\0';
+  *pp = p;
+  return SQLITE_OK;
+}
+
+/*
+** Add a docid/column/position entry to a PendingList structure. Non-zero
+** is returned if the structure is sqlite3_realloced as part of adding
+** the entry. Otherwise, zero.
+**
+** If an OOM error occurs, *pRc is set to SQLITE_NOMEM before returning.
+** Zero is always returned in this case. Otherwise, if no OOM error occurs,
+** it is set to SQLITE_OK.
+*/
+static int fts3PendingListAppend(
+  PendingList **pp,               /* IN/OUT: PendingList structure */
+  sqlite3_int64 iDocid,           /* Docid for entry to add */
+  sqlite3_int64 iCol,             /* Column for entry to add */
+  sqlite3_int64 iPos,             /* Position of term for entry to add */
+  int *pRc                        /* OUT: Return code */
+){
+  PendingList *p = *pp;
+  int rc = SQLITE_OK;
+
+  assert( !p || p->iLastDocid<=iDocid );
+
+  if( !p || p->iLastDocid!=iDocid ){
+    sqlite3_int64 iDelta = iDocid - (p ? p->iLastDocid : 0);
+    if( p ){
+      assert( p->nData<p->nSpace );
+      assert( p->aData[p->nData]==0 );
+      p->nData++;
+    }
+    if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iDelta)) ){
+      goto pendinglistappend_out;
+    }
+    p->iLastCol = -1;
+    p->iLastPos = 0;
+    p->iLastDocid = iDocid;
+  }
+  if( iCol>0 && p->iLastCol!=iCol ){
+    if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, 1))
+     || SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iCol))
+    ){
+      goto pendinglistappend_out;
+    }
+    p->iLastCol = iCol;
+    p->iLastPos = 0;
+  }
+  if( iCol>=0 ){
+    assert( iPos>p->iLastPos || (iPos==0 && p->iLastPos==0) );
+    rc = fts3PendingListAppendVarint(&p, 2+iPos-p->iLastPos);
+    if( rc==SQLITE_OK ){
+      p->iLastPos = iPos;
+    }
+  }
+
+ pendinglistappend_out:
+  *pRc = rc;
+  if( p!=*pp ){
+    *pp = p;
+    return 1;
+  }
+  return 0;
+}
+
+/*
+** Tokenize the nul-terminated string zText and add all tokens to the
+** pending-terms hash-table. The docid used is that currently stored in
+** p->iPrevDocid, and the column is specified by argument iCol.
+**
+** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.
+*/
+static int fts3PendingTermsAdd(Fts3Table *p, const char *zText, int iCol){
+  int rc;
+  int iStart;
+  int iEnd;
+  int iPos;
+
+  char const *zToken;
+  int nToken;
+
+  sqlite3_tokenizer *pTokenizer = p->pTokenizer;
+  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;
+  sqlite3_tokenizer_cursor *pCsr;
+  int (*xNext)(sqlite3_tokenizer_cursor *pCursor,
+      const char**,int*,int*,int*,int*);
+
+  assert( pTokenizer && pModule );
+
+  rc = pModule->xOpen(pTokenizer, zText, -1, &pCsr);
+  if( rc!=SQLITE_OK ){
+    return rc;
+  }
+  pCsr->pTokenizer = pTokenizer;
+
+  xNext = pModule->xNext;
+  while( SQLITE_OK==rc
+      && SQLITE_OK==(rc = xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos))
+  ){
+    PendingList *pList;
+
+    /* Positions cannot be negative; we use -1 as a terminator internally.
+    ** Tokens must have a non-zero length.
+    */
+    if( iPos<0 || !zToken || nToken<=0 ){
+      rc = SQLITE_ERROR;
+      break;
+    }
+
+    pList = (PendingList *)fts3HashFind(&p->pendingTerms, zToken, nToken);
+    if( pList ){
+      p->nPendingData -= (pList->nData + nToken + sizeof(Fts3HashElem));
+    }
+    if( fts3PendingListAppend(&pList, p->iPrevDocid, iCol, iPos, &rc) ){
+      if( pList==fts3HashInsert(&p->pendingTerms, zToken, nToken, pList) ){
+        /* Malloc failed while inserting the new entry. This can only 
+        ** happen if there was no previous entry for this token.
+        */
+        assert( 0==fts3HashFind(&p->pendingTerms, zToken, nToken) );
+        sqlite3_free(pList);
+        rc = SQLITE_NOMEM;
+      }
+    }
+    if( rc==SQLITE_OK ){
+      p->nPendingData += (pList->nData + nToken + sizeof(Fts3HashElem));
+    }
+  }
+
+  pModule->xClose(pCsr);
+  return (rc==SQLITE_DONE ? SQLITE_OK : rc);
+}
+
+/* 
+** Calling this function indicates that subsequent calls to 
+** fts3PendingTermsAdd() are to add term/position-list pairs for the
+** contents of the document with docid iDocid.
+*/
+static int fts3PendingTermsDocid(Fts3Table *p, sqlite_int64 iDocid){
+  /* TODO(shess) Explore whether partially flushing the buffer on
+  ** forced-flush would provide better performance.  I suspect that if
+  ** we ordered the doclists by size and flushed the largest until the
+  ** buffer was half empty, that would let the less frequent terms
+  ** generate longer doclists.
+  */
+  if( iDocid<=p->iPrevDocid || p->nPendingData>p->nMaxPendingData ){
+    int rc = sqlite3Fts3PendingTermsFlush(p);
+    if( rc!=SQLITE_OK ) return rc;
+  }
+  p->iPrevDocid = iDocid;
+  return SQLITE_OK;
+}
+
+SQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *p){
+  Fts3HashElem *pElem;
+  for(pElem=fts3HashFirst(&p->pendingTerms); pElem; pElem=fts3HashNext(pElem)){
+    sqlite3_free(fts3HashData(pElem));
+  }
+  fts3HashClear(&p->pendingTerms);
+  p->nPendingData = 0;
+}
+
+/*
+** This function is called by the xUpdate() method as part of an INSERT
+** operation. It adds entries for each term in the new record to the
+** pendingTerms hash table.
+**
+** Argument apVal is the same as the similarly named argument passed to
+** fts3InsertData(). Parameter iDocid is the docid of the new row.
+*/
+static int fts3InsertTerms(Fts3Table *p, sqlite3_value **apVal){
+  int i;                          /* Iterator variable */
+  for(i=2; i<p->nColumn+2; i++){
+    const char *zText = (const char *)sqlite3_value_text(apVal[i]);
+    if( zText ){
+      int rc = fts3PendingTermsAdd(p, zText, i-2);
+      if( rc!=SQLITE_OK ){
+        return rc;
+      }
+    }
+  }
+  return SQLITE_OK;
+}
+
+/*
+** This function is called by the xUpdate() method for an INSERT operation.
+** The apVal parameter is passed a copy of the apVal argument passed by
+** SQLite to the xUpdate() method. i.e:
+**
+**   apVal[0]                Not used for INSERT.
+**   apVal[1]                rowid
+**   apVal[2]                Left-most user-defined column
+**   ...
+**   apVal[p->nColumn+1]     Right-most user-defined column
+**   apVal[p->nColumn+2]     Hidden column with same name as table
+**   apVal[p->nColumn+3]     Hidden "docid" column (alias for rowid)
+*/
+static int fts3InsertData(
+  Fts3Table *p,                   /* Full-text table */
+  sqlite3_value **apVal,          /* Array of values to insert */
+  sqlite3_int64 *piDocid          /* OUT: Docid for row just inserted */
+){
+  int rc;                         /* Return code */
+  sqlite3_stmt *pContentInsert;   /* INSERT INTO %_content VALUES(...) */
+
+  /* Locate the statement handle used to insert data into the %_content
+  ** table. The SQL for this statement is:
+  **
+  **   INSERT INTO %_content VALUES(?, ?, ?, ...)
+  **
+  ** The statement features N '?' variables, where N is the number of user
+  ** defined columns in the FTS3 table, plus one for the docid field.
+  */
+  rc = fts3SqlStmt(p, SQL_CONTENT_INSERT, &pContentInsert, &apVal[1]);
+  if( rc!=SQLITE_OK ){
+    return rc;
+  }
+
+  /* There is a quirk here. The users INSERT statement may have specified
+  ** a value for the "rowid" field, for the "docid" field, or for both.
+  ** Which is a problem, since "rowid" and "docid" are aliases for the
+  ** same value. For example:
+  **
+  **   INSERT INTO fts3tbl(rowid, docid) VALUES(1, 2);
+  **
+  ** In FTS3, this is an error. It is an error to specify non-NULL values
+  ** for both docid and some other rowid alias.
+  */
+  if( SQLITE_NULL!=sqlite3_value_type(apVal[3+p->nColumn]) ){
+    if( SQLITE_NULL==sqlite3_value_type(apVal[0])
+     && SQLITE_NULL!=sqlite3_value_type(apVal[1])
+    ){
+      /* A rowid/docid conflict. */
+      return SQLITE_ERROR;
+    }
+    rc = sqlite3_bind_value(pContentInsert, 1, apVal[3+p->nColumn]);
+    if( rc!=SQLITE_OK ) return rc;
+  }
+
+  /* Execute the statement to insert the record. Set *piDocid to the 
+  ** new docid value. 
+  */
+  sqlite3_step(pContentInsert);
+  rc = sqlite3_reset(pContentInsert);
+
+  *piDocid = sqlite3_last_insert_rowid(p->db);
+  return rc;
+}
+
+
+
+/*
+** Remove all data from the FTS3 table. Clear the hash table containing
+** pending terms.
+*/
+static int fts3DeleteAll(Fts3Table *p){
+  int rc;                         /* Return code */
+
+  /* Discard the contents of the pending-terms hash table. */
+  sqlite3Fts3PendingTermsClear(p);
+
+  /* Delete everything from the %_content, %_segments and %_segdir tables. */
+  rc = fts3SqlExec(p, SQL_DELETE_ALL_CONTENT, 0);
+  if( rc==SQLITE_OK ){
+    rc = fts3SqlExec(p, SQL_DELETE_ALL_SEGMENTS, 0);
+  }
+  if( rc==SQLITE_OK ){
+    rc = fts3SqlExec(p, SQL_DELETE_ALL_SEGDIR, 0);
+  }
+  return rc;
+}
+
+/*
+** The first element in the apVal[] array is assumed to contain the docid
+** (an integer) of a row about to be deleted. Remove all terms from the
+** full-text index.
+*/
+static int fts3DeleteTerms(Fts3Table *p, sqlite3_value **apVal){
+  int rc;
+  sqlite3_stmt *pSelect;
+
+  rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pSelect, apVal);
+  if( rc==SQLITE_OK ){
+    if( SQLITE_ROW==sqlite3_step(pSelect) ){
+      int i;
+      for(i=1; i<=p->nColumn; i++){
+        const char *zText = (const char *)sqlite3_column_text(pSelect, i);
+        rc = fts3PendingTermsAdd(p, zText, -1);
+        if( rc!=SQLITE_OK ){
+          sqlite3_reset(pSelect);
+          return rc;
+        }
+      }
+    }
+    rc = sqlite3_reset(pSelect);
+  }else{
+    sqlite3_reset(pSelect);
+  }
+  return rc;
+}
+
+/*
+** Forward declaration to account for the circular dependency between
+** functions fts3SegmentMerge() and fts3AllocateSegdirIdx().
+*/
+static int fts3SegmentMerge(Fts3Table *, int);
+
+/* 
+** This function allocates a new level iLevel index in the segdir table.
+** Usually, indexes are allocated within a level sequentially starting
+** with 0, so the allocated index is one greater than the value returned
+** by:
+**
+**   SELECT max(idx) FROM %_segdir WHERE level = :iLevel
+**
+** However, if there are already FTS3_MERGE_COUNT indexes at the requested
+** level, they are merged into a single level (iLevel+1) segment and the 
+** allocated index is 0.
+**
+** If successful, *piIdx is set to the allocated index slot and SQLITE_OK
+** returned. Otherwise, an SQLite error code is returned.
+*/
+static int fts3AllocateSegdirIdx(Fts3Table *p, int iLevel, int *piIdx){
+  int rc;                         /* Return Code */
+  sqlite3_stmt *pNextIdx;         /* Query for next idx at level iLevel */
+  int iNext = 0;                  /* Result of query pNextIdx */
+
+  /* Set variable iNext to the next available segdir index at level iLevel. */
+  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pNextIdx, 0);
+  if( rc==SQLITE_OK ){
+    sqlite3_bind_int(pNextIdx, 1, iLevel);
+    if( SQLITE_ROW==sqlite3_step(pNextIdx) ){
+      iNext = sqlite3_column_int(pNextIdx, 0);
+    }
+    rc = sqlite3_reset(pNextIdx);
+  }
+
+  if( rc==SQLITE_OK ){
+    /* If iNext is FTS3_MERGE_COUNT, indicating that level iLevel is already
+    ** full, merge all segments in level iLevel into a single iLevel+1
+    ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
+    ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
+    */
+    if( iNext>=FTS3_MERGE_COUNT ){
+      rc = fts3SegmentMerge(p, iLevel);
+      *piIdx = 0;
+    }else{
+      *piIdx = iNext;
+    }
+  }
+
+  return rc;
+}
+
+/*
+** Move the iterator passed as the first argument to the next term in the
+** segment. If successful, SQLITE_OK is returned. If there is no next term,
+** SQLITE_DONE. Otherwise, an SQLite error code.
+*/
+static int fts3SegReaderNext(Fts3SegReader *pReader){
+  char *pNext;                    /* Cursor variable */
+  int nPrefix;                    /* Number of bytes in term prefix */
+  int nSuffix;                    /* Number of bytes in term suffix */
+
+  if( !pReader->aDoclist ){
+    pNext = pReader->aNode;
+  }else{
+    pNext = &pReader->aDoclist[pReader->nDoclist];
+  }
+
+  if( !pNext || pNext>=&pReader->aNode[pReader->nNode] ){
+    int rc;
+    if( fts3SegReaderIsPending(pReader) ){
+      Fts3HashElem *pElem = *(pReader->ppNextElem);
+      if( pElem==0 ){
+        pReader->aNode = 0;
+      }else{
+        PendingList *pList = (PendingList *)fts3HashData(pElem);
+        pReader->zTerm = (char *)fts3HashKey(pElem);
+        pReader->nTerm = fts3HashKeysize(pElem);
+        pReader->nNode = pReader->nDoclist = pList->nData + 1;
+        pReader->aNode = pReader->aDoclist = pList->aData;
+        pReader->ppNextElem++;
+        assert( pReader->aNode );
+      }
+      return SQLITE_OK;
+    }
+    if( !pReader->pStmt ){
+      pReader->aNode = 0;
+      return SQLITE_OK;
+    }
+    rc = sqlite3_step(pReader->pStmt);
+    if( rc!=SQLITE_ROW ){
+      pReader->aNode = 0;
+      return (rc==SQLITE_DONE ? SQLITE_OK : rc);
+    }
+    pReader->nNode = sqlite3_column_bytes(pReader->pStmt, 0);
+    pReader->aNode = (char *)sqlite3_column_blob(pReader->pStmt, 0);
+    pNext = pReader->aNode;
+  }
+  
+  pNext += sqlite3Fts3GetVarint32(pNext, &nPrefix);
+  pNext += sqlite3Fts3GetVarint32(pNext, &nSuffix);
+
+  if( nPrefix+nSuffix>pReader->nTermAlloc ){
+    int nNew = (nPrefix+nSuffix)*2;
+    char *zNew = sqlite3_realloc(pReader->zTerm, nNew);
+    if( !zNew ){
+      return SQLITE_NOMEM;
+    }
+    pReader->zTerm = zNew;
+    pReader->nTermAlloc = nNew;
+  }
+  memcpy(&pReader->zTerm[nPrefix], pNext, nSuffix);
+  pReader->nTerm = nPrefix+nSuffix;
+  pNext += nSuffix;
+  pNext += sqlite3Fts3GetVarint32(pNext, &pReader->nDoclist);
+  assert( pNext<&pReader->aNode[pReader->nNode] );
+  pReader->aDoclist = pNext;
+  pReader->pOffsetList = 0;
+  return SQLITE_OK;
+}
+
+/*
+** Set the SegReader to point to the first docid in the doclist associated
+** with the current term.
+*/
+static void fts3SegReaderFirstDocid(Fts3SegReader *pReader){
+  int n;
+  assert( pReader->aDoclist );
+  assert( !pReader->pOffsetList );
+  n = sqlite3Fts3GetVarint(pReader->aDoclist, &pReader->iDocid);
+  pReader->pOffsetList = &pReader->aDoclist[n];
+}
+
+/*
+** Advance the SegReader to point to the next docid in the doclist
+** associated with the current term.
+** 
+** If arguments ppOffsetList and pnOffsetList are not NULL, then 
+** *ppOffsetList is set to point to the first column-offset list
+** in the doclist entry (i.e. immediately past the docid varint).
+** *pnOffsetList is set to the length of the set of column-offset
+** lists, not including the nul-terminator byte. For example:
+*/
+static void fts3SegReaderNextDocid(
+  Fts3SegReader *pReader,
+  char **ppOffsetList,
+  int *pnOffsetList
+){
+  char *p = pReader->pOffsetList;
+  char c = 0;
+
+  /* Pointer p currently points at the first byte of an offset list. The
+  ** following two lines advance it to point one byte past the end of
+  ** the same offset list.
+  */
+  while( *p | c ) c = *p++ & 0x80;
+  p++;
+
+  /* If required, populate the output variables with a pointer to and the
+  ** size of the previous offset-list.
+  */
+  if( ppOffsetList ){
+    *ppOffsetList = pReader->pOffsetList;
+    *pnOffsetList = (int)(p - pReader->pOffsetList - 1);
+  }
+
+  /* If there are no more entries in the doclist, set pOffsetList to
+  ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and
+  ** Fts3SegReader.pOffsetList to point to the next offset list before
+  ** returning.
+  */
+  if( p>=&pReader->aDoclist[pReader->nDoclist] ){
+    pReader->pOffsetList = 0;
+  }else{
+    sqlite3_int64 iDelta;
+    pReader->pOffsetList = p + sqlite3Fts3GetVarint(p, &iDelta);
+    pReader->iDocid += iDelta;
+  }
+}
+
+/*
+** Free all allocations associated with the iterator passed as the 
+** second argument.
+*/
+SQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3Table *p, Fts3SegReader *pReader){
+  if( pReader ){
+    if( pReader->pStmt ){
+      /* Move the leaf-range SELECT statement to the aLeavesStmt[] array,
+      ** so that it can be reused when required by another query.
+      */
+      assert( p->nLeavesStmt<p->nLeavesTotal );
+      sqlite3_reset(pReader->pStmt);
+      p->aLeavesStmt[p->nLeavesStmt++] = pReader->pStmt;
+    }
+    if( !fts3SegReaderIsPending(pReader) ){
+      sqlite3_free(pReader->zTerm);
+    }
+    sqlite3_free(pReader);
+  }
+}
+
+/*
+** Allocate a new SegReader object.
+*/
+SQLITE_PRIVATE int sqlite3Fts3SegReaderNew(
+  Fts3Table *p,                   /* Virtual table handle */
+  int iAge,                       /* Segment "age". */
+  sqlite3_int64 iStartLeaf,       /* First leaf to traverse */
+  sqlite3_int64 iEndLeaf,         /* Final leaf to traverse */
+  sqlite3_int64 iEndBlock,        /* Final block of segment */
+  const char *zRoot,              /* Buffer containing root node */
+  int nRoot,                      /* Size of buffer containing root node */
+  Fts3SegReader **ppReader        /* OUT: Allocated Fts3SegReader */
+){
+  int rc = SQLITE_OK;             /* Return code */
+  Fts3SegReader *pReader;         /* Newly allocated SegReader object */
+  int nExtra = 0;                 /* Bytes to allocate segment root node */
+
+  if( iStartLeaf==0 ){
+    nExtra = nRoot;
+  }
+
+  pReader = (Fts3SegReader *)sqlite3_malloc(sizeof(Fts3SegReader) + nExtra);
+  if( !pReader ){
+    return SQLITE_NOMEM;
+  }
+  memset(pReader, 0, sizeof(Fts3SegReader));
+  pReader->iStartBlock = iStartLeaf;
+  pReader->iIdx = iAge;
+  pReader->iEndBlock = iEndBlock;
+
+  if( nExtra ){
+    /* The entire segment is stored in the root node. */
+    pReader->aNode = (char *)&pReader[1];
+    pReader->nNode = nRoot;
+    memcpy(pReader->aNode, zRoot, nRoot);
+  }else{
+    /* If the text of the SQL statement to iterate through a contiguous
+    ** set of entries in the %_segments table has not yet been composed,
+    ** compose it now.
+    */
+    if( !p->zSelectLeaves ){
+      p->zSelectLeaves = sqlite3_mprintf(
+          "SELECT block FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ? "
+          "ORDER BY blockid", p->zDb, p->zName
+      );
+      if( !p->zSelectLeaves ){
+        rc = SQLITE_NOMEM;
+        goto finished;
+      }
+    }
+
+    /* If there are no free statements in the aLeavesStmt[] array, prepare
+    ** a new statement now. Otherwise, reuse a prepared statement from
+    ** aLeavesStmt[].
+    */
+    if( p->nLeavesStmt==0 ){
+      if( p->nLeavesTotal==p->nLeavesAlloc ){
+        int nNew = p->nLeavesAlloc + 16;
+        sqlite3_stmt **aNew = (sqlite3_stmt **)sqlite3_realloc(
+            p->aLeavesStmt, nNew*sizeof(sqlite3_stmt *)
+        );
+        if( !aNew ){
+          rc = SQLITE_NOMEM;
+          goto finished;
+        }
+        p->nLeavesAlloc = nNew;
+        p->aLeavesStmt = aNew;
+      }
+      rc = sqlite3_prepare_v2(p->db, p->zSelectLeaves, -1, &pReader->pStmt, 0);
+      if( rc!=SQLITE_OK ){
+        goto finished;
+      }
+      p->nLeavesTotal++;
+    }else{
+      pReader->pStmt = p->aLeavesStmt[--p->nLeavesStmt];
+    }
+
+    /* Bind the start and end leaf blockids to the prepared SQL statement. */
+    sqlite3_bind_int64(pReader->pStmt, 1, iStartLeaf);
+    sqlite3_bind_int64(pReader->pStmt, 2, iEndLeaf);
+  }
+  rc = fts3SegReaderNext(pReader);
+
+ finished:
+  if( rc==SQLITE_OK ){
+    *ppReader = pReader;
+  }else{
+    sqlite3Fts3SegReaderFree(p, pReader);
+  }
+  return rc;
+}
+
+/*
+** This is a comparison function used as a qsort() callback when sorting
+** an array of pending terms by term. This occurs as part of flushing
+** the contents of the pending-terms hash table to the database.
+*/
+static int fts3CompareElemByTerm(const void *lhs, const void *rhs){
+  char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);
+  char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);
+  int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);
+  int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);
+
+  int n = (n1<n2 ? n1 : n2);
+  int c = memcmp(z1, z2, n);
+  if( c==0 ){
+    c = n1 - n2;
+  }
+  return c;
+}
+
+/*
+** This function is used to allocate an Fts3SegReader that iterates through
+** a subset of the terms stored in the Fts3Table.pendingTerms array.
+*/
+SQLITE_PRIVATE int sqlite3Fts3SegReaderPending(
+  Fts3Table *p,                   /* Virtual table handle */
+  const char *zTerm,              /* Term to search for */
+  int nTerm,                      /* Size of buffer zTerm */
+  int isPrefix,                   /* True for a term-prefix query */
+  Fts3SegReader **ppReader        /* OUT: SegReader for pending-terms */
+){
+  Fts3SegReader *pReader = 0;     /* Fts3SegReader object to return */
+  Fts3HashElem **aElem = 0;       /* Array of term hash entries to scan */
+  int nElem = 0;                  /* Size of array at aElem */
+  int rc = SQLITE_OK;             /* Return Code */
+
+  if( isPrefix ){
+    int nAlloc = 0;               /* Size of allocated array at aElem */
+    Fts3HashElem *pE = 0;         /* Iterator variable */
+
+    for(pE=fts3HashFirst(&p->pendingTerms); pE; pE=fts3HashNext(pE)){
+      char *zKey = (char *)fts3HashKey(pE);
+      int nKey = fts3HashKeysize(pE);
+      if( nTerm==0 || (nKey>=nTerm && 0==memcmp(zKey, zTerm, nTerm)) ){
+        if( nElem==nAlloc ){
+          Fts3HashElem **aElem2;
+          nAlloc += 16;
+          aElem2 = (Fts3HashElem **)sqlite3_realloc(
+              aElem, nAlloc*sizeof(Fts3HashElem *)
+          );
+          if( !aElem2 ){
+            rc = SQLITE_NOMEM;
+            nElem = 0;
+            break;
+          }
+          aElem = aElem2;
+        }
+        aElem[nElem++] = pE;
+      }
+    }
+
+    /* If more than one term matches the prefix, sort the Fts3HashElem
+    ** objects in term order using qsort(). This uses the same comparison
+    ** callback as is used when flushing terms to disk.
+    */
+    if( nElem>1 ){
+      qsort(aElem, nElem, sizeof(Fts3HashElem *), fts3CompareElemByTerm);
+    }
+
+  }else{
+    Fts3HashElem *pE = fts3HashFindElem(&p->pendingTerms, zTerm, nTerm);
+    if( pE ){
+      aElem = &pE;
+      nElem = 1;
+    }
+  }
+
+  if( nElem>0 ){
+    int nByte = sizeof(Fts3SegReader) + (nElem+1)*sizeof(Fts3HashElem *);
+    pReader = (Fts3SegReader *)sqlite3_malloc(nByte);
+    if( !pReader ){
+      rc = SQLITE_NOMEM;
+    }else{
+      memset(pReader, 0, nByte);
+      pReader->iIdx = 0x7FFFFFFF;
+      pReader->ppNextElem = (Fts3HashElem **)&pReader[1];
+      memcpy(pReader->ppNextElem, aElem, nElem*sizeof(Fts3HashElem *));
+      fts3SegReaderNext(pReader);
+    }
+  }
+
+  if( isPrefix ){
+    sqlite3_free(aElem);
+  }
+  *ppReader = pReader;
+  return rc;
+}
+
+
+/*
+** The second argument to this function is expected to be a statement of
+** the form:
+**
+**   SELECT 
+**     idx,                  -- col 0
+**     start_block,          -- col 1
+**     leaves_end_block,     -- col 2
+**     end_block,            -- col 3
+**     root                  -- col 4
+**   FROM %_segdir ...
+**
+** This function allocates and initializes a Fts3SegReader structure to
+** iterate through the terms stored in the segment identified by the
+** current row that pStmt is pointing to. 
+**
+** If successful, the Fts3SegReader is left pointing to the first term
+** in the segment and SQLITE_OK is returned. Otherwise, an SQLite error
+** code is returned.
+*/
+static int fts3SegReaderNew(
+  Fts3Table *p,                   /* Virtual table handle */
+  sqlite3_stmt *pStmt,            /* See above */
+  int iAge,                       /* Segment "age". */
+  Fts3SegReader **ppReader        /* OUT: Allocated Fts3SegReader */
+){
+  return sqlite3Fts3SegReaderNew(p, iAge, 
+      sqlite3_column_int64(pStmt, 1),
+      sqlite3_column_int64(pStmt, 2),
+      sqlite3_column_int64(pStmt, 3),
+      sqlite3_column_blob(pStmt, 4),
+      sqlite3_column_bytes(pStmt, 4),
+      ppReader
+  );
+}
+
+/*
+** Compare the entries pointed to by two Fts3SegReader structures. 
+** Comparison is as follows:
+**
+**   1) EOF is greater than not EOF.
+**
+**   2) The current terms (if any) are compared using memcmp(). If one
+**      term is a prefix of another, the longer term is considered the
+**      larger.
+**
+**   3) By segment age. An older segment is considered larger.
+*/
+static int fts3SegReaderCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){
+  int rc;
+  if( pLhs->aNode && pRhs->aNode ){
+    int rc2 = pLhs->nTerm - pRhs->nTerm;
+    if( rc2<0 ){
+      rc = memcmp(pLhs->zTerm, pRhs->zTerm, pLhs->nTerm);
+    }else{
+      rc = memcmp(pLhs->zTerm, pRhs->zTerm, pRhs->nTerm);
+    }
+    if( rc==0 ){
+      rc = rc2;
+    }
+  }else{
+    rc = (pLhs->aNode==0) - (pRhs->aNode==0);
+  }
+  if( rc==0 ){
+    rc = pRhs->iIdx - pLhs->iIdx;
+  }
+  assert( rc!=0 );
+  return rc;
+}
+
+/*
+** A different comparison function for SegReader structures. In this
+** version, it is assumed that each SegReader points to an entry in
+** a doclist for identical terms. Comparison is made as follows:
+**
+**   1) EOF (end of doclist in this case) is greater than not EOF.
+**
+**   2) By current docid.
+**
+**   3) By segment age. An older segment is considered larger.
+*/
+static int fts3SegReaderDoclistCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){
+  int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);
+  if( rc==0 ){
+    if( pLhs->iDocid==pRhs->iDocid ){
+      rc = pRhs->iIdx - pLhs->iIdx;
+    }else{
+      rc = (pLhs->iDocid > pRhs->iDocid) ? 1 : -1;
+    }
+  }
+  assert( pLhs->aNode && pRhs->aNode );
+  return rc;
+}
+
+/*
+** Compare the term that the Fts3SegReader object passed as the first argument
+** points to with the term specified by arguments zTerm and nTerm. 
+**
+** If the pSeg iterator is already at EOF, return 0. Otherwise, return
+** -ve if the pSeg term is less than zTerm/nTerm, 0 if the two terms are
+** equal, or +ve if the pSeg term is greater than zTerm/nTerm.
+*/
+static int fts3SegReaderTermCmp(
+  Fts3SegReader *pSeg,            /* Segment reader object */
+  const char *zTerm,              /* Term to compare to */
+  int nTerm                       /* Size of term zTerm in bytes */
+){
+  int res = 0;
+  if( pSeg->aNode ){
+    if( pSeg->nTerm>nTerm ){
+      res = memcmp(pSeg->zTerm, zTerm, nTerm);
+    }else{
+      res = memcmp(pSeg->zTerm, zTerm, pSeg->nTerm);
+    }
+    if( res==0 ){
+      res = pSeg->nTerm-nTerm;
+    }
+  }
+  return res;
+}
+
+/*
+** Argument apSegment is an array of nSegment elements. It is known that
+** the final (nSegment-nSuspect) members are already in sorted order
+** (according to the comparison function provided). This function shuffles
+** the array around until all entries are in sorted order.
+*/
+static void fts3SegReaderSort(
+  Fts3SegReader **apSegment,                     /* Array to sort entries of */
+  int nSegment,                                  /* Size of apSegment array */
+  int nSuspect,                                  /* Unsorted entry count */
+  int (*xCmp)(Fts3SegReader *, Fts3SegReader *)  /* Comparison function */
+){
+  int i;                          /* Iterator variable */
+
+  assert( nSuspect<=nSegment );
+
+  if( nSuspect==nSegment ) nSuspect--;
+  for(i=nSuspect-1; i>=0; i--){
+    int j;
+    for(j=i; j<(nSegment-1); j++){
+      Fts3SegReader *pTmp;
+      if( xCmp(apSegment[j], apSegment[j+1])<0 ) break;
+      pTmp = apSegment[j+1];
+      apSegment[j+1] = apSegment[j];
+      apSegment[j] = pTmp;
+    }
+  }
+
+#ifndef NDEBUG
+  /* Check that the list really is sorted now. */
+  for(i=0; i<(nSuspect-1); i++){
+    assert( xCmp(apSegment[i], apSegment[i+1])<0 );
+  }
+#endif
+}
+
+/* 
+** Insert a record into the %_segments table.
+*/
+static int fts3WriteSegment(
+  Fts3Table *p,                   /* Virtual table handle */
+  sqlite3_int64 iBlock,           /* Block id for new block */
+  char *z,                        /* Pointer to buffer containing block data */
+  int n                           /* Size of buffer z in bytes */
+){
+  sqlite3_stmt *pStmt;
+  int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);
+  if( rc==SQLITE_OK ){
+    sqlite3_bind_int64(pStmt, 1, iBlock);
+    sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);
+    sqlite3_step(pStmt);
+    rc = sqlite3_reset(pStmt);
+  }
+  return rc;
+}
+
+/* 
+** Insert a record into the %_segdir table.
+*/
+static int fts3WriteSegdir(
+  Fts3Table *p,                   /* Virtual table handle */
+  int iLevel,                     /* Value for "level" field */
+  int iIdx,                       /* Value for "idx" field */
+  sqlite3_int64 iStartBlock,      /* Value for "start_block" field */
+  sqlite3_int64 iLeafEndBlock,    /* Value for "leaves_end_block" field */
+  sqlite3_int64 iEndBlock,        /* Value for "end_block" field */
+  char *zRoot,                    /* Blob value for "root" field */
+  int nRoot                       /* Number of bytes in buffer zRoot */
+){
+  sqlite3_stmt *pStmt;
+  int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);
+  if( rc==SQLITE_OK ){
+    sqlite3_bind_int(pStmt, 1, iLevel);
+    sqlite3_bind_int(pStmt, 2, iIdx);
+    sqlite3_bind_int64(pStmt, 3, iStartBlock);
+    sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
+    sqlite3_bind_int64(pStmt, 5, iEndBlock);
+    sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
+    sqlite3_step(pStmt);
+    rc = sqlite3_reset(pStmt);
+  }
+  return rc;
+}
+
+/*
+** Return the size of the common prefix (if any) shared by zPrev and
+** zNext, in bytes. For example, 
+**
+**   fts3PrefixCompress("abc", 3, "abcdef", 6)   // returns 3
+**   fts3PrefixCompress("abX", 3, "abcdef", 6)   // returns 2
+**   fts3PrefixCompress("abX", 3, "Xbcdef", 6)   // returns 0
+*/
+static int fts3PrefixCompress(
+  const char *zPrev,              /* Buffer containing previous term */
+  int nPrev,                      /* Size of buffer zPrev in bytes */
+  const char *zNext,              /* Buffer containing next term */
+  int nNext                       /* Size of buffer zNext in bytes */
+){
+  int n;
+  UNUSED_PARAMETER(nNext);
+  for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++);
+  return n;
+}
+
+/*
+** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger
+** (according to memcmp) than the previous term.
+*/
+static int fts3NodeAddTerm(
+  Fts3Table *p,               /* Virtual table handle */
+  SegmentNode **ppTree,           /* IN/OUT: SegmentNode handle */ 
+  int isCopyTerm,                 /* True if zTerm/nTerm is transient */
+  const char *zTerm,              /* Pointer to buffer containing term */
+  int nTerm                       /* Size of term in bytes */
+){
+  SegmentNode *pTree = *ppTree;
+  int rc;
+  SegmentNode *pNew;
+
+  /* First try to append the term to the current node. Return early if 
+  ** this is possible.
+  */
+  if( pTree ){
+    int nData = pTree->nData;     /* Current size of node in bytes */
+    int nReq = nData;             /* Required space after adding zTerm */
+    int nPrefix;                  /* Number of bytes of prefix compression */
+    int nSuffix;                  /* Suffix length */
+
+    nPrefix = fts3PrefixCompress(pTree->zTerm, pTree->nTerm, zTerm, nTerm);
+    nSuffix = nTerm-nPrefix;
+
+    nReq += sqlite3Fts3VarintLen(nPrefix)+sqlite3Fts3VarintLen(nSuffix)+nSuffix;
+    if( nReq<=p->nNodeSize || !pTree->zTerm ){
+
+      if( nReq>p->nNodeSize ){
+        /* An unusual case: this is the first term to be added to the node
+        ** and the static node buffer (p->nNodeSize bytes) is not large
+        ** enough. Use a separately malloced buffer instead This wastes
+        ** p->nNodeSize bytes, but since this scenario only comes about when
+        ** the database contain two terms that share a prefix of almost 2KB, 
+        ** this is not expected to be a serious problem. 
+        */
+        assert( pTree->aData==(char *)&pTree[1] );
+        pTree->aData = (char *)sqlite3_malloc(nReq);
+        if( !pTree->aData ){
+          return SQLITE_NOMEM;
+        }
+      }
+
+      if( pTree->zTerm ){
+        /* There is no prefix-length field for first term in a node */
+        nData += sqlite3Fts3PutVarint(&pTree->aData[nData], nPrefix);
+      }
+
+      nData += sqlite3Fts3PutVarint(&pTree->aData[nData], nSuffix);
+      memcpy(&pTree->aData[nData], &zTerm[nPrefix], nSuffix);
+      pTree->nData = nData + nSuffix;
+      pTree->nEntry++;
+
+      if( isCopyTerm ){
+        if( pTree->nMalloc<nTerm ){
+          char *zNew = sqlite3_realloc(pTree->zMalloc, nTerm*2);
+          if( !zNew ){
+            return SQLITE_NOMEM;
+          }
+          pTree->nMalloc = nTerm*2;
+          pTree->zMalloc = zNew;
+        }
+        pTree->zTerm = pTree->zMalloc;
+        memcpy(pTree->zTerm, zTerm, nTerm);
+        pTree->nTerm = nTerm;
+      }else{
+        pTree->zTerm = (char *)zTerm;
+        pTree->nTerm = nTerm;
+      }
+      return SQLITE_OK;
+    }
+  }
+
+  /* If control flows to here, it was not possible to append zTerm to the
+  ** current node. Create a new node (a right-sibling of the current node).
+  ** If this is the first node in the tree, the term is added to it.
+  **
+  ** Otherwise, the term is not added to the new node, it is left empty for
+  ** now. Instead, the term is inserted into the parent of pTree. If pTree 
+  ** has no parent, one is created here.
+  */
+  pNew = (SegmentNode *)sqlite3_malloc(sizeof(SegmentNode) + p->nNodeSize);
+  if( !pNew ){
+    return SQLITE_NOMEM;
+  }
+  memset(pNew, 0, sizeof(SegmentNode));
+  pNew->nData = 1 + FTS3_VARINT_MAX;
+  pNew->aData = (char *)&pNew[1];
+
+  if( pTree ){
+    SegmentNode *pParent = pTree->pParent;
+    rc = fts3NodeAddTerm(p, &pParent, isCopyTerm, zTerm, nTerm);
+    if( pTree->pParent==0 ){
+      pTree->pParent = pParent;
+    }
+    pTree->pRight = pNew;
+    pNew->pLeftmost = pTree->pLeftmost;
+    pNew->pParent = pParent;
+    pNew->zMalloc = pTree->zMalloc;
+    pNew->nMalloc = pTree->nMalloc;
+    pTree->zMalloc = 0;
+  }else{
+    pNew->pLeftmost = pNew;
+    rc = fts3NodeAddTerm(p, &pNew, isCopyTerm, zTerm, nTerm); 
+  }
+
+  *ppTree = pNew;
+  return rc;
+}
+
+/*
+** Helper function for fts3NodeWrite().
+*/
+static int fts3TreeFinishNode(
+  SegmentNode *pTree, 
+  int iHeight, 
+  sqlite3_int64 iLeftChild
+){
+  int nStart;
+  assert( iHeight>=1 && iHeight<128 );
+  nStart = FTS3_VARINT_MAX - sqlite3Fts3VarintLen(iLeftChild);
+  pTree->aData[nStart] = (char)iHeight;
+  sqlite3Fts3PutVarint(&pTree->aData[nStart+1], iLeftChild);
+  return nStart;
+}
+
+/*
+** Write the buffer for the segment node pTree and all of its peers to the
+** database. Then call this function recursively to write the parent of 
+** pTree and its peers to the database. 
+**
+** Except, if pTree is a root node, do not write it to the database. Instead,
+** set output variables *paRoot and *pnRoot to contain the root node.
+**
+** If successful, SQLITE_OK is returned and output variable *piLast is
+** set to the largest blockid written to the database (or zero if no
+** blocks were written to the db). Otherwise, an SQLite error code is 
+** returned.
+*/
+static int fts3NodeWrite(
+  Fts3Table *p,                   /* Virtual table handle */
+  SegmentNode *pTree,             /* SegmentNode handle */
+  int iHeight,                    /* Height of this node in tree */
+  sqlite3_int64 iLeaf,            /* Block id of first leaf node */
+  sqlite3_int64 iFree,            /* Block id of next free slot in %_segments */
+  sqlite3_int64 *piLast,          /* OUT: Block id of last entry written */
+  char **paRoot,                  /* OUT: Data for root node */
+  int *pnRoot                     /* OUT: Size of root node in bytes */
+){
+  int rc = SQLITE_OK;
+
+  if( !pTree->pParent ){
+    /* Root node of the tree. */
+    int nStart = fts3TreeFinishNode(pTree, iHeight, iLeaf);
+    *piLast = iFree-1;
+    *pnRoot = pTree->nData - nStart;
+    *paRoot = &pTree->aData[nStart];
+  }else{
+    SegmentNode *pIter;
+    sqlite3_int64 iNextFree = iFree;
+    sqlite3_int64 iNextLeaf = iLeaf;
+    for(pIter=pTree->pLeftmost; pIter && rc==SQLITE_OK; pIter=pIter->pRight){
+      int nStart = fts3TreeFinishNode(pIter, iHeight, iNextLeaf);
+      int nWrite = pIter->nData - nStart;
+  
+      rc = fts3WriteSegment(p, iNextFree, &pIter->aData[nStart], nWrite);
+      iNextFree++;
+      iNextLeaf += (pIter->nEntry+1);
+    }
+    if( rc==SQLITE_OK ){
+      assert( iNextLeaf==iFree );
+      rc = fts3NodeWrite(
+          p, pTree->pParent, iHeight+1, iFree, iNextFree, piLast, paRoot, pnRoot
+      );
+    }
+  }
+
+  return rc;
+}
+
+/*
+** Free all memory allocations associated with the tree pTree.
+*/
+static void fts3NodeFree(SegmentNode *pTree){
+  if( pTree ){
+    SegmentNode *p = pTree->pLeftmost;
+    fts3NodeFree(p->pParent);
+    while( p ){
+      SegmentNode *pRight = p->pRight;
+      if( p->aData!=(char *)&p[1] ){
+        sqlite3_free(p->aData);
+      }
+      assert( pRight==0 || p->zMalloc==0 );
+      sqlite3_free(p->zMalloc);
+      sqlite3_free(p);
+      p = pRight;
+    }
+  }
+}
+
+/*
+** Add a term to the segment being constructed by the SegmentWriter object
+** *ppWriter. When adding the first term to a segment, *ppWriter should
+** be passed NULL. This function will allocate a new SegmentWriter object
+** and return it via the input/output variable *ppWriter in this case.
+**
+** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.
+*/
+static int fts3SegWriterAdd(
+  Fts3Table *p,                   /* Virtual table handle */
+  SegmentWriter **ppWriter,       /* IN/OUT: SegmentWriter handle */ 
+  int isCopyTerm,                 /* True if buffer zTerm must be copied */
+  const char *zTerm,              /* Pointer to buffer containing term */
+  int nTerm,                      /* Size of term in bytes */
+  const char *aDoclist,           /* Pointer to buffer containing doclist */
+  int nDoclist                    /* Size of doclist in bytes */
+){
+  int nPrefix;                    /* Size of term prefix in bytes */
+  int nSuffix;                    /* Size of term suffix in bytes */
+  int nReq;                       /* Number of bytes required on leaf page */
+  int nData;
+  SegmentWriter *pWriter = *ppWriter;
+
+  if( !pWriter ){
+    int rc;
+    sqlite3_stmt *pStmt;
+
+    /* Allocate the SegmentWriter structure */
+    pWriter = (SegmentWriter *)sqlite3_malloc(sizeof(SegmentWriter));
+    if( !pWriter ) return SQLITE_NOMEM;
+    memset(pWriter, 0, sizeof(SegmentWriter));
+    *ppWriter = pWriter;
+
+    /* Allocate a buffer in which to accumulate data */
+    pWriter->aData = (char *)sqlite3_malloc(p->nNodeSize);
+    if( !pWriter->aData ) return SQLITE_NOMEM;
+    pWriter->nSize = p->nNodeSize;
+
+    /* Find the next free blockid in the %_segments table */
+    rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pStmt, 0);
+    if( rc!=SQLITE_OK ) return rc;
+    if( SQLITE_ROW==sqlite3_step(pStmt) ){
+      pWriter->iFree = sqlite3_column_int64(pStmt, 0);
+      pWriter->iFirst = pWriter->iFree;
+    }
+    rc = sqlite3_reset(pStmt);
+    if( rc!=SQLITE_OK ) return rc;
+  }
+  nData = pWriter->nData;
+
+  nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm);
+  nSuffix = nTerm-nPrefix;
+
+  /* Figure out how many bytes are required by this new entry */
+  nReq = sqlite3Fts3VarintLen(nPrefix) +    /* varint containing prefix size */
+    sqlite3Fts3VarintLen(nSuffix) +         /* varint containing suffix size */
+    nSuffix +                               /* Term suffix */
+    sqlite3Fts3VarintLen(nDoclist) +        /* Size of doclist */
+    nDoclist;                               /* Doclist data */
+
+  if( nData>0 && nData+nReq>p->nNodeSize ){
+    int rc;
+
+    /* The current leaf node is full. Write it out to the database. */
+    rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
+    if( rc!=SQLITE_OK ) return rc;
+
+    /* Add the current term to the interior node tree. The term added to
+    ** the interior tree must:
+    **
+    **   a) be greater than the largest term on the leaf node just written
+    **      to the database (still available in pWriter->zTerm), and
+    **
+    **   b) be less than or equal to the term about to be added to the new
+    **      leaf node (zTerm/nTerm).
+    **
+    ** In other words, it must be the prefix of zTerm 1 byte longer than
+    ** the common prefix (if any) of zTerm and pWriter->zTerm.
+    */
+    assert( nPrefix<nTerm );
+    rc = fts3NodeAddTerm(p, &pWriter->pTree, isCopyTerm, zTerm, nPrefix+1);
+    if( rc!=SQLITE_OK ) return rc;
+
+    nData = 0;
+    pWriter->nTerm = 0;
+
+    nPrefix = 0;
+    nSuffix = nTerm;
+    nReq = 1 +                              /* varint containing prefix size */
+      sqlite3Fts3VarintLen(nTerm) +         /* varint containing suffix size */
+      nTerm +                               /* Term suffix */
+      sqlite3Fts3VarintLen(nDoclist) +      /* Size of doclist */
+      nDoclist;                             /* Doclist data */
+  }
+
+  /* If the buffer currently allocated is too small for this entry, realloc
+  ** the buffer to make it large enough.
+  */
+  if( nReq>pWriter->nSize ){
+    char *aNew = sqlite3_realloc(pWriter->aData, nReq);
+    if( !aNew ) return SQLITE_NOMEM;
+    pWriter->aData = aNew;
+    pWriter->nSize = nReq;
+  }
+  assert( nData+nReq<=pWriter->nSize );
+
+  /* Append the prefix-compressed term and doclist to the buffer. */
+  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix);
+  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix);
+  memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix);
+  nData += nSuffix;
+  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist);
+  memcpy(&pWriter->aData[nData], aDoclist, nDoclist);
+  pWriter->nData = nData + nDoclist;
+
+  /* Save the current term so that it can be used to prefix-compress the next.
+  ** If the isCopyTerm parameter is true, then the buffer pointed to by
+  ** zTerm is transient, so take a copy of the term data. Otherwise, just
+  ** store a copy of the pointer.
+  */
+  if( isCopyTerm ){
+    if( nTerm>pWriter->nMalloc ){
+      char *zNew = sqlite3_realloc(pWriter->zMalloc, nTerm*2);
+      if( !zNew ){
+        return SQLITE_NOMEM;
+      }
+      pWriter->nMalloc = nTerm*2;
+      pWriter->zMalloc = zNew;
+      pWriter->zTerm = zNew;
+    }
+    assert( pWriter->zTerm==pWriter->zMalloc );
+    memcpy(pWriter->zTerm, zTerm, nTerm);
+  }else{
+    pWriter->zTerm = (char *)zTerm;
+  }
+  pWriter->nTerm = nTerm;
+
+  return SQLITE_OK;
+}
+
+/*
+** Flush all data associated with the SegmentWriter object pWriter to the
+** database. This function must be called after all terms have been added
+** to the segment using fts3SegWriterAdd(). If successful, SQLITE_OK is
+** returned. Otherwise, an SQLite error code.
+*/
+static int fts3SegWriterFlush(
+  Fts3Table *p,                   /* Virtual table handle */
+  SegmentWriter *pWriter,         /* SegmentWriter to flush to the db */
+  int iLevel,                     /* Value for 'level' column of %_segdir */
+  int iIdx                        /* Value for 'idx' column of %_segdir */
+){
+  int rc;                         /* Return code */
+  if( pWriter->pTree ){
+    sqlite3_int64 iLast = 0;      /* Largest block id written to database */
+    sqlite3_int64 iLastLeaf;      /* Largest leaf block id written to db */
+    char *zRoot = NULL;           /* Pointer to buffer containing root node */
+    int nRoot = 0;                /* Size of buffer zRoot */
+
+    iLastLeaf = pWriter->iFree;
+    rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, pWriter->nData);
+    if( rc==SQLITE_OK ){
+      rc = fts3NodeWrite(p, pWriter->pTree, 1,
+          pWriter->iFirst, pWriter->iFree, &iLast, &zRoot, &nRoot);
+    }
+    if( rc==SQLITE_OK ){
+      rc = fts3WriteSegdir(
+          p, iLevel, iIdx, pWriter->iFirst, iLastLeaf, iLast, zRoot, nRoot);
+    }
+  }else{
+    /* The entire tree fits on the root node. Write it to the segdir table. */
+    rc = fts3WriteSegdir(
+        p, iLevel, iIdx, 0, 0, 0, pWriter->aData, pWriter->nData);
+  }
+  return rc;
+}
+
+/*
+** Release all memory held by the SegmentWriter object passed as the 
+** first argument.
+*/
+static void fts3SegWriterFree(SegmentWriter *pWriter){
+  if( pWriter ){
+    sqlite3_free(pWriter->aData);
+    sqlite3_free(pWriter->zMalloc);
+    fts3NodeFree(pWriter->pTree);
+    sqlite3_free(pWriter);
+  }
+}
+
+/*
+** The first value in the apVal[] array is assumed to contain an integer.
+** This function tests if there exist any documents with docid values that
+** are different from that integer. i.e. if deleting the document with docid
+** apVal[0] would mean the FTS3 table were empty.
+**
+** If successful, *pisEmpty is set to true if the table is empty except for
+** document apVal[0], or false otherwise, and SQLITE_OK is returned. If an
+** error occurs, an SQLite error code is returned.
+*/
+static int fts3IsEmpty(Fts3Table *p, sqlite3_value **apVal, int *pisEmpty){
+  sqlite3_stmt *pStmt;
+  int rc;
+  rc = fts3SqlStmt(p, SQL_IS_EMPTY, &pStmt, apVal);
+  if( rc==SQLITE_OK ){
+    if( SQLITE_ROW==sqlite3_step(pStmt) ){
+      *pisEmpty = sqlite3_column_int(pStmt, 0);
+    }
+    rc = sqlite3_reset(pStmt);
+  }
+  return rc;
+}
+
+/*
+** Set *pnSegment to the number of segments of level iLevel in the database.
+**
+** Return SQLITE_OK if successful, or an SQLite error code if not.
+*/
+static int fts3SegmentCount(Fts3Table *p, int iLevel, int *pnSegment){
+  sqlite3_stmt *pStmt;
+  int rc;
+
+  assert( iLevel>=0 );
+  rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_COUNT, &pStmt, 0);
+  if( rc!=SQLITE_OK ) return rc;
+  sqlite3_bind_int(pStmt, 1, iLevel);
+  if( SQLITE_ROW==sqlite3_step(pStmt) ){
+    *pnSegment = sqlite3_column_int(pStmt, 0);
+  }
+  return sqlite3_reset(pStmt);
+}
+
+/*
+** Set *pnSegment to the total number of segments in the database. Set
+** *pnMax to the largest segment level in the database (segment levels
+** are stored in the 'level' column of the %_segdir table).
+**
+** Return SQLITE_OK if successful, or an SQLite error code if not.
+*/
+static int fts3SegmentCountMax(Fts3Table *p, int *pnSegment, int *pnMax){
+  sqlite3_stmt *pStmt;
+  int rc;
+
+  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_COUNT_MAX, &pStmt, 0);
+  if( rc!=SQLITE_OK ) return rc;
+  if( SQLITE_ROW==sqlite3_step(pStmt) ){
+    *pnSegment = sqlite3_column_int(pStmt, 0);
+    *pnMax = sqlite3_column_int(pStmt, 1);
+  }
+  return sqlite3_reset(pStmt);
+}
+
+/*
+** This function is used after merging multiple segments into a single large
+** segment to delete the old, now redundant, segment b-trees. Specifically,
+** it:
+** 
+**   1) Deletes all %_segments entries for the segments associated with 
+**      each of the SegReader objects in the array passed as the third 
+**      argument, and
+**
+**   2) deletes all %_segdir entries with level iLevel, or all %_segdir
+**      entries regardless of level if (iLevel<0).
+**
+** SQLITE_OK is returned if successful, otherwise an SQLite error code.
+*/
+static int fts3DeleteSegdir(
+  Fts3Table *p,                   /* Virtual table handle */
+  int iLevel,                     /* Level of %_segdir entries to delete */
+  Fts3SegReader **apSegment,      /* Array of SegReader objects */
+  int nReader                     /* Size of array apSegment */
+){
+  int rc;                         /* Return Code */
+  int i;                          /* Iterator variable */
+  sqlite3_stmt *pDelete;          /* SQL statement to delete rows */
+
+  rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);
+  for(i=0; rc==SQLITE_OK && i<nReader; i++){
+    Fts3SegReader *pSegment = apSegment[i];
+    if( pSegment->iStartBlock ){
+      sqlite3_bind_int64(pDelete, 1, pSegment->iStartBlock);
+      sqlite3_bind_int64(pDelete, 2, pSegment->iEndBlock);
+      sqlite3_step(pDelete);
+      rc = sqlite3_reset(pDelete);
+    }
+  }
+  if( rc!=SQLITE_OK ){
+    return rc;
+  }
+
+  if( iLevel>=0 ){
+    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_BY_LEVEL, &pDelete, 0);
+    if( rc==SQLITE_OK ){
+      sqlite3_bind_int(pDelete, 1, iLevel);
+      sqlite3_step(pDelete);
+      rc = sqlite3_reset(pDelete);
+    }
+  }else{
+    rc = fts3SqlExec(p, SQL_DELETE_ALL_SEGDIR, 0);
+  }
+
+  return rc;
+}
+
+/*
+** When this function is called, buffer *ppList (size *pnList bytes) contains 
+** a position list that may (or may not) feature multiple columns. This
+** function adjusts the pointer *ppList and the length *pnList so that they
+** identify the subset of the position list that corresponds to column iCol.
+**
+** If there are no entries in the input position list for column iCol, then
+** *pnList is set to zero before returning.
+*/
+static void fts3ColumnFilter(
+  int iCol,                       /* Column to filter on */
+  char **ppList,                  /* IN/OUT: Pointer to position list */
+  int *pnList                     /* IN/OUT: Size of buffer *ppList in bytes */
+){
+  char *pList = *ppList;
+  int nList = *pnList;
+  char *pEnd = &pList[nList];
+  int iCurrent = 0;
+  char *p = pList;
+
+  assert( iCol>=0 );
+  while( 1 ){
+    char c = 0;
+    while( p<pEnd && (c | *p)&0xFE ) c = *p++ & 0x80;
+  
+    if( iCol==iCurrent ){
+      nList = (int)(p - pList);
+      break;
+    }
+
+    nList -= (int)(p - pList);
+    pList = p;
+    if( nList==0 ){
+      break;
+    }
+    p = &pList[1];
+    p += sqlite3Fts3GetVarint32(p, &iCurrent);
+  }
+
+  *ppList = pList;
+  *pnList = nList;
+}
+
+/*
+** sqlite3Fts3SegReaderIterate() callback used when merging multiple 
+** segments to create a single, larger segment.
+*/
+static int fts3MergeCallback(
+  Fts3Table *p,                   /* FTS3 Virtual table handle */
+  void *pContext,                 /* Pointer to SegmentWriter* to write with */
+  char *zTerm,                    /* Term to write to the db */
+  int nTerm,                      /* Number of bytes in zTerm */
+  char *aDoclist,                 /* Doclist associated with zTerm */
+  int nDoclist                    /* Number of bytes in doclist */
+){
+  SegmentWriter **ppW = (SegmentWriter **)pContext;
+  return fts3SegWriterAdd(p, ppW, 1, zTerm, nTerm, aDoclist, nDoclist);
+}
+
+/*
+** sqlite3Fts3SegReaderIterate() callback used when flushing the contents
+** of the pending-terms hash table to the database.
+*/
+static int fts3FlushCallback(
+  Fts3Table *p,                   /* FTS3 Virtual table handle */
+  void *pContext,                 /* Pointer to SegmentWriter* to write with */
+  char *zTerm,                    /* Term to write to the db */
+  int nTerm,                      /* Number of bytes in zTerm */
+  char *aDoclist,                 /* Doclist associated with zTerm */
+  int nDoclist                    /* Number of bytes in doclist */
+){
+  SegmentWriter **ppW = (SegmentWriter **)pContext;
+  return fts3SegWriterAdd(p, ppW, 0, zTerm, nTerm, aDoclist, nDoclist);
+}
+
+/*
+** This function is used to iterate through a contiguous set of terms 
+** stored in the full-text index. It merges data contained in one or 
+** more segments to support this.
+**
+** The second argument is passed an array of pointers to SegReader objects
+** allocated with sqlite3Fts3SegReaderNew(). This function merges the range 
+** of terms selected by each SegReader. If a single term is present in
+** more than one segment, the associated doclists are merged. For each
+** term and (possibly merged) doclist in the merged range, the callback
+** function xFunc is invoked with its arguments set as follows.
+**
+**   arg 0: Copy of 'p' parameter passed to this function
+**   arg 1: Copy of 'pContext' parameter passed to this function
+**   arg 2: Pointer to buffer containing term
+**   arg 3: Size of arg 2 buffer in bytes
+**   arg 4: Pointer to buffer containing doclist
+**   arg 5: Size of arg 2 buffer in bytes
+**
+** The 4th argument to this function is a pointer to a structure of type
+** Fts3SegFilter, defined in fts3Int.h. The contents of this structure
+** further restrict the range of terms that callbacks are made for and
+** modify the behaviour of this function. See comments above structure
+** definition for details.
+*/
+SQLITE_PRIVATE int sqlite3Fts3SegReaderIterate(
+  Fts3Table *p,                   /* Virtual table handle */
+  Fts3SegReader **apSegment,      /* Array of Fts3SegReader objects */
+  int nSegment,                   /* Size of apSegment array */
+  Fts3SegFilter *pFilter,         /* Restrictions on range of iteration */
+  int (*xFunc)(Fts3Table *, void *, char *, int, char *, int),  /* Callback */
+  void *pContext                  /* Callback context (2nd argument) */
+){
+  int i;                          /* Iterator variable */
+  char *aBuffer = 0;              /* Buffer to merge doclists in */
+  int nAlloc = 0;                 /* Allocated size of aBuffer buffer */
+  int rc = SQLITE_OK;             /* Return code */
+
+  int isIgnoreEmpty =  (pFilter->flags & FTS3_SEGMENT_IGNORE_EMPTY);
+  int isRequirePos =   (pFilter->flags & FTS3_SEGMENT_REQUIRE_POS);
+  int isColFilter =    (pFilter->flags & FTS3_SEGMENT_COLUMN_FILTER);
+  int isPrefix =       (pFilter->flags & FTS3_SEGMENT_PREFIX);
+
+  /* If there are zero segments, this function is a no-op. This scenario
+  ** comes about only when reading from an empty database.
+  */
+  if( nSegment==0 ) goto finished;
+
+  /* If the Fts3SegFilter defines a specific term (or term prefix) to search 
+  ** for, then advance each segment iterator until it points to a term of
+  ** equal or greater value than the specified term. This prevents many
+  ** unnecessary merge/sort operations for the case where single segment
+  ** b-tree leaf nodes contain more than one term.
+  */
+  if( pFilter->zTerm ){
+    int nTerm = pFilter->nTerm;
+    const char *zTerm = pFilter->zTerm;
+    for(i=0; i<nSegment; i++){
+      Fts3SegReader *pSeg = apSegment[i];
+      while( fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ){
+        rc = fts3SegReaderNext(pSeg);
+        if( rc!=SQLITE_OK ) goto finished; }
+    }
+  }
+
+  fts3SegReaderSort(apSegment, nSegment, nSegment, fts3SegReaderCmp);
+  while( apSegment[0]->aNode ){
+    int nTerm = apSegment[0]->nTerm;
+    char *zTerm = apSegment[0]->zTerm;
+    int nMerge = 1;
+
+    /* If this is a prefix-search, and if the term that apSegment[0] points
+    ** to does not share a suffix with pFilter->zTerm/nTerm, then all 
+    ** required callbacks have been made. In this case exit early.
+    **
+    ** Similarly, if this is a search for an exact match, and the first term
+    ** of segment apSegment[0] is not a match, exit early.
+    */
+    if( pFilter->zTerm ){
+      if( nTerm<pFilter->nTerm 
+       || (!isPrefix && nTerm>pFilter->nTerm)
+       || memcmp(zTerm, pFilter->zTerm, pFilter->nTerm) 
+    ){
+        goto finished;
+      }
+    }
+
+    while( nMerge<nSegment 
+        && apSegment[nMerge]->aNode
+        && apSegment[nMerge]->nTerm==nTerm 
+        && 0==memcmp(zTerm, apSegment[nMerge]->zTerm, nTerm)
+    ){
+      nMerge++;
+    }
+
+    assert( isIgnoreEmpty || (isRequirePos && !isColFilter) );
+    if( nMerge==1 && !isIgnoreEmpty ){
+      Fts3SegReader *p0 = apSegment[0];
+      rc = xFunc(p, pContext, zTerm, nTerm, p0->aDoclist, p0->nDoclist);
+      if( rc!=SQLITE_OK ) goto finished;
+    }else{
+      int nDoclist = 0;           /* Size of doclist */
+      sqlite3_int64 iPrev = 0;    /* Previous docid stored in doclist */
+
+      /* The current term of the first nMerge entries in the array
+      ** of Fts3SegReader objects is the same. The doclists must be merged
+      ** and a single term added to the new segment.
+      */
+      for(i=0; i<nMerge; i++){
+        fts3SegReaderFirstDocid(apSegment[i]);
+      }
+      fts3SegReaderSort(apSegment, nMerge, nMerge, fts3SegReaderDoclistCmp);
+      while( apSegment[0]->pOffsetList ){
+        int j;                    /* Number of segments that share a docid */
+        char *pList;
+        int nList;
+        int nByte;
+        sqlite3_int64 iDocid = apSegment[0]->iDocid;
+        fts3SegReaderNextDocid(apSegment[0], &pList, &nList);
+        j = 1;
+        while( j<nMerge
+            && apSegment[j]->pOffsetList
+            && apSegment[j]->iDocid==iDocid
+        ){
+          fts3SegReaderNextDocid(apSegment[j], 0, 0);
+          j++;
+        }
+
+        if( isColFilter ){
+          fts3ColumnFilter(pFilter->iCol, &pList, &nList);
+        }
+
+        if( !isIgnoreEmpty || nList>0 ){
+          nByte = sqlite3Fts3VarintLen(iDocid-iPrev) + (isRequirePos?nList+1:0);
+          if( nDoclist+nByte>nAlloc ){
+            char *aNew;
+            nAlloc = nDoclist+nByte*2;
+            aNew = sqlite3_realloc(aBuffer, nAlloc);
+            if( !aNew ){
+              rc = SQLITE_NOMEM;
+              goto finished;
+            }
+            aBuffer = aNew;
+          }
+          nDoclist += sqlite3Fts3PutVarint(&aBuffer[nDoclist], iDocid-iPrev);
+          iPrev = iDocid;
+          if( isRequirePos ){
+            memcpy(&aBuffer[nDoclist], pList, nList);
+            nDoclist += nList;
+            aBuffer[nDoclist++] = '\0';
+          }
+        }
+
+        fts3SegReaderSort(apSegment, nMerge, j, fts3SegReaderDoclistCmp);
+      }
+
+      if( nDoclist>0 ){
+        rc = xFunc(p, pContext, zTerm, nTerm, aBuffer, nDoclist);
+        if( rc!=SQLITE_OK ) goto finished;
+      }
+    }
+
+    /* If there is a term specified to filter on, and this is not a prefix
+    ** search, return now. The callback that corresponds to the required
+    ** term (if such a term exists in the index) has already been made.
+    */
+    if( pFilter->zTerm && !isPrefix ){
+      goto finished;
+    }
+
+    for(i=0; i<nMerge; i++){
+      rc = fts3SegReaderNext(apSegment[i]);
+      if( rc!=SQLITE_OK ) goto finished;
+    }
+    fts3SegReaderSort(apSegment, nSegment, nMerge, fts3SegReaderCmp);
+  }
+
+ finished:
+  sqlite3_free(aBuffer);
+  return rc;
+}
+
+/*
+** Merge all level iLevel segments in the database into a single 
+** iLevel+1 segment. Or, if iLevel<0, merge all segments into a
+** single segment with a level equal to the numerically largest level 
+** currently present in the database.
+**
+** If this function is called with iLevel<0, but there is only one
+** segment in the database, SQLITE_DONE is returned immediately. 
+** Otherwise, if successful, SQLITE_OK is returned. If an error occurs, 
+** an SQLite error code is returned.
+*/
+static int fts3SegmentMerge(Fts3Table *p, int iLevel){
+  int i;                          /* Iterator variable */
+  int rc;                         /* Return code */
+  int iIdx;                       /* Index of new segment */
+  int iNewLevel;                  /* Level to create new segment at */
+  sqlite3_stmt *pStmt = 0;
+  SegmentWriter *pWriter = 0;
+  int nSegment = 0;               /* Number of segments being merged */
+  Fts3SegReader **apSegment = 0;  /* Array of Segment iterators */
+  Fts3SegReader *pPending = 0;    /* Iterator for pending-terms */
+  Fts3SegFilter filter;           /* Segment term filter condition */
+
+  if( iLevel<0 ){
+    /* This call is to merge all segments in the database to a single
+    ** segment. The level of the new segment is equal to the the numerically 
+    ** greatest segment level currently present in the database. The index
+    ** of the new segment is always 0.
+    */
+    iIdx = 0;
+    rc = sqlite3Fts3SegReaderPending(p, 0, 0, 1, &pPending);
+    if( rc!=SQLITE_OK ) goto finished;
+    rc = fts3SegmentCountMax(p, &nSegment, &iNewLevel);
+    if( rc!=SQLITE_OK ) goto finished;
+    nSegment += (pPending!=0);
+    if( nSegment<=1 ){
+      return SQLITE_DONE;
+    }
+  }else{
+    /* This call is to merge all segments at level iLevel. Find the next
+    ** available segment index at level iLevel+1. The call to
+    ** fts3AllocateSegdirIdx() will merge the segments at level iLevel+1 to 
+    ** a single iLevel+2 segment if necessary.
+    */
+    iNewLevel = iLevel+1;
+    rc = fts3AllocateSegdirIdx(p, iNewLevel, &iIdx);
+    if( rc!=SQLITE_OK ) goto finished;
+    rc = fts3SegmentCount(p, iLevel, &nSegment);
+    if( rc!=SQLITE_OK ) goto finished;
+  }
+  assert( nSegment>0 );
+  assert( iNewLevel>=0 );
+
+  /* Allocate space for an array of pointers to segment iterators. */
+  apSegment = (Fts3SegReader**)sqlite3_malloc(sizeof(Fts3SegReader *)*nSegment);
+  if( !apSegment ){
+    rc = SQLITE_NOMEM;
+    goto finished;
+  }
+  memset(apSegment, 0, sizeof(Fts3SegReader *)*nSegment);
+
+  /* Allocate a Fts3SegReader structure for each segment being merged. A 
+  ** Fts3SegReader stores the state data required to iterate through all 
+  ** entries on all leaves of a single segment. 
+  */
+  assert( SQL_SELECT_LEVEL+1==SQL_SELECT_ALL_LEVEL);
+  rc = fts3SqlStmt(p, SQL_SELECT_LEVEL+(iLevel<0), &pStmt, 0);
+  if( rc!=SQLITE_OK ) goto finished;
+  sqlite3_bind_int(pStmt, 1, iLevel);
+  for(i=0; SQLITE_ROW==(sqlite3_step(pStmt)); i++){
+    rc = fts3SegReaderNew(p, pStmt, i, &apSegment[i]);
+    if( rc!=SQLITE_OK ){
+      goto finished;
+    }
+  }
+  rc = sqlite3_reset(pStmt);
+  if( pPending ){
+    apSegment[i] = pPending;
+    pPending = 0;
+  }
+  pStmt = 0;
+  if( rc!=SQLITE_OK ) goto finished;
+
+  memset(&filter, 0, sizeof(Fts3SegFilter));
+  filter.flags = FTS3_SEGMENT_REQUIRE_POS;
+  filter.flags |= (iLevel<0 ? FTS3_SEGMENT_IGNORE_EMPTY : 0);
+  rc = sqlite3Fts3SegReaderIterate(p, apSegment, nSegment,
+      &filter, fts3MergeCallback, (void *)&pWriter
+  );
+  if( rc!=SQLITE_OK ) goto finished;
+
+  rc = fts3DeleteSegdir(p, iLevel, apSegment, nSegment);
+  if( rc==SQLITE_OK ){
+    rc = fts3SegWriterFlush(p, pWriter, iNewLevel, iIdx);
+  }
+
+ finished:
+  fts3SegWriterFree(pWriter);
+  if( apSegment ){
+    for(i=0; i<nSegment; i++){
+      sqlite3Fts3SegReaderFree(p, apSegment[i]);
+    }
+    sqlite3_free(apSegment);
+  }
+  sqlite3Fts3SegReaderFree(p, pPending);
+  sqlite3_reset(pStmt);
+  return rc;
+}
+
+
+/* 
+** Flush the contents of pendingTerms to a level 0 segment.
+*/
+SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
+  int rc;                         /* Return Code */
+  int idx;                        /* Index of new segment created */
+  SegmentWriter *pWriter = 0;     /* Used to write the segment */
+  Fts3SegReader *pReader = 0;     /* Used to iterate through the hash table */
+
+  /* Allocate a SegReader object to iterate through the contents of the
+  ** pending-terms table. If an error occurs, or if there are no terms
+  ** in the pending-terms table, return immediately.
+  */
+  rc = sqlite3Fts3SegReaderPending(p, 0, 0, 1, &pReader);
+  if( rc!=SQLITE_OK || pReader==0 ){
+    return rc;
+  }
+
+  /* Determine the next index at level 0. If level 0 is already full, this
+  ** call may merge all existing level 0 segments into a single level 1
+  ** segment.
+  */
+  rc = fts3AllocateSegdirIdx(p, 0, &idx);
+
+  /* If no errors have occured, iterate through the contents of the 
+  ** pending-terms hash table using the Fts3SegReader iterator. The callback
+  ** writes each term (along with its doclist) to the database via the
+  ** SegmentWriter handle pWriter.
+  */
+  if( rc==SQLITE_OK ){
+    void *c = (void *)&pWriter;   /* SegReaderIterate() callback context */
+    Fts3SegFilter f;              /* SegReaderIterate() parameters */
+
+    memset(&f, 0, sizeof(Fts3SegFilter));
+    f.flags = FTS3_SEGMENT_REQUIRE_POS;
+    rc = sqlite3Fts3SegReaderIterate(p, &pReader, 1, &f, fts3FlushCallback, c);
+  }
+  assert( pWriter || rc!=SQLITE_OK );
+
+  /* If no errors have occured, flush the SegmentWriter object to the
+  ** database. Then delete the SegmentWriter and Fts3SegReader objects
+  ** allocated by this function.
+  */
+  if( rc==SQLITE_OK ){
+    rc = fts3SegWriterFlush(p, pWriter, 0, idx);
+  }
+  fts3SegWriterFree(pWriter);
+  sqlite3Fts3SegReaderFree(p, pReader);
+
+  if( rc==SQLITE_OK ){
+    sqlite3Fts3PendingTermsClear(p);
+  }
+  return rc;
+}
+
+/*
+** Handle a 'special' INSERT of the form:
+**
+**   "INSERT INTO tbl(tbl) VALUES(<expr>)"
+**
+** Argument pVal contains the result of <expr>. Currently the only 
+** meaningful value to insert is the text 'optimize'.
+*/
+static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){
+  int rc;                         /* Return Code */
+  const char *zVal = (const char *)sqlite3_value_text(pVal);
+  int nVal = sqlite3_value_bytes(pVal);
+
+  if( !zVal ){
+    return SQLITE_NOMEM;
+  }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){
+    rc = fts3SegmentMerge(p, -1);
+    if( rc==SQLITE_DONE ){
+      rc = SQLITE_OK;
+    }else{
+      sqlite3Fts3PendingTermsClear(p);
+    }
+#ifdef SQLITE_TEST
+  }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
+    p->nNodeSize = atoi(&zVal[9]);
+    rc = SQLITE_OK;
+  }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
+    p->nMaxPendingData = atoi(&zVal[11]);
+    rc = SQLITE_OK;
+#endif
+  }else{
+    rc = SQLITE_ERROR;
+  }
+
+  return rc;
+}
+
+/*
+** This function does the work for the xUpdate method of FTS3 virtual
+** tables.
+*/
+SQLITE_PRIVATE int sqlite3Fts3UpdateMethod(
+  sqlite3_vtab *pVtab,            /* FTS3 vtab object */
+  int nArg,                       /* Size of argument array */
+  sqlite3_value **apVal,          /* Array of arguments */
+  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */
+){
+  Fts3Table *p = (Fts3Table *)pVtab;
+  int rc = SQLITE_OK;             /* Return Code */
+  int isRemove = 0;               /* True for an UPDATE or DELETE */
+  sqlite3_int64 iRemove = 0;      /* Rowid removed by UPDATE or DELETE */
+
+
+  /* If this is a DELETE or UPDATE operation, remove the old record. */
+  if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
+    int isEmpty;
+    rc = fts3IsEmpty(p, apVal, &isEmpty);
+    if( rc==SQLITE_OK ){
+      if( isEmpty ){
+        /* Deleting this row means the whole table is empty. In this case
+        ** delete the contents of all three tables and throw away any
+        ** data in the pendingTerms hash table.
+        */
+        rc = fts3DeleteAll(p);
+      }else{
+        isRemove = 1;
+        iRemove = sqlite3_value_int64(apVal[0]);
+        rc = fts3PendingTermsDocid(p, iRemove);
+        if( rc==SQLITE_OK ){
+          rc = fts3DeleteTerms(p, apVal);
+          if( rc==SQLITE_OK ){
+            rc = fts3SqlExec(p, SQL_DELETE_CONTENT, apVal);
+          }
+        }
+      }
+    }
+  }else if( sqlite3_value_type(apVal[p->nColumn+2])!=SQLITE_NULL ){
+    return fts3SpecialInsert(p, apVal[p->nColumn+2]);
+  }
+  
+  /* If this is an INSERT or UPDATE operation, insert the new record. */
+  if( nArg>1 && rc==SQLITE_OK ){
+    rc = fts3InsertData(p, apVal, pRowid);
+    if( rc==SQLITE_OK && (!isRemove || *pRowid!=iRemove) ){
+      rc = fts3PendingTermsDocid(p, *pRowid);
+    }
+    if( rc==SQLITE_OK ){
+      rc = fts3InsertTerms(p, apVal);
+    }
+  }
+
+  return rc;
+}
+
+/* 
+** Flush any data in the pending-terms hash table to disk. If successful,
+** merge all segments in the database (including the new segment, if 
+** there was any data to flush) into a single segment. 
+*/
+SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *p){
+  int rc;
+  rc = sqlite3_exec(p->db, "SAVEPOINT fts3", 0, 0, 0);
+  if( rc==SQLITE_OK ){
+    rc = fts3SegmentMerge(p, -1);
+    if( rc==SQLITE_OK ){
+      rc = sqlite3_exec(p->db, "RELEASE fts3", 0, 0, 0);
+      if( rc==SQLITE_OK ){
+        sqlite3Fts3PendingTermsClear(p);
+      }
+    }else{
+      sqlite3_exec(p->db, "ROLLBACK TO fts3", 0, 0, 0);
+      sqlite3_exec(p->db, "RELEASE fts3", 0, 0, 0);
+    }
+  }
+  return rc;
+}
+
+#endif
+
+/************** End of fts3_write.c ******************************************/
+/************** Begin file fts3_snippet.c ************************************/
+/*
+** 2009 Oct 23
+**
+** 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.
+**
+******************************************************************************
+*/
+
+#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
+
+
+typedef struct Snippet Snippet;
+
+/*
+** An instance of the following structure keeps track of generated
+** matching-word offset information and snippets.
+*/
+struct Snippet {
+  int nMatch;                     /* Total number of matches */
+  int nAlloc;                     /* Space allocated for aMatch[] */
+  struct snippetMatch {  /* One entry for each matching term */
+    char snStatus;       /* Status flag for use while constructing snippets */
+    short int nByte;     /* Number of bytes in the term */
+    short int iCol;      /* The column that contains the match */
+    short int iTerm;     /* The index in Query.pTerms[] of the matching term */
+    int iToken;          /* The index of the matching document token */
+    int iStart;          /* The offset to the first character of the term */
+  } *aMatch;                      /* Points to space obtained from malloc */
+  char *zOffset;                  /* Text rendering of aMatch[] */
+  int nOffset;                    /* strlen(zOffset) */
+  char *zSnippet;                 /* Snippet text */
+  int nSnippet;                   /* strlen(zSnippet) */
+};
+
+
+/* It is not safe to call isspace(), tolower(), or isalnum() on
+** hi-bit-set characters.  This is the same solution used in the
+** tokenizer.
+*/
+static int fts3snippetIsspace(char c){
+  return (c&0x80)==0 ? isspace(c) : 0;
+}
+
+
+/*
+** A StringBuffer object holds a zero-terminated string that grows
+** arbitrarily by appending.  Space to hold the string is obtained
+** from sqlite3_malloc().  After any memory allocation failure, 
+** StringBuffer.z is set to NULL and no further allocation is attempted.
+*/
+typedef struct StringBuffer {
+  char *z;         /* Text of the string.  Space from malloc. */
+  int nUsed;       /* Number bytes of z[] used, not counting \000 terminator */
+  int nAlloc;      /* Bytes allocated for z[] */
+} StringBuffer;
+
+
+/*
+** Initialize a new StringBuffer.
+*/
+static void fts3SnippetSbInit(StringBuffer *p){
+  p->nAlloc = 100;
+  p->nUsed = 0;
+  p->z = sqlite3_malloc( p->nAlloc );
+}
+
+/*
+** Append text to the string buffer.
+*/
+static void fts3SnippetAppend(StringBuffer *p, const char *zNew, int nNew){
+  if( p->z==0 ) return;
+  if( nNew<0 ) nNew = (int)strlen(zNew);
+  if( p->nUsed + nNew >= p->nAlloc ){
+    int nAlloc;
+    char *zNew;
+
+    nAlloc = p->nUsed + nNew + p->nAlloc;
+    zNew = sqlite3_realloc(p->z, nAlloc);
+    if( zNew==0 ){
+      sqlite3_free(p->z);
+      p->z = 0;
+      return;
+    }
+    p->z = zNew;
+    p->nAlloc = nAlloc;
+  }
+  memcpy(&p->z[p->nUsed], zNew, nNew);
+  p->nUsed += nNew;
+  p->z[p->nUsed] = 0;
+}
+
+/* If the StringBuffer ends in something other than white space, add a
+** single space character to the end.
+*/
+static void fts3SnippetAppendWhiteSpace(StringBuffer *p){
+  if( p->z && p->nUsed && !fts3snippetIsspace(p->z[p->nUsed-1]) ){
+    fts3SnippetAppend(p, " ", 1);
+  }
+}
+
+/* Remove white space from the end of the StringBuffer */
+static void fts3SnippetTrimWhiteSpace(StringBuffer *p){
+  if( p->z ){
+    while( p->nUsed && fts3snippetIsspace(p->z[p->nUsed-1]) ){
+      p->nUsed--;
+    }
+    p->z[p->nUsed] = 0;
+  }
+}
+
+/* 
+** Release all memory associated with the Snippet structure passed as
+** an argument.
+*/
+static void fts3SnippetFree(Snippet *p){
+  if( p ){
+    sqlite3_free(p->aMatch);
+    sqlite3_free(p->zOffset);
+    sqlite3_free(p->zSnippet);
+    sqlite3_free(p);
+  }
+}
+
+/*
+** Append a single entry to the p->aMatch[] log.
+*/
+static int snippetAppendMatch(
+  Snippet *p,               /* Append the entry to this snippet */
+  int iCol, int iTerm,      /* The column and query term */
+  int iToken,               /* Matching token in document */
+  int iStart, int nByte     /* Offset and size of the match */
+){
+  int i;
+  struct snippetMatch *pMatch;
+  if( p->nMatch+1>=p->nAlloc ){
+    struct snippetMatch *pNew;
+    p->nAlloc = p->nAlloc*2 + 10;
+    pNew = sqlite3_realloc(p->aMatch, p->nAlloc*sizeof(p->aMatch[0]) );
+    if( pNew==0 ){
+      p->aMatch = 0;
+      p->nMatch = 0;
+      p->nAlloc = 0;
+      return SQLITE_NOMEM;
+    }
+    p->aMatch = pNew;
+  }
+  i = p->nMatch++;
+  pMatch = &p->aMatch[i];
+  pMatch->iCol = (short)iCol;
+  pMatch->iTerm = (short)iTerm;
+  pMatch->iToken = iToken;
+  pMatch->iStart = iStart;
+  pMatch->nByte = (short)nByte;
+  return SQLITE_OK;
+}
+
+/*
+** Sizing information for the circular buffer used in snippetOffsetsOfColumn()
+*/
+#define FTS3_ROTOR_SZ   (32)
+#define FTS3_ROTOR_MASK (FTS3_ROTOR_SZ-1)
+
+/*
+** Function to iterate through the tokens of a compiled expression.
+**
+** Except, skip all tokens on the right-hand side of a NOT operator.
+** This function is used to find tokens as part of snippet and offset
+** generation and we do nt want snippets and offsets to report matches
+** for tokens on the RHS of a NOT.
+*/
+static int fts3NextExprToken(Fts3Expr **ppExpr, int *piToken){
+  Fts3Expr *p = *ppExpr;
+  int iToken = *piToken;
+  if( iToken<0 ){
+    /* In this case the expression p is the root of an expression tree.
+    ** Move to the first token in the expression tree.
+    */
+    while( p->pLeft ){
+      p = p->pLeft;
+    }
+    iToken = 0;
+  }else{
+    assert(p && p->eType==FTSQUERY_PHRASE );
+    if( iToken<(p->pPhrase->nToken-1) ){
+      iToken++;
+    }else{
+      iToken = 0;
+      while( p->pParent && p->pParent->pLeft!=p ){
+        assert( p->pParent->pRight==p );
+        p = p->pParent;
+      }
+      p = p->pParent;
+      if( p ){
+        assert( p->pRight!=0 );
+        p = p->pRight;
+        while( p->pLeft ){
+          p = p->pLeft;
+        }
+      }
+    }
+  }
+
+  *ppExpr = p;
+  *piToken = iToken;
+  return p?1:0;
+}
+
+/*
+** Return TRUE if the expression node pExpr is located beneath the
+** RHS of a NOT operator.
+*/
+static int fts3ExprBeneathNot(Fts3Expr *p){
+  Fts3Expr *pParent;
+  while( p ){
+    pParent = p->pParent;
+    if( pParent && pParent->eType==FTSQUERY_NOT && pParent->pRight==p ){
+      return 1;
+    }
+    p = pParent;
+  }
+  return 0;
+}
+
+/*
+** Add entries to pSnippet->aMatch[] for every match that occurs against
+** document zDoc[0..nDoc-1] which is stored in column iColumn.
+*/
+static int snippetOffsetsOfColumn(
+  Fts3Cursor *pCur,         /* The fulltest search cursor */
+  Snippet *pSnippet,             /* The Snippet object to be filled in */
+  int iColumn,                   /* Index of fulltext table column */
+  const char *zDoc,              /* Text of the fulltext table column */
+  int nDoc                       /* Length of zDoc in bytes */
+){
+  const sqlite3_tokenizer_module *pTModule;  /* The tokenizer module */
+  sqlite3_tokenizer *pTokenizer;             /* The specific tokenizer */
+  sqlite3_tokenizer_cursor *pTCursor;        /* Tokenizer cursor */
+  Fts3Table *pVtab;                /* The full text index */
+  int nColumn;                         /* Number of columns in the index */
+  int i, j;                            /* Loop counters */
+  int rc;                              /* Return code */
+  unsigned int match, prevMatch;       /* Phrase search bitmasks */
+  const char *zToken;                  /* Next token from the tokenizer */
+  int nToken;                          /* Size of zToken */
+  int iBegin, iEnd, iPos;              /* Offsets of beginning and end */
+
+  /* The following variables keep a circular buffer of the last
+  ** few tokens */
+  unsigned int iRotor = 0;             /* Index of current token */
+  int iRotorBegin[FTS3_ROTOR_SZ];      /* Beginning offset of token */
+  int iRotorLen[FTS3_ROTOR_SZ];        /* Length of token */
+
+  pVtab =  (Fts3Table *)pCur->base.pVtab;
+  nColumn = pVtab->nColumn;
+  pTokenizer = pVtab->pTokenizer;
+  pTModule = pTokenizer->pModule;
+  rc = pTModule->xOpen(pTokenizer, zDoc, nDoc, &pTCursor);
+  if( rc ) return rc;
+  pTCursor->pTokenizer = pTokenizer;
+
+  prevMatch = 0;
+  while( (rc = pTModule->xNext(pTCursor, &zToken, &nToken,
+                               &iBegin, &iEnd, &iPos))==SQLITE_OK ){
+    Fts3Expr *pIter = pCur->pExpr;
+    int iIter = -1;
+    iRotorBegin[iRotor&FTS3_ROTOR_MASK] = iBegin;
+    iRotorLen[iRotor&FTS3_ROTOR_MASK] = iEnd-iBegin;
+    match = 0;
+    for(i=0; i<(FTS3_ROTOR_SZ-1) && fts3NextExprToken(&pIter, &iIter); i++){
+      int nPhrase;                    /* Number of tokens in current phrase */
+      struct PhraseToken *pToken;     /* Current token */
+      int iCol;                       /* Column index */
+
+      if( fts3ExprBeneathNot(pIter) ) continue;
+      nPhrase = pIter->pPhrase->nToken;
+      pToken = &pIter->pPhrase->aToken[iIter];
+      iCol = pIter->pPhrase->iColumn;
+      if( iCol>=0 && iCol<nColumn && iCol!=iColumn ) continue;
+      if( pToken->n>nToken ) continue;
+      if( !pToken->isPrefix && pToken->n<nToken ) continue;
+      assert( pToken->n<=nToken );
+      if( memcmp(pToken->z, zToken, pToken->n) ) continue;
+      if( iIter>0 && (prevMatch & (1<<i))==0 ) continue;
+      match |= 1<<i;
+      if( i==(FTS3_ROTOR_SZ-2) || nPhrase==iIter+1 ){
+        for(j=nPhrase-1; j>=0; j--){
+          int k = (iRotor-j) & FTS3_ROTOR_MASK;
+          rc = snippetAppendMatch(pSnippet, iColumn, i-j, iPos-j,
+                                  iRotorBegin[k], iRotorLen[k]);
+          if( rc ) goto end_offsets_of_column;
+        }
+      }
+    }
+    prevMatch = match<<1;
+    iRotor++;
+  }
+end_offsets_of_column:
+  pTModule->xClose(pTCursor);  
+  return rc==SQLITE_DONE ? SQLITE_OK : rc;
+}
+
+/*
+** Remove entries from the pSnippet structure to account for the NEAR
+** operator. When this is called, pSnippet contains the list of token 
+** offsets produced by treating all NEAR operators as AND operators.
+** This function removes any entries that should not be present after
+** accounting for the NEAR restriction. For example, if the queried
+** document is:
+**
+**     "A B C D E A"
+**
+** and the query is:
+** 
+**     A NEAR/0 E
+**
+** then when this function is called the Snippet contains token offsets
+** 0, 4 and 5. This function removes the "0" entry (because the first A
+** is not near enough to an E).
+**
+** When this function is called, the value pointed to by parameter piLeft is
+** the integer id of the left-most token in the expression tree headed by
+** pExpr. This function increments *piLeft by the total number of tokens
+** in the expression tree headed by pExpr.
+**
+** Return 1 if any trimming occurs.  Return 0 if no trimming is required.
+*/
+static int trimSnippetOffsets(
+  Fts3Expr *pExpr,      /* The search expression */
+  Snippet *pSnippet,    /* The set of snippet offsets to be trimmed */
+  int *piLeft           /* Index of left-most token in pExpr */
+){
+  if( pExpr ){
+    if( trimSnippetOffsets(pExpr->pLeft, pSnippet, piLeft) ){
+      return 1;
+    }
+
+    switch( pExpr->eType ){
+      case FTSQUERY_PHRASE:
+        *piLeft += pExpr->pPhrase->nToken;
+        break;
+      case FTSQUERY_NEAR: {
+        /* The right-hand-side of a NEAR operator is always a phrase. The
+        ** left-hand-side is either a phrase or an expression tree that is 
+        ** itself headed by a NEAR operator. The following initializations
+        ** set local variable iLeft to the token number of the left-most
+        ** token in the right-hand phrase, and iRight to the right most
+        ** token in the same phrase. For example, if we had:
+        **
+        **     <col> MATCH '"abc def" NEAR/2 "ghi jkl"'
+        **
+        ** then iLeft will be set to 2 (token number of ghi) and nToken will
+        ** be set to 4.
+        */
+        Fts3Expr *pLeft = pExpr->pLeft;
+        Fts3Expr *pRight = pExpr->pRight;
+        int iLeft = *piLeft;
+        int nNear = pExpr->nNear;
+        int nToken = pRight->pPhrase->nToken;
+        int jj, ii;
+        if( pLeft->eType==FTSQUERY_NEAR ){
+          pLeft = pLeft->pRight;
+        }
+        assert( pRight->eType==FTSQUERY_PHRASE );
+        assert( pLeft->eType==FTSQUERY_PHRASE );
+        nToken += pLeft->pPhrase->nToken;
+
+        for(ii=0; ii<pSnippet->nMatch; ii++){
+          struct snippetMatch *p = &pSnippet->aMatch[ii];
+          if( p->iTerm==iLeft ){
+            int isOk = 0;
+            /* Snippet ii is an occurence of query term iLeft in the document.
+            ** It occurs at position (p->iToken) of the document. We now
+            ** search for an instance of token (iLeft-1) somewhere in the 
+            ** range (p->iToken - nNear)...(p->iToken + nNear + nToken) within 
+            ** the set of snippetMatch structures. If one is found, proceed. 
+            ** If one cannot be found, then remove snippets ii..(ii+N-1) 
+            ** from the matching snippets, where N is the number of tokens 
+            ** in phrase pRight->pPhrase.
+            */
+            for(jj=0; isOk==0 && jj<pSnippet->nMatch; jj++){
+              struct snippetMatch *p2 = &pSnippet->aMatch[jj];
+              if( p2->iTerm==(iLeft-1) ){
+                if( p2->iToken>=(p->iToken-nNear-1) 
+                 && p2->iToken<(p->iToken+nNear+nToken) 
+                ){
+                  isOk = 1;
+                }
+              }
+            }
+            if( !isOk ){
+              int kk;
+              for(kk=0; kk<pRight->pPhrase->nToken; kk++){
+                pSnippet->aMatch[kk+ii].iTerm = -2;
+              }
+              return 1;
+            }
+          }
+          if( p->iTerm==(iLeft-1) ){
+            int isOk = 0;
+            for(jj=0; isOk==0 && jj<pSnippet->nMatch; jj++){
+              struct snippetMatch *p2 = &pSnippet->aMatch[jj];
+              if( p2->iTerm==iLeft ){
+                if( p2->iToken<=(p->iToken+nNear+1) 
+                 && p2->iToken>(p->iToken-nNear-nToken) 
+                ){
+                  isOk = 1;
+                }
+              }
+            }
+            if( !isOk ){
+              int kk;
+              for(kk=0; kk<pLeft->pPhrase->nToken; kk++){
+                pSnippet->aMatch[ii-kk].iTerm = -2;
+              }
+              return 1;
+            }
+          }
+        }
+        break;
+      }
+    }
+
+    if( trimSnippetOffsets(pExpr->pRight, pSnippet, piLeft) ){
+      return 1;
+    }
+  }
+  return 0;
+}
+
+/*
+** Compute all offsets for the current row of the query.  
+** If the offsets have already been computed, this routine is a no-op.
+*/
+static int snippetAllOffsets(Fts3Cursor *pCsr, Snippet **ppSnippet){
+  Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;  /* The FTS3 virtual table */
+  int nColumn;           /* Number of columns.  Docid does count */
+  int iColumn;           /* Index of of a column */
+  int i;                 /* Loop index */
+  int iFirst;            /* First column to search */
+  int iLast;             /* Last coumn to search */
+  int iTerm = 0;
+  Snippet *pSnippet;
+  int rc = SQLITE_OK;
+
+  if( pCsr->pExpr==0 ){
+    return SQLITE_OK;
+  }
+
+  pSnippet = (Snippet *)sqlite3_malloc(sizeof(Snippet));
+  *ppSnippet = pSnippet;
+  if( !pSnippet ){
+    return SQLITE_NOMEM;
+  }
+  memset(pSnippet, 0, sizeof(Snippet));
+
+  nColumn = p->nColumn;
+  iColumn = (pCsr->eSearch - 2);
+  if( iColumn<0 || iColumn>=nColumn ){
+    /* Look for matches over all columns of the full-text index */
+    iFirst = 0;
+    iLast = nColumn-1;
+  }else{
+    /* Look for matches in the iColumn-th column of the index only */
+    iFirst = iColumn;
+    iLast = iColumn;
+  }
+  for(i=iFirst; rc==SQLITE_OK && i<=iLast; i++){
+    const char *zDoc;
+    int nDoc;
+    zDoc = (const char*)sqlite3_column_text(pCsr->pStmt, i+1);
+    nDoc = sqlite3_column_bytes(pCsr->pStmt, i+1);
+    if( zDoc==0 && sqlite3_column_type(pCsr->pStmt, i+1)!=SQLITE_NULL ){
+      rc = SQLITE_NOMEM;
+    }else{
+      rc = snippetOffsetsOfColumn(pCsr, pSnippet, i, zDoc, nDoc);
+    }
+  }
+
+  while( trimSnippetOffsets(pCsr->pExpr, pSnippet, &iTerm) ){
+    iTerm = 0;
+  }
+
+  return rc;
+}
+
+/*
+** Convert the information in the aMatch[] array of the snippet
+** into the string zOffset[0..nOffset-1]. This string is used as
+** the return of the SQL offsets() function.
+*/
+static void snippetOffsetText(Snippet *p){
+  int i;
+  int cnt = 0;
+  StringBuffer sb;
+  char zBuf[200];
+  if( p->zOffset ) return;
+  fts3SnippetSbInit(&sb);
+  for(i=0; i<p->nMatch; i++){
+    struct snippetMatch *pMatch = &p->aMatch[i];
+    if( pMatch->iTerm>=0 ){
+      /* If snippetMatch.iTerm is less than 0, then the match was 
+      ** discarded as part of processing the NEAR operator (see the 
+      ** trimSnippetOffsetsForNear() function for details). Ignore 
+      ** it in this case
+      */
+      zBuf[0] = ' ';
+      sqlite3_snprintf(sizeof(zBuf)-1, &zBuf[cnt>0], "%d %d %d %d",
+          pMatch->iCol, pMatch->iTerm, pMatch->iStart, pMatch->nByte);
+      fts3SnippetAppend(&sb, zBuf, -1);
+      cnt++;
+    }
+  }
+  p->zOffset = sb.z;
+  p->nOffset = sb.z ? sb.nUsed : 0;
+}
+
+/*
+** zDoc[0..nDoc-1] is phrase of text.  aMatch[0..nMatch-1] are a set
+** of matching words some of which might be in zDoc.  zDoc is column
+** number iCol.
+**
+** iBreak is suggested spot in zDoc where we could begin or end an
+** excerpt.  Return a value similar to iBreak but possibly adjusted
+** to be a little left or right so that the break point is better.
+*/
+static int wordBoundary(
+  int iBreak,                   /* The suggested break point */
+  const char *zDoc,             /* Document text */
+  int nDoc,                     /* Number of bytes in zDoc[] */
+  struct snippetMatch *aMatch,  /* Matching words */
+  int nMatch,                   /* Number of entries in aMatch[] */
+  int iCol                      /* The column number for zDoc[] */
+){
+  int i;
+  if( iBreak<=10 ){
+    return 0;
+  }
+  if( iBreak>=nDoc-10 ){
+    return nDoc;
+  }
+  for(i=0; ALWAYS(i<nMatch) && aMatch[i].iCol<iCol; i++){}
+  while( i<nMatch && aMatch[i].iStart+aMatch[i].nByte<iBreak ){ i++; }
+  if( i<nMatch ){
+    if( aMatch[i].iStart<iBreak+10 ){
+      return aMatch[i].iStart;
+    }
+    if( i>0 && aMatch[i-1].iStart+aMatch[i-1].nByte>=iBreak ){
+      return aMatch[i-1].iStart;
+    }
+  }
+  for(i=1; i<=10; i++){
+    if( fts3snippetIsspace(zDoc[iBreak-i]) ){
+      return iBreak - i + 1;
+    }
+    if( fts3snippetIsspace(zDoc[iBreak+i]) ){
+      return iBreak + i + 1;
+    }
+  }
+  return iBreak;
+}
+
+
+
+/*
+** Allowed values for Snippet.aMatch[].snStatus
+*/
+#define SNIPPET_IGNORE  0   /* It is ok to omit this match from the snippet */
+#define SNIPPET_DESIRED 1   /* We want to include this match in the snippet */
+
+/*
+** Generate the text of a snippet.
+*/
+static void snippetText(
+  Fts3Cursor *pCursor,   /* The cursor we need the snippet for */
+  Snippet *pSnippet,
+  const char *zStartMark,     /* Markup to appear before each match */
+  const char *zEndMark,       /* Markup to appear after each match */
+  const char *zEllipsis       /* Ellipsis mark */
+){
+  int i, j;
+  struct snippetMatch *aMatch;
+  int nMatch;
+  int nDesired;
+  StringBuffer sb;
+  int tailCol;
+  int tailOffset;
+  int iCol;
+  int nDoc;
+  const char *zDoc;
+  int iStart, iEnd;
+  int tailEllipsis = 0;
+  int iMatch;
+  
+
+  sqlite3_free(pSnippet->zSnippet);
+  pSnippet->zSnippet = 0;
+  aMatch = pSnippet->aMatch;
+  nMatch = pSnippet->nMatch;
+  fts3SnippetSbInit(&sb);
+
+  for(i=0; i<nMatch; i++){
+    aMatch[i].snStatus = SNIPPET_IGNORE;
+  }
+  nDesired = 0;
+  for(i=0; i<FTS3_ROTOR_SZ; i++){
+    for(j=0; j<nMatch; j++){
+      if( aMatch[j].iTerm==i ){
+        aMatch[j].snStatus = SNIPPET_DESIRED;
+        nDesired++;
+        break;
+      }
+    }
+  }
+
+  iMatch = 0;
+  tailCol = -1;
+  tailOffset = 0;
+  for(i=0; i<nMatch && nDesired>0; i++){
+    if( aMatch[i].snStatus!=SNIPPET_DESIRED ) continue;
+    nDesired--;
+    iCol = aMatch[i].iCol;
+    zDoc = (const char*)sqlite3_column_text(pCursor->pStmt, iCol+1);
+    nDoc = sqlite3_column_bytes(pCursor->pStmt, iCol+1);
+    iStart = aMatch[i].iStart - 40;
+    iStart = wordBoundary(iStart, zDoc, nDoc, aMatch, nMatch, iCol);
+    if( iStart<=10 ){
+      iStart = 0;
+    }
+    if( iCol==tailCol && iStart<=tailOffset+20 ){
+      iStart = tailOffset;
+    }
+    if( (iCol!=tailCol && tailCol>=0) || iStart!=tailOffset ){
+      fts3SnippetTrimWhiteSpace(&sb);
+      fts3SnippetAppendWhiteSpace(&sb);
+      fts3SnippetAppend(&sb, zEllipsis, -1);
+      fts3SnippetAppendWhiteSpace(&sb);
+    }
+    iEnd = aMatch[i].iStart + aMatch[i].nByte + 40;
+    iEnd = wordBoundary(iEnd, zDoc, nDoc, aMatch, nMatch, iCol);
+    if( iEnd>=nDoc-10 ){
+      iEnd = nDoc;
+      tailEllipsis = 0;
+    }else{
+      tailEllipsis = 1;
+    }
+    while( iMatch<nMatch && aMatch[iMatch].iCol<iCol ){ iMatch++; }
+    while( iStart<iEnd ){
+      while( iMatch<nMatch && aMatch[iMatch].iStart<iStart
+             && aMatch[iMatch].iCol<=iCol ){
+        iMatch++;
+      }
+      if( iMatch<nMatch && aMatch[iMatch].iStart<iEnd
+             && aMatch[iMatch].iCol==iCol ){
+        fts3SnippetAppend(&sb, &zDoc[iStart], aMatch[iMatch].iStart - iStart);
+        iStart = aMatch[iMatch].iStart;
+        fts3SnippetAppend(&sb, zStartMark, -1);
+        fts3SnippetAppend(&sb, &zDoc[iStart], aMatch[iMatch].nByte);
+        fts3SnippetAppend(&sb, zEndMark, -1);
+        iStart += aMatch[iMatch].nByte;
+        for(j=iMatch+1; j<nMatch; j++){
+          if( aMatch[j].iTerm==aMatch[iMatch].iTerm
+              && aMatch[j].snStatus==SNIPPET_DESIRED ){
+            nDesired--;
+            aMatch[j].snStatus = SNIPPET_IGNORE;
+          }
+        }
+      }else{
+        fts3SnippetAppend(&sb, &zDoc[iStart], iEnd - iStart);
+        iStart = iEnd;
+      }
+    }
+    tailCol = iCol;
+    tailOffset = iEnd;
+  }
+  fts3SnippetTrimWhiteSpace(&sb);
+  if( tailEllipsis ){
+    fts3SnippetAppendWhiteSpace(&sb);
+    fts3SnippetAppend(&sb, zEllipsis, -1);
+  }
+  pSnippet->zSnippet = sb.z;
+  pSnippet->nSnippet = sb.z ? sb.nUsed : 0;
+}
+
+SQLITE_PRIVATE void sqlite3Fts3Offsets(
+  sqlite3_context *pCtx,          /* SQLite function call context */
+  Fts3Cursor *pCsr                /* Cursor object */
+){
+  Snippet *p;                     /* Snippet structure */
+  int rc = snippetAllOffsets(pCsr, &p);
+  if( rc==SQLITE_OK ){
+    snippetOffsetText(p);
+    if( p->zOffset ){
+      sqlite3_result_text(pCtx, p->zOffset, p->nOffset, SQLITE_TRANSIENT);
+    }else{
+      sqlite3_result_error_nomem(pCtx);
+    }
+  }else{
+    sqlite3_result_error_nomem(pCtx);
+  }
+  fts3SnippetFree(p);
+}
+
+SQLITE_PRIVATE void sqlite3Fts3Snippet(
+  sqlite3_context *pCtx,          /* SQLite function call context */
+  Fts3Cursor *pCsr,               /* Cursor object */
+  const char *zStart,             /* Snippet start text - "<b>" */
+  const char *zEnd,               /* Snippet end text - "</b>" */
+  const char *zEllipsis           /* Snippet ellipsis text - "<b>...</b>" */
+){
+  Snippet *p;                     /* Snippet structure */
+  int rc = snippetAllOffsets(pCsr, &p);
+  if( rc==SQLITE_OK ){
+    snippetText(pCsr, p, zStart, zEnd, zEllipsis);
+    if( p->zSnippet ){
+      sqlite3_result_text(pCtx, p->zSnippet, p->nSnippet, SQLITE_TRANSIENT);
+    }else{
+      sqlite3_result_error_nomem(pCtx);
+    }
+  }else{
+    sqlite3_result_error_nomem(pCtx);
+  }
+  fts3SnippetFree(p);
+}
+
+/*************************************************************************
+** Below this point is the alternative, experimental snippet() implementation.
+*/
+
+#define SNIPPET_BUFFER_CHUNK  64
+#define SNIPPET_BUFFER_SIZE   SNIPPET_BUFFER_CHUNK*4
+#define SNIPPET_BUFFER_MASK   (SNIPPET_BUFFER_SIZE-1)
+
+static void fts3GetDeltaPosition(char **pp, int *piPos){
+  int iVal;
+  *pp += sqlite3Fts3GetVarint32(*pp, &iVal);
+  *piPos += (iVal-2);
+}
+
+/*
+** Iterate through all phrase nodes in an FTS3 query, except those that
+** are part of a sub-tree that is the right-hand-side of a NOT operator.
+** For each phrase node found, the supplied callback function is invoked.
+**
+** If the callback function returns anything other than SQLITE_OK, 
+** the iteration is abandoned and the error code returned immediately.
+** Otherwise, SQLITE_OK is returned after a callback has been made for
+** all eligible phrase nodes.
+*/
+static int fts3ExprIterate(
+  Fts3Expr *pExpr,                /* Expression to iterate phrases of */
+  int (*x)(Fts3Expr *, void *),   /* Callback function to invoke for phrases */
+  void *pCtx                      /* Second argument to pass to callback */
+){
+  int rc;
+  int eType = pExpr->eType;
+  if( eType==FTSQUERY_NOT ){
+    rc = SQLITE_OK;
+  }else if( eType!=FTSQUERY_PHRASE ){
+    assert( pExpr->pLeft && pExpr->pRight );
+    rc = fts3ExprIterate(pExpr->pLeft, x, pCtx);
+    if( rc==SQLITE_OK ){
+      rc = fts3ExprIterate(pExpr->pRight, x, pCtx);
+    }
+  }else{
+    rc = x(pExpr, pCtx);
+  }
+  return rc;
+}
+
+typedef struct LoadDoclistCtx LoadDoclistCtx;
+struct LoadDoclistCtx {
+  Fts3Table *pTab;                /* FTS3 Table */
+  int nPhrase;                    /* Number of phrases so far */
+};
+
+static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, void *ctx){
+  int rc = SQLITE_OK;
+  LoadDoclistCtx *p = (LoadDoclistCtx *)ctx;
+  p->nPhrase++;
+  if( pExpr->isLoaded==0 ){
+    rc = sqlite3Fts3ExprLoadDoclist(p->pTab, pExpr);
+    pExpr->isLoaded = 1;
+    if( rc==SQLITE_OK && pExpr->aDoclist ){
+      pExpr->pCurrent = pExpr->aDoclist;
+      pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent,&pExpr->iCurrent);
+    }
+  }
+  return rc;
+}
+
+static int fts3ExprLoadDoclists(Fts3Cursor *pCsr, int *pnPhrase){
+  int rc;
+  LoadDoclistCtx sCtx = {0, 0};
+  sCtx.pTab = (Fts3Table *)pCsr->base.pVtab;
+  rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);
+  *pnPhrase = sCtx.nPhrase;
+  return rc;
+}
+
+/*
+** Each call to this function populates a chunk of a snippet-buffer 
+** SNIPPET_BUFFER_CHUNK bytes in size.
+**
+** Return true if the end of the data has been reached (and all subsequent
+** calls to fts3LoadSnippetBuffer() with the same arguments will be no-ops), 
+** or false otherwise.
+*/
+static int fts3LoadSnippetBuffer(
+  int iPos,                       /* Document token offset to load data for */
+  u8 *aBuffer,                    /* Circular snippet buffer to populate */
+  int nList,                      /* Number of position lists in appList */
+  char **apList,                  /* IN/OUT: nList position list pointers */
+  int *aiPrev                     /* IN/OUT: Previous positions read */
+){
+  int i;
+  int nFin = 0;
+
+  assert( (iPos&(SNIPPET_BUFFER_CHUNK-1))==0 );
+
+  memset(&aBuffer[iPos&SNIPPET_BUFFER_MASK], 0, SNIPPET_BUFFER_CHUNK);
+
+  for(i=0; i<nList; i++){
+    int iPrev = aiPrev[i];
+    char *pList = apList[i];
+
+    if( !pList ){
+      nFin++;
+      continue;
+    }
+
+    while( iPrev<(iPos+SNIPPET_BUFFER_CHUNK) ){
+      if( iPrev>=iPos ){
+        aBuffer[iPrev&SNIPPET_BUFFER_MASK] = (u8)(i+1);
+      }
+      if( 0==((*pList)&0xFE) ){
+        nFin++;
+        break;
+      }
+      fts3GetDeltaPosition(&pList, &iPrev); 
+    }
+
+    aiPrev[i] = iPrev;
+    apList[i] = pList;
+  }
+
+  return (nFin==nList);
+}
+
+typedef struct SnippetCtx SnippetCtx;
+struct SnippetCtx {
+  Fts3Cursor *pCsr;
+  int iCol;
+  int iPhrase;
+  int *aiPrev;
+  int *anToken;
+  char **apList;
+};
+
+static int fts3SnippetFindPositions(Fts3Expr *pExpr, void *ctx){
+  SnippetCtx *p = (SnippetCtx *)ctx;
+  int iPhrase = p->iPhrase++;
+  char *pCsr;
+
+  p->anToken[iPhrase] = pExpr->pPhrase->nToken;
+  pCsr = sqlite3Fts3FindPositions(pExpr, p->pCsr->iPrevId, p->iCol);
+
+  if( pCsr ){
+    int iVal;
+    pCsr += sqlite3Fts3GetVarint32(pCsr, &iVal);
+    p->apList[iPhrase] = pCsr;
+    p->aiPrev[iPhrase] = iVal-2;
+  }
+  return SQLITE_OK;
+}
+
+static void fts3SnippetCnt(
+  int iIdx, 
+  int nSnippet, 
+  int *anCnt, 
+  u8 *aBuffer,
+  int *anToken,
+  u64 *pHlmask
+){
+  int iSub =  (iIdx-1)&SNIPPET_BUFFER_MASK;
+  int iAdd =  (iIdx+nSnippet-1)&SNIPPET_BUFFER_MASK;
+  int iSub2 = (iIdx+(nSnippet/3)-1)&SNIPPET_BUFFER_MASK;
+  int iAdd2 = (iIdx+(nSnippet*2/3)-1)&SNIPPET_BUFFER_MASK;
+
+  u64 h = *pHlmask;
+
+  anCnt[ aBuffer[iSub]  ]--;
+  anCnt[ aBuffer[iSub2] ]--;
+  anCnt[ aBuffer[iAdd]  ]++;
+  anCnt[ aBuffer[iAdd2] ]++;
+
+  h = h >> 1;
+  if( aBuffer[iAdd] ){
+    int j;
+    for(j=anToken[aBuffer[iAdd]-1]; j>=1; j--){
+      h |= (u64)1 << (nSnippet-j);
+    }
+  }
+  *pHlmask = h;
+}
+
+static int fts3SnippetScore(int n, int *anCnt){
+  int j;
+  int iScore = 0;
+  for(j=1; j<=n; j++){
+    int nCnt = anCnt[j];
+    iScore += nCnt + (nCnt ? 1000 : 0);
+  }
+  return iScore;
+}
+
+static int fts3BestSnippet(
+  int nSnippet,                   /* Desired snippet length */
+  Fts3Cursor *pCsr,               /* Cursor to create snippet for */
+  int iCol,                       /* Index of column to create snippet from */
+  int *piPos,                     /* OUT: Starting token for best snippet */
+  u64 *pHlmask                    /* OUT: Highlight mask for best snippet */
+){
+  int rc;                         /* Return Code */
+  u8 aBuffer[SNIPPET_BUFFER_SIZE];/* Circular snippet buffer */
+  int *aiPrev;                    /* Used by fts3LoadSnippetBuffer() */
+  int *anToken;                   /* Number of tokens in each phrase */
+  char **apList;                  /* Array of position lists */
+  int *anCnt;                     /* Running totals of phrase occurences */
+  int nList;
+
+  int i;
+
+  u64 hlmask = 0;                 /* Current mask of highlighted terms */
+  u64 besthlmask = 0;             /* Mask of highlighted terms for iBestPos */
+  int iBestPos = 0;               /* Starting position of 'best' snippet */
+  int iBestScore = 0;             /* Score of best snippet higher->better */
+  SnippetCtx sCtx;
+
+  /* Iterate through the phrases in the expression to count them. The same
+  ** callback makes sure the doclists are loaded for each phrase.
+  */
+  rc = fts3ExprLoadDoclists(pCsr, &nList);
+  if( rc!=SQLITE_OK ){
+    return rc;
+  }
+
+  /* Now that it is known how many phrases there are, allocate and zero
+  ** the required arrays using malloc().
+  */
+  apList = sqlite3_malloc(
+      sizeof(u8*)*nList +         /* apList */
+      sizeof(int)*(nList) +       /* anToken */
+      sizeof(int)*nList +         /* aiPrev */
+      sizeof(int)*(nList+1)       /* anCnt */
+  );
+  if( !apList ){
+    return SQLITE_NOMEM;
+  }
+  memset(apList, 0, sizeof(u8*)*nList+sizeof(int)*nList+sizeof(int)*nList);
+  anToken = (int *)&apList[nList];
+  aiPrev = &anToken[nList];
+  anCnt = &aiPrev[nList];
+
+  /* Initialize the contents of the aiPrev and aiList arrays. */
+  sCtx.pCsr = pCsr;
+  sCtx.iCol = iCol;
+  sCtx.apList = apList;
+  sCtx.aiPrev = aiPrev;
+  sCtx.anToken = anToken;
+  sCtx.iPhrase = 0;
+  (void)fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void *)&sCtx);
+
+  /* Load the first two chunks of data into the buffer. */
+  memset(aBuffer, 0, SNIPPET_BUFFER_SIZE);
+  fts3LoadSnippetBuffer(0, aBuffer, nList, apList, aiPrev);
+  fts3LoadSnippetBuffer(SNIPPET_BUFFER_CHUNK, aBuffer, nList, apList, aiPrev);
+
+  /* Set the initial contents of the highlight-mask and anCnt[] array. */
+  for(i=1-nSnippet; i<=0; i++){
+    fts3SnippetCnt(i, nSnippet, anCnt, aBuffer, anToken, &hlmask);
+  }
+  iBestScore = fts3SnippetScore(nList, anCnt);
+  besthlmask = hlmask;
+  iBestPos = 0;
+
+  for(i=1; 1; i++){
+    int iScore;
+
+    if( 0==(i&(SNIPPET_BUFFER_CHUNK-1)) ){
+      int iLoad = i + SNIPPET_BUFFER_CHUNK;
+      if( fts3LoadSnippetBuffer(iLoad, aBuffer, nList, apList, aiPrev) ) break;
+    }
+
+    /* Figure out how highly a snippet starting at token offset i scores
+    ** according to fts3SnippetScore(). If it is higher than any previously
+    ** considered position, save the current position, score and hlmask as 
+    ** the best snippet candidate found so far.
+    */
+    fts3SnippetCnt(i, nSnippet, anCnt, aBuffer, anToken, &hlmask);
+    iScore = fts3SnippetScore(nList, anCnt);
+    if( iScore>iBestScore ){
+      iBestPos = i;
+      iBestScore = iScore;
+      besthlmask = hlmask;
+    }
+  }
+
+  sqlite3_free(apList);
+  *piPos = iBestPos;
+  *pHlmask = besthlmask;
+  return SQLITE_OK;
+}
+
+typedef struct StrBuffer StrBuffer;
+struct StrBuffer {
+  char *z;
+  int n;
+  int nAlloc;
+};
+
+static int fts3StringAppend(
+  StrBuffer *pStr, 
+  const char *zAppend, 
+  int nAppend
+){
+  if( nAppend<0 ){
+    nAppend = (int)strlen(zAppend);
+  }
+
+  if( pStr->n+nAppend+1>=pStr->nAlloc ){
+    int nAlloc = pStr->nAlloc+nAppend+100;
+    char *zNew = sqlite3_realloc(pStr->z, nAlloc);
+    if( !zNew ){
+      return SQLITE_NOMEM;
+    }
+    pStr->z = zNew;
+    pStr->nAlloc = nAlloc;
+  }
+
+  memcpy(&pStr->z[pStr->n], zAppend, nAppend);
+  pStr->n += nAppend;
+  pStr->z[pStr->n] = '\0';
+
+  return SQLITE_OK;
+}
+
+static int fts3SnippetText(
+  Fts3Cursor *pCsr,               /* FTS3 Cursor */
+  const char *zDoc,               /* Document to extract snippet from */
+  int nDoc,                       /* Size of zDoc in bytes */
+  int nSnippet,                   /* Number of tokens in extracted snippet */
+  int iPos,                       /* Index of first document token in snippet */
+  u64 hlmask,                     /* Bitmask of terms to highlight in snippet */
+  const char *zOpen,              /* String inserted before highlighted term */
+  const char *zClose,             /* String inserted after highlighted term */
+  const char *zEllipsis,
+  char **pzSnippet                /* OUT: Snippet text */
+){
+  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
+  int rc;                         /* Return code */
+  int iCurrent = 0;
+  int iStart = 0;
+  int iEnd;
+
+  sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */
+  sqlite3_tokenizer_cursor *pC;   /* Tokenizer cursor open on zDoc/nDoc */
+  const char *ZDUMMY;             /* Dummy arguments used with tokenizer */
+  int DUMMY1, DUMMY2, DUMMY3;     /* Dummy arguments used with tokenizer */
+
+  StrBuffer res = {0, 0, 0};   /* Result string */
+
+  /* Open a token cursor on the document. Read all tokens up to and 
+  ** including token iPos (the first token of the snippet). Set variable
+  ** iStart to the byte offset in zDoc of the start of token iPos.
+  */
+  pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;
+  rc = pMod->xOpen(pTab->pTokenizer, zDoc, nDoc, &pC);
+  while( rc==SQLITE_OK && iCurrent<iPos ){
+    rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iStart, &DUMMY2, &iCurrent);
+  }
+  iEnd = iStart;
+
+  if( rc==SQLITE_OK && iStart>0 ){
+    rc = fts3StringAppend(&res, zEllipsis, -1);
+  }
+
+  while( rc==SQLITE_OK ){
+    int iBegin;
+    int iFin;
+    rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);
+
+    if( rc==SQLITE_OK ){
+      if( iCurrent>=(iPos+nSnippet) ){
+        rc = SQLITE_DONE;
+      }else{
+        iEnd = iFin;
+        if( hlmask & ((u64)1 << (iCurrent-iPos)) ){
+          if( fts3StringAppend(&res, &zDoc[iStart], iBegin-iStart)
+           || fts3StringAppend(&res, zOpen, -1)
+           || fts3StringAppend(&res, &zDoc[iBegin], iEnd-iBegin)
+           || fts3StringAppend(&res, zClose, -1)
+          ){
+            rc = SQLITE_NOMEM;
+          }
+          iStart = iEnd;
+        }
+      }
+    }
+  }
+  assert( rc!=SQLITE_OK );
+  if( rc==SQLITE_DONE ){
+    rc = fts3StringAppend(&res, &zDoc[iStart], iEnd-iStart);
+    if( rc==SQLITE_OK ){
+      rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);
+      if( rc==SQLITE_OK ){
+        rc = fts3StringAppend(&res, zEllipsis, -1);
+      }else if( rc==SQLITE_DONE ){
+        rc = fts3StringAppend(&res, &zDoc[iEnd], -1);
+      }
+    }
+  }
+
+  pMod->xClose(pC);
+  if( rc!=SQLITE_OK ){
+    sqlite3_free(res.z);
+  }else{
+    *pzSnippet = res.z;
+  }
+  return rc;
+}
+
+
+/*
+** An instance of this structure is used to collect the 'global' part of
+** the matchinfo statistics. The 'global' part consists of the following:
+**
+**   1. The number of phrases in the query (nPhrase).
+**
+**   2. The number of columns in the FTS3 table (nCol).
+**
+**   3. A matrix of (nPhrase*nCol) integers containing the sum of the
+**      number of hits for each phrase in each column across all rows
+**      of the table.
+**
+** The total size of the global matchinfo array, assuming the number of
+** columns is N and the number of phrases is P is:
+**
+**   2 + P*(N+1)
+**
+** The number of hits for the 3rd phrase in the second column is found
+** using the expression:
+**
+**   aGlobal[2 + P*(1+2) + 1]
+*/
+typedef struct MatchInfo MatchInfo;
+struct MatchInfo {
+  Fts3Table *pTab;                /* FTS3 Table */
+  Fts3Cursor *pCursor;            /* FTS3 Cursor */
+  int iPhrase;                    /* Number of phrases so far */
+  int nCol;                       /* Number of columns in table */
+  u32 *aGlobal;                   /* Pre-allocated buffer */
+};
+
+/*
+** This function is used to count the entries in a column-list (delta-encoded
+** list of term offsets within a single column of a single row).
+*/
+static int fts3ColumnlistCount(char **ppCollist){
+  char *pEnd = *ppCollist;
+  char c = 0;
+  int nEntry = 0;
+
+  /* A column-list is terminated by either a 0x01 or 0x00. */
+  while( 0xFE & (*pEnd | c) ){
+    c = *pEnd++ & 0x80;
+    if( !c ) nEntry++;
+  }
+
+  *ppCollist = pEnd;
+  return nEntry;
+}
+
+static void fts3LoadColumnlistCounts(char **pp, u32 *aOut){
+  char *pCsr = *pp;
+  while( *pCsr ){
+    sqlite3_int64 iCol = 0;
+    if( *pCsr==0x01 ){
+      pCsr++;
+      pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
+    }
+    aOut[iCol] += fts3ColumnlistCount(&pCsr);
+  }
+  pCsr++;
+  *pp = pCsr;
+}
+
+/*
+** fts3ExprIterate() callback used to collect the "global" matchinfo stats
+** for a single query.
+*/
+static int fts3ExprGlobalMatchinfoCb(
+  Fts3Expr *pExpr,                /* Phrase expression node */
+  void *pCtx                      /* Pointer to MatchInfo structure */
+){
+  MatchInfo *p = (MatchInfo *)pCtx;
+  char *pCsr;
+  char *pEnd;
+  const int iStart = 2 + p->nCol*p->iPhrase;
+
+  assert( pExpr->isLoaded );
+
+  /* Fill in the global hit count matrix row for this phrase. */
+  pCsr = pExpr->aDoclist;
+  pEnd = &pExpr->aDoclist[pExpr->nDoclist];
+  while( pCsr<pEnd ){
+    while( *pCsr++ & 0x80 );
+    fts3LoadColumnlistCounts(&pCsr, &p->aGlobal[iStart]);
+  }
+
+  p->iPhrase++;
+  return SQLITE_OK;
+}
+
+static int fts3ExprLocalMatchinfoCb(
+  Fts3Expr *pExpr,                /* Phrase expression node */
+  void *pCtx                      /* Pointer to MatchInfo structure */
+){
+  MatchInfo *p = (MatchInfo *)pCtx;
+  int iPhrase = p->iPhrase++;
+
+  if( pExpr->aDoclist ){
+    char *pCsr;
+    int iOffset = 2 + p->nCol*(p->aGlobal[0]+iPhrase);
+
+    memset(&p->aGlobal[iOffset], 0, p->nCol*sizeof(u32));
+    pCsr = sqlite3Fts3FindPositions(pExpr, p->pCursor->iPrevId, -1);
+    if( pCsr ) fts3LoadColumnlistCounts(&pCsr, &p->aGlobal[iOffset]);
+  }
+
+  return SQLITE_OK;
+}
+
+/*
+** Populate pCsr->aMatchinfo[] with data for the current row. The 'matchinfo'
+** data is an array of 32-bit unsigned integers (C type u32).
+*/
+static int fts3GetMatchinfo(Fts3Cursor *pCsr){
+  MatchInfo g;
+  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
+  if( pCsr->aMatchinfo==0 ){
+    int rc;
+    int nPhrase;
+    int nMatchinfo;
+
+    g.pTab = pTab;
+    g.nCol = pTab->nColumn;
+    g.iPhrase = 0;
+    rc = fts3ExprLoadDoclists(pCsr, &nPhrase);
+    if( rc!=SQLITE_OK ){
+      return rc;
+    }
+
+    nMatchinfo = 2 + 2*g.nCol*nPhrase;
+
+    g.iPhrase = 0;
+    g.aGlobal = (u32 *)sqlite3_malloc(sizeof(u32)*nMatchinfo);
+    if( !g.aGlobal ){ 
+      return SQLITE_NOMEM;
+    }
+    memset(g.aGlobal, 0, sizeof(u32)*nMatchinfo);
+
+    g.aGlobal[0] = nPhrase;
+    g.aGlobal[1] = g.nCol;
+    (void)fts3ExprIterate(pCsr->pExpr, fts3ExprGlobalMatchinfoCb, (void *)&g);
+
+    pCsr->aMatchinfo = g.aGlobal;
+  }
+
+  g.pTab = pTab;
+  g.pCursor = pCsr;
+  g.nCol = pTab->nColumn;
+  g.iPhrase = 0;
+  g.aGlobal = pCsr->aMatchinfo;
+
+  if( pCsr->isMatchinfoOk ){
+    (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLocalMatchinfoCb, (void *)&g);
+    pCsr->isMatchinfoOk = 0;
+  }
+
+  return SQLITE_OK;
+}
+
+SQLITE_PRIVATE void sqlite3Fts3Snippet2(
+  sqlite3_context *pCtx,          /* SQLite function call context */
+  Fts3Cursor *pCsr,               /* Cursor object */
+  const char *zStart,             /* Snippet start text - "<b>" */
+  const char *zEnd,               /* Snippet end text - "</b>" */
+  const char *zEllipsis,          /* Snippet ellipsis text - "<b>...</b>" */
+  int iCol,                       /* Extract snippet from this column */
+  int nToken                      /* Approximate number of tokens in snippet */
+){
+  int rc;
+  int iPos = 0;
+  u64 hlmask = 0;
+  char *z = 0;
+  int nDoc;
+  const char *zDoc;
+
+  rc = fts3BestSnippet(nToken, pCsr, iCol, &iPos, &hlmask);
+
+  nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol+1);
+  zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol+1);
+
+  if( rc==SQLITE_OK ){
+    rc = fts3SnippetText(
+        pCsr, zDoc, nDoc, nToken, iPos, hlmask, zStart, zEnd, zEllipsis, &z);
+  }
+  if( rc!=SQLITE_OK ){
+    sqlite3_result_error_code(pCtx, rc);
+  }else{
+    sqlite3_result_text(pCtx, z, -1, sqlite3_free);
+  }
+}
+
+SQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *pContext, Fts3Cursor *pCsr){
+  int rc = fts3GetMatchinfo(pCsr);
+  if( rc!=SQLITE_OK ){
+    sqlite3_result_error_code(pContext, rc);
+  }else{
+    int n = sizeof(u32)*(2+pCsr->aMatchinfo[0]*pCsr->aMatchinfo[1]*2);
+    sqlite3_result_blob(pContext, pCsr->aMatchinfo, n, SQLITE_TRANSIENT);
+  }
+}
+
+#endif
+
+/************** End of fts3_snippet.c ****************************************/
 /************** Begin file rtree.c *******************************************/
 /*
 ** 2001 September 15
@@ -107001,8 +107254,6 @@ SQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(
 *************************************************************************
 ** This file contains code for implementations of the r-tree and r*-tree
 ** algorithms packaged as an SQLite virtual table module.
-**
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
 */
 
 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE)
@@ -109862,7 +110113,7 @@ SQLITE_API int sqlite3_extension_init(
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
+** $Id: sqlite3.c 294454 2010-02-03 20:23:53Z pajoye $
 **
 ** This file implements an integration between the ICU library 
 ** ("International Components for Unicode", an open-source library 
@@ -110304,7 +110555,7 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db){
     void *pContext;                           /* sqlite3_user_data() context */
     void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
   } scalars[] = {
-    {"regexp",-1, SQLITE_ANY,          0, icuRegexpFunc},
+    {"regexp", 2, SQLITE_ANY,          0, icuRegexpFunc},
 
     {"lower",  1, SQLITE_UTF16,        0, icuCaseFunc16},
     {"lower",  2, SQLITE_UTF16,        0, icuCaseFunc16},
@@ -110363,7 +110614,7 @@ SQLITE_API int sqlite3_extension_init(
 *************************************************************************
 ** This file implements a tokenizer for fts3 based on the ICU library.
 ** 
-** $Id: sqlite3.c 289758 2009-10-19 17:11:05Z pajoye $
+** $Id: sqlite3.c 294454 2010-02-03 20:23:53Z pajoye $
 */
 
 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
diff --git a/ext/sqlite3/libsqlite/sqlite3.h b/ext/sqlite3/libsqlite/sqlite3.h
index 5216154..6709662 100644
--- a/ext/sqlite3/libsqlite/sqlite3.h
+++ b/ext/sqlite3/libsqlite/sqlite3.h
@@ -81,55 +81,43 @@ extern "C" {
 #endif
 
 /*
-** CAPI3REF: Compile-Time Library Version Numbers {H10010} <S60100>
-**
-** The SQLITE_VERSION and SQLITE_VERSION_NUMBER #defines in
-** the sqlite3.h file specify the version of SQLite with which
-** that header file is associated.
-**
-** The "version" of SQLite is a string of the form "W.X.Y" or "W.X.Y.Z".
-** The W value is major version number and is always 3 in SQLite3.
-** The W value only changes when backwards compatibility is
-** broken and we intend to never break backwards compatibility.
-** The X value is the minor version number and only changes when
-** there are major feature enhancements that are forwards compatible
-** but not backwards compatible.
-** The Y value is the release number and is incremented with
-** each release but resets back to 0 whenever X is incremented.
-** The Z value only appears on branch releases.
-**
-** The SQLITE_VERSION_NUMBER is an integer that is computed as
-** follows:
-**
-** <blockquote><pre>
-** SQLITE_VERSION_NUMBER = W*1000000 + X*1000 + Y
-** </pre></blockquote>
+** CAPI3REF: Compile-Time Library Version Numbers
+**
+** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
+** evaluates to a string literal that is the SQLite version in the
+** format "X.Y.Z" where X is the major version number (always 3 for
+** SQLite3) and Y is the minor version number and Z is the release number.)^
+** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
+** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
+** numbers used in [SQLITE_VERSION].)^
+** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
+** be larger than the release from which it is derived.  Either Y will
+** be held constant and Z will be incremented or else Y will be incremented
+** and Z will be reset to zero.
 **
 ** 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 is a string which identifies a particular check-in of SQLite
-** within its configuration management system.  The string contains the
-** date and time of the check-in (UTC) and an SHA1 hash of the entire
-** source tree.
+** <a href="http://www.fossil-scm.org/">Fossil configuration management
+** system</a>.  ^The SQLITE_SOURCE_ID macro evalutes 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
+** hash of the entire source tree.
 **
 ** See also: [sqlite3_libversion()],
 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
 ** [sqlite_version()] and [sqlite_source_id()].
-**
-** Requirements: [H10011] [H10014]
 */
-#define SQLITE_VERSION        "3.6.19"
-#define SQLITE_VERSION_NUMBER 3006019
-#define SQLITE_SOURCE_ID      "2009-10-14 11:33:55 c1d499afc50d54b376945b4efb65c56c787a073d"
+#define SQLITE_VERSION        "3.6.22"
+#define SQLITE_VERSION_NUMBER 3006022
+#define SQLITE_SOURCE_ID      "2010-01-05 15:30:36 28d0d7710761114a44a1a3a425a6883c661f06e7"
 
 /*
-** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
+** CAPI3REF: Run-Time Library Version Numbers
 ** KEYWORDS: sqlite3_version
 **
 ** These interfaces provide the same information as the [SQLITE_VERSION],
-** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] #defines in the header,
-** but are associated with the library instead of the header file.  Cautious
+** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
+** but are associated with the library instead of the header file.  ^(Cautious
 ** programmers might include assert() statements in their application to
 ** verify that values returned by these interfaces match the macros in
 ** the header, and thus insure that the application is
@@ -138,19 +126,20 @@ extern "C" {
 ** <blockquote><pre>
 ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
 ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
-** assert( strcmp(sqlite3_libversion,SQLITE_VERSION)==0 );
-** </pre></blockquote>
-**
-** The sqlite3_libversion() function returns the same information as is
-** in the sqlite3_version[] string constant.  The function is provided
-** for use in DLLs since DLL users usually do not have direct access to string
-** constants within the DLL.  Similarly, the sqlite3_sourceid() function
-** returns the same information as is in the [SQLITE_SOURCE_ID] #define of
-** the header file.
+** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
+** </pre></blockquote>)^
+**
+** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
+** macro.  ^The sqlite3_libversion() function returns a pointer to the
+** to the sqlite3_version[] string constant.  The sqlite3_libversion()
+** function is provided for use in DLLs since DLL users usually do not have
+** direct access to string constants within the DLL.  ^The
+** sqlite3_libversion_number() function returns an integer equal to
+** [SQLITE_VERSION_NUMBER].  ^The sqlite3_sourceid() function a pointer
+** to a string constant whose value is the same as the [SQLITE_SOURCE_ID]
+** C preprocessor macro.
 **
 ** See also: [sqlite_version()] and [sqlite_source_id()].
-**
-** Requirements: [H10021] [H10022] [H10023]
 */
 SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
 SQLITE_API const char *sqlite3_libversion(void);
@@ -158,7 +147,11 @@ SQLITE_API const char *sqlite3_sourceid(void);
 SQLITE_API int sqlite3_libversion_number(void);
 
 /*
-** CAPI3REF: Test To See If The Library Is Threadsafe {H10100} <S60100>
+** CAPI3REF: Test To See If The Library Is Threadsafe
+**
+** ^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 can be compiled with or without mutexes.  When
 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
@@ -170,7 +163,7 @@ SQLITE_API int sqlite3_libversion_number(void);
 ** Enabling mutexes incurs a measurable performance penalty.
 ** So if speed is of utmost importance, it makes sense to disable
 ** the mutexes.  But for maximum safety, mutexes should be enabled.
-** The default behavior is for mutexes to be enabled.
+** ^The default behavior is for mutexes to be enabled.
 **
 ** This interface can be used by an application to make sure that the
 ** version of SQLite that it is linking against was compiled with
@@ -178,21 +171,21 @@ SQLITE_API int sqlite3_libversion_number(void);
 **
 ** This interface only reports on the compile-time mutex setting
 ** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with
-** SQLITE_THREADSAFE=1 then mutexes are enabled by default but
+** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
 ** can be fully or partially disabled using a call to [sqlite3_config()]
 ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
-** or [SQLITE_CONFIG_MUTEX].  The return value of this function shows
-** only the default compile-time setting, not any run-time changes
-** to that setting.
+** or [SQLITE_CONFIG_MUTEX].  ^(The return value of the
+** sqlite3_threadsafe() function shows only the compile-time setting of
+** thread safety, not any run-time changes to that setting made by
+** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
+** is unchanged by calls to sqlite3_config().)^
 **
 ** See the [threading mode] documentation for additional information.
-**
-** Requirements: [H10101] [H10102]
 */
 SQLITE_API int sqlite3_threadsafe(void);
 
 /*
-** CAPI3REF: Database Connection Handle {H12000} <S40200>
+** CAPI3REF: Database Connection Handle
 ** KEYWORDS: {database connection} {database connections}
 **
 ** Each open SQLite database is represented by a pointer to an instance of
@@ -207,7 +200,7 @@ SQLITE_API int sqlite3_threadsafe(void);
 typedef struct sqlite3 sqlite3;
 
 /*
-** CAPI3REF: 64-Bit Integer Types {H10200} <S10110>
+** CAPI3REF: 64-Bit Integer Types
 ** KEYWORDS: sqlite_int64 sqlite_uint64
 **
 ** Because there is no cross-platform way to specify 64-bit integer types
@@ -217,7 +210,10 @@ typedef struct sqlite3 sqlite3;
 ** The sqlite_int64 and sqlite_uint64 types are supported for backwards
 ** compatibility only.
 **
-** Requirements: [H10201] [H10202]
+** ^The sqlite3_int64 and sqlite_int64 types can store integer values
+** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
+** sqlite3_uint64 and sqlite_uint64 types can store integer values 
+** between 0 and +18446744073709551615 inclusive.
 */
 #ifdef SQLITE_INT64_TYPE
   typedef SQLITE_INT64_TYPE sqlite_int64;
@@ -241,34 +237,28 @@ typedef sqlite_uint64 sqlite3_uint64;
 #endif
 
 /*
-** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200>
+** CAPI3REF: Closing A Database Connection
 **
-** This routine is the destructor for the [sqlite3] object.
+** ^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.
 **
-** Applications should [sqlite3_finalize | finalize] all [prepared statements]
+** Applications must [sqlite3_finalize | finalize] all [prepared statements]
 ** and [sqlite3_blob_close | close] all [BLOB handles] associated with
-** the [sqlite3] object prior to attempting to close the object.
-** The [sqlite3_next_stmt()] interface can be used to locate all
-** [prepared statements] associated with a [database connection] if desired.
-** Typical code might look like this:
-**
-** <blockquote><pre>
-** sqlite3_stmt *pStmt;
-** while( (pStmt = sqlite3_next_stmt(db, 0))!=0 ){
-**     sqlite3_finalize(pStmt);
-** }
-** </pre></blockquote>
+** the [sqlite3] object prior to attempting to close the object.  ^If
+** sqlite3_close() is called on a [database connection] that still has
+** outstanding [prepared statements] or [BLOB handles], then it returns
+** SQLITE_BUSY.
 **
-** If [sqlite3_close()] is invoked while a transaction is open,
+** ^If [sqlite3_close()] is invoked while a transaction is open,
 ** the transaction is automatically rolled back.
 **
 ** The C parameter to [sqlite3_close(C)] must be either a NULL
 ** pointer or an [sqlite3] object pointer obtained
 ** from [sqlite3_open()], [sqlite3_open16()], or
 ** [sqlite3_open_v2()], and not previously closed.
-**
-** Requirements:
-** [H12011] [H12012] [H12013] [H12014] [H12015] [H12019]
+** ^Calling sqlite3_close() with a NULL pointer argument is a 
+** harmless no-op.
 */
 SQLITE_API int sqlite3_close(sqlite3 *);
 
@@ -280,48 +270,65 @@ SQLITE_API int sqlite3_close(sqlite3 *);
 typedef int (*sqlite3_callback)(void*,int,char**, char**);
 
 /*
-** CAPI3REF: One-Step Query Execution Interface {H12100} <S10000>
-**
-** The sqlite3_exec() interface is a convenient way of running one or more
-** SQL statements without having to write a lot of C code.  The UTF-8 encoded
-** SQL statements are passed in as the second parameter to sqlite3_exec().
-** The statements are evaluated one by one until either an error or
-** an interrupt is encountered, or until they are all done.  The 3rd parameter
-** is an optional callback that is invoked once for each row of any query
-** results produced by the SQL statements.  The 5th parameter tells where
-** to write any error messages.
-**
-** The error message passed back through the 5th parameter is held
-** in memory obtained from [sqlite3_malloc()].  To avoid a memory leak,
-** the calling application should call [sqlite3_free()] on any error
-** message returned through the 5th parameter when it has finished using
-** the error message.
-**
-** If the SQL statement in the 2nd parameter is NULL or an empty string
-** or a string containing only whitespace and comments, then no SQL
-** statements are evaluated and the database is not changed.
+** CAPI3REF: One-Step Query Execution Interface
+**
+** The sqlite3_exec() interface is a convenience wrapper around
+** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
+** that allows an application to run multiple statements of SQL
+** without having to use a lot of C code. 
+**
+** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
+** semicolon-separate SQL statements passed into its 2nd argument,
+** in the context of the [database connection] passed in as its 1st
+** argument.  ^If the callback function of the 3rd argument to
+** sqlite3_exec() is not NULL, then it is invoked for each result row
+** coming out of the evaluated SQL statements.  ^The 4th argument to
+** to sqlite3_exec() is relayed through to the 1st argument of each
+** callback invocation.  ^If the callback pointer to sqlite3_exec()
+** is NULL, then no callback is ever invoked and result rows are
+** ignored.
+**
+** ^If an error occurs while evaluating the SQL statements passed into
+** sqlite3_exec(), then execution of the current statement stops and
+** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()
+** is not NULL then any error message is written into memory obtained
+** from [sqlite3_malloc()] and passed back through the 5th parameter.
+** To avoid memory leaks, the application should invoke [sqlite3_free()]
+** on error message strings returned through the 5th parameter of
+** of sqlite3_exec() after the error message string is no longer needed.
+** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
+** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
+** NULL before returning.
+**
+** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
+** routine returns SQLITE_ABORT without invoking the callback again and
+** without running any subsequent SQL statements.
+**
+** ^The 2nd argument to the sqlite3_exec() callback function is the
+** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()
+** callback is an array of pointers to strings obtained as if from
+** [sqlite3_column_text()], one for each column.  ^If an element of a
+** result row is NULL then the corresponding string pointer for the
+** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the
+** sqlite3_exec() callback is an array of pointers to strings where each
+** entry represents the name of corresponding result column as obtained
+** from [sqlite3_column_name()].
+**
+** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
+** to an empty string, or a pointer that contains only whitespace and/or 
+** SQL comments, then no SQL statements are evaluated and the database
+** is not changed.
+**
+** Restrictions:
 **
-** The sqlite3_exec() interface is implemented in terms of
-** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
-** The sqlite3_exec() routine does nothing to the database that cannot be done
-** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
-**
-** The first parameter to [sqlite3_exec()] must be an valid and open
-** [database connection].
-**
-** The database connection must not be closed while
-** [sqlite3_exec()] is running.
-**
-** The calling function should use [sqlite3_free()] to free
-** the memory that *errmsg is left pointing at once the error
-** message is no longer needed.
-**
-** The SQL statement text in the 2nd parameter to [sqlite3_exec()]
-** must remain unchanged while [sqlite3_exec()] is running.
-**
-** Requirements:
-** [H12101] [H12102] [H12104] [H12105] [H12107] [H12110] [H12113] [H12116]
-** [H12119] [H12122] [H12125] [H12131] [H12134] [H12137] [H12138]
+** <ul>
+** <li> The application must insure that the 1st parameter to sqlite3_exec()
+**      is a valid and open [database connection].
+** <li> The application must not close [database connection] specified by
+**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
+** <li> The application must not modify the SQL statement text passed into
+**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
+** </ul>
 */
 SQLITE_API int sqlite3_exec(
   sqlite3*,                                  /* An open database */
@@ -332,7 +339,7 @@ SQLITE_API int sqlite3_exec(
 );
 
 /*
-** CAPI3REF: Result Codes {H10210} <S10700>
+** CAPI3REF: Result Codes
 ** KEYWORDS: SQLITE_OK {error code} {error codes}
 ** KEYWORDS: {result code} {result codes}
 **
@@ -376,7 +383,7 @@ SQLITE_API int sqlite3_exec(
 /* end-of-error-codes */
 
 /*
-** CAPI3REF: Extended Result Codes {H10220} <S10700>
+** CAPI3REF: Extended Result Codes
 ** KEYWORDS: {extended error code} {extended error codes}
 ** KEYWORDS: {extended result code} {extended result codes}
 **
@@ -418,7 +425,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED | (1<<8) )
 
 /*
-** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
+** CAPI3REF: Flags For File Open Operations
 **
 ** These bit values are intended for use in the
 ** 3rd parameter to the [sqlite3_open_v2()] interface and
@@ -443,7 +450,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */
 
 /*
-** CAPI3REF: Device Characteristics {H10240} <H11120>
+** CAPI3REF: Device Characteristics
 **
 ** The xDeviceCapabilities method of the [sqlite3_io_methods]
 ** object returns an integer which is a vector of the these
@@ -475,7 +482,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_IOCAP_SEQUENTIAL      0x00000400
 
 /*
-** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310>
+** CAPI3REF: File Locking Levels
 **
 ** SQLite uses one of these integer values as the second
 ** argument to calls it makes to the xLock() and xUnlock() methods
@@ -488,7 +495,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_LOCK_EXCLUSIVE     4
 
 /*
-** CAPI3REF: Synchronization Type Flags {H10260} <H11120>
+** CAPI3REF: Synchronization Type Flags
 **
 ** When SQLite invokes the xSync() method of an
 ** [sqlite3_io_methods] object it uses a combination of
@@ -506,7 +513,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_SYNC_DATAONLY      0x00010
 
 /*
-** CAPI3REF: OS Interface Open File Handle {H11110} <S20110>
+** CAPI3REF: OS Interface Open File Handle
 **
 ** An [sqlite3_file] object represents an open file in the 
 ** [sqlite3_vfs | OS interface layer].  Individual OS interface
@@ -522,7 +529,7 @@ struct sqlite3_file {
 };
 
 /*
-** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110>
+** CAPI3REF: OS Interface File Virtual Methods Object
 **
 ** Every file opened by the [sqlite3_vfs] xOpen method populates an
 ** [sqlite3_file] object (or, more commonly, a subclass of the
@@ -627,7 +634,7 @@ struct sqlite3_io_methods {
 };
 
 /*
-** CAPI3REF: Standard File Control Opcodes {H11310} <S30800>
+** CAPI3REF: Standard File Control Opcodes
 **
 ** These integer constants are opcodes for the xFileControl method
 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
@@ -647,7 +654,7 @@ struct sqlite3_io_methods {
 #define SQLITE_LAST_ERRNO             4
 
 /*
-** CAPI3REF: Mutex Handle {H17110} <S20130>
+** CAPI3REF: Mutex Handle
 **
 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
 ** abstract type for a mutex object.  The SQLite core never looks
@@ -659,7 +666,7 @@ struct sqlite3_io_methods {
 typedef struct sqlite3_mutex sqlite3_mutex;
 
 /*
-** CAPI3REF: OS Interface Object {H11140} <S20100>
+** CAPI3REF: OS Interface Object
 **
 ** An instance of the sqlite3_vfs object defines the interface between
 ** the SQLite core and the underlying operating system.  The "vfs"
@@ -813,10 +820,10 @@ struct sqlite3_vfs {
 };
 
 /*
-** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140>
+** CAPI3REF: Flags for the xAccess VFS method
 **
 ** These integer constants can be used as the third parameter to
-** the xAccess method of an [sqlite3_vfs] object. {END}  They determine
+** the xAccess method of an [sqlite3_vfs] object.  They determine
 ** what kind of permissions the xAccess method is looking for.
 ** With SQLITE_ACCESS_EXISTS, the xAccess method
 ** simply checks whether the file exists.
@@ -830,39 +837,48 @@ struct sqlite3_vfs {
 #define SQLITE_ACCESS_READ      2
 
 /*
-** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100>
+** CAPI3REF: Initialize The SQLite Library
 **
-** The sqlite3_initialize() routine initializes the
-** SQLite library.  The sqlite3_shutdown() routine
+** ^The sqlite3_initialize() routine initializes the
+** SQLite library.  ^The sqlite3_shutdown() routine
 ** deallocates any resources that were allocated by sqlite3_initialize().
+** These routines are designed to aid in process initialization and
+** shutdown on embedded systems.  Workstation applications using
+** SQLite normally do not need to invoke either of these routines.
 **
 ** A call to sqlite3_initialize() is an "effective" call if it is
 ** the first time sqlite3_initialize() is invoked during the lifetime of
 ** the process, or if it is the first time sqlite3_initialize() is invoked
-** following a call to sqlite3_shutdown().  Only an effective call
+** following a call to sqlite3_shutdown().  ^(Only an effective call
 ** of sqlite3_initialize() does any initialization.  All other calls
-** are harmless no-ops.
+** are harmless no-ops.)^
 **
 ** A call to sqlite3_shutdown() is an "effective" call if it is the first
-** call to sqlite3_shutdown() since the last sqlite3_initialize().  Only
+** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only
 ** an effective call to sqlite3_shutdown() does any deinitialization.
-** All other calls to sqlite3_shutdown() are harmless no-ops.
+** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
+**
+** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
+** is not.  The sqlite3_shutdown() interface must only be called from a
+** single thread.  All open [database connections] must be closed and all
+** other SQLite resources must be deallocated prior to invoking
+** sqlite3_shutdown().
 **
-** Among other things, sqlite3_initialize() shall invoke
-** sqlite3_os_init().  Similarly, sqlite3_shutdown()
-** shall invoke sqlite3_os_end().
+** Among other things, ^sqlite3_initialize() will invoke
+** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()
+** will invoke sqlite3_os_end().
 **
-** The sqlite3_initialize() routine returns [SQLITE_OK] on success.
-** If for some reason, sqlite3_initialize() is unable to initialize
+** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
+** ^If for some reason, sqlite3_initialize() is unable to initialize
 ** the library (perhaps it is unable to allocate a needed resource such
 ** as a mutex) it returns an [error code] other than [SQLITE_OK].
 **
-** The sqlite3_initialize() routine is called internally by many other
+** ^The sqlite3_initialize() routine is called internally by many other
 ** SQLite interfaces so that an application usually does not need to
 ** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]
 ** calls sqlite3_initialize() so the SQLite library will be automatically
 ** initialized when [sqlite3_open()] is called if it has not be initialized
-** already.  However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
+** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
 ** compile-time option, then the automatic calls to sqlite3_initialize()
 ** are omitted and the application must call sqlite3_initialize() directly
 ** prior to using any other SQLite interface.  For maximum portability,
@@ -901,7 +917,7 @@ SQLITE_API int sqlite3_os_init(void);
 SQLITE_API int sqlite3_os_end(void);
 
 /*
-** CAPI3REF: Configuring The SQLite Library {H14100} <S20000><S30200>
+** CAPI3REF: Configuring The SQLite Library
 ** EXPERIMENTAL
 **
 ** The sqlite3_config() interface is used to make global configuration
@@ -915,7 +931,9 @@ SQLITE_API int sqlite3_os_end(void);
 ** threads while sqlite3_config() is running.  Furthermore, sqlite3_config()
 ** may only be invoked prior to library initialization using
 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
-** Note, however, that sqlite3_config() can be called as part of the
+** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
+** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
+** Note, however, that ^sqlite3_config() can be called as part of the
 ** implementation of an application-defined [sqlite3_os_init()].
 **
 ** The first argument to sqlite3_config() is an integer
@@ -924,26 +942,21 @@ SQLITE_API int sqlite3_os_end(void);
 ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option]
 ** in the first argument.
 **
-** When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
-** If the option is unknown or SQLite is unable to set the option
+** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
+** ^If the option is unknown or SQLite is unable to set the option
 ** then this routine returns a non-zero [error code].
-**
-** Requirements:
-** [H14103] [H14106] [H14120] [H14123] [H14126] [H14129] [H14132] [H14135]
-** [H14138] [H14141] [H14144] [H14147] [H14150] [H14153] [H14156] [H14159]
-** [H14162] [H14165] [H14168]
 */
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
 
 /*
-** CAPI3REF: Configure database connections  {H14200} <S20000>
+** 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
 ** [sqlite3_config()] except that the changes apply to a single
 ** [database connection] (specified in the first argument).  The
-** sqlite3_db_config() interface can only be used immediately after
+** sqlite3_db_config() interface should only be used immediately after
 ** the database connection is created using [sqlite3_open()],
 ** [sqlite3_open16()], or [sqlite3_open_v2()].  
 **
@@ -954,13 +967,13 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
 ** New verbs are likely to be added in future releases of SQLite.
 ** Additional arguments depend on the verb.
 **
-** Requirements:
-** [H14203] [H14206] [H14209] [H14212] [H14215]
+** ^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, ...);
 
 /*
-** CAPI3REF: Memory Allocation Routines {H10155} <S20120>
+** CAPI3REF: Memory Allocation Routines
 ** EXPERIMENTAL
 **
 ** An instance of this object defines the interface between SQLite
@@ -990,7 +1003,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
 ** The xRealloc method must work like realloc() from the standard C library
 ** with the exception that if the second argument to xRealloc is zero,
 ** xRealloc must be a no-op - it must not perform any allocation or
-** deallocation.  SQLite guaranteeds that the second argument to
+** deallocation.  ^SQLite guarantees that the second argument to
 ** xRealloc is always a value returned by a prior call to xRoundup.
 ** And so in cases where xRoundup always returns a positive number,
 ** xRealloc can perform exactly as the standard library realloc() and
@@ -1042,7 +1055,7 @@ struct sqlite3_mem_methods {
 };
 
 /*
-** CAPI3REF: Configuration Options {H10160} <S20000>
+** CAPI3REF: Configuration Options
 ** EXPERIMENTAL
 **
 ** These constants are the available integer configuration options that
@@ -1057,22 +1070,33 @@ struct sqlite3_mem_methods {
 **
 ** <dl>
 ** <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
-** <dd>There are no arguments to this option.  This option disables
+** <dd>There are no arguments to this option.  ^This option sets the
+** [threading mode] to Single-thread.  In other words, it disables
 ** all mutexing and puts SQLite into a mode where it can only be used
-** by a single thread.</dd>
+** by a single thread.   ^If SQLite is compiled with
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
+** it is not possible to change the [threading mode] from its default
+** value of Single-thread and so [sqlite3_config()] will return 
+** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
+** configuration option.</dd>
 **
 ** <dt>SQLITE_CONFIG_MULTITHREAD</dt>
-** <dd>There are no arguments to this option.  This option disables
+** <dd>There are no arguments to this option.  ^This option sets the
+** [threading mode] to Multi-thread.  In other words, it disables
 ** mutexing on [database connection] and [prepared statement] objects.
 ** The application is responsible for serializing access to
 ** [database connections] and [prepared statements].  But other mutexes
 ** are enabled so that SQLite will be safe to use in a multi-threaded
 ** environment as long as no two threads attempt to use the same
-** [database connection] at the same time.  See the [threading mode]
-** documentation for additional information.</dd>
+** [database connection] at the same time.  ^If SQLite is compiled with
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
+** it is not possible to set the Multi-thread [threading mode] and
+** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
+** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
 **
 ** <dt>SQLITE_CONFIG_SERIALIZED</dt>
-** <dd>There are no arguments to this option.  This option enables
+** <dd>There are no arguments to this option.  ^This option sets the
+** [threading mode] to Serialized. In other words, this option enables
 ** all mutexes including the recursive
 ** mutexes on [database connection] and [prepared statement] objects.
 ** In this mode (which is the default when SQLite is compiled with
@@ -1080,55 +1104,63 @@ struct sqlite3_mem_methods {
 ** to [database connections] and [prepared statements] so that the
 ** application is free to use the same [database connection] or the
 ** same [prepared statement] in different threads at the same time.
-** See the [threading mode] documentation for additional information.</dd>
+** ^If SQLite is compiled with
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
+** it is not possible to set the Serialized [threading mode] and
+** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
+** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
 **
 ** <dt>SQLITE_CONFIG_MALLOC</dt>
-** <dd>This option takes a single argument which is a pointer to an
+** <dd> ^(This option takes a single argument which is a pointer to an
 ** instance of the [sqlite3_mem_methods] structure.  The argument specifies
 ** alternative low-level memory allocation routines to be used in place of
-** the memory allocation routines built into SQLite.</dd>
+** the memory allocation routines built into SQLite.)^ ^SQLite makes
+** its own private copy of the content of the [sqlite3_mem_methods] structure
+** before the [sqlite3_config()] call returns.</dd>
 **
 ** <dt>SQLITE_CONFIG_GETMALLOC</dt>
-** <dd>This option takes a single argument which is a pointer to an
+** <dd> ^(This option takes a single argument which is a pointer to an
 ** instance of the [sqlite3_mem_methods] structure.  The [sqlite3_mem_methods]
-** structure is filled with the currently defined memory allocation routines.
+** structure is filled with the currently defined memory allocation routines.)^
 ** This option can be used to overload the default memory allocation
 ** routines with a wrapper that simulations memory allocation failure or
-** tracks memory usage, for example.</dd>
+** tracks memory usage, for example. </dd>
 **
 ** <dt>SQLITE_CONFIG_MEMSTATUS</dt>
-** <dd>This option takes single argument of type int, interpreted as a 
+** <dd> ^This option takes single argument of type int, interpreted as a 
 ** boolean, which enables or disables the collection of memory allocation 
-** statistics. When disabled, the following SQLite interfaces become 
-** non-operational:
+** statistics. ^(When memory allocation statistics are disabled, the 
+** following SQLite interfaces become non-operational:
 **   <ul>
 **   <li> [sqlite3_memory_used()]
 **   <li> [sqlite3_memory_highwater()]
 **   <li> [sqlite3_soft_heap_limit()]
 **   <li> [sqlite3_status()]
-**   </ul>
+**   </ul>)^
+** ^Memory allocation statistics are enabled by default unless SQLite is
+** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
+** allocation statistics are disabled by default.
 ** </dd>
 **
 ** <dt>SQLITE_CONFIG_SCRATCH</dt>
-** <dd>This option specifies a static memory buffer that SQLite can use for
+** <dd> ^This option specifies a static memory buffer that SQLite can use for
 ** scratch memory.  There are three arguments:  A pointer an 8-byte
 ** 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.
-** The first argument should pointer to an 8-byte aligned buffer
+** 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 at once per thread, so
-** N should be set to the expected maximum number of threads.  The sz
-** parameter should be 6 times the size of the largest database page size.
-** Scratch buffers are used as part of the btree balance operation.  If
-** The btree balancer needs additional memory beyond what is provided by
-** scratch buffers or if no scratch buffer space is specified, then SQLite
-** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd>
+** ^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 
+** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
 **
 ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
-** <dd>This option specifies a static memory buffer that SQLite can use for
+** <dd> ^This option specifies a static memory buffer that SQLite can use for
 ** the database page cache with the default page cache implemenation.  
 ** This configuration should not be used if an application-define page
 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
@@ -1136,28 +1168,28 @@ struct sqlite3_mem_methods {
 ** memory, the size of each page buffer (sz), and the number of pages (N).
 ** The sz argument should be the size of the largest database page
 ** (a power of two between 512 and 32768) plus a little extra for each
-** page header.  The page header size is 20 to 40 bytes depending on
-** the host architecture.  It is harmless, apart from the wasted memory,
+** page header.  ^The page header size is 20 to 40 bytes depending on
+** the host architecture.  ^It is harmless, apart from the wasted memory,
 ** to make sz a little too large.  The first
 ** argument should point to an allocation of at least sz*N bytes of memory.
-** SQLite will use the memory provided by the first argument to satisfy its
-** memory needs for the first N pages that it adds to cache.  If additional
+** ^SQLite will use the memory provided by the first argument to satisfy its
+** 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 
+** ^The implementation might use one or more of the N buffers to hold 
 ** memory accounting information. The pointer in the first argument must
 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
 ** will be undefined.</dd>
 **
 ** <dt>SQLITE_CONFIG_HEAP</dt>
-** <dd>This option specifies a static memory buffer that SQLite will use
+** <dd> ^This option specifies a static memory buffer that SQLite will use
 ** for all of its dynamic memory allocation needs beyond those provided
 ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
 ** There are three arguments: An 8-byte aligned pointer to the memory,
 ** the number of bytes in the memory buffer, and the minimum allocation size.
-** If the first pointer (the memory pointer) is NULL, then SQLite reverts
+** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
 ** to using its default memory allocator (the system malloc() implementation),
-** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  If the
+** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the
 ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
 ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
 ** allocator is engaged to handle all of SQLites memory allocation needs.
@@ -1165,39 +1197,50 @@ struct sqlite3_mem_methods {
 ** boundary or subsequent behavior of SQLite will be undefined.</dd>
 **
 ** <dt>SQLITE_CONFIG_MUTEX</dt>
-** <dd>This option takes a single argument which is a pointer to an
+** <dd> ^(This option takes a single argument which is a pointer to an
 ** instance of the [sqlite3_mutex_methods] structure.  The argument specifies
 ** alternative low-level mutex routines to be used in place
-** the mutex routines built into SQLite.</dd>
+** the mutex routines built into SQLite.)^  ^SQLite makes a copy of the
+** content of the [sqlite3_mutex_methods] structure before the call to
+** [sqlite3_config()] returns. ^If SQLite is compiled with
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
+** the entire mutexing subsystem is omitted from the build and hence calls to
+** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
+** return [SQLITE_ERROR].</dd>
 **
 ** <dt>SQLITE_CONFIG_GETMUTEX</dt>
-** <dd>This option takes a single argument which is a pointer to an
+** <dd> ^(This option takes a single argument which is a pointer to an
 ** instance of the [sqlite3_mutex_methods] structure.  The
 ** [sqlite3_mutex_methods]
-** structure is filled with the currently defined mutex routines.
+** structure is filled with the currently defined mutex routines.)^
 ** This option can be used to overload the default mutex allocation
 ** routines with a wrapper used to track mutex usage for performance
-** profiling or testing, for example.</dd>
+** profiling or testing, for example.   ^If SQLite is compiled with
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
+** the entire mutexing subsystem is omitted from the build and hence calls to
+** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
+** return [SQLITE_ERROR].</dd>
 **
 ** <dt>SQLITE_CONFIG_LOOKASIDE</dt>
-** <dd>This option takes two arguments that determine the default
-** memory allocation lookaside optimization.  The first argument is the
+** <dd> ^(This option takes two arguments that determine the default
+** memory allocation for the lookaside memory allocator on each
+** [database connection].  The first argument is the
 ** size of each lookaside buffer slot and the second is the number of
-** slots allocated to each database connection.  This option sets the
-** <i>default</i> lookaside size.  The [SQLITE_DBCONFIG_LOOKASIDE]
+** slots allocated to each database connection.)^  ^(This option sets the
+** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
 ** verb to [sqlite3_db_config()] can be used to change the lookaside
-** configuration on individual connections.</dd>
+** configuration on individual connections.)^ </dd>
 **
 ** <dt>SQLITE_CONFIG_PCACHE</dt>
-** <dd>This option takes a single argument which is a pointer to
+** <dd> ^(This option takes a single argument which is a pointer to
 ** an [sqlite3_pcache_methods] object.  This object specifies the interface
-** to a custom page cache implementation.  SQLite makes a copy of the
+** to a custom page cache implementation.)^  ^SQLite makes a copy of the
 ** object and uses it for page cache memory allocations.</dd>
 **
 ** <dt>SQLITE_CONFIG_GETPCACHE</dt>
-** <dd>This option takes a single argument which is a pointer to an
+** <dd> ^(This option takes a single argument which is a pointer to an
 ** [sqlite3_pcache_methods] object.  SQLite copies of the current
-** page cache implementation into that object.</dd>
+** page cache implementation into that object.)^ </dd>
 **
 ** </dl>
 */
@@ -1218,7 +1261,7 @@ struct sqlite3_mem_methods {
 #define SQLITE_CONFIG_GETPCACHE    15  /* sqlite3_pcache_methods* */
 
 /*
-** CAPI3REF: Configuration Options {H10170} <S20000>
+** CAPI3REF: Configuration Options
 ** EXPERIMENTAL
 **
 ** These constants are the available integer configuration options that
@@ -1227,23 +1270,25 @@ struct sqlite3_mem_methods {
 ** New configuration options may be added in future releases of SQLite.
 ** Existing configuration options might be discontinued.  Applications
 ** should check the return code from [sqlite3_db_config()] to make sure that
-** the call worked.  The [sqlite3_db_config()] interface will return a
+** the call worked.  ^The [sqlite3_db_config()] interface will return a
 ** non-zero [error code] if a discontinued or unsupported configuration option
 ** is invoked.
 **
 ** <dl>
 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
-** <dd>This option takes three additional arguments that determine the 
+** <dd> ^This option takes three additional arguments that determine the 
 ** [lookaside memory allocator] configuration for the [database connection].
-** The first argument (the third parameter to [sqlite3_db_config()] is a
+** ^The first argument (the third parameter to [sqlite3_db_config()] is a
 ** pointer to an memory buffer to use for lookaside memory.
-** The first argument may be NULL in which case SQLite will allocate the
-** lookaside buffer itself using [sqlite3_malloc()].  The second argument is the
-** size of each lookaside buffer slot and the third argument is the number of
+** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
+** may be NULL in which case SQLite will allocate the
+** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
+** size of each lookaside buffer slot.  ^The third argument is the number of
 ** slots.  The size of the buffer in the first argument must be greater than
 ** 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 is not
-** a multiple of 8, it is internally rounded down to the next smaller
+** 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>
 **
 ** </dl>
@@ -1252,52 +1297,49 @@ struct sqlite3_mem_methods {
 
 
 /*
-** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700>
-**
-** The sqlite3_extended_result_codes() routine enables or disables the
-** [extended result codes] feature of SQLite. The extended result
-** codes are disabled by default for historical compatibility considerations.
+** CAPI3REF: Enable Or Disable Extended Result Codes
 **
-** Requirements:
-** [H12201] [H12202]
+** ^The sqlite3_extended_result_codes() routine enables or disables the
+** [extended result codes] feature of SQLite. ^The extended result
+** codes are disabled by default for historical compatibility.
 */
 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
 
 /*
-** CAPI3REF: Last Insert Rowid {H12220} <S10700>
+** CAPI3REF: Last Insert Rowid
 **
-** Each entry in an SQLite table has a unique 64-bit signed
-** integer key called the [ROWID | "rowid"]. The rowid is always available
+** ^Each entry in an SQLite table has a unique 64-bit signed
+** integer key called the [ROWID | "rowid"]. ^The rowid is always available
 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
-** names are not also used by explicitly declared columns. If
+** names are not also used by explicitly declared columns. ^If
 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
 ** is another alias for the rowid.
 **
-** This routine returns the [rowid] of the most recent
+** ^This routine returns the [rowid] of the most recent
 ** successful [INSERT] into the database from the [database connection]
-** in the first argument.  If no successful [INSERT]s
+** in the first argument.  ^If no successful [INSERT]s
 ** have ever occurred on that database connection, zero is returned.
 **
-** If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
+** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
 ** row is returned by this routine as long as the trigger is running.
 ** But once the trigger terminates, the value returned by this routine
-** reverts to the last value inserted before the trigger fired.
+** reverts to the last value inserted before the trigger fired.)^
 **
-** An [INSERT] that fails due to a constraint violation is not a
+** ^An [INSERT] that fails due to a constraint violation is not a
 ** successful [INSERT] and does not change the value returned by this
-** routine.  Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
+** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
 ** and INSERT OR ABORT make no changes to the return value of this
-** routine when their insertion fails.  When INSERT OR REPLACE
+** routine when their insertion fails.  ^(When INSERT OR REPLACE
 ** encounters a constraint violation, it does not fail.  The
 ** INSERT continues to completion after deleting rows that caused
 ** the constraint problem so INSERT OR REPLACE will always change
-** the return value of this interface.
+** the return value of this interface.)^
 **
-** For the purposes of this routine, an [INSERT] is considered to
+** ^For the purposes of this routine, an [INSERT] is considered to
 ** be successful even if it is subsequently rolled back.
 **
-** Requirements:
-** [H12221] [H12223]
+** This function is accessible to SQL statements via the
+** [last_insert_rowid() SQL function].
 **
 ** If a separate thread performs a new [INSERT] on the same
 ** database connection while the [sqlite3_last_insert_rowid()]
@@ -1309,25 +1351,25 @@ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
 
 /*
-** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600>
+** CAPI3REF: Count The Number Of Rows Modified
 **
-** This function returns the number of database rows that were changed
+** ^This function returns the number of database rows that were changed
 ** or inserted or deleted by the most recently completed SQL statement
 ** on the [database connection] specified by the first parameter.
-** Only changes that are directly specified by the [INSERT], [UPDATE],
+** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
 ** or [DELETE] statement are counted.  Auxiliary changes caused by
-** triggers or [foreign key actions] are not counted. Use the
+** triggers or [foreign key actions] are not counted.)^ Use the
 ** [sqlite3_total_changes()] function to find the total number of changes
 ** including changes caused by triggers and foreign key actions.
 **
-** Changes to a view that are simulated by an [INSTEAD OF trigger]
+** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
 ** are not counted.  Only real table changes are counted.
 **
-** A "row change" is a change to a single row of a single table
+** ^(A "row change" is a change to a single row of a single table
 ** caused by an INSERT, DELETE, or UPDATE statement.  Rows that
 ** are changed as side effects of [REPLACE] constraint resolution,
 ** rollback, ABORT processing, [DROP TABLE], or by any other
-** mechanisms do not count as direct row changes.
+** mechanisms do not count as direct row changes.)^
 **
 ** A "trigger context" is a scope of execution that begins and
 ** ends with the script of a [CREATE TRIGGER | trigger]. 
@@ -1337,27 +1379,24 @@ SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
 ** new trigger context is entered for the duration of that one
 ** trigger.  Subtriggers create subcontexts for their duration.
 **
-** Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
+** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
 ** not create a new trigger context.
 **
-** This function returns the number of direct row changes in the
+** ^This function returns the number of direct row changes in the
 ** most recent INSERT, UPDATE, or DELETE statement within the same
 ** trigger context.
 **
-** Thus, when called from the top level, this function returns the
+** ^Thus, when called from the top level, this function returns the
 ** number of changes in the most recent INSERT, UPDATE, or DELETE
-** that also occurred at the top level.  Within the body of a trigger,
+** that also occurred at the top level.  ^(Within the body of a trigger,
 ** the sqlite3_changes() interface can be called to find the number of
 ** changes in the most recently completed INSERT, UPDATE, or DELETE
 ** statement within the body of the same trigger.
 ** However, the number returned does not include changes
-** caused by subtriggers since those have their own context.
+** caused by subtriggers since those have their own context.)^
 **
-** See also the [sqlite3_total_changes()] interface and the
-** [count_changes pragma].
-**
-** Requirements:
-** [H12241] [H12243]
+** See also the [sqlite3_total_changes()] interface, the
+** [count_changes pragma], and the [changes() SQL function].
 **
 ** If a separate thread makes changes on the same database connection
 ** while [sqlite3_changes()] is running then the value returned
@@ -1366,26 +1405,24 @@ SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
 SQLITE_API int sqlite3_changes(sqlite3*);
 
 /*
-** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
+** CAPI3REF: Total Number Of Rows Modified
 **
-** This function returns the number of row changes caused by [INSERT],
+** ^This function returns the number of row changes caused by [INSERT],
 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
-** The count includes all changes from all [CREATE TRIGGER | trigger] 
-** contexts and changes made by [foreign key actions]. However,
+** ^(The count returned by sqlite3_total_changes() includes all changes
+** from all [CREATE TRIGGER | trigger] contexts and changes made by
+** [foreign key actions]. However,
 ** the count does not include changes used to implement [REPLACE] constraints,
 ** do rollbacks or ABORT processing, or [DROP TABLE] processing.  The
 ** count does not include rows of views that fire an [INSTEAD OF trigger],
 ** though if the INSTEAD OF trigger makes changes of its own, those changes 
-** are counted.
-** The changes are counted as soon as the statement that makes them is
-** completed (when the statement handle is passed to [sqlite3_reset()] or
-** [sqlite3_finalize()]).
-**
-** See also the [sqlite3_changes()] interface and the
-** [count_changes pragma].
+** are counted.)^
+** ^The sqlite3_total_changes() function counts the changes as soon as
+** the statement that makes them is completed (when the statement handle
+** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
 **
-** Requirements:
-** [H12261] [H12263]
+** See also the [sqlite3_changes()] interface, the
+** [count_changes pragma], and the [total_changes() SQL function].
 **
 ** If a separate thread makes changes on the same database connection
 ** while [sqlite3_total_changes()] is running then the value
@@ -1394,75 +1431,70 @@ SQLITE_API int sqlite3_changes(sqlite3*);
 SQLITE_API int sqlite3_total_changes(sqlite3*);
 
 /*
-** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500>
+** CAPI3REF: Interrupt A Long-Running Query
 **
-** This function causes any pending database operation to abort and
+** ^This function causes any pending database operation to abort and
 ** return at its earliest opportunity. This routine is typically
 ** called in response to a user action such as pressing "Cancel"
 ** or Ctrl-C where the user wants a long query operation to halt
 ** immediately.
 **
-** It is safe to call this routine from a thread different from the
+** ^It is safe to call this routine from a thread different from the
 ** thread that is currently running the database operation.  But it
 ** is not safe to call this routine with a [database connection] that
 ** is closed or might close before sqlite3_interrupt() returns.
 **
-** If an SQL operation is very nearly finished at the time when
+** ^If an SQL operation is very nearly finished at the time when
 ** sqlite3_interrupt() is called, then it might not have an opportunity
 ** to be interrupted and might continue to completion.
 **
-** An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
-** If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
+** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
+** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
 ** that is inside an explicit transaction, then the entire transaction
 ** will be rolled back automatically.
 **
-** The sqlite3_interrupt(D) call is in effect until all currently running
-** SQL statements on [database connection] D complete.  Any new SQL statements
+** ^The sqlite3_interrupt(D) call is in effect until all currently running
+** SQL statements on [database connection] D complete.  ^Any new SQL statements
 ** that are started after the sqlite3_interrupt() call and before the 
 ** running statements reaches zero are interrupted as if they had been
-** running prior to the sqlite3_interrupt() call.  New SQL statements
+** running prior to the sqlite3_interrupt() call.  ^New SQL statements
 ** that are started after the running statement count reaches zero are
 ** not effected by the sqlite3_interrupt().
-** A call to sqlite3_interrupt(D) that occurs when there are no running
+** ^A call to sqlite3_interrupt(D) that occurs when there are no running
 ** SQL statements is a no-op and has no effect on SQL statements
 ** that are started after the sqlite3_interrupt() call returns.
 **
-** Requirements:
-** [H12271] [H12272]
-**
 ** If the database connection closes while [sqlite3_interrupt()]
 ** is running then bad things will likely happen.
 */
 SQLITE_API void sqlite3_interrupt(sqlite3*);
 
 /*
-** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200>
+** CAPI3REF: Determine If An SQL Statement Is Complete
 **
 ** These routines are useful during command-line input to determine if the
 ** currently entered text seems to form a complete SQL statement or
 ** if additional input is needed before sending the text into
-** SQLite for parsing.  These routines return 1 if the input string
-** appears to be a complete SQL statement.  A statement is judged to be
+** SQLite for parsing.  ^These routines return 1 if the input string
+** appears to be a complete SQL statement.  ^A statement is judged to be
 ** complete if it ends with a semicolon token and is not a prefix of a
-** well-formed CREATE TRIGGER statement.  Semicolons that are embedded within
+** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within
 ** string literals or quoted identifier names or comments are not
 ** independent tokens (they are part of the token in which they are
-** embedded) and thus do not count as a statement terminator.  Whitespace
+** embedded) and thus do not count as a statement terminator.  ^Whitespace
 ** and comments that follow the final semicolon are ignored.
 **
-** These routines return 0 if the statement is incomplete.  If a
+** ^These routines return 0 if the statement is incomplete.  ^If a
 ** memory allocation fails, then SQLITE_NOMEM is returned.
 **
-** These routines do not parse the SQL statements thus
+** ^These routines do not parse the SQL statements thus
 ** will not detect syntactically incorrect SQL.
 **
-** If SQLite has not been initialized using [sqlite3_initialize()] prior 
+** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior 
 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
 ** automatically by sqlite3_complete16().  If that initialization fails,
 ** then the return value from sqlite3_complete16() will be non-zero
-** regardless of whether or not the input SQL is complete.
-**
-** Requirements: [H10511] [H10512]
+** regardless of whether or not the input SQL is complete.)^
 **
 ** The input to [sqlite3_complete()] must be a zero-terminated
 ** UTF-8 string.
@@ -1474,27 +1506,27 @@ SQLITE_API int sqlite3_complete(const char *sql);
 SQLITE_API int sqlite3_complete16(const void *sql);
 
 /*
-** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400>
+** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
 **
-** This routine sets a callback function that might be invoked whenever
+** ^This routine sets a callback function that might be invoked whenever
 ** an attempt is made to open a database table that another thread
 ** or process has locked.
 **
-** If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
-** is returned immediately upon encountering the lock. If the busy callback
-** is not NULL, then the callback will be invoked with two arguments.
+** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
+** is returned immediately upon encountering the lock.  ^If the busy callback
+** is not NULL, then the callback might be invoked with two arguments.
 **
-** The first argument to the handler is a copy of the void* pointer which
-** is the third argument to sqlite3_busy_handler().  The second argument to
-** the handler callback is the number of times that the busy handler has
-** been invoked for this locking event.  If the
+** ^The first argument to the busy handler is a copy of the void* pointer which
+** is the third argument to sqlite3_busy_handler().  ^The second argument to
+** the busy handler callback is the number of times that the busy handler has
+** been invoked for this locking event.  ^If the
 ** busy callback returns 0, then no additional attempts are made to
 ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
-** If the callback returns non-zero, then another attempt
+** ^If the callback returns non-zero, then another attempt
 ** is made to open the database for reading and the cycle repeats.
 **
 ** The presence of a busy handler does not guarantee that it will be invoked
-** when there is lock contention. If SQLite determines that invoking the busy
+** when there is lock contention. ^If SQLite determines that invoking the busy
 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
 ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.
 ** Consider a scenario where one process is holding a read lock that
@@ -1508,65 +1540,59 @@ SQLITE_API int sqlite3_complete16(const void *sql);
 ** will induce the first process to release its read lock and allow
 ** the second process to proceed.
 **
-** The default busy callback is NULL.
+** ^The default busy callback is NULL.
 **
-** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
+** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
 ** when SQLite is in the middle of a large transaction where all the
 ** changes will not fit into the in-memory cache.  SQLite will
 ** already hold a RESERVED lock on the database file, but it needs
 ** to promote this lock to EXCLUSIVE so that it can spill cache
 ** pages into the database file without harm to concurrent
-** readers.  If it is unable to promote the lock, then the in-memory
+** readers.  ^If it is unable to promote the lock, then the in-memory
 ** cache will be left in an inconsistent state and so the error
 ** code is promoted from the relatively benign [SQLITE_BUSY] to
-** the more severe [SQLITE_IOERR_BLOCKED].  This error code promotion
+** the more severe [SQLITE_IOERR_BLOCKED].  ^This error code promotion
 ** forces an automatic rollback of the changes.  See the
 ** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError">
 ** CorruptionFollowingBusyError</a> wiki page for a discussion of why
 ** this is important.
 **
-** There can only be a single busy handler defined for each
+** ^(There can only be a single busy handler defined for each
 ** [database connection].  Setting a new busy handler clears any
-** previously set handler.  Note that calling [sqlite3_busy_timeout()]
+** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]
 ** will also set or clear the busy handler.
 **
 ** The busy callback should not take any actions which modify the
 ** database connection that invoked the busy handler.  Any such actions
 ** result in undefined behavior.
 ** 
-** Requirements:
-** [H12311] [H12312] [H12314] [H12316] [H12318]
-**
 ** A busy handler must not close the database connection
 ** or [prepared statement] that invoked the busy handler.
 */
 SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
 
 /*
-** CAPI3REF: Set A Busy Timeout {H12340} <S40410>
+** CAPI3REF: Set A Busy Timeout
 **
-** This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
-** for a specified amount of time when a table is locked.  The handler
+** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
+** for a specified amount of time when a table is locked.  ^The handler
 ** will sleep multiple times until at least "ms" milliseconds of sleeping
-** have accumulated. {H12343} After "ms" milliseconds of sleeping,
+** have accumulated.  ^After at least "ms" milliseconds of sleeping,
 ** the handler returns 0 which causes [sqlite3_step()] to return
 ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].
 **
-** Calling this routine with an argument less than or equal to zero
+** ^Calling this routine with an argument less than or equal to zero
 ** turns off all busy handlers.
 **
-** There can only be a single busy handler for a particular
+** ^(There can only be a single busy handler for a particular
 ** [database connection] any any given moment.  If another busy handler
 ** was defined  (using [sqlite3_busy_handler()]) prior to calling
-** this routine, that other busy handler is cleared.
-**
-** Requirements:
-** [H12341] [H12343] [H12344]
+** this routine, that other busy handler is cleared.)^
 */
 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 
 /*
-** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000>
+** CAPI3REF: Convenience Routines For Running Queries
 **
 ** Definition: A <b>result table</b> is memory data structure created by the
 ** [sqlite3_get_table()] interface.  A result table records the
@@ -1614,27 +1640,25 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 **        azResult[7] = "21";
 ** </pre></blockquote>
 **
-** The sqlite3_get_table() function evaluates one or more
+** ^The sqlite3_get_table() function evaluates one or more
 ** semicolon-separated SQL statements in the zero-terminated UTF-8
-** string of its 2nd parameter.  It returns a result table to the
+** string of its 2nd parameter and returns a result table to the
 ** pointer given in its 3rd parameter.
 **
-** After the calling function has finished using the result, it should
-** pass the pointer to the result table to sqlite3_free_table() in order to
+** 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
 ** 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()].
-**
-** Requirements:
-** [H12371] [H12373] [H12374] [H12376] [H12379] [H12382]
+** reflected in subsequent calls to [sqlite3_errcode()] or
+** [sqlite3_errmsg()].)^
 */
 SQLITE_API int sqlite3_get_table(
   sqlite3 *db,          /* An open database */
@@ -1647,33 +1671,33 @@ SQLITE_API int sqlite3_get_table(
 SQLITE_API void sqlite3_free_table(char **result);
 
 /*
-** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000>
+** CAPI3REF: Formatted String Printing Functions
 **
 ** These routines are work-alikes of the "printf()" family of functions
 ** from the standard C library.
 **
-** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
+** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
 ** results into memory obtained from [sqlite3_malloc()].
 ** The strings returned by these two routines should be
-** released by [sqlite3_free()].  Both routines return a
+** released by [sqlite3_free()].  ^Both routines return a
 ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
 ** memory to hold the resulting string.
 **
-** In sqlite3_snprintf() routine is similar to "snprintf()" from
+** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from
 ** the standard C library.  The result is written into the
 ** buffer supplied as the second parameter whose size is given by
 ** the first parameter. Note that the order of the
-** first two parameters is reversed from snprintf().  This is an
+** first two parameters is reversed from snprintf().)^  This is an
 ** historical accident that cannot be fixed without breaking
-** backwards compatibility.  Note also that sqlite3_snprintf()
+** backwards compatibility.  ^(Note also that sqlite3_snprintf()
 ** returns a pointer to its buffer instead of the number of
-** characters actually written into the buffer.  We admit that
+** characters actually written into the buffer.)^  We admit that
 ** the number of characters written would be a more useful return
 ** value but we cannot change the implementation of sqlite3_snprintf()
 ** now without breaking compatibility.
 **
-** As long as the buffer size is greater than zero, sqlite3_snprintf()
-** guarantees that the buffer is always zero-terminated.  The first
+** ^As long as the buffer size is greater than zero, sqlite3_snprintf()
+** guarantees that the buffer is always zero-terminated.  ^The first
 ** parameter "n" is the total size of the buffer, including space for
 ** the zero terminator.  So the longest string that can be completely
 ** written will be n-1 characters.
@@ -1683,9 +1707,9 @@ SQLITE_API void sqlite3_free_table(char **result);
 ** All of the usual printf() formatting options apply.  In addition, there
 ** is are "%q", "%Q", and "%z" options.
 **
-** The %q option works like %s in that it substitutes a null-terminated
+** ^(The %q option works like %s in that it substitutes a null-terminated
 ** string from the argument list.  But %q also doubles every '\'' character.
-** %q is designed for use inside a string literal.  By doubling each '\''
+** %q is designed for use inside a string literal.)^  By doubling each '\''
 ** character it escapes that character and allows it to be inserted into
 ** the string.
 **
@@ -1720,10 +1744,10 @@ SQLITE_API void sqlite3_free_table(char **result);
 ** This second example is an SQL syntax error.  As a general rule you should
 ** always use %q instead of %s when inserting text into a string literal.
 **
-** The %Q option works like %q except it also adds single quotes around
+** ^(The %Q option works like %q except it also adds single quotes around
 ** the outside of the total string.  Additionally, if the parameter in the
 ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
-** single quotes) in place of the %Q option.  So, for example, one could say:
+** single quotes).)^  So, for example, one could say:
 **
 ** <blockquote><pre>
 **  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
@@ -1734,35 +1758,32 @@ SQLITE_API void sqlite3_free_table(char **result);
 ** The code above will render a correct SQL statement in the zSQL
 ** variable even if the zText variable is a NULL pointer.
 **
-** The "%z" formatting option works exactly like "%s" with the
+** ^(The "%z" formatting option works like "%s" but with the
 ** addition that after the string has been read and copied into
-** the result, [sqlite3_free()] is called on the input string. {END}
-**
-** Requirements:
-** [H17403] [H17406] [H17407]
+** the result, [sqlite3_free()] is called on the input string.)^
 */
 SQLITE_API char *sqlite3_mprintf(const char*,...);
 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
 
 /*
-** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000>
+** CAPI3REF: Memory Allocation Subsystem
 **
-** The SQLite core  uses these three routines for all of its own
+** The SQLite core uses these three routines for all of its own
 ** internal memory allocation needs. "Core" in the previous sentence
 ** does not include operating-system specific VFS implementation.  The
 ** Windows VFS uses native malloc() and free() for some operations.
 **
-** The sqlite3_malloc() routine returns a pointer to a block
+** ^The sqlite3_malloc() routine returns a pointer to a block
 ** of memory at least N bytes in length, where N is the parameter.
-** If sqlite3_malloc() is unable to obtain sufficient free
-** memory, it returns a NULL pointer.  If the parameter N to
+** ^If sqlite3_malloc() is unable to obtain sufficient free
+** memory, it returns a NULL pointer.  ^If the parameter N to
 ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
 ** a NULL pointer.
 **
-** Calling sqlite3_free() with a pointer previously returned
+** ^Calling sqlite3_free() with a pointer previously returned
 ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
-** that it might be reused.  The sqlite3_free() routine is
+** that it might be reused.  ^The sqlite3_free() routine is
 ** a no-op if is called with a NULL pointer.  Passing a NULL pointer
 ** to sqlite3_free() is harmless.  After being freed, memory
 ** should neither be read nor written.  Even reading previously freed
@@ -1771,34 +1792,25 @@ SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
 ** might result if sqlite3_free() is called with a non-NULL pointer that
 ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
 **
-** The sqlite3_realloc() interface attempts to resize a
+** ^(The sqlite3_realloc() interface attempts to resize a
 ** prior memory allocation to be at least N bytes, where N is the
 ** second parameter.  The memory allocation to be resized is the first
-** parameter.  If the first parameter to sqlite3_realloc()
+** parameter.)^ ^ If the first parameter to sqlite3_realloc()
 ** is a NULL pointer then its behavior is identical to calling
 ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
-** If the second parameter to sqlite3_realloc() is zero or
+** ^If the second parameter to sqlite3_realloc() is zero or
 ** negative then the behavior is exactly the same as calling
 ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
-** sqlite3_realloc() returns a pointer to a memory allocation
+** ^sqlite3_realloc() returns a pointer to a memory allocation
 ** of at least N bytes in size or NULL if sufficient memory is unavailable.
-** If M is the size of the prior allocation, then min(N,M) bytes
+** ^If M is the size of the prior allocation, then min(N,M) bytes
 ** of the prior allocation are copied into the beginning of buffer returned
 ** by sqlite3_realloc() and the prior allocation is freed.
-** If sqlite3_realloc() returns NULL, then the prior allocation
+** ^If sqlite3_realloc() returns NULL, then the prior allocation
 ** is not freed.
 **
-** The memory returned by sqlite3_malloc() and sqlite3_realloc()
-** is always aligned to at least an 8 byte boundary. {END}
-**
-** The default implementation of the memory allocation subsystem uses
-** the malloc(), realloc() and free() provided by the standard C library.
-** {H17382} However, if SQLite is compiled with the
-** SQLITE_MEMORY_SIZE=<i>NNN</i> C preprocessor macro (where <i>NNN</i>
-** is an integer), then SQLite create a static array of at least
-** <i>NNN</i> bytes in size and uses that array for all of its dynamic
-** memory allocation needs. {END}  Additional memory allocator options
-** may be added in future releases.
+** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
+** is always aligned to at least an 8 byte boundary.
 **
 ** 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
@@ -1813,10 +1825,6 @@ SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
 ** they are reported back as [SQLITE_CANTOPEN] or
 ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
 **
-** Requirements:
-** [H17303] [H17304] [H17305] [H17306] [H17310] [H17312] [H17315] [H17318]
-** [H17321] [H17322] [H17323]
-**
 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
 ** must be either NULL or else pointers obtained from a prior
 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
@@ -1831,20 +1839,33 @@ SQLITE_API void *sqlite3_realloc(void*, int);
 SQLITE_API void sqlite3_free(void*);
 
 /*
-** CAPI3REF: Memory Allocator Statistics {H17370} <S30210>
+** CAPI3REF: Memory Allocator Statistics
 **
 ** SQLite provides these two interfaces for reporting on the status
 ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
 ** routines, which form the built-in memory allocation subsystem.
 **
-** Requirements:
-** [H17371] [H17373] [H17374] [H17375]
+** ^The [sqlite3_memory_used()] routine returns the number of bytes
+** of memory currently outstanding (malloced but not freed).
+** ^The [sqlite3_memory_highwater()] routine returns the maximum
+** value of [sqlite3_memory_used()] since the high-water mark
+** was last reset.  ^The values returned by [sqlite3_memory_used()] and
+** [sqlite3_memory_highwater()] include any overhead
+** added by SQLite in its implementation of [sqlite3_malloc()],
+** but not overhead added by the any underlying system library
+** routines that [sqlite3_malloc()] may call.
+**
+** ^The memory high-water mark is reset to the current value of
+** [sqlite3_memory_used()] if and only if the parameter to
+** [sqlite3_memory_highwater()] is true.  ^The value returned
+** by [sqlite3_memory_highwater(1)] is the high-water mark
+** prior to the reset.
 */
 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
 
 /*
-** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000>
+** CAPI3REF: Pseudo-Random Number Generator
 **
 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
 ** select random [ROWID | ROWIDs] when inserting new records into a table that
@@ -1852,60 +1873,57 @@ SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
 ** the build-in random() and randomblob() SQL functions.  This interface allows
 ** applications to access the same PRNG for other purposes.
 **
-** A call to this routine stores N bytes of randomness into buffer P.
+** ^A call to this routine stores N bytes of randomness into buffer P.
 **
-** The first time this routine is invoked (either internally or by
+** ^The first time this routine is invoked (either internally or by
 ** the application) the PRNG is seeded using randomness obtained
 ** from the xRandomness method of the default [sqlite3_vfs] object.
-** On all subsequent invocations, the pseudo-randomness is generated
+** ^On all subsequent invocations, the pseudo-randomness is generated
 ** internally and without recourse to the [sqlite3_vfs] xRandomness
 ** method.
-**
-** Requirements:
-** [H17392]
 */
 SQLITE_API void sqlite3_randomness(int N, void *P);
 
 /*
-** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100>
+** CAPI3REF: Compile-Time Authorization Callbacks
 **
-** This routine registers a authorizer callback with a particular
+** ^This routine registers a authorizer callback with a particular
 ** [database connection], supplied in the first argument.
-** The authorizer callback is invoked as SQL statements are being compiled
+** ^The authorizer callback is invoked as SQL statements are being compiled
 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
-** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()].  At various
+** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()].  ^At various
 ** points during the compilation process, as logic is being created
 ** to perform various actions, the authorizer callback is invoked to
-** see if those actions are allowed.  The authorizer callback should
+** see if those actions are allowed.  ^The authorizer callback should
 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
 ** specific action but allow the SQL statement to continue to be
 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
-** rejected with an error.  If the authorizer callback returns
+** rejected with an error.  ^If the authorizer callback returns
 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
 ** the authorizer will fail with an error message.
 **
 ** When the callback returns [SQLITE_OK], that means the operation
-** requested is ok.  When the callback returns [SQLITE_DENY], the
+** requested is ok.  ^When the callback returns [SQLITE_DENY], the
 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
 ** authorizer will fail with an error message explaining that
 ** access is denied. 
 **
-** The first parameter to the authorizer callback is a copy of the third
-** parameter to the sqlite3_set_authorizer() interface. The second parameter
+** ^The first parameter to the authorizer callback is a copy of the third
+** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
-** the particular action to be authorized. The third through sixth parameters
+** the particular action to be authorized. ^The third through sixth parameters
 ** to the callback are zero-terminated strings that contain additional
 ** details about the action to be authorized.
 **
-** If the action code is [SQLITE_READ]
+** ^If the action code is [SQLITE_READ]
 ** and the callback returns [SQLITE_IGNORE] then the
 ** [prepared statement] statement is constructed to substitute
 ** a NULL value in place of the table column that would have
 ** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]
 ** return can be used to deny an untrusted user access to individual
 ** columns of a table.
-** If the action code is [SQLITE_DELETE] and the callback returns
+** ^If the action code is [SQLITE_DELETE] and the callback returns
 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
 ** [truncate optimization] is disabled and all rows are deleted individually.
 **
@@ -1925,9 +1943,9 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
 ** and limiting database size using the [max_page_count] [PRAGMA]
 ** in addition to using an authorizer.
 **
-** Only a single authorizer can be in place on a database connection
+** ^(Only a single authorizer can be in place on a database connection
 ** at a time.  Each call to sqlite3_set_authorizer overrides the
-** previous call.  Disable the authorizer by installing a NULL callback.
+** previous call.)^  ^Disable the authorizer by installing a NULL callback.
 ** The authorizer is disabled by default.
 **
 ** The authorizer callback must not do anything that will modify
@@ -1935,20 +1953,16 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
-** When [sqlite3_prepare_v2()] is used to prepare a statement, the
+** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
 ** statement might be re-prepared during [sqlite3_step()] due to a 
 ** schema change.  Hence, the application should ensure that the
 ** correct authorizer callback remains in place during the [sqlite3_step()].
 **
-** Note that the authorizer callback is invoked only during
+** ^Note that the authorizer callback is invoked only during
 ** [sqlite3_prepare()] or its variants.  Authorization is not
 ** performed during statement evaluation in [sqlite3_step()], unless
 ** as stated in the previous paragraph, sqlite3_step() invokes
 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
-**
-** Requirements:
-** [H12501] [H12502] [H12503] [H12504] [H12505] [H12506] [H12507] [H12510]
-** [H12511] [H12512] [H12520] [H12521] [H12522]
 */
 SQLITE_API int sqlite3_set_authorizer(
   sqlite3*,
@@ -1957,7 +1971,7 @@ SQLITE_API int sqlite3_set_authorizer(
 );
 
 /*
-** CAPI3REF: Authorizer Return Codes {H12590} <H12500>
+** CAPI3REF: Authorizer Return Codes
 **
 ** The [sqlite3_set_authorizer | authorizer callback function] must
 ** return either [SQLITE_OK] or one of these two constants in order
@@ -1969,7 +1983,7 @@ SQLITE_API int sqlite3_set_authorizer(
 #define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */
 
 /*
-** CAPI3REF: Authorizer Action Codes {H12550} <H12500>
+** CAPI3REF: Authorizer Action Codes
 **
 ** The [sqlite3_set_authorizer()] interface registers a callback function
 ** that is invoked to authorize certain SQL statement actions.  The
@@ -1980,15 +1994,12 @@ SQLITE_API int sqlite3_set_authorizer(
 ** These action code values signify what kind of operation is to be
 ** authorized.  The 3rd and 4th parameters to the authorization
 ** callback function will be parameters or NULL depending on which of these
-** codes is used as the second parameter.  The 5th parameter to the
+** codes is used as the second parameter.  ^(The 5th parameter to the
 ** authorizer callback is the name of the database ("main", "temp",
-** etc.) if applicable.  The 6th parameter to the authorizer callback
+** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback
 ** is the name of the inner-most trigger or view that is responsible for
 ** the access attempt or NULL if this access attempt is directly from
 ** top-level SQL code.
-**
-** Requirements:
-** [H12551] [H12552] [H12553] [H12554]
 */
 /******************************************* 3rd ************ 4th ***********/
 #define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */
@@ -2026,42 +2037,39 @@ SQLITE_API int sqlite3_set_authorizer(
 #define SQLITE_COPY                  0   /* No longer used */
 
 /*
-** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400>
+** CAPI3REF: Tracing And Profiling Functions
 ** EXPERIMENTAL
 **
 ** These routines register callback functions that can be used for
 ** tracing and profiling the execution of SQL statements.
 **
-** The callback function registered by sqlite3_trace() is invoked at
+** ^The callback function registered by sqlite3_trace() is invoked at
 ** various times when an SQL statement is being run by [sqlite3_step()].
-** The callback returns a UTF-8 rendering of the SQL statement text
-** as the statement first begins executing.  Additional callbacks occur
+** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
+** SQL statement text as the statement first begins executing.
+** ^(Additional sqlite3_trace() callbacks might occur
 ** as each triggered subprogram is entered.  The callbacks for triggers
-** contain a UTF-8 SQL comment that identifies the trigger.
+** contain a UTF-8 SQL comment that identifies the trigger.)^
 **
-** The callback function registered by sqlite3_profile() is invoked
-** as each SQL statement finishes.  The profile callback contains
+** ^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.
-**
-** Requirements:
-** [H12281] [H12282] [H12283] [H12284] [H12285] [H12287] [H12288] [H12289]
-** [H12290]
 */
 SQLITE_API SQLITE_EXPERIMENTAL 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 {H12910} <S60400>
+** CAPI3REF: Query Progress Callbacks
 **
-** This routine configures a callback function - the
+** ^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
 ** interface is to keep a GUI updated during a large query.
 **
-** If the progress callback returns non-zero, the operation is
+** ^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.
 **
@@ -2070,28 +2078,26 @@ SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
-** Requirements:
-** [H12911] [H12912] [H12913] [H12914] [H12915] [H12916] [H12917] [H12918]
-**
 */
 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
 
 /*
-** CAPI3REF: Opening A New Database Connection {H12700} <S40200>
+** CAPI3REF: Opening A New Database Connection
 **
-** These routines open an SQLite database file whose name is given by the
-** filename argument. The filename argument is interpreted as UTF-8 for
+** ^These routines open an SQLite database file whose name is given by the
+** filename argument. ^The filename argument is interpreted as UTF-8 for
 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
-** order for sqlite3_open16(). A [database connection] handle is usually
+** order for sqlite3_open16(). ^(A [database connection] handle is usually
 ** returned in *ppDb, even if an error occurs.  The only exception is that
 ** if SQLite is unable to allocate memory to hold the [sqlite3] object,
 ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
-** object. If the database is opened (and/or created) successfully, then
-** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.  The
+** object.)^ ^(If the database is opened (and/or created) successfully, then
+** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The
 ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
-** an English language description of the error.
+** an English language description of the error following a failure of any
+** of the sqlite3_open() routines.
 **
-** The default encoding for the database will be UTF-8 if
+** ^The default encoding for the database will be UTF-8 if
 ** sqlite3_open() or sqlite3_open_v2() is called and
 ** UTF-16 in the native byte order if sqlite3_open16() is used.
 **
@@ -2101,25 +2107,26 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
 **
 ** The sqlite3_open_v2() interface works like sqlite3_open()
 ** except that it accepts two additional parameters for additional control
-** over the new database connection.  The flags parameter can take one of
+** over the new database connection.  ^(The flags parameter to
+** sqlite3_open_v2() can take one of
 ** the following three values, optionally combined with the 
 ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
-** and/or [SQLITE_OPEN_PRIVATECACHE] flags:
+** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^
 **
 ** <dl>
-** <dt>[SQLITE_OPEN_READONLY]</dt>
+** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
 ** <dd>The database is opened in read-only mode.  If the database does not
-** already exist, an error is returned.</dd>
+** already exist, an error is returned.</dd>)^
 **
-** <dt>[SQLITE_OPEN_READWRITE]</dt>
+** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>
 ** <dd>The database is opened for reading and writing if possible, or reading
 ** only if the file is write protected by the operating system.  In either
-** case the database must already exist, otherwise an error is returned.</dd>
+** case the database must already exist, otherwise an error is returned.</dd>)^
 **
-** <dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
+** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
 ** <dd>The database is opened for reading and writing, and is creates it if
 ** it does not already exist. This is the behavior that is always used for
-** sqlite3_open() and sqlite3_open16().</dd>
+** sqlite3_open() and sqlite3_open16().</dd>)^
 ** </dl>
 **
 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
@@ -2128,33 +2135,33 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
 ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
 ** then the behavior is undefined.
 **
-** If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
+** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
 ** opens in the multi-thread [threading mode] as long as the single-thread
-** mode has not been set at compile-time or start-time.  If the
+** mode has not been set at compile-time or start-time.  ^If the
 ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
 ** in the serialized [threading mode] unless single-thread was
 ** previously selected at compile-time or start-time.
-** The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
+** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
 ** eligible to use [shared cache mode], regardless of whether or not shared
-** cache is enabled using [sqlite3_enable_shared_cache()].  The
+** cache is enabled using [sqlite3_enable_shared_cache()].  ^The
 ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
 ** participate in [shared cache mode] even if it is enabled.
 **
-** If the filename is ":memory:", then a private, temporary in-memory database
-** is created for the connection.  This in-memory database will vanish when
+** ^If the filename is ":memory:", then a private, temporary in-memory database
+** is created for the connection.  ^This in-memory database will vanish when
 ** the database connection is closed.  Future versions of SQLite might
 ** make use of additional special filenames that begin with the ":" character.
 ** It is recommended that when a database filename actually does begin with
 ** a ":" character you should prefix the filename with a pathname such as
 ** "./" to avoid ambiguity.
 **
-** If the filename is an empty string, then a private, temporary
-** on-disk database will be created.  This private database will be
+** ^If the filename is an empty string, then a private, temporary
+** on-disk database will be created.  ^This private database will be
 ** automatically deleted as soon as the database connection is closed.
 **
-** The fourth parameter to sqlite3_open_v2() is the name of the
+** ^The fourth parameter to sqlite3_open_v2() is the name of the
 ** [sqlite3_vfs] object that defines the operating system interface that
-** the new database connection should use.  If the fourth parameter is
+** the new database connection should use.  ^If the fourth parameter is
 ** a NULL pointer then the default [sqlite3_vfs] object is used.
 **
 ** <b>Note to Windows users:</b>  The encoding used for the filename argument
@@ -2162,10 +2169,6 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
 ** codepage is currently defined.  Filenames containing international
 ** characters must be converted to UTF-8 prior to passing them into
 ** sqlite3_open() or sqlite3_open_v2().
-**
-** Requirements:
-** [H12701] [H12702] [H12703] [H12704] [H12706] [H12707] [H12709] [H12711]
-** [H12712] [H12713] [H12714] [H12717] [H12719] [H12721] [H12723]
 */
 SQLITE_API int sqlite3_open(
   const char *filename,   /* Database filename (UTF-8) */
@@ -2183,23 +2186,23 @@ SQLITE_API int sqlite3_open_v2(
 );
 
 /*
-** CAPI3REF: Error Codes And Messages {H12800} <S60200>
+** CAPI3REF: Error Codes And Messages
 **
-** The sqlite3_errcode() interface returns the numeric [result code] or
+** ^The sqlite3_errcode() interface returns the numeric [result code] or
 ** [extended result code] for the most recent failed sqlite3_* API call
 ** associated with a [database connection]. If a prior API call failed
 ** but the most recent API call succeeded, the return value from
-** sqlite3_errcode() is undefined.  The sqlite3_extended_errcode()
+** sqlite3_errcode() is undefined.  ^The sqlite3_extended_errcode()
 ** interface is the same except that it always returns the 
 ** [extended result code] even when extended result codes are
 ** disabled.
 **
-** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
+** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
-** Memory to hold the error message string is managed internally.
+** ^(Memory to hold the error message string is managed internally.
 ** The application does not need to worry about freeing the result.
 ** However, the error string might be overwritten or deallocated by
-** subsequent calls to other SQLite interface functions.
+** subsequent calls to other SQLite interface functions.)^
 **
 ** When the serialized [threading mode] is in use, it might be the
 ** case that a second error occurs on a separate thread in between
@@ -2214,9 +2217,6 @@ SQLITE_API int sqlite3_open_v2(
 ** If an interface fails with SQLITE_MISUSE, that means the interface
 ** was invoked incorrectly by the application.  In that case, the
 ** error code and message may or may not be set.
-**
-** Requirements:
-** [H12801] [H12802] [H12803] [H12807] [H12808] [H12809]
 */
 SQLITE_API int sqlite3_errcode(sqlite3 *db);
 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
@@ -2224,7 +2224,7 @@ SQLITE_API const char *sqlite3_errmsg(sqlite3*);
 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
 
 /*
-** CAPI3REF: SQL Statement Object {H13000} <H13010>
+** CAPI3REF: SQL Statement Object
 ** KEYWORDS: {prepared statement} {prepared statements}
 **
 ** An instance of this object represents a single SQL statement.
@@ -2250,25 +2250,25 @@ SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
 typedef struct sqlite3_stmt sqlite3_stmt;
 
 /*
-** CAPI3REF: Run-time Limits {H12760} <S20600>
+** CAPI3REF: Run-time Limits
 **
-** This interface allows the size of various constructs to be limited
+** ^(This interface allows the size of various constructs to be limited
 ** on a connection by connection basis.  The first parameter is the
 ** [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.  The function returns the old limit.)^
 **
-** If the new limit is a negative number, the limit is unchanged.
-** For the limit category of SQLITE_LIMIT_XYZ there is a 
+** ^If the new limit is a negative number, the limit is unchanged.
+** ^(For the limit category of SQLITE_LIMIT_XYZ there is a 
 ** [limits | hard upper bound]
 ** set by a compile-time C preprocessor macro named 
 ** [limits | SQLITE_MAX_XYZ].
-** (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 limit.
+** (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.
 **
-** Run time limits are intended for use in applications that manage
+** 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
 ** web browser that has its own databases for storing history and
@@ -2282,15 +2282,12 @@ typedef struct sqlite3_stmt sqlite3_stmt;
 ** [max_page_count] [PRAGMA].
 **
 ** New run-time limit categories may be added in future releases.
-**
-** Requirements:
-** [H12762] [H12766] [H12769]
 */
 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 
 /*
-** CAPI3REF: Run-Time Limit Categories {H12790} <H12760>
-** KEYWORDS: {limit category} {limit categories}
+** CAPI3REF: Run-Time Limit Categories
+** KEYWORDS: {limit category} {*limit categories}
 **
 ** These constants define various performance limits
 ** that can be lowered at run-time using [sqlite3_limit()].
@@ -2298,43 +2295,43 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** Additional information is available at [limits | Limits in SQLite].
 **
 ** <dl>
-** <dt>SQLITE_LIMIT_LENGTH</dt>
-** <dd>The maximum size of any string or BLOB or table row.<dd>
+** ^(<dt>SQLITE_LIMIT_LENGTH</dt>
+** <dd>The maximum size of any string or BLOB or table row.<dd>)^
 **
-** <dt>SQLITE_LIMIT_SQL_LENGTH</dt>
-** <dd>The maximum length of an SQL statement.</dd>
+** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
+** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
 **
-** <dt>SQLITE_LIMIT_COLUMN</dt>
+** ^(<dt>SQLITE_LIMIT_COLUMN</dt>
 ** <dd>The maximum number of columns in a table definition or in the
 ** result set of a [SELECT] or the maximum number of columns in an index
-** or in an ORDER BY or GROUP BY clause.</dd>
+** or in an ORDER BY or GROUP BY clause.</dd>)^
 **
-** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
-** <dd>The maximum depth of the parse tree on any expression.</dd>
+** ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
+** <dd>The maximum depth of the parse tree on any expression.</dd>)^
 **
-** <dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
-** <dd>The maximum number of terms in a compound SELECT statement.</dd>
+** ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
+** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
 **
-** <dt>SQLITE_LIMIT_VDBE_OP</dt>
+** ^(<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.</dd>)^
 **
-** <dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
-** <dd>The maximum number of arguments on a function.</dd>
+** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
+** <dd>The maximum number of arguments on a function.</dd>)^
 **
-** <dt>SQLITE_LIMIT_ATTACHED</dt>
-** <dd>The maximum number of [ATTACH | attached databases].</dd>
+** ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
+** <dd>The maximum number of [ATTACH | attached databases].)^</dd>
 **
-** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
+** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
 ** <dd>The maximum length of the pattern argument to the [LIKE] or
-** [GLOB] operators.</dd>
+** [GLOB] operators.</dd>)^
 **
-** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
+** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
 ** <dd>The maximum number of variables in an SQL statement that can
-** be bound.</dd>
+** be bound.</dd>)^
 **
-** <dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
-** <dd>The maximum depth of recursion for triggers.</dd>
+** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
+** <dd>The maximum depth of recursion for triggers.</dd>)^
 ** </dl>
 */
 #define SQLITE_LIMIT_LENGTH                    0
@@ -2350,7 +2347,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 #define SQLITE_LIMIT_TRIGGER_DEPTH            10
 
 /*
-** CAPI3REF: Compiling An SQL Statement {H13010} <S10000>
+** CAPI3REF: Compiling An SQL Statement
 ** KEYWORDS: {SQL statement compiler}
 **
 ** To execute an SQL query, it must first be compiled into a byte-code
@@ -2365,9 +2362,9 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
 ** use UTF-16.
 **
-** If the nByte argument is less than zero, then zSql is read up to the
-** first zero terminator. If nByte is non-negative, then it is the maximum
-** number of  bytes read from zSql.  When nByte is non-negative, the
+** ^If the nByte argument is less than zero, then zSql is read up to the
+** first zero terminator. ^If nByte is non-negative, then it is the maximum
+** number of  bytes read from zSql.  ^When nByte is non-negative, the
 ** zSql string ends at either the first '\000' or '\u0000' character or
 ** the nByte-th byte, whichever comes first. If the caller knows
 ** that the supplied string is nul-terminated, then there is a small
@@ -2375,34 +2372,35 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** is equal to the number of bytes in the input string <i>including</i>
 ** the nul-terminator bytes.
 **
-** If pzTail is not NULL then *pzTail is made to point to the first byte
+** ^If pzTail is not NULL then *pzTail is made to point to the first byte
 ** past the end of the first SQL statement in zSql.  These routines only
 ** compile the first statement in zSql, so *pzTail is left pointing to
 ** what remains uncompiled.
 **
-** *ppStmt is left pointing to a compiled [prepared statement] that can be
-** executed using [sqlite3_step()].  If there is an error, *ppStmt is set
-** to NULL.  If the input text contains no SQL (if the input is an empty
+** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
+** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set
+** to NULL.  ^If the input text contains no SQL (if the input is an empty
 ** string or a comment) then *ppStmt is set to NULL.
 ** The calling procedure is responsible for deleting the compiled
 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
 ** ppStmt may not be NULL.
 **
-** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
+** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
+** otherwise an [error code] is returned.
 **
 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
 ** recommended for all new programs. The two older interfaces are retained
 ** for backwards compatibility, but their use is discouraged.
-** In the "v2" interfaces, the prepared statement
+** ^In the "v2" interfaces, the prepared statement
 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
 ** original SQL text. This causes the [sqlite3_step()] interface to
-** behave a differently in two ways:
+** behave differently in three ways:
 **
 ** <ol>
 ** <li>
-** If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
+** ^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
+** 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
@@ -2411,18 +2409,22 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** </li>
 **
 ** <li>
-** When an error occurs, [sqlite3_step()] will return one of the detailed
-** [error codes] or [extended error codes].  The legacy behavior was that
+** ^When an error occurs, [sqlite3_step()] will return one of the detailed
+** [error codes] or [extended error codes].  ^The legacy behavior was that
 ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
-** and you would have to make a second call to [sqlite3_reset()] in order
-** to find the underlying cause of the problem. With the "v2" prepare
+** and the application would have to make a second call to [sqlite3_reset()]
+** in order to find the underlying cause of the problem. With the "v2" prepare
 ** interfaces, the underlying reason for the error is returned immediately.
 ** </li>
-** </ol>
-**
-** Requirements:
-** [H13011] [H13012] [H13013] [H13014] [H13015] [H13016] [H13019] [H13021]
 **
+** <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]. 
+** </li>
+** </ol>
 */
 SQLITE_API int sqlite3_prepare(
   sqlite3 *db,            /* Database handle */
@@ -2454,24 +2456,21 @@ SQLITE_API int sqlite3_prepare16_v2(
 );
 
 /*
-** CAPI3REF: Retrieving Statement SQL {H13100} <H13000>
+** CAPI3REF: Retrieving Statement SQL
 **
-** This interface can be used to retrieve a saved copy of the original
+** ^This interface can be used to retrieve a saved copy of the original
 ** SQL text used to create a [prepared statement] if that statement was
 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
-**
-** Requirements:
-** [H13101] [H13102] [H13103]
 */
 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Dynamically Typed Value Object {H15000} <S20200>
+** CAPI3REF: Dynamically Typed Value Object
 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
 **
 ** SQLite uses the sqlite3_value object to represent all values
 ** that can be stored in a database table. SQLite uses dynamic typing
-** for the values it stores. Values stored in sqlite3_value objects
+** for the values it stores.  ^Values stored in sqlite3_value objects
 ** can be integers, floating point values, strings, BLOBs, or NULL.
 **
 ** An sqlite3_value object may be either "protected" or "unprotected".
@@ -2493,9 +2492,9 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
 ** still make the distinction between between protected and unprotected
 ** sqlite3_value objects even when not strictly required.
 **
-** The sqlite3_value objects that are passed as parameters into the
+** ^The sqlite3_value objects that are passed as parameters into the
 ** implementation of [application-defined SQL functions] are protected.
-** The sqlite3_value object returned by
+** ^The sqlite3_value object returned by
 ** [sqlite3_column_value()] is unprotected.
 ** Unprotected sqlite3_value objects may only be used with
 ** [sqlite3_result_value()] and [sqlite3_bind_value()].
@@ -2505,10 +2504,10 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
 typedef struct Mem sqlite3_value;
 
 /*
-** CAPI3REF: SQL Function Context Object {H16001} <S20200>
+** CAPI3REF: SQL Function Context Object
 **
 ** The context in which an SQL function executes is stored in an
-** sqlite3_context object.  A pointer to an sqlite3_context object
+** sqlite3_context object.  ^A pointer to an sqlite3_context object
 ** is always first parameter to [application-defined SQL functions].
 ** The application-defined SQL function implementation will pass this
 ** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
@@ -2519,11 +2518,11 @@ typedef struct Mem sqlite3_value;
 typedef struct sqlite3_context sqlite3_context;
 
 /*
-** CAPI3REF: Binding Values To Prepared Statements {H13500} <S70300>
+** CAPI3REF: Binding Values To Prepared Statements
 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
 **
-** In the SQL strings input to [sqlite3_prepare_v2()] and its variants,
+** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
 ** literals may be replaced by a [parameter] that matches one of following
 ** templates:
 **
@@ -2536,72 +2535,66 @@ 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 identifer.)^  ^The values of these
 ** parameters (also called "host parameter names" or "SQL parameters")
 ** can be set using the sqlite3_bind_*() routines defined here.
 **
-** The first argument to the sqlite3_bind_*() routines is always
+** ^The first argument to the sqlite3_bind_*() routines is always
 ** a pointer to the [sqlite3_stmt] object returned from
 ** [sqlite3_prepare_v2()] or its variants.
 **
-** The second argument is the index of the SQL parameter to be set.
-** The leftmost SQL parameter has an index of 1.  When the same named
+** ^The second argument is the index of the SQL parameter to be set.
+** ^The leftmost SQL parameter has an index of 1.  ^When the same named
 ** SQL parameter is used more than once, second and subsequent
 ** occurrences have the same index as the first occurrence.
-** The index for named parameters can be looked up using the
-** [sqlite3_bind_parameter_index()] API if desired.  The index
+** ^The index for named parameters can be looked up using the
+** [sqlite3_bind_parameter_index()] API if desired.  ^The index
 ** for "?NNN" parameters is the value of NNN.
-** The NNN value must be between 1 and the [sqlite3_limit()]
+** ^The NNN value must be between 1 and the [sqlite3_limit()]
 ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
 **
-** The third argument is the value to bind to the parameter.
+** ^The third argument is the value to bind to the parameter.
 **
-** In those routines that have a fourth argument, its value is the
+** ^(In those routines that have a fourth argument, its value is the
 ** number of bytes in the parameter.  To be clear: the value is the
-** number of <u>bytes</u> in the value, not the number of characters.
-** If the fourth parameter is negative, the length of the string is
+** number of <u>bytes</u> in the value, not the number of characters.)^
+** ^If the fourth parameter is negative, the length of the string is
 ** the number of bytes up to the first zero terminator.
 **
-** The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
+** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
 ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
-** string after SQLite has finished with it. If the fifth argument is
+** string after SQLite has finished with it. ^If the fifth argument is
 ** the special value [SQLITE_STATIC], then SQLite assumes that the
 ** information is in static, unmanaged space and does not need to be freed.
-** If the fifth argument has the value [SQLITE_TRANSIENT], then
+** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
 ** SQLite makes its own private copy of the data immediately, before
 ** the sqlite3_bind_*() routine returns.
 **
-** The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
-** is filled with zeroes.  A zeroblob uses a fixed amount of memory
+** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
+** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory
 ** (just an integer to hold its size) while it is being processed.
 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
 ** content is later written using
 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
-** A negative value for the zeroblob results in a zero-length BLOB.
-**
-** The sqlite3_bind_*() routines must be called after
-** [sqlite3_prepare_v2()] (and its variants) or [sqlite3_reset()] and
-** before [sqlite3_step()].
-** Bindings are not cleared by the [sqlite3_reset()] routine.
-** Unbound parameters are interpreted as NULL.
-**
-** These routines return [SQLITE_OK] on success or an error code if
-** anything goes wrong.  [SQLITE_RANGE] is returned if the parameter
-** index is out of range.  [SQLITE_NOMEM] is returned if malloc() fails.
-** [SQLITE_MISUSE] might be returned if these routines are called on a
-** virtual machine that is the wrong state or which has already been finalized.
-** Detection of misuse is unreliable.  Applications should not depend
-** on SQLITE_MISUSE returns.  SQLITE_MISUSE is intended to indicate a
-** a logic error in the application.  Future versions of SQLite might
-** panic rather than return SQLITE_MISUSE.
+** ^A negative value for the zeroblob results in a zero-length BLOB.
 **
-** See also: [sqlite3_bind_parameter_count()],
-** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
+** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
+** for the [prepared statement] or with a prepared statement for which
+** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
+** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()
+** routine is passed a [prepared statement] that has been finalized, the
+** result is undefined and probably harmful.
+**
+** ^Bindings are not cleared by the [sqlite3_reset()] routine.
+** ^Unbound parameters are interpreted as NULL.
 **
-** Requirements:
-** [H13506] [H13509] [H13512] [H13515] [H13518] [H13521] [H13524] [H13527]
-** [H13530] [H13533] [H13536] [H13539] [H13542] [H13545] [H13548] [H13551]
+** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
+** [error code] if anything goes wrong.
+** ^[SQLITE_RANGE] is returned if the parameter
+** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.
 **
+** See also: [sqlite3_bind_parameter_count()],
+** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
 */
 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
@@ -2614,45 +2607,42 @@ SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
 
 /*
-** CAPI3REF: Number Of SQL Parameters {H13600} <S70300>
+** CAPI3REF: Number Of SQL Parameters
 **
-** This routine can be used to find the number of [SQL parameters]
+** ^This routine can be used to find the number of [SQL parameters]
 ** in a [prepared statement].  SQL parameters are tokens of the
 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
 ** placeholders for values that are [sqlite3_bind_blob | bound]
 ** to the parameters at a later time.
 **
-** This routine actually returns the index of the largest (rightmost)
+** ^(This routine actually returns the index of the largest (rightmost)
 ** parameter. For all forms except ?NNN, this will correspond to the
-** number of unique parameters.  If parameters of the ?NNN are used,
-** there may be gaps in the list.
+** number of unique parameters.  If parameters of the ?NNN form are used,
+** there may be gaps in the list.)^
 **
 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
 ** [sqlite3_bind_parameter_name()], and
 ** [sqlite3_bind_parameter_index()].
-**
-** Requirements:
-** [H13601]
 */
 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
 
 /*
-** CAPI3REF: Name Of A Host Parameter {H13620} <S70300>
+** CAPI3REF: Name Of A Host Parameter
 **
-** This routine returns a pointer to the name of the n-th
-** [SQL parameter] in a [prepared statement].
-** SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
+** ^The sqlite3_bind_parameter_name(P,N) interface returns
+** the name of the N-th [SQL parameter] in the [prepared statement] P.
+** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
 ** respectively.
 ** In other words, the initial ":" or "$" or "@" or "?"
-** is included as part of the name.
-** Parameters of the form "?" without a following integer have no name
-** and are also referred to as "anonymous parameters".
+** is included as part of the name.)^
+** ^Parameters of the form "?" without a following integer have no name
+** and are referred to as "nameless" or "anonymous parameters".
 **
-** The first host parameter has an index of 1, not 0.
+** ^The first host parameter has an index of 1, not 0.
 **
-** If the value n is out of range or if the n-th parameter is
-** nameless, then NULL is returned.  The returned string is
+** ^If the value N is out of range or if the N-th parameter is
+** nameless, then NULL is returned.  ^The returned string is
 ** always in UTF-8 encoding even if the named parameter was
 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
 ** [sqlite3_prepare16_v2()].
@@ -2660,125 +2650,108 @@ SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
 ** [sqlite3_bind_parameter_count()], and
 ** [sqlite3_bind_parameter_index()].
-**
-** Requirements:
-** [H13621]
 */
 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
 
 /*
-** CAPI3REF: Index Of A Parameter With A Given Name {H13640} <S70300>
+** CAPI3REF: Index Of A Parameter With A Given Name
 **
-** Return the index of an SQL parameter given its name.  The
+** ^Return the index of an SQL parameter given its name.  ^The
 ** index value returned is suitable for use as the second
-** parameter to [sqlite3_bind_blob|sqlite3_bind()].  A zero
-** is returned if no matching parameter is found.  The parameter
+** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero
+** is returned if no matching parameter is found.  ^The parameter
 ** name must be given in UTF-8 even if the original statement
 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
 **
 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
 ** [sqlite3_bind_parameter_count()], and
 ** [sqlite3_bind_parameter_index()].
-**
-** Requirements:
-** [H13641]
 */
 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
 
 /*
-** CAPI3REF: Reset All Bindings On A Prepared Statement {H13660} <S70300>
+** CAPI3REF: Reset All Bindings On A Prepared Statement
 **
-** Contrary to the intuition of many, [sqlite3_reset()] does not reset
+** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
-** Use this routine to reset all host parameters to NULL.
-**
-** Requirements:
-** [H13661]
+** ^Use this routine to reset all host parameters to NULL.
 */
 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
 
 /*
-** CAPI3REF: Number Of Columns In A Result Set {H13710} <S10700>
+** CAPI3REF: Number Of Columns In A Result Set
 **
-** Return the number of columns in the result set returned by the
-** [prepared statement]. This routine returns 0 if pStmt is an SQL
+** ^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]).
-**
-** Requirements:
-** [H13711]
 */
 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Column Names In A Result Set {H13720} <S10700>
+** CAPI3REF: Column Names In A Result Set
 **
-** These routines return the name assigned to a particular column
-** in the result set of a [SELECT] statement.  The sqlite3_column_name()
+** ^These routines return the name assigned to a particular column
+** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()
 ** interface returns a pointer to a zero-terminated UTF-8 string
 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
-** UTF-16 string.  The first parameter is the [prepared statement]
-** that implements the [SELECT] statement. The second parameter is the
-** column number.  The leftmost column is number 0.
+** UTF-16 string.  ^The first parameter is the [prepared statement]
+** that implements the [SELECT] statement. ^The second parameter is the
+** column number.  ^The leftmost column is number 0.
 **
-** The returned string pointer is valid until either the [prepared statement]
+** ^The returned string pointer is valid until either the [prepared statement]
 ** is destroyed by [sqlite3_finalize()] or until the next call to
 ** sqlite3_column_name() or sqlite3_column_name16() on the same column.
 **
-** If sqlite3_malloc() fails during the processing of either routine
+** ^If sqlite3_malloc() fails during the processing of either routine
 ** (for example during a conversion from UTF-8 to UTF-16) then a
 ** NULL pointer is returned.
 **
-** The name of a result column is the value of the "AS" clause for
+** ^The name of a result column is the value of the "AS" clause for
 ** that column, if there is an AS clause.  If there is no AS clause
 ** then the name of the column is unspecified and may change from
 ** one release of SQLite to the next.
-**
-** Requirements:
-** [H13721] [H13723] [H13724] [H13725] [H13726] [H13727]
 */
 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
 
 /*
-** CAPI3REF: Source Of Data In A Query Result {H13740} <S10700>
+** CAPI3REF: Source Of Data In A Query Result
 **
-** These routines provide a means to determine what column of what
-** table in which database a result of a [SELECT] statement comes from.
-** The name of the database or table or column can be returned as
-** either a UTF-8 or UTF-16 string.  The _database_ routines return
+** ^These routines provide a means to determine the database, table, and
+** table column that is the origin of a particular result column in
+** [SELECT] statement.
+** ^The name of the database or table or column can be returned as
+** either a UTF-8 or UTF-16 string.  ^The _database_ routines return
 ** the database name, the _table_ routines return the table name, and
 ** the origin_ routines return the column name.
-** The returned string is valid until the [prepared statement] is destroyed
+** ^The returned string is valid until the [prepared statement] is destroyed
 ** using [sqlite3_finalize()] or until the same information is requested
 ** again in a different encoding.
 **
-** The names returned are the original un-aliased names of the
+** ^The names returned are the original un-aliased names of the
 ** database, table, and column.
 **
-** The first argument to the following calls is a [prepared statement].
-** These functions return information about the Nth column returned by
+** ^The first argument to these interfaces is a [prepared statement].
+** ^These functions return information about the Nth result column returned by
 ** the statement, where N is the second function argument.
+** ^The left-most column is column 0 for these routines.
 **
-** If the Nth column returned by the statement is an expression or
+** ^If the Nth column returned by the statement is an expression or
 ** subquery and is not a column value, then all of these functions return
-** NULL.  These routine might also return NULL if a memory allocation error
-** occurs.  Otherwise, they return the name of the attached database, table
-** and column that query result column was extracted from.
+** NULL.  ^These routine might also return NULL if a memory allocation error
+** occurs.  ^Otherwise, they return the name of the attached database, table,
+** or column that query result column was extracted from.
 **
-** As with all other SQLite APIs, those postfixed with "16" return
-** UTF-16 encoded strings, the other functions return UTF-8. {END}
+** ^As with all other SQLite APIs, those whose names end with "16" return
+** UTF-16 encoded strings and the other functions return UTF-8.
 **
-** These APIs are only available if the library was compiled with the
-** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
+** ^These APIs are only available if the library was compiled with the
+** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
 **
-** {A13751}
 ** If two or more threads call one or more of these routines against the same
 ** prepared statement and column at the same time then the results are
 ** undefined.
 **
-** Requirements:
-** [H13741] [H13742] [H13743] [H13744] [H13745] [H13746] [H13748]
-**
 ** If two or more threads call one or more
 ** [sqlite3_column_database_name | column metadata interfaces]
 ** for the same [prepared statement] and result column
@@ -2792,17 +2765,17 @@ SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
 
 /*
-** CAPI3REF: Declared Datatype Of A Query Result {H13760} <S10700>
+** CAPI3REF: Declared Datatype Of A Query Result
 **
-** The first parameter is a [prepared statement].
+** ^(The first parameter is a [prepared statement].
 ** If this statement is a [SELECT] statement and the Nth column of the
 ** returned result set of that [SELECT] is a table column (not an
 ** expression or subquery) then the declared type of the table
-** column is returned.  If the Nth column of the result set is an
+** column is returned.)^  ^If the Nth column of the result set is an
 ** expression or subquery, then a NULL pointer is returned.
-** The returned string is always UTF-8 encoded. {END}
+** ^The returned string is always UTF-8 encoded.
 **
-** For example, given the database schema:
+** ^(For example, given the database schema:
 **
 ** CREATE TABLE t1(c1 VARIANT);
 **
@@ -2811,23 +2784,20 @@ SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
 ** SELECT c1 + 1, c1 FROM t1;
 **
 ** this routine would return the string "VARIANT" for the second result
-** column (i==1), and a NULL pointer for the first result column (i==0).
+** column (i==1), and a NULL pointer for the first result column (i==0).)^
 **
-** SQLite uses dynamic run-time typing.  So just because a column
+** ^SQLite uses dynamic run-time typing.  ^So just because a column
 ** is declared to contain a particular type does not mean that the
 ** data stored in that column is of the declared type.  SQLite is
-** strongly typed, but the typing is dynamic not static.  Type
+** strongly typed, but the typing is dynamic not static.  ^Type
 ** is associated with individual values, not with the containers
 ** used to hold those values.
-**
-** Requirements:
-** [H13761] [H13762] [H13763]
 */
 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
 
 /*
-** CAPI3REF: Evaluate An SQL Statement {H13200} <S10000>
+** CAPI3REF: Evaluate An SQL Statement
 **
 ** After a [prepared statement] has been prepared using either
 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
@@ -2841,35 +2811,35 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
 ** new "v2" interface is recommended for new applications but the legacy
 ** interface will continue to be supported.
 **
-** In the legacy interface, the return value will be either [SQLITE_BUSY],
+** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
-** With the "v2" interface, any of the other [result codes] or
+** ^With the "v2" interface, any of the other [result codes] or
 ** [extended result codes] might be returned as well.
 **
-** [SQLITE_BUSY] means that the database engine was unable to acquire the
-** database locks it needs to do its job.  If the statement is a [COMMIT]
+** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
+** database locks it needs to do its job.  ^If the statement is a [COMMIT]
 ** or occurs outside of an explicit transaction, then you can retry the
 ** statement.  If the statement is not a [COMMIT] and occurs within a
 ** explicit transaction then you should rollback the transaction before
 ** continuing.
 **
-** [SQLITE_DONE] means that the statement has finished executing
+** ^[SQLITE_DONE] means that the statement has finished executing
 ** successfully.  sqlite3_step() should not be called again on this virtual
 ** machine without first calling [sqlite3_reset()] to reset the virtual
 ** machine back to its initial state.
 **
-** If the SQL statement being executed returns any data, then [SQLITE_ROW]
+** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]
 ** is returned each time a new row of data is ready for processing by the
 ** caller. The values may be accessed using the [column access functions].
 ** sqlite3_step() is called again to retrieve the next row of data.
 **
-** [SQLITE_ERROR] means that a run-time error (such as a constraint
+** ^[SQLITE_ERROR] means that a run-time error (such as a constraint
 ** violation) has occurred.  sqlite3_step() should not be called again on
 ** the VM. More information may be found by calling [sqlite3_errmsg()].
-** With the legacy interface, a more specific error code (for example,
+** ^With the legacy interface, a more specific error code (for example,
 ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
 ** can be obtained by calling [sqlite3_reset()] on the
-** [prepared statement].  In the "v2" interface,
+** [prepared statement].  ^In the "v2" interface,
 ** the more specific error code is returned directly by sqlite3_step().
 **
 ** [SQLITE_MISUSE] means that the this routine was called inappropriately.
@@ -2890,27 +2860,22 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
 ** then the more specific [error codes] are returned directly
 ** by sqlite3_step().  The use of the "v2" interface is recommended.
-**
-** Requirements:
-** [H13202] [H15304] [H15306] [H15308] [H15310]
 */
 SQLITE_API int sqlite3_step(sqlite3_stmt*);
 
 /*
-** CAPI3REF: Number of columns in a result set {H13770} <S10700>
-**
-** Returns the number of values in the current row of the result set.
+** CAPI3REF: Number of columns in a result set
 **
-** Requirements:
-** [H13771] [H13772]
+** ^The sqlite3_data_count(P) the number of columns in the
+** of the result set of [prepared statement] P.
 */
 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Fundamental Datatypes {H10265} <S10110><S10120>
+** CAPI3REF: Fundamental Datatypes
 ** KEYWORDS: SQLITE_TEXT
 **
-** {H10266} Every value in SQLite has one of five fundamental datatypes:
+** ^(Every value in SQLite has one of five fundamental datatypes:
 **
 ** <ul>
 ** <li> 64-bit signed integer
@@ -2918,7 +2883,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** <li> string
 ** <li> BLOB
 ** <li> NULL
-** </ul> {END}
+** </ul>)^
 **
 ** These constants are codes for each of those types.
 **
@@ -2939,17 +2904,19 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 #define SQLITE3_TEXT     3
 
 /*
-** CAPI3REF: Result Values From A Query {H13800} <S10700>
+** CAPI3REF: Result Values From A Query
 ** KEYWORDS: {column access functions}
 **
-** These routines form the "result set query" interface.
+** These routines form the "result set" interface.
 **
-** These routines return information about a single column of the current
-** result row of a query.  In every case the first argument is a pointer
+** ^These routines return information about a single column of the current
+** result row of a query.  ^In every case the first argument is a pointer
 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
 ** and the second argument is the index of the column for which information
-** should be returned.  The leftmost column of the result set has the index 0.
+** should be returned. ^The leftmost column of the result set has the index 0.
+** ^The number of columns in the result can be determined using
+** [sqlite3_column_count()].
 **
 ** If the SQL statement does not currently point to a valid row, or if the
 ** column index is out of range, the result is undefined.
@@ -2963,9 +2930,9 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** are called from a different thread while any of these routines
 ** are pending, then the results are undefined.
 **
-** The sqlite3_column_type() routine returns the
+** ^The sqlite3_column_type() routine returns the
 ** [SQLITE_INTEGER | datatype code] for the initial data type
-** of the result column.  The returned value is one of [SQLITE_INTEGER],
+** of the result column.  ^The returned value is one of [SQLITE_INTEGER],
 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].  The value
 ** returned by sqlite3_column_type() is only meaningful if no type
 ** conversions have occurred as described below.  After a type conversion,
@@ -2973,27 +2940,27 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** versions of SQLite may change the behavior of sqlite3_column_type()
 ** following a type conversion.
 **
-** If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
+** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
 ** routine returns the number of bytes in that BLOB or string.
-** If the result is a UTF-16 string, then sqlite3_column_bytes() converts
+** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
 ** the string to UTF-8 and then returns the number of bytes.
-** If the result is a numeric value then sqlite3_column_bytes() uses
+** ^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
+** ^The value returned does not include the zero terminator at the end
+** of the string.  ^For clarity: the value returned is 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
+** ^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()
+** ^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.
+** ^The zero terminator is not included in this count.
 **
-** The object returned by [sqlite3_column_value()] is an
+** ^The object returned by [sqlite3_column_value()] is an
 ** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object
 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
 ** If the [unprotected sqlite3_value] object returned by
@@ -3001,10 +2968,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
 ** or [sqlite3_value_bytes()], then the behavior is undefined.
 **
-** These routines attempt to convert the value where appropriate.  For
+** These routines attempt to convert the value where appropriate.  ^For
 ** example, if the internal representation is FLOAT and a text result
 ** is requested, [sqlite3_snprintf()] is used internally to perform the
-** conversion automatically.  The following table details the conversions
+** conversion automatically.  ^(The following table details the conversions
 ** that are applied:
 **
 ** <blockquote>
@@ -3028,7 +2995,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** <tr><td>  BLOB    <td>  FLOAT    <td> Convert to TEXT then use atof()
 ** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed
 ** </table>
-** </blockquote>
+** </blockquote>)^
 **
 ** The table above makes reference to standard C library functions atoi()
 ** and atof().  SQLite does not really use these functions.  It has its
@@ -3036,10 +3003,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>
@@ -3052,22 +3019,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
+** ^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
 ** 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
@@ -3077,22 +3044,18 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
 ** with calls to sqlite3_column_bytes().
 **
-** The pointers returned are valid until a type conversion occurs as
+** ^The pointers returned are valid until a type conversion occurs as
 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
-** [sqlite3_finalize()] is called.  The memory space used to hold strings
+** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
 ** and BLOBs is freed automatically.  Do <b>not</b> pass the pointers returned
 ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
 ** [sqlite3_free()].
 **
-** If a memory allocation error occurs during the evaluation of any
+** ^(If a memory allocation error occurs during the evaluation of any
 ** of these routines, a default value is returned.  The default value
 ** is either the integer 0, the floating point number 0.0, or a NULL
 ** pointer.  Subsequent calls to [sqlite3_errcode()] will return
-** [SQLITE_NOMEM].
-**
-** Requirements:
-** [H13803] [H13806] [H13809] [H13812] [H13815] [H13818] [H13821] [H13824]
-** [H13827] [H13830]
+** [SQLITE_NOMEM].)^
 */
 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
@@ -3106,79 +3069,76 @@ SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
 
 /*
-** CAPI3REF: Destroy A Prepared Statement Object {H13300} <S70300><S30100>
+** 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
+** ^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
+** ^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,
+** ^Incomplete updates may be rolled back and transactions canceled,
 ** depending on the circumstances, and the
 ** [error code] returned will be [SQLITE_ABORT].
-**
-** Requirements:
-** [H11302] [H11304]
 */
 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Reset A Prepared Statement Object {H13330} <S70300>
+** CAPI3REF: Reset A Prepared Statement Object
 **
 ** The sqlite3_reset() function is called to reset a [prepared statement]
 ** object back to its initial state, ready to be re-executed.
-** Any SQL statement variables that had values bound to them using
+** ^Any SQL statement variables that had values bound to them using
 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
 ** Use [sqlite3_clear_bindings()] to reset the bindings.
 **
-** {H11332} The [sqlite3_reset(S)] interface resets the [prepared statement] S
-**          back to the beginning of its program.
+** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
+** back to the beginning of its program.
 **
-** {H11334} If the most recent call to [sqlite3_step(S)] for the
-**          [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
-**          or if [sqlite3_step(S)] has never before been called on S,
-**          then [sqlite3_reset(S)] returns [SQLITE_OK].
+** ^If the most recent call to [sqlite3_step(S)] for the
+** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
+** or if [sqlite3_step(S)] has never before been called on S,
+** then [sqlite3_reset(S)] returns [SQLITE_OK].
 **
-** {H11336} If the most recent call to [sqlite3_step(S)] for the
-**          [prepared statement] S indicated an error, then
-**          [sqlite3_reset(S)] returns an appropriate [error code].
+** ^If the most recent call to [sqlite3_step(S)] for the
+** [prepared statement] S indicated an error, then
+** [sqlite3_reset(S)] returns an appropriate [error code].
 **
-** {H11338} The [sqlite3_reset(S)] interface does not change the values
-**          of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
+** ^The [sqlite3_reset(S)] interface does not change the values
+** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
 */
 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Create Or Redefine SQL Functions {H16100} <S20200>
+** CAPI3REF: Create Or Redefine SQL Functions
 ** KEYWORDS: {function creation routines}
 ** KEYWORDS: {application-defined SQL function}
 ** KEYWORDS: {application-defined SQL functions}
 **
-** These two functions (collectively known as "function creation routines")
+** ^These two 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().
 **
-** The first parameter is the [database connection] to which the SQL
-** function is to be added.  If a single program uses more than one database
-** connection internally, then SQL functions must be added individually to
-** each database connection.
+** ^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
+** 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
+** characters.  ^Any attempt to create a function with a longer name
 ** will result in [SQLITE_ERROR] being returned.
 **
-** The third parameter (nArg)
+** ^The third parameter (nArg)
 ** is the number of arguments that the SQL function or
-** aggregate takes. If this parameter is -1, then the SQL function or
+** aggregate takes. ^If this parameter is -1, then the SQL function or
 ** aggregate may take any number of arguments between 0 and the limit
 ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third
 ** parameter is less than -1 or greater than 127 then the behavior is
@@ -3188,53 +3148,49 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 ** [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
-** more efficient with one encoding than another.  An application may
+** 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.
-** When multiple implementations of the same function are available, SQLite
+** ^When multiple implementations of the same function are available, SQLite
 ** will pick the one that involves the least amount of data conversion.
 ** If there is only a single implementation which does not care what text
 ** encoding is used, then the fourth argument should be [SQLITE_ANY].
 **
-** The fifth parameter is an arbitrary pointer.  The implementation of the
-** function can gain access to this pointer using [sqlite3_user_data()].
+** ^(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
 ** 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
-** parameters. An aggregate SQL function requires an implementation of xStep
-** and xFinal and NULL should be passed for xFunc. To delete an existing
+** aggregate. ^A scalar SQL function requires an implementation of the xFunc
+** callback only; NULL pointers should 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.
 **
-** It is permitted to register multiple implementations of the same
+** ^It is permitted to register multiple implementations of the same
 ** functions with the same name but with either differing numbers of
-** arguments or differing preferred text encodings.  SQLite will use
+** arguments or differing preferred text encodings.  ^SQLite will use
 ** the implementation that most closely matches the way in which the
-** SQL function is used.  A function implementation with a non-negative
+** SQL function is used.  ^A function implementation with a non-negative
 ** nArg parameter is a better match than a function implementation with
-** a negative nArg.  A function where the preferred text encoding
+** a negative nArg.  ^A function where the preferred text encoding
 ** matches the database encoding is a better
 ** match than a function where the encoding is different.  
-** A function where the encoding difference is between UTF16le and UTF16be
+** ^A function where the encoding difference is between UTF16le and UTF16be
 ** is a closer match than a function where the encoding difference is
 ** 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 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 
+** ^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
+** ^An application-defined function is permitted to call other
 ** SQLite interfaces.  However, such calls must not
 ** close the database connection nor finalize or reset the prepared
 ** statement in which the function is running.
-**
-** Requirements:
-** [H16103] [H16106] [H16109] [H16112] [H16118] [H16121] [H16127]
-** [H16130] [H16133] [H16136] [H16139] [H16142]
 */
 SQLITE_API int sqlite3_create_function(
   sqlite3 *db,
@@ -3258,7 +3214,7 @@ SQLITE_API int sqlite3_create_function16(
 );
 
 /*
-** CAPI3REF: Text Encodings {H10267} <S50200> <H16100>
+** CAPI3REF: Text Encodings
 **
 ** These constant define integer codes that represent the various
 ** text encodings supported by SQLite.
@@ -3290,7 +3246,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
 #endif
 
 /*
-** CAPI3REF: Obtaining SQL Function Parameter Values {H15100} <S20200>
+** CAPI3REF: Obtaining SQL Function Parameter Values
 **
 ** The C-language implementation of SQL functions and aggregates uses
 ** this set of interface routines to access the parameter values on
@@ -3308,22 +3264,22 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
 ** Any attempt to use these routines on an [unprotected sqlite3_value]
 ** object results in undefined behavior.
 **
-** These routines work just like the corresponding [column access functions]
+** ^These routines work just like the corresponding [column access functions]
 ** except that  these routines take a single [protected sqlite3_value] object
 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
 **
-** The sqlite3_value_text16() interface extracts a UTF-16 string
-** in the native byte-order of the host machine.  The
+** ^The sqlite3_value_text16() interface extracts a UTF-16 string
+** in the native byte-order of the host machine.  ^The
 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
 ** extract UTF-16 strings as big-endian and little-endian respectively.
 **
-** The sqlite3_value_numeric_type() interface attempts to apply
+** ^(The sqlite3_value_numeric_type() interface attempts to apply
 ** numeric affinity to the value.  This means that an attempt is
 ** made to convert the value to an integer or floating point.  If
 ** such a conversion is possible without loss of information (in other
 ** words, if the value is a string that looks like a number)
 ** then the conversion is performed.  Otherwise no conversion occurs.
-** The [SQLITE_INTEGER | datatype] after conversion is returned.
+** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
 **
 ** Please pay particular attention to the fact that the pointer returned
 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
@@ -3333,10 +3289,6 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
 **
 ** These routines must be called from the same thread as
 ** the SQL function that supplied the [sqlite3_value*] parameters.
-**
-** Requirements:
-** [H15103] [H15106] [H15109] [H15112] [H15115] [H15118] [H15121] [H15124]
-** [H15127] [H15130] [H15133] [H15136]
 */
 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -3352,66 +3304,73 @@ SQLITE_API int sqlite3_value_type(sqlite3_value*);
 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
 
 /*
-** CAPI3REF: Obtain Aggregate Function Context {H16210} <S20200>
+** CAPI3REF: Obtain Aggregate Function Context
+**
+** Implementions 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 
+** for a particular aggregate function, SQLite
+** allocates N of memory, zeroes out that memory, and returns a pointer
+** to the new memory. ^On second and subsequent calls to
+** sqlite3_aggregate_context() for the same aggregate function instance,
+** the same buffer is returned.  Sqlite3_aggregate_context() is normally
+** called once for each invocation of the xStep callback and then one
+** last time when the xFinal callback is invoked.  ^(When no rows match
+** an aggregate query, the xStep() callback of the aggregate function
+** implementation is never called and xFinal() is called exactly once.
+** In those cases, sqlite3_aggregate_context() might be called for the
+** first time from within xFinal().)^
 **
-** The implementation of aggregate SQL functions use this routine to allocate
-** a structure for storing their state.
+** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is
+** less than or equal to zero or if a memory allocate error occurs.
 **
-** The first time the sqlite3_aggregate_context() routine is called for a
-** particular aggregate, SQLite allocates nBytes of memory, zeroes out that
-** memory, and returns a pointer to it. On second and subsequent calls to
-** sqlite3_aggregate_context() for the same aggregate function index,
-** the same buffer is returned. The implementation of the aggregate can use
-** the returned buffer to accumulate data.
+** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
+** determined by the N parameter on first successful call.  Changing the
+** value of N in subsequent call to sqlite3_aggregate_context() within
+** the same aggregate function instance will not resize the memory
+** allocation.)^
 **
-** SQLite automatically frees the allocated buffer when the aggregate
-** query concludes.
+** ^SQLite automatically frees the memory allocated by 
+** sqlite3_aggregate_context() when the aggregate query concludes.
 **
-** The first parameter should be a copy of the
+** The first parameter must be a copy of the
 ** [sqlite3_context | SQL function context] that is the first parameter
-** to the callback routine that implements the aggregate function.
+** to the xStep or xFinal callback routine that implements the aggregate
+** function.
 **
 ** This routine must be called from the same thread in which
 ** the aggregate SQL function is running.
-**
-** Requirements:
-** [H16211] [H16213] [H16215] [H16217]
 */
 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
 
 /*
-** CAPI3REF: User Data For Functions {H16240} <S20200>
+** CAPI3REF: User Data For Functions
 **
-** The sqlite3_user_data() interface returns a copy of
+** ^The sqlite3_user_data() interface returns a copy of
 ** the pointer that was the pUserData parameter (the 5th parameter)
 ** of the [sqlite3_create_function()]
 ** and [sqlite3_create_function16()] routines that originally
-** registered the application defined function. {END}
+** registered the application defined function.
 **
 ** This routine must be called from the same thread in which
 ** the application-defined function is running.
-**
-** Requirements:
-** [H16243]
 */
 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
 
 /*
-** CAPI3REF: Database Connection For Functions {H16250} <S60600><S20200>
+** CAPI3REF: Database Connection For Functions
 **
-** The sqlite3_context_db_handle() interface returns a copy of
+** ^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.
-**
-** Requirements:
-** [H16253]
 */
 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
 
 /*
-** CAPI3REF: Function Auxiliary Data {H16270} <S20200>
+** CAPI3REF: Function Auxiliary Data
 **
 ** The following two functions may be used by scalar SQL functions to
 ** associate metadata with argument values. If the same value is passed to
@@ -3424,48 +3383,45 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
 ** invocations of the same function so that the original pattern string
 ** does not need to be recompiled on each invocation.
 **
-** The sqlite3_get_auxdata() interface returns a pointer to the metadata
+** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
 ** associated by the sqlite3_set_auxdata() function with the Nth argument
-** value to the application-defined function. If no metadata has been ever
+** value to the application-defined function. ^If no metadata has been ever
 ** been set for the Nth argument of the function, or if the corresponding
 ** function parameter has changed since the meta-data was set,
 ** then sqlite3_get_auxdata() returns a NULL pointer.
 **
-** The sqlite3_set_auxdata() interface saves the metadata
+** ^The sqlite3_set_auxdata() interface saves the metadata
 ** pointed to by its 3rd parameter as the metadata for the N-th
 ** argument of the application-defined function.  Subsequent
 ** calls to sqlite3_get_auxdata() might return this data, if it has
 ** not been destroyed.
-** If it is not NULL, SQLite will invoke the destructor
+** ^If it is not NULL, SQLite will invoke the destructor
 ** function given by the 4th parameter to sqlite3_set_auxdata() on
 ** the metadata when the corresponding function parameter changes
 ** or when the SQL statement completes, whichever comes first.
 **
 ** SQLite is free to call the destructor and drop metadata on any
-** parameter of any function at any time.  The only guarantee is that
+** parameter of any function at any time.  ^The only guarantee is that
 ** the destructor will be called before the metadata is dropped.
 **
-** In practice, metadata is preserved between function calls for
+** ^(In practice, metadata is preserved between function calls for
 ** expressions that are constant at compile time. This includes literal
-** values and SQL variables.
+** values and [parameters].)^
 **
 ** These routines must be called from the same thread in which
 ** the SQL function is running.
-**
-** Requirements:
-** [H16272] [H16274] [H16276] [H16277] [H16278] [H16279]
 */
 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
 
 
 /*
-** CAPI3REF: Constants Defining Special Destructor Behavior {H10280} <S30100>
+** CAPI3REF: Constants Defining Special Destructor Behavior
 **
 ** These are special values for the destructor that is passed in as the
-** final argument to routines like [sqlite3_result_blob()].  If the destructor
+** final argument to routines like [sqlite3_result_blob()].  ^If the destructor
 ** argument is SQLITE_STATIC, it means that the content pointer is constant
-** and will never change.  It does not need to be destroyed.  The
+** and will never change.  It does not need to be destroyed.  ^The
 ** SQLITE_TRANSIENT value means that the content will likely change in
 ** the near future and that SQLite should make its own private copy of
 ** the content before returning.
@@ -3478,7 +3434,7 @@ typedef void (*sqlite3_destructor_type)(void*);
 #define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)
 
 /*
-** CAPI3REF: Setting The Result Of An SQL Function {H16400} <S20200>
+** CAPI3REF: Setting The Result Of An SQL Function
 **
 ** These routines are used by the xFunc or xFinal callbacks that
 ** implement SQL functions and aggregates.  See
@@ -3489,103 +3445,98 @@ typedef void (*sqlite3_destructor_type)(void*);
 ** functions used to bind values to host parameters in prepared statements.
 ** Refer to the [SQL parameter] documentation for additional information.
 **
-** The sqlite3_result_blob() interface sets the result from
+** ^The sqlite3_result_blob() interface sets the result from
 ** an application-defined function to be the BLOB whose content is pointed
 ** to by the second parameter and which is N bytes long where N is the
 ** third parameter.
 **
-** The sqlite3_result_zeroblob() interfaces set the result of
+** ^The sqlite3_result_zeroblob() interfaces set the result of
 ** the application-defined function to be a BLOB containing all zero
 ** bytes and N bytes in size, where N is the value of the 2nd parameter.
 **
-** The sqlite3_result_double() interface sets the result from
+** ^The sqlite3_result_double() interface sets the result from
 ** an application-defined function to be a floating point value specified
 ** by its 2nd argument.
 **
-** The sqlite3_result_error() and sqlite3_result_error16() functions
+** ^The sqlite3_result_error() and sqlite3_result_error16() functions
 ** cause the implemented SQL function to throw an exception.
-** SQLite uses the string pointed to by the
+** ^SQLite uses the string pointed to by the
 ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
-** as the text of an error message.  SQLite interprets the error
-** message string from sqlite3_result_error() as UTF-8. SQLite
+** as the text of an error message.  ^SQLite interprets the error
+** message string from sqlite3_result_error() as UTF-8. ^SQLite
 ** interprets the string from sqlite3_result_error16() as UTF-16 in native
-** byte order.  If the third parameter to sqlite3_result_error()
+** byte order.  ^If the third parameter to sqlite3_result_error()
 ** or sqlite3_result_error16() is negative then SQLite takes as the error
 ** message all text up through the first zero character.
-** If the third parameter to sqlite3_result_error() or
+** ^If the third parameter to sqlite3_result_error() or
 ** sqlite3_result_error16() is non-negative then SQLite takes that many
 ** bytes (not characters) from the 2nd parameter as the error message.
-** The sqlite3_result_error() and sqlite3_result_error16()
+** ^The sqlite3_result_error() and sqlite3_result_error16()
 ** routines make a private copy of the error message text before
 ** they return.  Hence, the calling function can deallocate or
 ** modify the text after they return without harm.
-** The sqlite3_result_error_code() function changes the error code
-** returned by SQLite as a result of an error in a function.  By default,
-** the error code is SQLITE_ERROR.  A subsequent call to sqlite3_result_error()
+** ^The sqlite3_result_error_code() function changes the error code
+** returned by SQLite as a result of an error in a function.  ^By default,
+** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()
 ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
 **
-** The sqlite3_result_toobig() interface causes SQLite to throw an error
-** indicating that a string or BLOB is to long to represent.
+** ^The sqlite3_result_toobig() interface causes SQLite to throw an error
+** indicating that a string or BLOB is too long to represent.
 **
-** The sqlite3_result_nomem() interface causes SQLite to throw an error
+** ^The sqlite3_result_nomem() interface causes SQLite to throw an error
 ** indicating that a memory allocation failed.
 **
-** The sqlite3_result_int() interface sets the return value
+** ^The sqlite3_result_int() interface sets the return value
 ** of the application-defined function to be the 32-bit signed integer
 ** value given in the 2nd argument.
-** The sqlite3_result_int64() interface sets the return value
+** ^The sqlite3_result_int64() interface sets the return value
 ** of the application-defined function to be the 64-bit signed integer
 ** value given in the 2nd argument.
 **
-** The sqlite3_result_null() interface sets the return value
+** ^The sqlite3_result_null() interface sets the return value
 ** of the application-defined function to be NULL.
 **
-** The sqlite3_result_text(), sqlite3_result_text16(),
+** ^The sqlite3_result_text(), sqlite3_result_text16(),
 ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
 ** set the return value of the application-defined function to be
 ** a text string which is represented as UTF-8, UTF-16 native byte order,
 ** UTF-16 little endian, or UTF-16 big endian, respectively.
-** SQLite takes the text result from the application from
+** ^SQLite takes the text result from the application from
 ** the 2nd parameter of the sqlite3_result_text* interfaces.
-** If the 3rd parameter to the sqlite3_result_text* interfaces
+** ^If the 3rd parameter to the sqlite3_result_text* interfaces
 ** is negative, then SQLite takes result text from the 2nd parameter
 ** through the first zero character.
-** If the 3rd parameter to the sqlite3_result_text* interfaces
+** ^If the 3rd parameter to the sqlite3_result_text* interfaces
 ** is non-negative, then as many bytes (not characters) of the text
 ** pointed to by the 2nd parameter are taken as the application-defined
 ** function result.
-** If the 4th parameter to the sqlite3_result_text* interfaces
+** ^If the 4th parameter to the sqlite3_result_text* interfaces
 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
 ** function as the destructor on the text or BLOB result when it has
 ** finished using that result.
-** If the 4th parameter to the sqlite3_result_text* interfaces or to
+** ^If the 4th parameter to the sqlite3_result_text* interfaces or to
 ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
 ** assumes that the text or BLOB result is in constant space and does not
 ** copy the content of the parameter nor call a destructor on the content
 ** when it has finished using that result.
-** If the 4th parameter to the sqlite3_result_text* interfaces
+** ^If the 4th parameter to the sqlite3_result_text* interfaces
 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
 ** then SQLite makes a copy of the result into space obtained from
 ** from [sqlite3_malloc()] before it returns.
 **
-** The sqlite3_result_value() interface sets the result of
+** ^The sqlite3_result_value() interface sets the result of
 ** the application-defined function to be a copy the
-** [unprotected sqlite3_value] object specified by the 2nd parameter.  The
+** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The
 ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
 ** so that the [sqlite3_value] specified in the parameter may change or
 ** be deallocated after sqlite3_result_value() returns without harm.
-** A [protected sqlite3_value] object may always be used where an
+** ^A [protected sqlite3_value] object may always be used where an
 ** [unprotected sqlite3_value] object is required, so either
 ** kind of [sqlite3_value] object can be used with this interface.
 **
 ** If these routines are called from within the different thread
 ** than the one containing the application-defined function that received
 ** the [sqlite3_context] pointer, the results are undefined.
-**
-** Requirements:
-** [H16403] [H16406] [H16409] [H16412] [H16415] [H16418] [H16421] [H16424]
-** [H16427] [H16430] [H16433] [H16436] [H16439] [H16442] [H16445] [H16448]
-** [H16451] [H16454] [H16457] [H16460] [H16463]
 */
 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
@@ -3605,20 +3556,20 @@ SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
 
 /*
-** CAPI3REF: Define New Collating Sequences {H16600} <S20300>
+** CAPI3REF: Define New Collating Sequences
 **
 ** These functions are used to add new collation sequences to 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 new collation sequence is specified as 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
+** 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],
+** ^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
+** 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
@@ -3626,33 +3577,29 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
 ** 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
+** 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
+** ^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,
+** ^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. {END}  The application defined collation routine should
+** 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).
 **
-** The sqlite3_create_collation_v2() works like sqlite3_create_collation()
+** ^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
+** 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
+** ^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()].
 **
 ** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
-**
-** Requirements:
-** [H16603] [H16604] [H16606] [H16609] [H16612] [H16615] [H16618] [H16621]
-** [H16624] [H16627] [H16630]
 */
 SQLITE_API int sqlite3_create_collation(
   sqlite3*, 
@@ -3678,33 +3625,30 @@ SQLITE_API int sqlite3_create_collation16(
 );
 
 /*
-** CAPI3REF: Collation Needed Callbacks {H16700} <S20300>
+** CAPI3REF: Collation Needed Callbacks
 **
-** To avoid having to register all collation sequences before a database
+** ^To avoid having to register all collation sequences before a database
 ** can be used, a single callback function may be registered with the
-** [database connection] to be called whenever an undefined collation
+** [database connection] to be invoked whenever an undefined collation
 ** sequence is required.
 **
-** If the function is registered using the sqlite3_collation_needed() API,
+** ^If the function is registered using the sqlite3_collation_needed() API,
 ** then it is passed the names of undefined collation sequences as strings
-** encoded in UTF-8. {H16703} If sqlite3_collation_needed16() is used,
+** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,
 ** the names are passed as UTF-16 in machine native byte order.
-** A call to either function replaces any existing callback.
+** ^A call to either function replaces the existing collation-needed callback.
 **
-** When the callback is invoked, the first argument passed is a copy
+** ^(When the callback is invoked, the first argument passed is a copy
 ** of the second argument to sqlite3_collation_needed() or
 ** sqlite3_collation_needed16().  The second argument is the database
 ** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
 ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
 ** sequence function required.  The fourth parameter is the name of the
-** required collation sequence.
+** required collation sequence.)^
 **
 ** The callback function should register the desired collation using
 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
 ** [sqlite3_create_collation_v2()].
-**
-** Requirements:
-** [H16702] [H16704] [H16706]
 */
 SQLITE_API int sqlite3_collation_needed(
   sqlite3*, 
@@ -3743,29 +3687,28 @@ SQLITE_API int sqlite3_rekey(
 );
 
 /*
-** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410>
+** 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()
+** ^SQLite implements this interface by calling the xSleep()
 ** method of the default [sqlite3_vfs] object.
-**
-** Requirements: [H10533] [H10536]
 */
 SQLITE_API int sqlite3_sleep(int);
 
 /*
-** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000>
+** CAPI3REF: Name Of The Folder Holding Temporary Files
 **
-** If this global variable is made to point to a string which is
+** ^(If this global variable is made to point to a string which is
 ** the name of a folder (a.k.a. directory), then all temporary files
-** created by SQLite will be placed in that directory.  If this variable
+** created by SQLite when using a built-in [sqlite3_vfs | VFS]
+** will be placed in that directory.)^  ^If this variable
 ** is a NULL pointer, then SQLite performs a search for an appropriate
 ** temporary file directory.
 **
@@ -3778,8 +3721,8 @@ SQLITE_API int sqlite3_sleep(int);
 ** routines have been called and that this variable remain unchanged
 ** thereafter.
 **
-** The [temp_store_directory pragma] may modify this variable and cause
-** it to point to memory obtained from [sqlite3_malloc].  Furthermore,
+** ^The [temp_store_directory pragma] may modify this variable and cause
+** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,
 ** the [temp_store_directory pragma] always assumes that any string
 ** that this variable points to is held in memory obtained from 
 ** [sqlite3_malloc] and the pragma may attempt to free that memory
@@ -3791,14 +3734,14 @@ SQLITE_API int sqlite3_sleep(int);
 SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
 
 /*
-** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
+** CAPI3REF: Test For Auto-Commit Mode
 ** KEYWORDS: {autocommit mode}
 **
-** The sqlite3_get_autocommit() interface returns non-zero or
+** ^The sqlite3_get_autocommit() interface returns non-zero or
 ** zero if the given database connection is or is not in autocommit mode,
-** respectively.  Autocommit mode is on by default.
-** Autocommit mode is disabled by a [BEGIN] statement.
-** Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
+** respectively.  ^Autocommit mode is on by default.
+** ^Autocommit mode is disabled by a [BEGIN] statement.
+** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
 **
 ** If certain kinds of errors occur on a statement within a multi-statement
 ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
@@ -3810,58 +3753,55 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
 ** If another thread changes the autocommit status of the database
 ** connection while this routine is running, then the return value
 ** is undefined.
-**
-** Requirements: [H12931] [H12932] [H12933] [H12934]
 */
 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
 
 /*
-** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600>
+** CAPI3REF: Find The Database Handle Of A Prepared Statement
 **
-** The sqlite3_db_handle interface returns the [database connection] handle
-** to which a [prepared statement] belongs.  The [database connection]
-** returned by sqlite3_db_handle is the same [database connection] that was the first argument
+** ^The sqlite3_db_handle interface returns the [database connection] handle
+** to which a [prepared statement] belongs.  ^The [database connection]
+** returned by sqlite3_db_handle is the same [database connection]
+** that was the first argument
 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
 ** create the statement in the first place.
-**
-** Requirements: [H13123]
 */
 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
 
 /*
-** CAPI3REF: Find the next prepared statement {H13140} <S60600>
+** CAPI3REF: Find the next prepared statement
 **
-** This interface returns a pointer to the next [prepared statement] after
-** pStmt associated with the [database connection] pDb.  If pStmt is NULL
+** ^This interface returns a pointer to the next [prepared statement] after
+** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL
 ** then this interface returns a pointer to the first prepared statement
-** associated with the database connection pDb.  If no prepared statement
+** associated with the database connection pDb.  ^If no prepared statement
 ** satisfies the conditions of this routine, it returns NULL.
 **
 ** The [database connection] pointer D in a call to
 ** [sqlite3_next_stmt(D,S)] must refer to an open database
 ** connection and in particular must not be a NULL pointer.
-**
-** Requirements: [H13143] [H13146] [H13149] [H13152]
 */
 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
 
 /*
-** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400>
+** CAPI3REF: Commit And Rollback Notification Callbacks
 **
-** The sqlite3_commit_hook() interface registers a callback
+** ^The sqlite3_commit_hook() interface registers a callback
 ** function to be invoked whenever a transaction is [COMMIT | committed].
-** Any callback set by a previous call to sqlite3_commit_hook()
+** ^Any callback set by a previous call to sqlite3_commit_hook()
 ** for the same database connection is overridden.
-** The sqlite3_rollback_hook() interface registers a callback
+** ^The sqlite3_rollback_hook() interface registers a callback
 ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
-** Any callback set by a previous call to sqlite3_commit_hook()
+** ^Any callback set by a previous call to sqlite3_rollback_hook()
 ** for the same database connection is overridden.
-** The pArg argument is passed through to the callback.
-** If the callback on a commit hook function returns non-zero,
+** ^The pArg argument is passed through to the callback.
+** ^If the callback on a commit hook function returns non-zero,
 ** then the commit is converted into a rollback.
 **
-** If another function was previously registered, its
-** pArg value is returned.  Otherwise NULL is returned.
+** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
+** return the P argument from the previous call of the same function
+** on the same [database connection] D, or NULL for
+** the first call for each function on D.
 **
 ** The callback implementation must not do anything that will modify
 ** the database connection that invoked the callback.  Any actions
@@ -3871,59 +3811,54 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
-** Registering a NULL function disables the callback.
+** ^Registering a NULL function disables the callback.
 **
-** When the commit hook callback routine returns zero, the [COMMIT]
-** operation is allowed to continue normally.  If the commit hook
+** ^When the commit hook callback routine returns zero, the [COMMIT]
+** operation is allowed to continue normally.  ^If the commit hook
 ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
-** The rollback hook is invoked on a rollback that results from a commit
+** ^The rollback hook is invoked on a rollback that results from a commit
 ** hook returning non-zero, just as it would be with any other rollback.
 **
-** For the purposes of this API, a transaction is said to have been
+** ^For the purposes of this API, a transaction is said to have been
 ** rolled back if an explicit "ROLLBACK" statement is executed, or
 ** an error or constraint causes an implicit rollback to occur.
-** The rollback callback is not invoked if a transaction is
+** ^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
+** ^The rollback callback is not invoked if a transaction is
 ** rolled back because a commit callback returned non-zero.
-** <todo> Check on this </todo>
 **
 ** See also the [sqlite3_update_hook()] interface.
-**
-** Requirements:
-** [H12951] [H12952] [H12953] [H12954] [H12955]
-** [H12961] [H12962] [H12963] [H12964]
 */
 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
 
 /*
-** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400>
+** CAPI3REF: Data Change Notification Callbacks
 **
-** The sqlite3_update_hook() interface registers a callback function
+** ^The sqlite3_update_hook() interface registers a callback function
 ** with the [database connection] identified by the first argument
 ** to be invoked whenever a row is updated, inserted or deleted.
-** Any callback set by a previous call to this function
+** ^Any callback set by a previous call to this function
 ** for the same database connection is overridden.
 **
-** The second argument is a pointer to the function to invoke when a
+** ^The second argument is a pointer to the function to invoke when a
 ** row is updated, inserted or deleted.
-** The first argument to the callback is a copy of the third argument
+** ^The first argument to the callback is a copy of the third argument
 ** to sqlite3_update_hook().
-** The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
+** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
 ** or [SQLITE_UPDATE], depending on the operation that caused the callback
 ** to be invoked.
-** The third and fourth arguments to the callback contain pointers to the
+** ^The third and fourth arguments to the callback contain pointers to the
 ** database and table name containing the affected row.
-** The final callback parameter is the [rowid] of the row.
-** In the case of an update, this is the [rowid] after the update takes place.
+** ^The final callback parameter is the [rowid] of the row.
+** ^In the case of an update, this is the [rowid] after the update takes place.
 **
-** The update hook is not invoked when internal system tables are
-** modified (i.e. sqlite_master and sqlite_sequence).
+** ^(The update hook is not invoked when internal system tables are
+** modified (i.e. sqlite_master and sqlite_sequence).)^
 **
-** In the current implementation, the update hook
+** ^In the current implementation, the update hook
 ** is not invoked when duplication rows are deleted because of an
-** [ON CONFLICT | ON CONFLICT REPLACE] clause.  Nor is the update hook
+** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook
 ** invoked when rows are deleted using the [truncate optimization].
 ** The exceptions defined in this paragraph might change in a future
 ** release of SQLite.
@@ -3935,14 +3870,13 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
-** If another function was previously registered, its pArg value
-** is returned.  Otherwise NULL is returned.
+** ^The sqlite3_update_hook(D,C,P) function
+** returns the P argument from the previous call
+** on the same [database connection] D, or NULL for
+** the first call on D.
 **
 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
 ** interfaces.
-**
-** Requirements:
-** [H12971] [H12973] [H12975] [H12977] [H12979] [H12981] [H12983] [H12986]
 */
 SQLITE_API void *sqlite3_update_hook(
   sqlite3*, 
@@ -3951,74 +3885,66 @@ SQLITE_API void *sqlite3_update_hook(
 );
 
 /*
-** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900>
+** CAPI3REF: Enable Or Disable Shared Pager Cache
 ** KEYWORDS: {shared cache}
 **
-** This routine enables or disables the sharing of the database cache
+** ^(This routine enables or disables the sharing of the database cache
 ** and schema data structures between [database connection | connections]
 ** to the same database. Sharing is enabled if the argument is true
-** and disabled if the argument is false.
+** and disabled if the argument is false.)^
 **
-** Cache sharing is enabled and disabled for an entire process.
+** ^Cache sharing is enabled and disabled for an entire process.
 ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
 ** sharing was enabled or disabled for each thread separately.
 **
-** The cache sharing mode set by this interface effects all subsequent
+** ^(The cache sharing mode set by this interface effects all subsequent
 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
 ** Existing database connections continue use the sharing mode
-** that was in effect at the time they were opened.
+** that was in effect at the time they were opened.)^
 **
-** Virtual tables cannot be used with a shared cache.  When shared
-** cache is enabled, the [sqlite3_create_module()] API used to register
-** virtual tables will always return an error.
+** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
+** successfully.  An [error code] is returned otherwise.)^
 **
-** This routine returns [SQLITE_OK] if shared cache was enabled or disabled
-** successfully.  An [error code] is returned otherwise.
-**
-** Shared cache is disabled by default. But this might change in
+** ^Shared cache is disabled by default. But this might change in
 ** future releases of SQLite.  Applications that care about shared
 ** cache setting should set it explicitly.
 **
 ** See Also:  [SQLite Shared-Cache Mode]
-**
-** Requirements: [H10331] [H10336] [H10337] [H10339]
 */
 SQLITE_API int sqlite3_enable_shared_cache(int);
 
 /*
-** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220>
+** CAPI3REF: Attempt To Free Heap Memory
 **
-** The sqlite3_release_memory() interface attempts to free N bytes
+** ^The sqlite3_release_memory() interface attempts to free N bytes
 ** of heap memory by deallocating non-essential memory allocations
-** held by the database library. {END}  Memory used to cache database
+** held by the database library.   Memory used to cache database
 ** pages to improve performance is an example of non-essential memory.
-** sqlite3_release_memory() returns the number of bytes actually freed,
+** ^sqlite3_release_memory() returns the number of bytes actually freed,
 ** which might be more or less than the amount requested.
-**
-** Requirements: [H17341] [H17342]
 */
 SQLITE_API int sqlite3_release_memory(int);
 
 /*
-** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220>
+** CAPI3REF: Impose A Limit On Heap Size
 **
-** The sqlite3_soft_heap_limit() interface places a "soft" limit
+** ^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
+** ^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 limit is called "soft", because if [sqlite3_release_memory()]
+** ^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.
 **
-** A negative or zero value for N means that there is no soft heap limit and
+** ^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.
+** ^The default value for the soft heap limit is zero.
 **
-** SQLite makes a best effort to honor the soft heap limit.
+** ^(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
+** continue without error or notification.)^  This is why the limit is
 ** called a "soft" limit.  It is advisory only.
 **
 ** Prior to SQLite version 3.5.0, this routine only constrained the memory
@@ -4028,35 +3954,32 @@ SQLITE_API int sqlite3_release_memory(int);
 ** 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.
-**
-** Requirements:
-** [H16351] [H16352] [H16353] [H16354] [H16355] [H16358]
 */
 SQLITE_API void sqlite3_soft_heap_limit(int);
 
 /*
-** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300>
+** CAPI3REF: Extract Metadata About A Column Of A Table
 **
-** This routine returns metadata about a specific column of a specific
+** ^This routine returns metadata about a specific column of a specific
 ** database table accessible using the [database connection] handle
 ** passed as the first function argument.
 **
-** The column is identified by the second, third and fourth parameters to
-** this function. The second parameter is either the name of the database
-** (i.e. "main", "temp" or an attached database) containing the specified
-** table or NULL. If it is NULL, then all attached databases are searched
+** ^The column is identified by the second, third and fourth parameters to
+** this function. ^The second parameter is either the name of the database
+** (i.e. "main", "temp", or an attached database) containing the specified
+** table or NULL. ^If it is NULL, then all attached databases are searched
 ** for the table using the same algorithm used by the database engine to
 ** resolve unqualified table references.
 **
-** The third and fourth parameters to this function are the table and column
+** ^The third and fourth parameters to this function are the table and column
 ** name of the desired column, respectively. Neither of these parameters
 ** may be NULL.
 **
-** Metadata is returned by writing to the memory locations passed as the 5th
-** and subsequent parameters to this function. Any of these arguments may be
+** ^Metadata is returned by writing to the memory locations passed as the 5th
+** and subsequent parameters to this function. ^Any of these arguments may be
 ** NULL, in which case the corresponding element of metadata is omitted.
 **
-** <blockquote>
+** ^(<blockquote>
 ** <table border="1">
 ** <tr><th> Parameter <th> Output<br>Type <th>  Description
 **
@@ -4066,17 +3989,17 @@ SQLITE_API void sqlite3_soft_heap_limit(int);
 ** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY
 ** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]
 ** </table>
-** </blockquote>
+** </blockquote>)^
 **
-** The memory pointed to by the character pointers returned for the
+** ^The memory pointed to by the character pointers returned for the
 ** declaration type and collation sequence is valid only until the next
 ** call to any SQLite API function.
 **
-** If the specified table is actually a view, an [error code] is returned.
+** ^If the specified table is actually a view, an [error code] is returned.
 **
-** If the specified column is "rowid", "oid" or "_rowid_" and an
+** ^If the specified column is "rowid", "oid" or "_rowid_" and an
 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
-** parameters are set for the explicitly declared column. If there is no
+** parameters are set for the explicitly declared column. ^(If there is no
 ** explicitly declared [INTEGER PRIMARY KEY] column, then the output
 ** parameters are set as follows:
 **
@@ -4086,14 +4009,14 @@ SQLITE_API void sqlite3_soft_heap_limit(int);
 **     not null: 0
 **     primary key: 1
 **     auto increment: 0
-** </pre>
+** </pre>)^
 **
-** This function may load one or more schemas from database files. If an
+** ^(This function may load one or more schemas from database files. If an
 ** error occurs during this process, or if the requested table or column
 ** cannot be found, an [error code] is returned and an error message left
-** in the [database connection] (to be retrieved using sqlite3_errmsg()).
+** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
 **
-** This API is only available if the library was compiled with the
+** ^This API is only available if the library was compiled with the
 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
 */
 SQLITE_API int sqlite3_table_column_metadata(
@@ -4109,30 +4032,29 @@ SQLITE_API int sqlite3_table_column_metadata(
 );
 
 /*
-** CAPI3REF: Load An Extension {H12600} <S20500>
+** CAPI3REF: Load An Extension
 **
-** This interface loads an SQLite extension library from the named file.
+** ^This interface loads an SQLite extension library from the named file.
 **
-** {H12601} The sqlite3_load_extension() interface attempts to load an
-**          SQLite extension library contained in the file zFile.
+** ^The sqlite3_load_extension() interface attempts to load an
+** SQLite extension library contained in the file zFile.
 **
-** {H12602} The entry point is zProc.
+** ^The entry point is zProc.
+** ^zProc may be 0, in which case the name of the entry point
+** defaults to "sqlite3_extension_init".
+** ^The sqlite3_load_extension() interface returns
+** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
+** ^If an error occurs and pzErrMsg is not 0, then the
+** [sqlite3_load_extension()] interface shall attempt to
+** fill *pzErrMsg with error message text stored in memory
+** obtained from [sqlite3_malloc()]. The calling function
+** should free this memory by calling [sqlite3_free()].
 **
-** {H12603} zProc may be 0, in which case the name of the entry point
-**          defaults to "sqlite3_extension_init".
+** ^Extension loading must be enabled using
+** [sqlite3_enable_load_extension()] prior to calling this API,
+** otherwise an error will be returned.
 **
-** {H12604} The sqlite3_load_extension() interface shall return
-**          [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
-**
-** {H12605} If an error occurs and pzErrMsg is not 0, then the
-**          [sqlite3_load_extension()] interface shall attempt to
-**          fill *pzErrMsg with error message text stored in memory
-**          obtained from [sqlite3_malloc()]. {END}  The calling function
-**          should free this memory by calling [sqlite3_free()].
-**
-** {H12606} Extension loading must be enabled using
-**          [sqlite3_enable_load_extension()] prior to calling this API,
-**          otherwise an error will be returned.
+** See also the [load_extension() SQL function].
 */
 SQLITE_API int sqlite3_load_extension(
   sqlite3 *db,          /* Load the extension into this database connection */
@@ -4142,61 +4064,49 @@ SQLITE_API int sqlite3_load_extension(
 );
 
 /*
-** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500>
+** CAPI3REF: Enable Or Disable Extension Loading
 **
-** So as not to open security holes in older applications that are
+** ^So as not to open security holes in older applications that are
 ** unprepared to deal with extension loading, and as a means of disabling
 ** extension loading while evaluating user-entered SQL, the following API
 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
 **
-** Extension loading is off by default. See ticket #1863.
-**
-** {H12621} Call the sqlite3_enable_load_extension() routine with onoff==1
-**          to turn extension loading on and call it with onoff==0 to turn
-**          it back off again.
-**
-** {H12622} Extension loading is off by default.
+** ^Extension loading is off by default. See ticket #1863.
+** ^Call the sqlite3_enable_load_extension() routine with onoff==1
+** to turn extension loading on and call it with onoff==0 to turn
+** it back off again.
 */
 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
 
 /*
-** CAPI3REF: Automatically Load An Extensions {H12640} <S20500>
+** CAPI3REF: Automatically Load An Extensions
 **
-** This API can be invoked at program startup in order to register
+** ^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]. {END}
+** to all new [database connections].
 **
-** This routine stores a pointer to the extension in an array that is
-** obtained from [sqlite3_malloc()].  If you run a memory leak checker
-** on your program and it reports a leak because of this array, invoke
-** [sqlite3_reset_auto_extension()] prior to shutdown to free the memory.
+** ^(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()].)^
 **
-** {H12641} 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()].
-**
-** {H12642} Duplicate extensions are detected so calling this routine
-**          multiple times with the same extension is harmless.
-**
-** {H12643} This routine stores a pointer to the extension in an array
-**          that is obtained from [sqlite3_malloc()].
-**
-** {H12644} Automatic extensions apply across all threads.
+** ^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.
 */
 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
 
 /*
-** CAPI3REF: Reset Automatic Extension Loading {H12660} <S20500>
-**
-** This function disables all previously registered automatic
-** extensions. {END}  It undoes the effect of all prior
-** [sqlite3_auto_extension()] calls.
+** CAPI3REF: Reset Automatic Extension Loading
 **
-** {H12661} This function disables all previously registered
-**          automatic extensions.
+** ^(This function disables all previously registered automatic
+** extensions. It undoes the effect of all prior
+** [sqlite3_auto_extension()] calls.)^
 **
-** {H12662} This function disables automatic extensions in all threads.
+** ^This function disables automatic extensions in all threads.
 */
 SQLITE_API void sqlite3_reset_auto_extension(void);
 
@@ -4220,7 +4130,7 @@ typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
 typedef struct sqlite3_module sqlite3_module;
 
 /*
-** CAPI3REF: Virtual Table Object {H18000} <S20400>
+** CAPI3REF: Virtual Table Object
 ** KEYWORDS: sqlite3_module {virtual table module}
 ** EXPERIMENTAL
 **
@@ -4228,10 +4138,10 @@ typedef struct sqlite3_module sqlite3_module;
 ** defines the implementation of a [virtual tables].  
 ** This structure consists mostly of methods for the module.
 **
-** A virtual table module is created by filling in a persistent
+** ^A virtual table module is created by filling in a persistent
 ** instance of this structure and passing a pointer to that instance
 ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
-** The registration remains valid until it is replaced by a different
+** ^The registration remains valid until it is replaced by a different
 ** module or until the [database connection] closes.  The content
 ** of this structure must not change while it is registered with
 ** any database connection.
@@ -4267,7 +4177,7 @@ struct sqlite3_module {
 };
 
 /*
-** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400>
+** CAPI3REF: Virtual Table Indexing Information
 ** KEYWORDS: sqlite3_index_info
 ** EXPERIMENTAL
 **
@@ -4277,42 +4187,42 @@ struct sqlite3_module {
 ** inputs to xBestIndex and are read-only.  xBestIndex inserts its
 ** results into the **Outputs** fields.
 **
-** The aConstraint[] array records WHERE clause constraints of the form:
+** ^(The aConstraint[] array records WHERE clause constraints of the form:
 **
 ** <pre>column OP expr</pre>
 **
-** where OP is =, <, <=, >, or >=.  The particular operator is
-** stored in aConstraint[].op.  The index of the column is stored in
-** aConstraint[].iColumn.  aConstraint[].usable is TRUE if the
+** where OP is =, <, <=, >, or >=.)^  ^(The particular operator is
+** stored in aConstraint[].op.)^  ^(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.
+** is usable) and false if it cannot.)^
 **
-** The optimizer automatically inverts terms of the form "expr OP column"
+** ^The optimizer automatically inverts terms of the form "expr OP column"
 ** and makes other simplifications to the WHERE clause in an attempt to
 ** get as many WHERE clause terms into the form shown above as possible.
-** The aConstraint[] array only reports WHERE clause terms in the correct
-** form that refer to the particular virtual table being queried.
+** ^The aConstraint[] array only reports WHERE clause terms that are
+** relevant to the particular virtual table being queried.
 **
-** Information about the ORDER BY clause is stored in aOrderBy[].
-** Each term of aOrderBy records a column of the ORDER BY clause.
+** ^Information about the ORDER BY clause is stored in aOrderBy[].
+** ^Each term of aOrderBy records a column of the ORDER BY clause.
 **
 ** The [xBestIndex] method must fill aConstraintUsage[] with information
-** about what parameters to pass to xFilter.  If argvIndex>0 then
+** about what parameters to pass to xFilter.  ^If argvIndex>0 then
 ** the right-hand side of the corresponding aConstraint[] is evaluated
-** and becomes the argvIndex-th entry in argv.  If aConstraintUsage[].omit
+** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit
 ** is true, then the constraint is assumed to be fully handled by the
-** virtual table and is not checked again by SQLite.
+** virtual table and is not checked again by SQLite.)^
 **
-** The idxNum and idxPtr values are recorded and passed into the
+** ^The idxNum and idxPtr values are recorded and passed into the
 ** [xFilter] method.
-** [sqlite3_free()] is used to free idxPtr if and only iff
+** ^[sqlite3_free()] is used to free idxPtr if and only if
 ** needToFreeIdxPtr is true.
 **
-** The orderByConsumed means that output from [xFilter]/[xNext] will occur in
+** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
 ** the correct order to satisfy the ORDER BY clause so that no separate
 ** sorting step is required.
 **
-** The estimatedCost value is an estimate of the cost of doing the
+** ^The estimatedCost value is an estimate of the cost of doing the
 ** particular lookup.  A full scan of a table with N entries should have
 ** a cost of N.  A binary search of a table of N entries should have a
 ** cost of approximately log(N).
@@ -4350,24 +4260,28 @@ struct sqlite3_index_info {
 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
 
 /*
-** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400>
+** CAPI3REF: Register A Virtual Table Implementation
 ** EXPERIMENTAL
 **
-** This routine is used to register a new [virtual table module] name.
-** Module names must be registered before
-** creating a new [virtual table] using the module, or before using a
+** ^These routines are used to register a new [virtual table module] name.
+** ^Module names must be registered before
+** creating a new [virtual table] using the module and before using a
 ** preexisting [virtual table] for the module.
 **
-** The module name is registered on the [database connection] specified
-** by the first parameter.  The name of the module is given by the 
-** second parameter.  The third parameter is a pointer to
-** the implementation of the [virtual table module].   The fourth
+** ^The module name is registered on the [database connection] specified
+** by the first parameter.  ^The name of the module is given by the 
+** second parameter.  ^The third parameter is a pointer to
+** the implementation of the [virtual table module].   ^The fourth
 ** parameter is an arbitrary client data pointer that is passed through
 ** into the [xCreate] and [xConnect] methods of the virtual table module
 ** when a new virtual table is be being created or reinitialized.
 **
-** This interface has exactly the same effect as calling
-** [sqlite3_create_module_v2()] with a NULL client data destructor.
+** ^The sqlite3_create_module_v2() interface has a fifth parameter which
+** is a pointer to a destructor for the pClientData.  ^SQLite will
+** invoke the destructor function (if it is not NULL) when SQLite
+** no longer needs the pClientData pointer.  ^The sqlite3_create_module()
+** interface is equivalent to sqlite3_create_module_v2() with a NULL
+** destructor.
 */
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
   sqlite3 *db,               /* SQLite connection to register module with */
@@ -4375,17 +4289,6 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
   const sqlite3_module *p,   /* Methods for the module */
   void *pClientData          /* Client data for xCreate/xConnect */
 );
-
-/*
-** CAPI3REF: Register A Virtual Table Implementation {H18210} <S20400>
-** EXPERIMENTAL
-**
-** This routine is identical to the [sqlite3_create_module()] method,
-** except that it has an extra parameter to specify 
-** a destructor function for the client data pointer.  SQLite will
-** invoke the destructor function (if it is not NULL) when SQLite
-** no longer needs the pClientData pointer.  
-*/
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
   sqlite3 *db,               /* SQLite connection to register module with */
   const char *zName,         /* Name of the module */
@@ -4395,21 +4298,21 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
 );
 
 /*
-** CAPI3REF: Virtual Table Instance Object {H18010} <S20400>
+** CAPI3REF: Virtual Table Instance Object
 ** KEYWORDS: sqlite3_vtab
 ** EXPERIMENTAL
 **
 ** Every [virtual table module] implementation uses a subclass
-** of the following structure to describe a particular instance
+** of this object to describe a particular instance
 ** of the [virtual table].  Each subclass will
 ** be tailored to the specific needs of the module implementation.
 ** The purpose of this superclass is to define certain fields that are
 ** common to all module implementations.
 **
-** Virtual tables methods can set an error message by assigning a
+** ^Virtual tables methods can set an error message by assigning a
 ** string obtained from [sqlite3_mprintf()] to zErrMsg.  The method should
 ** take care that any prior string is freed by a call to [sqlite3_free()]
-** prior to assigning a new string to zErrMsg.  After the error message
+** prior to assigning a new string to zErrMsg.  ^After the error message
 ** is delivered up to the client application, the string will be automatically
 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
 */
@@ -4421,7 +4324,7 @@ struct sqlite3_vtab {
 };
 
 /*
-** CAPI3REF: Virtual Table Cursor Object  {H18020} <S20400>
+** CAPI3REF: Virtual Table Cursor Object
 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
 ** EXPERIMENTAL
 **
@@ -4430,7 +4333,7 @@ struct sqlite3_vtab {
 ** [virtual table] and are used
 ** to loop through the virtual table.  Cursors are created using the
 ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed
-** by the [sqlite3_module.xClose | xClose] method.  Cussors are used
+** by the [sqlite3_module.xClose | xClose] method.  Cursors are used
 ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods
 ** of the module.  Each module implementation will define
 ** the content of a cursor structure to suit its own needs.
@@ -4444,10 +4347,10 @@ struct sqlite3_vtab_cursor {
 };
 
 /*
-** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400>
+** CAPI3REF: Declare The Schema Of A Virtual Table
 ** EXPERIMENTAL
 **
-** The [xCreate] and [xConnect] methods of a
+** ^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.
@@ -4455,17 +4358,17 @@ struct sqlite3_vtab_cursor {
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
 
 /*
-** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400>
+** CAPI3REF: Overload A Function For A Virtual Table
 ** EXPERIMENTAL
 **
-** Virtual tables can provide alternative implementations of functions
+** ^(Virtual tables can provide alternative implementations of functions
 ** using the [xFindFunction] method of the [virtual table module].  
 ** But global versions of those functions
-** must exist in order to be overloaded.
+** must exist in order to be overloaded.)^
 **
-** This API makes sure a global version of a function with a particular
+** ^(This API makes sure a global version of a function with a particular
 ** name and number of parameters exists.  If no such function exists
-** before this API is called, a new function is created.  The implementation
+** before this API is called, a new function is created.)^  ^The implementation
 ** of the new function always causes an exception to be thrown.  So
 ** the new function is not good for anything by itself.  Its only
 ** purpose is to be a placeholder function that can be overloaded
@@ -4486,77 +4389,74 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_overload_function(sqlite3*, const cha
 */
 
 /*
-** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230>
+** CAPI3REF: A Handle To An Open BLOB
 ** KEYWORDS: {BLOB handle} {BLOB handles}
 **
 ** An instance of this object represents an open BLOB on which
 ** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
-** Objects of this type are created by [sqlite3_blob_open()]
+** ^Objects of this type are created by [sqlite3_blob_open()]
 ** and destroyed by [sqlite3_blob_close()].
-** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
+** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
 ** can be used to read or write small subsections of the BLOB.
-** The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
+** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
 */
 typedef struct sqlite3_blob sqlite3_blob;
 
 /*
-** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230>
+** CAPI3REF: Open A BLOB For Incremental I/O
 **
-** This interfaces opens a [BLOB handle | handle] to the BLOB located
+** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
 ** in row iRow, column zColumn, table zTable in database zDb;
 ** in other words, the same BLOB that would be selected by:
 **
 ** <pre>
 **     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
-** </pre> {END}
+** </pre>)^
 **
-** If the flags parameter is non-zero, then the BLOB is opened for read
-** and write access. If it is zero, the BLOB is opened for read access.
-** It is not possible to open a column that is part of an index or primary 
+** ^If the flags parameter is non-zero, then the BLOB is opened for read
+** and write access. ^If it is zero, the BLOB is opened for read access.
+** ^It is not possible to open a column that is part of an index or primary 
 ** key for writing. ^If [foreign key constraints] are enabled, it is 
 ** not possible to open a column that is part of a [child key] for writing.
 **
-** Note that the database name is not the filename that contains
+** ^Note that the database name is not the filename that contains
 ** the database but rather the symbolic name of the database that
-** is assigned when the database is connected using [ATTACH].
-** For the main database file, the database name is "main".
-** For TEMP tables, the database name is "temp".
+** appears after the AS keyword when the database is connected using [ATTACH].
+** ^For the main database file, the database name is "main".
+** ^For TEMP tables, the database name is "temp".
 **
-** On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
+** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
 ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
-** to be a null pointer.
-** This function sets the [database connection] error code and message
+** to be a null pointer.)^
+** ^This function sets the [database connection] error code and message
 ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
-** functions.  Note that the *ppBlob variable is always initialized in a
+** functions. ^Note that the *ppBlob variable is always initialized in a
 ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
 ** regardless of the success or failure of this routine.
 **
-** If the row that a BLOB handle points to is modified by an
+** ^(If the row that a BLOB handle points to is modified by an
 ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
 ** then the BLOB handle is marked as "expired".
 ** This is true if any column of the row is changed, even a column
-** other than the one the BLOB handle is open on.
-** Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
+** other than the one the BLOB handle is open on.)^
+** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
 ** a expired BLOB handle fail with an return code of [SQLITE_ABORT].
-** Changes written into a BLOB prior to the BLOB expiring are not
-** rollback by the expiration of the BLOB.  Such changes will eventually
-** commit if the transaction continues to completion.
+** ^(Changes written into a BLOB prior to the BLOB expiring are not
+** rolled back by the expiration of the BLOB.  Such changes will eventually
+** commit if the transaction continues to completion.)^
 **
-** Use the [sqlite3_blob_bytes()] interface to determine the size of
-** the opened blob.  The size of a blob may not be changed by this
+** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
+** the opened blob.  ^The size of a blob may not be changed by this
 ** interface.  Use the [UPDATE] SQL command to change the size of a
 ** blob.
 **
-** The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
+** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
 ** and the built-in [zeroblob] SQL function can be used, if desired,
 ** to create an empty, zero-filled blob in which to read or write using
 ** this interface.
 **
 ** To avoid a resource leak, every open [BLOB handle] should eventually
 ** be released by a call to [sqlite3_blob_close()].
-**
-** Requirements:
-** [H17813] [H17814] [H17816] [H17819] [H17821] [H17824]
 */
 SQLITE_API int sqlite3_blob_open(
   sqlite3*,
@@ -4569,37 +4469,34 @@ SQLITE_API int sqlite3_blob_open(
 );
 
 /*
-** CAPI3REF: Close A BLOB Handle {H17830} <S30230>
+** CAPI3REF: Close A BLOB Handle
 **
-** Closes an open [BLOB handle].
+** ^Closes an open [BLOB handle].
 **
-** Closing a BLOB shall cause the current transaction to commit
+** ^Closing a BLOB shall cause the current transaction to commit
 ** if there are no other BLOBs, no pending prepared statements, and the
 ** database connection is in [autocommit mode].
-** If any writes were made to the BLOB, they might be held in cache
+** ^If any writes were made to the BLOB, they might be held in cache
 ** until the close operation if they will fit.
 **
-** Closing the BLOB often forces the changes
+** ^(Closing the BLOB often forces the changes
 ** out to disk and so if any I/O errors occur, they will likely occur
 ** at the time when the BLOB is closed.  Any errors that occur during
-** closing are reported as a non-zero return value.
+** closing are reported as a non-zero return value.)^
 **
-** The BLOB is closed unconditionally.  Even if this routine returns
-** an error code, the BLOB is still closed.
+** ^(The BLOB is closed unconditionally.  Even if this routine returns
+** an error code, the BLOB is still closed.)^
 **
-** Calling this routine with a null pointer (which as would be returned
-** by failed call to [sqlite3_blob_open()]) is a harmless no-op.
-**
-** Requirements:
-** [H17833] [H17836] [H17839]
+** ^Calling this routine with a null pointer (such as would be returned
+** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
 */
 SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
 
 /*
-** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230>
+** CAPI3REF: Return The Size Of An Open BLOB
 **
-** Returns the size in bytes of the BLOB accessible via the 
-** successfully opened [BLOB handle] in its only argument.  The
+** ^Returns the size in bytes of the BLOB accessible via the 
+** successfully opened [BLOB handle] in its only argument.  ^The
 ** incremental blob I/O routines can only read or overwriting existing
 ** blob content; they cannot change the size of a blob.
 **
@@ -4607,30 +4504,27 @@ SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
 ** by a prior successful call to [sqlite3_blob_open()] and which has not
 ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
 ** to this routine results in undefined and probably undesirable behavior.
-**
-** Requirements:
-** [H17843]
 */
 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
 
 /*
-** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230>
+** CAPI3REF: Read Data From A BLOB Incrementally
 **
-** This function is used to read data from an open [BLOB handle] into a
+** ^(This function is used to read data from an open [BLOB handle] into a
 ** caller-supplied buffer. N bytes of data are copied into buffer Z
-** from the open BLOB, starting at offset iOffset.
+** from the open BLOB, starting at offset iOffset.)^
 **
-** If offset iOffset is less than N bytes from the end of the BLOB,
-** [SQLITE_ERROR] is returned and no data is read.  If N or iOffset is
+** ^If offset iOffset is less than N bytes from the end of the BLOB,
+** [SQLITE_ERROR] is returned and no data is read.  ^If N or iOffset is
 ** less than zero, [SQLITE_ERROR] is returned and no data is read.
-** The size of the blob (and hence the maximum value of N+iOffset)
+** ^The size of the blob (and hence the maximum value of N+iOffset)
 ** can be determined using the [sqlite3_blob_bytes()] interface.
 **
-** An attempt to read from an expired [BLOB handle] fails with an
+** ^An attempt to read from an expired [BLOB handle] fails with an
 ** error code of [SQLITE_ABORT].
 **
-** On success, SQLITE_OK is returned.
-** Otherwise, an [error code] or an [extended error code] is returned.
+** ^(On success, sqlite3_blob_read() returns SQLITE_OK.
+** Otherwise, an [error code] or an [extended error code] is returned.)^
 **
 ** This routine only works on a [BLOB handle] which has been created
 ** by a prior successful call to [sqlite3_blob_open()] and which has not
@@ -4638,40 +4532,37 @@ SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
 ** to this routine results in undefined and probably undesirable behavior.
 **
 ** See also: [sqlite3_blob_write()].
-**
-** Requirements:
-** [H17853] [H17856] [H17859] [H17862] [H17863] [H17865] [H17868]
 */
 SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
 
 /*
-** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230>
+** CAPI3REF: Write Data Into A BLOB Incrementally
 **
-** This function is used to write data into an open [BLOB handle] from a
-** caller-supplied buffer. N bytes of data are copied from the buffer Z
+** ^This function is used to write data into an open [BLOB handle] from a
+** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
 ** into the open BLOB, starting at offset iOffset.
 **
-** If the [BLOB handle] passed as the first argument was not opened for
+** ^If the [BLOB handle] passed as the first argument was not opened for
 ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
 ** this function returns [SQLITE_READONLY].
 **
-** This function may only modify the contents of the BLOB; it is
+** ^This function may only modify the contents of the BLOB; it is
 ** not possible to increase the size of a BLOB using this API.
-** If offset iOffset is less than N bytes from the end of the BLOB,
-** [SQLITE_ERROR] is returned and no data is written.  If N is
+** ^If offset iOffset is less than N bytes from the end of the BLOB,
+** [SQLITE_ERROR] is returned and no data is written.  ^If N is
 ** less than zero [SQLITE_ERROR] is returned and no data is written.
 ** The size of the BLOB (and hence the maximum value of N+iOffset)
 ** can be determined using the [sqlite3_blob_bytes()] interface.
 **
-** An attempt to write to an expired [BLOB handle] fails with an
-** error code of [SQLITE_ABORT].  Writes to the BLOB that occurred
+** ^An attempt to write to an expired [BLOB handle] fails with an
+** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred
 ** before the [BLOB handle] expired are not rolled back by the
 ** expiration of the handle, though of course those changes might
 ** have been overwritten by the statement that expired the BLOB handle
 ** or by other independent statements.
 **
-** On success, SQLITE_OK is returned.
-** Otherwise, an  [error code] or an [extended error code] is returned.
+** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
+** Otherwise, an  [error code] or an [extended error code] is returned.)^
 **
 ** This routine only works on a [BLOB handle] which has been created
 ** by a prior successful call to [sqlite3_blob_open()] and which has not
@@ -4679,15 +4570,11 @@ SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
 ** to this routine results in undefined and probably undesirable behavior.
 **
 ** See also: [sqlite3_blob_read()].
-**
-** Requirements:
-** [H17873] [H17874] [H17875] [H17876] [H17877] [H17879] [H17882] [H17885]
-** [H17888]
 */
 SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
 
 /*
-** CAPI3REF: Virtual File System Objects {H11200} <S20100>
+** CAPI3REF: Virtual File System Objects
 **
 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
 ** that SQLite uses to interact
@@ -4696,34 +4583,31 @@ SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOff
 ** New VFSes can be registered and existing VFSes can be unregistered.
 ** The following interfaces are provided.
 **
-** The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
-** Names are case sensitive.
-** Names are zero-terminated UTF-8 strings.
-** If there is no match, a NULL pointer is returned.
-** If zVfsName is NULL then the default VFS is returned.
+** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
+** ^Names are case sensitive.
+** ^Names are zero-terminated UTF-8 strings.
+** ^If there is no match, a NULL pointer is returned.
+** ^If zVfsName is NULL then the default VFS is returned.
 **
-** New VFSes are registered with sqlite3_vfs_register().
-** Each new VFS becomes the default VFS if the makeDflt flag is set.
-** The same VFS can be registered multiple times without injury.
-** To make an existing VFS into the default VFS, register it again
+** ^New VFSes are registered with sqlite3_vfs_register().
+** ^Each new VFS becomes the default VFS if the makeDflt flag is set.
+** ^The same VFS can be registered multiple times without injury.
+** ^To make an existing VFS into the default VFS, register it again
 ** with the makeDflt flag set.  If two different VFSes with the
 ** same name are registered, the behavior is undefined.  If a
 ** VFS is registered with a name that is NULL or an empty string,
 ** then the behavior is undefined.
 **
-** Unregister a VFS with the sqlite3_vfs_unregister() interface.
-** If the default VFS is unregistered, another VFS is chosen as
-** the default.  The choice for the new VFS is arbitrary.
-**
-** Requirements:
-** [H11203] [H11206] [H11209] [H11212] [H11215] [H11218]
+** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
+** ^(If the default VFS is unregistered, another VFS is chosen as
+** the default.  The choice for the new VFS is arbitrary.)^
 */
 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
 
 /*
-** CAPI3REF: Mutexes {H17000} <S20000>
+** CAPI3REF: Mutexes
 **
 ** The SQLite core uses these routines for thread
 ** synchronization. Though they are intended for internal
@@ -4732,7 +4616,7 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
 **
 ** The SQLite source code contains multiple implementations
 ** of these mutex routines.  An appropriate implementation
-** is selected automatically at compile-time.  The following
+** is selected automatically at compile-time.  ^(The following
 ** implementations are available in the SQLite core:
 **
 ** <ul>
@@ -4740,26 +4624,26 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
 ** <li>   SQLITE_MUTEX_PTHREAD
 ** <li>   SQLITE_MUTEX_W32
 ** <li>   SQLITE_MUTEX_NOOP
-** </ul>
+** </ul>)^
 **
-** The SQLITE_MUTEX_NOOP implementation is a set of routines
+** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
 ** that does no real locking and is appropriate for use in
-** a single-threaded application.  The SQLITE_MUTEX_OS2,
+** a single-threaded application.  ^The SQLITE_MUTEX_OS2,
 ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
 ** are appropriate for use on OS/2, Unix, and Windows.
 **
-** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
+** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
 ** implementation is included with the library. In this case the
 ** application must supply a custom mutex implementation using the
 ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
 ** before calling sqlite3_initialize() or any other public sqlite3_
-** function that calls sqlite3_initialize().
+** function that calls sqlite3_initialize().)^
 **
-** {H17011} The sqlite3_mutex_alloc() routine allocates a new
-** mutex and returns a pointer to it. {H17012} If it returns NULL
-** that means that a mutex could not be allocated. {H17013} SQLite
-** will unwind its stack and return an error. {H17014} The argument
+** ^The sqlite3_mutex_alloc() routine allocates a new
+** mutex and returns a pointer to it. ^If it returns NULL
+** that means that a mutex could not be allocated.  ^SQLite
+** will unwind its stack and return an error.  ^(The argument
 ** to sqlite3_mutex_alloc() is one of these integer constants:
 **
 ** <ul>
@@ -4771,64 +4655,66 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
 ** <li>  SQLITE_MUTEX_STATIC_PRNG
 ** <li>  SQLITE_MUTEX_STATIC_LRU
 ** <li>  SQLITE_MUTEX_STATIC_LRU2
-** </ul>
+** </ul>)^
 **
-** {H17015} The first two constants cause sqlite3_mutex_alloc() to create
-** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
-** is used but not necessarily so when SQLITE_MUTEX_FAST is used. {END}
+** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
+** cause sqlite3_mutex_alloc() to create
+** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
+** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
 ** The mutex implementation does not need to make a distinction
 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
-** not want to.  {H17016} But SQLite will only request a recursive mutex in
-** cases where it really needs one.  {END} If a faster non-recursive mutex
+** not want to.  ^SQLite will only request a recursive mutex in
+** cases where it really needs one.  ^If a faster non-recursive mutex
 ** implementation is available on the host platform, the mutex subsystem
 ** might return such a mutex in response to SQLITE_MUTEX_FAST.
 **
-** {H17017} The other allowed parameters to sqlite3_mutex_alloc() each return
-** a pointer to a static preexisting mutex. {END}  Six static mutexes are
+** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
+** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
+** a pointer to a static preexisting mutex.  ^Six static mutexes are
 ** used by the current version of SQLite.  Future versions of SQLite
 ** may add additional static mutexes.  Static mutexes are for internal
 ** use by SQLite only.  Applications that use SQLite mutexes should
 ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
 ** SQLITE_MUTEX_RECURSIVE.
 **
-** {H17018} Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
+** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
 ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
-** returns a different mutex on every call.  {H17034} But for the static
+** returns a different mutex on every call.  ^But for the static
 ** mutex types, the same mutex is returned on every call that has
 ** the same type number.
 **
-** {H17019} The sqlite3_mutex_free() routine deallocates a previously
-** allocated dynamic mutex. {H17020} SQLite is careful to deallocate every
-** dynamic mutex that it allocates. {A17021} The dynamic mutexes must not be in
-** use when they are deallocated. {A17022} Attempting to deallocate a static
-** mutex results in undefined behavior. {H17023} SQLite never deallocates
-** a static mutex. {END}
+** ^The sqlite3_mutex_free() routine deallocates a previously
+** allocated dynamic mutex.  ^SQLite is careful to deallocate every
+** dynamic mutex that it allocates.  The dynamic mutexes must not be in
+** use when they are deallocated.  Attempting to deallocate a static
+** mutex results in undefined behavior.  ^SQLite never deallocates
+** a static mutex.
 **
-** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
-** to enter a mutex. {H17024} If another thread is already within the mutex,
+** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
+** to enter a mutex.  ^If another thread is already within the mutex,
 ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
-** SQLITE_BUSY. {H17025}  The sqlite3_mutex_try() interface returns [SQLITE_OK]
-** upon successful entry.  {H17026} Mutexes created using
+** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
+** upon successful entry.  ^(Mutexes created using
 ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
-** {H17027} In such cases the,
+** In such cases the,
 ** mutex must be exited an equal number of times before another thread
-** can enter.  {A17028} If the same thread tries to enter any other
+** can enter.)^  ^(If the same thread tries to enter any other
 ** kind of mutex more than once, the behavior is undefined.
-** {H17029} SQLite will never exhibit
-** such behavior in its own use of mutexes.
+** SQLite will never exhibit
+** such behavior in its own use of mutexes.)^
 **
-** Some systems (for example, Windows 95) do not support the operation
+** ^(Some systems (for example, Windows 95) do not support the operation
 ** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()
-** will always return SQLITE_BUSY.  {H17030} The SQLite core only ever uses
-** sqlite3_mutex_try() as an optimization so this is acceptable behavior.
+** will always return SQLITE_BUSY.  The SQLite core only ever uses
+** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
 **
-** {H17031} The sqlite3_mutex_leave() routine exits a mutex that was
-** previously entered by the same thread.  {A17032} The behavior
+** ^The sqlite3_mutex_leave() routine exits a mutex that was
+** previously entered by the same thread.   ^(The behavior
 ** is undefined if the mutex is not currently entered by the
-** calling thread or is not currently allocated.  {H17033} SQLite will
-** never do either. {END}
+** calling thread or is not currently allocated.  SQLite will
+** never do either.)^
 **
-** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
+** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
 ** behave as no-ops.
 **
@@ -4841,7 +4727,7 @@ SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 
 /*
-** CAPI3REF: Mutex Methods Object {H17120} <S20130>
+** CAPI3REF: Mutex Methods Object
 ** EXPERIMENTAL
 **
 ** An instance of this structure defines the low-level routines
@@ -4857,19 +4743,19 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 ** output variable when querying the system for the current mutex
 ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
 **
-** The xMutexInit method defined by this structure is invoked as
+** ^The xMutexInit method defined by this structure is invoked as
 ** part of system initialization by the sqlite3_initialize() function.
-** {H17001} The xMutexInit routine shall be called by SQLite once for each
+** ^The xMutexInit routine is calle by SQLite exactly once for each
 ** effective call to [sqlite3_initialize()].
 **
-** The xMutexEnd method defined by this structure is invoked as
+** ^The xMutexEnd method defined by this structure is invoked as
 ** part of system shutdown by the sqlite3_shutdown() function. The
 ** implementation of this method is expected to release all outstanding
 ** resources obtained by the mutex methods implementation, especially
-** those obtained by the xMutexInit method. {H17003} The xMutexEnd()
-** interface shall be invoked once for each call to [sqlite3_shutdown()].
+** those obtained by the xMutexInit method.  ^The xMutexEnd()
+** interface is invoked exactly once for each call to [sqlite3_shutdown()].
 **
-** The remaining seven methods defined by this structure (xMutexAlloc,
+** ^(The remaining seven methods defined by this structure (xMutexAlloc,
 ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
 ** xMutexNotheld) implement the following interfaces (respectively):
 **
@@ -4881,7 +4767,7 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 **   <li>  [sqlite3_mutex_leave()] </li>
 **   <li>  [sqlite3_mutex_held()] </li>
 **   <li>  [sqlite3_mutex_notheld()] </li>
-** </ul>
+** </ul>)^
 **
 ** The only difference is that the public sqlite3_XXX functions enumerated
 ** above silently ignore any invocations that pass a NULL pointer instead
@@ -4891,17 +4777,17 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 ** (i.e. it is acceptable to provide an implementation that segfaults if
 ** it is passed a NULL pointer).
 **
-** The xMutexInit() method must be threadsafe.  It must be harmless to
+** The xMutexInit() method must be threadsafe.  ^It must be harmless to
 ** invoke xMutexInit() mutiple times within the same process and without
 ** intervening calls to xMutexEnd().  Second and subsequent calls to
 ** xMutexInit() must be no-ops.
 **
-** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
-** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory
-** allocation for a static mutex.  However xMutexAlloc() may use SQLite
+** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
+** and its associates).  ^Similarly, xMutexAlloc() must not use SQLite memory
+** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite
 ** memory allocation for a fast or recursive mutex.
 **
-** SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
+** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
 ** called, but only if the prior call to xMutexInit returned SQLITE_OK.
 ** If xMutexInit fails in any way, it is expected to clean up after itself
 ** prior to returning.
@@ -4920,39 +4806,41 @@ struct sqlite3_mutex_methods {
 };
 
 /*
-** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800>
+** CAPI3REF: Mutex Verification Routines
 **
 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
-** are intended for use inside assert() statements. {H17081} The SQLite core
+** are intended for use inside assert() statements.  ^The SQLite core
 ** never uses these routines except inside an assert() and applications
-** are advised to follow the lead of the core.  {H17082} The core only
+** are advised to follow the lead of the core.  ^The SQLite core only
 ** provides implementations for these routines when it is compiled
-** with the SQLITE_DEBUG flag.  {A17087} External mutex implementations
+** with the SQLITE_DEBUG flag.  ^External mutex implementations
 ** are only required to provide these routines if SQLITE_DEBUG is
 ** defined and if NDEBUG is not defined.
 **
-** {H17083} These routines should return true if the mutex in their argument
+** ^These routines should return true if the mutex in their argument
 ** is held or not held, respectively, by the calling thread.
 **
-** {X17084} The implementation is not required to provided versions of these
+** ^The implementation is not required to provided versions of these
 ** routines that actually work. If the implementation does not provide working
 ** versions of these routines, it should at least provide stubs that always
 ** return true so that one does not get spurious assertion failures.
 **
-** {H17085} If the argument to sqlite3_mutex_held() is a NULL pointer then
-** the routine should return 1.  {END} This seems counter-intuitive since
+** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
+** the routine should return 1.   This seems counter-intuitive since
 ** clearly the mutex cannot be held if it does not exist.  But the
 ** the reason the mutex does not exist is because the build is not
 ** using mutexes.  And we do not want the assert() containing the
 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
-** the appropriate thing to do.  {H17086} The sqlite3_mutex_notheld()
+** the appropriate thing to do.  ^The sqlite3_mutex_notheld()
 ** interface should also return 1 when given a NULL pointer.
 */
+#ifndef NDEBUG
 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
+#endif
 
 /*
-** CAPI3REF: Mutex Types {H17001} <H17000>
+** CAPI3REF: Mutex Types
 **
 ** The [sqlite3_mutex_alloc()] interface takes a single argument
 ** which is one of these integer constants.
@@ -4972,48 +4860,50 @@ SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
 #define SQLITE_MUTEX_STATIC_LRU2      7  /* lru page list */
 
 /*
-** CAPI3REF: Retrieve the mutex for a database connection {H17002} <H17000>
+** CAPI3REF: Retrieve the mutex for a database connection
 **
-** This interface returns a pointer the [sqlite3_mutex] object that 
+** ^This interface returns a pointer the [sqlite3_mutex] object that 
 ** serializes access to the [database connection] given in the argument
 ** when the [threading mode] is Serialized.
-** If the [threading mode] is Single-thread or Multi-thread then this
+** ^If the [threading mode] is Single-thread or Multi-thread then this
 ** routine returns a NULL pointer.
 */
 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
 
 /*
-** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800>
+** CAPI3REF: Low-Level Control Of Database Files
 **
-** {H11301} The [sqlite3_file_control()] interface makes a direct call to the
+** ^The [sqlite3_file_control()] interface makes a direct call to the
 ** xFileControl method for the [sqlite3_io_methods] object associated
-** with a particular database identified by the second argument. {H11302} The
-** name of the database is the name assigned to the database by the
-** <a href="lang_attach.html">ATTACH</a> SQL command that opened the
-** database. {H11303} To control the main database file, use the name "main"
-** or a NULL pointer. {H11304} The third and fourth parameters to this routine
+** with a particular database identified by the second argument. ^The
+** name of the database "main" for the main database or "temp" for the
+** TEMP database, or the name that appears after the AS keyword for
+** databases that are added using the [ATTACH] SQL command.
+** ^A NULL pointer can be used in place of "main" to refer to the
+** main database file.
+** ^The third and fourth parameters to this routine
 ** are passed directly through to the second and third parameters of
-** the xFileControl method.  {H11305} The return value of the xFileControl
+** the xFileControl method.  ^The return value of the xFileControl
 ** method becomes the return value of this routine.
 **
-** {H11306} If the second parameter (zDbName) does not match the name of any
-** open database file, then SQLITE_ERROR is returned. {H11307} This error
+** ^If the second parameter (zDbName) does not match the name of any
+** open database file, then SQLITE_ERROR is returned.  ^This error
 ** code is not remembered and will not be recalled by [sqlite3_errcode()]
-** or [sqlite3_errmsg()]. {A11308} The underlying xFileControl method might
-** also return SQLITE_ERROR.  {A11309} There is no way to distinguish between
+** or [sqlite3_errmsg()].  The underlying xFileControl method might
+** also return SQLITE_ERROR.  There is no way to distinguish between
 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
-** xFileControl method. {END}
+** xFileControl method.
 **
 ** See also: [SQLITE_FCNTL_LOCKSTATE]
 */
 SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
 
 /*
-** CAPI3REF: Testing Interface {H11400} <S30800>
+** CAPI3REF: Testing Interface
 **
-** The sqlite3_test_control() interface is used to read out internal
+** ^The sqlite3_test_control() interface is used to read out internal
 ** state of SQLite and to inject faults into SQLite for testing
-** purposes.  The first parameter is an operation code that determines
+** purposes.  ^The first parameter is an operation code that determines
 ** the number, meaning, and operation of all subsequent parameters.
 **
 ** This interface is not for use by applications.  It exists solely
@@ -5028,7 +4918,7 @@ SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*
 SQLITE_API int sqlite3_test_control(int op, ...);
 
 /*
-** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400>
+** CAPI3REF: Testing Interface Operation Codes
 **
 ** These constants are the valid operation code parameters used
 ** as the first argument to [sqlite3_test_control()].
@@ -5038,6 +4928,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 ** Applications should not use any of these parameters or the
 ** [sqlite3_test_control()] interface.
 */
+#define SQLITE_TESTCTRL_FIRST                    5
 #define SQLITE_TESTCTRL_PRNG_SAVE                5
 #define SQLITE_TESTCTRL_PRNG_RESTORE             6
 #define SQLITE_TESTCTRL_PRNG_RESET               7
@@ -5048,27 +4939,30 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 #define SQLITE_TESTCTRL_ASSERT                  12
 #define SQLITE_TESTCTRL_ALWAYS                  13
 #define SQLITE_TESTCTRL_RESERVE                 14
+#define SQLITE_TESTCTRL_OPTIMIZATIONS           15
+#define SQLITE_TESTCTRL_ISKEYWORD               16
+#define SQLITE_TESTCTRL_LAST                    16
 
 /*
-** CAPI3REF: SQLite Runtime Status {H17200} <S60200>
+** CAPI3REF: SQLite Runtime Status
 ** EXPERIMENTAL
 **
-** This interface is used to retrieve runtime status information
+** ^This interface is used to retrieve runtime status information
 ** about the preformance 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_...].
-** The current value of the parameter is returned into *pCurrent.
-** The highest recorded value is returned in *pHighwater.  If the
+** 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_...].)^
+** ^The current value of the parameter is returned into *pCurrent.
+** ^The highest recorded value is returned in *pHighwater.  ^If the
 ** resetFlag is true, then the highest record value is reset after
-** *pHighwater is written. Some parameters do not record the highest
+** *pHighwater is written.  ^(Some parameters do not record the highest
 ** value.  For those parameters
-** nothing is written into *pHighwater and the resetFlag is ignored.
-** Other parameters record only the highwater mark and not the current
-** value.  For these latter parameters nothing is written into *pCurrent.
+** nothing is written into *pHighwater and the resetFlag is ignored.)^
+** ^(Other parameters record only the highwater mark and not the current
+** value.  For these latter parameters nothing is written into *pCurrent.)^
 **
-** This routine returns SQLITE_OK on success and a non-zero
-** [error code] on failure.
+** ^The sqlite3_db_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
 ** called while other threads are running the same or different SQLite
@@ -5083,14 +4977,14 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 
 
 /*
-** CAPI3REF: Status Parameters {H17250} <H17200>
+** CAPI3REF: Status Parameters
 ** EXPERIMENTAL
 **
 ** These integer constants designate various run-time status parameters
 ** that can be returned by [sqlite3_status()].
 **
 ** <dl>
-** <dt>SQLITE_STATUS_MEMORY_USED</dt>
+** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>
 ** <dd>This parameter is the current amount of memory checked out
 ** using [sqlite3_malloc()], either directly or indirectly.  The
 ** figure includes calls made to [sqlite3_malloc()] by the application
@@ -5098,45 +4992,45 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache
 ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in
 ** this parameter.  The amount returned is the sum of the allocation
-** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>
+** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^
 **
-** <dt>SQLITE_STATUS_MALLOC_SIZE</dt>
+** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>
 ** <dd>This parameter records the largest memory allocation request
 ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
 ** internal equivalents).  Only the value returned in the
 ** *pHighwater parameter to [sqlite3_status()] is of interest.  
-** The value written into the *pCurrent parameter is undefined.</dd>
+** The value written into the *pCurrent parameter is undefined.</dd>)^
 **
-** <dt>SQLITE_STATUS_PAGECACHE_USED</dt>
+** ^(<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 
 ** [SQLITE_CONFIG_PAGECACHE].  The
-** value returned is in pages, not in bytes.</dd>
+** value returned is in pages, not in bytes.</dd>)^
 **
-** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
+** ^(<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]
 ** 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
 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
-** no space was left in the page cache.</dd>
+** no space was left in the page cache.</dd>)^
 **
-** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
+** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
 ** <dd>This parameter records the largest memory allocation request
 ** handed to [pagecache memory allocator].  Only the value returned in the
 ** *pHighwater parameter to [sqlite3_status()] is of interest.  
-** The value written into the *pCurrent parameter is undefined.</dd>
+** The value written into the *pCurrent parameter is undefined.</dd>)^
 **
-** <dt>SQLITE_STATUS_SCRATCH_USED</dt>
+** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>
 ** <dd>This parameter returns the number of allocations used out of the
 ** [scratch memory allocator] configured using
 ** [SQLITE_CONFIG_SCRATCH].  The value returned is in allocations, not
 ** in bytes.  Since a single thread may only have one scratch allocation
 ** outstanding at time, this parameter also reports the number of threads
-** using scratch memory at the same time.</dd>
+** using scratch memory at the same time.</dd>)^
 **
-** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
+** ^(<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]
 ** buffer and where forced to overflow to [sqlite3_malloc()].  The values
@@ -5144,17 +5038,17 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 ** larger (that is, because the requested allocation was larger than the
 ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer
 ** slots were available.
-** </dd>
+** </dd>)^
 **
-** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
+** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
 ** <dd>This parameter records the largest memory allocation request
 ** handed to [scratch memory allocator].  Only the value returned in the
 ** *pHighwater parameter to [sqlite3_status()] is of interest.  
-** The value written into the *pCurrent parameter is undefined.</dd>
+** The value written into the *pCurrent parameter is undefined.</dd>)^
 **
-** <dt>SQLITE_STATUS_PARSER_STACK</dt>
+** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
 ** <dd>This parameter records the deepest parser stack.  It is only
-** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>
+** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
 ** </dl>
 **
 ** New status parameters may be added from time to time.
@@ -5170,18 +5064,18 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 #define SQLITE_STATUS_SCRATCH_SIZE         8
 
 /*
-** CAPI3REF: Database Connection Status {H17500} <S60200>
+** 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
+** ^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.
 **
-** The current value of the requested parameter is written into *pCur
-** and the highest instantaneous value is written into *pHiwtr.  If
+** ^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.
 **
@@ -5190,7 +5084,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
 
 /*
-** CAPI3REF: Status Parameters for database connections {H17520} <H17500>
+** CAPI3REF: Status Parameters for database connections
 ** EXPERIMENTAL
 **
 ** These constants are the available integer "verbs" that can be passed as
@@ -5203,34 +5097,34 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur
 ** if a discontinued or unsupported verb is invoked.
 **
 ** <dl>
-** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
+** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
 ** <dd>This parameter returns the number of lookaside memory slots currently
-** checked out.</dd>
+** checked out.</dd>)^
 ** </dl>
 */
 #define SQLITE_DBSTATUS_LOOKASIDE_USED     0
 
 
 /*
-** CAPI3REF: Prepared Statement Status {H17550} <S60200>
+** CAPI3REF: Prepared Statement Status
 ** EXPERIMENTAL
 **
-** Each prepared statement maintains various
+** ^(Each prepared statement maintains various
 ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
-** of times it has performed specific operations.  These counters can
+** of times it has performed specific operations.)^  These counters can
 ** be used to monitor the performance characteristics of the prepared
 ** statements.  For example, if the number of table steps greatly exceeds
 ** the number of table searches or result rows, that would tend to indicate
 ** that the prepared statement is using a full table scan rather than
 ** an index.  
 **
-** This interface is used to retrieve and reset counter values from
+** ^(This interface is used to retrieve and reset counter values from
 ** a [prepared statement].  The first argument is the prepared statement
 ** object to be interrogated.  The second argument
 ** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter]
-** to be interrogated. 
-** The current value of the requested counter is returned.
-** If the resetFlg is true, then the counter is reset to zero after this
+** to be interrogated.)^
+** ^The current value of the requested counter is returned.
+** ^If the resetFlg is true, then the counter is reset to zero after this
 ** interface call returns.
 **
 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
@@ -5238,7 +5132,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur
 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
 
 /*
-** CAPI3REF: Status Parameters for prepared statements {H17570} <H17550>
+** CAPI3REF: Status Parameters for prepared statements
 ** EXPERIMENTAL
 **
 ** These preprocessor macros define integer codes that name counter
@@ -5247,13 +5141,13 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int
 **
 ** <dl>
 ** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
-** <dd>This is the number of times that SQLite has stepped forward in
+** <dd>^This is the number of times that SQLite has stepped forward in
 ** a table as part of a full table scan.  Large numbers for this counter
 ** may indicate opportunities for performance improvement through 
 ** careful use of indices.</dd>
 **
 ** <dt>SQLITE_STMTSTATUS_SORT</dt>
-** <dd>This is the number of sort operations that have occurred.
+** <dd>^This is the number of sort operations that have occurred.
 ** A non-zero value in this counter may indicate an opportunity to
 ** improvement performance through careful use of indices.</dd>
 **
@@ -5281,9 +5175,9 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 ** KEYWORDS: {page cache}
 ** EXPERIMENTAL
 **
-** The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
+** ^(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 
+** 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 
@@ -5292,69 +5186,69 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 ** determine exactly which parts of a database file are cached and for 
 ** how long.
 **
-** The contents of the sqlite3_pcache_methods structure are copied to an
+** ^(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.
+** [sqlite3_config()] returns.)^
 **
-** The xInit() method is called once for each call to [sqlite3_initialize()]
-** (usually only once during the lifetime of the process). It is passed
-** a copy of the sqlite3_pcache_methods.pArg value. It can be used to set
-** up global structures and mutexes required by the custom page cache 
-** implementation. 
+** ^The xInit() method is called once for each 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
+** required by the custom page cache implementation. 
 **
-** The xShutdown() method is called from within [sqlite3_shutdown()], 
+** ^The xShutdown() method is called from within [sqlite3_shutdown()], 
 ** if the application invokes this API. It can be used to clean up 
 ** any outstanding resources before process shutdown, if required.
 **
-** SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
-** the xInit method, so the xInit method need not be threadsafe.  The
+** ^SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
+** 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.
 **
-** SQLite will never invoke xInit() more than once without an intervening
+** ^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
+** ^The xCreate() method is used to construct a new cache instance.  SQLite
 ** will typically create one cache instance for each open database file,
-** though this is not guaranteed. The
+** 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
+** 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
+** ^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
+** 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, a cache created with bPurgeable set to false will
 ** never contain any unpinned pages.
 **
-** The xCachesize() method may be called at any time by SQLite to set the
+** ^(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 parameter,
-** the implementation is not required to do anything with this
+** 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
+** ^The xPagecount() method should return the number of pages currently
 ** stored in the cache.
 ** 
-** 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
+** ^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 
 ** 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
+** 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:
 **
@@ -5365,7 +5259,7 @@ 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
@@ -5374,32 +5268,32 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 ** attempting to unpin pages, the xFetch() method will be invoked again with
 ** a createFlag of 2.
 **
-** 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,
+** ^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
+** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is
+** zero, then the page is considered to be unpinned. ^The 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 is not required to 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
+** ^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
-** discarded. Any prior cache entry associated with newKey is guaranteed not
+** 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.
 **
-** The xDestroy() method is used to delete a cache allocated by xCreate().
-** All resources associated with the specified cache should be freed. After
+** ^The xDestroy() method is used to delete a cache allocated by xCreate().
+** All resources associated with the specified cache should be freed. ^After
 ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
 ** handle invalid, and will not use it with any other sqlite3_pcache_methods
 ** functions.
@@ -5424,7 +5318,7 @@ struct sqlite3_pcache_methods {
 ** EXPERIMENTAL
 **
 ** The sqlite3_backup object records state information about an ongoing
-** online backup operation.  The sqlite3_backup object is created by
+** online backup operation.  ^The sqlite3_backup object is created by
 ** a call to [sqlite3_backup_init()] and is destroyed by a call to
 ** [sqlite3_backup_finish()].
 **
@@ -5436,20 +5330,20 @@ typedef struct sqlite3_backup sqlite3_backup;
 ** CAPI3REF: Online Backup API.
 ** EXPERIMENTAL
 **
-** This API is used to overwrite the contents of one database with that
-** of another. It is useful either for creating backups of databases or
+** The backup API copies the content of one database into another.
+** It is useful either for creating backups of databases or
 ** for copying in-memory databases to or from persistent files. 
 **
 ** See Also: [Using the SQLite Online Backup API]
 **
-** Exclusive access is required to the destination database for the 
-** duration of the operation. However the source database is only
-** read-locked while it is actually being read, it is not locked
-** continuously for the entire operation. Thus, the backup may be
-** performed on a live database without preventing other users from
-** writing to the database for an extended period of time.
+** ^Exclusive access is required to the destination database for the 
+** duration of the operation. ^However the source database is only
+** read-locked while it is actually being read; it is not locked
+** continuously for the entire backup operation. ^Thus, the backup may be
+** performed on a live source database without preventing other users from
+** reading or writing to the source database while the backup is underway.
 ** 
-** To perform a backup operation: 
+** ^(To perform a backup operation: 
 **   <ol>
 **     <li><b>sqlite3_backup_init()</b> is called once to initialize the
 **         backup, 
@@ -5457,143 +5351,148 @@ typedef struct sqlite3_backup sqlite3_backup;
 **         the data between the two databases, and finally
 **     <li><b>sqlite3_backup_finish()</b> is called to release all resources 
 **         associated with the backup operation. 
-**   </ol>
+**   </ol>)^
 ** There should be exactly one call to sqlite3_backup_finish() for each
 ** successful call to sqlite3_backup_init().
 **
 ** <b>sqlite3_backup_init()</b>
 **
-** The first two arguments passed to [sqlite3_backup_init()] are the database
-** handle associated with the destination database and the database name 
-** used to attach the destination database to the handle. The database name
-** is "main" for the main database, "temp" for the temporary database, or
-** the name specified as part of the [ATTACH] statement if the destination is
-** an attached database. The third and fourth arguments passed to 
-** sqlite3_backup_init() identify the [database connection]
-** and database name used
-** to access the source database. The values passed for the source and 
-** destination [database connection] parameters must not be the same.
-**
-** If an error occurs within sqlite3_backup_init(), then NULL is returned
-** and an error code and error message written into the [database connection] 
-** passed as the first argument. They may be retrieved using the
-** [sqlite3_errcode()], [sqlite3_errmsg()], and [sqlite3_errmsg16()] functions.
-** Otherwise, if successful, a pointer to an [sqlite3_backup] object is
-** returned. This pointer may be used with the sqlite3_backup_step() and
+** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the 
+** [database connection] associated with the destination database 
+** and the database name, respectively.
+** ^The database name is "main" for the main database, "temp" for the
+** temporary database, or the name specified after the AS keyword in
+** an [ATTACH] statement for an attached database.
+** ^The S and M arguments passed to 
+** sqlite3_backup_init(D,N,S,M) identify the [database connection]
+** and database name of the source database, respectively.
+** ^The source and destination [database connections] (parameters S and D)
+** must be different or else sqlite3_backup_init(D,N,S,M) will file with
+** an error.
+**
+** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
+** returned and an error code and error message are store3d in the
+** destination [database connection] D.
+** ^The error code and message for the failed call to sqlite3_backup_init()
+** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or
+** [sqlite3_errmsg16()] functions.
+** ^A successful call to sqlite3_backup_init() returns a pointer to an
+** [sqlite3_backup] object.
+** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and
 ** sqlite3_backup_finish() functions to perform the specified backup 
 ** operation.
 **
 ** <b>sqlite3_backup_step()</b>
 **
-** Function [sqlite3_backup_step()] is used to copy up to nPage pages between 
-** the source and destination databases, where nPage is the value of the 
-** second parameter passed to sqlite3_backup_step(). If nPage is a negative
-** value, all remaining source pages are copied. If the required pages are 
-** succesfully copied, but there are still more pages to copy before the 
-** backup is complete, it returns [SQLITE_OK]. If no error occured and there 
-** are no more pages to copy, then [SQLITE_DONE] is returned. If an error 
-** occurs, then an SQLite error code is returned. As well as [SQLITE_OK] and
+** ^Function sqlite3_backup_step(B,N) will copy up to N pages between 
+** the source and destination databases specified by [sqlite3_backup] object B.
+** ^If N is negative, all remaining source pages are copied. 
+** ^If sqlite3_backup_step(B,N) successfully copies N pages and there
+** are still more pages to be copied, then the function resturns [SQLITE_OK].
+** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages
+** from source to destination, then it returns [SQLITE_DONE].
+** ^If an error occurs while running sqlite3_backup_step(B,N),
+** then an [error code] is returned. ^As well as [SQLITE_OK] and
 ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],
 ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
 **
-** As well as the case where the destination database file was opened for
-** read-only access, sqlite3_backup_step() may return [SQLITE_READONLY] if
+** ^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.
 **
-** If sqlite3_backup_step() cannot obtain a required file-system lock, then
+** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
 ** the [sqlite3_busy_handler | busy-handler function]
-** is invoked (if one is specified). If the 
+** is invoked (if one is specified). ^If the 
 ** busy-handler returns non-zero before the lock is available, then 
-** [SQLITE_BUSY] is returned to the caller. In this case the call to
-** sqlite3_backup_step() can be retried later. If the source
+** [SQLITE_BUSY] is returned to the caller. ^In this case the call to
+** sqlite3_backup_step() can be retried later. ^If the source
 ** [database connection]
 ** is being used to write to the source database when sqlite3_backup_step()
-** is called, then [SQLITE_LOCKED] is returned immediately. Again, in this
-** case the call to sqlite3_backup_step() can be retried later on. If
+** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this
+** case the call to sqlite3_backup_step() can be retried later on. ^(If
 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
 ** [SQLITE_READONLY] is returned, then 
 ** there is no point in retrying the call to sqlite3_backup_step(). These 
-** errors are considered fatal. At this point the application must accept 
+** errors are considered fatal.)^  The application must accept 
 ** that the backup operation has failed and pass the backup operation handle 
 ** to the sqlite3_backup_finish() to release associated resources.
 **
-** Following the first call to sqlite3_backup_step(), an exclusive lock is
-** obtained on the destination file. It is not released until either 
+** ^The first call to sqlite3_backup_step() obtains an exclusive lock
+** on the destination file. ^The exclusive lock is not released until either 
 ** sqlite3_backup_finish() is called or the backup operation is complete 
-** and sqlite3_backup_step() returns [SQLITE_DONE]. Additionally, each time 
-** a call to sqlite3_backup_step() is made a [shared lock] is obtained on
-** the source database file. This lock is released before the
-** sqlite3_backup_step() call returns. Because the source database is not
-** locked between calls to sqlite3_backup_step(), it may be modified mid-way
-** through the backup procedure. If the source database is modified by an
+** and sqlite3_backup_step() returns [SQLITE_DONE].  ^Every call to
+** sqlite3_backup_step() obtains a [shared lock] on the source database that
+** lasts for the duration of the sqlite3_backup_step() call.
+** ^Because the source database is not locked between calls to
+** sqlite3_backup_step(), the source database may be modified mid-way
+** through the backup process.  ^If the source database is modified by an
 ** external process or via a database connection other than the one being
-** used by the backup operation, then the backup will be transparently
-** restarted by the next call to sqlite3_backup_step(). If the source 
+** used by the backup operation, then the backup will be automatically
+** restarted by the next call to sqlite3_backup_step(). ^If the source 
 ** database is modified by the using the same database connection as is used
-** by the backup operation, then the backup database is transparently 
+** by the backup operation, then the backup database is automatically
 ** updated at the same time.
 **
 ** <b>sqlite3_backup_finish()</b>
 **
-** Once sqlite3_backup_step() has returned [SQLITE_DONE], or when the 
-** application wishes to abandon the backup operation, the [sqlite3_backup]
-** object should be passed to sqlite3_backup_finish(). This releases all
-** resources associated with the backup operation. If sqlite3_backup_step()
-** has not yet returned [SQLITE_DONE], then any active write-transaction on the
-** destination database is rolled back. The [sqlite3_backup] object is invalid
+** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the 
+** application wishes to abandon the backup operation, the application
+** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().
+** ^The sqlite3_backup_finish() interfaces releases all
+** resources associated with the [sqlite3_backup] object. 
+** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any
+** active write-transaction on the destination database is rolled back.
+** The [sqlite3_backup] object is invalid
 ** and may not be used following a call to sqlite3_backup_finish().
 **
-** The value returned by sqlite3_backup_finish is [SQLITE_OK] if no error
-** occurred, regardless or whether or not sqlite3_backup_step() was called
-** a sufficient number of times to complete the backup operation. Or, if
-** an out-of-memory condition or IO error occured during a call to
-** sqlite3_backup_step() then [SQLITE_NOMEM] or an
-** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] error code
-** is returned. In this case the error code and an error message are
-** written to the destination [database connection].
-**
-** A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() is
-** not a permanent error and does not affect the return value of
+** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no
+** sqlite3_backup_step() errors occurred, regardless or whether or not
+** sqlite3_backup_step() completed.
+** ^If an out-of-memory condition or IO error occurred during any prior
+** sqlite3_backup_step() call on the same [sqlite3_backup] object, then
+** sqlite3_backup_finish() returns the corresponding [error code].
+**
+** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
+** is not a permanent error and does not affect the return value of
 ** sqlite3_backup_finish().
 **
 ** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
 **
-** Each call to sqlite3_backup_step() sets two values stored internally
-** by an [sqlite3_backup] object. The number of pages still to be backed
-** up, which may be queried by sqlite3_backup_remaining(), and the total
-** number of pages in the source database file, which may be queried by
-** sqlite3_backup_pagecount().
+** ^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.
+** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
+** retrieve these two values, respectively.
 **
-** The values returned by these functions are only updated by
-** sqlite3_backup_step(). If the source database is modified during a backup
+** ^The values returned by these functions are only updated by
+** sqlite3_backup_step(). ^If the source database is modified during a backup
 ** operation, then the values are not updated to account for any extra
 ** pages that need to be updated or the size of the source database file
 ** changing.
 **
 ** <b>Concurrent Usage of Database Handles</b>
 **
-** The source [database connection] may be used by the application for other
+** ^The source [database connection] may be used by the application for other
 ** purposes while a backup operation is underway or being initialized.
-** If SQLite is compiled and configured to support threadsafe database
+** ^If SQLite is compiled and configured to support threadsafe database
 ** connections, then the source database connection may be used concurrently
 ** from within other threads.
 **
-** However, the application must guarantee that the destination database
-** connection handle is not passed to any other API (by any thread) after 
+** However, the application must guarantee that the destination 
+** [database connection] is not passed to any other API (by any thread) after 
 ** sqlite3_backup_init() is called and before the corresponding call to
-** sqlite3_backup_finish(). Unfortunately SQLite does not currently check
-** for this, if the application does use the destination [database connection]
-** for some other purpose during a backup operation, things may appear to
-** work correctly but in fact be subtly malfunctioning.  Use of the
-** destination database connection while a backup is in progress might
-** also cause a mutex deadlock.
-**
-** Furthermore, if running in [shared cache mode], the application must
+** sqlite3_backup_finish().  SQLite does not currently check to see
+** if the application incorrectly accesses the destination [database connection]
+** and so no error code is reported, but the operations may malfunction
+** nevertheless.  Use of the destination database connection while a
+** backup is in progress might also also cause a mutex deadlock.
+**
+** If running in [shared cache mode], the application must
 ** guarantee that the shared cache used by the destination database
 ** is not accessed while the backup is running. In practice this means
-** that the application must guarantee that the file-system file being 
+** that the application must guarantee that the disk file being 
 ** backed up to is not accessed by any connection within the process,
 ** not just the specific connection that was passed to sqlite3_backup_init().
 **
@@ -5619,48 +5518,48 @@ 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
+** ^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
 ** individual tables within the shared-cache cannot be obtained. See
 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. 
-** This API may be used to register a callback that SQLite will invoke 
+** ^This API may be used to register a callback that SQLite will invoke 
 ** when the connection currently holding the required lock relinquishes it.
-** This API is only available if the library was compiled with the
+** ^This API is only available if the library was compiled with the
 ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
 **
 ** See Also: [Using the SQLite Unlock Notification Feature].
 **
-** Shared-cache locks are released when a database connection concludes
+** ^Shared-cache locks are released when a database connection concludes
 ** its current transaction, either by committing it or rolling it back. 
 **
-** When a connection (known as the blocked connection) fails to obtain a
+** ^When a connection (known as the blocked connection) fails to obtain a
 ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
 ** identity of the database connection (the blocking connection) that
-** has locked the required resource is stored internally. After an 
+** has locked the required resource is stored internally. ^After an 
 ** application receives an SQLITE_LOCKED error, it may call the
 ** sqlite3_unlock_notify() method with the blocked connection handle as 
 ** the first argument to register for a callback that will be invoked
-** when the blocking connections current transaction is concluded. The
+** when the blocking connections current transaction is concluded. ^The
 ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
 ** call that concludes the blocking connections transaction.
 **
-** If sqlite3_unlock_notify() is called in a multi-threaded application,
+** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
 ** there is a chance that the blocking connection will have already
 ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
 ** If this happens, then the specified callback is invoked immediately,
-** from within the call to sqlite3_unlock_notify().
+** from within the call to sqlite3_unlock_notify().)^
 **
-** If the blocked connection is attempting to obtain a write-lock on a
+** ^If the blocked connection is attempting to obtain a write-lock on a
 ** shared-cache table, and more than one other connection currently holds
 ** a read-lock on the same table, then SQLite arbitrarily selects one of 
 ** the other connections to use as the blocking connection.
 **
-** There may be at most one unlock-notify callback registered by a 
+** ^(There may be at most one unlock-notify callback registered by a 
 ** blocked connection. If sqlite3_unlock_notify() is called when the
 ** blocked connection already has a registered unlock-notify callback,
-** then the new callback replaces the old. If sqlite3_unlock_notify() is
+** 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 cancelled. ^The blocked connections 
 ** unlock-notify callback may also be canceled by closing the blocked
 ** connection using [sqlite3_close()].
 **
@@ -5668,7 +5567,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 ** any sqlite3_xxx API functions from within an unlock-notify callback, a
 ** crash or deadlock may be the result.
 **
-** Unless deadlock is detected (see below), sqlite3_unlock_notify() always
+** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always
 ** returns SQLITE_OK.
 **
 ** <b>Callback Invocation Details</b>
@@ -5682,7 +5581,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 **
 ** When a blocking connections transaction is concluded, there may be
 ** more than one blocked connection that has registered for an unlock-notify
-** callback. If two or more such blocked connections have specified the
+** callback. ^If two or more such blocked connections have specified the
 ** same callback function, then instead of invoking the callback function
 ** multiple times, it is invoked once with the set of void* context pointers
 ** specified by the blocked connections bundled together into an array.
@@ -5700,16 +5599,16 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 ** will proceed and the system may remain deadlocked indefinitely.
 **
 ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
-** detection. If a given call to sqlite3_unlock_notify() would put the
+** detection. ^If a given call to sqlite3_unlock_notify() would put the
 ** system in a deadlocked state, then SQLITE_LOCKED is returned and no
 ** unlock-notify callback is registered. The system is said to be in
 ** a deadlocked state if connection A has registered for an unlock-notify
 ** callback on the conclusion of connection B's transaction, and connection
 ** B has itself registered for an unlock-notify callback when connection
-** A's transaction is concluded. Indirect deadlock is also detected, so
+** A's transaction is concluded. ^Indirect deadlock is also detected, so
 ** the system is also considered to be deadlocked if connection B has
 ** registered for an unlock-notify callback on the conclusion of connection
-** C's transaction, where connection C is waiting on connection A. Any
+** C's transaction, where connection C is waiting on connection A. ^Any
 ** number of levels of indirection are allowed.
 **
 ** <b>The "DROP TABLE" Exception</b>
@@ -5725,10 +5624,10 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 ** or "DROP INDEX" query, an infinite loop might be the result.
 **
 ** One way around this problem is to check the extended error code returned
-** by an sqlite3_step() call. If there is a blocking connection, then the
+** by an sqlite3_step() call. ^(If there is a blocking connection, then the
 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
 ** the special "DROP TABLE/INDEX" case, the extended error code is just 
-** SQLITE_LOCKED.
+** SQLITE_LOCKED.)^
 */
 SQLITE_API int sqlite3_unlock_notify(
   sqlite3 *pBlocked,                          /* Waiting connection */
@@ -5741,7 +5640,7 @@ SQLITE_API int sqlite3_unlock_notify(
 ** CAPI3REF: String Comparison
 ** EXPERIMENTAL
 **
-** The [sqlite3_strnicmp()] API allows applications and extensions to
+** ^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 
 ** that SQLite uses internally when comparing identifiers.
diff --git a/ext/sqlite3/libsqlite/sqlite3ext.h b/ext/sqlite3/libsqlite/sqlite3ext.h
index 102aaea..0d37bbe 100644
--- a/ext/sqlite3/libsqlite/sqlite3ext.h
+++ b/ext/sqlite3/libsqlite/sqlite3ext.h
@@ -14,8 +14,6 @@
 ** an SQLite instance.  Shared libraries that intend to be loaded
 ** as extensions by SQLite should #include this file instead of 
 ** sqlite3.h.
-**
-** @(#) $Id: sqlite3ext.h 283115 2009-06-30 11:17:14Z scottmac $
 */
 #ifndef _SQLITE3EXT_H_
 #define _SQLITE3EXT_H_
diff --git a/ext/sqlite3/php_sqlite3.h b/ext/sqlite3/php_sqlite3.h
index 48f2afd..ea81809 100644
--- a/ext/sqlite3/php_sqlite3.h
+++ b/ext/sqlite3/php_sqlite3.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_sqlite3.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_sqlite3.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SQLITE3_H
 #define PHP_SQLITE3_H
diff --git a/ext/sqlite3/php_sqlite3_structs.h b/ext/sqlite3/php_sqlite3_structs.h
index 866871e..3488361 100644
--- a/ext/sqlite3/php_sqlite3_structs.h
+++ b/ext/sqlite3/php_sqlite3_structs.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_sqlite3_structs.h 279456 2009-04-27 18:16:46Z scottmac $ */
+/* $Id: php_sqlite3_structs.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SQLITE_STRUCTS_H
 #define PHP_SQLITE_STRUCTS_H
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 70fab57..372ecda 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: sqlite3.c 281793 2009-06-08 02:15:54Z scottmac $ */
+/* $Id: sqlite3.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -851,9 +851,7 @@ PHP_METHOD(sqlite3, createFunction)
 		func->func_name = estrdup(sql_func);
 
 		MAKE_STD_ZVAL(func->func);
-		*(func->func) = *callback_func;
-		zval_copy_ctor(func->func);
-		INIT_PZVAL(func->func);
+		MAKE_COPY_ZVAL(&callback_func, func->func);
 
 		func->argc = sql_func_num_args;
 		func->next = db_obj->funcs;
@@ -910,14 +908,10 @@ PHP_METHOD(sqlite3, createAggregate)
 		func->func_name = estrdup(sql_func);
 
 		MAKE_STD_ZVAL(func->step);
-		*(func->step) = *step_callback;
-		zval_copy_ctor(func->step);
-		INIT_PZVAL(func->step);
+		MAKE_COPY_ZVAL(&step_callback, func->step);
 
 		MAKE_STD_ZVAL(func->fini);
-		*(func->fini) = *fini_callback;
-		zval_copy_ctor(func->fini);
-		INIT_PZVAL(func->fini);
+		MAKE_COPY_ZVAL(&fini_callback, func->fini);
 
 		func->argc = sql_func_num_args;
 		func->next = db_obj->funcs;
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 457f8b1..e4156e8 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: array.c 287275 2009-08-14 06:20:21Z dmitry $ */
+/* $Id: array.c 293982 2010-01-25 14:11:32Z johannes $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -768,6 +768,7 @@ static int php_array_user_key_compare(const void *a, const void *b TSRMLS_DC) /*
 PHP_FUNCTION(uksort)
 {
 	zval *array;
+	int refcount;
 	PHP_ARRAY_CMP_FUNC_VARS;
 
 	PHP_ARRAY_CMP_FUNC_BACKUP();
@@ -777,13 +778,31 @@ PHP_FUNCTION(uksort)
 		return;
 	}
 
+	/* Clear the is_ref flag, so the attemts to modify the array in user
+	 * comaprison function will create a copy of array and won't affect the
+	 * original array. The fact of modification is detected using refcount
+	 * comparison. The result of sorting in such case is undefined and the
+	 * function returns FALSE.
+	 */
+	Z_UNSET_ISREF_P(array);
+	refcount = Z_REFCOUNT_P(array);
+
 	if (zend_hash_sort(Z_ARRVAL_P(array), zend_qsort, php_array_user_key_compare, 0 TSRMLS_CC) == FAILURE) {
-		PHP_ARRAY_CMP_FUNC_RESTORE();
-		RETURN_FALSE;
+		RETVAL_FALSE;
+	} else {
+		if (refcount > Z_REFCOUNT_P(array)) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array was modified by the user comparison function");
+			RETVAL_FALSE;
+		} else {
+			RETVAL_TRUE;
+		}
+	}
+
+	if (Z_REFCOUNT_P(array) > 1) {
+		Z_SET_ISREF_P(array);
 	}
 
 	PHP_ARRAY_CMP_FUNC_RESTORE();
-	RETURN_TRUE;
 }
 /* }}} */
 
@@ -1364,6 +1383,9 @@ PHP_FUNCTION(extract)
 				if (var_exists && var_name_len == sizeof("GLOBALS") && !strcmp(var_name, "GLOBALS")) {
 					break;
 				}
+				if (var_exists && var_name_len == sizeof("this")  && !strcmp(var_name, "this") && EG(scope) && EG(scope)->name_length != 0) {
+					break;
+				}
 				ZVAL_STRINGL(&final_name, var_name, var_name_len, 1);
 				break;
 
@@ -1445,9 +1467,7 @@ static void php_compact_var(HashTable *eg_active_symbol_table, zval *return_valu
 		if (zend_hash_find(eg_active_symbol_table, Z_STRVAL_P(entry), Z_STRLEN_P(entry) + 1, (void **)&value_ptr) != FAILURE) {
 			value = *value_ptr;
 			ALLOC_ZVAL(data);
-			*data = *value;
-			zval_copy_ctor(data);
-			INIT_PZVAL(data);
+			MAKE_COPY_ZVAL(&value, data);
 
 			zend_hash_update(Z_ARRVAL_P(return_value), Z_STRVAL_P(entry), Z_STRLEN_P(entry) + 1, &data, sizeof(zval *), NULL);
 		}
@@ -4070,9 +4090,7 @@ PHP_FUNCTION(array_reduce)
 
 	if (ZEND_NUM_ARGS() > 2) {
 		ALLOC_ZVAL(result);
-		*result = *initial;
-		zval_copy_ctor(result);
-		INIT_PZVAL(result);
+		MAKE_COPY_ZVAL(&initial, result);
 	} else {
 		MAKE_STD_ZVAL(result);
 		ZVAL_NULL(result);
diff --git a/ext/standard/assert.c b/ext/standard/assert.c
index af5ffff..1730e41 100644
--- a/ext/standard/assert.c
+++ b/ext/standard/assert.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: assert.c 284153 2009-07-15 23:55:50Z stas $ */
+/* $Id: assert.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* {{{ includes */
 #include "php.h"
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index 42f5c53..dff9055 100644
--- a/ext/standard/base64.c
+++ b/ext/standard/base64.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Jim Winstead <jimw at php.net>                                  |
    +----------------------------------------------------------------------+
  */
-/* $Id: base64.c 274569 2009-01-25 18:27:12Z iliaa $ */
+/* $Id: base64.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <string.h>
 
diff --git a/ext/standard/base64.h b/ext/standard/base64.h
index 4f43dbb..8976095 100644
--- a/ext/standard/base64.h
+++ b/ext/standard/base64.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: base64.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: base64.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef BASE64_H
 #define BASE64_H
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index f7b394a..cd722db 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c 289669 2009-10-15 14:10:03Z pajoye $ */
+/* $Id: basic_functions.c 294503 2010-02-04 09:08:57Z pajoye $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -1301,6 +1301,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_clearstatcache, 0, 0, 0)
 	ZEND_ARG_INFO(0, filename)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO(arginfo_realpath_cache_size, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_realpath_cache_get, 0)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO(arginfo_fileperms, 0)
 	ZEND_ARG_INFO(0, filename)
 ZEND_END_ARG_INFO()
@@ -2004,6 +2010,10 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_INFO(arginfo_stream_get_wrappers, 0)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO(arginfo_stream_resolve_include_path, 0)
+	ZEND_ARG_INFO(0, filename)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO(arginfo_stream_is_local, 0)
 	ZEND_ARG_INFO(0, stream)
 ZEND_END_ARG_INFO()
@@ -3109,6 +3119,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */
 	PHP_FE(stream_wrapper_restore,											arginfo_stream_wrapper_restore)
 	PHP_FE(stream_get_wrappers,												arginfo_stream_get_wrappers)
 	PHP_FE(stream_get_transports,											arginfo_stream_get_transports)
+	PHP_FE(stream_resolve_include_path,										arginfo_stream_resolve_include_path)
 	PHP_FE(stream_is_local,												arginfo_stream_is_local)
 	PHP_FE(get_headers,														arginfo_get_headers)
 
@@ -3198,6 +3209,8 @@ const zend_function_entry basic_functions[] = { /* {{{ */
 	PHP_FE(disk_total_space,												arginfo_disk_total_space)
 	PHP_FE(disk_free_space,													arginfo_disk_free_space)
 	PHP_FALIAS(diskfreespace,		disk_free_space,						arginfo_disk_free_space)
+	PHP_FE(realpath_cache_size,												arginfo_realpath_cache_size)
+	PHP_FE(realpath_cache_get,												arginfo_realpath_cache_get)
 
 	/* functions from mail.c */
 	PHP_FE(mail,															arginfo_mail)
@@ -4043,7 +4056,7 @@ PHP_FUNCTION(putenv)
 		pe.key_len = strlen(pe.key);
 #ifdef PHP_WIN32
 		if (equals) {
-			if (pe.key_len < setting_len - 2) {
+			if (pe.key_len < setting_len - 1) {
 				value = p + 1;
 			} else {
 				/* empty string*/
@@ -4652,7 +4665,7 @@ PHP_FUNCTION(error_log)
 		opt_err = erropt;
 	}
 
-	if (_php_error_log(opt_err, message, opt, headers TSRMLS_CC) == FAILURE) {
+	if (_php_error_log_ex(opt_err, message, message_len, opt, headers TSRMLS_CC) == FAILURE) {
 		RETURN_FALSE;
 	}
 
@@ -4660,17 +4673,22 @@ PHP_FUNCTION(error_log)
 }
 /* }}} */
 
+/* For BC (not binary-safe!) */
 PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers TSRMLS_DC) /* {{{ */
 {
-	php_stream *stream = NULL;
+	return _php_error_log_ex(opt_err, message, (opt_err == 3) ? strlen(message) : 0, opt, headers TSRMLS_CC);
+}
+/* }}} */
 
-	switch (opt_err) {
+PHPAPI int _php_error_log_ex(int opt_err, char *message, int message_len, char *opt, char *headers TSRMLS_DC) /* {{{ */
+{
+	php_stream *stream = NULL;
 
+	switch (opt_err)
+	{
 		case 1:		/*send an email */
-			{
-				if (!php_mail(opt, "PHP error_log message", message, headers, NULL TSRMLS_CC)) {
-					return FAILURE;
-				}
+			if (!php_mail(opt, "PHP error_log message", message, headers, NULL TSRMLS_CC)) {
+				return FAILURE;
 			}
 			break;
 
@@ -4681,11 +4699,13 @@ PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers T
 
 		case 3:		/*save to a file */
 			stream = php_stream_open_wrapper(opt, "a", IGNORE_URL_WIN | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
-			if (!stream)
+			if (!stream) {
 				return FAILURE;
-			php_stream_write(stream, message, strlen(message));
+			}
+			php_stream_write(stream, message, message_len);
 			php_stream_close(stream);
 			break;
+
 		case 4: /* send to SAPI */
 			if (sapi_module.log_message) {
 				sapi_module.log_message(message);
@@ -4693,6 +4713,7 @@ PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers T
 				return FAILURE;
 			}
 			break;
+
 		default:
 			php_log_err(message TSRMLS_CC);
 			break;
@@ -5561,6 +5582,15 @@ PHP_FUNCTION(getservbyname)
 		return;
 	}
 
+
+/* empty string behaves like NULL on windows implementation of 
+   getservbyname. Let be portable instead. */
+#ifdef PHP_WIN32
+	if (proto_len == 0) {
+		RETURN_FALSE;
+	}
+#endif
+
 	serv = getservbyname(name, proto);
 
 	if (serv == NULL) {
@@ -5821,9 +5851,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
 				break;
 			}
 			ALLOC_ZVAL(element);
-			*element = *arg2;
-			zval_copy_ctor(element);
-			INIT_PZVAL(element);
+			MAKE_COPY_ZVAL(&arg2, element);
 			zend_symtable_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, &element, sizeof(zval *), NULL);
 			break;
 
@@ -5866,9 +5894,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
 			}
 
 			ALLOC_ZVAL(element);
-			*element = *arg2;
-			zval_copy_ctor(element);
-			INIT_PZVAL(element);
+			MAKE_COPY_ZVAL(&arg2, element);
 
 			if (arg3 && Z_STRLEN_P(arg3) > 0) {
 				add_assoc_zval_ex(hash, Z_STRVAL_P(arg3), Z_STRLEN_P(arg3) + 1, element);
diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h
index bc18f07..acd17e5 100644
--- a/ext/standard/basic_functions.h
+++ b/ext/standard/basic_functions.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: basic_functions.h 286378 2009-07-26 22:59:46Z jani $ */
+/* $Id: basic_functions.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef BASIC_FUNCTIONS_H
 #define BASIC_FUNCTIONS_H
@@ -141,7 +141,9 @@ PHP_FUNCTION(stream_bucket_new);
 PHP_MINIT_FUNCTION(user_filters);
 PHP_RSHUTDOWN_FUNCTION(user_filters);
 
+/* Left for BC (not binary safe!) */
 PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers TSRMLS_DC);
+PHPAPI int _php_error_log_ex(int opt_err, char *message, int message_len, char *opt, char *headers TSRMLS_DC);
 PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, int var_name_len, zend_bool add_underscore TSRMLS_DC);
 
 #if SIZEOF_INT == 4
diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c
index c0b2029..9106727 100644
--- a/ext/standard/browscap.c
+++ b/ext/standard/browscap.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: browscap.c 281742 2009-06-06 02:40:49Z mattwil $ */
+/* $Id: browscap.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_browscap.h"
@@ -328,7 +328,7 @@ PHP_FUNCTION(get_browser)
 	char *agent_name = NULL;
 	int agent_name_len = 0;
 	zend_bool return_array = 0;
-	zval **agent, **z_agent_name;
+	zval **agent, **z_agent_name, **http_user_agent;
 	zval *found_browser_entry, *tmp_copy;
 	char *lookup_browser_name;
 	char *browscap = INI_STR("browscap");
@@ -344,11 +344,14 @@ PHP_FUNCTION(get_browser)
 
 	if (agent_name == NULL) {
 		zend_is_auto_global("_SERVER", sizeof("_SERVER") - 1 TSRMLS_CC);
-		if (!PG(http_globals)[TRACK_VARS_SERVER]
-			|| zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &agent_name) == FAILURE) {
+		if (!PG(http_globals)[TRACK_VARS_SERVER] ||
+			zend_hash_find(HASH_OF(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &http_user_agent) == FAILURE
+		) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "HTTP_USER_AGENT variable is not set, cannot determine user agent name");
 			RETURN_FALSE;
 		}
+		agent_name = Z_STRVAL_PP(http_user_agent);
+		agent_name_len = Z_STRLEN_PP(http_user_agent);
 	}
 
 	lookup_browser_name = estrndup(agent_name, agent_name_len);
diff --git a/ext/standard/config.m4 b/ext/standard/config.m4
index 7ccec31..98912a1 100644
--- a/ext/standard/config.m4
+++ b/ext/standard/config.m4
@@ -1,4 +1,4 @@
-dnl $Id: config.m4 287120 2009-08-11 22:07:35Z scottmac $ -*- autoconf -*-
+dnl $Id: config.m4 295350 2010-02-22 00:34:22Z pajoye $ -*- autoconf -*-
 
 divert(3)dnl
 
@@ -172,17 +172,112 @@ main() {
   ac_cv_crypt_blowfish=no
 ])])
 
+AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_SHA512,[
+AC_TRY_RUN([
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
+main() {
+#if HAVE_CRYPT
+    char salt[30], answer[80];
+    
+    salt[0]='$'; salt[1]='6'; salt[2]='$'; salt[3]='$'; salt[4]='b'; salt[5]='a'; salt[6]='r'; salt[7]='\0';
+    strcpy(answer, salt);
+    strcpy(&answer[29],"$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.");
+    exit (strcmp((char *)crypt("foo",salt),answer));
+#else
+	exit(0);
+#endif
+}],[
+  ac_cv_crypt_SHA512=yes
+],[
+  ac_cv_crypt_SHA512=no
+],[
+  ac_cv_crypt_SHA512=no
+])])
+
+AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_SHA256,[
+AC_TRY_RUN([
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
+main() {
+#if HAVE_CRYPT
+    char salt[30], answer[80];
+    salt[0]='$'; salt[1]='5'; salt[2]='$'; salt[3]='$'; salt[4]='s'; salt[5]='a'; salt[6]='l'; salt[7]='t';  salt[8]='s'; salt[9]='t'; salt[10]='r'; salt[11]='i'; salt[12]='n'; salt[13]='g'; salt[14]='\0';    
+    strcat(salt,"");
+    strcpy(answer, salt);
+    strcpy(&answer[29], "$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5");
+    exit (strcmp((char *)crypt("foo",salt),answer));
+#else
+	exit(0);
+#endif
+}],[
+  ac_cv_crypt_SHA256=yes
+],[
+  ac_cv_crypt_SHA256=no
+],[
+  ac_cv_crypt_SHA256=no
+])])
+
+
 dnl
 dnl If one of them is missing, use our own implementation, portable code is then possible
 dnl
 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
+
+  dnl
+  dnl Check for __alignof__ support in the compiler
+  dnl
+  AC_CACHE_CHECK(whether the compiler supports __alignof__, ac_cv_alignof_exists,[
+  AC_TRY_COMPILE([
+  ],[
+    int align = __alignof__(int);
+  ],[
+    ac_cv_alignof_exists=yes
+  ],[
+    ac_cv_alignof_exists=no
+  ])])
+  if test "$ac_cv_alignof_exists" = "yes"; then
+    AC_DEFINE([HAVE_ALIGNOF], 1, [whether the compiler supports __alignof__])
+  fi
+
+  dnl 
+  dnl Check for __attribute__ ((__aligned__)) support in the compiler
+  dnl
+  AC_CACHE_CHECK(whether the compiler supports aligned attribute, ac_cv_attribute_aligned,[
+  AC_TRY_COMPILE([
+  ],[
+    unsigned char test[32] __attribute__ ((__aligned__ (__alignof__ (int))));
+  ],[
+    ac_cv_attribute_aligned=yes
+  ],[
+    ac_cv_attribute_aligned=no
+  ])])
+  if test "$ac_cv_attribute_aligned" = "yes"; then
+    AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1, [whether the compiler supports __attribute__ ((__aligned__))])
+  fi
+    
+
   AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 1, [Whether PHP has to use its own crypt_r for blowfish, des, ext des and md5])
   AC_DEFINE_UNQUOTED(PHP_STD_DES_CRYPT, 1, [Whether the system supports standard DES salt])
   AC_DEFINE_UNQUOTED(PHP_BLOWFISH_CRYPT, 1, [Whether the system supports BlowFish salt])
   AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, 1, [Whether the system supports extended DES salt])
-  AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, 1, [Whether the system supports extended DES salt])
+  AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, 1, [Whether the system supports MD5 salt])
+  AC_DEFINE_UNQUOTED(PHP_SHA512_CRYPT, 1, [Whether the system supports SHA512 salt])
+  AC_DEFINE_UNQUOTED(PHP_SHA256_CRYPT, 1, [Whether the system supports SHA256 salt])
 
-  PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c php_crypt_r.c)
+  PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c)
 else
   if test "$ac_cv_crypt_des" = "yes"; then
     ac_result=1
@@ -211,13 +306,31 @@ else
   fi
   AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, $ac_result, [Whether the system supports extended DES salt])
 
+  if test "$ac_cv_crypt_sha512" = "yes"; then
+    ac_result=1
+    ac_crypt_sha512=1
+  else
+    ac_result=0
+    ac_crypt_sha512=0
+  fi
+  AC_DEFINE_UNQUOTED(PHP_EXT_SHA512_CRYPT, $ac_result, [Whether the system supports SHA512 salt])
+
+  if test "$ac_cv_crypt_sha256" = "yes"; then
+    ac_result=1
+    ac_crypt_sha256=1
+  else
+    ac_result=0
+    ac_crypt_sha256=0
+  fi
+  AC_DEFINE_UNQUOTED(PHP_EXT_SHA256_CRYPT, $ac_result, [Whether the system supports SHA256 salt])
+
   AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 0, [Whether PHP has to use its own crypt_r for blowfish, des and ext des])
 fi
 
 dnl
 dnl Check for available functions
 dnl
-AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan)
+AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy)
 AC_FUNC_FNMATCH	
 
 divert(5)dnl
@@ -226,13 +339,12 @@ dnl
 dnl Check if there is a support means of creating a new process
 dnl and defining which handles it receives
 dnl
-AC_CACHE_VAL(php_can_support_proc_open,[
 AC_CHECK_FUNCS(fork CreateProcess, [
   php_can_support_proc_open=yes
   break
 ],[
   php_can_support_proc_open=no
-])])
+])
 AC_MSG_CHECKING([if your OS can spawn processes with inherited handles])
 if test "$php_can_support_proc_open" = "yes"; then
   AC_MSG_RESULT(yes)
diff --git a/ext/standard/config.w32 b/ext/standard/config.w32
index c72a8aa..44dea72 100644
--- a/ext/standard/config.w32
+++ b/ext/standard/config.w32
@@ -1,5 +1,5 @@
 // vim:ft=javascript
-// $Id: config.w32 286378 2009-07-26 22:59:46Z jani $
+// $Id: config.w32 291899 2009-12-09 00:20:14Z pajoye $
 
 ARG_WITH("config-file-scan-dir", "Dir to check for additional php ini files", "");
 
@@ -9,8 +9,8 @@ AC_DEFINE("PHP_USE_PHP_CRYPT_R", 1);
 CHECK_HEADER_ADD_INCLUDE("timelib_config.h", "CFLAGS_STANDARD", "ext/date/lib");
 
 EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \
-	crc32.c crypt.c \
-	crypt_freesec.c crypt_blowfish.c php_crypt_r.c \
+	crc32.c crypt.c crypt_freesec.c crypt_blowfish.c crypt_sha256.c \
+	crypt_sha512.c  php_crypt_r.c \
 	cyr_convert.c datetime.c dir.c dl.c dns.c dns_win32.c exec.c \
 	file.c filestat.c formatted_print.c fsock.c head.c html.c image.c \
 	info.c iptc.c lcg.c link_win32.c mail.c math.c md5.c metaphone.c microtime.c \
diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c
index 9afb56b..1504dab 100644
--- a/ext/standard/crc32.c
+++ b/ext/standard/crc32.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: crc32.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: crc32.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "basic_functions.h"
diff --git a/ext/standard/crc32.h b/ext/standard/crc32.h
index 140d04e..50ac116 100644
--- a/ext/standard/crc32.h
+++ b/ext/standard/crc32.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: crc32.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: crc32.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
  * This code implements the AUTODIN II polynomial
diff --git a/ext/standard/credits.c b/ext/standard/credits.c
index 71998b8..eaf9d54 100644
--- a/ext/standard/credits.c
+++ b/ext/standard/credits.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: credits.c 289420 2009-10-09 14:34:18Z pajoye $ */
+/* $Id: credits.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "info.h"
diff --git a/ext/standard/credits.h b/ext/standard/credits.h
index 3fff960..2451c77 100644
--- a/ext/standard/credits.h
+++ b/ext/standard/credits.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: credits.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: credits.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef CREDITS_H
 #define CREDITS_H
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c
index 3743e1e..b4a5167 100644
--- a/ext/standard/crypt.c
+++ b/ext/standard/crypt.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,10 +15,11 @@
    | Authors: Stig Bakken <ssb at php.net>                                   |
    |          Zeev Suraski <zeev at zend.com>                                |
    |          Rasmus Lerdorf <rasmus at php.net>                             |
+   |          Pierre Joye <pierre at php.net>                                |
    +----------------------------------------------------------------------+
 */
 
-/* $Id: crypt.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: crypt.c 295421 2010-02-23 17:49:00Z pajoye $ */
 
 #include <stdlib.h>
 
@@ -82,6 +83,12 @@
 #define PHP_MAX_SALT_LEN 60
 #endif
 
+#if PHP_SHA512_CRYPT
+#undef PHP_MAX_SALT_LEN
+#define PHP_MAX_SALT_LEN 123
+#endif
+
+
 /* If the configure-time checks fail, we provide DES.
  * XXX: This is a hack. Fix the real problem! */
 
@@ -100,6 +107,9 @@ PHP_MINIT_FUNCTION(crypt) /* {{{ */
 	REGISTER_LONG_CONSTANT("CRYPT_EXT_DES", PHP_EXT_DES_CRYPT, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("CRYPT_MD5", PHP_MD5_CRYPT, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("CRYPT_BLOWFISH", PHP_BLOWFISH_CRYPT, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("CRYPT_SHA256", PHP_SHA256_CRYPT, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("CRYPT_SHA512", PHP_SHA512_CRYPT, CONST_CS | CONST_PERSISTENT);
+
 
 #ifdef PHP_USE_PHP_CRYPT_R
 	php_init_crypt_r();
@@ -137,7 +147,7 @@ PHP_FUNCTION(crypt)
 	char salt[PHP_MAX_SALT_LEN + 1];
 	char *str, *salt_in = NULL;
 	int str_len, salt_in_len = 0;
-
+	char *crypt_res;
 	salt[0] = salt[PHP_MAX_SALT_LEN] = '\0';
 
 	/* This will produce suitable results if people depend on DES-encryption
@@ -163,6 +173,7 @@ PHP_FUNCTION(crypt)
 		php_to64(&salt[0], PHP_CRYPT_RAND, 2);
 		salt[2] = '\0';
 #endif
+		salt_in_len = strlen(salt);
 	}
 
 /* Windows (win32/crypt) has a stripped down version of libxcrypt and 
@@ -175,7 +186,53 @@ PHP_FUNCTION(crypt)
 			char output[MD5_HASH_MAX_LEN];
 
 			RETURN_STRING(php_md5_crypt_r(str, salt, output), 1);
-		} else  if (
+		} else if (salt[0]=='$' && salt[1]=='6' && salt[2]=='$') {
+			const char sha512_salt_prefix[] = "$6$";
+			const char sha512_rounds_prefix[] = "rounds=";
+			char *output;
+			int needed = (sizeof(sha512_salt_prefix) - 1
+						+ sizeof(sha512_rounds_prefix) + 9 + 1
+						+ strlen(salt) + 1 + 43 + 1);
+			output = emalloc(needed * sizeof(char *));
+			salt[salt_in_len] = '\0';
+
+			crypt_res = php_sha512_crypt_r(str, salt, output, needed);
+			if (!crypt_res) {
+				if (salt[0]=='*' && salt[1]=='0') {
+					RETVAL_STRING("*1", 1);
+				} else {
+					RETVAL_STRING("*0", 1);
+				}
+			} else {
+				RETVAL_STRING(output, 1);
+			}
+
+			memset(output, 0, PHP_MAX_SALT_LEN + 1);
+			efree(output);
+		} else if (salt[0]=='$' && salt[1]=='5' && salt[2]=='$') {
+			const char sha256_salt_prefix[] = "$5$";
+			const char sha256_rounds_prefix[] = "rounds=";
+			char *output;
+			int needed = (sizeof(sha256_salt_prefix) - 1
+						+ sizeof(sha256_rounds_prefix) + 9 + 1
+						+ strlen(salt) + 1 + 43 + 1);
+			output = emalloc(needed * sizeof(char *));
+			salt[salt_in_len] = '\0';
+
+			crypt_res = php_sha256_crypt_r(str, salt, output, needed);
+			if (!crypt_res) {
+				if (salt[0]=='*' && salt[1]=='0') {
+					RETVAL_STRING("*1", 1);
+				} else {
+					RETVAL_STRING("*0", 1);
+				}
+			} else {
+				RETVAL_STRING(output, 1);
+			}
+
+			memset(output, 0, PHP_MAX_SALT_LEN + 1);
+			efree(output);
+		} else if (
 				salt[0] == '$' &&
 				salt[1] == '2' &&
 				salt[2] == 'a' &&
@@ -186,14 +243,33 @@ PHP_FUNCTION(crypt)
 			char output[PHP_MAX_SALT_LEN + 1];
 
 			memset(output, 0, PHP_MAX_SALT_LEN + 1);
-			php_crypt_blowfish_rn(str, salt, output, sizeof(output));
 
-			RETVAL_STRING(output, 1);
+			crypt_res = php_crypt_blowfish_rn(str, salt, output, sizeof(output));
+			if (!crypt_res) {
+				if (salt[0]=='*' && salt[1]=='0') {
+					RETVAL_STRING("*1", 1);
+				} else {
+					RETVAL_STRING("*0", 1);
+				}
+			} else {
+				RETVAL_STRING(output, 1);
+			}
+
 			memset(output, 0, PHP_MAX_SALT_LEN + 1);
 		} else {
 			memset(&buffer, 0, sizeof(buffer));
 			_crypt_extended_init_r();
-			RETURN_STRING(_crypt_extended_r(str, salt, &buffer), 1);
+
+			crypt_res = _crypt_extended_r(str, salt, &buffer);
+			if (!crypt_res) {
+				if (salt[0]=='*' && salt[1]=='0') {
+					RETURN_STRING("*1", 1);
+				} else {
+					RETURN_STRING("*0", 1);
+				}
+			} else {
+				RETURN_STRING(crypt_res, 1);
+			}
 		}
 	}
 #else
@@ -208,8 +284,16 @@ PHP_FUNCTION(crypt)
 #  else
 #    error Data struct used by crypt_r() is unknown. Please report.
 #  endif
-
-		RETURN_STRING(crypt_r(str, salt, &buffer), 1);
+		crypt_res = crypt_r(str, salt, &buffer);
+		if (!crypt_res) {
+				if (salt[0]=='*' && salt[1]=='0') {
+					RETURN_STRING("*1", 1);
+				} else {
+					RETURN_STRING("*0", 1);
+				}
+		} else {
+			RETURN_STRING(crypt_res, 1);
+		}
 	}
 # endif
 #endif
diff --git a/ext/standard/crypt_blowfish.c b/ext/standard/crypt_blowfish.c
index a345fc0..c88c699 100644
--- a/ext/standard/crypt_blowfish.c
+++ b/ext/standard/crypt_blowfish.c
@@ -1,5 +1,5 @@
 /*
-  $Id: crypt_blowfish.c 281805 2009-06-08 08:44:15Z pajoye $ 
+  $Id: crypt_blowfish.c 295350 2010-02-22 00:34:22Z pajoye $ 
 */
 /*
  * This code comes from John the Ripper password cracker, with reentrant
@@ -606,6 +606,7 @@ char *php_crypt_blowfish_rn(__CONST char *key, __CONST char *setting,
 	    setting[3] != '$' ||
 	    setting[4] < '0' || setting[4] > '3' ||
 	    setting[5] < '0' || setting[5] > '9' ||
+	    (setting[4] == '3' && setting[5] > '1') ||
 	    setting[6] != '$') {
 		__set_errno(EINVAL);
 		return NULL;
diff --git a/ext/standard/crypt_freesec.c b/ext/standard/crypt_freesec.c
index 0d70772..bb9c032 100644
--- a/ext/standard/crypt_freesec.c
+++ b/ext/standard/crypt_freesec.c
@@ -1,12 +1,13 @@
 /*
-  $Id: crypt_freesec.c 265468 2008-08-25 13:42:55Z jani $ 
+  $Id: crypt_freesec.c 295350 2010-02-22 00:34:22Z pajoye $ 
 */
 /*
  * This version is derived from the original implementation of FreeSec
  * (release 1.1) by David Burren.  I've reviewed the changes made in
  * OpenBSD (as of 2.7) and modified the original code in a similar way
- * where applicable.  I've also made it reentrant and did a number of
- * other changes -- SD.
+ * where applicable.  I've also made it reentrant and made a number of
+ * other changes.
+ * - Solar Designer <solar at openwall.com>
  */
 
 /*
@@ -40,7 +41,7 @@
  * SUCH DAMAGE.
  *
  *	$Owl: Owl/packages/glibc/crypt_freesec.c,v 1.4 2005/11/16 13:08:32 solar Exp $
- *	$Id: crypt_freesec.c 265468 2008-08-25 13:42:55Z jani $
+ *	$Id: crypt_freesec.c 295350 2010-02-22 00:34:22Z pajoye $
  *
  * This is an original implementation of the DES and the crypt(3) interfaces
  * by David Burren <davidb at werj.com.au>.
@@ -57,14 +58,17 @@
  * posted to the sci.crypt newsgroup by the author and is available for FTP.
  *
  * ARCHITECTURE ASSUMPTIONS:
- *	This code used to have some nasty ones, but I believe these have
- *	been removed by now.  The code isn't very portable and requires a
- *	32-bit integer type, though -- SD.
+ *	This code used to have some nasty ones, but these have been removed
+ *	by now.  The code requires a 32-bit integer type, though.
  */
 
 #include <sys/types.h>
 #include <string.h>
 
+#ifdef TEST
+#include <stdio.h>
+#endif
+
 #include "crypt_freesec.h"
 
 #define _PASSWORD_EFMT1 '_'
@@ -183,19 +187,28 @@ static uint32_t comp_maskl[8][128], comp_maskr[8][128];
 static inline int
 ascii_to_bin(char ch)
 {
-	if (ch > 'z')
-		return(0);
-	if (ch >= 'a')
-		return(ch - 'a' + 38);
-	if (ch > 'Z')
-		return(0);
-	if (ch >= 'A')
-		return(ch - 'A' + 12);
-	if (ch > '9')
-		return(0);
-	if (ch >= '.')
-		return(ch - '.');
-	return(0);
+	signed char sch = ch;
+	int retval;
+
+	retval = sch - '.';
+	if (sch >= 'A') {
+		retval = sch - ('A' - 12);
+		if (sch >= 'a')
+			retval = sch - ('a' - 38);
+	}
+	retval &= 0x3f;
+
+	return(retval);
+}
+
+/*
+ * When we choose to "support" invalid salts, nevertheless disallow those
+ * containing characters that would violate the passwd file format.
+ */
+static inline int
+ascii_is_unsafe(char ch)
+{
+	return !ch || ch == '\n' || ch == ':';
 }
 
 void
@@ -625,14 +638,24 @@ _crypt_extended_r(const char *key, const char *setting,
 	if (*setting == _PASSWORD_EFMT1) {
 		/*
 		 * "new"-style:
-		 *	setting - underscore, 4 bytes of count, 4 bytes of salt
+		 *	setting - underscore, 4 chars of count, 4 chars of salt
 		 *	key - unlimited characters
 		 */
-		for (i = 1, count = 0; i < 5; i++)
-			count |= ascii_to_bin(setting[i]) << (i - 1) * 6;
+		for (i = 1, count = 0; i < 5; i++) {
+			int value = ascii_to_bin(setting[i]);
+			if (ascii64[value] != setting[i])
+				return(NULL);
+			count |= value << (i - 1) * 6;
+		}
+		if (!count)
+			return(NULL);
 
-		for (i = 5, salt = 0; i < 9; i++)
-			salt |= ascii_to_bin(setting[i]) << (i - 5) * 6;
+		for (i = 5, salt = 0; i < 9; i++) {
+			int value = ascii_to_bin(setting[i]);
+			if (ascii64[value] != setting[i])
+				return(NULL);
+			salt |= value << (i - 5) * 6;
+		}
 
 		while (*key) {
 			/*
@@ -651,35 +674,25 @@ _crypt_extended_r(const char *key, const char *setting,
 			if (des_setkey((u_char *) keybuf, data))
 				return(NULL);
 		}
-		strncpy(data->output, setting, 9);
-		/*
-		 * Double check that we weren't given a short setting.
-		 * If we were, the above code will probably have created
-		 * wierd values for count and salt, but we don't really care.
-		 * Just make sure the output string doesn't have an extra
-		 * NUL in it.
-		 */
+		memcpy(data->output, setting, 9);
 		data->output[9] = '\0';
-		p = (u_char *) data->output + strlen(data->output);
+		p = (u_char *) data->output + 9;
 	} else {
 		/*
 		 * "old"-style:
-		 *	setting - 2 bytes of salt
+		 *	setting - 2 chars of salt
 		 *	key - up to 8 characters
 		 */
 		count = 25;
 
+		if (ascii_is_unsafe(setting[0]) || ascii_is_unsafe(setting[1]))
+			return(NULL);
+
 		salt = (ascii_to_bin(setting[1]) << 6)
 		     |  ascii_to_bin(setting[0]);
 
 		data->output[0] = setting[0];
-		/*
-		 * If the encrypted password that the salt was extracted from
-		 * is only 1 character long, the salt will be corrupted.  We
-		 * need to ensure that the output string doesn't have an extra
-		 * NUL in it!
-		 */
-		data->output[1] = setting[1] ? setting[1] : data->output[0];
+		data->output[1] = setting[1];
 		p = (u_char *) data->output + 2;
 	}
 	setup_salt(salt, data);
@@ -733,6 +746,7 @@ static struct {
 	char *hash;
 	char *pw;
 } tests[] = {
+/* "new"-style */
 	{"_J9..CCCCXBrJUJV154M", "U*U*U*U*"},
 	{"_J9..CCCCXUhOBTXzaiE", "U*U***U"},
 	{"_J9..CCCC4gQ.mB/PffM", "U*U***U*"},
@@ -745,6 +759,30 @@ static struct {
 	{"_J9..SDizxmRI1GjnQuE", "zxyDPWgydbQjgq"},
 	{"_K9..SaltNrQgIYUAeoY", "726 even"},
 	{"_J9..SDSD5YGyRCr4W4c", ""},
+/* "old"-style, valid salts */
+	{"CCNf8Sbh3HDfQ", "U*U*U*U*"},
+	{"CCX.K.MFy4Ois", "U*U***U"},
+	{"CC4rMpbg9AMZ.", "U*U***U*"},
+	{"XXxzOu6maQKqQ", "*U*U*U*U"},
+	{"SDbsugeBiC58A", ""},
+	{"./xZjzHv5vzVE", "password"},
+	{"0A2hXM1rXbYgo", "password"},
+	{"A9RXdR23Y.cY6", "password"},
+	{"ZziFATVXHo2.6", "password"},
+	{"zZDDIZ0NOlPzw", "password"},
+/* "old"-style, "reasonable" invalid salts, UFC-crypt behavior expected */
+	{"\001\002wyd0KZo65Jo", "password"},
+	{"a_C10Dk/ExaG.", "password"},
+	{"~\377.5OTsRVjwLo", "password"},
+/* The below are erroneous inputs, so NULL return is expected/required */
+	{"", ""}, /* no salt */
+	{" ", ""}, /* setting string is too short */
+	{"a:", ""}, /* unsafe character */
+	{"\na", ""}, /* unsafe character */
+	{"_/......", ""}, /* setting string is too short for its type */
+	{"_........", ""}, /* zero iteration count */
+	{"_/!......", ""}, /* invalid character in count */
+	{"_/......!", ""}, /* invalid character in salt */
 	{NULL}
 };
 
@@ -752,8 +790,12 @@ int main(void)
 {
 	int i;
 
-	for (i = 0; tests[i].hash; i++)
-	if (strcmp(crypt(tests[i].pw, tests[i].hash), tests[i].hash)) {
+	for (i = 0; tests[i].hash; i++) {
+		char *hash = crypt(tests[i].pw, tests[i].hash);
+		if (!hash && strlen(tests[i].hash) < 13)
+			continue; /* expected failure */
+		if (!strcmp(hash, tests[i].hash))
+			continue; /* expected success */
 		puts("FAILED");
 		return 1;
 	}
diff --git a/ext/standard/crypt_sha256.c b/ext/standard/crypt_sha256.c
new file mode 100644
index 0000000..3e234ce
--- /dev/null
+++ b/ext/standard/crypt_sha256.c
@@ -0,0 +1,759 @@
+/* SHA256-based Unix crypt implementation.
+   Released into the Public Domain by Ulrich Drepper <drepper at redhat.com>.  */
+/* Windows VC++ port by Pierre Joye <pierre at php.net> */
+
+#include "php.h"
+#include "php_main.h"
+
+#include <errno.h>
+#include <limits.h>
+
+#ifdef PHP_WIN32
+# include "win32/php_stdint.h"
+# define __alignof__ __alignof
+# define alloca _alloca
+#else
+# if HAVE_INTTYPES_H
+#  include <inttypes.h>
+# elif HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+# ifndef HAVE_ALIGNOF
+#  include <stddef.h>
+#  define __alignof__(type) offsetof (struct { char c; type member;}, member)
+# endif
+# if HAVE_ATTRIBUTE_ALIGNED
+#  define ALIGNED(size) __attribute__ ((__aligned__ (size)))
+# else
+#  define ALIGNED(size)
+# endif
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef PHP_WIN32
+# include <string.h>
+#else
+# include <sys/param.h>
+# include <sys/types.h>
+# if HAVE_STRING_H
+//#  define __USE_GNU 1
+#  include <string.h>
+# else
+#  include <strings.h>
+# endif
+#endif
+
+char * __php_stpncpy(char *dst, const char *src, size_t len)
+{
+	size_t n = strlen(src);
+	if (n > len) {
+		n = len;
+	}
+	return strncpy(dst, src, len) + n;
+}
+
+void * __php_mempcpy(void * dst, const void * src, size_t len)
+{
+	return (((char *)memcpy(dst, src, len)) + len);
+}
+
+#ifndef MIN
+# define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+#ifndef MAX
+# define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+/* Structure to save state of computation between the single steps.  */
+struct sha256_ctx {
+	uint32_t H[8];
+
+	uint32_t total[2];
+	uint32_t buflen;
+	char buffer[128]; /* NB: always correctly aligned for uint32_t.  */
+};
+
+#if PHP_WIN32 || (!defined(WORDS_BIGENDIAN))
+# define SWAP(n) \
+    (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
+#else
+# define SWAP(n) (n)
+#endif
+
+/* This array contains the bytes used to pad the buffer to the next
+   64-byte boundary.  (FIPS 180-2:5.1.1)  */
+static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
+
+
+/* Constants for SHA256 from FIPS 180-2:4.2.2.  */
+static const uint32_t K[64] = {
+	0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+	0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+	0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+	0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+	0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+	0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+	0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+	0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+	0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+	0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+	0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+	0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+	0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+	0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+	0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+	0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+};
+
+
+/* Process LEN bytes of BUFFER, accumulating context into CTX.
+   It is assumed that LEN % 64 == 0.  */
+static void sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) {
+	const uint32_t *words = buffer;
+	size_t nwords = len / sizeof (uint32_t);
+	unsigned int t;
+
+	uint32_t a = ctx->H[0];
+	uint32_t b = ctx->H[1];
+	uint32_t c = ctx->H[2];
+	uint32_t d = ctx->H[3];
+	uint32_t e = ctx->H[4];
+	uint32_t f = ctx->H[5];
+	uint32_t g = ctx->H[6];
+	uint32_t h = ctx->H[7];
+
+	/* First increment the byte count.  FIPS 180-2 specifies the possible
+	 length of the file up to 2^64 bits.  Here we only compute the
+	 number of bytes.  Do a double word increment.  */
+	ctx->total[0] += len;
+	if (ctx->total[0] < len) {
+		++ctx->total[1];
+	}
+
+	/* Process all bytes in the buffer with 64 bytes in each round of
+	 the loop.  */
+	while (nwords > 0) {
+		uint32_t W[64];
+		uint32_t a_save = a;
+		uint32_t b_save = b;
+		uint32_t c_save = c;
+		uint32_t d_save = d;
+		uint32_t e_save = e;
+		uint32_t f_save = f;
+		uint32_t g_save = g;
+		uint32_t h_save = h;
+
+	/* Operators defined in FIPS 180-2:4.1.2.  */
+#define Ch(x, y, z) ((x & y) ^ (~x & z))
+#define Maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
+#define S0(x) (CYCLIC (x, 2) ^ CYCLIC (x, 13) ^ CYCLIC (x, 22))
+#define S1(x) (CYCLIC (x, 6) ^ CYCLIC (x, 11) ^ CYCLIC (x, 25))
+#define R0(x) (CYCLIC (x, 7) ^ CYCLIC (x, 18) ^ (x >> 3))
+#define R1(x) (CYCLIC (x, 17) ^ CYCLIC (x, 19) ^ (x >> 10))
+
+	/* It is unfortunate that C does not provide an operator for
+	cyclic rotation.  Hope the C compiler is smart enough.  */
+#define CYCLIC(w, s) ((w >> s) | (w << (32 - s)))
+
+		/* Compute the message schedule according to FIPS 180-2:6.2.2 step 2.  */
+		for (t = 0; t < 16; ++t) {
+			W[t] = SWAP (*words);
+			++words;
+		}
+		for (t = 16; t < 64; ++t)
+			W[t] = R1 (W[t - 2]) + W[t - 7] + R0 (W[t - 15]) + W[t - 16];
+
+		/* The actual computation according to FIPS 180-2:6.2.2 step 3.  */
+		for (t = 0; t < 64; ++t) {
+			uint32_t T1 = h + S1 (e) + Ch (e, f, g) + K[t] + W[t];
+			uint32_t T2 = S0 (a) + Maj (a, b, c);
+			h = g;
+			g = f;
+			f = e;
+			e = d + T1;
+			d = c;
+			c = b;
+			b = a;
+			a = T1 + T2;
+		}
+
+		/* Add the starting values of the context according to FIPS 180-2:6.2.2
+		step 4.  */
+		a += a_save;
+		b += b_save;
+		c += c_save;
+		d += d_save;
+		e += e_save;
+		f += f_save;
+		g += g_save;
+		h += h_save;
+
+		/* Prepare for the next round.  */
+		nwords -= 16;
+	}
+
+	/* Put checksum in context given as argument.  */
+	ctx->H[0] = a;
+	ctx->H[1] = b;
+	ctx->H[2] = c;
+	ctx->H[3] = d;
+	ctx->H[4] = e;
+	ctx->H[5] = f;
+	ctx->H[6] = g;
+	ctx->H[7] = h;
+}
+
+
+/* Initialize structure containing state of computation.
+   (FIPS 180-2:5.3.2)  */
+static void sha256_init_ctx(struct sha256_ctx *ctx) {
+	ctx->H[0] = 0x6a09e667;
+	ctx->H[1] = 0xbb67ae85;
+	ctx->H[2] = 0x3c6ef372;
+	ctx->H[3] = 0xa54ff53a;
+	ctx->H[4] = 0x510e527f;
+	ctx->H[5] = 0x9b05688c;
+	ctx->H[6] = 0x1f83d9ab;
+	ctx->H[7] = 0x5be0cd19;
+
+	ctx->total[0] = ctx->total[1] = 0;
+	ctx->buflen = 0;
+}
+
+
+/* Process the remaining bytes in the internal buffer and the usual
+   prolog according to the standard and write the result to RESBUF.
+
+   IMPORTANT: On some systems it is required that RESBUF is correctly
+   aligned for a 32 bits value.  */
+static void * sha256_finish_ctx(struct sha256_ctx *ctx, void *resbuf) {
+	/* Take yet unprocessed bytes into account.  */
+	uint32_t bytes = ctx->buflen;
+	size_t pad;
+	unsigned int i;
+
+	/* Now count remaining bytes.  */
+	ctx->total[0] += bytes;
+	if (ctx->total[0] < bytes) {
+		++ctx->total[1];
+	}
+
+	pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
+	memcpy(&ctx->buffer[bytes], fillbuf, pad);
+
+	/* Put the 64-bit file length in *bits* at the end of the buffer.  */
+	*(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3);
+	*(uint32_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) |
+						  (ctx->total[0] >> 29));
+
+	/* Process last bytes.  */
+	sha256_process_block(ctx->buffer, bytes + pad + 8, ctx);
+
+	/* Put result from CTX in first 32 bytes following RESBUF.  */
+	for (i = 0; i < 8; ++i) {
+		((uint32_t *) resbuf)[i] = SWAP(ctx->H[i]);
+	}
+
+	return resbuf;
+}
+
+
+static void sha256_process_bytes(const void *buffer, size_t len, struct sha256_ctx *ctx) {
+	/* When we already have some bits in our internal buffer concatenate
+	 both inputs first.  */
+	if (ctx->buflen != 0) {
+		size_t left_over = ctx->buflen;
+		size_t add = 128 - left_over > len ? len : 128 - left_over;
+
+		  memcpy(&ctx->buffer[left_over], buffer, add);
+		  ctx->buflen += add;
+
+		if (ctx->buflen > 64) {
+			sha256_process_block(ctx->buffer, ctx->buflen & ~63, ctx);
+			ctx->buflen &= 63;
+			/* The regions in the following copy operation cannot overlap.  */
+			memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen);
+		}
+
+		buffer = (const char *) buffer + add;
+		len -= add;
+	}
+
+	/* Process available complete blocks.  */
+	if (len >= 64) {
+/* To check alignment gcc has an appropriate operator.  Other
+compilers don't.  */
+#if __GNUC__ >= 2
+# define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint32_t) != 0)
+#else
+# define UNALIGNED_P(p) (((uintptr_t) p) % sizeof (uint32_t) != 0)
+#endif
+		if (UNALIGNED_P (buffer))
+			while (len > 64) {
+				sha256_process_block(memcpy(ctx->buffer, buffer, 64), 64, ctx);
+				buffer = (const char *) buffer + 64;
+				len -= 64;
+			} else {
+				sha256_process_block(buffer, len & ~63, ctx);
+				buffer = (const char *) buffer + (len & ~63);
+				len &= 63;
+			}
+	}
+
+	/* Move remaining bytes into internal buffer.  */
+	if (len > 0) {
+		size_t left_over = ctx->buflen;
+
+		memcpy(&ctx->buffer[left_over], buffer, len);
+		left_over += len;
+		if (left_over >= 64) {
+			sha256_process_block(ctx->buffer, 64, ctx);
+			left_over -= 64;
+			memcpy(ctx->buffer, &ctx->buffer[64], left_over);
+		}
+		ctx->buflen = left_over;
+	}
+}
+
+
+/* Define our magic string to mark salt for SHA256 "encryption"
+   replacement.  */
+static const char sha256_salt_prefix[] = "$5$";
+
+/* Prefix for optional rounds specification.  */
+static const char sha256_rounds_prefix[] = "rounds=";
+
+/* Maximum salt string length.  */
+#define SALT_LEN_MAX 16
+/* Default number of rounds if not explicitly specified.  */
+#define ROUNDS_DEFAULT 5000
+/* Minimum number of rounds.  */
+#define ROUNDS_MIN 1000
+/* Maximum number of rounds.  */
+#define ROUNDS_MAX 999999999
+
+/* Table with characters for base64 transformation.  */
+static const char b64t[64] =
+"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
+{
+#ifdef PHP_WIN32
+# if _MSC <= 1300
+#  pragma pack(push, 16)
+	unsigned char alt_result[32];
+	unsigned char temp_result[32];
+#  pragma pack(pop)
+# else
+	__declspec(align(32)) unsigned char alt_result[32];
+	__declspec(align(32)) unsigned char temp_result[32];
+# endif
+#else
+	unsigned char alt_result[32] ALIGNED(__alignof__ (uint32_t));
+	unsigned char temp_result[32] ALIGNED(__alignof__ (uint32_t));
+#endif
+
+	struct sha256_ctx ctx;
+	struct sha256_ctx alt_ctx;
+	size_t salt_len;
+	size_t key_len;
+	size_t cnt;
+	char *cp;
+	char *copied_key = NULL;
+	char *copied_salt = NULL;
+	char *p_bytes;
+	char *s_bytes;
+	/* Default number of rounds.  */
+	size_t rounds = ROUNDS_DEFAULT;
+	zend_bool rounds_custom = 0;
+
+	/* Find beginning of salt string.  The prefix should normally always
+	be present.  Just in case it is not.  */
+	if (strncmp(sha256_salt_prefix, salt, sizeof(sha256_salt_prefix) - 1) == 0) {
+		/* Skip salt prefix.  */
+		salt += sizeof(sha256_salt_prefix) - 1;
+	}
+
+	if (strncmp(salt, sha256_rounds_prefix, sizeof(sha256_rounds_prefix) - 1) == 0) {
+		const char *num = salt + sizeof(sha256_rounds_prefix) - 1;
+		char *endp;
+		unsigned long int srounds = strtoul(num, &endp, 10);
+		if (*endp == '$') {
+			salt = endp + 1;
+			rounds = MAX(ROUNDS_MIN, MIN(srounds, ROUNDS_MAX));
+			rounds_custom = 1;
+		}
+	}
+
+	salt_len = MIN(strcspn(salt, "$"), SALT_LEN_MAX);
+	key_len = strlen(key);
+
+	if ((key - (char *) 0) % __alignof__ (uint32_t) != 0) {
+		char *tmp = (char *) alloca(key_len + __alignof__(uint32_t));
+		key = copied_key = memcpy(tmp + __alignof__(uint32_t) - (tmp - (char *) 0) % __alignof__(uint32_t), key, key_len);
+	}
+
+	if ((salt - (char *) 0) % __alignof__(uint32_t) != 0) {
+		char *tmp = (char *) alloca(salt_len + __alignof__(uint32_t));
+		salt = copied_salt =
+		memcpy(tmp + __alignof__(uint32_t) - (tmp - (char *) 0) % __alignof__ (uint32_t), salt, salt_len);
+	}
+
+	/* Prepare for the real work.  */
+	sha256_init_ctx(&ctx);
+
+	/* Add the key string.  */
+	sha256_process_bytes(key, key_len, &ctx);
+
+	/* The last part is the salt string.  This must be at most 16
+	 characters and it ends at the first `$' character (for
+	 compatibility with existing implementations).  */
+	sha256_process_bytes(salt, salt_len, &ctx);
+
+
+	/* Compute alternate SHA256 sum with input KEY, SALT, and KEY.  The
+	 final result will be added to the first context.  */
+	sha256_init_ctx(&alt_ctx);
+
+	/* Add key.  */
+	sha256_process_bytes(key, key_len, &alt_ctx);
+
+	/* Add salt.  */
+	sha256_process_bytes(salt, salt_len, &alt_ctx);
+
+	/* Add key again.  */
+	sha256_process_bytes(key, key_len, &alt_ctx);
+
+	/* Now get result of this (32 bytes) and add it to the other
+	 context.  */
+	sha256_finish_ctx(&alt_ctx, alt_result);
+
+	/* Add for any character in the key one byte of the alternate sum.  */
+	for (cnt = key_len; cnt > 32; cnt -= 32) {
+		sha256_process_bytes(alt_result, 32, &ctx);
+	}
+	sha256_process_bytes(alt_result, cnt, &ctx);
+
+	/* Take the binary representation of the length of the key and for every
+	1 add the alternate sum, for every 0 the key.  */
+	for (cnt = key_len; cnt > 0; cnt >>= 1) {
+		if ((cnt & 1) != 0) {
+			sha256_process_bytes(alt_result, 32, &ctx);
+		} else {
+			sha256_process_bytes(key, key_len, &ctx);
+		}
+	}
+
+	/* Create intermediate result.  */
+	sha256_finish_ctx(&ctx, alt_result);
+
+	/* Start computation of P byte sequence.  */
+	sha256_init_ctx(&alt_ctx);
+
+	/* For every character in the password add the entire password.  */
+	for (cnt = 0; cnt < key_len; ++cnt) {
+		sha256_process_bytes(key, key_len, &alt_ctx);
+	}
+
+	/* Finish the digest.  */
+	sha256_finish_ctx(&alt_ctx, temp_result);
+
+	/* Create byte sequence P.  */
+	cp = p_bytes = alloca(key_len);
+	for (cnt = key_len; cnt >= 32; cnt -= 32) {
+		cp = __php_mempcpy((void *)cp, (const void *)temp_result, 32);
+	}
+	memcpy(cp, temp_result, cnt);
+
+	/* Start computation of S byte sequence.  */
+	sha256_init_ctx(&alt_ctx);
+
+	/* For every character in the password add the entire password.  */
+	for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt) {
+		sha256_process_bytes(salt, salt_len, &alt_ctx);
+	}
+
+	/* Finish the digest.  */
+	sha256_finish_ctx(&alt_ctx, temp_result);
+
+	/* Create byte sequence S.  */
+	cp = s_bytes = alloca(salt_len);
+	for (cnt = salt_len; cnt >= 32; cnt -= 32) {
+		cp = __php_mempcpy(cp, temp_result, 32);
+	}
+	memcpy(cp, temp_result, cnt);
+
+	/* Repeatedly run the collected hash value through SHA256 to burn
+	CPU cycles.  */
+	for (cnt = 0; cnt < rounds; ++cnt) {
+		/* New context.  */
+		sha256_init_ctx(&ctx);
+
+		/* Add key or last result.  */
+		if ((cnt & 1) != 0) {
+			sha256_process_bytes(p_bytes, key_len, &ctx);
+		} else {
+			sha256_process_bytes(alt_result, 32, &ctx);
+		}
+
+		/* Add salt for numbers not divisible by 3.  */
+		if (cnt % 3 != 0) {
+			sha256_process_bytes(s_bytes, salt_len, &ctx);
+		}
+
+		/* Add key for numbers not divisible by 7.  */
+		if (cnt % 7 != 0) {
+			sha256_process_bytes(p_bytes, key_len, &ctx);
+		}
+
+		/* Add key or last result.  */
+		if ((cnt & 1) != 0) {
+			sha256_process_bytes(alt_result, 32, &ctx);
+		} else {
+			sha256_process_bytes(p_bytes, key_len, &ctx);
+		}
+
+		/* Create intermediate result.  */
+		sha256_finish_ctx(&ctx, alt_result);
+	}
+
+	/* Now we can construct the result string.  It consists of three
+	parts.  */
+	cp = __php_stpncpy(buffer, sha256_salt_prefix, MAX(0, buflen));
+	buflen -= sizeof(sha256_salt_prefix) - 1;
+
+	if (rounds_custom) {
+#ifdef PHP_WIN32
+		int n = _snprintf(cp, MAX(0, buflen), "%s%u$", sha256_rounds_prefix, rounds);
+#else
+		int n = snprintf(cp, MAX(0, buflen), "%s%zu$", sha256_rounds_prefix, rounds);
+#endif
+		cp += n;
+		buflen -= n;
+	}
+
+	cp = __php_stpncpy(cp, salt, MIN ((size_t) MAX (0, buflen), salt_len));
+	buflen -= MIN((size_t) MAX (0, buflen), salt_len);
+
+	if (buflen > 0) {
+		*cp++ = '$';
+		--buflen;
+	}
+
+#define b64_from_24bit(B2, B1, B0, N)					      \
+  do {									      \
+    unsigned int w = ((B2) << 16) | ((B1) << 8) | (B0);			      \
+    int n = (N);							      \
+    while (n-- > 0 && buflen > 0)					      \
+      {									      \
+	*cp++ = b64t[w & 0x3f];						      \
+	--buflen;							      \
+	w >>= 6;							      \
+      }									      \
+  } while (0)
+
+	b64_from_24bit(alt_result[0], alt_result[10], alt_result[20], 4);
+	b64_from_24bit(alt_result[21], alt_result[1], alt_result[11], 4);
+	b64_from_24bit(alt_result[12], alt_result[22], alt_result[2], 4);
+	b64_from_24bit(alt_result[3], alt_result[13], alt_result[23], 4);
+	b64_from_24bit(alt_result[24], alt_result[4], alt_result[14], 4);
+	b64_from_24bit(alt_result[15], alt_result[25], alt_result[5], 4);
+	b64_from_24bit(alt_result[6], alt_result[16], alt_result[26], 4);
+	b64_from_24bit(alt_result[27], alt_result[7], alt_result[17], 4);
+	b64_from_24bit(alt_result[18], alt_result[28], alt_result[8], 4);
+	b64_from_24bit(alt_result[9], alt_result[19], alt_result[29], 4);
+	b64_from_24bit(0, alt_result[31], alt_result[30], 3);
+	if (buflen <= 0) {
+		errno = ERANGE;
+		buffer = NULL;
+	} else
+		*cp = '\0';		/* Terminate the string.  */
+
+	/* Clear the buffer for the intermediate result so that people
+     attaching to processes or reading core dumps cannot get any
+     information.  We do it in this way to clear correct_words[]
+     inside the SHA256 implementation as well.  */
+	sha256_init_ctx(&ctx);
+	sha256_finish_ctx(&ctx, alt_result);
+	memset(temp_result, '\0', sizeof(temp_result));
+	memset(p_bytes, '\0', key_len);
+	memset(s_bytes, '\0', salt_len);
+	memset(&ctx, '\0', sizeof(ctx));
+	memset(&alt_ctx, '\0', sizeof(alt_ctx));
+
+	if (copied_key != NULL) {
+		memset(copied_key, '\0', key_len);
+
+	}
+	if (copied_salt != NULL) {
+		memset(copied_salt, '\0', salt_len);
+	}
+
+	return buffer;
+}
+
+
+/* This entry point is equivalent to the `crypt' function in Unix
+   libcs.  */
+char * php_sha256_crypt(const char *key, const char *salt)
+{
+	/* We don't want to have an arbitrary limit in the size of the
+	password.  We can compute an upper bound for the size of the
+	result in advance and so we can prepare the buffer we pass to
+	`sha256_crypt_r'.  */
+	static char *buffer;
+	static int buflen;
+	int needed = (sizeof(sha256_salt_prefix) - 1
+			+ sizeof(sha256_rounds_prefix) + 9 + 1
+			+ strlen(salt) + 1 + 43 + 1);
+
+	if (buflen < needed) {
+		char *new_buffer = (char *) realloc(buffer, needed);
+		if (new_buffer == NULL) {
+			return NULL;
+		}
+
+		buffer = new_buffer;
+		buflen = needed;
+	}
+
+	return php_sha256_crypt_r(key, salt, buffer, buflen);
+}
+
+
+#ifdef TEST
+static const struct
+{
+	const char *input;
+	const char result[32];
+} tests[] =
+	{
+	/* Test vectors from FIPS 180-2: appendix B.1.  */
+	{ "abc",
+	"\xba\x78\x16\xbf\x8f\x01\xcf\xea\x41\x41\x40\xde\x5d\xae\x22\x23"
+	"\xb0\x03\x61\xa3\x96\x17\x7a\x9c\xb4\x10\xff\x61\xf2\x00\x15\xad" },
+	/* Test vectors from FIPS 180-2: appendix B.2.  */
+	{ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+	"\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
+	"\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1" },
+	/* Test vectors from the NESSIE project.  */
+	{ "",
+	"\xe3\xb0\xc4\x42\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
+	"\x27\xae\x41\xe4\x64\x9b\x93\x4c\xa4\x95\x99\x1b\x78\x52\xb8\x55" },
+	{ "a",
+	"\xca\x97\x81\x12\xca\x1b\xbd\xca\xfa\xc2\x31\xb3\x9a\x23\xdc\x4d"
+	"\xa7\x86\xef\xf8\x14\x7c\x4e\x72\xb9\x80\x77\x85\xaf\xee\x48\xbb" },
+	{ "message digest",
+	"\xf7\x84\x6f\x55\xcf\x23\xe1\x4e\xeb\xea\xb5\xb4\xe1\x55\x0c\xad"
+	"\x5b\x50\x9e\x33\x48\xfb\xc4\xef\xa3\xa1\x41\x3d\x39\x3c\xb6\x50" },
+	{ "abcdefghijklmnopqrstuvwxyz",
+	"\x71\xc4\x80\xdf\x93\xd6\xae\x2f\x1e\xfa\xd1\x44\x7c\x66\xc9\x52"
+	"\x5e\x31\x62\x18\xcf\x51\xfc\x8d\x9e\xd8\x32\xf2\xda\xf1\x8b\x73" },
+	{ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+	"\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
+	"\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1" },
+	{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+	"\xdb\x4b\xfc\xbd\x4d\xa0\xcd\x85\xa6\x0c\x3c\x37\xd3\xfb\xd8\x80"
+	"\x5c\x77\xf1\x5f\xc6\xb1\xfd\xfe\x61\x4e\xe0\xa7\xc8\xfd\xb4\xc0" },
+	{ "123456789012345678901234567890123456789012345678901234567890"
+	"12345678901234567890",
+	"\xf3\x71\xbc\x4a\x31\x1f\x2b\x00\x9e\xef\x95\x2d\xd8\x3c\xa8\x0e"
+	"\x2b\x60\x02\x6c\x8e\x93\x55\x92\xd0\xf9\xc3\x08\x45\x3c\x81\x3e" }
+  };
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+
+static const struct
+{
+	const char *salt;
+	const char *input;
+	const char *expected;
+} tests2[] =
+{
+	{ "$5$saltstring", "Hello world!",
+	"$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5" },
+	{ "$5$rounds=10000$saltstringsaltstring", "Hello world!",
+	"$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2."
+	"opqey6IcA" },
+	{ "$5$rounds=5000$toolongsaltstring", "This is just a test",
+	"$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8"
+	"mGRcvxa5" },
+	{ "$5$rounds=1400$anotherlongsaltstring",
+	"a very much longer text to encrypt.  This one even stretches over more"
+	"than one line.",
+	"$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12"
+	"oP84Bnq1" },
+	{ "$5$rounds=77777$short",
+	"we have a short salt string but not a short password",
+	"$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/" },
+	{ "$5$rounds=123456$asaltof16chars..", "a short string",
+	"$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/"
+	"cZKmF/wJvD" },
+	{ "$5$rounds=10$roundstoolow", "the minimum number is still observed",
+	"$5$rounds=1000$roundstoolow$yfvwcWrQ8l/K0DAWyuPMDNHpIVlTQebY9l/gL97"
+	"2bIC" },
+};
+#define ntests2 (sizeof (tests2) / sizeof (tests2[0]))
+
+
+int main(void) {
+	struct sha256_ctx ctx;
+	char sum[32];
+	int result = 0;
+	int cnt, i;
+	char buf[1000];
+	static const char expected[32] =
+	"\xcd\xc7\x6e\x5c\x99\x14\xfb\x92\x81\xa1\xc7\xe2\x84\xd7\x3e\x67"
+	"\xf1\x80\x9a\x48\xa4\x97\x20\x0e\x04\x6d\x39\xcc\xc7\x11\x2c\xd0";
+
+	for (cnt = 0; cnt < (int) ntests; ++cnt) {
+		sha256_init_ctx(&ctx);
+		sha256_process_bytes(tests[cnt].input, strlen(tests[cnt].input), &ctx);
+		sha256_finish_ctx(&ctx, sum);
+		if (memcmp(tests[cnt].result, sum, 32) != 0) {
+			printf("test %d run %d failed\n", cnt, 1);
+			result = 1;
+		}
+
+		sha256_init_ctx(&ctx);
+		for (i = 0; tests[cnt].input[i] != '\0'; ++i) {
+			sha256_process_bytes(&tests[cnt].input[i], 1, &ctx);
+		}
+		sha256_finish_ctx(&ctx, sum);
+		if (memcmp(tests[cnt].result, sum, 32) != 0) {
+			printf("test %d run %d failed\n", cnt, 2);
+			result = 1;
+		}
+	}
+
+	/* Test vector from FIPS 180-2: appendix B.3.  */
+
+	memset(buf, 'a', sizeof(buf));
+	sha256_init_ctx(&ctx);
+	for (i = 0; i < 1000; ++i) {
+		sha256_process_bytes (buf, sizeof (buf), &ctx);
+	}
+
+	sha256_finish_ctx(&ctx, sum);
+
+	if (memcmp(expected, sum, 32) != 0) {
+		printf("test %d failed\n", cnt);
+		result = 1;
+	}
+
+	for (cnt = 0; cnt < ntests2; ++cnt) {
+		char *cp = php_sha256_crypt(tests2[cnt].input, tests2[cnt].salt);
+		if (strcmp(cp, tests2[cnt].expected) != 0) {
+			printf("test %d: expected \"%s\", got \"%s\"\n", cnt, tests2[cnt].expected, cp);
+			result = 1;
+		}
+	}
+
+	if (result == 0)
+	puts("all tests OK");
+
+	return result;
+}
+#endif
diff --git a/ext/standard/crypt_sha512.c b/ext/standard/crypt_sha512.c
new file mode 100644
index 0000000..ba9a639
--- /dev/null
+++ b/ext/standard/crypt_sha512.c
@@ -0,0 +1,823 @@
+/* SHA512-based Unix crypt implementation.
+   Released into the Public Domain by Ulrich Drepper <drepper at redhat.com>.  */
+/* Windows VC++ port by Pierre Joye <pierre at php.net> */
+
+#include "php.h"
+#include "php_main.h"
+
+#include <errno.h>
+#include <limits.h>
+#ifdef PHP_WIN32
+# include "win32/php_stdint.h"
+# define __alignof__ __alignof
+# define alloca _alloca
+#else
+# if HAVE_INTTYPES_H
+#  include <inttypes.h>
+# elif HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+# ifndef HAVE_ALIGNOF
+#  include <stddef.h>
+#  define __alignof__(type) offsetof (struct { char c; type member;}, member)
+# endif
+# if HAVE_ATTRIBUTE_ALIGNED
+#  define ALIGNED(size) __attribute__ ((__aligned__ (size)))
+# else
+#  define ALIGNED(size)
+# endif
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef PHP_WIN32
+# include <string.h>
+#else
+# include <sys/param.h>
+# include <sys/types.h>
+# if HAVE_STRING_H
+#  include <string.h>
+# else
+#  include <strings.h>
+# endif
+#endif
+
+extern void * __php_mempcpy(void * dst, const void * src, size_t len);
+extern char * __php_stpncpy(char *dst, const char *src, size_t len);
+
+#ifndef MIN
+# define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+#ifndef MAX
+# define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+/* Structure to save state of computation between the single steps.  */
+struct sha512_ctx
+{
+	uint64_t H[8];
+
+	uint64_t total[2];
+	uint64_t buflen;
+	char buffer[256];	/* NB: always correctly aligned for uint64_t.  */
+};
+
+
+#if PHP_WIN32 || (!defined(WORDS_BIGENDIAN))
+# define SWAP(n) \
+  (((n) << 56)					\
+   | (((n) & 0xff00) << 40)			\
+   | (((n) & 0xff0000) << 24)			\
+   | (((n) & 0xff000000) << 8)			\
+   | (((n) >> 8) & 0xff000000)			\
+   | (((n) >> 24) & 0xff0000)			\
+   | (((n) >> 40) & 0xff00)			\
+   | ((n) >> 56))
+#else
+# define SWAP(n) (n)
+#endif
+
+/* This array contains the bytes used to pad the buffer to the next
+   64-byte boundary.  (FIPS 180-2:5.1.2)  */
+static const unsigned char fillbuf[128] = { 0x80, 0 /* , 0, 0, ...  */ };
+
+/* Constants for SHA512 from FIPS 180-2:4.2.3.  */
+static const uint64_t K[80] = {
+	UINT64_C (0x428a2f98d728ae22), UINT64_C (0x7137449123ef65cd),
+	UINT64_C (0xb5c0fbcfec4d3b2f), UINT64_C (0xe9b5dba58189dbbc),
+	UINT64_C (0x3956c25bf348b538), UINT64_C (0x59f111f1b605d019),
+	UINT64_C (0x923f82a4af194f9b), UINT64_C (0xab1c5ed5da6d8118),
+	UINT64_C (0xd807aa98a3030242), UINT64_C (0x12835b0145706fbe),
+	UINT64_C (0x243185be4ee4b28c), UINT64_C (0x550c7dc3d5ffb4e2),
+	UINT64_C (0x72be5d74f27b896f), UINT64_C (0x80deb1fe3b1696b1),
+	UINT64_C (0x9bdc06a725c71235), UINT64_C (0xc19bf174cf692694),
+	UINT64_C (0xe49b69c19ef14ad2), UINT64_C (0xefbe4786384f25e3),
+	UINT64_C (0x0fc19dc68b8cd5b5), UINT64_C (0x240ca1cc77ac9c65),
+	UINT64_C (0x2de92c6f592b0275), UINT64_C (0x4a7484aa6ea6e483),
+	UINT64_C (0x5cb0a9dcbd41fbd4), UINT64_C (0x76f988da831153b5),
+	UINT64_C (0x983e5152ee66dfab), UINT64_C (0xa831c66d2db43210),
+	UINT64_C (0xb00327c898fb213f), UINT64_C (0xbf597fc7beef0ee4),
+	UINT64_C (0xc6e00bf33da88fc2), UINT64_C (0xd5a79147930aa725),
+	UINT64_C (0x06ca6351e003826f), UINT64_C (0x142929670a0e6e70),
+	UINT64_C (0x27b70a8546d22ffc), UINT64_C (0x2e1b21385c26c926),
+	UINT64_C (0x4d2c6dfc5ac42aed), UINT64_C (0x53380d139d95b3df),
+	UINT64_C (0x650a73548baf63de), UINT64_C (0x766a0abb3c77b2a8),
+	UINT64_C (0x81c2c92e47edaee6), UINT64_C (0x92722c851482353b),
+	UINT64_C (0xa2bfe8a14cf10364), UINT64_C (0xa81a664bbc423001),
+	UINT64_C (0xc24b8b70d0f89791), UINT64_C (0xc76c51a30654be30),
+	UINT64_C (0xd192e819d6ef5218), UINT64_C (0xd69906245565a910),
+	UINT64_C (0xf40e35855771202a), UINT64_C (0x106aa07032bbd1b8),
+	UINT64_C (0x19a4c116b8d2d0c8), UINT64_C (0x1e376c085141ab53),
+	UINT64_C (0x2748774cdf8eeb99), UINT64_C (0x34b0bcb5e19b48a8),
+	UINT64_C (0x391c0cb3c5c95a63), UINT64_C (0x4ed8aa4ae3418acb),
+	UINT64_C (0x5b9cca4f7763e373), UINT64_C (0x682e6ff3d6b2b8a3),
+	UINT64_C (0x748f82ee5defb2fc), UINT64_C (0x78a5636f43172f60),
+	UINT64_C (0x84c87814a1f0ab72), UINT64_C (0x8cc702081a6439ec),
+	UINT64_C (0x90befffa23631e28), UINT64_C (0xa4506cebde82bde9),
+	UINT64_C (0xbef9a3f7b2c67915), UINT64_C (0xc67178f2e372532b),
+	UINT64_C (0xca273eceea26619c), UINT64_C (0xd186b8c721c0c207),
+	UINT64_C (0xeada7dd6cde0eb1e), UINT64_C (0xf57d4f7fee6ed178),
+	UINT64_C (0x06f067aa72176fba), UINT64_C (0x0a637dc5a2c898a6),
+	UINT64_C (0x113f9804bef90dae), UINT64_C (0x1b710b35131c471b),
+	UINT64_C (0x28db77f523047d84), UINT64_C (0x32caab7b40c72493),
+	UINT64_C (0x3c9ebe0a15c9bebc), UINT64_C (0x431d67c49c100d4c),
+	UINT64_C (0x4cc5d4becb3e42b6), UINT64_C (0x597f299cfc657e2a),
+	UINT64_C (0x5fcb6fab3ad6faec), UINT64_C (0x6c44198c4a475817)
+  };
+
+
+/* Process LEN bytes of BUFFER, accumulating context into CTX.
+   It is assumed that LEN % 128 == 0.  */
+static void
+sha512_process_block(const void *buffer, size_t len, struct sha512_ctx *ctx) {
+	const uint64_t *words = buffer;
+	size_t nwords = len / sizeof(uint64_t);
+	uint64_t a = ctx->H[0];
+	uint64_t b = ctx->H[1];
+	uint64_t c = ctx->H[2];
+	uint64_t d = ctx->H[3];
+	uint64_t e = ctx->H[4];
+	uint64_t f = ctx->H[5];
+	uint64_t g = ctx->H[6];
+	uint64_t h = ctx->H[7];
+
+  /* First increment the byte count.  FIPS 180-2 specifies the possible
+	 length of the file up to 2^128 bits.  Here we only compute the
+	 number of bytes.  Do a double word increment.  */
+	ctx->total[0] += len;
+	if (ctx->total[0] < len) {
+		++ctx->total[1];
+	}
+
+	/* Process all bytes in the buffer with 128 bytes in each round of
+	 the loop.  */
+	while (nwords > 0) {
+		uint64_t W[80];
+		uint64_t a_save = a;
+		uint64_t b_save = b;
+		uint64_t c_save = c;
+		uint64_t d_save = d;
+		uint64_t e_save = e;
+		uint64_t f_save = f;
+		uint64_t g_save = g;
+		uint64_t h_save = h;
+		unsigned int t;
+
+/* Operators defined in FIPS 180-2:4.1.2.  */
+#define Ch(x, y, z) ((x & y) ^ (~x & z))
+#define Maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
+#define S0(x) (CYCLIC (x, 28) ^ CYCLIC (x, 34) ^ CYCLIC (x, 39))
+#define S1(x) (CYCLIC (x, 14) ^ CYCLIC (x, 18) ^ CYCLIC (x, 41))
+#define R0(x) (CYCLIC (x, 1) ^ CYCLIC (x, 8) ^ (x >> 7))
+#define R1(x) (CYCLIC (x, 19) ^ CYCLIC (x, 61) ^ (x >> 6))
+
+		/* It is unfortunate that C does not provide an operator for
+		   cyclic rotation.  Hope the C compiler is smart enough.  */
+#define CYCLIC(w, s) ((w >> s) | (w << (64 - s)))
+
+		/* Compute the message schedule according to FIPS 180-2:6.3.2 step 2.  */
+		for (t = 0; t < 16; ++t) {
+			W[t] = SWAP (*words);
+			++words;
+		}
+
+		for (t = 16; t < 80; ++t) {
+			W[t] = R1 (W[t - 2]) + W[t - 7] + R0 (W[t - 15]) + W[t - 16];
+		}
+
+		/* The actual computation according to FIPS 180-2:6.3.2 step 3.  */
+		for (t = 0; t < 80; ++t) {
+			uint64_t T1 = h + S1 (e) + Ch (e, f, g) + K[t] + W[t];
+			uint64_t T2 = S0 (a) + Maj (a, b, c);
+			h = g;
+			g = f;
+			f = e;
+			e = d + T1;
+			d = c;
+			c = b;
+			b = a;
+			a = T1 + T2;
+		}
+
+		/* Add the starting values of the context according to FIPS 180-2:6.3.2
+		step 4.  */
+		a += a_save;
+		b += b_save;
+		c += c_save;
+		d += d_save;
+		e += e_save;
+		f += f_save;
+		g += g_save;
+		h += h_save;
+
+		/* Prepare for the next round.  */
+		nwords -= 16;
+	}
+
+	/* Put checksum in context given as argument.  */
+	ctx->H[0] = a;
+	ctx->H[1] = b;
+	ctx->H[2] = c;
+	ctx->H[3] = d;
+	ctx->H[4] = e;
+	ctx->H[5] = f;
+	ctx->H[6] = g;
+	ctx->H[7] = h;
+}
+
+
+/* Initialize structure containing state of computation.
+   (FIPS 180-2:5.3.3)  */
+static void sha512_init_ctx (struct sha512_ctx *ctx) {
+	ctx->H[0] = UINT64_C (0x6a09e667f3bcc908);
+	ctx->H[1] = UINT64_C (0xbb67ae8584caa73b);
+	ctx->H[2] = UINT64_C (0x3c6ef372fe94f82b);
+	ctx->H[3] = UINT64_C (0xa54ff53a5f1d36f1);
+	ctx->H[4] = UINT64_C (0x510e527fade682d1);
+	ctx->H[5] = UINT64_C (0x9b05688c2b3e6c1f);
+	ctx->H[6] = UINT64_C (0x1f83d9abfb41bd6b);
+	ctx->H[7] = UINT64_C (0x5be0cd19137e2179);
+
+	ctx->total[0] = ctx->total[1] = 0;
+	ctx->buflen = 0;
+}
+
+
+/* Process the remaining bytes in the internal buffer and the usual
+	prolog according to the standard and write the result to RESBUF.
+
+	IMPORTANT: On some systems it is required that RESBUF is correctly
+	aligned for a 32 bits value. */
+static void * sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf) {
+	/* Take yet unprocessed bytes into account.  */
+	uint64_t bytes = ctx->buflen;
+	size_t pad;
+	unsigned int i;
+
+	/* Now count remaining bytes.  */
+	ctx->total[0] += bytes;
+	if (ctx->total[0] < bytes) {
+		++ctx->total[1];
+	}
+
+	pad = bytes >= 112 ? 128 + 112 - (size_t)bytes : 112 - (size_t)bytes;
+	memcpy(&ctx->buffer[bytes], fillbuf, pad);
+
+	/* Put the 128-bit file length in *bits* at the end of the buffer.  */
+	*(uint64_t *) &ctx->buffer[bytes + pad + 8] = SWAP(ctx->total[0] << 3);
+	*(uint64_t *) &ctx->buffer[bytes + pad] = SWAP((ctx->total[1] << 3) |
+						(ctx->total[0] >> 61));
+
+	/* Process last bytes.  */
+	sha512_process_block(ctx->buffer, (size_t)(bytes + pad + 16), ctx);
+
+	/* Put result from CTX in first 64 bytes following RESBUF.  */
+	for (i = 0; i < 8; ++i) {
+		((uint64_t *) resbuf)[i] = SWAP(ctx->H[i]);
+	}
+
+	return resbuf;
+}
+
+static void
+sha512_process_bytes(const void *buffer, size_t len, struct sha512_ctx *ctx) {
+	/* When we already have some bits in our internal buffer concatenate
+	 both inputs first.  */
+	if (ctx->buflen != 0) {
+		size_t left_over = (size_t)ctx->buflen;
+		size_t add = (size_t)(256 - left_over > len ? len : 256 - left_over);
+
+		memcpy(&ctx->buffer[left_over], buffer, add);
+		ctx->buflen += add;
+
+		if (ctx->buflen > 128) {
+			sha512_process_block(ctx->buffer, ctx->buflen & ~127, ctx);
+
+			ctx->buflen &= 127;
+			/* The regions in the following copy operation cannot overlap.  */
+			memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~127],
+					(size_t)ctx->buflen);
+		}
+
+		buffer = (const char *) buffer + add;
+		len -= add;
+	}
+
+	/* Process available complete blocks.  */
+	if (len >= 128) {
+#if !_STRING_ARCH_unaligned
+/* To check alignment gcc has an appropriate operator.  Other
+   compilers don't.  */
+# if __GNUC__ >= 2
+#  define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint64_t) != 0)
+# else
+#  define UNALIGNED_P(p) (((uintptr_t) p) % sizeof(uint64_t) != 0)
+# endif
+		if (UNALIGNED_P(buffer))
+			while (len > 128) {
+				sha512_process_block(memcpy(ctx->buffer, buffer, 128), 128, ctx);
+				buffer = (const char *) buffer + 128;
+				len -= 128;
+			}
+		else
+#endif
+		{
+		  sha512_process_block(buffer, len & ~127, ctx);
+		  buffer = (const char *) buffer + (len & ~127);
+		  len &= 127;
+		}
+	}
+
+  /* Move remaining bytes into internal buffer.  */
+	if (len > 0) {
+		size_t left_over = (size_t)ctx->buflen;
+
+		memcpy(&ctx->buffer[left_over], buffer, len);
+		left_over += len;
+		if (left_over >= 128) {
+			sha512_process_block(ctx->buffer, 128, ctx);
+			left_over -= 128;
+			memcpy(ctx->buffer, &ctx->buffer[128], left_over);
+		}
+		ctx->buflen = left_over;
+	}
+}
+
+
+/* Define our magic string to mark salt for SHA512 "encryption"
+   replacement.  */
+static const char sha512_salt_prefix[] = "$6$";
+
+/* Prefix for optional rounds specification.  */
+static const char sha512_rounds_prefix[] = "rounds=";
+
+/* Maximum salt string length.  */
+#define SALT_LEN_MAX 16
+/* Default number of rounds if not explicitly specified.  */
+#define ROUNDS_DEFAULT 5000
+/* Minimum number of rounds.  */
+#define ROUNDS_MIN 1000
+/* Maximum number of rounds.  */
+#define ROUNDS_MAX 999999999
+
+/* Table with characters for base64 transformation.  */
+static const char b64t[64] =
+"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+
+char *
+php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen) {
+#ifdef PHP_WIN32
+# if _MSC <= 1300
+#  pragma pack(push, 16)
+	unsigned char alt_result[64];
+	unsigned char temp_result[64];
+#  pragma pack(pop)
+# else
+	__declspec(align(64)) unsigned char alt_result[64];
+	__declspec(align(64)) unsigned char temp_result[64];
+# endif
+#else
+	unsigned char alt_result[64] ALIGNED(__alignof__ (uint64_t));
+	unsigned char temp_result[64] ALIGNED(__alignof__ (uint64_t));
+#endif
+	struct sha512_ctx ctx;
+	struct sha512_ctx alt_ctx;
+	size_t salt_len;
+	size_t key_len;
+	size_t cnt;
+	char *cp;
+	char *copied_key = NULL;
+	char *copied_salt = NULL;
+	char *p_bytes;
+	char *s_bytes;
+	/* Default number of rounds.  */
+	size_t rounds = ROUNDS_DEFAULT;
+	zend_bool rounds_custom = 0;
+
+	/* Find beginning of salt string.  The prefix should normally always
+	 be present.  Just in case it is not.  */
+	if (strncmp(sha512_salt_prefix, salt, sizeof(sha512_salt_prefix) - 1) == 0) {
+		/* Skip salt prefix.  */
+		salt += sizeof(sha512_salt_prefix) - 1;
+	}
+
+	if (strncmp(salt, sha512_rounds_prefix, sizeof(sha512_rounds_prefix) - 1) == 0) {
+		const char *num = salt + sizeof(sha512_rounds_prefix) - 1;
+		char *endp;
+		unsigned long int srounds = strtoul(num, &endp, 10);
+
+		if (*endp == '$') {
+			salt = endp + 1;
+			rounds = MAX(ROUNDS_MIN, MIN(srounds, ROUNDS_MAX));
+			rounds_custom = 1;
+		}
+	}
+
+	salt_len = MIN(strcspn(salt, "$"), SALT_LEN_MAX);
+	key_len = strlen(key);
+
+	if ((key - (char *) 0) % __alignof__ (uint64_t) != 0) {
+		char *tmp = (char *) alloca (key_len + __alignof__ (uint64_t));
+		key = copied_key =
+		memcpy(tmp + __alignof__(uint64_t) - (tmp - (char *) 0) % __alignof__(uint64_t), key, key_len);
+	}
+
+	if ((salt - (char *) 0) % __alignof__ (uint64_t) != 0) {
+		char *tmp = (char *) alloca(salt_len + __alignof__(uint64_t));
+
+		salt = copied_salt = memcpy(tmp + __alignof__(uint64_t) - (tmp - (char *) 0) % __alignof__(uint64_t), salt, salt_len);
+	}
+
+	/* Prepare for the real work.  */
+	sha512_init_ctx(&ctx);
+
+	/* Add the key string.  */
+	sha512_process_bytes(key, key_len, &ctx);
+
+	/* The last part is the salt string.  This must be at most 16
+	 characters and it ends at the first `$' character (for
+	 compatibility with existing implementations).  */
+	sha512_process_bytes(salt, salt_len, &ctx);
+
+
+	/* Compute alternate SHA512 sum with input KEY, SALT, and KEY.  The
+	 final result will be added to the first context.  */
+	sha512_init_ctx(&alt_ctx);
+
+	/* Add key.  */
+	sha512_process_bytes(key, key_len, &alt_ctx);
+
+	/* Add salt.  */
+	sha512_process_bytes(salt, salt_len, &alt_ctx);
+
+	/* Add key again.  */
+	sha512_process_bytes(key, key_len, &alt_ctx);
+
+	/* Now get result of this (64 bytes) and add it to the other
+	 context.  */
+	sha512_finish_ctx(&alt_ctx, alt_result);
+
+	/* Add for any character in the key one byte of the alternate sum.  */
+	for (cnt = key_len; cnt > 64; cnt -= 64) {
+		sha512_process_bytes(alt_result, 64, &ctx);
+	}
+	sha512_process_bytes(alt_result, cnt, &ctx);
+
+	/* Take the binary representation of the length of the key and for every
+	 1 add the alternate sum, for every 0 the key.  */
+	for (cnt = key_len; cnt > 0; cnt >>= 1) {
+		if ((cnt & 1) != 0) {
+			sha512_process_bytes(alt_result, 64, &ctx);
+		} else {
+			sha512_process_bytes(key, key_len, &ctx);
+		}
+	}
+
+	/* Create intermediate result.  */
+	sha512_finish_ctx(&ctx, alt_result);
+
+	/* Start computation of P byte sequence.  */
+	sha512_init_ctx(&alt_ctx);
+
+	/* For every character in the password add the entire password.  */
+	for (cnt = 0; cnt < key_len; ++cnt) {
+		sha512_process_bytes(key, key_len, &alt_ctx);
+	}
+
+	/* Finish the digest.  */
+	sha512_finish_ctx(&alt_ctx, temp_result);
+
+	/* Create byte sequence P.  */
+	cp = p_bytes = alloca(key_len);
+	for (cnt = key_len; cnt >= 64; cnt -= 64) {
+		cp = __php_mempcpy((void *) cp, (const void *)temp_result, 64);
+	}
+
+	memcpy(cp, temp_result, cnt);
+
+	/* Start computation of S byte sequence.  */
+	sha512_init_ctx(&alt_ctx);
+
+	/* For every character in the password add the entire password.  */
+	for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt) {
+		sha512_process_bytes(salt, salt_len, &alt_ctx);
+	}
+
+	/* Finish the digest.  */
+	sha512_finish_ctx(&alt_ctx, temp_result);
+
+	/* Create byte sequence S.  */
+	cp = s_bytes = alloca(salt_len);
+	for (cnt = salt_len; cnt >= 64; cnt -= 64) {
+		cp = __php_mempcpy(cp, temp_result, 64);
+	}
+	memcpy(cp, temp_result, cnt);
+
+	/* Repeatedly run the collected hash value through SHA512 to burn
+	 CPU cycles.  */
+	for (cnt = 0; cnt < rounds; ++cnt) {
+		/* New context.  */
+		sha512_init_ctx(&ctx);
+
+		/* Add key or last result.  */
+		if ((cnt & 1) != 0) {
+			sha512_process_bytes(p_bytes, key_len, &ctx);
+		} else {
+			sha512_process_bytes(alt_result, 64, &ctx);
+		}
+
+		/* Add salt for numbers not divisible by 3.  */
+		if (cnt % 3 != 0) {
+			sha512_process_bytes(s_bytes, salt_len, &ctx);
+		}
+
+		/* Add key for numbers not divisible by 7.  */
+		if (cnt % 7 != 0) {
+			sha512_process_bytes(p_bytes, key_len, &ctx);
+		}
+
+		/* Add key or last result.  */
+		if ((cnt & 1) != 0) {
+			sha512_process_bytes(alt_result, 64, &ctx);
+		} else {
+			sha512_process_bytes(p_bytes, key_len, &ctx);
+		}
+
+		/* Create intermediate result.  */
+		sha512_finish_ctx(&ctx, alt_result);
+	}
+
+	/* Now we can construct the result string.  It consists of three
+	 parts.  */
+	cp = __php_stpncpy(buffer, sha512_salt_prefix, MAX(0, buflen));
+	buflen -= sizeof(sha512_salt_prefix) - 1;
+
+	if (rounds_custom) {
+#ifdef PHP_WIN32
+	  int n = _snprintf(cp, MAX(0, buflen), "%s%u$", sha512_rounds_prefix, rounds);
+#else
+	  int n = snprintf(cp, MAX(0, buflen), "%s%zu$", sha512_rounds_prefix, rounds);
+#endif
+	  cp += n;
+	  buflen -= n;
+	}
+
+	cp = __php_stpncpy(cp, salt, MIN((size_t) MAX(0, buflen), salt_len));
+	buflen -= (int) MIN((size_t) MAX(0, buflen), salt_len);
+
+	if (buflen > 0) {
+		*cp++ = '$';
+		--buflen;
+	}
+
+#define b64_from_24bit(B2, B1, B0, N)                    \
+  do {									                 \
+	unsigned int w = ((B2) << 16) | ((B1) << 8) | (B0);	 \
+	int n = (N);							             \
+	while (n-- > 0 && buflen > 0)					     \
+	  {									                 \
+	*cp++ = b64t[w & 0x3f];						         \
+	--buflen;							                 \
+	w >>= 6;							                 \
+	  }									                 \
+  } while (0)
+
+	b64_from_24bit(alt_result[0], alt_result[21], alt_result[42], 4);
+	b64_from_24bit(alt_result[22], alt_result[43], alt_result[1], 4);
+	b64_from_24bit(alt_result[44], alt_result[2], alt_result[23], 4);
+	b64_from_24bit(alt_result[3], alt_result[24], alt_result[45], 4);
+	b64_from_24bit(alt_result[25], alt_result[46], alt_result[4], 4);
+	b64_from_24bit(alt_result[47], alt_result[5], alt_result[26], 4);
+	b64_from_24bit(alt_result[6], alt_result[27], alt_result[48], 4);
+	b64_from_24bit(alt_result[28], alt_result[49], alt_result[7], 4);
+	b64_from_24bit(alt_result[50], alt_result[8], alt_result[29], 4);
+	b64_from_24bit(alt_result[9], alt_result[30], alt_result[51], 4);
+	b64_from_24bit(alt_result[31], alt_result[52], alt_result[10], 4);
+	b64_from_24bit(alt_result[53], alt_result[11], alt_result[32], 4);
+	b64_from_24bit(alt_result[12], alt_result[33], alt_result[54], 4);
+	b64_from_24bit(alt_result[34], alt_result[55], alt_result[13], 4);
+	b64_from_24bit(alt_result[56], alt_result[14], alt_result[35], 4);
+	b64_from_24bit(alt_result[15], alt_result[36], alt_result[57], 4);
+	b64_from_24bit(alt_result[37], alt_result[58], alt_result[16], 4);
+	b64_from_24bit(alt_result[59], alt_result[17], alt_result[38], 4);
+	b64_from_24bit(alt_result[18], alt_result[39], alt_result[60], 4);
+	b64_from_24bit(alt_result[40], alt_result[61], alt_result[19], 4);
+	b64_from_24bit(alt_result[62], alt_result[20], alt_result[41], 4);
+	b64_from_24bit(0, 0, alt_result[63], 2);
+
+	if (buflen <= 0) {
+		errno = ERANGE;
+		buffer = NULL;
+	} else {
+		*cp = '\0';		/* Terminate the string.  */
+	}
+
+	/* Clear the buffer for the intermediate result so that people
+	 attaching to processes or reading core dumps cannot get any
+	 information.  We do it in this way to clear correct_words[]
+	 inside the SHA512 implementation as well.  */
+	sha512_init_ctx(&ctx);
+	sha512_finish_ctx(&ctx, alt_result);
+	memset(temp_result, '\0', sizeof(temp_result));
+	memset(p_bytes, '\0', key_len);
+	memset(s_bytes, '\0', salt_len);
+	memset(&ctx, '\0', sizeof(ctx));
+	memset(&alt_ctx, '\0', sizeof(alt_ctx));
+	if (copied_key != NULL) {
+		memset(copied_key, '\0', key_len);
+	}
+	if (copied_salt != NULL) {
+		memset(copied_salt, '\0', salt_len);
+	}
+
+	return buffer;
+}
+
+
+/* This entry point is equivalent to the `crypt' function in Unix
+   libcs.  */
+char *
+php_sha512_crypt(const char *key, const char *salt) {
+	/* We don't want to have an arbitrary limit in the size of the
+	 password.  We can compute an upper bound for the size of the
+	 result in advance and so we can prepare the buffer we pass to
+	 `sha512_crypt_r'.  */
+	static char *buffer;
+	static int buflen;
+	int needed = (int)(sizeof(sha512_salt_prefix) - 1
+		+ sizeof(sha512_rounds_prefix) + 9 + 1
+		+ strlen(salt) + 1 + 86 + 1);
+
+	if (buflen < needed) {
+		char *new_buffer = (char *) realloc(buffer, needed);
+		if (new_buffer == NULL) {
+			return NULL;
+		}
+
+		buffer = new_buffer;
+		buflen = needed;
+	}
+
+	return php_sha512_crypt_r (key, salt, buffer, buflen);
+}
+
+#ifdef TEST
+static const struct {
+	const char *input;
+	const char result[64];
+} tests[] =
+	{
+	/* Test vectors from FIPS 180-2: appendix C.1.  */
+	{ "abc",
+	  "\xdd\xaf\x35\xa1\x93\x61\x7a\xba\xcc\x41\x73\x49\xae\x20\x41\x31"
+	  "\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
+	  "\x21\x92\x99\x2a\x27\x4f\xc1\xa8\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
+	  "\x45\x4d\x44\x23\x64\x3c\xe8\x0e\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f" },
+	/* Test vectors from FIPS 180-2: appendix C.2.  */
+	{ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
+	  "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
+	  "\x8e\x95\x9b\x75\xda\xe3\x13\xda\x8c\xf4\xf7\x28\x14\xfc\x14\x3f"
+	  "\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1\x72\x99\xae\xad\xb6\x88\x90\x18"
+	  "\x50\x1d\x28\x9e\x49\x00\xf7\xe4\x33\x1b\x99\xde\xc4\xb5\x43\x3a"
+	  "\xc7\xd3\x29\xee\xb6\xdd\x26\x54\x5e\x96\xe5\x5b\x87\x4b\xe9\x09" },
+	/* Test vectors from the NESSIE project.  */
+	{ "",
+	  "\xcf\x83\xe1\x35\x7e\xef\xb8\xbd\xf1\x54\x28\x50\xd6\x6d\x80\x07"
+	  "\xd6\x20\xe4\x05\x0b\x57\x15\xdc\x83\xf4\xa9\x21\xd3\x6c\xe9\xce"
+	  "\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0\xff\x83\x18\xd2\x87\x7e\xec\x2f"
+	  "\x63\xb9\x31\xbd\x47\x41\x7a\x81\xa5\x38\x32\x7a\xf9\x27\xda\x3e" },
+	{ "a",
+	  "\x1f\x40\xfc\x92\xda\x24\x16\x94\x75\x09\x79\xee\x6c\xf5\x82\xf2"
+	  "\xd5\xd7\xd2\x8e\x18\x33\x5d\xe0\x5a\xbc\x54\xd0\x56\x0e\x0f\x53"
+	  "\x02\x86\x0c\x65\x2b\xf0\x8d\x56\x02\x52\xaa\x5e\x74\x21\x05\x46"
+	  "\xf3\x69\xfb\xbb\xce\x8c\x12\xcf\xc7\x95\x7b\x26\x52\xfe\x9a\x75" },
+	{ "message digest",
+	  "\x10\x7d\xbf\x38\x9d\x9e\x9f\x71\xa3\xa9\x5f\x6c\x05\x5b\x92\x51"
+	  "\xbc\x52\x68\xc2\xbe\x16\xd6\xc1\x34\x92\xea\x45\xb0\x19\x9f\x33"
+	  "\x09\xe1\x64\x55\xab\x1e\x96\x11\x8e\x8a\x90\x5d\x55\x97\xb7\x20"
+	  "\x38\xdd\xb3\x72\xa8\x98\x26\x04\x6d\xe6\x66\x87\xbb\x42\x0e\x7c" },
+	{ "abcdefghijklmnopqrstuvwxyz",
+	  "\x4d\xbf\xf8\x6c\xc2\xca\x1b\xae\x1e\x16\x46\x8a\x05\xcb\x98\x81"
+	  "\xc9\x7f\x17\x53\xbc\xe3\x61\x90\x34\x89\x8f\xaa\x1a\xab\xe4\x29"
+	  "\x95\x5a\x1b\xf8\xec\x48\x3d\x74\x21\xfe\x3c\x16\x46\x61\x3a\x59"
+	  "\xed\x54\x41\xfb\x0f\x32\x13\x89\xf7\x7f\x48\xa8\x79\xc7\xb1\xf1" },
+	{ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+	  "\x20\x4a\x8f\xc6\xdd\xa8\x2f\x0a\x0c\xed\x7b\xeb\x8e\x08\xa4\x16"
+	  "\x57\xc1\x6e\xf4\x68\xb2\x28\xa8\x27\x9b\xe3\x31\xa7\x03\xc3\x35"
+	  "\x96\xfd\x15\xc1\x3b\x1b\x07\xf9\xaa\x1d\x3b\xea\x57\x78\x9c\xa0"
+	  "\x31\xad\x85\xc7\xa7\x1d\xd7\x03\x54\xec\x63\x12\x38\xca\x34\x45" },
+	{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+	  "\x1e\x07\xbe\x23\xc2\x6a\x86\xea\x37\xea\x81\x0c\x8e\xc7\x80\x93"
+	  "\x52\x51\x5a\x97\x0e\x92\x53\xc2\x6f\x53\x6c\xfc\x7a\x99\x96\xc4"
+	  "\x5c\x83\x70\x58\x3e\x0a\x78\xfa\x4a\x90\x04\x1d\x71\xa4\xce\xab"
+	  "\x74\x23\xf1\x9c\x71\xb9\xd5\xa3\xe0\x12\x49\xf0\xbe\xbd\x58\x94" },
+	{ "123456789012345678901234567890123456789012345678901234567890"
+	  "12345678901234567890",
+	  "\x72\xec\x1e\xf1\x12\x4a\x45\xb0\x47\xe8\xb7\xc7\x5a\x93\x21\x95"
+	  "\x13\x5b\xb6\x1d\xe2\x4e\xc0\xd1\x91\x40\x42\x24\x6e\x0a\xec\x3a"
+	  "\x23\x54\xe0\x93\xd7\x6f\x30\x48\xb4\x56\x76\x43\x46\x90\x0c\xb1"
+	  "\x30\xd2\xa4\xfd\x5d\xd1\x6a\xbb\x5e\x30\xbc\xb8\x50\xde\xe8\x43" }
+  };
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+
+static const struct
+{
+	const char *salt;
+	const char *input;
+	const char *expected;
+} tests2[] = {
+	{ "$6$saltstring", "Hello world!",
+	"$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJu"
+	"esI68u4OTLiBFdcbYEdFCoEOfaS35inz1"},
+	{ "$6$rounds=10000$saltstringsaltstring", "Hello world!",
+	"$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sb"
+	"HbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v." },
+	{ "$6$rounds=5000$toolongsaltstring", "This is just a test",
+	"$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQ"
+	"zQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0" },
+	{ "$6$rounds=1400$anotherlongsaltstring",
+	"a very much longer text to encrypt.  This one even stretches over more"
+	"than one line.",
+	"$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wP"
+	"vMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1" },
+	{ "$6$rounds=77777$short",
+	"we have a short salt string but not a short password",
+	"$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0g"
+	"ge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0" },
+	{ "$6$rounds=123456$asaltof16chars..", "a short string",
+	"$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwc"
+	"elCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1" },
+	{ "$6$rounds=10$roundstoolow", "the minimum number is still observed",
+	"$6$rounds=1000$roundstoolow$kUMsbe306n21p9R.FRkW3IGn.S9NPN0x50YhH1x"
+	"hLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX." },
+};
+#define ntests2 (sizeof (tests2) / sizeof (tests2[0]))
+
+
+int main (void) {
+	struct sha512_ctx ctx;
+	char sum[64];
+	int result = 0;
+	int cnt;
+	int i;
+	char buf[1000];
+	static const char expected[64] =
+		"\xe7\x18\x48\x3d\x0c\xe7\x69\x64\x4e\x2e\x42\xc7\xbc\x15\xb4\x63"
+		"\x8e\x1f\x98\xb1\x3b\x20\x44\x28\x56\x32\xa8\x03\xaf\xa9\x73\xeb"
+		"\xde\x0f\xf2\x44\x87\x7e\xa6\x0a\x4c\xb0\x43\x2c\xe5\x77\xc3\x1b"
+		"\xeb\x00\x9c\x5c\x2c\x49\xaa\x2e\x4e\xad\xb2\x17\xad\x8c\xc0\x9b";
+
+	for (cnt = 0; cnt < (int) ntests; ++cnt) {
+		sha512_init_ctx (&ctx);
+		sha512_process_bytes (tests[cnt].input, strlen (tests[cnt].input), &ctx);
+		sha512_finish_ctx (&ctx, sum);
+		if (memcmp (tests[cnt].result, sum, 64) != 0) {
+			printf ("test %d run %d failed\n", cnt, 1);
+			result = 1;
+		}
+
+		sha512_init_ctx (&ctx);
+		for (i = 0; tests[cnt].input[i] != '\0'; ++i) {
+			sha512_process_bytes (&tests[cnt].input[i], 1, &ctx);
+		}
+		sha512_finish_ctx (&ctx, sum);
+		if (memcmp (tests[cnt].result, sum, 64) != 0) {
+			printf ("test %d run %d failed\n", cnt, 2);
+			result = 1;
+		}
+	}
+
+	/* Test vector from FIPS 180-2: appendix C.3.  */
+
+	memset (buf, 'a', sizeof (buf));
+	sha512_init_ctx (&ctx);
+	for (i = 0; i < 1000; ++i) {
+		sha512_process_bytes (buf, sizeof (buf), &ctx);
+	}
+
+	sha512_finish_ctx (&ctx, sum);
+	if (memcmp (expected, sum, 64) != 0) {
+		printf ("test %d failed\n", cnt);
+		result = 1;
+	}
+
+	for (cnt = 0; cnt < ntests2; ++cnt) {
+		char *cp = php_sha512_crypt(tests2[cnt].input, tests2[cnt].salt);
+
+		if (strcmp (cp, tests2[cnt].expected) != 0) {
+			printf ("test %d: expected \"%s\", got \"%s\"\n",
+					cnt, tests2[cnt].expected, cp);
+			result = 1;
+		}
+	}
+
+	if (result == 0) {
+		puts ("all tests OK");
+	}
+
+	return result;
+}
+#endif
diff --git a/ext/standard/css.c b/ext/standard/css.c
index 5a62621..d417953 100644
--- a/ext/standard/css.c
+++ b/ext/standard/css.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: css.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: css.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "info.h"
diff --git a/ext/standard/css.h b/ext/standard/css.h
index 855c21e..d7cc796 100644
--- a/ext/standard/css.h
+++ b/ext/standard/css.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: css.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: css.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef CSS_H
 #define CSS_H
diff --git a/ext/standard/cyr_convert.c b/ext/standard/cyr_convert.c
index 3a847be..be11cd0 100644
--- a/ext/standard/cyr_convert.c
+++ b/ext/standard/cyr_convert.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: cyr_convert.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: cyr_convert.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdlib.h>
 
diff --git a/ext/standard/cyr_convert.h b/ext/standard/cyr_convert.h
index 74a1a36..3ff5c59 100644
--- a/ext/standard/cyr_convert.h
+++ b/ext/standard/cyr_convert.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: cyr_convert.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: cyr_convert.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef CYR_CONVERT_H
 #define CYR_CONVERT_H
diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c
index 6afd945..87fd1b6 100644
--- a/ext/standard/datetime.c
+++ b/ext/standard/datetime.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: datetime.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: datetime.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "zend_operators.h"
diff --git a/ext/standard/datetime.h b/ext/standard/datetime.h
index a944f27..0ac21ea 100644
--- a/ext/standard/datetime.h
+++ b/ext/standard/datetime.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: datetime.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: datetime.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef DATETIME_H
 #define DATETIME_H
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index f2b8d24..fcaf1f0 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dir.c 286555 2009-07-30 12:06:40Z felipe $ */
+/* $Id: dir.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* {{{ includes/startup/misc */
 
diff --git a/ext/standard/dl.c b/ext/standard/dl.c
index 37eda68..0499007 100644
--- a/ext/standard/dl.c
+++ b/ext/standard/dl.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: dl.c 286859 2009-08-06 01:33:54Z scottmac $ */
+/* $Id: dl.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "dl.h"
@@ -146,8 +146,18 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now TSRMLS_DC)
 	/* load dynamic symbol */
 	handle = DL_LOAD(libpath);
 	if (!handle) {
+#if PHP_WIN32
+		char *err = GET_DL_ERROR();
+		if (err) {
+			php_error_docref(NULL TSRMLS_CC, error_type, "Unable to load dynamic library '%s' - %s", libpath, err);
+			LocalFree(err);
+		} else {
+			php_error_docref(NULL TSRMLS_CC, error_type, "Unable to load dynamic library '%s' - %s", libpath, "Unknown reason");
+		}
+#else
 		php_error_docref(NULL TSRMLS_CC, error_type, "Unable to load dynamic library '%s' - %s", libpath, GET_DL_ERROR());
 		GET_DL_ERROR(); /* free the buffer storing the error */
+#endif
 		efree(libpath);
 		return FAILURE;
 	}
diff --git a/ext/standard/dl.h b/ext/standard/dl.h
index 8d9ce1e..6eb3fb6 100644
--- a/ext/standard/dl.h
+++ b/ext/standard/dl.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: dl.h 272444 2008-12-31 18:55:22Z helly $ */
+/* $Id: dl.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef DL_H
 #define DL_H
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index 7507884..96d6fb7 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dns.c 287120 2009-08-11 22:07:35Z scottmac $ */
+/* $Id: dns.c 292413 2009-12-21 15:22:40Z jani $ */
 
 /* {{{ includes */
 #include "php.h"
@@ -44,10 +44,10 @@
 #undef T_UNSPEC
 #endif
 #if HAVE_ARPA_NAMESER_H
-#include <arpa/nameser.h>
+#ifdef DARWIN
+# define BIND_8_COMPAT 1
 #endif
-#if HAVE_ARPA_NAMESER_COMPAT_H
-#include <arpa/nameser_compat.h>
+#include <arpa/nameser.h>
 #endif
 #if HAVE_RESOLV_H
 #include <resolv.h>
@@ -810,14 +810,8 @@ PHP_FUNCTION(dns_get_record)
 			n = php_dns_search(handle, hostname, C_IN, type_to_fetch, answer.qb2, sizeof answer);
 
 			if (n < 0) {
-				if (php_dns_errno(handle) == NO_DATA) {
-					php_dns_free_handle(handle);
-					continue;
-				}
-
 				php_dns_free_handle(handle);
-				zval_dtor(return_value);
-				RETURN_FALSE;
+				continue;
 			}
 
 			cp = answer.qb2 + HFIXEDSZ;
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index 6c2dd60..54c25f2 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    |         Ilia Alshanetsky <iliaa at php.net>                             |
    +----------------------------------------------------------------------+
  */
-/* $Id: exec.c 289688 2009-10-15 21:36:42Z pajoye $ */
+/* $Id: exec.c 294429 2010-02-03 18:11:24Z pajoye $ */
 
 #include <stdio.h>
 #include "php.h"
@@ -121,7 +121,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
 
 	if (type != 3) {
 		b = buf;
-
+		
 		while (php_stream_get_line(stream, b, EXEC_INPUT_BUF, &bufl)) {
 			/* no new line found, let's read some more */
 			if (b[bufl - 1] != '\n' && !php_stream_eof(stream)) {
@@ -157,7 +157,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
 		}
 		if (bufl) {
 			/* strip trailing whitespaces if we have not done so already */
-			if ((type == 2 && bufl && !l) || type != 2) {
+			if ((type == 2 && buf != b) || type != 2) {
 				l = bufl;
 				while (l-- && isspace(((unsigned char *)buf)[l]));
 				if (l != (int)(bufl - 1)) {
diff --git a/ext/standard/exec.h b/ext/standard/exec.h
index 669fa1b..18ba008 100644
--- a/ext/standard/exec.h
+++ b/ext/standard/exec.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: exec.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: exec.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef EXEC_H
 #define EXEC_H
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 61eb06c..0bfe060 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: file.c 289422 2009-10-09 14:37:45Z pajoye $ */
+/* $Id: file.c 294896 2010-02-11 18:03:57Z johannes $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -50,16 +50,6 @@
 # include "win32/param.h"
 # include "win32/winutil.h"
 # include "win32/fnmatch.h"
-#elif defined(NETWARE)
-# include <sys/param.h>
-# include <sys/select.h>
-# ifdef USE_WINSOCK
-#  include <novsock2.h>
-# else
-#  include <sys/socket.h>
-#  include <netinet/in.h>
-#  include <netdb.h>
-# endif
 #else
 # if HAVE_SYS_PARAM_H
 #  include <sys/param.h>
@@ -846,7 +836,7 @@ PHP_FUNCTION(tempnam)
 		return;
 	}
 
-	if (PG(safe_mode) &&(!php_checkuid(dir, NULL, CHECKUID_ALLOW_ONLY_DIR))) {
+	if (PG(safe_mode) &&(!php_checkuid(dir, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		RETURN_FALSE;
 	}
 
@@ -1636,16 +1626,9 @@ PHP_NAMED_FUNCTION(php_if_fstat)
 	MAKE_LONG_ZVAL_INCREF(stat_rdev, -1);
 #endif
 	MAKE_LONG_ZVAL_INCREF(stat_size, stat_ssb.sb.st_size);
-#ifdef NETWARE
-	MAKE_LONG_ZVAL_INCREF(stat_atime, stat_ssb.sb.st_atime.tv_sec);
-	MAKE_LONG_ZVAL_INCREF(stat_mtime, stat_ssb.sb.st_mtime.tv_sec);
-	MAKE_LONG_ZVAL_INCREF(stat_ctime, stat_ssb.sb.st_ctime.tv_sec);
-#else
 	MAKE_LONG_ZVAL_INCREF(stat_atime, stat_ssb.sb.st_atime);
 	MAKE_LONG_ZVAL_INCREF(stat_mtime, stat_ssb.sb.st_mtime);
 	MAKE_LONG_ZVAL_INCREF(stat_ctime, stat_ssb.sb.st_ctime);
-#endif
-
 #ifdef HAVE_ST_BLKSIZE
 	MAKE_LONG_ZVAL_INCREF(stat_blksize, stat_ssb.sb.st_blksize);
 #else
diff --git a/ext/standard/file.h b/ext/standard/file.h
index d3720f9..63804b7 100644
--- a/ext/standard/file.h
+++ b/ext/standard/file.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: file.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: file.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */
 
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
index 031422f..72aaf98 100644
--- a/ext/standard/filestat.c
+++ b/ext/standard/filestat.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: filestat.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: filestat.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "safe_mode.h"
@@ -386,7 +386,7 @@ PHP_FUNCTION(disk_free_space)
 }
 /* }}} */
 
-#if !defined(WINDOWS)
+#if !defined(WINDOWS) && !defined(NETWARE)
 static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
 {
 	char *filename;
@@ -487,7 +487,7 @@ PHP_FUNCTION(lchgrp)
 /* }}} */
 #endif /* !NETWARE */
 
-#if !defined(WINDOWS)
+#if !defined(WINDOWS) && !defined(NETWARE)
 static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */
 {
 	char *filename;
@@ -899,23 +899,11 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
 	case FS_GROUP:
 		RETURN_LONG((long)ssb.sb.st_gid);
 	case FS_ATIME:
-#ifdef NETWARE
-		RETURN_LONG((long)ssb.sb.st_atime.tv_sec);
-#else
 		RETURN_LONG((long)ssb.sb.st_atime);
-#endif
 	case FS_MTIME:
-#ifdef NETWARE
-		RETURN_LONG((long)ssb.sb.st_mtime.tv_sec);
-#else
 		RETURN_LONG((long)ssb.sb.st_mtime);
-#endif
 	case FS_CTIME:
-#ifdef NETWARE
-		RETURN_LONG((long)ssb.sb.st_ctime.tv_sec);
-#else
 		RETURN_LONG((long)ssb.sb.st_ctime);
-#endif
 	case FS_TYPE:
 		if (S_ISLNK(ssb.sb.st_mode)) {
 			RETURN_STRING("link", 1);
@@ -963,15 +951,9 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
 		MAKE_LONG_ZVAL_INCREF(stat_rdev, -1);
 #endif
 		MAKE_LONG_ZVAL_INCREF(stat_size, stat_sb->st_size);
-#ifdef NETWARE
-		MAKE_LONG_ZVAL_INCREF(stat_atime, (stat_sb->st_atime).tv_sec);
-		MAKE_LONG_ZVAL_INCREF(stat_mtime, (stat_sb->st_mtime).tv_sec);
-		MAKE_LONG_ZVAL_INCREF(stat_ctime, (stat_sb->st_ctime).tv_sec);
-#else
 		MAKE_LONG_ZVAL_INCREF(stat_atime, stat_sb->st_atime);
 		MAKE_LONG_ZVAL_INCREF(stat_mtime, stat_sb->st_mtime);
 		MAKE_LONG_ZVAL_INCREF(stat_ctime, stat_sb->st_ctime);
-#endif
 #ifdef HAVE_ST_BLKSIZE
 		MAKE_LONG_ZVAL_INCREF(stat_blksize, stat_sb->st_blksize);
 #else
@@ -1125,6 +1107,51 @@ FileFunction(php_if_lstat, FS_LSTAT)
 FileFunction(php_if_stat, FS_STAT)
 /* }}} */
 
+/* {{{ proto bool realpath_cache_size()
+   Get current size of realpath cache */
+PHP_FUNCTION(realpath_cache_size)
+{
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	RETURN_LONG(realpath_cache_size(TSRMLS_C));
+}
+
+/* {{{ proto bool realpath_cache_get()
+   Get current size of realpath cache */
+PHP_FUNCTION(realpath_cache_get)
+{
+	realpath_cache_bucket **buckets = realpath_cache_get_buckets(TSRMLS_C), **end = buckets + realpath_cache_max_buckets(TSRMLS_C);
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	array_init(return_value);
+	while(buckets < end) {
+		realpath_cache_bucket *bucket = *buckets;
+		while(bucket) {
+			zval *entry;
+			MAKE_STD_ZVAL(entry);
+			array_init(entry);
+
+			add_assoc_long(entry, "key", bucket->key);
+			add_assoc_bool(entry, "is_dir", bucket->is_dir);
+			add_assoc_stringl(entry, "realpath", bucket->realpath, bucket->realpath_len, 1);
+			add_assoc_long(entry, "expires", bucket->expires);
+#ifdef PHP_WIN32
+			add_assoc_bool(entry, "is_rvalid", bucket->is_rvalid);
+			add_assoc_bool(entry, "is_wvalid", bucket->is_wvalid);
+			add_assoc_bool(entry, "is_readable", bucket->is_readable);
+			add_assoc_bool(entry, "is_writable", bucket->is_writable);
+#endif
+			zend_hash_update(Z_ARRVAL_P(return_value), bucket->path, bucket->path_len+1, &entry, sizeof(zval *), NULL);
+			bucket = bucket->next;
+		}
+		buckets++;
+	}
+}
+
 /*
  * Local variables:
  * tab-width: 4
diff --git a/ext/standard/filters.c b/ext/standard/filters.c
index 888b14e..c534cc4 100644
--- a/ext/standard/filters.c
+++ b/ext/standard/filters.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: filters.c 284646 2009-07-23 12:18:40Z iliaa $ */
+/* $Id: filters.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_globals.h"
diff --git a/ext/standard/flock_compat.c b/ext/standard/flock_compat.c
index a01423c..696e972 100644
--- a/ext/standard/flock_compat.c
+++ b/ext/standard/flock_compat.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: flock_compat.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: flock_compat.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include <errno.h>
diff --git a/ext/standard/flock_compat.h b/ext/standard/flock_compat.h
index a2d347f..c7265fc 100644
--- a/ext/standard/flock_compat.h
+++ b/ext/standard/flock_compat.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: flock_compat.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: flock_compat.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef FLOCK_COMPAT_H
 #define FLOCK_COMPAT_H
@@ -42,9 +42,12 @@ PHPAPI int flock(int fd, int operation);
 #define PHP_LOCK_NB 4
 
 #ifdef PHP_WIN32
-#define EWOULDBLOCK WSAEWOULDBLOCK
-#	define fsync _commit
-#	define ftruncate(a, b) chsize(a, b)
+# ifdef EWOULDBLOCK
+#  undef EWOULDBLOCK
+# endif
+# define EWOULDBLOCK WSAEWOULDBLOCK
+# define fsync _commit
+# define ftruncate(a, b) chsize(a, b)
 #endif /* defined(PHP_WIN32) */
 
 #if !HAVE_INET_ATON
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index d44aae5..5f5f2a6 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: formatted_print.c 284649 2009-07-23 14:54:04Z jani $ */
+/* $Id: formatted_print.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <math.h>				/* modf() */
 #include "php.h"
@@ -232,14 +232,14 @@ php_sprintf_appenddouble(char **buffer, int *pos,
 	if (zend_isnan(number)) {
 		is_negative = (number<0);
 		php_sprintf_appendstring(buffer, pos, size, "NaN", 3, 0, padding,
-								 alignment, precision, is_negative, 0, always_sign);
+								 alignment, 3, is_negative, 0, always_sign);
 		return;
 	}
 
 	if (zend_isinf(number)) {
 		is_negative = (number<0);
 		php_sprintf_appendstring(buffer, pos, size, "INF", 3, 0, padding,
-								 alignment, precision, is_negative, 0, always_sign);
+								 alignment, 3, is_negative, 0, always_sign);
 		return;
 	}
 
diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c
index 270e4d5..87e3e52 100644
--- a/ext/standard/fsock.c
+++ b/ext/standard/fsock.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: fsock.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: fsock.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_globals.h"
diff --git a/ext/standard/fsock.h b/ext/standard/fsock.h
index 8c5db51..3776613 100644
--- a/ext/standard/fsock.h
+++ b/ext/standard/fsock.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: fsock.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: fsock.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Synced with php 3.0 revision 1.24 1999-06-18 [ssb] */
 
diff --git a/ext/standard/ftok.c b/ext/standard/ftok.c
index 3c768a8..a41c126 100644
--- a/ext/standard/ftok.c
+++ b/ext/standard/ftok.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: ftok.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: ftok.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
index b2175e8..6e20d5a 100644
--- a/ext/standard/ftp_fopen_wrapper.c
+++ b/ext/standard/ftp_fopen_wrapper.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    |          Sara Golemon <pollita at php.net>                              |
    +----------------------------------------------------------------------+
  */
-/* $Id: ftp_fopen_wrapper.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: ftp_fopen_wrapper.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -834,32 +834,19 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, char *url, int f
 		tm.tm_sec += stamp - mktime(gmt);
 		tm.tm_isdst = gmt->tm_isdst;
 
-#ifdef NETWARE
-		ssb->sb.st_mtime.tv_sec = mktime(&tm);
-#else
 		ssb->sb.st_mtime = mktime(&tm);
-#endif
 	} else {
 		/* error or unsupported command */
 mdtm_error:
-#ifdef NETWARE
-		ssb->sb.st_mtime.tv_sec = -1;
-#else
 		ssb->sb.st_mtime = -1;
-#endif
 	}
 
 	ssb->sb.st_ino = 0;						/* Unknown values */
 	ssb->sb.st_dev = 0;
 	ssb->sb.st_uid = 0;
 	ssb->sb.st_gid = 0;
-#ifdef NETWARE
-	ssb->sb.st_atime.tv_sec = -1;
-	ssb->sb.st_ctime.tv_sec = -1;
-#else
 	ssb->sb.st_atime = -1;
 	ssb->sb.st_ctime = -1;
-#endif
 
 	ssb->sb.st_nlink = 1;
 	ssb->sb.st_rdev = -1;
diff --git a/ext/standard/head.c b/ext/standard/head.c
index 9e9d9d5..807d30b 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Rasmus Lerdorf <rasmus at lerdorf.on.ca>                        |
    +----------------------------------------------------------------------+
  */
-/* $Id: head.c 286508 2009-07-29 13:44:16Z iliaa $ */
+/* $Id: head.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdio.h>
 #include "php.h"
diff --git a/ext/standard/head.h b/ext/standard/head.h
index 1eef0f2..7d7f6ca 100644
--- a/ext/standard/head.h
+++ b/ext/standard/head.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: head.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: head.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef HEAD_H
 #define HEAD_H
diff --git a/ext/standard/html.c b/ext/standard/html.c
index 6f1bab2..c9c7a75 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: html.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: html.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
  * HTML entity resources:
@@ -144,7 +144,7 @@ static entity_table_t ent_uni_greek[] = {
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	"thetasym", "upsih",
 	NULL, NULL, NULL,
-	"piv" 
+	"piv"
 };
 
 static entity_table_t ent_uni_punct[] = {
@@ -154,7 +154,7 @@ static entity_table_t ent_uni_punct[] = {
 	NULL, NULL, NULL, "ndash", "mdash", NULL, NULL, NULL,
 	/* 8216 */
 	"lsquo", "rsquo", "sbquo", NULL, "ldquo", "rdquo", "bdquo", NULL,
-	"dagger", "Dagger",	"bull", NULL, NULL, NULL, "hellip",
+	"dagger", "Dagger", "bull", NULL, NULL, NULL, "hellip",
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "permil", NULL,
 	/* 8242 */
 	"prime", "Prime", NULL, NULL, NULL, NULL, NULL, "lsaquo", "rsaquo", NULL,
@@ -194,39 +194,39 @@ static entity_table_t ent_uni_8592_9002[] = {
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 8656 (0x21d0) */
-	"lArr", "uArr", "rArr", "dArr", "hArr", "vArr", NULL, NULL,
-	NULL, NULL, "lAarr", "rAarr", NULL, "rarrw", NULL, NULL,
+	"lArr", "uArr", "rArr", "dArr", "hArr", NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 8672 (0x21e0) */
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 8704 (0x2200) */
-	"forall", "comp", "part", "exist", "nexist", "empty", NULL, "nabla",
-	"isin", "notin", "epsis", "ni", "notni", "bepsi", NULL, "prod",
+	"forall", NULL, "part", "exist", NULL, "empty", NULL, "nabla",
+	"isin", "notin", NULL, "ni", NULL, NULL, NULL, "prod",
 	/* 8720 (0x2210) */
-	"coprod", "sum", "minus", "mnplus", "plusdo", NULL, "setmn", "lowast",
-	"compfn", NULL, "radic", NULL, NULL, "prop", "infin", "ang90",
+	NULL, "sum", "minus", NULL, NULL, NULL, NULL, "lowast",
+	NULL, NULL, "radic", NULL, NULL, "prop", "infin", NULL,
 	/* 8736 (0x2220) */
-	"ang", "angmsd", "angsph", "mid", "nmid", "par", "npar", "and",
-	"or", "cap", "cup", "int", NULL, NULL, "conint", NULL,
+	"ang", NULL, NULL, NULL, NULL, NULL, NULL, "and",
+	"or", "cap", "cup", "int", NULL, NULL, NULL, NULL,
 	/* 8752 (0x2230) */
-	NULL, NULL, NULL, NULL, "there4", "becaus", NULL, NULL,
-	NULL, NULL, NULL, NULL, "sim", "bsim", NULL, NULL,
+	NULL, NULL, NULL, NULL, "there4", NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, "sim", NULL, NULL, NULL,
 	/* 8768 (0x2240) */
-	"wreath", "nsim", NULL, "sime", "nsime", "cong", NULL, "ncong",
-	"asymp", "nap", "ape", NULL, "bcong", "asymp", "bump", "bumpe",
+	NULL, NULL, NULL, NULL, NULL, "cong", NULL, NULL,
+	"asymp", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 8784 (0x2250) */
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 8800 (0x2260) */
-	"ne", "equiv", NULL, NULL, "le", "ge", "lE", "gE",
-	"lnE", "gnE", "Lt", "Gt", "twixt", NULL, "nlt", "ngt",
+	"ne", "equiv", NULL, NULL, "le", "ge", NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 8816 (0x2270) */
-	"nles", "nges", "lsim", "gsim", NULL, NULL, "lg", "gl",
-	NULL, NULL, "pr", "sc", "cupre", "sscue", "prsim", "scsim",
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 8832 (0x2280) */
-	"npr", "nsc", "sub", "sup", "nsub", "nsup", "sube", "supe",
+	NULL, NULL, "sub", "sup", "nsub", NULL, "sube", "supe",
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 8848 (0x2290) */
 	NULL, NULL, NULL, NULL, NULL, "oplus", NULL, "otimes",
@@ -380,8 +380,8 @@ static entity_table_t ent_macroman[] = {
 
 struct html_entity_map {
 	enum entity_charset charset;	/* charset identifier */
-	unsigned short basechar;			/* char code at start of table */
-	unsigned short endchar;			/* last char code in the table */
+	unsigned int basechar;			/* char code at start of table */
+	unsigned int endchar;			/* last char code in the table */
 	entity_table_t *table;			/* the table of mappings */
 };
 
@@ -483,16 +483,31 @@ struct basic_entities_dec {
 			}                        \
 			mbseq[mbpos++] = (mbchar); }
 
+/* skip one byte and return */
+#define MB_FAILURE(pos) do { \
+	*newpos = pos + 1; \
+	*status = FAILURE; \
+	return 0; \
+} while (0)
+
 #define CHECK_LEN(pos, chars_need)			\
-	if((str_len - (pos)) < chars_need) {	\
-		*newpos = pos;						\
-		*status = FAILURE;					\
-		return 0;							\
+	if (chars_need < 1) {						\
+		if((str_len - (pos)) < chars_need) {	\
+			*newpos = pos;						\
+			*status = FAILURE;					\
+			return 0;							\
+		}										\
+	} else {									\
+		if((str_len - (pos)) < chars_need) {	\
+			*newpos = pos + 1;					\
+			*status = FAILURE;					\
+			return 0;							\
+		}										\
 	}
 
 /* {{{ get_next_char
  */
-inline static unsigned short get_next_char(enum entity_charset charset,
+inline static unsigned int get_next_char(enum entity_charset charset,
 		unsigned char * str,
 		int str_len,
 		int * newpos,
@@ -503,206 +518,191 @@ inline static unsigned short get_next_char(enum entity_charset charset,
 	int pos = *newpos;
 	int mbpos = 0;
 	int mbspace = *mbseqlen;
-	unsigned short this_char = str[pos++];
+	unsigned int this_char = 0;
 	unsigned char next_char;
 
 	*status = SUCCESS;
-	
+
 	if (mbspace <= 0) {
 		*mbseqlen = 0;
-		return this_char;
+		CHECK_LEN(pos, 1);
+		*newpos = pos + 1;
+		return str[pos];
 	}
-	
-	MB_WRITE((unsigned char)this_char);
-	
+
 	switch (charset) {
 		case cs_utf_8:
 			{
-				unsigned long utf = 0;
-				int stat = 0;
-				int more = 1;
-
-				/* unpack utf-8 encoding into a wide char.
-				 * Code stolen from the mbstring extension */
-
-				do {
+				unsigned char c;
+				CHECK_LEN(pos, 1);
+				c = str[pos];
+				if (c < 0x80) {
+					MB_WRITE(c);
+					this_char = c;
+					pos++;
+				} else if (c < 0xc0) {
+					MB_FAILURE(pos);
+				} else if (c < 0xe0) {
+					CHECK_LEN(pos, 2);
+					if (str[pos + 1] < 0x80 || str[pos + 1] > 0xbf) {
+						MB_FAILURE(pos);
+					}
+					this_char = ((c & 0x1f) << 6) | (str[pos + 1] & 0x3f);
 					if (this_char < 0x80) {
-						more = 0;
-						if(stat) {
-							/* we didn't finish the UTF sequence correctly */
-							--pos;
-							*status = FAILURE;
-						}
-						break;
-					} else if (this_char < 0xc0) {
-						switch (stat) {
-							case 0x10:	/* 2, 2nd */
-							case 0x21:	/* 3, 3rd */
-							case 0x32:	/* 4, 4th */
-							case 0x43:	/* 5, 5th */
-							case 0x54:	/* 6, 6th */
-								/* last byte in sequence */
-								more = 0;
-								utf |= (this_char & 0x3f);
-								this_char = (unsigned short)utf;
-								break;
-							case 0x20:	/* 3, 2nd */
-							case 0x31:	/* 4, 3rd */
-							case 0x42:	/* 5, 4th */
-							case 0x53:	/* 6, 5th */
-								/* penultimate char */
-								utf |= ((this_char & 0x3f) << 6);
-								stat++;
-								break;
-							case 0x30:	/* 4, 2nd */
-							case 0x41:	/* 5, 3rd */
-							case 0x52:	/* 6, 4th */
-								utf |= ((this_char & 0x3f) << 12);
-								stat++;
-								break;
-							case 0x40:	/* 5, 2nd */
-							case 0x51:
-								utf |= ((this_char & 0x3f) << 18);
-								stat++;
-								break;
-							case 0x50:	/* 6, 2nd */
-								utf |= ((this_char & 0x3f) << 24);
-								stat++;
-								break;
-							default:
-								/* invalid */
-								*status = FAILURE;
-								more = 0;
-						}
+						MB_FAILURE(pos);
 					}
-					/* lead byte */
-					else if (this_char < 0xe0) {
-						stat = 0x10;	/* 2 byte */
-						utf = (this_char & 0x1f) << 6;
-						CHECK_LEN(pos, 1);
-					} else if (this_char < 0xf0) {
-						stat = 0x20;	/* 3 byte */
-						utf = (this_char & 0xf) << 12;
-						CHECK_LEN(pos, 2);
-					} else if (this_char < 0xf8) {
-						stat = 0x30;	/* 4 byte */
-						utf = (this_char & 0x7) << 18;
-						CHECK_LEN(pos, 3);
-					} else if (this_char < 0xfc) {
-						stat = 0x40;	/* 5 byte */
-						utf = (this_char & 0x3) << 24;
-						CHECK_LEN(pos, 4);
-					} else if (this_char < 0xfe) {
-						stat = 0x50;	/* 6 byte */
-						utf = (this_char & 0x1) << 30;
-						CHECK_LEN(pos, 5);
-					} else {
-						/* invalid; bail */
-						more = 0;
-						*status = FAILURE;
-						break;
+					MB_WRITE((unsigned char)c);
+					MB_WRITE((unsigned char)str[pos + 1]);
+					pos += 2;
+				} else if (c < 0xf0) {
+					CHECK_LEN(pos, 3);
+					if (str[pos + 1] < 0x80 || str[pos + 1] > 0xbf) {
+						MB_FAILURE(pos);
 					}
-
-					if (more) {
-						this_char = str[pos++];
-						MB_WRITE((unsigned char)this_char);
+					if (str[pos + 2] < 0x80 || str[pos + 2] > 0xbf) {
+						MB_FAILURE(pos);
+					}
+					this_char = ((c & 0x0f) << 12) | ((str[pos + 1] & 0x3f) << 6) | (str[pos + 2] & 0x3f);
+					if (this_char < 0x800) {
+						MB_FAILURE(pos);
+					} else if (this_char >= 0xd800 && this_char <= 0xdfff) {
+						MB_FAILURE(pos);
 					}
-				} while (more);
+					MB_WRITE((unsigned char)c);
+					MB_WRITE((unsigned char)str[pos + 1]);
+					MB_WRITE((unsigned char)str[pos + 2]);
+					pos += 3;
+				} else if (c < 0xf8) {
+					CHECK_LEN(pos, 4);
+					if (str[pos + 1] < 0x80 || str[pos + 1] > 0xbf) {
+						MB_FAILURE(pos);
+					}
+					if (str[pos + 2] < 0x80 || str[pos + 2] > 0xbf) {
+						MB_FAILURE(pos);
+					}
+					if (str[pos + 3] < 0x80 || str[pos + 3] > 0xbf) {
+						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) {
+						MB_FAILURE(pos);
+					}
+					MB_WRITE((unsigned char)c);
+					MB_WRITE((unsigned char)str[pos + 1]);
+					MB_WRITE((unsigned char)str[pos + 2]);
+					MB_WRITE((unsigned char)str[pos + 3]);
+					pos += 4;
+				} else {
+					MB_FAILURE(pos);
+				}
 			}
 			break;
 		case cs_big5:
 		case cs_gb2312:
 		case cs_big5hkscs:
 			{
+				CHECK_LEN(pos, 1);
+				this_char = str[pos++];
 				/* check if this is the first of a 2-byte sequence */
-				if (this_char >= 0xa1 && this_char <= 0xfe) {
+				if (this_char >= 0x81 && this_char <= 0xfe) {
 					/* peek at the next char */
 					CHECK_LEN(pos, 1);
-					next_char = str[pos];
+					next_char = str[pos++];
 					if ((next_char >= 0x40 && next_char <= 0x7e) ||
 							(next_char >= 0xa1 && next_char <= 0xfe)) {
 						/* yes, this a wide char */
-						this_char <<= 8;
+						MB_WRITE(this_char);
 						MB_WRITE(next_char);
-						this_char |= next_char;
-						pos++;
+						this_char = (this_char << 8) | next_char;
+					} else {
+						MB_FAILURE(pos);
 					}
-					
+				} else {
+					MB_WRITE(this_char);
 				}
-				break;
 			}
+			break;
 		case cs_sjis:
 			{
+				CHECK_LEN(pos, 1);
+				this_char = str[pos++];
 				/* check if this is the first of a 2-byte sequence */
-				if ( (this_char >= 0x81 && this_char <= 0x9f) ||
-					 (this_char >= 0xe0 && this_char <= 0xef)
-					) {
+				if ((this_char >= 0x81 && this_char <= 0x9f) ||
+					(this_char >= 0xe0 && this_char <= 0xfc)) {
 					/* peek at the next char */
 					CHECK_LEN(pos, 1);
-					next_char = str[pos];
+					next_char = str[pos++];
 					if ((next_char >= 0x40 && next_char <= 0x7e) ||
 						(next_char >= 0x80 && next_char <= 0xfc))
 					{
 						/* yes, this a wide char */
-						this_char <<= 8;
+						MB_WRITE(this_char);
 						MB_WRITE(next_char);
-						this_char |= next_char;
-						pos++;
+						this_char = (this_char << 8) | next_char;
+					} else {
+						MB_FAILURE(pos);
 					}
-					
+				} else {
+					MB_WRITE(this_char);
 				}
 				break;
 			}
 		case cs_eucjp:
 			{
+				CHECK_LEN(pos, 1);
+				this_char = str[pos++];
 				/* check if this is the first of a multi-byte sequence */
 				if (this_char >= 0xa1 && this_char <= 0xfe) {
 					/* peek at the next char */
 					CHECK_LEN(pos, 1);
-					next_char = str[pos];
+					next_char = str[pos++];
 					if (next_char >= 0xa1 && next_char <= 0xfe) {
 						/* yes, this a jis kanji char */
-						this_char <<= 8;
+						MB_WRITE(this_char);
 						MB_WRITE(next_char);
-						this_char |= next_char;
-						pos++;
+						this_char = (this_char << 8) | next_char;
+					} else {
+						MB_FAILURE(pos);
 					}
-					
 				} else if (this_char == 0x8e) {
 					/* peek at the next char */
 					CHECK_LEN(pos, 1);
-					next_char = str[pos];
+					next_char = str[pos++];
 					if (next_char >= 0xa1 && next_char <= 0xdf) {
 						/* JIS X 0201 kana */
-						this_char <<= 8;
+						MB_WRITE(this_char);
 						MB_WRITE(next_char);
-						this_char |= next_char;
-						pos++;
+						this_char = (this_char << 8) | next_char;
+					} else {
+						MB_FAILURE(pos);
 					}
-					
 				} else if (this_char == 0x8f) {
 					/* peek at the next two char */
 					unsigned char next2_char;
 					CHECK_LEN(pos, 2);
 					next_char = str[pos];
-					next2_char = str[pos+1];
+					next2_char = str[pos + 1];
+					pos += 2;
 					if ((next_char >= 0xa1 && next_char <= 0xfe) &&
 						(next2_char >= 0xa1 && next2_char <= 0xfe)) {
 						/* JIS X 0212 hojo-kanji */
-						this_char <<= 8;
+						MB_WRITE(this_char);
 						MB_WRITE(next_char);
-						this_char |= next_char;
-						pos++;
-						this_char <<= 8;
 						MB_WRITE(next2_char);
-						this_char |= next2_char;
-						pos++;
+						this_char = (this_char << 16) | (next_char << 8) | next2_char;
+					} else {
+						MB_FAILURE(pos);
 					}
-					
+				} else {
+					MB_WRITE(this_char);
 				}
 				break;
 			}
 		default:
+			/* single-byte charsets */
+			CHECK_LEN(pos, 1);
+			this_char = str[pos++];
+			MB_WRITE(this_char);
 			break;
 	}
 	MB_RETURN;
@@ -1133,7 +1133,7 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, int oldlen, int *ne
 		unsigned char mbsequence[16];	/* allow up to 15 characters in a multibyte sequence */
 		int mbseqlen = sizeof(mbsequence);
 		int status = SUCCESS;
-		unsigned short this_char = get_next_char(charset, old, oldlen, &i, mbsequence, &mbseqlen, &status);
+		unsigned int this_char = get_next_char(charset, old, oldlen, &i, mbsequence, &mbseqlen, &status);
 
 		if(status == FAILURE) {
 			/* invalid MB sequence */
diff --git a/ext/standard/html.h b/ext/standard/html.h
index 9cd9e8b..86bae2d 100644
--- a/ext/standard/html.h
+++ b/ext/standard/html.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: html.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: html.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef HTML_H
 #define HTML_H
diff --git a/ext/standard/http.c b/ext/standard/http.c
index e3ee24f..3f57bbe 100644
--- a/ext/standard/http.c
+++ b/ext/standard/http.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: http.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: http.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_http.h"
 #include "php_ini.h"
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index c1757d1..5a30d7f 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    |          Sara Golemon <pollita at php.net>                              |
    +----------------------------------------------------------------------+
  */
-/* $Id: http_fopen_wrapper.c 286790 2009-08-04 09:24:48Z tony2001 $ */ 
+/* $Id: http_fopen_wrapper.c 294506 2010-02-04 09:17:20Z pajoye $ */ 
 
 #include "php.h"
 #include "php_globals.h"
@@ -416,15 +416,19 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 	}
 
 	/* auth header if it was specified */
-	if (((have_header & HTTP_HEADER_AUTH) == 0) && resource->user && resource->pass)	{
+	if (((have_header & HTTP_HEADER_AUTH) == 0) && resource->user) {
 		/* decode the strings first */
 		php_url_decode(resource->user, strlen(resource->user));
-		php_url_decode(resource->pass, strlen(resource->pass));
 
 		/* scratch is large enough, since it was made large enough for the whole URL */
 		strcpy(scratch, resource->user);
 		strcat(scratch, ":");
-		strcat(scratch, resource->pass);
+
+		/* Note: password is optional! */
+		if (resource->pass) {
+			php_url_decode(resource->pass, strlen(resource->pass));
+			strcat(scratch, resource->pass);
+		}
 
 		tmp = (char*)php_base64_encode((unsigned char*)scratch, strlen(scratch), NULL);
 		
@@ -610,6 +614,13 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 		size_t http_header_line_length;
 		if (php_stream_get_line(stream, http_header_line, HTTP_HEADER_BLOCK_SIZE, &http_header_line_length) && *http_header_line != '\n' && *http_header_line != '\r') {
 			char *e = http_header_line + http_header_line_length - 1;
+			if (*e != '\n') {
+				do { /* partial header */
+					php_stream_get_line(stream, http_header_line, HTTP_HEADER_BLOCK_SIZE, &http_header_line_length);
+					e = http_header_line + http_header_line_length - 1;
+				} while (*e != '\n');
+				continue;
+			}
 			while (*e == '\n' || *e == '\r') {
 				e--;
 			}
@@ -739,7 +750,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 			s++;	\
 		}	\
 	}	\
-}	\
+}
 			/* check for control characters in login, password & path */
 			if (strncasecmp(new_path, "http://", sizeof("http://") - 1) || strncasecmp(new_path, "https://", sizeof("https://") - 1)) {
 				CHECK_FOR_CNTRL_CHARS(resource->user)
diff --git a/ext/standard/image.c b/ext/standard/image.c
index b6d41f4..689f4a8 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: image.c 277324 2009-03-17 03:25:57Z scottmac $ */
+/* $Id: image.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include <stdio.h>
diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c
index d66921e..e64365f 100644
--- a/ext/standard/incomplete_class.c
+++ b/ext/standard/incomplete_class.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: incomplete_class.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: incomplete_class.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "basic_functions.h"
diff --git a/ext/standard/info.c b/ext/standard/info.c
index fd5eeac..7746d06 100644
--- a/ext/standard/info.c
+++ b/ext/standard/info.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: info.c 289430 2009-10-09 17:15:46Z pajoye $ */
+/* $Id: info.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_ini.h"
diff --git a/ext/standard/info.h b/ext/standard/info.h
index 173415b..4eaf06e 100644
--- a/ext/standard/info.h
+++ b/ext/standard/info.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: info.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: info.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef INFO_H
 #define INFO_H
diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c
index 93b144c..b5c0b25 100644
--- a/ext/standard/iptc.c
+++ b/ext/standard/iptc.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: iptc.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: iptc.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
  * Functions to parse & compse IPTC data.
diff --git a/ext/standard/lcg.c b/ext/standard/lcg.c
index 3850151..ae94f48 100644
--- a/ext/standard/lcg.c
+++ b/ext/standard/lcg.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: lcg.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: lcg.c 294448 2010-02-03 20:10:35Z pajoye $ */
 
 #include "php.h"
 #include "php_lcg.h"
@@ -78,7 +78,7 @@ static void lcg_seed(TSRMLS_D) /* {{{ */
 	struct timeval tv;
 
 	if (gettimeofday(&tv, NULL) == 0) {
-		LCG(s1) = tv.tv_sec ^ (~tv.tv_usec);
+		LCG(s1) = tv.tv_sec ^ (tv.tv_usec<<11);
 	} else {
 		LCG(s1) = 1;
 	}
@@ -88,6 +88,11 @@ static void lcg_seed(TSRMLS_D) /* {{{ */
 	LCG(s2) = (long) getpid();
 #endif
 
+	/* Add entropy to s2 by calling gettimeofday() again */
+	if (gettimeofday(&tv, NULL) == 0) {
+		LCG(s2) ^= (tv.tv_usec<<11);
+	}
+
 	LCG(seeded) = 1;
 }
 /* }}} */
diff --git a/ext/standard/levenshtein.c b/ext/standard/levenshtein.c
index b02dcc5..8a3b747 100644
--- a/ext/standard/levenshtein.c
+++ b/ext/standard/levenshtein.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Hartmut Holzgraefe <hholzgra at php.net>                        |
    +----------------------------------------------------------------------+
  */
-/* $Id: levenshtein.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: levenshtein.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include <stdlib.h>
diff --git a/ext/standard/link.c b/ext/standard/link.c
index 9236221..ac45b4b 100644
--- a/ext/standard/link.c
+++ b/ext/standard/link.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: link.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: link.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_filestat.h"
diff --git a/ext/standard/link_win32.c b/ext/standard/link_win32.c
index 97c7cb7..f7f5803 100644
--- a/ext/standard/link_win32.c
+++ b/ext/standard/link_win32.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: link_win32.c 287813 2009-08-27 14:45:41Z pajoye $ */
+/* $Id: link_win32.c 293036 2010-01-03 09:23:27Z sebastian $ */
 #ifdef PHP_WIN32
 
 #include "php.h"
diff --git a/ext/standard/mail.c b/ext/standard/mail.c
index 2825881..09fa2ef 100644
--- a/ext/standard/mail.c
+++ b/ext/standard/mail.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mail.c 282504 2009-06-21 15:29:16Z iliaa $ */
+/* $Id: mail.c 294548 2010-02-05 00:19:32Z pajoye $ */
 
 #include <stdlib.h>
 #include <ctype.h>
@@ -241,7 +241,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
 		php_basename(tmp, strlen(tmp), NULL, 0,&f, &f_len TSRMLS_CC);
 
 		if (headers != NULL) {
-			spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\r\n%s", php_getuid(), f, headers);
+			spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n%s", php_getuid(), f, headers);
 		} else {
 			spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n", php_getuid(), f);
 		}
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 89b7fcf..8a3949e 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: math.c 277398 2009-03-18 10:18:10Z dmitry $ */
+/* $Id: math.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_math.h"
diff --git a/ext/standard/md5.c b/ext/standard/md5.c
index 5ddd40f..e84fe4b 100644
--- a/ext/standard/md5.c
+++ b/ext/standard/md5.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: md5.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: md5.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "md5.h"
diff --git a/ext/standard/md5.h b/ext/standard/md5.h
index f9d55ab..b976752 100644
--- a/ext/standard/md5.h
+++ b/ext/standard/md5.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: md5.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: md5.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef MD5_H
 #define MD5_H
diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c
index 06186d0..bf10671 100644
--- a/ext/standard/metaphone.c
+++ b/ext/standard/metaphone.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: metaphone.c 283127 2009-06-30 11:46:20Z felipe $ */
+/* $Id: metaphone.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
 	Based on CPANs "Text-Metaphone-1.96" by Michael G Schwern <schwern at pobox.com> 
diff --git a/ext/standard/microtime.c b/ext/standard/microtime.c
index 9a7c179..116fb02 100644
--- a/ext/standard/microtime.c
+++ b/ext/standard/microtime.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: microtime.c 280906 2009-05-21 14:21:40Z lbarnaud $ */
+/* $Id: microtime.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/ext/standard/microtime.h b/ext/standard/microtime.h
index 8838d2c..419150d 100644
--- a/ext/standard/microtime.h
+++ b/ext/standard/microtime.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: microtime.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: microtime.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef MICROTIME_H
 #define MICROTIME_H
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
index 4aa4d56..0723ece 100644
--- a/ext/standard/pack.c
+++ b/ext/standard/pack.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Chris Schneider <cschneid at relog.ch>                          |
    +----------------------------------------------------------------------+
  */
-/* $Id: pack.c 287647 2009-08-24 18:40:13Z iliaa $ */
+/* $Id: pack.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/ext/standard/pack.h b/ext/standard/pack.h
index 70d3715..ba58997 100644
--- a/ext/standard/pack.h
+++ b/ext/standard/pack.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: pack.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pack.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PACK_H
 #define PACK_H
diff --git a/ext/standard/pageinfo.c b/ext/standard/pageinfo.c
index 89022c7..a1b323b 100644
--- a/ext/standard/pageinfo.c
+++ b/ext/standard/pageinfo.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: pageinfo.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pageinfo.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "pageinfo.h"
@@ -68,11 +68,7 @@ PHPAPI void php_statpage(TSRMLS_D)
 			BG(page_uid)   = pstat->st_uid;
 			BG(page_gid)   = pstat->st_gid;
 			BG(page_inode) = pstat->st_ino;
-#ifdef NETWARE
-			BG(page_mtime) = (pstat->st_mtime).tv_sec;
-#else
 			BG(page_mtime) = pstat->st_mtime;
-#endif
 		} else { /* handler for situations where there is no source file, ex. php -r */
 			BG(page_uid) = getuid();
 			BG(page_gid) = getgid();
diff --git a/ext/standard/pageinfo.h b/ext/standard/pageinfo.h
index 5722bed..0405de2 100644
--- a/ext/standard/pageinfo.h
+++ b/ext/standard/pageinfo.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: pageinfo.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pageinfo.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PAGEINFO_H
 #define PAGEINFO_H
diff --git a/ext/standard/php_array.h b/ext/standard/php_array.h
index 76a5a66..92a4f22 100644
--- a/ext/standard/php_array.h
+++ b/ext/standard/php_array.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_array.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_array.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_ARRAY_H
 #define PHP_ARRAY_H
diff --git a/ext/standard/php_assert.h b/ext/standard/php_assert.h
index f8a634a..bf4de1a 100644
--- a/ext/standard/php_assert.h
+++ b/ext/standard/php_assert.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_assert.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_assert.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_ASSERT_H
 #define PHP_ASSERT_H
diff --git a/ext/standard/php_browscap.h b/ext/standard/php_browscap.h
index 4107a4b..c26098a 100644
--- a/ext/standard/php_browscap.h
+++ b/ext/standard/php_browscap.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_browscap.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_browscap.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_BROWSCAP_H
 #define PHP_BROWSCAP_H
diff --git a/ext/standard/php_crypt.h b/ext/standard/php_crypt.h
index 8b06dad..c0dafe6 100644
--- a/ext/standard/php_crypt.h
+++ b/ext/standard/php_crypt.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_crypt.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_crypt.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_CRYPT_H
 #define PHP_CRYPT_H
diff --git a/ext/standard/php_crypt_r.c b/ext/standard/php_crypt_r.c
index d1e0cda..3d9d022 100644
--- a/ext/standard/php_crypt_r.c
+++ b/ext/standard/php_crypt_r.c
@@ -1,9 +1,9 @@
-/* $Id: php_crypt_r.c 290154 2009-11-02 20:46:52Z pajoye $ */
+/* $Id: php_crypt_r.c 293036 2010-01-03 09:23:27Z sebastian $ */
 /*
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/standard/php_crypt_r.h b/ext/standard/php_crypt_r.h
index 57143db..e5fbf26 100644
--- a/ext/standard/php_crypt_r.h
+++ b/ext/standard/php_crypt_r.h
@@ -1,9 +1,9 @@
-/* $Id: php_crypt_r.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_crypt_r.h 293036 2010-01-03 09:23:27Z sebastian $ */
 /*
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -49,6 +49,8 @@ PHPAPI char *php_crypt_r (const char *__key, const char *__salt, struct php_cryp
 extern char * php_md5_crypt_r(const char *pw, const char *salt, char *out);
 extern char * php_crypt_blowfish_rn(__CONST char *key, __CONST char *setting,
 	char *output, int size);
+extern char * php_sha512_crypt_r (const char *key, const char *salt, char *buffer, int buflen);
+extern char * php_sha256_crypt_r (const char *key, const char *salt, char *buffer, int buflen);
 
 #ifdef __cplusplus
 }
diff --git a/ext/standard/php_dir.h b/ext/standard/php_dir.h
index edc7615..5e80f3e 100644
--- a/ext/standard/php_dir.h
+++ b/ext/standard/php_dir.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_dir.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_dir.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_DIR_H
 #define PHP_DIR_H
diff --git a/ext/standard/php_dns.h b/ext/standard/php_dns.h
index 2fa6746..95900ae 100644
--- a/ext/standard/php_dns.h
+++ b/ext/standard/php_dns.h
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_dns.h 287120 2009-08-11 22:07:35Z scottmac $ */
+/* $Id: php_dns.h 289691 2009-10-16 02:10:52Z scottmac $ */
 
 #ifndef PHP_DNS_H
 #define PHP_DNS_H
@@ -28,8 +28,6 @@
     	((int)dns_search(res, dname, class, type, answer, anslen, (struct sockaddr *)&from, &fromsize))
 #define php_dns_free_handle(res) \
 		dns_free(res)
-#define php_dns_errno(_res) \
-			(NO_DATA)
 
 #elif defined(HAVE_RES_NSEARCH)
 #define php_dns_search(res, dname, class, type, answer, anslen) \
@@ -37,15 +35,11 @@
 #define php_dns_free_handle(res) \
 			res_nclose(res); \
 			php_dns_free_res(*res)
-#define php_dns_errno(res) \
-			(res->res_h_errno)
 
 #elif defined(HAVE_RES_SEARCH)
 #define php_dns_search(res, dname, class, type, answer, anslen) \
 			res_search(dname, class, type, answer, anslen)
 #define php_dns_free_handle(res) /* noop */
-#define php_dns_errno(res) \
-			(_res.res_h_errno)
 
 #endif
 
diff --git a/ext/standard/php_ext_syslog.h b/ext/standard/php_ext_syslog.h
index 0b6e3af..353c24e 100644
--- a/ext/standard/php_ext_syslog.h
+++ b/ext/standard/php_ext_syslog.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_ext_syslog.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_ext_syslog.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_EXT_SYSLOG_H
 #define PHP_EXT_SYSLOG_H
diff --git a/ext/standard/php_filestat.h b/ext/standard/php_filestat.h
index 4981055..7eee0fa 100644
--- a/ext/standard/php_filestat.h
+++ b/ext/standard/php_filestat.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_filestat.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_filestat.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_FILESTAT_H
 #define PHP_FILESTAT_H
@@ -24,6 +24,8 @@
 PHP_RINIT_FUNCTION(filestat);
 PHP_RSHUTDOWN_FUNCTION(filestat);
 
+PHP_FUNCTION(realpath_cache_size);
+PHP_FUNCTION(realpath_cache_get);
 PHP_FUNCTION(clearstatcache);
 PHP_FUNCTION(fileatime);
 PHP_FUNCTION(filectime);
diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c
index f3dbf91..808a973 100644
--- a/ext/standard/php_fopen_wrapper.c
+++ b/ext/standard/php_fopen_wrapper.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    |          Hartmut Holzgraefe <hholzgra at php.net>                       |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_fopen_wrapper.c 287507 2009-08-20 12:40:15Z jani $ */
+/* $Id: php_fopen_wrapper.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/ext/standard/php_fopen_wrappers.h b/ext/standard/php_fopen_wrappers.h
index 7709e3e..d9dee94 100644
--- a/ext/standard/php_fopen_wrappers.h
+++ b/ext/standard/php_fopen_wrappers.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_fopen_wrappers.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_fopen_wrappers.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_FOPEN_WRAPPERS_H
 #define PHP_FOPEN_WRAPPERS_H
diff --git a/ext/standard/php_ftok.h b/ext/standard/php_ftok.h
index c7e4018..ac023b7 100644
--- a/ext/standard/php_ftok.h
+++ b/ext/standard/php_ftok.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_ftok.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_ftok.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_FTOK_H
 #define PHP_FTOK_H
diff --git a/ext/standard/php_http.h b/ext/standard/php_http.h
index 6de68b4..f0ed15f 100644
--- a/ext/standard/php_http.h
+++ b/ext/standard/php_http.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_http.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_http.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_HTTP_H
 #define PHP_HTTP_H
diff --git a/ext/standard/php_image.h b/ext/standard/php_image.h
index f699dbb..093980a 100644
--- a/ext/standard/php_image.h
+++ b/ext/standard/php_image.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_image.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_image.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_IMAGE_H
 #define PHP_IMAGE_H
diff --git a/ext/standard/php_incomplete_class.h b/ext/standard/php_incomplete_class.h
index d84e7a5..3ec93c7 100644
--- a/ext/standard/php_incomplete_class.h
+++ b/ext/standard/php_incomplete_class.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_incomplete_class.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_incomplete_class.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_INCOMPLETE_CLASS_H
 #define PHP_INCOMPLETE_CLASS_H
diff --git a/ext/standard/php_iptc.h b/ext/standard/php_iptc.h
index 7a4e3ce..e47753c 100644
--- a/ext/standard/php_iptc.h
+++ b/ext/standard/php_iptc.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_iptc.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_iptc.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_IPTC_H
 #define PHP_IPTC_H
diff --git a/ext/standard/php_lcg.h b/ext/standard/php_lcg.h
index 58b7d33..8ccd218 100644
--- a/ext/standard/php_lcg.h
+++ b/ext/standard/php_lcg.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_lcg.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_lcg.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_LCG_H
 #define PHP_LCG_H
diff --git a/ext/standard/php_link.h b/ext/standard/php_link.h
index 8c63be6..916029d 100644
--- a/ext/standard/php_link.h
+++ b/ext/standard/php_link.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_link.h 273611 2009-01-16 01:00:22Z pajoye $ */
+/* $Id: php_link.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_LINK_H
 #define PHP_LINK_H
diff --git a/ext/standard/php_mail.h b/ext/standard/php_mail.h
index a3516dc..e8d3875 100644
--- a/ext/standard/php_mail.h
+++ b/ext/standard/php_mail.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_mail.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_mail.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_MAIL_H
 #define PHP_MAIL_H
diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h
index f130e2f..1d124f0 100644
--- a/ext/standard/php_math.h
+++ b/ext/standard/php_math.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_math.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_math.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_MATH_H
 #define PHP_MATH_H
diff --git a/ext/standard/php_metaphone.h b/ext/standard/php_metaphone.h
index 622aa31..da8c67b 100644
--- a/ext/standard/php_metaphone.h
+++ b/ext/standard/php_metaphone.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: php_metaphone.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_metaphone.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_METAPHONE_H
 #define PHP_METAPHONE_H
diff --git a/ext/standard/php_rand.h b/ext/standard/php_rand.h
index 220f436..887ac70 100644
--- a/ext/standard/php_rand.h
+++ b/ext/standard/php_rand.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -20,7 +20,7 @@
    | Based on code from: Shawn Cokus <Cokus at math.washington.edu>          |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_rand.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_rand.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_RAND_H
 #define	PHP_RAND_H
diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h
index 2989978..8dd9647 100644
--- a/ext/standard/php_smart_str.h
+++ b/ext/standard/php_smart_str.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_smart_str.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_smart_str.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SMART_STR_H
 #define PHP_SMART_STR_H
diff --git a/ext/standard/php_smart_str_public.h b/ext/standard/php_smart_str_public.h
index e189549..c851fac 100644
--- a/ext/standard/php_smart_str_public.h
+++ b/ext/standard/php_smart_str_public.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_smart_str_public.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_smart_str_public.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SMART_STR_PUBLIC_H
 #define PHP_SMART_STR_PUBLIC_H
diff --git a/ext/standard/php_standard.h b/ext/standard/php_standard.h
index 005fa29..447f6d7 100644
--- a/ext/standard/php_standard.h
+++ b/ext/standard/php_standard.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_standard.h 286857 2009-08-05 23:20:17Z scottmac $ */
+/* $Id: php_standard.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "basic_functions.h"
 #include "php_math.h"
diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h
index 4d85671..fd3c8b5 100644
--- a/ext/standard/php_string.h
+++ b/ext/standard/php_string.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_string.h 287198 2009-08-13 06:44:50Z stas $ */
+/* $Id: php_string.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
 
diff --git a/ext/standard/php_type.h b/ext/standard/php_type.h
index 9a8ae44..550d4d5 100644
--- a/ext/standard/php_type.h
+++ b/ext/standard/php_type.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_type.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_type.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_TYPE_H
 #define PHP_TYPE_H
diff --git a/ext/standard/php_uuencode.h b/ext/standard/php_uuencode.h
index b722e1b..d6432a6 100644
--- a/ext/standard/php_uuencode.h
+++ b/ext/standard/php_uuencode.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_uuencode.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_uuencode.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_UUENCODE_H
 #define PHP_UUENCODE_H
diff --git a/ext/standard/php_var.h b/ext/standard/php_var.h
index 442762d..76546f3 100644
--- a/ext/standard/php_var.h
+++ b/ext/standard/php_var.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_var.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_var.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_VAR_H
 #define PHP_VAR_H
diff --git a/ext/standard/php_versioning.h b/ext/standard/php_versioning.h
index ecfd948..6a91e61 100644
--- a/ext/standard/php_versioning.h
+++ b/ext/standard/php_versioning.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_versioning.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_versioning.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_VERSIONING_H
 #define PHP_VERSIONING_H
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index d7dbccd..afb5071 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Wez Furlong <wez at thebrainroom.com>                           |
    +----------------------------------------------------------------------+
  */
-/* $Id: proc_open.c 286752 2009-08-03 19:05:56Z felipe $ */
+/* $Id: proc_open.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__))
 # define _BSD_SOURCE 		/* linux wants this when XOPEN mode is on */
diff --git a/ext/standard/proc_open.h b/ext/standard/proc_open.h
index 473c9f0..40249f2 100644
--- a/ext/standard/proc_open.h
+++ b/ext/standard/proc_open.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Wez Furlong <wez at thebrainroom.com>                           |
    +----------------------------------------------------------------------+
  */
-/* $Id: proc_open.h 284431 2009-07-20 11:48:04Z gwynne $ */
+/* $Id: proc_open.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef PHP_WIN32
 typedef HANDLE php_file_descriptor_t;
diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c
index c24ed0b..7f0fae0 100644
--- a/ext/standard/quot_print.c
+++ b/ext/standard/quot_print.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: quot_print.c 272979 2009-01-07 17:20:18Z felipe $ */
+/* $Id: quot_print.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdlib.h>
 
diff --git a/ext/standard/quot_print.h b/ext/standard/quot_print.h
index 8f25c0b..4a769e0 100644
--- a/ext/standard/quot_print.h
+++ b/ext/standard/quot_print.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: quot_print.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: quot_print.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef QUOT_PRINT_H
 #define QUOT_PRINT_H
diff --git a/ext/standard/rand.c b/ext/standard/rand.c
index 4b1cac3..db5523a 100644
--- a/ext/standard/rand.c
+++ b/ext/standard/rand.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -23,7 +23,7 @@
    |                     Shawn Cokus <Cokus at math.washington.edu>          |
    +----------------------------------------------------------------------+
  */
-/* $Id: rand.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: rand.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdlib.h>
 
diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c
index 093c08a..81a49e4 100644
--- a/ext/standard/scanf.c
+++ b/ext/standard/scanf.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: scanf.c 278157 2009-04-02 05:17:36Z kalle $ */
+/* $Id: scanf.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
 	scanf.c --
diff --git a/ext/standard/scanf.h b/ext/standard/scanf.h
index b1fbd49..46243bd 100644
--- a/ext/standard/scanf.h
+++ b/ext/standard/scanf.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: scanf.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: scanf.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef  SCANF_H
 #define  SCANF_H
diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c
index 09c1943..084de7f 100644
--- a/ext/standard/sha1.c
+++ b/ext/standard/sha1.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: sha1.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sha1.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/ext/standard/sha1.h b/ext/standard/sha1.h
index 885d988..cd7e631 100644
--- a/ext/standard/sha1.h
+++ b/ext/standard/sha1.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: sha1.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sha1.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SHA1_H
 #define SHA1_H
diff --git a/ext/standard/soundex.c b/ext/standard/soundex.c
index aa42d95..d22d361 100644
--- a/ext/standard/soundex.c
+++ b/ext/standard/soundex.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Bjørn Borud - Guardian Networks AS <borud at guardian.no>       |
    +----------------------------------------------------------------------+
  */
-/* $Id: soundex.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: soundex.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include <stdlib.h>
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index b57c7f9..a030060 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.c 286744 2009-08-03 15:58:18Z felipe $ */
+/* $Id: streamsfuncs.c 293995 2010-01-25 15:57:24Z johannes $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -484,9 +484,7 @@ PHP_FUNCTION(stream_get_meta_data)
 	
 	if (stream->wrapperdata) {
 		MAKE_STD_ZVAL(newval);
-		*newval = *(stream->wrapperdata);
-		zval_copy_ctor(newval);
-		INIT_PZVAL(newval);
+		MAKE_COPY_ZVAL(&stream->wrapperdata, newval);
 
 		add_assoc_zval(return_value, "wrapper_data", newval);
 	}
@@ -1444,6 +1442,26 @@ PHP_FUNCTION(stream_socket_enable_crypto)
 }
 /* }}} */
 
+/* {{{ proto string stream_resolve_include_path(string filename)
+Determine what file will be opened by calls to fopen() with a relative path */
+PHP_FUNCTION(stream_resolve_include_path)
+{
+	char *filename, *resolved_path; 
+	int filename_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
+		return;
+	}
+
+	resolved_path = zend_resolve_path(filename, filename_len TSRMLS_CC);
+
+	if (resolved_path) {
+		RETURN_STRING(resolved_path, 0);
+	}
+	RETURN_FALSE;
+}
+/* }}} */
+
 /* {{{ proto bool stream_is_local(resource stream|string url) U
 */
 PHP_FUNCTION(stream_is_local)
diff --git a/ext/standard/streamsfuncs.h b/ext/standard/streamsfuncs.h
index 4519520..e4e20e1 100644
--- a/ext/standard/streamsfuncs.h
+++ b/ext/standard/streamsfuncs.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.h 274392 2009-01-23 15:49:49Z kalle $ */
+/* $Id: streamsfuncs.h 293995 2010-01-25 15:57:24Z johannes $ */
 
 /* Flags for stream_socket_client */
 #define PHP_STREAM_CLIENT_PERSISTENT	1
@@ -56,6 +56,7 @@ PHP_FUNCTION(stream_filter_append);
 PHP_FUNCTION(stream_filter_remove);
 PHP_FUNCTION(stream_socket_enable_crypto);
 PHP_FUNCTION(stream_socket_shutdown);
+PHP_FUNCTION(stream_resolve_include_path);
 PHP_FUNCTION(stream_is_local);
 PHP_FUNCTION(stream_supports_lock);
 
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 88d3add..2ebd18a 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: string.c 287916 2009-08-31 12:28:46Z iliaa $ */
+/* $Id: string.c 294517 2010-02-04 09:44:16Z pajoye $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -3530,9 +3530,7 @@ static void php_str_replace_in_subject(zval *search, zval *replace, zval **subje
 	/* If search is an array */
 	if (Z_TYPE_P(search) == IS_ARRAY) {
 		/* Duplicate subject string for repeated replacement */
-		*result = **subject;
-		zval_copy_ctor(result);
-		INIT_PZVAL(result);
+		MAKE_COPY_ZVAL(subject, result);
 		
 		zend_hash_internal_pointer_reset(Z_ARRVAL_P(search));
 
@@ -3616,9 +3614,7 @@ static void php_str_replace_in_subject(zval *search, zval *replace, zval **subje
 													Z_STRVAL_P(search), Z_STRLEN_P(search),
 													Z_STRVAL_P(replace), Z_STRLEN_P(replace), &Z_STRLEN_P(result), case_sensitivity, replace_count);
 		} else {
-			*result = **subject;
-			zval_copy_ctor(result);
-			INIT_PZVAL(result);
+			MAKE_COPY_ZVAL(subject, result);
 		}
 	}
 }
@@ -3918,7 +3914,7 @@ PHP_FUNCTION(nl2br)
 	tmp = str;
 	end = str + str_len;
 	
-	/* it is really faster to scan twice and allocate mem once insted scanning once
+	/* it is really faster to scan twice and allocate mem once instead of scanning once
 	   and constantly reallocing */
 	while (tmp < end) {
 		if (*tmp == '\r') {
@@ -4247,7 +4243,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
 {
 	char *tbuf, *buf, *p, *tp, *rp, c, lc;
 	int br, i=0, depth=0, in_q = 0;
-	int state = 0;
+	int state = 0, pos;
 
 	if (stateptr)
 		state = *stateptr;
@@ -4260,7 +4256,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
 	br = 0;
 	if (allow) {
 		php_strtolower(allow, allow_len);
-		tbuf = emalloc(PHP_TAG_BUF_SIZE+1);
+		tbuf = emalloc(PHP_TAG_BUF_SIZE + 1);
 		tp = tbuf;
 	} else {
 		tbuf = tp = NULL;
@@ -4281,7 +4277,11 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
 					lc = '<';
 					state = 1;
 					if (allow) {
-						tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp);
+						if (tp - tbuf >= PHP_TAG_BUF_SIZE) {
+							pos = tp - tbuf;
+							tbuf = erealloc(tbuf, (tp - tbuf) + PHP_TAG_BUF_SIZE + 1);
+							tp = tbuf + pos;
+						}
 						*(tp++) = '<';
 				 	}
 				} else if (state == 1) {
@@ -4296,7 +4296,11 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
 						br++;
 					}
 				} else if (allow && state == 1) {
-					tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp);
+					if (tp - tbuf >= PHP_TAG_BUF_SIZE) {
+						pos = tp - tbuf;
+						tbuf = erealloc(tbuf, (tp - tbuf) + PHP_TAG_BUF_SIZE + 1);
+						tp = tbuf + pos;
+					}
 					*(tp++) = c;
 				} else if (state == 0) {
 					*(rp++) = c;
@@ -4310,7 +4314,11 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
 						br--;
 					}
 				} else if (allow && state == 1) {
-					tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp);
+					if (tp - tbuf >= PHP_TAG_BUF_SIZE) {
+						pos = tp - tbuf;
+						tbuf = erealloc(tbuf, (tp - tbuf) + PHP_TAG_BUF_SIZE + 1);
+						tp = tbuf + pos;
+					}
 					*(tp++) = c;
 				} else if (state == 0) {
 					*(rp++) = c;
@@ -4332,7 +4340,11 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
 						lc = '>';
 						in_q = state = 0;
 						if (allow) {
-							tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp);
+							if (tp - tbuf >= PHP_TAG_BUF_SIZE) {
+								pos = tp - tbuf;
+								tbuf = erealloc(tbuf, (tp - tbuf) + PHP_TAG_BUF_SIZE + 1);
+								tp = tbuf + pos;
+							}
 							*(tp++) = '>';
 							*tp='\0';
 							if (php_tag_find(tbuf, tp-tbuf, allow)) {
@@ -4382,10 +4394,14 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
 				} else if (state == 0) {
 					*(rp++) = c;
 				} else if (allow && state == 1) {
-					tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp);
+					if (tp - tbuf >= PHP_TAG_BUF_SIZE) {
+						pos = tp - tbuf;
+						tbuf = erealloc(tbuf, (tp - tbuf) + PHP_TAG_BUF_SIZE + 1);
+						tp = tbuf + pos;
+					}
 					*(tp++) = c;
 				}
-				if (state && p != buf && *(p-1) != '\\' && (!in_q || *p == in_q)) {
+				if (state && p != buf && (state == 1 || *(p-1) != '\\') && (!in_q || *p == in_q)) {
 					if (in_q) {
 						in_q = 0;
 					} else {
@@ -4403,7 +4419,11 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
 					if (state == 0) {
 						*(rp++) = c;
 					} else if (allow && state == 1) {
-						tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp);
+						if (tp - tbuf >= PHP_TAG_BUF_SIZE) {
+							pos = tp - tbuf;
+							tbuf = erealloc(tbuf, (tp - tbuf) + PHP_TAG_BUF_SIZE + 1);
+							tp = tbuf + pos;
+						}
 						*(tp++) = c;
 					}
 				}
@@ -4458,7 +4478,11 @@ reg_char:
 				if (state == 0) {
 					*(rp++) = c;
 				} else if (allow && state == 1) {
-					tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp);
+					if (tp - tbuf >= PHP_TAG_BUF_SIZE) {
+						pos = tp - tbuf;
+						tbuf = erealloc(tbuf, (tp - tbuf) + PHP_TAG_BUF_SIZE + 1);
+						tp = tbuf + pos;
+					}
 					*(tp++) = c;
 				} 
 				break;
diff --git a/ext/standard/strnatcmp.c b/ext/standard/strnatcmp.c
index 3a60bc7..e1c6960 100644
--- a/ext/standard/strnatcmp.c
+++ b/ext/standard/strnatcmp.c
@@ -38,7 +38,7 @@
 
 #if 0
 static char const *version UNUSED =
-    "$Id: strnatcmp.c 289419 2009-10-09 14:33:38Z pajoye $";
+    "$Id: strnatcmp.c 288896 2009-09-28 13:29:53Z rasmus $";
 #endif
 /* {{{ compare_right
  */
diff --git a/ext/standard/syslog.c b/ext/standard/syslog.c
index aa8c472..8208319 100644
--- a/ext/standard/syslog.c
+++ b/ext/standard/syslog.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: syslog.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: syslog.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/ext/standard/tests/array/array_flip_variation2.phpt b/ext/standard/tests/array/array_flip_variation2.phpt
index 1474a6955b5229638e25153cf4c0e448be4b662d..997c391306e5cf751d4603cad8fb3c679155dab4 100644
GIT binary patch
delta 21
ccmZn?Y!=*L%E79dqN$)XnVZRcash`B06Rnl0ssI2

delta 35
qcmZn`Y!cjH%E4lysh~8Oo5@^=D={yHGcl()Ux}-h%OyWAl?wow at d()f

diff --git a/ext/standard/tests/array/bug50006.phpt b/ext/standard/tests/array/bug50006.phpt
new file mode 100644
index 0000000..f03a002
--- /dev/null
+++ b/ext/standard/tests/array/bug50006.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #50006 (Segfault caused by uksort())
+--FILE--
+<?php
+
+$data = array(
+    'bar-bazbazbaz.' => 0,
+    'bar-bazbazbaz-' => 0,
+    'foo' => 0,
+);
+uksort($data, 'magic_sort_cmp');
+print_r($data);
+
+function magic_sort_cmp($a, $b) {
+  $a = substr($a, 1);
+  $b = substr($b, 1);
+  if (!$a) return $b ? -1 : 0;
+  if (!$b) return 1;
+  return magic_sort_cmp($a, $b);
+}
+
+?>
+--EXPECTF--
+Array
+(
+    [foo] => 0
+    [bar-bazbazbaz-] => 0
+    [bar-bazbazbaz.] => 0
+)
diff --git a/ext/standard/tests/array/bug50006_1.phpt b/ext/standard/tests/array/bug50006_1.phpt
new file mode 100644
index 0000000..fbb7ddd
--- /dev/null
+++ b/ext/standard/tests/array/bug50006_1.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #50006 (Segfault caused by uksort()) - usort variant
+--FILE--
+<?php
+
+$data = array(
+    'bar-bazbazbaz.',
+    'bar-bazbazbaz-', 
+    'foo'
+);
+usort($data, 'magic_sort_cmp');
+print_r($data);
+
+function magic_sort_cmp($a, $b) {
+  $a = substr($a, 1);
+  $b = substr($b, 1);
+  if (!$a) return $b ? -1 : 0;
+  if (!$b) return 1;
+  return magic_sort_cmp($a, $b);
+}
+
+?>
+--EXPECTF--
+Array
+(
+    [0] => foo
+    [1] => bar-bazbazbaz-
+    [2] => bar-bazbazbaz.
+)
diff --git a/ext/standard/tests/array/bug50006_2.phpt b/ext/standard/tests/array/bug50006_2.phpt
new file mode 100644
index 0000000..19c0d14
--- /dev/null
+++ b/ext/standard/tests/array/bug50006_2.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #50006 (Segfault caused by uksort()) - uasort variant
+--FILE--
+<?php
+
+$data = array(
+    'bar-bazbazbaz.',
+    'bar-bazbazbaz-', 
+    'foo'
+);
+uasort($data, 'magic_sort_cmp');
+print_r($data);
+
+function magic_sort_cmp($a, $b) {
+  $a = substr($a, 1);
+  $b = substr($b, 1);
+  if (!$a) return $b ? -1 : 0;
+  if (!$b) return 1;
+  return magic_sort_cmp($a, $b);
+}
+
+?>
+--EXPECTF--
+Array
+(
+    [2] => foo
+    [1] => bar-bazbazbaz-
+    [0] => bar-bazbazbaz.
+)
diff --git a/ext/standard/tests/array/uasort_variation5.phpt b/ext/standard/tests/array/uasort_variation5.phpt
index 22d9da3..e6996a5 100644
--- a/ext/standard/tests/array/uasort_variation5.phpt
+++ b/ext/standard/tests/array/uasort_variation5.phpt
@@ -139,7 +139,7 @@ array(4) {
   [1]=>
   string(7) "Heredoc"
   [3]=>
-  string(43) "heredoc string	with!@# and 123
+  string(4%d) "heredoc string	with!@# and 123
 Test this!!!"
 }
 Done
diff --git a/ext/standard/tests/bug49244.phpt b/ext/standard/tests/bug49244.phpt
new file mode 100644
index 0000000..1ba24fb
--- /dev/null
+++ b/ext/standard/tests/bug49244.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #49244 (Floating point NaN cause garbage characters)
+--FILE--
+<?php
+
+for ($i = 0; $i < 10; $i++) {
+	printf("{%f} %1\$f\n", pow(-1.0, 0.3));
+	printf(b"{%f} %1\$f\n", pow(-1.0, 0.3));
+}
+
+?>
+--EXPECT--
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
+{NaN} NaN
diff --git a/ext/standard/tests/file/005_variation2-win32.phpt b/ext/standard/tests/file/005_variation2-win32.phpt
index 513182d..45dcbc5 100644
--- a/ext/standard/tests/file/005_variation2-win32.phpt
+++ b/ext/standard/tests/file/005_variation2-win32.phpt
@@ -108,18 +108,18 @@ Warning: filectime(): stat failed for | in %s on line %d
 
 
 *** testing touch ***
-Warning: touch(): Unable to create file  because %s in %s on line %d
+Warning: touch(): %s in %s on line %d
 bool(false)
 
-Warning: touch(): Unable to create file  because %s in %s on line %d
+Warning: touch(): %s in %s on line %d
 bool(false)
 
-Warning: touch(): Unable to create file  because %s in %s on line %d
+Warning: touch(): %s in %s on line %d
 bool(false)
 
-Warning: touch(): Unable to create file   because %s in %s on line %d
+Warning: touch(): %s in %s on line %d
 bool(false)
 
-Warning: touch(): Unable to create file | because %s in %s on line %d
+Warning: touch(): %s in %s on line %d
 bool(false)
 Done
diff --git a/ext/standard/tests/file/bug26615.phpt b/ext/standard/tests/file/bug26615.phpt
index 9fee92a..3689fdf 100644
--- a/ext/standard/tests/file/bug26615.phpt
+++ b/ext/standard/tests/file/bug26615.phpt
@@ -1,6 +1,6 @@
 --TEST--
 Bug #26615 (exec crash on long input lines)
---INI---
+--INI--
 variables_order=E
 --FILE--
 <?php
diff --git a/ext/standard/tests/file/bug47767.phpt b/ext/standard/tests/file/bug47767.phpt
index 62388c2..312476a 100644
--- a/ext/standard/tests/file/bug47767.phpt
+++ b/ext/standard/tests/file/bug47767.phpt
@@ -10,6 +10,11 @@ if(substr(PHP_OS, 0, 3) != 'WIN' ) {
 if(PHP_WINDOWS_VERSION_MAJOR < 6)  {
         die('skip windows version 6.0+ only test');
 }
+
+$ret = exec('mklink rename_variation13tmp.lnk ' . __FILE__ .' 2>&1', $out);
+if (strpos($ret, 'privilege')) {
+	die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
+}
 ?>
 --FILE--
 <?php
diff --git a/ext/standard/tests/file/chmod_variation3.phpt b/ext/standard/tests/file/chmod_variation3.phpt
index c2dd607..df18ccf 100644
--- a/ext/standard/tests/file/chmod_variation3.phpt
+++ b/ext/standard/tests/file/chmod_variation3.phpt
@@ -159,11 +159,11 @@ Error: 2 - chmod() expects parameter 1 to be string, array given, %s(%d)
 NULL
 
 --uppercase NULL--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
 bool(false)
 
 --lowercase null--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
 bool(false)
 
 --lowercase true--
@@ -171,7 +171,7 @@ Error: 2 - chmod(): No such file or directory, %s(%d)
 bool(false)
 
 --lowercase false--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
 bool(false)
 
 --uppercase TRUE--
@@ -179,15 +179,15 @@ Error: 2 - chmod(): No such file or directory, %s(%d)
 bool(false)
 
 --uppercase FALSE--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
 bool(false)
 
 --empty string DQ--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
 bool(false)
 
 --empty string SQ--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
 bool(false)
 
 --instance of classWithToString--
@@ -199,11 +199,11 @@ Error: 2 - chmod() expects parameter 1 to be string, object given, %s(%d)
 NULL
 
 --undefined var--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
 bool(false)
 
 --unset var--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
 bool(false)
 ===DONE===
 
diff --git a/ext/standard/tests/file/fflush_basic.phpt b/ext/standard/tests/file/fflush_basic.phpt
index 5cd81d7..f375c4f 100755
--- a/ext/standard/tests/file/fflush_basic.phpt
+++ b/ext/standard/tests/file/fflush_basic.phpt
@@ -21,6 +21,10 @@ $file_handle = fopen($filename, "w");
 if($file_handle == false)
   exit("Error:failed to open file $filename");
 
+if(substr(PHP_OS, 0, 3) == "WIN")  {
+	$data = str_replace("\r",'', $data);
+}
+
 // writing data to the file
 var_dump( fwrite($file_handle, $data) );
 var_dump( fflush($file_handle) );
diff --git a/ext/standard/tests/file/fgetss_basic1.phpt b/ext/standard/tests/file/fgetss_basic1.phpt
index ab9eae0..4c5881d 100644
--- a/ext/standard/tests/file/fgetss_basic1.phpt
+++ b/ext/standard/tests/file/fgetss_basic1.phpt
@@ -22,7 +22,9 @@ is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
 <html> html </html> <?php echo "php"; ?>
 EOT;
 
-
+if(substr(PHP_OS, 0, 3) == "WIN")  {
+	$string_with_tags = str_replace("\r",'', $string_with_tags);
+}
 /* try reading the file opened in different modes of reading */
 $file_modes = array("r","rb", "rt","r+", "r+b", "r+t");
 
@@ -62,7 +64,7 @@ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
 
 echo "Done\n";
 ?>
---EXPECTF--
+--EXPECT--
 *** Testing fgetss() : Basic operations ***
 
 -- Testing fgetss() with file opened using r mode --
diff --git a/ext/standard/tests/file/fgetss_basic2-win32.phpt b/ext/standard/tests/file/fgetss_basic2-win32.phpt
index 5a87b4c..9187fe5 100644
--- a/ext/standard/tests/file/fgetss_basic2-win32.phpt
+++ b/ext/standard/tests/file/fgetss_basic2-win32.phpt
@@ -29,7 +29,9 @@ $string_with_tags = <<<EOT
 is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
 <html> html </html> <?php echo "php"; ?>
 EOT;
-
+if(substr(PHP_OS, 0, 3) == "WIN")  {
+	$string_with_tags = str_replace("\r",'', $string_with_tags);
+}
 $filename = dirname(__FILE__)."/fgetss_basic2.tmp"; 
 
 /* try reading the file opened in different modes of reading */
diff --git a/ext/standard/tests/file/fgetss_variation1-win32.phpt b/ext/standard/tests/file/fgetss_variation1-win32.phpt
index dc3ee93..0aca5d3 100644
--- a/ext/standard/tests/file/fgetss_variation1-win32.phpt
+++ b/ext/standard/tests/file/fgetss_variation1-win32.phpt
@@ -36,6 +36,10 @@ this text contains some html tags <body> body </body> <br> br </br>
 this is the line with \n character. 
 EOT;
 
+if(substr(PHP_OS, 0, 3) == "WIN")  {
+	$string_with_tags = str_replace("\r",'', $string_with_tags);
+}
+
 $filename = dirname(__FILE__)."/fgetss_variation1.tmp";
 
 /* try reading the file opened in different modes of reading */
@@ -73,7 +77,7 @@ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
 
 echo "Done\n";
 ?>
---EXPECTF--
+--EXPECT--
 *** Testing fgetss() : usage variations ***
 
 -- Testing fgetss() with file opened using w mode --
diff --git a/ext/standard/tests/file/fgetss_variation3-win32.phpt b/ext/standard/tests/file/fgetss_variation3-win32.phpt
index ea8ee2f..7539b36 100644
--- a/ext/standard/tests/file/fgetss_variation3-win32.phpt
+++ b/ext/standard/tests/file/fgetss_variation3-win32.phpt
@@ -35,6 +35,10 @@ this text contains some html tags <body> body </body> <br> br </br>
 this is the line with \n character. 
 EOT;
 
+if(substr(PHP_OS, 0, 3) == "WIN")  {
+	$string_with_tags = str_replace("\r",'', $string_with_tags);
+}
+
 $filename = dirname(__FILE__)."/fgetss_variation3.tmp"; 
 
 /* try reading the file opened in different modes of reading */
@@ -76,7 +80,7 @@ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
 
 echo "Done\n";
 ?>
---EXPECTF--
+--EXPECT--
 *** Testing fgetss() : usage variations ***
 
 -- Testing fgetss() with file opened using w+ mode --
diff --git a/ext/standard/tests/file/fgetss_variation4.phpt b/ext/standard/tests/file/fgetss_variation4.phpt
index 134a965..6c201d1 100644
--- a/ext/standard/tests/file/fgetss_variation4.phpt
+++ b/ext/standard/tests/file/fgetss_variation4.phpt
@@ -1,5 +1,10 @@
 --TEST--
 Test fgetss() function : usage variations - read  modes, file pointer at EOF
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip not for Windows");
+?>
 --FILE--
 <?php
 /*
diff --git a/ext/standard/tests/file/fgetss_variation5-win32.phpt b/ext/standard/tests/file/fgetss_variation5-win32.phpt
index d806ddd..cedc7b9 100644
--- a/ext/standard/tests/file/fgetss_variation5-win32.phpt
+++ b/ext/standard/tests/file/fgetss_variation5-win32.phpt
@@ -33,6 +33,9 @@ this is a line with more than eighty character,want to check line splitting corr
 this text contains some html tags <body> body </body> <br> br </br>
 this is the line with \n character. 
 EOT;
+if(substr(PHP_OS, 0, 3) == "WIN")  {
+	$string_with_tags = str_replace("\r",'', $string_with_tags);
+}
 
 $filename = dirname(__FILE__)."/fgetss_variation5.tmp"; 
 
@@ -77,7 +80,7 @@ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
 
 echo "Done\n";
 ?>
---EXPECTF--
+--EXPECT--
 *** Testing fgetss() : usage variations ***
 
 -- Testing fgetss() with file opened using w+ mode --
diff --git a/ext/standard/tests/file/file.inc b/ext/standard/tests/file/file.inc
index efb425c..c0f86e7 100644
--- a/ext/standard/tests/file/file.inc
+++ b/ext/standard/tests/file/file.inc
@@ -347,16 +347,16 @@ function create_files( $file_path,
      filled => total files filled, always returned as 1
      perms_changed => total files permission changed
 */
-function create_links( $file_path,
-		       $filename,
-                       $link_count = 1,
-                       $link_type = "soft",
-                       $link_size = 1024,
-                       $link_name_prefix = "link",
-                       $link_name_suffix = 1,
-                       $link_file_content = "text",
-                       $link_perms = 0755,
-                       $link_file_extension = ".tmp"
+function create_links($file_path,
+                      $filename,
+                      $link_count = 1,
+                      $link_type = "soft",
+                      $link_size = 1024,
+                      $link_name_prefix = "link",
+                      $link_name_suffix = 1,
+                      $link_file_content = "text",
+                      $link_perms = 0755,
+                      $link_file_extension = ".tmp"
                      )
 {
   $return_value = array('created' => 0, 'filled' => 0, 'perms_changed' => 0);
diff --git a/ext/standard/tests/file/fopen_variation10-win32.phpt b/ext/standard/tests/file/fopen_variation10-win32.phpt
index bf8d388..c949f86 100644
--- a/ext/standard/tests/file/fopen_variation10-win32.phpt
+++ b/ext/standard/tests/file/fopen_variation10-win32.phpt
@@ -6,6 +6,11 @@ Dave Kelsey <d_kelsey at uk.ibm.com>
 <?php
 if(substr(PHP_OS, 0, 3) != "WIN")
   die("skip Run only on Windows");
+
+if (!is_writable('c:\\fopen_variation10.tmp')) {
+	die('skip. C:\\ not writable.');
+}
+
 ?>
 --FILE--
 <?php
diff --git a/ext/standard/tests/file/fopen_variation11-win32.phpt b/ext/standard/tests/file/fopen_variation11-win32.phpt
index cc33a4e..61a2f60 100644
--- a/ext/standard/tests/file/fopen_variation11-win32.phpt
+++ b/ext/standard/tests/file/fopen_variation11-win32.phpt
@@ -6,6 +6,10 @@ Dave Kelsey <d_kelsey at uk.ibm.com>
 <?php
 if(substr(PHP_OS, 0, 3) != "WIN")
   die("skip Run only on Windows");
+if (!is_writable('c:\\fopen_variation10.tmp')) {
+	die('skip. C:\\ not writable.');
+}
+
 ?>
 --FILE--
 <?php
diff --git a/ext/standard/tests/file/fopen_variation17.phpt b/ext/standard/tests/file/fopen_variation17.phpt
index 75f24b3..bc75c11 100644
--- a/ext/standard/tests/file/fopen_variation17.phpt
+++ b/ext/standard/tests/file/fopen_variation17.phpt
@@ -37,7 +37,7 @@ function runtest() {
     mkdir($dir1.'/'.$extraDir);
     mkdir($extraDir);
     
-	$tmpfile = $extraDir.'/ basename(__FILE__, ".php") . ".tmp"';
+	$tmpfile = $extraDir . '/' . basename(__FILE__, ".php") . ".tmp";
 	$h = fopen($tmpfile, "w+", true);
 	fwrite($h, (binary) "This is the test file");
 	fclose($h);
diff --git a/ext/standard/tests/file/fpassthru_basic.phpt b/ext/standard/tests/file/fpassthru_basic.phpt
index db03abc..8924b27 100644
--- a/ext/standard/tests/file/fpassthru_basic.phpt
+++ b/ext/standard/tests/file/fpassthru_basic.phpt
@@ -13,7 +13,9 @@ $write_handle = fopen($file_name, "w");
 
 $string = "Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^ 
           Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^\n";
-
+if(substr(PHP_OS, 0, 3) == "WIN")  {
+	$string = str_replace("\r",'', $string);
+}
 fwrite($write_handle, $string);
 fclose($write_handle);
 
diff --git a/ext/standard/tests/file/mkdir_variation1-win32.phpt b/ext/standard/tests/file/mkdir_variation1-win32.phpt
index 6dfe3be..17f5492 100644
--- a/ext/standard/tests/file/mkdir_variation1-win32.phpt
+++ b/ext/standard/tests/file/mkdir_variation1-win32.phpt
@@ -94,28 +94,28 @@ foreach($inputs as $key =>$value) {
 *** Testing mkdir() : usage variation ***
 
 --uppercase NULL--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
 
 --lowercase null--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
 
 --lowercase false--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
 
 --uppercase FALSE--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
 
 --empty string DQ--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
 
 --empty string SQ--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
 
 --undefined var--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
 
 --unset var--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
 
 --single space--
 Error: 2 - mkdir(): %s, %s(%d)
diff --git a/ext/standard/tests/file/realpath_cache.phpt b/ext/standard/tests/file/realpath_cache.phpt
new file mode 100644
index 0000000..567f0e2
--- /dev/null
+++ b/ext/standard/tests/file/realpath_cache.phpt
@@ -0,0 +1,30 @@
+--TEST--
+realpath_cache_size() and realpath_cache_get()
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip not on Windows');
+}
+?>
+--FILE--
+<?php
+
+var_dump(realpath_cache_size());
+$data = realpath_cache_get();
+var_dump($data[__DIR__]);
+
+echo "Done\n";
+?>
+--EXPECTF--	
+int(%d)
+array(4) {
+  ["key"]=>
+  int(%d)
+  ["is_dir"]=>
+  bool(true)
+  ["realpath"]=>
+  string(%d) "%sfile"
+  ["expires"]=>
+  int(%d)
+}
+Done
diff --git a/ext/standard/tests/file/realpath_cache_win32.phpt b/ext/standard/tests/file/realpath_cache_win32.phpt
new file mode 100644
index 0000000..16fc412
--- /dev/null
+++ b/ext/standard/tests/file/realpath_cache_win32.phpt
@@ -0,0 +1,38 @@
+--TEST--
+realpath_cache_size() and realpath_cache_get()
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip only on Windows');
+}
+?>
+--FILE--
+<?php
+
+var_dump(realpath_cache_size());
+$data = realpath_cache_get();
+var_dump($data[__DIR__]);
+
+echo "Done\n";
+?>
+--EXPECTF--	
+int(%d)
+array(8) {
+  ["key"]=>
+  int(%d)
+  ["is_dir"]=>
+  bool(true)
+  ["realpath"]=>
+  string(%d) "%sfile"
+  ["expires"]=>
+  int(%d)
+  ["is_rvalid"]=>
+  bool(%s)
+  ["is_wvalid"]=>
+  bool(%s)
+  ["is_readable"]=>
+  bool(%s)
+  ["is_writable"]=>
+  bool(%s)
+}
+Done
diff --git a/ext/standard/tests/file/rename_variation-win32.phpt b/ext/standard/tests/file/rename_variation-win32.phpt
index cebf033..a10c6df 100644
--- a/ext/standard/tests/file/rename_variation-win32.phpt
+++ b/ext/standard/tests/file/rename_variation-win32.phpt
@@ -69,7 +69,7 @@ bool(false)
 bool(true)
 -- Iteration 2 --
 
-Warning: rename(%s/rename_variation/rename_variation.tmp/,%s/rename_variation2.tmp): No such file or directory in %s on line %d
+Warning: rename(%s/rename_variation/rename_variation.tmp/,%s/rename_variation2.tmp): The filename, directory name, or volume label syntax is incorrect. (code: 123) in %s on line %d
 bool(false)
 bool(false)
 bool(false)
diff --git a/ext/standard/tests/file/rename_variation11-win32.phpt b/ext/standard/tests/file/rename_variation11-win32.phpt
index d17b0d2..c13a09a 100644
--- a/ext/standard/tests/file/rename_variation11-win32.phpt
+++ b/ext/standard/tests/file/rename_variation11-win32.phpt
@@ -92,12 +92,12 @@ bool(true)
 
 -- Iteration 5 --
 
-Warning: rename(%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\renameMe.tmp,%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\renameMe.tmp,%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
 bool(false)
 
 -- Iteration 6 --
 
-Warning: rename(%s\renameVar11\renameVar11Sub\BADDIR\renameMe.tmp,%s\renameVar11\renameVar11Sub\BADDIR\IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(%s\renameVar11\renameVar11Sub\BADDIR\renameMe.tmp,%s\renameVar11\renameVar11Sub\BADDIR\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
 bool(false)
 
 -- Iteration 7 --
@@ -118,7 +118,7 @@ bool(true)
 
 -- Iteration 11 --
 
-Warning: rename(BADDIR\renameMe.tmp,BADDIR\IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(BADDIR\renameMe.tmp,BADDIR\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
 bool(false)
 
 -- Iteration 12 --
diff --git a/ext/standard/tests/file/rename_variation12-win32.phpt b/ext/standard/tests/file/rename_variation12-win32.phpt
new file mode 100644
index 0000000..de5fc14
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation12-win32.phpt
@@ -0,0 +1,121 @@
+--TEST--
+Test rename() function : variation - various relative, absolute paths
+--CREDITS--
+Dave Kelsey <d_kelsey at uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') die('skip..  for Windows');
+?>
+--FILE--
+<?php
+/* Prototype  : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+/* Creating unique files in various dirs by passing relative paths to $dir arg */
+
+echo "*** Testing rename() with absolute and relative paths ***\n";
+$mainDir = "renameVar11";
+$subDir = "renameVar11Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$fromFile = "renameMe.tmp";
+$toFile = "IwasRenamed.tmp";
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir/",
+  "$absSubDir/../".$subDir,
+  "$absSubDir//.././".$subDir,
+  "$absSubDir/../../".$mainDir."/./".$subDir,
+  "$absSubDir/..///".$subDir."//..//../".$subDir,
+  "$absSubDir/BADDIR",
+  
+  
+  // relative paths
+  $mainDir."/".$subDir,
+  $mainDir."//".$subDir, 
+   $mainDir."///".$subDir, 
+  "./".$mainDir."/../".$mainDir."/".$subDir,
+  "BADDIR",  
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  touch($absSubDir."/".$fromFile);
+  $res = rename($dir."/".$fromFile, $dir."/".$toFile);
+  var_dump($res);
+  if ($res == true) {
+     $res = rename($dir."/".$toFile, $dir."/".$fromFile);
+     var_dump($res);
+  }
+  unlink($absSubDir."/".$fromFile);
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing rename() with absolute and relative paths ***
+
+-- Iteration 1 --
+bool(true)
+bool(true)
+
+-- Iteration 2 --
+bool(true)
+bool(true)
+
+-- Iteration 3 --
+bool(true)
+bool(true)
+
+-- Iteration 4 --
+bool(true)
+bool(true)
+
+-- Iteration 5 --
+
+Warning: rename(%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/renameMe.tmp,%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: rename(%s/renameVar11/renameVar11Sub/BADDIR/renameMe.tmp,%s/renameVar11/renameVar11Sub/BADDIR/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+bool(true)
+bool(true)
+
+-- Iteration 8 --
+bool(true)
+bool(true)
+
+-- Iteration 9 --
+bool(true)
+bool(true)
+
+-- Iteration 10 --
+bool(true)
+bool(true)
+
+-- Iteration 11 --
+
+Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/rename_variation12.phpt b/ext/standard/tests/file/rename_variation12.phpt
index 11274f0..168beef 100644
--- a/ext/standard/tests/file/rename_variation12.phpt
+++ b/ext/standard/tests/file/rename_variation12.phpt
@@ -2,6 +2,10 @@
 Test rename() function : variation - various relative, absolute paths
 --CREDITS--
 Dave Kelsey <d_kelsey at uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip..  not for Windows');
+?>
 --FILE--
 <?php
 /* Prototype  : bool rename(string old_name, string new_name[, resource context])
@@ -85,12 +89,12 @@ bool(true)
 
 -- Iteration 5 --
 
-Warning: rename(%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/renameMe.tmp,%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/renameMe.tmp,%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/IwasRenamed.tmp): %s in %s on line %d
 bool(false)
 
 -- Iteration 6 --
 
-Warning: rename(%s/renameVar11/renameVar11Sub/BADDIR/renameMe.tmp,%s/renameVar11/renameVar11Sub/BADDIR/IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(%s/renameVar11/renameVar11Sub/BADDIR/renameMe.tmp,%s/renameVar11/renameVar11Sub/BADDIR/IwasRenamed.tmp): %s in %s on line %d
 bool(false)
 
 -- Iteration 7 --
@@ -111,7 +115,7 @@ bool(true)
 
 -- Iteration 11 --
 
-Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): %s in %s on line %d
 bool(false)
 
-*** Done ***
\ No newline at end of file
+*** Done ***
diff --git a/ext/standard/tests/file/rename_variation13-win32.phpt b/ext/standard/tests/file/rename_variation13-win32.phpt
index 290095629e4a2f28c3c4e0b043260fb63ef33a43..a86025889d31bedfad6b7214ff98c1a4cd9dcd62 100644
GIT binary patch
literal 3947
zcmd5;Yj4{&6y4Y9SKJCIEV-5)w|jI+(>7=v%xKUBjk^wL3xk%Zn2k&tB9#Y*{r8<q
zDN#13X_5iyKE$!f%X1IUeefp9WOOh|l3*gOqf%<IkWox|rBkPjrVTn4r4s&o;=h~9
zlG4YbP#G<So7*5sUcDXdj3)<x*%8N*UdzJDGkTUykNmfn)lpx~7X8#Lp2Pa!^>}~0
z3*%=mmh)wx^2k;*>&j^V*Zt{l2R&Nv(UX`SY*F}r{3eV8qD;vsv`1=5Wu?jJ;tU`3
zUg^x7*f8D<UNG?PcyDw8JLuAWX`FFqOG&uL%$VZ*f^eqvA(<kZ@`ZcUENFS+7e4f0
zX-!q8l2W6cJawNyqf0x|rlnf492 at l3t3`rxRY>CPgYzSq+#nnpSSNHQ%51<U{giFC
z3neT$bD^=_;Io4Ogts+`vJ|*n?m;cqDOh8Uc8VR^s`n#E0`qYb22mc?mPE<0$2-Z8
zl%>xVVk!_djukUtAQtYV7LL6VP2Rp6`9nhju at hMoJ&I~UV&0?Y6b{4Mc6WR4VAR8*
zH}CfL_<tDU=zzxL=1LzyWH+bfQ^KtYu?1U6C#7MnHB2PoB32wqOLJLDzQq96hf>Q@
zIILzW&#|FhYY3%))bnt-)3P)(F+==4Y>fa%b5NHG9!d&#IUJ)?Wt|PlU}0aD3uP_m
z^N!R?W?`SHQ|NE-aozv-P^`dA=EigLp@`yMz*}8-mbp5Gc6>!7K3TaGpbZZQmmm#z
z$zD0NGF8eHTW4P4aG=e=R_Wa5!2p|(jVa(}1N?<SfE*5FIyV${yItaHWSEPB^j^)(
zrWF+BP$J;n?nfPN25bCt>KSdZUthx0DHp?Z8u!CN4f4AvhfmmCczw30J=gCH1cUV5
zV%Y%?l~eR!aRjWWHHu^UGx**YVlGs{8Jw09QM&|00ALDSk$(jNbc|?CZLM$Olb)fJ
zD(#{+onu~q^oSUl$gd;A+x-t~>eD86YF(0qQII8GnT|K>Ac}qDkK-z at kz*``lq6mo
z9Cik}NA;~ii at 1qRvud%78gc8bUhOybCM<wg)yLB|z%@-GdRgfL+1 at NOCN4{~a>^_1
zb;F at c$LjU^+!cK4meer5n$Jy;!KqyQD~6j*j(yaeWjjX8i!|~bbo9sm=+%UK^DVLv
zotM_zz$C*C9tbB7QHucLz8kr+l5r5c7o|p8Z=B~fy46E_IX~Mxj5lb4eqqn7lM70P
z*2YnezUA8p2Z!uZrYc7{_bEyZx7^1uJkvwV-3Aeo^f0Ua=K?QM%tVJRQSfAPQs}So
zynmXHTblo1xgz10^y@)D2yv|(D`3|}<7;5h_Q_?^{6es<D^C7TjDNVyxETVzCFdK6
z{9{X*I_HDStvFLtTU<nSuR)inUn{DA<4HR<MTKFZ5Hnez3bhlbJW?o~nv#t#YHs)#
zv)b*_jIPTwuKN38hMfJWmGis1$@vWm?dO*CHqVQlW^BAF4Pp!>Xp|146Q-4gbZE=y
zE(UW>lRdrW^r1SI`lg}0{5)Re0)6)8E>?QPe at 67LPTTdLwt}sUVt0%B3e5EnRy{DT
uJXp6bofWrVE2S?ypm*ehg88MDvYB4*CSY^;eq?K$-LF`FhB}|Ig5YmeK;#zy

delta 824
zcmaDYH&13mH{;}P<}Tsf?3BzR4VARaoYeS&#F7k6Yp%&%jGoe53JM`Xp{_bW+Rf1?
z7|ies_3;4;Om=3nWmZzs*<8ycz{r=DU!<X+l4)yT4J2(Q=dw6Tl%y7yWagzSsH@~9
z=BBDE=<3GgDOoEhOuo+&CRCc2lbM&T0hR(<rl3$e*^^ayaxQD+<m0T3JaE0bhU$~!
z*z6?z@)e3plQR at RE>y at bQUE$PHMu0esB-c|PDO6Ga<FQJ$!hGf_;ql>bpVa$FvO>r
z!yBJ0r{dr=3K1j<ARp?<Drj0M;0Z(y{mG?V1Og3VCIiKx#t)AG$D*RdO7+cWxuqB<
zzvPjb9M7RU*^*ZTPoOvQ#^8|!rUyZ|;RP85`ald0g2`2UT=?_>gWx%zGF}z(lVkb$
E00CbTiU0rr

diff --git a/ext/standard/tests/file/rename_variation13.phpt b/ext/standard/tests/file/rename_variation13.phpt
index 1237604..24697d5 100644
--- a/ext/standard/tests/file/rename_variation13.phpt
+++ b/ext/standard/tests/file/rename_variation13.phpt
@@ -5,7 +5,7 @@ Dave Kelsey <d_kelsey at uk.ibm.com>
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) == "WIN")
-  die("skip Not for Windows");
+  die("skip. Not for Windows");
 ?>
 --FILE--
 <?php
@@ -15,7 +15,6 @@ if(substr(PHP_OS, 0, 3) == "WIN")
  * Alias to functions: 
  */
 
-
 echo "*** Testing rename() with obscure files ***\n";
 $file_path = dirname(__FILE__)."/renameVar13";
 $aFile = $file_path.'/afile.tmp';
@@ -74,24 +73,24 @@ Warning: rename(1,%s/renameVar13/afile.tmp): No such file or directory in %s on
 bool(false)
 -- testing '' --
 
-Warning: rename(%s/renameVar13/afile.tmp,): No such file or directory in %s on line %d
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
 bool(false)
 
-Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
 bool(false)
 -- testing '' --
 
-Warning: rename(%s/renameVar13/afile.tmp,): No such file or directory in %s on line %d
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
 bool(false)
 
-Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
 bool(false)
 -- testing '' --
 
-Warning: rename(%s/renameVar13/afile.tmp,): No such file or directory in %s on line %d
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
 bool(false)
 
-Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
 bool(false)
 -- testing ' ' --
 bool(true)
@@ -103,7 +102,7 @@ bool(false)
 Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
 bool(false)
 
-Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
 bool(false)
 -- testing 'Array' --
 
@@ -129,4 +128,4 @@ bool(false)
 Warning: rename(php/php,%s/renameVar13/afile.tmp): %s directory in %s on line %d
 bool(false)
 
-*** Done ***
\ No newline at end of file
+*** Done ***
diff --git a/ext/standard/tests/file/rename_variation3-win32.phpt b/ext/standard/tests/file/rename_variation3-win32.phpt
index b251fc4..b5da587 100644
--- a/ext/standard/tests/file/rename_variation3-win32.phpt
+++ b/ext/standard/tests/file/rename_variation3-win32.phpt
@@ -24,6 +24,9 @@ mkdir($dirname);
 
 $filename = "$file_path/rename_variation3.tmp"; 
 $fp = fopen($filename, "w");
+if (!$fp) {
+	die("Cannot create $filename\n");
+}
 fclose($fp);
 
 echo "\n-- Renaming file to same file name --\n";
@@ -68,7 +71,7 @@ bool(true)
 
 -- Renaming existing file to existing directory name --
 
-Warning: rename(%s/rename_variation3.tmp,%s/rename_variation3_dir): No such file or directory in %s on line %d
+Warning: rename(%s/rename_variation3.tmp,%s/rename_variation3_dir): Access is denied. (code: 5) in %s on line %d
 bool(false)
 bool(true)
 bool(true)
diff --git a/ext/standard/tests/file/rename_variation6-win32.phpt b/ext/standard/tests/file/rename_variation6-win32.phpt
index 6305447..14d59d0 100644
--- a/ext/standard/tests/file/rename_variation6-win32.phpt
+++ b/ext/standard/tests/file/rename_variation6-win32.phpt
@@ -4,6 +4,10 @@ Test rename() function: usage variations-6
 <?php
 if (substr(PHP_OS, 0, 3) != 'WIN') die('skip..  for Windows');
 if (!function_exists("symlink")) die("skip symlinks are not supported");
+$ret = exec('mklink rename_variation13tmp.lnk ' . __FILE__ .' 2>&1', $out);
+if (strpos($ret, 'privilege')) {
+	die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
+}
 ?>
 --FILE--
 <?php
diff --git a/ext/standard/tests/file/rename_variation8-win32.phpt b/ext/standard/tests/file/rename_variation8-win32.phpt
new file mode 100644
index 0000000..1d25a12
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation8-win32.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Test rename() function: variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') die('skip..  for Windows');
+?>
+--FILE--
+<?php
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
+   Description: Renames a file or directory
+*/
+
+echo "\n*** Testing rename() on non-existing file ***\n";
+$file_path = dirname(__FILE__);
+
+// try renaming a non existing file
+$src_name = $file_path."/non_existent_file.tmp";
+$dest_name = $file_path."/rename_variation8_new.tmp";
+var_dump( rename($src_name, $dest_name) );
+
+// ensure that $dest_name didn't get created
+var_dump( file_exists($src_name) );  // expecting false
+var_dump( file_exists($dest_name) ); // expecting false
+
+// rename a existing dir to new name
+echo "\n*** Testing rename() on existing directory ***\n";
+$dir_name = $file_path."/rename_basic_dir";
+mkdir($dir_name);
+$new_dir_name = $file_path."/rename_basic_dir1";
+var_dump( rename($dir_name, $new_dir_name) );
+//ensure that $new_dir_name got created
+var_dump( file_exists($dir_name) );  // expecting false
+var_dump( file_exists($new_dir_name) );  // expecting true
+
+// try to rename an non_existing dir 
+echo "\n*** Testing rename() on non-existing directory ***\n";
+$non_existent_dir_name = $file_path."/non_existent_dir";
+$new_dir_name = "$file_path/rename_basic_dir2";
+var_dump( rename($non_existent_dir_name, $new_dir_name) );
+// ensure that $new_dir_name didn't get created
+var_dump( file_exists($non_existent_dir_name) );  // expecting flase
+var_dump( file_exists($new_dir_name) );  // expecting false
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/rename_basic_dir1");
+?>
+--EXPECTF--
+*** Testing rename() on non-existing file ***
+
+Warning: rename(%s/non_existent_file.tmp,%s/rename_variation8_new.tmp): The system cannot find the file specified. (code: 2) in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+*** Testing rename() on existing directory ***
+bool(true)
+bool(false)
+bool(true)
+
+*** Testing rename() on non-existing directory ***
+
+Warning: rename(%s/non_existent_dir,%s/rename_basic_dir2): The system cannot find the file specified. (code: 2) in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/rename_variation8.phpt b/ext/standard/tests/file/rename_variation8.phpt
index 6b3644a..6e236c3 100644
--- a/ext/standard/tests/file/rename_variation8.phpt
+++ b/ext/standard/tests/file/rename_variation8.phpt
@@ -1,5 +1,9 @@
 --TEST--
 Test rename() function: variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip..  not for Windows');
+?>
 --FILE--
 <?php
 /* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
@@ -41,6 +45,7 @@ echo "Done\n";
 ?>
 --CLEAN--
 <?php
+unlink(dirname(__FILE__)."/rename_basic_new2.tmp");
 rmdir(dirname(__FILE__)."/rename_basic_dir1");
 ?>
 --EXPECTF--
diff --git a/ext/standard/tests/file/rename_variation9.phpt b/ext/standard/tests/file/rename_variation9.phpt
index d923e4a..272fa94 100644
--- a/ext/standard/tests/file/rename_variation9.phpt
+++ b/ext/standard/tests/file/rename_variation9.phpt
@@ -41,7 +41,7 @@ echo "Done\n";
 unlink(dirname(__FILE__)."/rename_variation9_new.tmp");
 rmdir(dirname(__FILE__)."/rename_variation_dir9_new");
 ?>
---EXPECTF--
+--EXPECT--
 *** Testing rename() by giving stream context as third argument ***
 bool(true)
 bool(false)
diff --git a/ext/standard/tests/file/rmdir_variation1-win32.phpt b/ext/standard/tests/file/rmdir_variation1-win32.phpt
index 0732821..2516e61 100644
--- a/ext/standard/tests/file/rmdir_variation1-win32.phpt
+++ b/ext/standard/tests/file/rmdir_variation1-win32.phpt
@@ -90,35 +90,35 @@ foreach($inputs as $key =>$value) {
 *** Testing rmdir() : usage variation ***
 
 --uppercase NULL--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
 bool(false)
 
 --lowercase null--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
 bool(false)
 
 --lowercase false--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
 bool(false)
 
 --uppercase FALSE--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
 bool(false)
 
 --empty string DQ--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
 bool(false)
 
 --empty string SQ--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
 bool(false)
 
 --undefined var--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
 bool(false)
 
 --unset var--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
 bool(false)
 
 --single space--
diff --git a/ext/standard/tests/file/rmdir_variation1.phpt b/ext/standard/tests/file/rmdir_variation1.phpt
index a7a4990..04fee0e 100644
--- a/ext/standard/tests/file/rmdir_variation1.phpt
+++ b/ext/standard/tests/file/rmdir_variation1.phpt
@@ -81,7 +81,7 @@ $inputs = array(
 
 foreach($inputs as $key =>$value) {
       echo "\n--$key--\n";
-      var_dump( rmdir($value) );
+      var_dump(rmdir($value));
 };
 
 ?>
diff --git a/ext/standard/tests/file/tempnam_variation3-win32.phpt b/ext/standard/tests/file/tempnam_variation3-win32.phpt
index ec7718f..fb457cb 100644
--- a/ext/standard/tests/file/tempnam_variation3-win32.phpt
+++ b/ext/standard/tests/file/tempnam_variation3-win32.phpt
@@ -3,7 +3,7 @@ Test tempnam() function: usage variations - obscure prefixes
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) != "WIN")
-  die("skip run only on Windows");
+	die("skip run only on Windows");
 ?>
 --FILE--
 <?php
@@ -15,106 +15,101 @@ if(substr(PHP_OS, 0, 3) != "WIN")
 
 echo "*** Testing tempnam() with obscure prefixes ***\n";
 $file_path = dirname(__FILE__)."/tempnamVar3";
-mkdir($file_path);
+if (!mkdir($file_path)) {
+	echo "Failed, cannot create temp dir $filepath\n";
+	exit(1);
+}
+
+$file_path = realpath($file_path);
 
 /* An array of prefixes */ 
 $names_arr = array(
-  /* Invalid args */ 
-  -1,
-  TRUE,
-  FALSE,
-  NULL,
-  "",
-  " ",
-  "\0",
-  array(),
+	/* Valid args (casting)*/ 
+	-1,
+	TRUE,
+	FALSE,
+	NULL,
+	"",
+	" ",
+	"\0",
+	/* Invalid args */ 
+	array(),
+
+	/* Valid args*/ 
+	/* prefix with path separator of a non existing directory*/
+	"/no/such/file/dir", 
+	"php/php"
+);
 
-  /* prefix with path separator of a non existing directory*/
-  "/no/such/file/dir", 
-  "php/php"
+$res_arr = array(
+	/* Invalid args */ 
+	true,
+	true,
+	true,
+	true,
+	true,
+	true,
+	true,
+	false,
 
+	/* prefix with path separator of a non existing directory*/
+	true, 
+	true
 );
 
 for( $i=0; $i<count($names_arr); $i++ ) {
-  echo "-- Iteration $i --\n";
-  $file_name = tempnam("$file_path", $names_arr[$i]);
+	echo "-- Iteration $i --\n";
+	$file_name = tempnam($file_path, $names_arr[$i]);
 
-  /* creating the files in existing dir */
-  if( file_exists($file_name) ) {
-    echo "File name is => ";
-    print($file_name);
-    echo "\n";
+	/* creating the files in existing dir */
+	if (file_exists($file_name) && !$res_arr[$i]) {
+		echo "Failed\n";
+	}
+	if ($res_arr[$i]) {
+		$file_dir = dirname($file_name);
+		if (realpath($file_dir) == $file_path || realpath($file_dir . "\\") == $file_path) {
+			echo "OK\n";
+		} else {
+			echo "Failed, not created in the correct directory " . realpath($file_dir) . ' vs ' . $file_path ."\n";
+		}
+		
+		if (!is_writable($file_name)) {
+			printf("%o\n", fileperms($file_name) );
 
-    echo "File permissions are => ";
-    printf("%o", fileperms($file_name) );
-    echo "\n";
-    
-    echo "File created in => ";
-    $file_dir = dirname($file_name);
-    if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
-       echo "temp dir\n";
-    }
-    else if (realpath($file_dir) == realpath($file_path) || realpath($file_dir."\\") == realpath($file_path)) {    
-       echo "directory specified\n";
-    }
-    else {
-       echo "unknown location\n";
-    }         
-  }
-  else {
-    echo "-- File is not created --\n";
-  }
-
-  unlink($file_name);
+		}
+	} else {
+		echo "OK\n";
+	}
+	@unlink($file_name);
 }
 
 rmdir($file_path);
-echo "\n*** Done ***\n";
+echo "\n*** Done. ***\n";
 ?>
 --EXPECTF--
 *** Testing tempnam() with obscure prefixes ***
 -- Iteration 0 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
 -- Iteration 1 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
 -- Iteration 2 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
 -- Iteration 3 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
 -- Iteration 4 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
 -- Iteration 5 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+Failed, not created in the correct directory %s vs %s
+0
 -- Iteration 6 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
 -- Iteration 7 --
 
-Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d
--- File is not created --
-
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: tempnam() expects parameter 2 to be string, array given in %s\ext\standard\tests\file\tempnam_variation3-win32.php on line %d
+OK
 -- Iteration 8 --
-File name is => %s\di%s
-File permissions are => 100666
-File created in => directory specified
+OK
 -- Iteration 9 --
-File name is => %s\ph%s
-File permissions are => 100666
-File created in => directory specified
-
-*** Done ***
+OK
 
+*** Done. ***
diff --git a/ext/standard/tests/file/tempnam_variation3.phpt b/ext/standard/tests/file/tempnam_variation3.phpt
index a0b9511..69ab16c 100644
--- a/ext/standard/tests/file/tempnam_variation3.phpt
+++ b/ext/standard/tests/file/tempnam_variation3.phpt
@@ -108,7 +108,7 @@ File created in => directory specified
 Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d
 -- File is not created --
 
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
 -- Iteration 8 --
 File name is => %s/dir%s
 File permissions are => 100600
diff --git a/ext/standard/tests/file/tempnam_variation7-win32.phpt b/ext/standard/tests/file/tempnam_variation7-win32.phpt
index 5096934..34e352a 100644
--- a/ext/standard/tests/file/tempnam_variation7-win32.phpt
+++ b/ext/standard/tests/file/tempnam_variation7-win32.phpt
@@ -17,50 +17,47 @@ if(substr(PHP_OS, 0, 3) != "WIN")
 echo "*** Testing tempnam() with invalid/non-existing directory names ***\n";
 /* An array of names, which will be passed as a dir name */ 
 $names_arr = array(
-  /* Invalid args */ 
-  -1,
-  TRUE,
-  FALSE,
-  NULL,
-  "",
-  " ",
-  "\0",
-  array(),
-
-  /* Non-existing dirs */
-  "/no/such/file/dir", 
-  "php"
+	/* Invalid args */ 
+	-1,
+	TRUE,
+	FALSE,
+	NULL,
+	"",
+	" ",
+	"\0",
+	array(),
 
+	/* Non-existing dirs */
+	"/no/such/file/dir", 
+	"php"
 );
 
 for( $i=0; $i<count($names_arr); $i++ ) {
-  echo "-- Iteration $i --\n";
-  $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp");
+	echo "-- Iteration $i --\n";
+	$file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp");
+
+	if( file_exists($file_name) ){
+
+		echo "File name is => ";
+		print($file_name);
+		echo "\n";
 
-  if( file_exists($file_name) ){
+		echo "File permissions are => ";
+		printf("%o", fileperms($file_name) );
+		echo "\n";
 
-    echo "File name is => ";
-    print($file_name);
-    echo "\n";
+		echo "File created in => ";
+		$file_dir = dirname($file_name);
+		if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+			echo "temp dir\n";
+		} else {
+			echo "unknown location\n";
+		}
+	} else {
+		echo "-- File is not created --\n";
+	}
 
-    echo "File permissions are => ";
-    printf("%o", fileperms($file_name) );
-    echo "\n";
-    
-    echo "File created in => ";
-    $file_dir = dirname($file_name);
-    if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
-       echo "temp dir\n";
-    }
-    else {
-       echo "unknown location\n";
-    }                
-  }
-  else { 
-    echo "-- File is not created --\n";
-  }
- 
-  unlink($file_name);
+	unlink($file_name);
 }
 
 echo "\n*** Done ***\n";
@@ -100,7 +97,7 @@ File created in => temp dir
 Warning: tempnam() expects parameter 1 to be string, array given in %s on line %d
 -- File is not created --
 
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
 -- Iteration 8 --
 File name is => %s%et%s
 File permissions are => 100666
diff --git a/ext/standard/tests/file/tempnam_variation7.phpt b/ext/standard/tests/file/tempnam_variation7.phpt
index 0e314da..18d074d 100644
--- a/ext/standard/tests/file/tempnam_variation7.phpt
+++ b/ext/standard/tests/file/tempnam_variation7.phpt
@@ -102,7 +102,7 @@ File created in => temp dir
 Warning: tempnam() expects parameter 1 to be string, array given in %s on line %d
 -- File is not created --
 
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
 -- Iteration 8 --
 File name is => %s%etempnam_variation3.tmp%s
 File permissions are => 100600
diff --git a/ext/standard/tests/file/unlink_error-win32.phpt b/ext/standard/tests/file/unlink_error-win32.phpt
index 2c913ae..e55f6ed 100644
--- a/ext/standard/tests/file/unlink_error-win32.phpt
+++ b/ext/standard/tests/file/unlink_error-win32.phpt
@@ -77,15 +77,15 @@ bool(true)
 
 -- Testing unlink() on invalid arguments --
 
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
 bool(false)
 bool(false)
 
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
 bool(false)
 bool(false)
 
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
 bool(false)
 bool(false)
 
diff --git a/ext/standard/tests/file/userstreams_003.phpt b/ext/standard/tests/file/userstreams_003.phpt
index b30636d..01a8efb 100644
--- a/ext/standard/tests/file/userstreams_003.phpt
+++ b/ext/standard/tests/file/userstreams_003.phpt
@@ -101,7 +101,7 @@ bool(false)
 value:
 int(0)
 ptrparam:
-int(8192)
+int(%d)
 $option === 3 === 3:
 bool(true)
 $value === 0 === 0:
diff --git a/ext/standard/tests/file/windows_acls/common.inc b/ext/standard/tests/file/windows_acls/common.inc
index 2a1adeb..c427601 100644
--- a/ext/standard/tests/file/windows_acls/common.inc
+++ b/ext/standard/tests/file/windows_acls/common.inc
@@ -118,7 +118,7 @@ function create_dir($name, $perms) {
 
 function create_file($name, $perms) {
 	if (empty($name)) {
-		echo "create_dir: Empty name is not allowed\n";
+		echo "create_file: Empty name is not allowed\n";
 		return;
 	}
 
diff --git a/ext/standard/tests/file/windows_links/bug48746.phpt b/ext/standard/tests/file/windows_links/bug48746.phpt
new file mode 100644
index 0000000..6c88c63
--- /dev/null
+++ b/ext/standard/tests/file/windows_links/bug48746.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Bug#48746 - Junction not working properly
+
+--CREDIT--
+Venkat Raman Don (don.raman at microsoft.com)
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+    die('skip windows only test');
+}
+$cmd = "mklink.exe /?";
+$ret = @exec($cmd, $output, $return_val);
+if (count($output) == 0) {
+    die("mklink.exe not found in PATH");
+}
+?>
+--FILE--
+<?php
+$old_dir = __DIR__;
+$dirname = __DIR__ . "\\mnt\\test\\directory";
+mkdir($dirname, 0700, true);
+chdir(__DIR__ . "\\mnt\\test");
+$drive = substr(__DIR__, 0, 2);
+$pathwithoutdrive = substr(__DIR__, 2);
+$ret = exec("mountvol " . $drive . " /L", $output, $ret_val);
+exec("mklink /j mounted_volume " . $ret, $output, $ret_val);
+$fullpath = "mounted_volume" . $pathwithoutdrive;
+exec("mklink /j mklink_junction directory", $output, $ret_val);
+var_dump(file_exists("directory"));
+var_dump(file_exists("mklink_junction"));
+var_dump(file_exists("mounted_volume"));
+var_dump(file_exists("$fullpath"));
+var_dump(is_dir("mklink_junction"));
+var_dump(is_dir("$fullpath"));
+var_dump(is_readable("mklink_junction"));
+var_dump(is_writeable("$fullpath"));
+chdir($old_dir);
+
+rmdir(__DIR__ . "\\mnt\\test\\directory");
+rmdir(__DIR__ . "\\mnt\\test\\mklink_junction");
+rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");
+rmdir(__DIR__ . "\\mnt\\test");
+rmdir(__DIR__ . "\\mnt");
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/standard/tests/file/windows_links/bug48746_1.phpt b/ext/standard/tests/file/windows_links/bug48746_1.phpt
new file mode 100644
index 0000000..ca8450a
--- /dev/null
+++ b/ext/standard/tests/file/windows_links/bug48746_1.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Bug#48746 - Junction not working properly
+
+--CREDIT--
+Venkat Raman Don (don.raman at microsoft.com)
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+    die('skip windows only test');
+}
+$cmd = "mklink.exe /?";
+$ret = @exec($cmd, $output, $return_val);
+if (count($output) == 0) {
+    die("mklink.exe not found in PATH");
+}
+?>
+--FILE--
+<?php
+$old_dir = __DIR__;
+$dirname = __DIR__ . "\\mnt\\test\\directory";
+exec("mkdir " . $dirname, $output, $ret_val);
+chdir(__DIR__ . "\\mnt\\test");
+$drive = substr(__DIR__, 0, 2);
+$pathwithoutdrive = substr(__DIR__, 2);
+$ret = exec("mountvol " . $drive . " /L", $output, $ret_val);
+exec("mklink /j mounted_volume " . $ret, $output, $ret_val);
+$fullpath = "mounted_volume" . $pathwithoutdrive;
+exec("mklink /j mklink_junction directory", $output, $ret_val);
+file_put_contents("mklink_junction\\a.php", "<?php echo \"I am included.\n\" ?>");
+include_once "mklink_junction\\a.php";
+file_put_contents("$fullpath\\mnt\\test\\directory\\b.php", "<?php echo \"I am included.\n\" ?>");
+require "$fullpath\\mnt\\test\\directory\\b.php";
+file_put_contents("$fullpath\\mnt\\test\\mklink_junction\\c.php", "<?php echo \"I am included.\n\" ?>");
+require_once "$fullpath\\mnt\\test\\mklink_junction\\c.php";
+var_dump(is_file("mklink_junction\\a.php"));
+var_dump(is_file("$fullpath\\mnt\\test\\directory\\b.php"));
+var_dump(is_file("$fullpath\\mnt\\test\\mklink_junction\\c.php"));
+unlink("$fullpath\\mnt\\test\\directory\\b.php");
+unlink("$fullpath\\mnt\\test\\mklink_junction\\c.php");
+unlink("mklink_junction\\a.php");
+chdir($old_dir);
+rmdir(__DIR__ . "\\mnt\\test\\directory");
+rmdir(__DIR__ . "\\mnt\\test\\mklink_junction");
+rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");
+rmdir(__DIR__ . "\\mnt\\test");
+rmdir(__DIR__ . "\\mnt");
+
+?>
+--EXPECT--
+I am included.
+I am included.
+I am included.
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/standard/tests/file/windows_links/bug48746_2.phpt b/ext/standard/tests/file/windows_links/bug48746_2.phpt
new file mode 100644
index 0000000..7beed16
--- /dev/null
+++ b/ext/standard/tests/file/windows_links/bug48746_2.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Bug#48746 - Junction not working properly
+
+--CREDIT--
+Venkat Raman Don (don.raman at microsoft.com)
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+    die('skip windows only test');
+}
+$ret = exec('mklink bug48746_tmp.lnk ' . __FILE__ .' 2>&1', $out);
+if (strpos($ret, 'privilege')) {
+	die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
+}
+unlink('mklink bug48746_tmp.lnk');
+?>
+--FILE--
+<?php
+$old_dir = __DIR__;
+$dirname = __DIR__ . "\\mnt\\test\\directory";
+exec("mkdir " . $dirname, $output, $ret_val);
+chdir(__DIR__ . "\\mnt\\test");
+$drive = substr(__DIR__, 0, 2);
+$pathwithoutdrive = substr(__DIR__, 2);
+$ret = exec("mountvol " . $drive . " /L", $output, $ret_val);
+exec("mklink /j mounted_volume " . $ret, $output, $ret_val);
+$fullpath = "mounted_volume" . $pathwithoutdrive;
+exec("mklink /j mklink_junction directory", $output, $ret_val);
+file_put_contents("mklink_junction\\a.php", "<?php echo \"I am included.\n\" ?>");
+file_put_contents("$fullpath\\mnt\\test\\directory\\b.php", "<?php echo \"I am included.\n\" ?>");
+print_r(scandir("mklink_junction"));
+print_r(scandir("$fullpath\\mnt\\test\\directory"));
+print_r(scandir("$fullpath\\mnt\\test\\mklink_junction"));
+unlink("$fullpath\\mnt\\test\\directory\\b.php");
+unlink("mklink_junction\\a.php");
+chdir($old_dir);
+rmdir(__DIR__ . "\\mnt\\test\\directory");
+rmdir(__DIR__ . "\\mnt\\test\\mklink_junction");
+rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");
+rmdir(__DIR__ . "\\mnt\\test");
+rmdir(__DIR__ . "\\mnt");
+
+?>
+--EXPECT--
+Array
+(
+    [0] => .
+    [1] => ..
+    [2] => a.php
+    [3] => b.php
+)
+Array
+(
+    [0] => .
+    [1] => ..
+    [2] => a.php
+    [3] => b.php
+)
+Array
+(
+    [0] => .
+    [1] => ..
+    [2] => a.php
+    [3] => b.php
+)
diff --git a/ext/standard/tests/file/windows_links/bug48746_3.phpt b/ext/standard/tests/file/windows_links/bug48746_3.phpt
new file mode 100644
index 0000000..a0dcbdc
--- /dev/null
+++ b/ext/standard/tests/file/windows_links/bug48746_3.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Bug#48746 - Junction not working properly
+
+--CREDIT--
+Venkat Raman Don (don.raman at microsoft.com)
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+	die('skip windows only test');
+}
+$ret = exec('junction /? 2>&1', $out);
+if (strpos($out[0], 'recognized')) {
+	die('skip. junction.exe not found in PATH.');
+}
+
+?>
+--FILE--
+<?php
+$old_dir = __DIR__;
+$dirname = __DIR__ . "\\mnt\\test\\directory";
+exec("mkdir " . $dirname, $output, $ret_val);
+chdir(__DIR__ . "\\mnt\\test");
+exec("junction junction directory", $output, $ret_val);
+file_put_contents("junction\\a.php", "<?php echo \"I am included.\n\" ?>");
+file_put_contents("junction\\b.php", "<?php echo \"I am included.\n\" ?>");
+include "junction/a.php";
+require_once "junction\\b.php";
+print_r(scandir("junction"));
+unlink("junction\\a.php");
+unlink("junction\\b.php");
+chdir($old_dir);
+rmdir(__DIR__ . "\\mnt\\test\\directory");
+rmdir(__DIR__ . "\\mnt\\test\\junction");
+rmdir(__DIR__ . "\\mnt\\test");
+rmdir(__DIR__ . "\\mnt");
+
+?>
+--EXPECT--
+I am included.
+I am included.
+Array
+(
+    [0] => .
+    [1] => ..
+    [2] => a.php
+    [3] => b.php
+)
diff --git a/ext/standard/tests/general_functions/.getservbyport_basic.phpt.swp b/ext/standard/tests/general_functions/.getservbyport_basic.phpt.swp
deleted file mode 100644
index dc8000aa0f5ca1e0b252441fbf7bb6ccbe2200a8..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 12288
zcmeI2%}*0S6u<{HF-^n|h#ovWR}XDMyQPE(Dne3<)`*}jV&b8h-M*H={mRTN1qo-*
z9z3cS<H5hkt0%9@#iPCjN<<^ZqwpsAwcXj7_ul-rr}lZ}$Mt!*UaANh=Y`nryt?=9
z?XY+_B*gO=v)R86T2~BYV&mlSrEVBmw- at VYCXqh6J=0275|<bsvuJFGaB<zb#>%KI
zb=%EmjoZZtwG3LFH1e&Aqin_+)N9^G5^LM?q)~o}!q~&p^IbM at d<~?wQ=AxF8mo+!
zuR2#?cxdVPy5N(u0XDz}*Z><~18jf|uz_Q0z$OFYJDvRmahVv{gWh<s0XDz}*Z><~
z18jf|umLu}2G{@_U;{_QfNTr#;*1a{2kAic|9|!yz_)Wkye3`}9x+Z_BEFmz;xqAy
z_&`L&MPi%wekDE<?};}=NURcF;wiB}Tp&&pr-+?=N5ml?gAK3&Hoykh02^QfY=8~0
zf&a(A^lbrqV{89Ye`ZbURyz%o{DG$9{6u*K9P1}e0j8#=pd$l=g`2{Q;~;N!inu9?
z#oCj_TD3V>EDB1I+Y-6lKSj&Y9;CRNf8GfDb-->RPOsN<sF0lM<U1<B7OpF5qRwB-
zE((QBA#zzrXe-Pw-d$`hG)mw=8ksc7nyIn9vpHKr0Zi%{tM}H8lt;$09N;Y1AJDOP
zA_84jZ at 4rwyRh7F&4#fUj#b>YR%@t at i`I9uR&C{@aj2?(V5_OB{m9_VO5IbDQ}`+D
zZ+o+Xe%%+SC|y5v+pTHp45w!?SHEAQ2hmVr93kAn$f`g=-e6>6Ewzegx}j7-$&bT=
zm{<M^1_%q<V2~{f;~CXPY2%Wz1u-W*6$8C`I`w_J-RXav>FOPkXjLS4W7Vw;l#GCE
zLz5cX=Lo2j%ac$=$}VAavREk>E2FTQMo5)bAJt~-%?1^lEr)*FI~@E17Qov8Us82Z
q7nFrC)(Ccm62%$<G-mfgSp&G9pihq$r0%96o!n5CX06er6h8no<~H&G

diff --git a/ext/standard/tests/general_functions/bug49692.ini b/ext/standard/tests/general_functions/bug49692.ini
new file mode 100644
index 0000000..5def69a
--- /dev/null
+++ b/ext/standard/tests/general_functions/bug49692.ini
@@ -0,0 +1,4 @@
+//my.ini file
+[sitemap]
+/home    = default:index
+/info    = default:info
diff --git a/ext/standard/tests/general_functions/bug49692.phpt b/ext/standard/tests/general_functions/bug49692.phpt
new file mode 100644
index 0000000..80a1612
--- /dev/null
+++ b/ext/standard/tests/general_functions/bug49692.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #49692: parse_ini_file() throws errors when key contains '/' (forward slash)
+--CREDITS--
+Rafael Dohms <rdohms [at] gmail [dot] com>
+--FILE--
+<?php
+
+var_dump(parse_ini_file('bug49692.ini', true));
+
+?>
+--EXPECTF--
+array(1) {
+  ["sitemap"]=>
+  array(2) {
+    ["/home"]=>
+    string(13) "default:index"
+    ["/info"]=>
+    string(12) "default:info"
+  }
+}
diff --git a/ext/standard/tests/general_functions/bug49847.phpt b/ext/standard/tests/general_functions/bug49847.phpt
new file mode 100644
index 0000000..8895202
--- /dev/null
+++ b/ext/standard/tests/general_functions/bug49847.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #49847 (exec() fails on lines larger then 4095 bytes)
+--FILE--
+<?php
+$iswin =  substr(PHP_OS, 0, 3) == "WIN";
+
+if ($iswin) {
+	$f = dirname(__FILE__) . '\\bug49847.tmp';
+	$s = str_repeat(' ', 4097);
+	$s .= '1';
+	file_put_contents($f, $s);
+	exec('more ' . $f, $output);
+} else {
+	exec("printf %4098d 1", $output);
+}
+var_dump($output);
+if ($iswin) {
+	unlink($f);
+}
+?>
+--EXPECTF--
+array(1) {
+  [0]=>
+  string(4098) "%s 1"
+}
diff --git a/ext/standard/tests/general_functions/bug50690.phpt b/ext/standard/tests/general_functions/bug50690.phpt
new file mode 100644
index 0000000..4d9f0dc
--- /dev/null
+++ b/ext/standard/tests/general_functions/bug50690.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #23650 (putenv() does not assign values when the value is one character)
+--FILE--
+<?php
+putenv("foo=ab");
+putenv("bar=c");
+var_dump(getenv("foo"));
+var_dump(getenv("bar"));
+var_dump(getenv("thisvardoesnotexist"));
+?>
+--EXPECT--
+string(2) "ab"
+string(1) "c"
+bool(false)
diff --git a/ext/standard/tests/general_functions/bug50732.phpt b/ext/standard/tests/general_functions/bug50732.phpt
new file mode 100644
index 0000000..ed8341d
--- /dev/null
+++ b/ext/standard/tests/general_functions/bug50732.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #50732 (exec() adds single byte twice to $output array)
+--FILE--
+<?php
+exec("echo x", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  string(1) "x"
+}
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 22188c7..31bcb80 100644
--- a/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt
+++ b/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt
@@ -14,7 +14,7 @@ var_dump(get_cfg_var( 'register_globals' ) );
 
 ?>
 --EXPECTF--
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in %s on line 0
+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"
 
diff --git a/ext/standard/tests/general_functions/import_request.phpt b/ext/standard/tests/general_functions/import_request.phpt
index a118147..0f9e93b 100644
--- a/ext/standard/tests/general_functions/import_request.phpt
+++ b/ext/standard/tests/general_functions/import_request.phpt
@@ -30,24 +30,24 @@ echo "Done\n";
 --EXPECTF--	
 Warning: import_request_variables() expects at least 1 parameter, 0 given in %s on line %d
 NULL
-NULL
+bool(false)
 
 Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d
-NULL
+bool(false)
 
 Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d
 
 Warning: import_request_variables(): Attempted GLOBALS variable overwrite in %s on line %d
 
 Warning: import_request_variables(): Numeric key detected - possible security hazard in %s on line %d
-NULL
+bool(true)
 
 Notice: Undefined variable: ap in %s on line %d
 string(1) "1"
 string(3) "heh"
 string(1) "3"
 NULL
-NULL
+bool(true)
 
 Notice: Undefined variable: g_ap in %s on line %d
 string(1) "1"
@@ -55,7 +55,7 @@ string(3) "heh"
 string(1) "3"
 NULL
 string(2) "hm"
-NULL
+bool(true)
 string(1) "1"
 string(3) "heh"
 string(1) "3"
@@ -66,7 +66,7 @@ array(1) {
   [0]=>
   string(2) "ar"
 }
-NULL
+bool(true)
 
 Notice: Undefined variable: r_ap in %s on line %d
 string(1) "1"
diff --git a/ext/standard/tests/general_functions/is_callable_basic1.phpt b/ext/standard/tests/general_functions/is_callable_basic1.phpt
index e836d73..fe4d6e2 100644
--- a/ext/standard/tests/general_functions/is_callable_basic1.phpt
+++ b/ext/standard/tests/general_functions/is_callable_basic1.phpt
@@ -64,7 +64,7 @@ check_iscallable($defined_functions);
 
 ?>
 ===DONE===
---EXPECT---
+--EXPECT--
 *** Testing is_callable() on defined functions ***
 -- Iteration  1 --
 bool(true)
@@ -106,4 +106,4 @@ Hello_World
 bool(true)
 bool(true)
 Hello_World
-===DONE===
\ No newline at end of file
+===DONE===
diff --git a/ext/standard/tests/general_functions/phpcredits.phpt b/ext/standard/tests/general_functions/phpcredits.phpt
index 69515df..0aff614 100644
--- a/ext/standard/tests/general_functions/phpcredits.phpt
+++ b/ext/standard/tests/general_functions/phpcredits.phpt
@@ -37,7 +37,7 @@ Language Design & Concept
 PHP Quality Assurance Team
 %a
 
-PHP Website Team
+%wWebsites and Infrastructure team%w
 %a
 bool(true)
 
diff --git a/ext/standard/tests/general_functions/proc_nice_basic.phpt b/ext/standard/tests/general_functions/proc_nice_basic.phpt
index 5a95756..3a95890 100644
--- a/ext/standard/tests/general_functions/proc_nice_basic.phpt
+++ b/ext/standard/tests/general_functions/proc_nice_basic.phpt
@@ -5,6 +5,10 @@ Italian PHP TestFest 2009 Cesena 19-20-21 june
 Fabio Fabbrucci (fabbrucci at grupporetina.com)
 Michele Orselli (mo at ideato.it)
 Simone Gentili (sensorario at gmail.com)
+--SKIPIF--
+<?php
+if(!function_exists('proc_nice')) die("skip. proc_nice not available ");
+?>
 --FILE--
 <?php
 	function getNice($id)
diff --git a/ext/standard/tests/general_functions/proc_nice_error.phpt b/ext/standard/tests/general_functions/proc_nice_error.phpt
index c50812c..09f84fa 100644
--- a/ext/standard/tests/general_functions/proc_nice_error.phpt
+++ b/ext/standard/tests/general_functions/proc_nice_error.phpt
@@ -1,5 +1,9 @@
 --TEST--
 Test function proc_nice() by calling it more than or less than its expected arguments
+--SKIPIF--
+<?php
+if(!function_exists('proc_nice')) die("skip. proc_nice not available ");
+?>
 --FILE--
 <?php
 
diff --git a/ext/standard/tests/general_functions/proc_nice_variation1.phpt b/ext/standard/tests/general_functions/proc_nice_variation1.phpt
index b86155c..8c2bdf0 100644
--- a/ext/standard/tests/general_functions/proc_nice_variation1.phpt
+++ b/ext/standard/tests/general_functions/proc_nice_variation1.phpt
@@ -5,6 +5,10 @@ Italian PHP TestFest 2009 Cesena 19-20-21 june
 Fabio Fabbrucci (fabbrucci at grupporetina.com)
 Michele Orselli (mo at ideato.it)
 Simone Gentili (sensorario at gmail.com)
+--SKIPIF--
+<?php
+if(!function_exists('proc_nice')) die("skip. proc_nice not available ");
+?>
 --FILE--
 <?php
 
diff --git a/ext/standard/tests/general_functions/proc_nice_variation2.phpt b/ext/standard/tests/general_functions/proc_nice_variation2.phpt
index 620fe91..42cbf9e 100644
--- a/ext/standard/tests/general_functions/proc_nice_variation2.phpt
+++ b/ext/standard/tests/general_functions/proc_nice_variation2.phpt
@@ -5,6 +5,10 @@ Italian PHP TestFest 2009 Cesena 19-20-21 june
 Fabio Fabbrucci (fabbrucci at grupporetina.com)
 Michele Orselli (mo at ideato.it)
 Simone Gentili (sensorario at gmail.com)
+--SKIPIF--
+<?php
+if(!function_exists('proc_nice')) die("skip. proc_nice not available ");
+?>
 --FILE--
 <?php
 
diff --git a/ext/standard/tests/general_functions/proc_nice_variation3.phpt b/ext/standard/tests/general_functions/proc_nice_variation3.phpt
index 458126d..46b4443 100644
--- a/ext/standard/tests/general_functions/proc_nice_variation3.phpt
+++ b/ext/standard/tests/general_functions/proc_nice_variation3.phpt
@@ -5,6 +5,10 @@ Italian PHP TestFest 2009 Cesena 19-20-21 june
 Fabio Fabbrucci (fabbrucci at grupporetina.com)
 Michele Orselli (mo at ideato.it)
 Simone Gentili (sensorario at gmail.com)
+--SKIPIF--
+<?php
+if(!function_exists('proc_nice')) die("skip. proc_nice not available ");
+?>
 --FILE--
 <?php
 
diff --git a/ext/standard/tests/general_functions/proc_nice_variation5.phpt b/ext/standard/tests/general_functions/proc_nice_variation5.phpt
index d832510..c22ca56 100644
--- a/ext/standard/tests/general_functions/proc_nice_variation5.phpt
+++ b/ext/standard/tests/general_functions/proc_nice_variation5.phpt
@@ -5,6 +5,11 @@ Italian PHP TestFest 2009 Cesena 19-20-21 june
 Fabio Fabbrucci (fabbrucci at grupporetina.com)
 Michele Orselli (mo at ideato.it)
 Simone Gentili (sensorario at gmail.com)
+--SKIPIF--
+<?php
+	if(!function_exists('proc_nice')) die("skip. proc_nice not available ");
+	if(posix_geteuid() == 0) print "skip - Cannot run test as root.";
+?>
 --FILE--
 <?php
 
diff --git a/ext/standard/tests/general_functions/proc_nice_variation6.phpt b/ext/standard/tests/general_functions/proc_nice_variation6.phpt
index b4babd5..d52c0c0 100644
--- a/ext/standard/tests/general_functions/proc_nice_variation6.phpt
+++ b/ext/standard/tests/general_functions/proc_nice_variation6.phpt
@@ -5,6 +5,10 @@ Italian PHP TestFest 2009 Cesena 19-20-21 june
 Fabio Fabbrucci (fabbrucci at grupporetina.com)
 Michele Orselli (mo at ideato.it)
 Simone Gentili (sensorario at gmail.com)
+--SKIPIF--
+<?php
+if(!function_exists('proc_nice')) die("skip. proc_nice not available ");
+?>
 --FILE--
 <?php
 
diff --git a/ext/standard/tests/general_functions/proc_nice_variation7.phpt b/ext/standard/tests/general_functions/proc_nice_variation7.phpt
index 70487dd..26dbab5 100644
--- a/ext/standard/tests/general_functions/proc_nice_variation7.phpt
+++ b/ext/standard/tests/general_functions/proc_nice_variation7.phpt
@@ -5,6 +5,10 @@ Italian PHP TestFest 2009 Cesena 19-20-21 june
 Fabio Fabbrucci (fabbrucci at grupporetina.com)
 Michele Orselli (mo at ideato.it)
 Simone Gentili (sensorario at gmail.com)
+--SKIPIF--
+<?php
+if(!function_exists('proc_nice')) die("skip. proc_nice not available ");
+?>
 --FILE--
 <?php
 
diff --git a/ext/standard/tests/general_functions/putenv_error1.phpt b/ext/standard/tests/general_functions/putenv_error1.phpt
index c5af05a..c4b49f3 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--
-PHP Warning:  Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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 365f0e5..456a7ab 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--
-PHP Warning:  Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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/general_functions/strval.phpt b/ext/standard/tests/general_functions/strval.phpt
index 1789e41..3506785 100644
--- a/ext/standard/tests/general_functions/strval.phpt
+++ b/ext/standard/tests/general_functions/strval.phpt
@@ -267,10 +267,10 @@ string(4) "true"
 -- Iteration 54 --
 string(4) "true"
 -- Iteration 55 --
-string(54) "This is a multiline heredoc
+string(5%d) "This is a multiline heredoc
 string. Numeric = 1232455."
 -- Iteration 56 --
-string(10) "12345
+string(1%d) "12345
 2345"
 -- Iteration 57 --
 string(0) ""
diff --git a/ext/standard/tests/general_functions/sunfuncts.phpt b/ext/standard/tests/general_functions/sunfuncts.phpt
deleted file mode 100644
index 59acb12..0000000
--- a/ext/standard/tests/general_functions/sunfuncts.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-date_sunrise() and date_sunset() functions
---INI--
-precision=13
---FILE--
-<?php
-date_default_timezone_set('Asia/Jerusalem');
-for($a=1;$a<=12;$a++){
-	echo date_sunrise(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_TIMESTAMP,31.76670,35.23330,90.83,2)." ";
-	echo date_sunrise(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_STRING,31.76670,35.23330,90.83,2)." ";
-	echo date_sunrise(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_DOUBLE,31.76670,35.23330,90.83,2)."\n";
-	
-	echo date_sunset(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_TIMESTAMP,31.76670,35.23330,90.83,2)." ";
-	echo date_sunset(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_STRING,31.76670,35.23330,90.83,2)." ";
-	echo date_sunset(mktime(1,1,1,$a,1,2003),SUNFUNCS_RET_DOUBLE,31.76670,35.23330,90.83,2)."\n";
-}
-?>
---EXPECTF--
-1041395864 06:37 6.6290131458%d
-1041432452 16:47 16.792451114%d
-1044073855 06:30 6.5154089279%d
-1044112463 17:14 17.239870289%d
-1046491495 06:04 6.0822145033%d
-1046533075 17:37 17.632011035%d
-1049167581 05:26 5.4394438111%d
-1049212774 17:59 17.993035729%d
-1051757532 04:52 4.8701934126%d
-1051806007 18:20 18.335390508%d
-1054434776 04:32 4.5489827182%d
-1054485647 18:40 18.679812949%d
-1057026949 04:35 4.5971956372%d
-1057078197 18:49 18.832563396%d
-1059706409 04:53 4.8916575089%d
-1059755837 18:37 18.621440704%d
-1062385999 05:13 5.2220951121%d
-1062432291 18:04 18.080957168%d
-1064979098 05:31 5.5273199215%d
-1065021952 17:25 17.431339135%d
-1067658845 05:54 5.9016292870%d
-1067698274 16:51 16.853902453%d
-1070252387 06:19 6.3299242689%d
-1070289382 16:36 16.606312600%d
diff --git a/ext/standard/tests/mail/mail_basic.phpt b/ext/standard/tests/mail/mail_basic.phpt
index 77ff351..fecb50f 100644
--- a/ext/standard/tests/mail/mail_basic.phpt
+++ b/ext/standard/tests/mail/mail_basic.phpt
@@ -2,6 +2,7 @@
 Test mail() function : basic functionality 
 --INI--
 sendmail_path=tee mailBasic.out >/dev/null
+mail.add_x_header = Off
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) == "WIN")
diff --git a/ext/standard/tests/mail/mail_basic2.phpt b/ext/standard/tests/mail/mail_basic2.phpt
index 8f9ef64..2ac4d20 100644
--- a/ext/standard/tests/mail/mail_basic2.phpt
+++ b/ext/standard/tests/mail/mail_basic2.phpt
@@ -6,7 +6,8 @@ if(substr(PHP_OS, 0, 3) == "WIN")
   die("skip Won't run on Windows");
 ?>
 --INI--
-sendmail_path="echo --- > /tmp/php_test_mailBasic2.out"
+sendmail_path="sed > /tmp/php_test_mailBasic2.out"
+mail.add_x_header = Off
 --FILE--
 <?php
 /* Prototype  : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]])
@@ -23,7 +24,7 @@ $to = 'user at company.com';
 $subject = 'Test Subject';
 $message = 'A Message';
 $additional_headers = 'KHeaders';
-$additional_parameters = "Extras";
+$additional_parameters = "-e '5 a--- Extras'";
 $outFile = "/tmp/php_test_mailBasic2.out";
 @unlink($outFile);
 
@@ -31,11 +32,6 @@ echo "-- extra parameters --\n";
 // Calling mail() with all possible arguments
 var_dump( mail($to, $subject, $message, $additional_headers, $additional_parameters) );
 
-//This test is just using a shell command (see the INI setting). The sleep()
-//is used because that can take a while. If you see the test failing sometimes try 
-//increasing the length of the sleep. 
-
-sleep(5);
 echo file_get_contents($outFile);
 unlink($outFile);
 ?>
@@ -44,5 +40,10 @@ unlink($outFile);
 *** Testing mail() : basic functionality ***
 -- extra parameters --
 bool(true)
+To: user at company.com
+Subject: Test Subject
+KHeaders
+
+A Message
 --- Extras
 ===DONE===
diff --git a/ext/standard/tests/mail/mail_variation2.phpt b/ext/standard/tests/mail/mail_variation2.phpt
index 59ef1d9..d6eafd2 100644
--- a/ext/standard/tests/mail/mail_variation2.phpt
+++ b/ext/standard/tests/mail/mail_variation2.phpt
@@ -1,8 +1,9 @@
 --TEST--
 Test mail() function : variation force extra parameters
 --INI--
-sendmail_path="echo --- > /tmp/php_test_mailVariation2.out"
-mail.force_extra_parameters="forced params"
+sendmail_path="sed > /tmp/php_test_mailVariation2.out"
+mail.force_extra_parameters="-e4a---forced-params"
+mail.add_x_header = Off
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) == "WIN")
@@ -35,5 +36,9 @@ unlink($outFile);
 --EXPECT--
 *** Testing mail() : basic functionality ***
 bool(true)
---- forced params
+To: user at company.com
+Subject: Test Subject
+
+A Message
+---forced-params
 ===DONE===
diff --git a/ext/standard/tests/misc/syslog_vars_variation1.phpt b/ext/standard/tests/misc/syslog_vars_variation1.phpt
index c5b9985..ae53a57 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--
-PHP Warning:  Directive 'define_syslog_variables' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Warning: 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/misc/time_sleep_until_error2.phpt b/ext/standard/tests/misc/time_sleep_until_error2.phpt
index 311dd72..d20c8ab 100644
--- a/ext/standard/tests/misc/time_sleep_until_error2.phpt
+++ b/ext/standard/tests/misc/time_sleep_until_error2.phpt
@@ -1,5 +1,9 @@
 --TEST--
 time_sleep_until() function - error test for time_sleep_until()
+--SKIPIF--
+<?php
+	function_exists('time_sleep_until') or die('skip time_sleep_until() is not supported in this build.');
+?>
 --CREDITS--
 Filippo De Santis fd at ideato.it
 #PHPTestFest Cesena Italia on 2009-06-20
diff --git a/ext/standard/tests/network/define_syslog_variables_variation-win32.phpt b/ext/standard/tests/network/define_syslog_variables_variation-win32.phpt
deleted file mode 100644
index ac7dac8..0000000
--- a/ext/standard/tests/network/define_syslog_variables_variation-win32.phpt
+++ /dev/null
@@ -1,97 +0,0 @@
---TEST--
-Test define_syslog_variables() function : variation
---INI--
-define_syslog_variables = true
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) != "WIN")
-  die("skip Only run on Windows");
-?> 
---FILE--
-<?php
-/* Prototype  : void define_syslog_variables(void)
- * Description: Initializes all syslog-related variables 
- * Source code: ext/standard/syslog.c
- * Alias to functions: 
- */
-
-echo "*** Testing define_syslog_variables() : variation ***\n";
-
-$log_constants = array(
-   		LOG_EMERG, 
-   		LOG_ALERT, 
-   		LOG_CRIT, 
-   		LOG_ERR, 
-   		LOG_WARNING, 
-   		LOG_NOTICE, 
-   		LOG_INFO, 
-   		LOG_DEBUG,
-		LOG_KERN, 
-		LOG_USER, 
-		LOG_MAIL, 
-		LOG_DAEMON, 
-		LOG_AUTH, 
-		LOG_SYSLOG, 
-		LOG_LPR, 
-		LOG_NEWS, 
-		LOG_UUCP, 
-		LOG_CRON, 
-		LOG_AUTHPRIV,
-		LOG_PID, 
-		LOG_CONS, 
-		LOG_ODELAY, 
-		LOG_NDELAY, 
-		LOG_NOWAIT, 
-		LOG_PERROR,
-);
-
-
-$log_variables = array(
-   		"LOG_EMERG", 
-   		"LOG_ALERT", 
-   		"LOG_CRIT", 
-   		"LOG_ERR", 
-   		"LOG_WARNING", 
-   		"LOG_NOTICE", 
-   		"LOG_INFO", 
-   		"LOG_DEBUG",
-		"LOG_KERN", 
-		"LOG_USER", 
-		"LOG_MAIL", 
-		"LOG_DAEMON", 
-		"LOG_AUTH", 
-		"LOG_SYSLOG", 
-		"LOG_LPR", 
-		"LOG_NEWS", 
-		"LOG_UUCP", 
-		"LOG_CRON", 
-		"LOG_AUTHPRIV",
-		"LOG_PID", 
-		"LOG_CONS", 
-		"LOG_ODELAY", 
-		"LOG_NDELAY", 
-		"LOG_NOWAIT", 
-		"LOG_PERROR",
-);
-
-error_reporting(E_ALL);
-$failed = false;
-
-// show variables defined
-for ($t = 0; $t < count($log_variables); $t++) {
-   if (isset($$log_variables[$t]) === false || $$log_variables[$t] != $log_constants[$t]) {
-      $failed = true;
-      echo "FAILED: $log_variables[$t] doesn't contain the correct value\n";
-   }
-}
-
-if ($failed == false) {
-   echo "PASSED\n";
-}
-?>
-===DONE===
---EXPECT--
-*** Testing define_syslog_variables() : variation ***
-PASSED
-===DONE===
-PHP Warning:  Directive 'define_syslog_variables' is deprecated in PHP 5.3 and greater in Unknown on line 0
diff --git a/ext/standard/tests/network/define_syslog_variables_variation.phpt b/ext/standard/tests/network/define_syslog_variables_variation.phpt
index 1e35633..e5842b0 100644
--- a/ext/standard/tests/network/define_syslog_variables_variation.phpt
+++ b/ext/standard/tests/network/define_syslog_variables_variation.phpt
@@ -1,12 +1,5 @@
 --TEST--
 Test define_syslog_variables() function : variation
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) == "WIN")
-  die("skip don't run on Windows");
-?> 
---INI--
-define_syslog_variables = true
 --FILE--
 <?php
 /* Prototype  : void define_syslog_variables(void)
@@ -15,6 +8,8 @@ define_syslog_variables = true
  * Alias to functions: 
  */
  
+define_syslog_variables();
+
 echo "*** Testing define_syslog_variables() : variation ***\n";
 
 $log_constants = array(
@@ -90,8 +85,8 @@ if ($failed == false) {
 }
 ?>
 ===DONE===
---EXPECT--
-PHP Warning:  Directive 'define_syslog_variables' is deprecated in PHP 5.3 and greater in Unknown on line 0
+--EXPECTF--
+Deprecated: Function define_syslog_variables() is deprecated in %s on line %d
 *** Testing define_syslog_variables() : variation ***
 PASSED
 ===DONE===
diff --git a/ext/standard/tests/php_ini_loaded_file.phpt b/ext/standard/tests/php_ini_loaded_file.phpt
index ab26953..b443c5f 100644
--- a/ext/standard/tests/php_ini_loaded_file.phpt
+++ b/ext/standard/tests/php_ini_loaded_file.phpt
@@ -8,6 +8,5 @@ Testfest 2009 Munich
 <?php
 var_dump(php_ini_loaded_file());
 ?>
---EXPECT--
-bool(false)
-
+--EXPECTF--
+string(%d) "%s/tmp-php.ini"
diff --git a/ext/standard/tests/streams/bug49936.phpt b/ext/standard/tests/streams/bug49936.phpt
new file mode 100644
index 0000000..d77e161
--- /dev/null
+++ b/ext/standard/tests/streams/bug49936.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #49936 (crash with ftp stream in php_stream_context_get_option())
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == "WIN" )
+  die("skip. Do not run on Windows");
+?>
+--FILE--
+<?php
+
+$dir = 'ftp://your:self@localhost/';
+
+var_dump(opendir($dir));
+var_dump(opendir($dir));
+
+?>
+--EXPECTF--
+Warning: opendir(): connect() failed: Connection refused in %s on line %d
+
+Warning: opendir(ftp://...@localhost/): failed to open dir: operation failed in %s on line %d
+bool(false)
+
+Warning: opendir(): connect() failed: Connection refused in %s on line %d
+
+Warning: opendir(ftp://...@localhost/): failed to open dir: operation failed in %s on line %d
+bool(false)
diff --git a/ext/standard/tests/streams/bug49936_win32.phpt b/ext/standard/tests/streams/bug49936_win32.phpt
new file mode 100644
index 0000000..4db4a50
--- /dev/null
+++ b/ext/standard/tests/streams/bug49936_win32.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #49936 (crash with ftp stream in php_stream_context_get_option())
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != "WIN" )
+  die("skip. Do run on Windows only");
+?>
+--INI--
+default_socket_timeout=2
+--FILE--
+<?php
+
+$dir = 'ftp://your:self@localhost/';
+
+var_dump(opendir($dir));
+var_dump(opendir($dir));
+
+?>
+--EXPECTF--
+Warning: opendir(): connect() failed: %s
+ in %s on line %d
+
+Warning: opendir(ftp://...@localhost/): failed to open dir: operation failed in %s on line %d
+bool(false)
+
+Warning: opendir(): connect() failed: %s
+ in %s on line %d
+
+Warning: opendir(ftp://...@localhost/): failed to open dir: operation failed in %s on line %d
+bool(false)
diff --git a/ext/standard/tests/streams/stream_resolve_include_path.phpt b/ext/standard/tests/streams/stream_resolve_include_path.phpt
new file mode 100644
index 0000000..aea5cdd
--- /dev/null
+++ b/ext/standard/tests/streams/stream_resolve_include_path.phpt
@@ -0,0 +1,37 @@
+--TEST--
+stream_resolve_include_path(string path)
+--FILE--
+<?php
+$include_path = __DIR__ . '/test_path';
+$include_path_nested = $include_path . '/nested';
+
+$include_path_file = $include_path . DIRECTORY_SEPARATOR . 'file';
+$include_path_nested_file = $include_path_nested . DIRECTORY_SEPARATOR . 'file';
+
+mkdir($include_path);
+mkdir($include_path_nested);
+
+file_put_contents($include_path_file, 'include_path');
+file_put_contents($include_path_nested_file, 'include_path');
+
+var_dump(stream_resolve_include_path());
+
+set_include_path($include_path . PATH_SEPARATOR . $include_path_nested);
+var_dump(stream_resolve_include_path('file-does-not-exist'));
+
+set_include_path($include_path . PATH_SEPARATOR . $include_path_nested);
+var_dump(stream_resolve_include_path('file'));
+set_include_path($include_path_nested . PATH_SEPARATOR . $include_path);
+var_dump(stream_resolve_include_path('file'));
+
+unlink($include_path_nested_file);
+rmdir($include_path_nested);
+unlink($include_path_file);
+rmdir($include_path);
+--EXPECTF--
+Warning: stream_resolve_include_path() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+bool(false)
+string(%d) "%stest_path%sfile"
+string(%d) "%stest_path%snested%sfile"
+
diff --git a/ext/standard/tests/strings/bug49785.phpt b/ext/standard/tests/strings/bug49785.phpt
new file mode 100644
index 0000000..fa42dac
--- /dev/null
+++ b/ext/standard/tests/strings/bug49785.phpt
@@ -0,0 +1,4124 @@
+--TEST--
+Bug #49785 (insufficient input string validation of htmlspecialchars())
+--FILE--
+<?php
+function _bin2hex($val) {
+    return is_string($val) ? bin2hex($val): $val;
+}
+
+// UTF-8: basic tests
+var_dump(_bin2hex(htmlentities("\xc1\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xc2\x80", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xc2\x00", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xc2\xc0", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xce\x91", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xce\xb1", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xdf\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xe0\xa0\x80", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xe0\x9f\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xe0\x9f\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xe0\x1f\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xe0\x9f\x3f", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xe0\x1f\x3f", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xe2\x99\xa5", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xef\xbf\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xef\xff\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xef\xbf\xff", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf0\x8f\xbf\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf0\x90\x80\x80", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf7\xbf\xbf\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf7\x3f\xbf\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf7\xbf\x3f\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf7\xbf\xbf\x3f", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf7\xff\xbf\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf7\xbf\xff\xbf", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf7\xbf\xbf\xff", ENT_QUOTES, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf8\x88\x80\x80\x80", ENT_QUOTES, "UTF-8")));
+
+echo "--\n";
+// UTF-8: with ENT_IGNORE
+var_dump(_bin2hex(htmlentities("\xc0\xa0\xc2\x80", ENT_QUOTES | ENT_IGNORE, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xe0\x80\x80\xe0\xa0\x80", ENT_QUOTES | ENT_IGNORE, "UTF-8")));
+var_dump(_bin2hex(htmlentities("\xf0\x80\x80\x80\xf0\x90\x80\x80", ENT_QUOTES | ENT_IGNORE, "UTF-8")));
+
+echo "--\n";
+// UTF-8: alternative (invalid) UTF-8 sequence / surrogate pairs
+var_dump(_bin2hex(htmlspecialchars("\xc0\xa6", ENT_QUOTES, 'UTF-8')));
+var_dump(_bin2hex(htmlspecialchars("\xe0\x80\xa6", ENT_QUOTES, 'UTF-8')));
+var_dump(_bin2hex(htmlspecialchars("\xf0\x80\x80\xa6", ENT_QUOTES, 'UTF-8')));
+var_dump(_bin2hex(htmlspecialchars("\xec\xbf\xbf", ENT_QUOTES, 'UTF-8')));
+var_dump(_bin2hex(htmlspecialchars("\xed\xa0\x80", ENT_QUOTES, 'UTF-8')));
+var_dump(_bin2hex(htmlspecialchars("\xed\xbf\xbf", ENT_QUOTES, 'UTF-8')));
+var_dump(_bin2hex(htmlspecialchars("\xee\x80\x80", ENT_QUOTES, 'UTF-8')));
+
+// Shift_JIS: non-lead byte >= 0x80
+var_dump(_bin2hex(htmlspecialchars("\x80", ENT_QUOTES, 'Shift_JIS')));
+foreach (array_map('chr', range(0xa0, 0xdf)) as $c) {
+    var_dump(_bin2hex(htmlspecialchars($c, ENT_QUOTES, 'Shift_JIS')));
+}
+var_dump(_bin2hex(htmlspecialchars("\xfd", ENT_QUOTES, 'Shift_JIS')));
+var_dump(_bin2hex(htmlspecialchars("\xfe", ENT_QUOTES, 'Shift_JIS')));
+var_dump(_bin2hex(htmlspecialchars("\xff", ENT_QUOTES, 'Shift_JIS')));
+
+echo "--\n";
+// Shift_JIS: incomplete / invalid multibyte sequences
+foreach (array_map('chr', array_merge(range(0x81, 0x9f), range(0xe0, 0xfc))) as $c) {
+    var_dump(_bin2hex(htmlspecialchars("$c", ENT_QUOTES, 'Shift_JIS')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x3f", ENT_QUOTES, 'Shift_JIS')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x40", ENT_QUOTES, 'Shift_JIS')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x7e", ENT_QUOTES, 'Shift_JIS')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x7f", ENT_QUOTES, 'Shift_JIS')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x80", ENT_QUOTES, 'Shift_JIS')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xfc", ENT_QUOTES, 'Shift_JIS')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xfd", ENT_QUOTES, 'Shift_JIS')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xfe", ENT_QUOTES, 'Shift_JIS')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xff", ENT_QUOTES, 'Shift_JIS')));
+}
+
+echo "--\n";
+// EUC-JP: non-lead byte >= 0x80
+foreach (array_map('chr', array_merge(range(0x80, 0x8d), range(0x90, 0x9f))) as $c) {
+    var_dump(_bin2hex(htmlspecialchars($c, ENT_QUOTES, 'EUC-JP')));
+}
+var_dump(_bin2hex(htmlspecialchars("\xff", ENT_QUOTES, 'EUC-JP')));
+
+// EUC-JP: control codes that are virtually lead bytes
+var_dump(_bin2hex(htmlspecialchars("\x8e", ENT_QUOTES, 'EUC-JP')));
+var_dump(_bin2hex(htmlspecialchars("\x8f", ENT_QUOTES, 'EUC-JP')));
+var_dump(_bin2hex(htmlspecialchars("\x8e\xa1", ENT_QUOTES, 'EUC-JP')));
+var_dump(_bin2hex(htmlspecialchars("\x8f\xa1", ENT_QUOTES, 'EUC-JP')));
+var_dump(_bin2hex(htmlspecialchars("\x8e\xa1\xa3", ENT_QUOTES, 'EUC-JP')));
+var_dump(_bin2hex(htmlspecialchars("\x8f\xa1\xa3", ENT_QUOTES, 'EUC-JP')));
+
+echo "--\n";
+// EUC-JP: incomplete / invalid multibyte sequences
+foreach (array_map('chr', array_merge(range(0xa1, 0xfe))) as $c) {
+    var_dump(_bin2hex(htmlspecialchars("$c", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x26", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x80", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xa0", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xa1", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xfe", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xff", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8e$c", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8e$c\x26", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8e$c\x80", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8e$c\xa0", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8e$c\xa1", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8e$c\xfe", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8e$c\xff", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8f$c", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8f$c\x26", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8f$c\x80", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8f$c\xa0", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8f$c\xa1", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8f$c\xfe", ENT_QUOTES, 'EUC-JP')));
+    var_dump(_bin2hex(htmlspecialchars("\x8f$c\xff", ENT_QUOTES, 'EUC-JP')));
+}
+
+echo "--\n";
+// BIG5: non-lead byte >= 0x80
+var_dump(_bin2hex(htmlspecialchars("\x80", ENT_QUOTES, 'BIG5')));
+var_dump(_bin2hex(htmlspecialchars("\xff", ENT_QUOTES, 'BIG5')));
+
+echo "--\n";
+// BIG5: incomplete / invalid multibyte sequences
+foreach (array_map('chr', range(0x81, 0xfe)) as $c) {
+    var_dump(_bin2hex(htmlspecialchars("$c", ENT_QUOTES, 'BIG5')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x3f", ENT_QUOTES, 'BIG5')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x40", ENT_QUOTES, 'BIG5')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x7e", ENT_QUOTES, 'BIG5')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x7f", ENT_QUOTES, 'BIG5')));
+    var_dump(_bin2hex(htmlspecialchars("$c\x80", ENT_QUOTES, 'BIG5')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xa0", ENT_QUOTES, 'BIG5')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xa1", ENT_QUOTES, 'BIG5')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xfe", ENT_QUOTES, 'BIG5')));
+    var_dump(_bin2hex(htmlspecialchars("$c\xff", ENT_QUOTES, 'BIG5')));
+}
+?>
+--EXPECT--
+string(0) ""
+string(4) "c280"
+string(0) ""
+string(0) ""
+string(14) "26416c7068613b"
+string(14) "26616c7068613b"
+string(4) "dfbf"
+string(6) "e0a080"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(16) "266865617274733b"
+string(6) "efbfbf"
+string(0) ""
+string(0) ""
+string(0) ""
+string(8) "f0908080"
+string(8) "f7bfbfbf"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+--
+string(4) "c280"
+string(6) "e0a080"
+string(8) "f0908080"
+--
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "ecbfbf"
+string(0) ""
+string(0) ""
+string(6) "ee8080"
+string(2) "80"
+string(2) "a0"
+string(2) "a1"
+string(2) "a2"
+string(2) "a3"
+string(2) "a4"
+string(2) "a5"
+string(2) "a6"
+string(2) "a7"
+string(2) "a8"
+string(2) "a9"
+string(2) "aa"
+string(2) "ab"
+string(2) "ac"
+string(2) "ad"
+string(2) "ae"
+string(2) "af"
+string(2) "b0"
+string(2) "b1"
+string(2) "b2"
+string(2) "b3"
+string(2) "b4"
+string(2) "b5"
+string(2) "b6"
+string(2) "b7"
+string(2) "b8"
+string(2) "b9"
+string(2) "ba"
+string(2) "bb"
+string(2) "bc"
+string(2) "bd"
+string(2) "be"
+string(2) "bf"
+string(2) "c0"
+string(2) "c1"
+string(2) "c2"
+string(2) "c3"
+string(2) "c4"
+string(2) "c5"
+string(2) "c6"
+string(2) "c7"
+string(2) "c8"
+string(2) "c9"
+string(2) "ca"
+string(2) "cb"
+string(2) "cc"
+string(2) "cd"
+string(2) "ce"
+string(2) "cf"
+string(2) "d0"
+string(2) "d1"
+string(2) "d2"
+string(2) "d3"
+string(2) "d4"
+string(2) "d5"
+string(2) "d6"
+string(2) "d7"
+string(2) "d8"
+string(2) "d9"
+string(2) "da"
+string(2) "db"
+string(2) "dc"
+string(2) "dd"
+string(2) "de"
+string(2) "df"
+string(2) "fd"
+string(2) "fe"
+string(2) "ff"
+--
+string(0) ""
+string(0) ""
+string(4) "8140"
+string(4) "817e"
+string(0) ""
+string(4) "8180"
+string(4) "81fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8240"
+string(4) "827e"
+string(0) ""
+string(4) "8280"
+string(4) "82fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8340"
+string(4) "837e"
+string(0) ""
+string(4) "8380"
+string(4) "83fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8440"
+string(4) "847e"
+string(0) ""
+string(4) "8480"
+string(4) "84fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8540"
+string(4) "857e"
+string(0) ""
+string(4) "8580"
+string(4) "85fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8640"
+string(4) "867e"
+string(0) ""
+string(4) "8680"
+string(4) "86fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8740"
+string(4) "877e"
+string(0) ""
+string(4) "8780"
+string(4) "87fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8840"
+string(4) "887e"
+string(0) ""
+string(4) "8880"
+string(4) "88fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8940"
+string(4) "897e"
+string(0) ""
+string(4) "8980"
+string(4) "89fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8a40"
+string(4) "8a7e"
+string(0) ""
+string(4) "8a80"
+string(4) "8afc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8b40"
+string(4) "8b7e"
+string(0) ""
+string(4) "8b80"
+string(4) "8bfc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8c40"
+string(4) "8c7e"
+string(0) ""
+string(4) "8c80"
+string(4) "8cfc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8d40"
+string(4) "8d7e"
+string(0) ""
+string(4) "8d80"
+string(4) "8dfc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8e40"
+string(4) "8e7e"
+string(0) ""
+string(4) "8e80"
+string(4) "8efc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8f40"
+string(4) "8f7e"
+string(0) ""
+string(4) "8f80"
+string(4) "8ffc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9040"
+string(4) "907e"
+string(0) ""
+string(4) "9080"
+string(4) "90fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9140"
+string(4) "917e"
+string(0) ""
+string(4) "9180"
+string(4) "91fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9240"
+string(4) "927e"
+string(0) ""
+string(4) "9280"
+string(4) "92fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9340"
+string(4) "937e"
+string(0) ""
+string(4) "9380"
+string(4) "93fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9440"
+string(4) "947e"
+string(0) ""
+string(4) "9480"
+string(4) "94fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9540"
+string(4) "957e"
+string(0) ""
+string(4) "9580"
+string(4) "95fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9640"
+string(4) "967e"
+string(0) ""
+string(4) "9680"
+string(4) "96fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9740"
+string(4) "977e"
+string(0) ""
+string(4) "9780"
+string(4) "97fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9840"
+string(4) "987e"
+string(0) ""
+string(4) "9880"
+string(4) "98fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9940"
+string(4) "997e"
+string(0) ""
+string(4) "9980"
+string(4) "99fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9a40"
+string(4) "9a7e"
+string(0) ""
+string(4) "9a80"
+string(4) "9afc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9b40"
+string(4) "9b7e"
+string(0) ""
+string(4) "9b80"
+string(4) "9bfc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9c40"
+string(4) "9c7e"
+string(0) ""
+string(4) "9c80"
+string(4) "9cfc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9d40"
+string(4) "9d7e"
+string(0) ""
+string(4) "9d80"
+string(4) "9dfc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9e40"
+string(4) "9e7e"
+string(0) ""
+string(4) "9e80"
+string(4) "9efc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9f40"
+string(4) "9f7e"
+string(0) ""
+string(4) "9f80"
+string(4) "9ffc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e040"
+string(4) "e07e"
+string(0) ""
+string(4) "e080"
+string(4) "e0fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e140"
+string(4) "e17e"
+string(0) ""
+string(4) "e180"
+string(4) "e1fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e240"
+string(4) "e27e"
+string(0) ""
+string(4) "e280"
+string(4) "e2fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e340"
+string(4) "e37e"
+string(0) ""
+string(4) "e380"
+string(4) "e3fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e440"
+string(4) "e47e"
+string(0) ""
+string(4) "e480"
+string(4) "e4fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e540"
+string(4) "e57e"
+string(0) ""
+string(4) "e580"
+string(4) "e5fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e640"
+string(4) "e67e"
+string(0) ""
+string(4) "e680"
+string(4) "e6fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e740"
+string(4) "e77e"
+string(0) ""
+string(4) "e780"
+string(4) "e7fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e840"
+string(4) "e87e"
+string(0) ""
+string(4) "e880"
+string(4) "e8fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e940"
+string(4) "e97e"
+string(0) ""
+string(4) "e980"
+string(4) "e9fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ea40"
+string(4) "ea7e"
+string(0) ""
+string(4) "ea80"
+string(4) "eafc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eb40"
+string(4) "eb7e"
+string(0) ""
+string(4) "eb80"
+string(4) "ebfc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ec40"
+string(4) "ec7e"
+string(0) ""
+string(4) "ec80"
+string(4) "ecfc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ed40"
+string(4) "ed7e"
+string(0) ""
+string(4) "ed80"
+string(4) "edfc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ee40"
+string(4) "ee7e"
+string(0) ""
+string(4) "ee80"
+string(4) "eefc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ef40"
+string(4) "ef7e"
+string(0) ""
+string(4) "ef80"
+string(4) "effc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f040"
+string(4) "f07e"
+string(0) ""
+string(4) "f080"
+string(4) "f0fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f140"
+string(4) "f17e"
+string(0) ""
+string(4) "f180"
+string(4) "f1fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f240"
+string(4) "f27e"
+string(0) ""
+string(4) "f280"
+string(4) "f2fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f340"
+string(4) "f37e"
+string(0) ""
+string(4) "f380"
+string(4) "f3fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f440"
+string(4) "f47e"
+string(0) ""
+string(4) "f480"
+string(4) "f4fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f540"
+string(4) "f57e"
+string(0) ""
+string(4) "f580"
+string(4) "f5fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f640"
+string(4) "f67e"
+string(0) ""
+string(4) "f680"
+string(4) "f6fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f740"
+string(4) "f77e"
+string(0) ""
+string(4) "f780"
+string(4) "f7fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f840"
+string(4) "f87e"
+string(0) ""
+string(4) "f880"
+string(4) "f8fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f940"
+string(4) "f97e"
+string(0) ""
+string(4) "f980"
+string(4) "f9fc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fa40"
+string(4) "fa7e"
+string(0) ""
+string(4) "fa80"
+string(4) "fafc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fb40"
+string(4) "fb7e"
+string(0) ""
+string(4) "fb80"
+string(4) "fbfc"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fc40"
+string(4) "fc7e"
+string(0) ""
+string(4) "fc80"
+string(4) "fcfc"
+string(0) ""
+string(0) ""
+string(0) ""
+--
+string(2) "80"
+string(2) "81"
+string(2) "82"
+string(2) "83"
+string(2) "84"
+string(2) "85"
+string(2) "86"
+string(2) "87"
+string(2) "88"
+string(2) "89"
+string(2) "8a"
+string(2) "8b"
+string(2) "8c"
+string(2) "8d"
+string(2) "90"
+string(2) "91"
+string(2) "92"
+string(2) "93"
+string(2) "94"
+string(2) "95"
+string(2) "96"
+string(2) "97"
+string(2) "98"
+string(2) "99"
+string(2) "9a"
+string(2) "9b"
+string(2) "9c"
+string(2) "9d"
+string(2) "9e"
+string(2) "9f"
+string(2) "ff"
+string(0) ""
+string(0) ""
+string(4) "8ea1"
+string(0) ""
+string(0) ""
+string(6) "8fa1a3"
+--
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a1a1"
+string(4) "a1fe"
+string(0) ""
+string(4) "8ea1"
+string(14) "8ea126616d703b"
+string(6) "8ea180"
+string(6) "8ea1a0"
+string(0) ""
+string(0) ""
+string(6) "8ea1ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fa1a1"
+string(6) "8fa1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a2a1"
+string(4) "a2fe"
+string(0) ""
+string(4) "8ea2"
+string(14) "8ea226616d703b"
+string(6) "8ea280"
+string(6) "8ea2a0"
+string(0) ""
+string(0) ""
+string(6) "8ea2ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fa2a1"
+string(6) "8fa2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a3a1"
+string(4) "a3fe"
+string(0) ""
+string(4) "8ea3"
+string(14) "8ea326616d703b"
+string(6) "8ea380"
+string(6) "8ea3a0"
+string(0) ""
+string(0) ""
+string(6) "8ea3ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fa3a1"
+string(6) "8fa3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a4a1"
+string(4) "a4fe"
+string(0) ""
+string(4) "8ea4"
+string(14) "8ea426616d703b"
+string(6) "8ea480"
+string(6) "8ea4a0"
+string(0) ""
+string(0) ""
+string(6) "8ea4ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fa4a1"
+string(6) "8fa4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a5a1"
+string(4) "a5fe"
+string(0) ""
+string(4) "8ea5"
+string(14) "8ea526616d703b"
+string(6) "8ea580"
+string(6) "8ea5a0"
+string(0) ""
+string(0) ""
+string(6) "8ea5ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fa5a1"
+string(6) "8fa5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a6a1"
+string(4) "a6fe"
+string(0) ""
+string(4) "8ea6"
+string(14) "8ea626616d703b"
+string(6) "8ea680"
+string(6) "8ea6a0"
+string(0) ""
+string(0) ""
+string(6) "8ea6ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fa6a1"
+string(6) "8fa6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a7a1"
+string(4) "a7fe"
+string(0) ""
+string(4) "8ea7"
+string(14) "8ea726616d703b"
+string(6) "8ea780"
+string(6) "8ea7a0"
+string(0) ""
+string(0) ""
+string(6) "8ea7ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fa7a1"
+string(6) "8fa7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a8a1"
+string(4) "a8fe"
+string(0) ""
+string(4) "8ea8"
+string(14) "8ea826616d703b"
+string(6) "8ea880"
+string(6) "8ea8a0"
+string(0) ""
+string(0) ""
+string(6) "8ea8ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fa8a1"
+string(6) "8fa8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a9a1"
+string(4) "a9fe"
+string(0) ""
+string(4) "8ea9"
+string(14) "8ea926616d703b"
+string(6) "8ea980"
+string(6) "8ea9a0"
+string(0) ""
+string(0) ""
+string(6) "8ea9ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fa9a1"
+string(6) "8fa9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "aaa1"
+string(4) "aafe"
+string(0) ""
+string(4) "8eaa"
+string(14) "8eaa26616d703b"
+string(6) "8eaa80"
+string(6) "8eaaa0"
+string(0) ""
+string(0) ""
+string(6) "8eaaff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8faaa1"
+string(6) "8faafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "aba1"
+string(4) "abfe"
+string(0) ""
+string(4) "8eab"
+string(14) "8eab26616d703b"
+string(6) "8eab80"
+string(6) "8eaba0"
+string(0) ""
+string(0) ""
+string(6) "8eabff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8faba1"
+string(6) "8fabfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "aca1"
+string(4) "acfe"
+string(0) ""
+string(4) "8eac"
+string(14) "8eac26616d703b"
+string(6) "8eac80"
+string(6) "8eaca0"
+string(0) ""
+string(0) ""
+string(6) "8eacff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8faca1"
+string(6) "8facfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ada1"
+string(4) "adfe"
+string(0) ""
+string(4) "8ead"
+string(14) "8ead26616d703b"
+string(6) "8ead80"
+string(6) "8eada0"
+string(0) ""
+string(0) ""
+string(6) "8eadff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fada1"
+string(6) "8fadfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "aea1"
+string(4) "aefe"
+string(0) ""
+string(4) "8eae"
+string(14) "8eae26616d703b"
+string(6) "8eae80"
+string(6) "8eaea0"
+string(0) ""
+string(0) ""
+string(6) "8eaeff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8faea1"
+string(6) "8faefe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "afa1"
+string(4) "affe"
+string(0) ""
+string(4) "8eaf"
+string(14) "8eaf26616d703b"
+string(6) "8eaf80"
+string(6) "8eafa0"
+string(0) ""
+string(0) ""
+string(6) "8eafff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fafa1"
+string(6) "8faffe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b0a1"
+string(4) "b0fe"
+string(0) ""
+string(4) "8eb0"
+string(14) "8eb026616d703b"
+string(6) "8eb080"
+string(6) "8eb0a0"
+string(0) ""
+string(0) ""
+string(6) "8eb0ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fb0a1"
+string(6) "8fb0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b1a1"
+string(4) "b1fe"
+string(0) ""
+string(4) "8eb1"
+string(14) "8eb126616d703b"
+string(6) "8eb180"
+string(6) "8eb1a0"
+string(0) ""
+string(0) ""
+string(6) "8eb1ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fb1a1"
+string(6) "8fb1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b2a1"
+string(4) "b2fe"
+string(0) ""
+string(4) "8eb2"
+string(14) "8eb226616d703b"
+string(6) "8eb280"
+string(6) "8eb2a0"
+string(0) ""
+string(0) ""
+string(6) "8eb2ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fb2a1"
+string(6) "8fb2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b3a1"
+string(4) "b3fe"
+string(0) ""
+string(4) "8eb3"
+string(14) "8eb326616d703b"
+string(6) "8eb380"
+string(6) "8eb3a0"
+string(0) ""
+string(0) ""
+string(6) "8eb3ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fb3a1"
+string(6) "8fb3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b4a1"
+string(4) "b4fe"
+string(0) ""
+string(4) "8eb4"
+string(14) "8eb426616d703b"
+string(6) "8eb480"
+string(6) "8eb4a0"
+string(0) ""
+string(0) ""
+string(6) "8eb4ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fb4a1"
+string(6) "8fb4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b5a1"
+string(4) "b5fe"
+string(0) ""
+string(4) "8eb5"
+string(14) "8eb526616d703b"
+string(6) "8eb580"
+string(6) "8eb5a0"
+string(0) ""
+string(0) ""
+string(6) "8eb5ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fb5a1"
+string(6) "8fb5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b6a1"
+string(4) "b6fe"
+string(0) ""
+string(4) "8eb6"
+string(14) "8eb626616d703b"
+string(6) "8eb680"
+string(6) "8eb6a0"
+string(0) ""
+string(0) ""
+string(6) "8eb6ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fb6a1"
+string(6) "8fb6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b7a1"
+string(4) "b7fe"
+string(0) ""
+string(4) "8eb7"
+string(14) "8eb726616d703b"
+string(6) "8eb780"
+string(6) "8eb7a0"
+string(0) ""
+string(0) ""
+string(6) "8eb7ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fb7a1"
+string(6) "8fb7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b8a1"
+string(4) "b8fe"
+string(0) ""
+string(4) "8eb8"
+string(14) "8eb826616d703b"
+string(6) "8eb880"
+string(6) "8eb8a0"
+string(0) ""
+string(0) ""
+string(6) "8eb8ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fb8a1"
+string(6) "8fb8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b9a1"
+string(4) "b9fe"
+string(0) ""
+string(4) "8eb9"
+string(14) "8eb926616d703b"
+string(6) "8eb980"
+string(6) "8eb9a0"
+string(0) ""
+string(0) ""
+string(6) "8eb9ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fb9a1"
+string(6) "8fb9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "baa1"
+string(4) "bafe"
+string(0) ""
+string(4) "8eba"
+string(14) "8eba26616d703b"
+string(6) "8eba80"
+string(6) "8ebaa0"
+string(0) ""
+string(0) ""
+string(6) "8ebaff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fbaa1"
+string(6) "8fbafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bba1"
+string(4) "bbfe"
+string(0) ""
+string(4) "8ebb"
+string(14) "8ebb26616d703b"
+string(6) "8ebb80"
+string(6) "8ebba0"
+string(0) ""
+string(0) ""
+string(6) "8ebbff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fbba1"
+string(6) "8fbbfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bca1"
+string(4) "bcfe"
+string(0) ""
+string(4) "8ebc"
+string(14) "8ebc26616d703b"
+string(6) "8ebc80"
+string(6) "8ebca0"
+string(0) ""
+string(0) ""
+string(6) "8ebcff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fbca1"
+string(6) "8fbcfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bda1"
+string(4) "bdfe"
+string(0) ""
+string(4) "8ebd"
+string(14) "8ebd26616d703b"
+string(6) "8ebd80"
+string(6) "8ebda0"
+string(0) ""
+string(0) ""
+string(6) "8ebdff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fbda1"
+string(6) "8fbdfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bea1"
+string(4) "befe"
+string(0) ""
+string(4) "8ebe"
+string(14) "8ebe26616d703b"
+string(6) "8ebe80"
+string(6) "8ebea0"
+string(0) ""
+string(0) ""
+string(6) "8ebeff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fbea1"
+string(6) "8fbefe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bfa1"
+string(4) "bffe"
+string(0) ""
+string(4) "8ebf"
+string(14) "8ebf26616d703b"
+string(6) "8ebf80"
+string(6) "8ebfa0"
+string(0) ""
+string(0) ""
+string(6) "8ebfff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fbfa1"
+string(6) "8fbffe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c0a1"
+string(4) "c0fe"
+string(0) ""
+string(4) "8ec0"
+string(14) "8ec026616d703b"
+string(6) "8ec080"
+string(6) "8ec0a0"
+string(0) ""
+string(0) ""
+string(6) "8ec0ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fc0a1"
+string(6) "8fc0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c1a1"
+string(4) "c1fe"
+string(0) ""
+string(4) "8ec1"
+string(14) "8ec126616d703b"
+string(6) "8ec180"
+string(6) "8ec1a0"
+string(0) ""
+string(0) ""
+string(6) "8ec1ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fc1a1"
+string(6) "8fc1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c2a1"
+string(4) "c2fe"
+string(0) ""
+string(4) "8ec2"
+string(14) "8ec226616d703b"
+string(6) "8ec280"
+string(6) "8ec2a0"
+string(0) ""
+string(0) ""
+string(6) "8ec2ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fc2a1"
+string(6) "8fc2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c3a1"
+string(4) "c3fe"
+string(0) ""
+string(4) "8ec3"
+string(14) "8ec326616d703b"
+string(6) "8ec380"
+string(6) "8ec3a0"
+string(0) ""
+string(0) ""
+string(6) "8ec3ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fc3a1"
+string(6) "8fc3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c4a1"
+string(4) "c4fe"
+string(0) ""
+string(4) "8ec4"
+string(14) "8ec426616d703b"
+string(6) "8ec480"
+string(6) "8ec4a0"
+string(0) ""
+string(0) ""
+string(6) "8ec4ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fc4a1"
+string(6) "8fc4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c5a1"
+string(4) "c5fe"
+string(0) ""
+string(4) "8ec5"
+string(14) "8ec526616d703b"
+string(6) "8ec580"
+string(6) "8ec5a0"
+string(0) ""
+string(0) ""
+string(6) "8ec5ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fc5a1"
+string(6) "8fc5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c6a1"
+string(4) "c6fe"
+string(0) ""
+string(4) "8ec6"
+string(14) "8ec626616d703b"
+string(6) "8ec680"
+string(6) "8ec6a0"
+string(0) ""
+string(0) ""
+string(6) "8ec6ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fc6a1"
+string(6) "8fc6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c7a1"
+string(4) "c7fe"
+string(0) ""
+string(4) "8ec7"
+string(14) "8ec726616d703b"
+string(6) "8ec780"
+string(6) "8ec7a0"
+string(0) ""
+string(0) ""
+string(6) "8ec7ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fc7a1"
+string(6) "8fc7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c8a1"
+string(4) "c8fe"
+string(0) ""
+string(4) "8ec8"
+string(14) "8ec826616d703b"
+string(6) "8ec880"
+string(6) "8ec8a0"
+string(0) ""
+string(0) ""
+string(6) "8ec8ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fc8a1"
+string(6) "8fc8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c9a1"
+string(4) "c9fe"
+string(0) ""
+string(4) "8ec9"
+string(14) "8ec926616d703b"
+string(6) "8ec980"
+string(6) "8ec9a0"
+string(0) ""
+string(0) ""
+string(6) "8ec9ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fc9a1"
+string(6) "8fc9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "caa1"
+string(4) "cafe"
+string(0) ""
+string(4) "8eca"
+string(14) "8eca26616d703b"
+string(6) "8eca80"
+string(6) "8ecaa0"
+string(0) ""
+string(0) ""
+string(6) "8ecaff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fcaa1"
+string(6) "8fcafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cba1"
+string(4) "cbfe"
+string(0) ""
+string(4) "8ecb"
+string(14) "8ecb26616d703b"
+string(6) "8ecb80"
+string(6) "8ecba0"
+string(0) ""
+string(0) ""
+string(6) "8ecbff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fcba1"
+string(6) "8fcbfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cca1"
+string(4) "ccfe"
+string(0) ""
+string(4) "8ecc"
+string(14) "8ecc26616d703b"
+string(6) "8ecc80"
+string(6) "8ecca0"
+string(0) ""
+string(0) ""
+string(6) "8eccff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fcca1"
+string(6) "8fccfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cda1"
+string(4) "cdfe"
+string(0) ""
+string(4) "8ecd"
+string(14) "8ecd26616d703b"
+string(6) "8ecd80"
+string(6) "8ecda0"
+string(0) ""
+string(0) ""
+string(6) "8ecdff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fcda1"
+string(6) "8fcdfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cea1"
+string(4) "cefe"
+string(0) ""
+string(4) "8ece"
+string(14) "8ece26616d703b"
+string(6) "8ece80"
+string(6) "8ecea0"
+string(0) ""
+string(0) ""
+string(6) "8eceff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fcea1"
+string(6) "8fcefe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cfa1"
+string(4) "cffe"
+string(0) ""
+string(4) "8ecf"
+string(14) "8ecf26616d703b"
+string(6) "8ecf80"
+string(6) "8ecfa0"
+string(0) ""
+string(0) ""
+string(6) "8ecfff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fcfa1"
+string(6) "8fcffe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d0a1"
+string(4) "d0fe"
+string(0) ""
+string(4) "8ed0"
+string(14) "8ed026616d703b"
+string(6) "8ed080"
+string(6) "8ed0a0"
+string(0) ""
+string(0) ""
+string(6) "8ed0ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fd0a1"
+string(6) "8fd0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d1a1"
+string(4) "d1fe"
+string(0) ""
+string(4) "8ed1"
+string(14) "8ed126616d703b"
+string(6) "8ed180"
+string(6) "8ed1a0"
+string(0) ""
+string(0) ""
+string(6) "8ed1ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fd1a1"
+string(6) "8fd1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d2a1"
+string(4) "d2fe"
+string(0) ""
+string(4) "8ed2"
+string(14) "8ed226616d703b"
+string(6) "8ed280"
+string(6) "8ed2a0"
+string(0) ""
+string(0) ""
+string(6) "8ed2ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fd2a1"
+string(6) "8fd2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d3a1"
+string(4) "d3fe"
+string(0) ""
+string(4) "8ed3"
+string(14) "8ed326616d703b"
+string(6) "8ed380"
+string(6) "8ed3a0"
+string(0) ""
+string(0) ""
+string(6) "8ed3ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fd3a1"
+string(6) "8fd3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d4a1"
+string(4) "d4fe"
+string(0) ""
+string(4) "8ed4"
+string(14) "8ed426616d703b"
+string(6) "8ed480"
+string(6) "8ed4a0"
+string(0) ""
+string(0) ""
+string(6) "8ed4ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fd4a1"
+string(6) "8fd4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d5a1"
+string(4) "d5fe"
+string(0) ""
+string(4) "8ed5"
+string(14) "8ed526616d703b"
+string(6) "8ed580"
+string(6) "8ed5a0"
+string(0) ""
+string(0) ""
+string(6) "8ed5ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fd5a1"
+string(6) "8fd5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d6a1"
+string(4) "d6fe"
+string(0) ""
+string(4) "8ed6"
+string(14) "8ed626616d703b"
+string(6) "8ed680"
+string(6) "8ed6a0"
+string(0) ""
+string(0) ""
+string(6) "8ed6ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fd6a1"
+string(6) "8fd6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d7a1"
+string(4) "d7fe"
+string(0) ""
+string(4) "8ed7"
+string(14) "8ed726616d703b"
+string(6) "8ed780"
+string(6) "8ed7a0"
+string(0) ""
+string(0) ""
+string(6) "8ed7ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fd7a1"
+string(6) "8fd7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d8a1"
+string(4) "d8fe"
+string(0) ""
+string(4) "8ed8"
+string(14) "8ed826616d703b"
+string(6) "8ed880"
+string(6) "8ed8a0"
+string(0) ""
+string(0) ""
+string(6) "8ed8ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fd8a1"
+string(6) "8fd8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d9a1"
+string(4) "d9fe"
+string(0) ""
+string(4) "8ed9"
+string(14) "8ed926616d703b"
+string(6) "8ed980"
+string(6) "8ed9a0"
+string(0) ""
+string(0) ""
+string(6) "8ed9ff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fd9a1"
+string(6) "8fd9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "daa1"
+string(4) "dafe"
+string(0) ""
+string(4) "8eda"
+string(14) "8eda26616d703b"
+string(6) "8eda80"
+string(6) "8edaa0"
+string(0) ""
+string(0) ""
+string(6) "8edaff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fdaa1"
+string(6) "8fdafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dba1"
+string(4) "dbfe"
+string(0) ""
+string(4) "8edb"
+string(14) "8edb26616d703b"
+string(6) "8edb80"
+string(6) "8edba0"
+string(0) ""
+string(0) ""
+string(6) "8edbff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fdba1"
+string(6) "8fdbfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dca1"
+string(4) "dcfe"
+string(0) ""
+string(4) "8edc"
+string(14) "8edc26616d703b"
+string(6) "8edc80"
+string(6) "8edca0"
+string(0) ""
+string(0) ""
+string(6) "8edcff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fdca1"
+string(6) "8fdcfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dda1"
+string(4) "ddfe"
+string(0) ""
+string(4) "8edd"
+string(14) "8edd26616d703b"
+string(6) "8edd80"
+string(6) "8edda0"
+string(0) ""
+string(0) ""
+string(6) "8eddff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fdda1"
+string(6) "8fddfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dea1"
+string(4) "defe"
+string(0) ""
+string(4) "8ede"
+string(14) "8ede26616d703b"
+string(6) "8ede80"
+string(6) "8edea0"
+string(0) ""
+string(0) ""
+string(6) "8edeff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fdea1"
+string(6) "8fdefe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dfa1"
+string(4) "dffe"
+string(0) ""
+string(4) "8edf"
+string(14) "8edf26616d703b"
+string(6) "8edf80"
+string(6) "8edfa0"
+string(0) ""
+string(0) ""
+string(6) "8edfff"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fdfa1"
+string(6) "8fdffe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e0a1"
+string(4) "e0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fe0a1"
+string(6) "8fe0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e1a1"
+string(4) "e1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fe1a1"
+string(6) "8fe1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e2a1"
+string(4) "e2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fe2a1"
+string(6) "8fe2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e3a1"
+string(4) "e3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fe3a1"
+string(6) "8fe3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e4a1"
+string(4) "e4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fe4a1"
+string(6) "8fe4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e5a1"
+string(4) "e5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fe5a1"
+string(6) "8fe5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e6a1"
+string(4) "e6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fe6a1"
+string(6) "8fe6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e7a1"
+string(4) "e7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fe7a1"
+string(6) "8fe7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e8a1"
+string(4) "e8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fe8a1"
+string(6) "8fe8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e9a1"
+string(4) "e9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fe9a1"
+string(6) "8fe9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eaa1"
+string(4) "eafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8feaa1"
+string(6) "8feafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eba1"
+string(4) "ebfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8feba1"
+string(6) "8febfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eca1"
+string(4) "ecfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8feca1"
+string(6) "8fecfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eda1"
+string(4) "edfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8feda1"
+string(6) "8fedfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eea1"
+string(4) "eefe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8feea1"
+string(6) "8feefe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "efa1"
+string(4) "effe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8fefa1"
+string(6) "8feffe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f0a1"
+string(4) "f0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ff0a1"
+string(6) "8ff0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f1a1"
+string(4) "f1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ff1a1"
+string(6) "8ff1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f2a1"
+string(4) "f2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ff2a1"
+string(6) "8ff2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f3a1"
+string(4) "f3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ff3a1"
+string(6) "8ff3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f4a1"
+string(4) "f4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ff4a1"
+string(6) "8ff4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f5a1"
+string(4) "f5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ff5a1"
+string(6) "8ff5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f6a1"
+string(4) "f6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ff6a1"
+string(6) "8ff6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f7a1"
+string(4) "f7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ff7a1"
+string(6) "8ff7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f8a1"
+string(4) "f8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ff8a1"
+string(6) "8ff8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f9a1"
+string(4) "f9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ff9a1"
+string(6) "8ff9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "faa1"
+string(4) "fafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ffaa1"
+string(6) "8ffafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fba1"
+string(4) "fbfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ffba1"
+string(6) "8ffbfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fca1"
+string(4) "fcfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ffca1"
+string(6) "8ffcfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fda1"
+string(4) "fdfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ffda1"
+string(6) "8ffdfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fea1"
+string(4) "fefe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(6) "8ffea1"
+string(6) "8ffefe"
+string(0) ""
+--
+string(2) "80"
+string(2) "ff"
+--
+string(0) ""
+string(0) ""
+string(4) "8140"
+string(4) "817e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "81a1"
+string(4) "81fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8240"
+string(4) "827e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "82a1"
+string(4) "82fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8340"
+string(4) "837e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "83a1"
+string(4) "83fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8440"
+string(4) "847e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "84a1"
+string(4) "84fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8540"
+string(4) "857e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "85a1"
+string(4) "85fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8640"
+string(4) "867e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "86a1"
+string(4) "86fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8740"
+string(4) "877e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "87a1"
+string(4) "87fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8840"
+string(4) "887e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "88a1"
+string(4) "88fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8940"
+string(4) "897e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "89a1"
+string(4) "89fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8a40"
+string(4) "8a7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8aa1"
+string(4) "8afe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8b40"
+string(4) "8b7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8ba1"
+string(4) "8bfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8c40"
+string(4) "8c7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8ca1"
+string(4) "8cfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8d40"
+string(4) "8d7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8da1"
+string(4) "8dfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8e40"
+string(4) "8e7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8ea1"
+string(4) "8efe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8f40"
+string(4) "8f7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "8fa1"
+string(4) "8ffe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9040"
+string(4) "907e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "90a1"
+string(4) "90fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9140"
+string(4) "917e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "91a1"
+string(4) "91fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9240"
+string(4) "927e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "92a1"
+string(4) "92fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9340"
+string(4) "937e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "93a1"
+string(4) "93fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9440"
+string(4) "947e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "94a1"
+string(4) "94fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9540"
+string(4) "957e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "95a1"
+string(4) "95fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9640"
+string(4) "967e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "96a1"
+string(4) "96fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9740"
+string(4) "977e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "97a1"
+string(4) "97fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9840"
+string(4) "987e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "98a1"
+string(4) "98fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9940"
+string(4) "997e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "99a1"
+string(4) "99fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9a40"
+string(4) "9a7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9aa1"
+string(4) "9afe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9b40"
+string(4) "9b7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9ba1"
+string(4) "9bfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9c40"
+string(4) "9c7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9ca1"
+string(4) "9cfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9d40"
+string(4) "9d7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9da1"
+string(4) "9dfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9e40"
+string(4) "9e7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9ea1"
+string(4) "9efe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9f40"
+string(4) "9f7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "9fa1"
+string(4) "9ffe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a040"
+string(4) "a07e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a0a1"
+string(4) "a0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a140"
+string(4) "a17e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a1a1"
+string(4) "a1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a240"
+string(4) "a27e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a2a1"
+string(4) "a2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a340"
+string(4) "a37e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a3a1"
+string(4) "a3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a440"
+string(4) "a47e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a4a1"
+string(4) "a4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a540"
+string(4) "a57e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a5a1"
+string(4) "a5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a640"
+string(4) "a67e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a6a1"
+string(4) "a6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a740"
+string(4) "a77e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a7a1"
+string(4) "a7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a840"
+string(4) "a87e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a8a1"
+string(4) "a8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a940"
+string(4) "a97e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "a9a1"
+string(4) "a9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "aa40"
+string(4) "aa7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "aaa1"
+string(4) "aafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ab40"
+string(4) "ab7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "aba1"
+string(4) "abfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ac40"
+string(4) "ac7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "aca1"
+string(4) "acfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ad40"
+string(4) "ad7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ada1"
+string(4) "adfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ae40"
+string(4) "ae7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "aea1"
+string(4) "aefe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "af40"
+string(4) "af7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "afa1"
+string(4) "affe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b040"
+string(4) "b07e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b0a1"
+string(4) "b0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b140"
+string(4) "b17e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b1a1"
+string(4) "b1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b240"
+string(4) "b27e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b2a1"
+string(4) "b2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b340"
+string(4) "b37e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b3a1"
+string(4) "b3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b440"
+string(4) "b47e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b4a1"
+string(4) "b4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b540"
+string(4) "b57e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b5a1"
+string(4) "b5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b640"
+string(4) "b67e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b6a1"
+string(4) "b6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b740"
+string(4) "b77e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b7a1"
+string(4) "b7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b840"
+string(4) "b87e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b8a1"
+string(4) "b8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b940"
+string(4) "b97e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "b9a1"
+string(4) "b9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ba40"
+string(4) "ba7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "baa1"
+string(4) "bafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bb40"
+string(4) "bb7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bba1"
+string(4) "bbfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bc40"
+string(4) "bc7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bca1"
+string(4) "bcfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bd40"
+string(4) "bd7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bda1"
+string(4) "bdfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "be40"
+string(4) "be7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bea1"
+string(4) "befe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bf40"
+string(4) "bf7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "bfa1"
+string(4) "bffe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c040"
+string(4) "c07e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c0a1"
+string(4) "c0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c140"
+string(4) "c17e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c1a1"
+string(4) "c1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c240"
+string(4) "c27e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c2a1"
+string(4) "c2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c340"
+string(4) "c37e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c3a1"
+string(4) "c3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c440"
+string(4) "c47e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c4a1"
+string(4) "c4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c540"
+string(4) "c57e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c5a1"
+string(4) "c5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c640"
+string(4) "c67e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c6a1"
+string(4) "c6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c740"
+string(4) "c77e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c7a1"
+string(4) "c7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c840"
+string(4) "c87e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c8a1"
+string(4) "c8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c940"
+string(4) "c97e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "c9a1"
+string(4) "c9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ca40"
+string(4) "ca7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "caa1"
+string(4) "cafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cb40"
+string(4) "cb7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cba1"
+string(4) "cbfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cc40"
+string(4) "cc7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cca1"
+string(4) "ccfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cd40"
+string(4) "cd7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cda1"
+string(4) "cdfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ce40"
+string(4) "ce7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cea1"
+string(4) "cefe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cf40"
+string(4) "cf7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "cfa1"
+string(4) "cffe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d040"
+string(4) "d07e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d0a1"
+string(4) "d0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d140"
+string(4) "d17e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d1a1"
+string(4) "d1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d240"
+string(4) "d27e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d2a1"
+string(4) "d2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d340"
+string(4) "d37e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d3a1"
+string(4) "d3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d440"
+string(4) "d47e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d4a1"
+string(4) "d4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d540"
+string(4) "d57e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d5a1"
+string(4) "d5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d640"
+string(4) "d67e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d6a1"
+string(4) "d6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d740"
+string(4) "d77e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d7a1"
+string(4) "d7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d840"
+string(4) "d87e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d8a1"
+string(4) "d8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d940"
+string(4) "d97e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "d9a1"
+string(4) "d9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "da40"
+string(4) "da7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "daa1"
+string(4) "dafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "db40"
+string(4) "db7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dba1"
+string(4) "dbfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dc40"
+string(4) "dc7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dca1"
+string(4) "dcfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dd40"
+string(4) "dd7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dda1"
+string(4) "ddfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "de40"
+string(4) "de7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dea1"
+string(4) "defe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "df40"
+string(4) "df7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "dfa1"
+string(4) "dffe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e040"
+string(4) "e07e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e0a1"
+string(4) "e0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e140"
+string(4) "e17e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e1a1"
+string(4) "e1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e240"
+string(4) "e27e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e2a1"
+string(4) "e2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e340"
+string(4) "e37e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e3a1"
+string(4) "e3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e440"
+string(4) "e47e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e4a1"
+string(4) "e4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e540"
+string(4) "e57e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e5a1"
+string(4) "e5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e640"
+string(4) "e67e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e6a1"
+string(4) "e6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e740"
+string(4) "e77e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e7a1"
+string(4) "e7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e840"
+string(4) "e87e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e8a1"
+string(4) "e8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e940"
+string(4) "e97e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "e9a1"
+string(4) "e9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ea40"
+string(4) "ea7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eaa1"
+string(4) "eafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eb40"
+string(4) "eb7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eba1"
+string(4) "ebfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ec40"
+string(4) "ec7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eca1"
+string(4) "ecfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ed40"
+string(4) "ed7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eda1"
+string(4) "edfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ee40"
+string(4) "ee7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "eea1"
+string(4) "eefe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "ef40"
+string(4) "ef7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "efa1"
+string(4) "effe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f040"
+string(4) "f07e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f0a1"
+string(4) "f0fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f140"
+string(4) "f17e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f1a1"
+string(4) "f1fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f240"
+string(4) "f27e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f2a1"
+string(4) "f2fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f340"
+string(4) "f37e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f3a1"
+string(4) "f3fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f440"
+string(4) "f47e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f4a1"
+string(4) "f4fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f540"
+string(4) "f57e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f5a1"
+string(4) "f5fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f640"
+string(4) "f67e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f6a1"
+string(4) "f6fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f740"
+string(4) "f77e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f7a1"
+string(4) "f7fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f840"
+string(4) "f87e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f8a1"
+string(4) "f8fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f940"
+string(4) "f97e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "f9a1"
+string(4) "f9fe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fa40"
+string(4) "fa7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "faa1"
+string(4) "fafe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fb40"
+string(4) "fb7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fba1"
+string(4) "fbfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fc40"
+string(4) "fc7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fca1"
+string(4) "fcfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fd40"
+string(4) "fd7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fda1"
+string(4) "fdfe"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fe40"
+string(4) "fe7e"
+string(0) ""
+string(0) ""
+string(0) ""
+string(4) "fea1"
+string(4) "fefe"
+string(0) ""
diff --git a/ext/standard/tests/strings/bug50052.phpt b/ext/standard/tests/strings/bug50052.phpt
index 24a5a20..96d8599 100644
--- a/ext/standard/tests/strings/bug50052.phpt
+++ b/ext/standard/tests/strings/bug50052.phpt
@@ -1,5 +1,5 @@
 --TEST--
-Bug #20934 (html_entity_decode() crash when "" is passed)
+Bug #50052 (Different Hashes on Windows and Linux on wrong Salt size)
 --FILE--
 <?php
 $salt = '$1$f+uslYF01$';
diff --git a/ext/standard/tests/strings/bug50847.phpt b/ext/standard/tests/strings/bug50847.phpt
new file mode 100644
index 0000000..28e83f5
--- /dev/null
+++ b/ext/standard/tests/strings/bug50847.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #50847 (strip_tags() removes all tags greater then 1023 bytes long)
+--FILE--
+<?php
+$var = '<param value="' . str_repeat("a", 2048) . '" />';
+var_dump(strip_tags($var, "<param>"), strip_tags($var));
+?>
+--EXPECT--
+string(2066) "<param value="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" />"
+string(0) ""
diff --git a/ext/standard/tests/strings/bug51059.phpt b/ext/standard/tests/strings/bug51059.phpt
new file mode 100644
index 0000000..f2cbe9d
--- /dev/null
+++ b/ext/standard/tests/strings/bug51059.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #51059 crypt() segfaults on certain salts
+--FILE--
+<?php
+$res = crypt('a', '_');
+if ($res == '*0' || $res == '*1') echo 'OK';
+else echo 'Not OK';
+
+?>
+--EXPECT--
+OK
diff --git a/ext/standard/tests/strings/crypt_blowfish_invalid_rounds.phpt b/ext/standard/tests/strings/crypt_blowfish_invalid_rounds.phpt
new file mode 100644
index 0000000..6d40b07
--- /dev/null
+++ b/ext/standard/tests/strings/crypt_blowfish_invalid_rounds.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test Blowfish crypt() with invalid rounds
+--FILE--
+<?php
+
+foreach(range(32, 38) as $i) {
+  if (crypt('U*U', '$2a$'.$i.'$CCCCCCCCCCCCCCCCCCCCCC$') === FALSE) {
+    echo "$i. OK\n";
+  } else {
+    echo "$i. Not OK\n";
+  }
+}
+
+?>
+--EXPECT--
+32. OK
+33. OK
+34. OK
+35. OK
+36. OK
+37. OK
+38. OK
diff --git a/ext/standard/tests/strings/crypt_sha256.phpt b/ext/standard/tests/strings/crypt_sha256.phpt
new file mode 100644
index 0000000..86c7245
--- /dev/null
+++ b/ext/standard/tests/strings/crypt_sha256.phpt
@@ -0,0 +1,64 @@
+--TEST--
+crypt() SHA-256 
+--SKIPIF--
+<?php
+if (!function_exists('crypt') || !defined("CRYPT_SHA256")) {
+	die("SKIP crypt()-sha256 is not available");
+}
+?> 
+--FILE--
+<?php
+
+$tests = array(
+	1 => array(
+		b'$5$saltstring',
+		b'Hello world!',
+		b'$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5'
+	),
+	2 => array(
+		b'$5$rounds=10000$saltstringsaltstring',
+		b'Hello world!',
+		b'$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA'
+	),
+	3 => array(
+		b'$5$rounds=10000$saltstringsaltstring',
+		b'Hello world!',
+		b'$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA'
+	),
+	4 => array(
+		b'$5$rounds=5000$toolongsaltstring',
+		b'This is just a test',
+		b'$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8mGRcvxa5'
+	),
+	5 => array(
+		b'$5$rounds=1400$anotherlongsaltstring',
+		b'a very much longer text to encrypt.  This one even stretches over morethan one line.',
+		b'$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12oP84Bnq1'
+	),
+	6 => array(
+		b'$5$rounds=77777$short',
+		b'we have a short salt string but not a short password',
+		b'$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/'
+	),
+	7 => array(
+		b'$5$rounds=123456$asaltof16chars..',
+		b'a short string',
+		b'$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/cZKmF/wJvD'
+	),
+	8 => array(
+		b'$5$rounds=10$roundstoolow',
+		b'the minimum number is still observed',
+		b'$5$rounds=1000$roundstoolow$yfvwcWrQ8l/K0DAWyuPMDNHpIVlTQebY9l/gL972bIC'
+	)
+);
+
+foreach ($tests as $iter => $t) {
+	$res = crypt($t[1], $t[0]);
+	if ($res != $t[2]) echo "Iteration $iter failed.
+Expected: <$t[2]>
+Got       <$res>\n";
+}
+echo "Passes.";?>
+--EXPECTF--
+Passes.
+
diff --git a/ext/standard/tests/strings/crypt_sha512.phpt b/ext/standard/tests/strings/crypt_sha512.phpt
new file mode 100644
index 0000000..d6f9df6
--- /dev/null
+++ b/ext/standard/tests/strings/crypt_sha512.phpt
@@ -0,0 +1,65 @@
+--TEST--
+crypt() SHA-512
+--SKIPIF--
+<?php
+if (!function_exists('crypt') || !defined("CRYPT_SHA512")) {
+	die("SKIP crypt()-sha512 is not available");
+}
+?> 
+--FILE--
+<?php
+
+$tests = array(
+	1 => array(
+		b'$6$saltstring',
+		b'Hello world!',
+		b'$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJuesI68u4OTLiBFdcbYEdFCoEOfaS35inz1'
+	),
+	2 => array(
+		b'$6$rounds=10000$saltstringsaltstring',
+		b'Hello world!',
+		b'$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sbHbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v.'
+	),
+	3 => array(
+		b'$6$rounds=5000$toolongsaltstring',
+		b'This is just a test',
+		b'$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQzQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0'
+	),
+	4 => array(
+		b'$6$rounds=1400$anotherlongsaltstring',
+		b'a very much longer text to encrypt.  This one even stretches over morethan one line.',
+		b'$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wPvMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1'
+	),
+	5 => array(
+		b'$6$rounds=77777$short',
+		b'we have a short salt string but not a short password',
+		b'$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0gge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0'
+	),
+	6 => array(
+		b'$6$rounds=123456$asaltof16chars..',
+		b'a short string',
+		b'$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwcelCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1'
+	),
+	7 => array(
+		b'$6$rounds=10$roundstoolow',
+		b'the minimum number is still observed',
+		b'$6$rounds=1000$roundstoolow$kUMsbe306n21p9R.FRkW3IGn.S9NPN0x50YhH1xhLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX.'
+	),
+	8 => array(
+		b'$6$$bar$',
+		b'foo',
+		b'$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.'
+	),
+);
+
+foreach ($tests as $iter => $t) {
+	$res = crypt($t[1], $t[0]);
+	if ($res != $t[2]) echo "Iteration $iter failed.
+Expected: <$t[2]>
+Got       <$res>\n";
+}
+echo "Passes.";
+?>
+--EXPECTF--
+Passes.
+
diff --git a/ext/standard/tests/strings/html_entity_decode_html4.phpt b/ext/standard/tests/strings/html_entity_decode_html4.phpt
new file mode 100644
index 0000000..3c92bf6
--- /dev/null
+++ b/ext/standard/tests/strings/html_entity_decode_html4.phpt
@@ -0,0 +1,516 @@
+--TEST--
+html_entity_decode() conformance check (HTML 4)
+--FILE--
+<?php
+$map = array(
+    """,
+    "&",
+    "<",
+    ">",
+    " ",
+    "¡",
+    "¢",
+    "£",
+    "¤",
+    "¥",
+    "¦",
+    "§",
+    "¨",
+    "©",
+    "ª",
+    "«",
+    "¬",
+    "­",
+    "®",
+    "¯",
+    "°",
+    "±",
+    "&sup2;",
+    "&sup3;",
+    "´",
+    "µ",
+    "¶",
+    "·",
+    "¸",
+    "&sup1;",
+    "º",
+    "»",
+    "&frac14;",
+    "&frac12;",
+    "&frac34;",
+    "¿",
+    "À",
+    "Á",
+    "Â",
+    "Ã",
+    "Ä",
+    "Å",
+    "Æ",
+    "Ç",
+    "È",
+    "É",
+    "Ê",
+    "Ë",
+    "Ì",
+    "Í",
+    "Î",
+    "Ï",
+    "Ð",
+    "Ñ",
+    "Ò",
+    "Ó",
+    "Ô",
+    "Õ",
+    "Ö",
+    "×",
+    "Ø",
+    "Ù",
+    "Ú",
+    "Û",
+    "Ü",
+    "Ý",
+    "Þ",
+    "ß",
+    "à",
+    "á",
+    "â",
+    "ã",
+    "ä",
+    "å",
+    "æ",
+    "ç",
+    "è",
+    "é",
+    "ê",
+    "ë",
+    "ì",
+    "í",
+    "î",
+    "ï",
+    "ð",
+    "ñ",
+    "ò",
+    "ó",
+    "ô",
+    "õ",
+    "ö",
+    "÷",
+    "ø",
+    "ù",
+    "ú",
+    "û",
+    "ü",
+    "ý",
+    "þ",
+    "ÿ",
+    "Œ",
+    "œ",
+    "Š",
+    "š",
+    "Ÿ",
+    "ƒ",
+    "ˆ",
+    "˜",
+    "Α",
+    "Β",
+    "Γ",
+    "Δ",
+    "Ε",
+    "Ζ",
+    "Η",
+    "Θ",
+    "Ι",
+    "Κ",
+    "Λ",
+    "Μ",
+    "Ν",
+    "Ξ",
+    "Ο",
+    "Π",
+    "Ρ",
+    "Σ",
+    "Τ",
+    "Υ",
+    "Φ",
+    "Χ",
+    "Ψ",
+    "Ω",
+    "α",
+    "β",
+    "γ",
+    "δ",
+    "ε",
+    "ζ",
+    "η",
+    "θ",
+    "ι",
+    "κ",
+    "λ",
+    "μ",
+    "ν",
+    "ξ",
+    "ο",
+    "π",
+    "ρ",
+    "ς",
+    "σ",
+    "τ",
+    "υ",
+    "φ",
+    "χ",
+    "ψ",
+    "ω",
+    "ϑ",
+    "ϒ",
+    "ϖ",
+    " ",
+    " ",
+    " ",
+    "‌",
+    "‍",
+    "‎",
+    "‏",
+    "–",
+    "—",
+    "‘",
+    "’",
+    "‚",
+    "“",
+    "”",
+    "„",
+    "†",
+    "‡",
+    "•",
+    "…",
+    "‰",
+    "′",
+    "″",
+    "‹",
+    "›",
+    "‾",
+    "⁄",
+    "€",
+    "ℑ",
+    "℘",
+    "ℜ",
+    "™",
+    "ℵ",
+    "←",
+    "↑",
+    "→",
+    "↓",
+    "↔",
+    "↵",
+    "⇐",
+    "⇑",
+    "⇒",
+    "⇓",
+    "⇔",
+    "∀",
+    "∂",
+    "∃",
+    "∅",
+    "∇",
+    "∈",
+    "∉",
+    "∋",
+    "∏",
+    "∑",
+    "−",
+    "∗",
+    "√",
+    "∝",
+    "∞",
+    "∠",
+    "∧",
+    "∨",
+    "∩",
+    "∪",
+    "∫",
+    "&there4;",
+    "∼",
+    "≅",
+    "≈",
+    "≠",
+    "≡",
+    "≤",
+    "≥",
+    "⊂",
+    "⊃",
+    "⊄",
+    "⊆",
+    "⊇",
+    "⊕",
+    "⊗",
+    "⊥",
+    "⋅",
+    "⌈",
+    "⌉",
+    "⌊",
+    "⌋",
+    "⟨",
+    "⟩",
+    "◊",
+    "♠",
+    "♣",
+    "♥",
+    "♦",
+);
+
+foreach ($map as $str) {
+    echo bin2hex(html_entity_decode($str, ENT_QUOTES, "UTF-8")), "\n";
+}
+?>
+--EXPECT--
+22
+26
+3c
+3e
+c2a0
+c2a1
+c2a2
+c2a3
+c2a4
+c2a5
+c2a6
+c2a7
+c2a8
+c2a9
+c2aa
+c2ab
+c2ac
+c2ad
+c2ae
+c2af
+c2b0
+c2b1
+c2b2
+c2b3
+c2b4
+c2b5
+c2b6
+c2b7
+c2b8
+c2b9
+c2ba
+c2bb
+c2bc
+c2bd
+c2be
+c2bf
+c380
+c381
+c382
+c383
+c384
+c385
+c386
+c387
+c388
+c389
+c38a
+c38b
+c38c
+c38d
+c38e
+c38f
+c390
+c391
+c392
+c393
+c394
+c395
+c396
+c397
+c398
+c399
+c39a
+c39b
+c39c
+c39d
+c39e
+c39f
+c3a0
+c3a1
+c3a2
+c3a3
+c3a4
+c3a5
+c3a6
+c3a7
+c3a8
+c3a9
+c3aa
+c3ab
+c3ac
+c3ad
+c3ae
+c3af
+c3b0
+c3b1
+c3b2
+c3b3
+c3b4
+c3b5
+c3b6
+c3b7
+c3b8
+c3b9
+c3ba
+c3bb
+c3bc
+c3bd
+c3be
+c3bf
+c592
+c593
+c5a0
+c5a1
+c5b8
+c692
+cb86
+cb9c
+ce91
+ce92
+ce93
+ce94
+ce95
+ce96
+ce97
+ce98
+ce99
+ce9a
+ce9b
+ce9c
+ce9d
+ce9e
+ce9f
+cea0
+cea1
+cea3
+cea4
+cea5
+cea6
+cea7
+cea8
+cea9
+ceb1
+ceb2
+ceb3
+ceb4
+ceb5
+ceb6
+ceb7
+ceb8
+ceb9
+ceba
+cebb
+cebc
+cebd
+cebe
+cebf
+cf80
+cf81
+cf82
+cf83
+cf84
+cf85
+cf86
+cf87
+cf88
+cf89
+cf91
+cf92
+cf96
+e28082
+e28083
+e28089
+e2808c
+e2808d
+e2808e
+e2808f
+e28093
+e28094
+e28098
+e28099
+e2809a
+e2809c
+e2809d
+e2809e
+e280a0
+e280a1
+e280a2
+e280a6
+e280b0
+e280b2
+e280b3
+e280b9
+e280ba
+e280be
+e28184
+e282ac
+e28491
+e28498
+e2849c
+e284a2
+e284b5
+e28690
+e28691
+e28692
+e28693
+e28694
+e286b5
+e28790
+e28791
+e28792
+e28793
+e28794
+e28880
+e28882
+e28883
+e28885
+e28887
+e28888
+e28889
+e2888b
+e2888f
+e28891
+e28892
+e28897
+e2889a
+e2889d
+e2889e
+e288a0
+e288a7
+e288a8
+e288a9
+e288aa
+e288ab
+e288b4
+e288bc
+e28985
+e28988
+e289a0
+e289a1
+e289a4
+e289a5
+e28a82
+e28a83
+e28a84
+e28a86
+e28a87
+e28a95
+e28a97
+e28aa5
+e28b85
+e28c88
+e28c89
+e28c8a
+e28c8b
+e28ca9
+e28caa
+e2978a
+e299a0
+e299a3
+e299a5
+e299a6
diff --git a/ext/standard/tests/strings/htmlentities-utf-2.phpt b/ext/standard/tests/strings/htmlentities-utf-2.phpt
index a80100c..c5f4ac4 100755
--- a/ext/standard/tests/strings/htmlentities-utf-2.phpt
+++ b/ext/standard/tests/strings/htmlentities-utf-2.phpt
@@ -36,8 +36,8 @@ foreach($strings as $string) {
 %unicode|string%(0) ""
 %unicode|string%(2) "79"
 %unicode|string%(2) "79"
-%unicode|string%(8) "2667743b"
-%unicode|string%(8) "2667743b"
+%unicode|string%(0) ""
+%unicode|string%(0) ""
 %unicode|string%(8) "566f696c"
 %unicode|string%(8) "566f696c"
 %unicode|string%(12) "436c69636873"
@@ -52,10 +52,10 @@ foreach($strings as $string) {
 %unicode|string%(2) "79"
 %unicode|string%(8) "f7bfbfbf"
 %unicode|string%(8) "f7bfbfbf"
-%unicode|string%(10) "fbbfbfbfbf"
-%unicode|string%(10) "fbbfbfbfbf"
-%unicode|string%(12) "fdbfbfbfbfbf"
-%unicode|string%(12) "fdbfbfbfbfbf"
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+%unicode|string%(0) ""
 %unicode|string%(4) "4142"
 %unicode|string%(4) "4142"
 %unicode|string%(4) "4242"
diff --git a/ext/standard/tests/strings/htmlentities-utf.phpt b/ext/standard/tests/strings/htmlentities-utf.phpt
index b85803a..1daafc6 100755
--- a/ext/standard/tests/strings/htmlentities-utf.phpt
+++ b/ext/standard/tests/strings/htmlentities-utf.phpt
@@ -36,8 +36,8 @@ foreach($strings as $string) {
 %unicode|string%(0) ""
 %unicode|string%(0) ""
 %unicode|string%(0) ""
-%unicode|string%(8) "2667743b"
-%unicode|string%(8) "2667743b"
+%unicode|string%(0) ""
+%unicode|string%(0) ""
 %unicode|string%(0) ""
 %unicode|string%(0) ""
 %unicode|string%(0) ""
@@ -52,10 +52,10 @@ foreach($strings as $string) {
 %unicode|string%(0) ""
 %unicode|string%(8) "f7bfbfbf"
 %unicode|string%(8) "f7bfbfbf"
-%unicode|string%(10) "fbbfbfbfbf"
-%unicode|string%(10) "fbbfbfbfbf"
-%unicode|string%(12) "fdbfbfbfbfbf"
-%unicode|string%(12) "fdbfbfbfbfbf"
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+%unicode|string%(0) ""
 %unicode|string%(0) ""
 %unicode|string%(0) ""
 %unicode|string%(0) ""
diff --git a/ext/standard/tests/strings/htmlentities02.phpt b/ext/standard/tests/strings/htmlentities02.phpt
index b8b9e63..5d708c2 100644
--- a/ext/standard/tests/strings/htmlentities02.phpt
+++ b/ext/standard/tests/strings/htmlentities02.phpt
@@ -10,7 +10,7 @@ if (!$result) {
 --INI--
 output_handler=
 default_charset=
-mbstring.internal_encoding=none
+mbstring.internal_encoding=pass
 --FILE--
 <?php
 	setlocale(LC_CTYPE, "fr_FR.ISO-8859-15", "fr_FR.ISO8859-15", 'fr_FR at euro');
diff --git a/ext/standard/tests/strings/htmlentities03.phpt b/ext/standard/tests/strings/htmlentities03.phpt
index 7e93354..9f40ff3 100644
--- a/ext/standard/tests/strings/htmlentities03.phpt
+++ b/ext/standard/tests/strings/htmlentities03.phpt
@@ -10,7 +10,7 @@ if (!$result || preg_match('/ISO/i', setlocale(LC_CTYPE, 0)) == 0) {
 --INI--
 output_handler=
 default_charset=
-mbstring.internal_encoding=none
+mbstring.internal_encoding=pass
 --FILE--
 <?php
 	setlocale( LC_CTYPE, "de_DE.ISO-8859-1", "de_DE.ISO8859-1");
diff --git a/ext/standard/tests/strings/htmlentities04.phpt b/ext/standard/tests/strings/htmlentities04.phpt
index 8e362d0..565c11b 100644
--- a/ext/standard/tests/strings/htmlentities04.phpt
+++ b/ext/standard/tests/strings/htmlentities04.phpt
@@ -10,7 +10,7 @@ if (!$result || preg_match('/EUC[^a-zA-Z]*JP/i', setlocale(LC_CTYPE, 0)) == 0) {
 --INI--
 output_handler=
 default_charset=
-mbstring.internal_encoding=none
+mbstring.internal_encoding=pass
 --FILE--
 <?php
 	setlocale( LC_CTYPE, "ja_JP.EUC-JP", "ja_JP.eucJP" );
diff --git a/ext/standard/tests/strings/htmlentities15.phpt b/ext/standard/tests/strings/htmlentities15.phpt
index 2dc36e6..f45be11 100644
--- a/ext/standard/tests/strings/htmlentities15.phpt
+++ b/ext/standard/tests/strings/htmlentities15.phpt
@@ -3,7 +3,7 @@ htmlentities() test 15 (setlocale / KOI8-R)
 --INI--
 output_handler=
 default_charset=
-mbstring.internal_encoding=none
+mbstring.internal_encoding=pass
 --SKIPIF--
 <?php
 $result = (bool)setlocale(LC_CTYPE, "ru_RU.koi8r", "ru_RU.KOI8-R");
diff --git a/ext/standard/tests/strings/htmlentities_html4.phpt b/ext/standard/tests/strings/htmlentities_html4.phpt
new file mode 100644
index 0000000..3f700e8
--- /dev/null
+++ b/ext/standard/tests/strings/htmlentities_html4.phpt
@@ -0,0 +1,305 @@
+--TEST--
+htmlentities() conformance check (HTML 4)
+--FILE--
+<?php
+function utf32_utf8($k) {
+	if ($k < 0x80) {
+		$retval = pack('C', $k);
+	} else if ($k < 0x800) {
+		$retval = pack('C2', 
+            0xc0 | ($k >> 6),
+            0x80 | ($k & 0x3f));
+	} else if ($k < 0x10000) {
+        $retval = pack('C3',
+            0xe0 | ($k >> 12),
+            0x80 | (($k >> 6) & 0x3f),
+            0x80 | ($k & 0x3f));
+	} else if ($k < 0x200000) {
+        $retval = pack('C4',
+            0xf0 | ($k >> 18),
+            0x80 | (($k >> 12) & 0x3f),
+            0x80 | (($k >> 6) & 0x3f),
+            0x80 | ($k & 0x3f));
+	} else if ($k < 0x4000000) {
+        $retval = pack('C5',
+            0xf8 | ($k >> 24),
+            0x80 | (($k >> 18) & 0x3f),
+            0x80 | (($k >> 12) & 0x3f),
+            0x80 | (($k >> 6) & 0x3f),
+            0x80 | ($k & 0x3f));
+	} else {
+        $retval = pack('C6',
+            0xfc | ($k >> 30),
+            0x80 | (($k >> 24) & 0x3f),
+            0x80 | (($k >> 18) & 0x3f),
+            0x80 | (($k >> 12) & 0x3f),
+            0x80 | (($k >> 6) & 0x3f),
+            0x80 | ($k & 0x3f));
+	}
+	return $retval;
+}
+
+for ($i = 0; $i < 0x110000; $i++) {
+    if ($i >= 0xd800 && $i < 0xe000)
+        continue;
+    $str = utf32_utf8($i);
+    $result = htmlentities($str, ENT_QUOTES, 'UTF-8');
+    if ($str != $result) {
+        printf("%s\tU+%05X\n", $result, $i);
+    }
+}
+?>
+--EXPECT--
+"	U+00022
+&	U+00026
+'	U+00027
+<	U+0003C
+>	U+0003E
+ 	U+000A0
+¡	U+000A1
+¢	U+000A2
+£	U+000A3
+¤	U+000A4
+¥	U+000A5
+¦	U+000A6
+§	U+000A7
+¨	U+000A8
+©	U+000A9
+ª	U+000AA
+«	U+000AB
+¬	U+000AC
+­	U+000AD
+®	U+000AE
+¯	U+000AF
+°	U+000B0
+±	U+000B1
+&sup2;	U+000B2
+&sup3;	U+000B3
+´	U+000B4
+µ	U+000B5
+¶	U+000B6
+·	U+000B7
+¸	U+000B8
+&sup1;	U+000B9
+º	U+000BA
+»	U+000BB
+&frac14;	U+000BC
+&frac12;	U+000BD
+&frac34;	U+000BE
+¿	U+000BF
+À	U+000C0
+Á	U+000C1
+Â	U+000C2
+Ã	U+000C3
+Ä	U+000C4
+Å	U+000C5
+Æ	U+000C6
+Ç	U+000C7
+È	U+000C8
+É	U+000C9
+Ê	U+000CA
+Ë	U+000CB
+Ì	U+000CC
+Í	U+000CD
+Î	U+000CE
+Ï	U+000CF
+Ð	U+000D0
+Ñ	U+000D1
+Ò	U+000D2
+Ó	U+000D3
+Ô	U+000D4
+Õ	U+000D5
+Ö	U+000D6
+×	U+000D7
+Ø	U+000D8
+Ù	U+000D9
+Ú	U+000DA
+Û	U+000DB
+Ü	U+000DC
+Ý	U+000DD
+Þ	U+000DE
+ß	U+000DF
+à	U+000E0
+á	U+000E1
+â	U+000E2
+ã	U+000E3
+ä	U+000E4
+å	U+000E5
+æ	U+000E6
+ç	U+000E7
+è	U+000E8
+é	U+000E9
+ê	U+000EA
+ë	U+000EB
+ì	U+000EC
+í	U+000ED
+î	U+000EE
+ï	U+000EF
+ð	U+000F0
+ñ	U+000F1
+ò	U+000F2
+ó	U+000F3
+ô	U+000F4
+õ	U+000F5
+ö	U+000F6
+÷	U+000F7
+ø	U+000F8
+ù	U+000F9
+ú	U+000FA
+û	U+000FB
+ü	U+000FC
+ý	U+000FD
+þ	U+000FE
+ÿ	U+000FF
+Œ	U+00152
+œ	U+00153
+Š	U+00160
+š	U+00161
+Ÿ	U+00178
+ƒ	U+00192
+ˆ	U+002C6
+˜	U+002DC
+Α	U+00391
+Β	U+00392
+Γ	U+00393
+Δ	U+00394
+Ε	U+00395
+Ζ	U+00396
+Η	U+00397
+Θ	U+00398
+Ι	U+00399
+Κ	U+0039A
+Λ	U+0039B
+Μ	U+0039C
+Ν	U+0039D
+Ξ	U+0039E
+Ο	U+0039F
+Π	U+003A0
+Ρ	U+003A1
+Σ	U+003A3
+Τ	U+003A4
+Υ	U+003A5
+Φ	U+003A6
+Χ	U+003A7
+Ψ	U+003A8
+Ω	U+003A9
+α	U+003B1
+β	U+003B2
+γ	U+003B3
+δ	U+003B4
+ε	U+003B5
+ζ	U+003B6
+η	U+003B7
+θ	U+003B8
+ι	U+003B9
+κ	U+003BA
+λ	U+003BB
+μ	U+003BC
+ν	U+003BD
+ξ	U+003BE
+ο	U+003BF
+π	U+003C0
+ρ	U+003C1
+ς	U+003C2
+σ	U+003C3
+τ	U+003C4
+υ	U+003C5
+φ	U+003C6
+χ	U+003C7
+ψ	U+003C8
+ω	U+003C9
+ϑ	U+003D1
+ϒ	U+003D2
+ϖ	U+003D6
+ 	U+02002
+ 	U+02003
+ 	U+02009
+‌	U+0200C
+‍	U+0200D
+‎	U+0200E
+‏	U+0200F
+–	U+02013
+—	U+02014
+‘	U+02018
+’	U+02019
+‚	U+0201A
+“	U+0201C
+”	U+0201D
+„	U+0201E
+†	U+02020
+‡	U+02021
+•	U+02022
+…	U+02026
+‰	U+02030
+′	U+02032
+″	U+02033
+‹	U+02039
+›	U+0203A
+‾	U+0203E
+⁄	U+02044
+€	U+020AC
+ℑ	U+02111
+℘	U+02118
+ℜ	U+0211C
+™	U+02122
+ℵ	U+02135
+←	U+02190
+↑	U+02191
+→	U+02192
+↓	U+02193
+↔	U+02194
+↵	U+021B5
+⇐	U+021D0
+⇑	U+021D1
+⇒	U+021D2
+⇓	U+021D3
+⇔	U+021D4
+∀	U+02200
+∂	U+02202
+∃	U+02203
+∅	U+02205
+∇	U+02207
+∈	U+02208
+∉	U+02209
+∋	U+0220B
+∏	U+0220F
+∑	U+02211
+−	U+02212
+∗	U+02217
+√	U+0221A
+∝	U+0221D
+∞	U+0221E
+∠	U+02220
+∧	U+02227
+∨	U+02228
+∩	U+02229
+∪	U+0222A
+∫	U+0222B
+&there4;	U+02234
+∼	U+0223C
+≅	U+02245
+≈	U+02248
+≠	U+02260
+≡	U+02261
+≤	U+02264
+≥	U+02265
+⊂	U+02282
+⊃	U+02283
+⊄	U+02284
+⊆	U+02286
+⊇	U+02287
+⊕	U+02295
+⊗	U+02297
+⊥	U+022A5
+⋅	U+022C5
+⌈	U+02308
+⌉	U+02309
+⌊	U+0230A
+⌋	U+0230B
+⟨	U+02329
+⟩	U+0232A
+◊	U+025CA
+♠	U+02660
+♣	U+02663
+♥	U+02665
+♦	U+02666
diff --git a/ext/standard/tests/strings/parse_str_basic3.phpt b/ext/standard/tests/strings/parse_str_basic3.phpt
index 5b0641e..0cc7616 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--
-PHP Warning:  Directive 'magic_quotes_gpc' 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
 *** Testing parse_str() : basic functionality ***
 
 Test string with array values
diff --git a/ext/standard/tests/strings/setlocale_variation2.phpt b/ext/standard/tests/strings/setlocale_variation2.phpt
index 98c405b..af8739a 100644
--- a/ext/standard/tests/strings/setlocale_variation2.phpt
+++ b/ext/standard/tests/strings/setlocale_variation2.phpt
@@ -18,6 +18,10 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
 /* setlocale() to set all available locales in the system and check the success count */
 echo "*** Testing setlocale() : usage variations ***\n";
 
+function good_locale($locale) {
+	return $locale !== 'tt_RU at iqtelif.UTF-8';
+}
+
 /* Prototype  : array list_system_locales( void )
  * Description: To get the currently installed locle in this platform 
  * Arguments  : Nil
@@ -38,8 +42,8 @@ function list_system_locales() {
 
   $system_locales = explode("\n", $all_locales);
 
-  // return all the locale found in the system
-  return $system_locales;
+  // return all the locale found in the system, except for broken one
+  return array_filter($system_locales, 'good_locale');
 }
 
 // gather all the locales installed in the system
diff --git a/ext/standard/type.c b/ext/standard/type.c
index be165d6..8b84662 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: type.c 278172 2009-04-02 09:56:33Z dmitry $ */
+/* $Id: type.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_incomplete_class.h"
diff --git a/ext/standard/uniqid.c b/ext/standard/uniqid.c
index e69f005..ef25240 100644
--- a/ext/standard/uniqid.c
+++ b/ext/standard/uniqid.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: uniqid.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: uniqid.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/ext/standard/uniqid.h b/ext/standard/uniqid.h
index 716cb8c..da98a8f 100644
--- a/ext/standard/uniqid.h
+++ b/ext/standard/uniqid.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: uniqid.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: uniqid.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef UNIQID_H
 #define UNIQID_H
diff --git a/ext/standard/url.c b/ext/standard/url.c
index 06d33fd..eebcdd0 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Jim Winstead <jimw at php.net>                                  |
    +----------------------------------------------------------------------+
  */
-/* $Id: url.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: url.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdlib.h>
 #include <string.h>
@@ -201,10 +201,21 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
 	e = ue;
 	
 	if (!(p = memchr(s, '/', (ue - s)))) {
-		if ((p = memchr(s, '?', (ue - s)))) {
-			e = p;
-		} else if ((p = memchr(s, '#', (ue - s)))) {
-			e = p;
+		char *query, *fragment;
+
+		query = memchr(s, '?', (ue - s));
+		fragment = memchr(s, '#', (ue - s));
+
+		if (query && fragment) {
+			if (query > fragment) {
+				p = e = fragment;
+			} else {
+				p = e = query;
+			}
+		} else if (query) {
+			p = e = query;
+		} else if (fragment) {
+			p = e = fragment;
 		}
 	} else {
 		e = p;
@@ -285,10 +296,10 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
 	
 	if ((p = memchr(s, '?', (ue - s)))) {
 		pp = strchr(s, '#');
-		
+
 		if (pp && pp < p) {
 			p = pp;
-			pp = strchr(pp+2, '#');
+			goto label_parse;
 		}
 	
 		if (p - s) {
diff --git a/ext/standard/url.h b/ext/standard/url.h
index a478d30..a9c2e03 100644
--- a/ext/standard/url.h
+++ b/ext/standard/url.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Jim Winstead <jimw at php.net>                                  |
    +----------------------------------------------------------------------+
  */
-/* $Id: url.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: url.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef URL_H
 #define URL_H
diff --git a/ext/standard/url_scanner_ex.h b/ext/standard/url_scanner_ex.h
index d3fb965..f454d9f 100644
--- a/ext/standard/url_scanner_ex.h
+++ b/ext/standard/url_scanner_ex.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: url_scanner_ex.h 286379 2009-07-26 23:20:34Z jani $ */
+/* $Id: url_scanner_ex.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef URL_SCANNER_EX_H
 #define URL_SCANNER_EX_H
diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c
index fc0069a..3922fc5 100644
--- a/ext/standard/user_filters.c
+++ b/ext/standard/user_filters.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: user_filters.c 273098 2009-01-08 18:40:27Z lbarnaud $ */
+/* $Id: user_filters.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_globals.h"
diff --git a/ext/standard/uuencode.c b/ext/standard/uuencode.c
index 2980e12..0ef1fd4 100644
--- a/ext/standard/uuencode.c
+++ b/ext/standard/uuencode.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: uuencode.c 280460 2009-05-13 16:29:26Z kalle $ */
+/* $Id: uuencode.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
  * Portions of this code are based on Berkeley's uuencode/uudecode
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 0ed635e..6d2614f 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: var.c 287123 2009-08-11 22:46:07Z stas $ */
+/* $Id: var.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* {{{ includes
 */
@@ -612,9 +612,9 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
 							break;
 						}
 						pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS);
-						php_error_docref(NULL TSRMLS_CC, E_NOTICE, "\"%s\" returned as member variable from __sleep() but does not exist", Z_STRVAL_PP(name));
 						php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name));
 						php_var_serialize_intern(buf, nvalp, var_hash TSRMLS_CC);
+						php_error_docref(NULL TSRMLS_CC, E_NOTICE, "\"%s\" returned as member variable from __sleep() but does not exist", Z_STRVAL_PP(name));
 					} while (0);
 				} else {
 					php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name));
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
index 01d2fd9..82c1622 100644
--- a/ext/standard/var_unserializer.c
+++ b/ext/standard/var_unserializer.c
@@ -1,9 +1,9 @@
-/* Generated by re2c 0.13.5 on Wed Apr  8 09:34:35 2009 */
+/* Generated by re2c 0.13.5 on Mon Nov 23 09:26:17 2009 */
 /*
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: var_unserializer.c 278451 2009-04-08 18:10:46Z rasmus $ */
+/* $Id: var_unserializer.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "ext/standard/php_var.h"
diff --git a/ext/standard/var_unserializer.c.orig b/ext/standard/var_unserializer.c.orig
index 7eebfc0..578f593 100644
--- a/ext/standard/var_unserializer.c.orig
+++ b/ext/standard/var_unserializer.c.orig
@@ -1,10 +1,10 @@
-/* Generated by re2c 0.13.5 on Wed Apr  8 09:34:35 2009 */
+/* Generated by re2c 0.13.5 on Mon Nov 23 09:26:17 2009 */
 #line 1 "ext/standard/var_unserializer.re"
 /*
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: var_unserializer.c 278451 2009-04-08 18:10:46Z rasmus $ */
+/* $Id: var_unserializer.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "ext/standard/php_var.h"
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
index 0b009fa..6cd6628 100644
--- a/ext/standard/var_unserializer.re
+++ b/ext/standard/var_unserializer.re
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: var_unserializer.re 277374 2009-03-17 23:07:40Z felipe $ */
+/* $Id: var_unserializer.re 293035 2010-01-03 08:22:14Z sebastian $ */
 
 #include "php.h"
 #include "ext/standard/php_var.h"
diff --git a/ext/standard/versioning.c b/ext/standard/versioning.c
index 172c555..0ab2472 100644
--- a/ext/standard/versioning.c
+++ b/ext/standard/versioning.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: versioning.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: versioning.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdio.h>
 #include <sys/types.h>
diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c
index b1774ae..8871988 100644
--- a/ext/sybase_ct/php_sybase_ct.c
+++ b/ext/sybase_ct/php_sybase_ct.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_sybase_ct.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_sybase_ct.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 
 #ifdef HAVE_CONFIG_H
diff --git a/ext/sybase_ct/php_sybase_ct.h b/ext/sybase_ct/php_sybase_ct.h
index d0da053..9add20c 100644
--- a/ext/sybase_ct/php_sybase_ct.h
+++ b/ext/sybase_ct/php_sybase_ct.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_sybase_ct.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_sybase_ct.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SYBASE_CT_H
 #define PHP_SYBASE_CT_H
diff --git a/ext/sysvmsg/php_sysvmsg.h b/ext/sysvmsg/php_sysvmsg.h
index 002381c..f424756 100644
--- a/ext/sysvmsg/php_sysvmsg.h
+++ b/ext/sysvmsg/php_sysvmsg.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_sysvmsg.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_sysvmsg.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SYSVMSG_H
 #define PHP_SYSVMSG_H
diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c
index acedc3f..9b04934 100644
--- a/ext/sysvmsg/sysvmsg.c
+++ b/ext/sysvmsg/sysvmsg.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sysvmsg.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sysvmsg.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #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: 272370 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 293036 $");
 	php_info_print_table_end();
 }
 /* }}} */
diff --git a/ext/sysvsem/php_sysvsem.h b/ext/sysvsem/php_sysvsem.h
index a8cf728..acafae5 100644
--- a/ext/sysvsem/php_sysvsem.h
+++ b/ext/sysvsem/php_sysvsem.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_sysvsem.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_sysvsem.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SYSVSEM_H
 #define PHP_SYSVSEM_H
diff --git a/ext/sysvsem/sysvsem.c b/ext/sysvsem/sysvsem.c
index 33ae22f..768af1c 100644
--- a/ext/sysvsem/sysvsem.c
+++ b/ext/sysvsem/sysvsem.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: sysvsem.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sysvsem.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Latest update build anc tested on Linux 2.2.14
  *
diff --git a/ext/sysvshm/php_sysvshm.h b/ext/sysvshm/php_sysvshm.h
index 6cc3126..c313044 100644
--- a/ext/sysvshm/php_sysvshm.h
+++ b/ext/sysvshm/php_sysvshm.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_sysvshm.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_sysvshm.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SYSVSHM_H
 #define PHP_SYSVSHM_H
diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c
index 94c24b3..32af9a0 100644
--- a/ext/sysvshm/sysvshm.c
+++ b/ext/sysvshm/sysvshm.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: sysvshm.c 281742 2009-06-06 02:40:49Z mattwil $ */
+/* $Id: sysvshm.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* This has been built and tested on Linux 2.2.14 
  *
diff --git a/ext/tidy/php_tidy.h b/ext/tidy/php_tidy.h
index f4df216..84864cb 100644
--- a/ext/tidy/php_tidy.h
+++ b/ext/tidy/php_tidy.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_tidy.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_tidy.h 294004 2010-01-25 17:29:37Z johannes $ */
 
 #ifndef PHP_TIDY_H
 #define PHP_TIDY_H
@@ -28,6 +28,7 @@ extern zend_module_entry tidy_module_entry;
 	ZEND_NAMED_FE(name, ZEND_FN(func_name), arg_types)
 #define TIDY_NODE_METHOD(name)    PHP_FUNCTION(tnm_ ##name)
 #define TIDY_NODE_ME(name, param) TIDY_METHOD_MAP(name, tnm_ ##name, param)
+#define TIDY_NODE_PRIVATE_ME(name, param) ZEND_NAMED_ME(name, ZEND_FN(tnm_ ##name), param, ZEND_ACC_PRIVATE)
 #define TIDY_DOC_METHOD(name)     PHP_FUNCTION(tdm_ ##name)
 #define TIDY_DOC_ME(name, param)  TIDY_METHOD_MAP(name, tdm_ ##name, param)
 #define TIDY_ATTR_METHOD(name)    PHP_FUNCTION(tam_ ##name)
diff --git a/ext/tidy/tests/023.phpt b/ext/tidy/tests/023.phpt
index e7ee4b3..1f7b02d 100644
--- a/ext/tidy/tests/023.phpt
+++ b/ext/tidy/tests/023.phpt
@@ -6,16 +6,11 @@ tidy and tidyNode OO
 <?php
 
 //test leaks here:
-new tidyNode();
-var_dump(new tidyNode());
 new tidy();
 var_dump(new tidy());
 
 echo "-------\n";
 
-$x = new tidyNode();
-var_dump($x->isHtml());
-
 $tidy = new tidy();
 $tidy->parseString('<html><?php echo "xpto;" ?></html>');
 
@@ -30,8 +25,6 @@ var_dump(tidy_get_root($tidy)->child[0]->child[0]->hasChildren());
 
 ?>
 --EXPECT--
-object(tidyNode)#1 (0) {
-}
 object(tidy)#1 (2) {
   ["errorBuffer"]=>
   NULL
@@ -39,7 +32,6 @@ object(tidy)#1 (2) {
   NULL
 }
 -------
-bool(false)
 bool(true)
 bool(true)
 bool(false)
diff --git a/ext/tidy/tests/025.phpt b/ext/tidy/tests/025.phpt
index a7bd544..631ec2e 100644
--- a/ext/tidy/tests/025.phpt
+++ b/ext/tidy/tests/025.phpt
@@ -5,15 +5,6 @@ tidyNode tests
 --FILE--
 <?php
 
-new tidyNode;
-$node = new tidyNode();
-
-var_dump($node->isPhp());
-var_dump($node->isText());
-var_dump($node->isComment());
-var_dump($node->hasSiblings());
-var_dump((string)$node);
-
 $tidy=tidy_parse_string('<% %>');
 var_dump($tidy->Root()->child[0]->isAsp());
 
@@ -34,11 +25,6 @@ var_dump($tidy->Root()->child[0]->child[0]->hasSiblings());
 
 ?>
 --EXPECT--
-bool(false)
-bool(false)
-bool(false)
-bool(false)
-string(0) ""
 bool(true)
 bool(true)
 bool(true)
diff --git a/ext/tidy/tests/035.phpt b/ext/tidy/tests/035.phpt
new file mode 100644
index 0000000..832f90f
--- /dev/null
+++ b/ext/tidy/tests/035.phpt
@@ -0,0 +1,12 @@
+--TEST--
+tidyNode::__construct()
+--SKIPIF--
+<?php
+  if (!extension_loaded('tidy')) die ('skip tidy not present');
+?>
+--FILE--
+<?php
+new tidyNode;
+?>
+--EXPECTF--
+Fatal error: Call to private tidyNode::__construct() from invalid context in %s on line %d
diff --git a/ext/tidy/tests/bug_50558.phpt b/ext/tidy/tests/bug_50558.phpt
new file mode 100644
index 0000000..b37cb92
--- /dev/null
+++ b/ext/tidy/tests/bug_50558.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #50558 - Broken object model when extending tidy
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+class MyTidy extends tidy
+{
+            // foo
+}
+
+function doSomething(MyTidy $o)
+{
+            var_dump($o);
+}
+
+$o = new MyTidy();
+var_dump($o instanceof MyTidy);
+doSomething($o);
+?>
+--EXPECTF--
+bool(true)
+object(MyTidy)#%d (%d) {
+  ["errorBuffer"]=>
+  NULL
+  ["value"]=>
+  NULL
+}
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
index 43c6a41..34b4d23 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: tidy.c 272922 2009-01-06 23:45:16Z iliaa $ */
+/* $Id: tidy.c 294893 2010-02-11 17:36:40Z johannes $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -206,8 +206,6 @@ static char *php_tidy_file_to_mem(char *, zend_bool, int * TSRMLS_DC);
 static void tidy_object_free_storage(void * TSRMLS_DC);
 static zend_object_value tidy_object_new_node(zend_class_entry * TSRMLS_DC);
 static zend_object_value tidy_object_new_doc(zend_class_entry * TSRMLS_DC);
-static zend_class_entry *tidy_get_ce_node(const zval * TSRMLS_DC);
-static zend_class_entry *tidy_get_ce_doc(const zval * TSRMLS_DC);
 static zval * tidy_instanciate(zend_class_entry *, zval * TSRMLS_DC);
 static int tidy_doc_cast_handler(zval *, zval *, int TSRMLS_DC);
 static int tidy_node_cast_handler(zval *, zval *, int TSRMLS_DC);
@@ -268,6 +266,7 @@ static TIDY_NODE_METHOD(isJste);
 static TIDY_NODE_METHOD(isAsp);
 static TIDY_NODE_METHOD(isPhp);
 static TIDY_NODE_METHOD(getParent);
+static TIDY_NODE_METHOD(__construct);
 /* }}} */
 
 ZEND_DECLARE_MODULE_GLOBALS(tidy)
@@ -443,6 +442,7 @@ static const zend_function_entry tidy_funcs_node[] = {
 	TIDY_NODE_ME(isAsp, NULL)
 	TIDY_NODE_ME(isPhp, NULL)
 	TIDY_NODE_ME(getParent, NULL)
+	TIDY_NODE_PRIVATE_ME(__construct, NULL)
 	{NULL, NULL, NULL}
 };
 
@@ -740,16 +740,6 @@ static zend_object_value tidy_object_new_doc(zend_class_entry *class_type TSRMLS
 	return retval;
 }
 
-static zend_class_entry *tidy_get_ce_node(const zval *object TSRMLS_DC)
-{
-	return tidy_ce_node;
-}
-
-static zend_class_entry *tidy_get_ce_doc(const zval *object TSRMLS_DC)
-{
-	return tidy_ce_doc;
-}
-
 static zval * tidy_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)
 {
 	if (!object) {
@@ -1064,9 +1054,6 @@ static PHP_MINIT_FUNCTION(tidy)
 	REGISTER_TIDY_CLASS(tidy, doc,	NULL, 0);
 	REGISTER_TIDY_CLASS(tidyNode, node,	NULL, ZEND_ACC_FINAL_CLASS);
 
-	tidy_object_handlers_doc.get_class_entry = tidy_get_ce_doc;
-	tidy_object_handlers_node.get_class_entry = tidy_get_ce_node;
-	
 	tidy_object_handlers_doc.cast_object = tidy_doc_cast_handler;
 	tidy_object_handlers_node.cast_object = tidy_node_cast_handler;
 
@@ -1098,7 +1085,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 272922 2009-01-06 23:45:16Z iliaa $)");
+	php_info_print_table_row(2, "Extension Version", PHP_TIDY_MODULE_VERSION " ($Id: tidy.c 294893 2010-02-11 17:36:40Z johannes $)");
 	php_info_print_table_end();
 
 	DISPLAY_INI_ENTRIES();
@@ -1790,6 +1777,14 @@ static TIDY_NODE_METHOD(getParent)
 }
 /* }}} */
 
+/* {{{ proto void tidyNode::__construct()
+         __constructor for tidyNode. */
+static TIDY_NODE_METHOD(__construct)
+{
+	php_error_docref(NULL TSRMLS_CC, E_ERROR, "You should not create a tidyNode manually");
+}   
+/* }}} */
+
 static void _php_tidy_register_nodetypes(INIT_FUNC_ARGS)
 {
 	TIDY_NODE_CONST(ROOT, Root);
diff --git a/ext/tokenizer/php_tokenizer.h b/ext/tokenizer/php_tokenizer.h
index 6f5e7e8..29e985b 100644
--- a/ext/tokenizer/php_tokenizer.h
+++ b/ext/tokenizer/php_tokenizer.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_tokenizer.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_tokenizer.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_TOKENIZER_H
 #define PHP_TOKENIZER_H
diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c
index afc20f0..fa597f6 100644
--- a/ext/tokenizer/tokenizer.c
+++ b/ext/tokenizer/tokenizer.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tokenizer.c 277761 2009-03-25 15:23:58Z dmitry $ */
+/* $Id: tokenizer.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/tokenizer/tokenizer_data.c b/ext/tokenizer/tokenizer_data.c
index a1e8696..38f4dde 100644
--- a/ext/tokenizer/tokenizer_data.c
+++ b/ext/tokenizer/tokenizer_data.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tokenizer_data.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: tokenizer_data.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
    DO NOT EDIT THIS FILE!
diff --git a/ext/wddx/php_wddx.h b/ext/wddx/php_wddx.h
index 4ba445a..7b816ff 100644
--- a/ext/wddx/php_wddx.h
+++ b/ext/wddx/php_wddx.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_wddx.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_wddx.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_WDDX_H
 #define PHP_WDDX_H
diff --git a/ext/wddx/php_wddx_api.h b/ext/wddx/php_wddx_api.h
index 6a069bf..db732bd 100644
--- a/ext/wddx/php_wddx_api.h
+++ b/ext/wddx/php_wddx_api.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_wddx_api.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_wddx_api.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_WDDX_API_H
 #define PHP_WDDX_API_H
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index 82b3eb9..507a423 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: wddx.c 282200 2009-06-16 02:54:26Z felipe $ */
+/* $Id: wddx.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/xml/compat.c b/ext/xml/compat.c
index 878b921..9c8761b 100644
--- a/ext/xml/compat.c
+++ b/ext/xml/compat.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/ext/xml/expat_compat.h b/ext/xml/expat_compat.h
index 83c79ed..7b4bc40 100644
--- a/ext/xml/expat_compat.h
+++ b/ext/xml/expat_compat.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: expat_compat.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: expat_compat.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_EXPAT_COMPAT_H
 #define PHP_EXPAT_COMPAT_H
diff --git a/ext/xml/php_xml.h b/ext/xml/php_xml.h
index db2d792..cd6ebec 100644
--- a/ext/xml/php_xml.h
+++ b/ext/xml/php_xml.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_xml.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_xml.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_XML_H
 #define PHP_XML_H
diff --git a/ext/xml/tests/bug32001b.phpt b/ext/xml/tests/bug32001b.phpt
index f4aea08..ddf26ce 100755
--- a/ext/xml/tests/bug32001b.phpt
+++ b/ext/xml/tests/bug32001b.phpt
@@ -95,9 +95,7 @@ $suite = array(
 );
 
 if (XML_SAX_IMPL == 'libxml') {
-  $php = getenv('TEST_PHP_EXECUTABLE');
-  preg_match("/^libxml2 Version.*\$/im", `$php -i`, $match);
-  echo $match[0], "\n";
+  echo "libxml2 Version => " . LIBXML_DOTTED_VERSION. "\n";
 } else {
   echo "libxml2 Version => NONE\n";  
 }
diff --git a/ext/xml/tests/bug50576.phpt b/ext/xml/tests/bug50576.phpt
new file mode 100644
index 0000000..fd3d0cb
--- /dev/null
+++ b/ext/xml/tests/bug50576.phpt
@@ -0,0 +1,133 @@
+--TEST--
+Bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+?>
+--FILE--
+<?php
+
+$XML = <<<XML
+<?xml version="1.0"?>
+<ns1:listOfAwards xmlns:ns1="http://www.fpdsng.com/FPDS">
+<ns1:count>
+<ns1:total>867</ns1:total>
+</ns1:count>
+</ns1:listOfAwards>
+XML;
+
+$xml_parser = xml_parser_create();
+xml_parser_set_option($xml_parser, XML_OPTION_SKIP_TAGSTART, 4);
+xml_parse_into_struct($xml_parser, $XML, $vals, $index);
+echo 'Index array' . PHP_EOL;
+print_r($index);
+echo 'Vals array' . PHP_EOL;
+print_r($vals);
+xml_parser_free($xml_parser);
+
+function startElement($parser, $name, $attribs) { echo $name . PHP_EOL; }
+function endElement($parser, $name) { echo $name . PHP_EOL; }
+$xml_parser = xml_parser_create();
+xml_set_element_handler($xml_parser, 'startElement', 'endElement');
+xml_parser_set_option($xml_parser, XML_OPTION_SKIP_TAGSTART, 4);
+xml_parse($xml_parser, $XML);
+xml_parser_free($xml_parser);
+
+?>
+--EXPECTF--
+Index array
+Array
+(
+    [LISTOFAWARDS] => Array
+        (
+            [0] => 0
+            [1] => 5
+            [2] => 6
+        )
+
+    [COUNT] => Array
+        (
+            [0] => 1
+            [1] => 3
+            [2] => 4
+        )
+
+    [TOTAL] => Array
+        (
+            [0] => 2
+        )
+
+)
+Vals array
+Array
+(
+    [0] => Array
+        (
+            [tag] => LISTOFAWARDS
+            [type] => open
+            [level] => 1
+            [attributes] => Array
+                (
+                    [XMLNS:NS1] => http://www.fpdsng.com/FPDS
+                )
+
+            [value] => 
+
+        )
+
+    [1] => Array
+        (
+            [tag] => COUNT
+            [type] => open
+            [level] => 2
+            [value] => 
+
+        )
+
+    [2] => Array
+        (
+            [tag] => TOTAL
+            [type] => complete
+            [level] => 3
+            [value] => 867
+        )
+
+    [3] => Array
+        (
+            [tag] => COUNT
+            [value] => 
+
+            [type] => cdata
+            [level] => 2
+        )
+
+    [4] => Array
+        (
+            [tag] => COUNT
+            [type] => close
+            [level] => 2
+        )
+
+    [5] => Array
+        (
+            [tag] => LISTOFAWARDS
+            [value] => 
+
+            [type] => cdata
+            [level] => 1
+        )
+
+    [6] => Array
+        (
+            [tag] => LISTOFAWARDS
+            [type] => close
+            [level] => 1
+        )
+
+)
+LISTOFAWARDS
+COUNT
+TOTAL
+TOTAL
+COUNT
+LISTOFAWARDS
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index 2a9240e..5dd532a 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: xml.c 287790 2009-08-27 05:05:42Z rasmus $ */
+/* $Id: xml.c 294434 2010-02-03 18:35:58Z pajoye $ */
 
 #define IS_EXT_MODULE
 
@@ -804,7 +804,7 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch
 
 		if (parser->startElementHandler) {
 			args[0] = _xml_resource_zval(parser->index);
-			args[1] = _xml_string_zval(tag_name);
+			args[1] = _xml_string_zval(((char *) tag_name) + parser->toffset);
 			MAKE_STD_ZVAL(args[2]);
 			array_init(args[2]);
 
@@ -884,7 +884,7 @@ void _xml_endElementHandler(void *userData, const XML_Char *name)
 
 		if (parser->endElementHandler) {
 			args[0] = _xml_resource_zval(parser->index);
-			args[1] = _xml_string_zval(tag_name);
+			args[1] = _xml_string_zval(((char *) tag_name) + parser->toffset);
 
 			if ((retval = xml_call_handler(parser, parser->endElementHandler, parser->endElementPtr, 2, args))) {
 				zval_ptr_dtor(&retval);
@@ -1270,9 +1270,7 @@ PHP_FUNCTION(xml_set_object)
 #endif */
 
 	ALLOC_ZVAL(parser->object);
-	*parser->object = *mythis;
-	zval_copy_ctor(parser->object);
-	INIT_PZVAL(parser->object);
+	MAKE_COPY_ZVAL(&mythis, parser->object);
 
 	RETVAL_TRUE;
 }
diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c
index 26c8bd2..ad9c206 100644
--- a/ext/xmlreader/php_xmlreader.c
+++ b/ext/xmlreader/php_xmlreader.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_xmlreader.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_xmlreader.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/xmlreader/php_xmlreader.h b/ext/xmlreader/php_xmlreader.h
index de3790c..3d510a0 100644
--- a/ext/xmlreader/php_xmlreader.h
+++ b/ext/xmlreader/php_xmlreader.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_xmlreader.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_xmlreader.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_XMLREADER_H
 #define PHP_XMLREADER_H
diff --git a/ext/xmlrpc/php_xmlrpc.h b/ext/xmlrpc/php_xmlrpc.h
index ce18b53..d1bc19c 100644
--- a/ext/xmlrpc/php_xmlrpc.h
+++ b/ext/xmlrpc/php_xmlrpc.h
@@ -37,7 +37,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -51,7 +51,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_xmlrpc.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_xmlrpc.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef _PHP_XMLRPC_H
 #define _PHP_XMLRPC_H
diff --git a/ext/xmlrpc/tests/bug50282.phpt b/ext/xmlrpc/tests/bug50282.phpt
new file mode 100644
index 0000000..eb35fe3
--- /dev/null
+++ b/ext/xmlrpc/tests/bug50282.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Bug #50282 (xmlrpc_encode_request() changes object into array in calling function)
+--SKIPIF--
+<?php if (!extension_loaded("xmlrpc")) print "skip"; ?>
+--FILE--
+<?php
+
+class One { var $x = 10; }
+
+$o = new One();
+var_dump($o);
+var_dump(xmlrpc_encode_request('test', $o));
+var_dump($o);
+
+?>
+--EXPECTF--
+object(One)#%d (1) {
+  ["x"]=>
+  int(10)
+}
+string(279) "<?xml version="1.0" encoding="iso-8859-1"?>
+<methodCall>
+<methodName>test</methodName>
+<params>
+ <param>
+  <value>
+   <struct>
+    <member>
+     <name>x</name>
+     <value>
+      <int>10</int>
+     </value>
+    </member>
+   </struct>
+  </value>
+ </param>
+</params>
+</methodCall>
+"
+object(One)#%d (1) {
+  ["x"]=>
+  int(10)
+}
diff --git a/ext/xmlrpc/tests/bug50285.phpt b/ext/xmlrpc/tests/bug50285.phpt
new file mode 100644
index 0000000..cf766fc
--- /dev/null
+++ b/ext/xmlrpc/tests/bug50285.phpt
@@ -0,0 +1,115 @@
+--TEST--
+Bug #50285 (xmlrpc does not preserve keys in encoded indexed arrays)
+--FILE--
+<?php
+
+function test1($func, $params) {
+    return array(1=>'One', 3=>'Three', 5=>'Five');
+}
+
+function test2($func, $params) {
+    return array('One', 'Three', 'Five', 5);
+}
+
+function test3($func, $params) {
+    return array('One', 3 => 'Three', b'Five' => 5, 'Six');
+}
+
+function test4($func, $params) {
+    return array('One', 'Three', 'Five', b'Six' => 6);
+}
+
+$server = xmlrpc_server_create();
+$result = xmlrpc_server_register_method($server, 'test1', 'test1');
+$HTTP_RAW_POST_DATA = <<<EOD
+<?xml version="1.0" encoding="UTF-8"?>
+<methodCall>
+<methodName>test1</methodName>
+<params />
+</methodCall>
+EOD;
+$response = xmlrpc_server_call_method($server, $HTTP_RAW_POST_DATA, null);
+var_dump(xmlrpc_decode($response));
+
+// ------------ 
+
+$server = xmlrpc_server_create();
+$result = xmlrpc_server_register_method($server, 'test2', 'test2');
+$HTTP_RAW_POST_DATA = <<<EOD
+<?xml version="1.0" encoding="UTF-8"?>
+<methodCall>
+<methodName>test2</methodName>
+<params />
+</methodCall>
+EOD;
+$response = xmlrpc_server_call_method($server, $HTTP_RAW_POST_DATA, null);
+var_dump(xmlrpc_decode($response));
+
+// ------------ 
+
+$server = xmlrpc_server_create();
+$result = xmlrpc_server_register_method($server, 'test3', 'test3');
+$HTTP_RAW_POST_DATA = <<<EOD
+<?xml version="1.0" encoding="UTF-8"?>
+<methodCall>
+<methodName>test3</methodName>
+<params />
+</methodCall>
+EOD;
+$response = xmlrpc_server_call_method($server, $HTTP_RAW_POST_DATA, null);
+var_dump(xmlrpc_decode($response));
+
+// ------------ 
+
+$server = xmlrpc_server_create();
+$result = xmlrpc_server_register_method($server, 'test4', 'test4');
+$HTTP_RAW_POST_DATA = <<<EOD
+<?xml version="1.0" encoding="UTF-8"?>
+<methodCall>
+<methodName>test4</methodName>
+<params />
+</methodCall>
+EOD;
+$response = xmlrpc_server_call_method($server, $HTTP_RAW_POST_DATA, null);
+var_dump(xmlrpc_decode($response));
+
+?>
+--EXPECT--
+array(3) {
+  [1]=>
+  string(3) "One"
+  [3]=>
+  string(5) "Three"
+  [5]=>
+  string(4) "Five"
+}
+array(4) {
+  [0]=>
+  string(3) "One"
+  [1]=>
+  string(5) "Three"
+  [2]=>
+  string(4) "Five"
+  [3]=>
+  int(5)
+}
+array(4) {
+  [0]=>
+  string(3) "One"
+  [3]=>
+  string(5) "Three"
+  ["Five"]=>
+  int(5)
+  [4]=>
+  string(3) "Six"
+}
+array(4) {
+  [0]=>
+  string(3) "One"
+  [1]=>
+  string(5) "Three"
+  [2]=>
+  string(4) "Five"
+  ["Six"]=>
+  int(6)
+}
diff --git a/ext/xmlrpc/tests/bug50761.phpt b/ext/xmlrpc/tests/bug50761.phpt
new file mode 100644
index 0000000..653d850
--- /dev/null
+++ b/ext/xmlrpc/tests/bug50761.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Bug #50761 (system.multiCall crashes)
+--FILE--
+<?php
+$req = '<?xml version="1.0"?>
+<methodCall>
+<methodName>system.multiCall</methodName>
+<params><param><value><array><data>
+<value><struct>
+<member><name>methodName</name><value><string>testMethodA</string></value></member>
+<member><name>params</name><value><array><data><value><string>A</string>
+</value></data></array></value></member>
+</struct></value>
+<value><struct>
+<member><name>methodName</name><value><string>testMethodB</string></value></member>
+<member><name>params</name><value><array><data><value><string>B</string>
+</value></data></array></value></member>
+</struct></value>
+</data></array></value></param></params>
+</methodCall>';
+
+function testA($methodName, $params, $var){ return "C"; }
+function testB($methodName, $params, $var){ return "D"; }
+
+$server = xmlrpc_server_create();
+xmlrpc_server_register_method($server, 'testMethodA', 'testA');
+xmlrpc_server_register_method($server, 'testMethodB', 'testB');
+$res = xmlrpc_server_call_method($server, $req, null);
+echo $res;
+?>
+--EXPECT--
+<?xml version="1.0" encoding="iso-8859-1"?>
+<methodResponse>
+<params>
+ <param>
+  <value>
+   <array>
+    <data>
+     <value>
+      <array>
+       <data>
+        <value>
+         <string>C</string>
+        </value>
+       </data>
+      </array>
+     </value>
+     <value>
+      <array>
+       <data>
+        <value>
+         <string>D</string>
+        </value>
+       </data>
+      </array>
+     </value>
+    </data>
+   </array>
+  </value>
+ </param>
+</params>
+</methodResponse>
diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c
index 77ec4ec..054ea2f 100644
--- a/ext/xmlrpc/xmlrpc-epi-php.c
+++ b/ext/xmlrpc/xmlrpc-epi-php.c
@@ -37,7 +37,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -51,7 +51,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: xmlrpc-epi-php.c 287434 2009-08-18 00:41:43Z stas $ */
+/* $Id: xmlrpc-epi-php.c 294452 2010-02-03 20:19:05Z pajoye $ */
 
 /**********************************************************************
 * BUGS:                                                               *
@@ -484,7 +484,7 @@ static void set_output_options(php_output_options* options, zval* output_opts)
 static XMLRPC_VECTOR_TYPE determine_vector_type (HashTable *ht)
 {
 	int bArray = 0, bStruct = 0, bMixed = 0;
-	unsigned long num_index;
+	unsigned long num_index, last_num = 0;
 	char* my_key;
 
 	zend_hash_internal_pointer_reset(ht);
@@ -495,8 +495,12 @@ static XMLRPC_VECTOR_TYPE determine_vector_type (HashTable *ht)
 			if (bStruct) {
 				bMixed = 1;
 				break;
+			} else if (last_num > 0 && last_num != num_index-1) {
+				bStruct = 1;
+				break;
 			}
 			bArray = 1;
+			last_num = num_index;
 		} else if (res == HASH_KEY_NON_EXISTANT) {
 			break;
 		} else if (res == HASH_KEY_IS_STRING) {
@@ -556,6 +560,8 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep
 						zval** pIter;
 						char* my_key;
 						HashTable *ht = NULL;
+						zval *val_arr;
+						XMLRPC_VECTOR_TYPE vtype;
 
 						ht = HASH_OF(val);
 						if (ht && ht->nApplyCount > 1) {
@@ -563,12 +569,16 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep
 							return NULL;
 						}
 
-						convert_to_array(val);
-						xReturn = XMLRPC_CreateVector(key, determine_vector_type(Z_ARRVAL_P(val)));
+						MAKE_STD_ZVAL(val_arr);
+						MAKE_COPY_ZVAL(&val, val_arr);
+						convert_to_array(val_arr);
+						
+						vtype = determine_vector_type(Z_ARRVAL_P(val_arr));
+						xReturn = XMLRPC_CreateVector(key, vtype);
 
-						zend_hash_internal_pointer_reset(Z_ARRVAL_P(val));
-						while(zend_hash_get_current_data(Z_ARRVAL_P(val), (void**)&pIter) == SUCCESS) {
-							int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val), &my_key, &num_index);
+						zend_hash_internal_pointer_reset(Z_ARRVAL_P(val_arr));
+						while(zend_hash_get_current_data(Z_ARRVAL_P(val_arr), (void**)&pIter) == SUCCESS) {
+							int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val_arr), &my_key, &num_index);
 
 							switch (res) {
 								case HASH_KEY_NON_EXISTANT:
@@ -580,7 +590,15 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep
 										ht->nApplyCount++;
 									}
 									if (res == HASH_KEY_IS_LONG) {
-										XMLRPC_AddValueToVector(xReturn, PHP_to_XMLRPC_worker(0, *pIter, depth++ TSRMLS_CC));
+										char *num_str = NULL;
+										
+										if (vtype != xmlrpc_vector_array) {
+											spprintf(&num_str, 0, "%ld", num_index);
+										}
+										XMLRPC_AddValueToVector(xReturn, PHP_to_XMLRPC_worker(num_str, *pIter, depth++ TSRMLS_CC));
+										if (num_str) {
+											efree(num_str);
+										}
 									} else {
 										XMLRPC_AddValueToVector(xReturn, PHP_to_XMLRPC_worker(my_key, *pIter, depth++ TSRMLS_CC));
 									}
@@ -589,8 +607,9 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep
 									}
 									break;
 							}
-							zend_hash_move_forward(Z_ARRVAL_P(val));
-						}
+							zend_hash_move_forward(Z_ARRVAL_P(val_arr));
+						}	
+						zval_ptr_dtor(&val_arr);
 					}
 					break;
 				default:
@@ -892,12 +911,26 @@ PHP_FUNCTION(xmlrpc_server_destroy)
 static XMLRPC_VALUE php_xmlrpc_callback(XMLRPC_SERVER server, XMLRPC_REQUEST xRequest, void* data) /* {{{ */
 {
 	xmlrpc_callback_data* pData = (xmlrpc_callback_data*)data;
+	zval** php_function;
 	zval* xmlrpc_params;
 	zval* callback_params[3];
 	TSRMLS_FETCH();
 
+	zval_dtor(pData->xmlrpc_method);
+	zval_dtor(pData->return_data);
+
 	/* convert xmlrpc to native php types */
+	ZVAL_STRING(pData->xmlrpc_method, XMLRPC_RequestGetMethodName(xRequest), 1);
 	xmlrpc_params = XMLRPC_to_PHP(XMLRPC_RequestGetData(xRequest));
+	
+	/* check if the called method has been previous registered */
+	if(zend_hash_find(Z_ARRVAL_P(pData->server->method_map),
+                      Z_STRVAL_P(pData->xmlrpc_method), 
+                      Z_STRLEN_P(pData->xmlrpc_method) + 1, 
+                      (void**)&php_function) == SUCCESS) {
+
+		pData->php_function = *php_function;
+	}
 
 	/* setup data hoojum */
 	callback_params[0] = pData->xmlrpc_method;
@@ -913,7 +946,7 @@ static XMLRPC_VALUE php_xmlrpc_callback(XMLRPC_SERVER server, XMLRPC_REQUEST xRe
 
 	zval_ptr_dtor(&xmlrpc_params);
 
-	return NULL;
+	return PHP_to_XMLRPC(pData->return_data TSRMLS_CC);
 }
 /* }}} */
 
@@ -1082,34 +1115,17 @@ PHP_FUNCTION(xmlrpc_server_call_method)
 
 		if (xRequest) {
 			const char* methodname = XMLRPC_RequestGetMethodName(xRequest);
-			zval **php_function;
 			XMLRPC_VALUE xAnswer = NULL;
 			MAKE_STD_ZVAL(data.xmlrpc_method); /* init. very important.  spent a frustrating day finding this out. */
 			MAKE_STD_ZVAL(data.return_data);
 			Z_TYPE_P(data.return_data) = IS_NULL;  /* in case value is never init'd, we don't dtor to think it is a string or something */
 			Z_TYPE_P(data.xmlrpc_method) = IS_NULL;
 
-			if (!methodname) {
-				methodname = "";
-			}
-            
 			/* setup some data to pass to the callback function */
-			Z_STRVAL_P(data.xmlrpc_method) = estrdup(methodname);
-			Z_STRLEN_P(data.xmlrpc_method) = strlen(methodname);
-			Z_TYPE_P(data.xmlrpc_method) = IS_STRING;
 			data.caller_params = *caller_params;
 			data.php_executed = 0;
 			data.server = server;
 
-			/* check if the called method has been previous registered */
-			if (zend_hash_find(Z_ARRVAL_P(server->method_map),
-								Z_STRVAL_P(data.xmlrpc_method), 
-								Z_STRLEN_P(data.xmlrpc_method) + 1, 
-								(void**)&php_function) == SUCCESS) {
-
-				data.php_function = *php_function;
-			}
-
 			/* We could just call the php method directly ourselves at this point, but we do this 
 			 * with a C callback in case the xmlrpc library ever implements some cool usage stats,
 			 * or somesuch.
@@ -1119,7 +1135,7 @@ PHP_FUNCTION(xmlrpc_server_call_method)
 				zval_dtor(data.return_data);
 				FREE_ZVAL(data.return_data);
 				data.return_data = XMLRPC_to_PHP(xAnswer);
-			} else if (data.php_executed && !out.b_php_out) {
+			} else if (data.php_executed && !out.b_php_out && !xAnswer) {
 				xAnswer = PHP_to_XMLRPC(data.return_data TSRMLS_CC);
 			}
 
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c
index 9af9809..3443bd7 100644
--- a/ext/xmlwriter/php_xmlwriter.c
+++ b/ext/xmlwriter/php_xmlwriter.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_xmlwriter.c 281145 2009-05-26 08:10:49Z pajoye $ */
+/* $Id: php_xmlwriter.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/xmlwriter/php_xmlwriter.h b/ext/xmlwriter/php_xmlwriter.h
index 86240b3..a62b4fe 100644
--- a/ext/xmlwriter/php_xmlwriter.h
+++ b/ext/xmlwriter/php_xmlwriter.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_xmlwriter.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_xmlwriter.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_XMLWRITER_H
 #define PHP_XMLWRITER_H
diff --git a/ext/xsl/php_xsl.c b/ext/xsl/php_xsl.c
index 4bbf59d..5839230 100644
--- a/ext/xsl/php_xsl.c
+++ b/ext/xsl/php_xsl.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_xsl.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_xsl.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/xsl/php_xsl.h b/ext/xsl/php_xsl.h
index 38d2c87..ce8d975 100644
--- a/ext/xsl/php_xsl.h
+++ b/ext/xsl/php_xsl.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_xsl.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_xsl.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_XSL_H
 #define PHP_XSL_H
diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcnostring.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcnostring.phpt
index a0d6bf6..d9a7051 100644
--- a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcnostring.phpt
+++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcnostring.phpt
@@ -30,8 +30,8 @@ Warning: XSLTProcessor::transformToXml(): xmlXPathCompiledEval: evaluation faile
 
 Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %d element value-of in %s on line %d
 
-Warning: XSLTProcessor::transformToXml(): XPath evaluation returned no result. in %s on line %d
-NULL
+Warning: XSLTProcessor::transformToXml(): xsltValueOf: text copy failed in %s on line %d
+bool(false)
 --CREDITS--
 Christian Weiske, cweiske at php.net
 PHP Testfest Berlin 2009-05-09
diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcundef.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcundef.phpt
index 1aa7bb0..a0ddf96 100644
--- a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcundef.phpt
+++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcundef.phpt
@@ -29,8 +29,8 @@ Warning: XSLTProcessor::transformToXml(): xmlXPathCompiledEval: evaluation faile
 
 Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %d element value-of in %s on line %d
 
-Warning: XSLTProcessor::transformToXml(): XPath evaluation returned no result. in %s on line %d
-NULL
+Warning: XSLTProcessor::transformToXml(): xsltValueOf: text copy failed in %s on line %d
+bool(false)
 --CREDITS--
 Christian Weiske, cweiske at php.net
 PHP Testfest Berlin 2009-05-09
diff --git a/ext/xsl/xsl_fe.h b/ext/xsl/xsl_fe.h
index f21b898..48377ca 100644
--- a/ext/xsl/xsl_fe.h
+++ b/ext/xsl/xsl_fe.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: xsl_fe.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: xsl_fe.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef XSL_FE_H
 #define XSL_FE_H
diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c
index e07bdd5..e6d7e53 100644
--- a/ext/xsl/xsltprocessor.c
+++ b/ext/xsl/xsltprocessor.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: xsltprocessor.c 287968 2009-09-02 13:07:44Z iliaa $ */
+/* $Id: xsltprocessor.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/ext/zip/lib/zip_close.c b/ext/zip/lib/zip_close.c
index bc640c7..0796f27 100644
--- a/ext/zip/lib/zip_close.c
+++ b/ext/zip/lib/zip_close.c
@@ -135,6 +135,7 @@ zip_close(struct zip *za)
 
     if ((temp=_zip_create_temp_output(za, &out)) == NULL) {
 	_zip_cdir_free(cd);
+	free(filelist);
 	return -1;
     }
 
@@ -192,7 +193,8 @@ zip_close(struct zip *za)
 		error = 1;
 		break;
 	    }
-	    if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0) {
+	    if (_zip_dirent_read(&de, za->zp, NULL, NULL, 1,
+				 &za->error) != 0) {
 		error = 1;
 		break;
 	    }
@@ -264,6 +266,8 @@ zip_close(struct zip *za)
 	_zip_dirent_finalize(&de);
     }
 
+    free(filelist);
+
     if (!error) {
 	if (write_cdir(za, cd, out) < 0)
 	    error = 1;
@@ -306,6 +310,8 @@ zip_close(struct zip *za)
     mask = umask(0);
     umask(mask);
     chmod(za->zn, 0666&~mask);
+    if (za->ch_comment)
+        free(za->ch_comment);
 
     _zip_free(za);
 	free(temp);
@@ -443,6 +449,7 @@ add_data_uncomp(struct zip *za, zip_source_callback cb, void *ud,
 
     zstr.next_out = (Bytef *)b2;
     zstr.avail_out = sizeof(b2);
+    zstr.next_in = NULL;
     zstr.avail_in = 0;
 
     flush = 0;
diff --git a/ext/zip/lib/zip_dirent.c b/ext/zip/lib/zip_dirent.c
index 425f7ff..39fcb6f 100644
--- a/ext/zip/lib/zip_dirent.c
+++ b/ext/zip/lib/zip_dirent.c
@@ -68,6 +68,30 @@ _zip_cdir_free(struct zip_cdir *cd)
 
 
 
+int
+_zip_cdir_grow(struct zip_cdir *cd, int nentry, struct zip_error *error)
+{
+    struct zip_dirent *entry;
+
+    if (nentry < cd->nentry) {
+	_zip_error_set(error, ZIP_ER_INTERNAL, 0);
+	return -1;
+    }
+
+    if ((entry=((struct zip_dirent *)
+		realloc(cd->entry, sizeof(*(cd->entry))*nentry))) == NULL) {
+	_zip_error_set(error, ZIP_ER_MEMORY, 0);
+	return -1;
+    }
+
+    cd->nentry = nentry;
+    cd->entry = entry;
+
+    return 0;
+}
+
+
+
 struct zip_cdir *
 _zip_cdir_new(int nentry, struct zip_error *error)
 {
@@ -173,19 +197,23 @@ _zip_dirent_init(struct zip_dirent *de)
    Fills the zip directory entry zde.
 
    If bufp is non-NULL, data is taken from there and bufp is advanced
-   by the amount of data used; no more than left bytes are used.
-   Otherwise data is read from fp as needed.
+   by the amount of data used; otherwise data is read from fp as needed.
+   
+   if leftp is non-NULL, no more bytes than specified by it are used,
+   and *leftp is reduced by the number of bytes used.
 
-   If localp != 0, it reads a local header instead of a central
+   If local != 0, it reads a local header instead of a central
    directory entry.
 
    Returns 0 if successful. On error, error is filled in and -1 is
    returned.
+
+   XXX: leftp and file position undefined on error.
 */
 
 int
 _zip_dirent_read(struct zip_dirent *zde, FILE *fp,
-		 unsigned char **bufp, unsigned int left, int localp,
+		 unsigned char **bufp, unsigned int *leftp, int local,
 		 struct zip_error *error)
 {
     unsigned char buf[CDENTRYSIZE];
@@ -193,18 +221,19 @@ _zip_dirent_read(struct zip_dirent *zde, FILE *fp,
     unsigned short dostime, dosdate;
     unsigned int size;
 
-    if (localp)
+    if (local)
 	size = LENTRYSIZE;
     else
 	size = CDENTRYSIZE;
-    
+
+    if (leftp && (*leftp < size)) {
+	_zip_error_set(error, ZIP_ER_NOZIP, 0);
+	return -1;
+    }
+
     if (bufp) {
 	/* use data from buffer */
 	cur = *bufp;
-	if (left < size) {
-	    _zip_error_set(error, ZIP_ER_NOZIP, 0);
-	    return -1;
-	}
     }
     else {
 	/* read entry from disk */
@@ -212,11 +241,10 @@ _zip_dirent_read(struct zip_dirent *zde, FILE *fp,
 	    _zip_error_set(error, ZIP_ER_READ, errno);
 	    return -1;
 	}
-	left = size;
 	cur = buf;
     }
 
-    if (memcmp(cur, (localp ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) {
+    if (memcmp(cur, (local ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) {
 	_zip_error_set(error, ZIP_ER_NOZIP, 0);
 	return -1;
     }
@@ -225,7 +253,7 @@ _zip_dirent_read(struct zip_dirent *zde, FILE *fp,
     
     /* convert buffercontents to zip_dirent */
     
-    if (!localp)
+    if (!local)
 	zde->version_madeby = _zip_read2(&cur);
     else
 	zde->version_madeby = 0;
@@ -245,7 +273,7 @@ _zip_dirent_read(struct zip_dirent *zde, FILE *fp,
     zde->filename_len = _zip_read2(&cur);
     zde->extrafield_len = _zip_read2(&cur);
     
-    if (localp) {
+    if (local) {
 	zde->comment_len = 0;
 	zde->disk_number = 0;
 	zde->int_attrib = 0;
@@ -263,13 +291,14 @@ _zip_dirent_read(struct zip_dirent *zde, FILE *fp,
     zde->extrafield = NULL;
     zde->comment = NULL;
 
-    if (bufp) {
-	if (left < CDENTRYSIZE + (zde->filename_len+zde->extrafield_len
-				  +zde->comment_len)) {
-	    _zip_error_set(error, ZIP_ER_NOZIP, 0);
-	    return -1;
-	}
+    size += zde->filename_len+zde->extrafield_len+zde->comment_len;
 
+    if (leftp && (*leftp < size)) {
+	_zip_error_set(error, ZIP_ER_NOZIP, 0);
+	return -1;
+    }
+
+    if (bufp) {
 	if (zde->filename_len) {
 	    zde->filename = _zip_readstr(&cur, zde->filename_len, 1, error);
 	    if (!zde->filename)
@@ -312,6 +341,8 @@ _zip_dirent_read(struct zip_dirent *zde, FILE *fp,
 
     if (bufp)
       *bufp = cur;
+    if (leftp)
+	*leftp -= size;
 
     return 0;
 }
@@ -442,23 +473,22 @@ _zip_dirent_write(struct zip_dirent *zde, FILE *fp, int localp,
 static time_t
 _zip_d2u_time(int dtime, int ddate)
 {
-    struct tm *tm;
-    time_t now;
+    struct tm tm;
 
-    now = time(NULL);
-    tm = localtime(&now);
+    memset(&tm, sizeof(tm), 0);
+    
     /* let mktime decide if DST is in effect */
-    tm->tm_isdst = -1;
+    tm.tm_isdst = -1;
     
-    tm->tm_year = ((ddate>>9)&127) + 1980 - 1900;
-    tm->tm_mon = ((ddate>>5)&15) - 1;
-    tm->tm_mday = ddate&31;
+    tm.tm_year = ((ddate>>9)&127) + 1980 - 1900;
+    tm.tm_mon = ((ddate>>5)&15) - 1;
+    tm.tm_mday = ddate&31;
 
-    tm->tm_hour = (dtime>>11)&31;
-    tm->tm_min = (dtime>>5)&63;
-    tm->tm_sec = (dtime<<1)&62;
+    tm.tm_hour = (dtime>>11)&31;
+    tm.tm_min = (dtime>>5)&63;
+    tm.tm_sec = (dtime<<1)&62;
 
-    return mktime(tm);
+    return mktime(&tm);
 }
 
 
diff --git a/ext/zip/lib/zip_file_get_offset.c b/ext/zip/lib/zip_file_get_offset.c
index 68f92f1..b96fd5e 100644
--- a/ext/zip/lib/zip_file_get_offset.c
+++ b/ext/zip/lib/zip_file_get_offset.c
@@ -63,7 +63,7 @@ _zip_file_get_offset(struct zip *za, int idx)
 	return 0;
     }
 
-    if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0)
+    if (_zip_dirent_read(&de, za->zp, NULL, NULL, 1, &za->error) != 0)
 	return 0;
 
     offset += LENTRYSIZE + de.filename_len + de.extrafield_len;
diff --git a/ext/zip/lib/zip_fread.c b/ext/zip/lib/zip_fread.c
index c0b71b8..00a6bdc 100644
--- a/ext/zip/lib/zip_fread.c
+++ b/ext/zip/lib/zip_fread.c
@@ -63,7 +63,7 @@ zip_fread(struct zip_file *zf, void *outbuf, size_t toread)
 	}
 	return 0;
     }
- 
+
     if ((zf->flags & ZIP_ZF_DECOMP) == 0) {
 	ret = _zip_file_fillbuf(outbuf, toread, zf);
 	if (ret > 0) {
@@ -84,25 +84,22 @@ zip_fread(struct zip_file *zf, void *outbuf, size_t toread)
 
 	switch (ret) {
 	case Z_STREAM_END:
-		zf->flags |= ZIP_ZF_EOF;
+	    if (zf->zstr->total_out == out_before) {
+		if (zf->crc != zf->crc_orig) {
+		    _zip_error_set(&zf->error, ZIP_ER_CRC, 0);
+		    return -1;
+		}
+		else
+		    return 0;
+	    }
 
-	case Z_OK:
+	    /* fallthrough */
 
-	    /* all ok */
-	    /* Z_STREAM_END probably won't happen, since we didn't
-	       have a header */
+	case Z_OK:
 	    len = zf->zstr->total_out - out_before;
 	    if (len >= zf->bytes_left || len >= toread) {
-		    if (zf->flags & ZIP_ZF_CRC) {
-			    zf->crc = crc32(zf->crc, (Bytef *)outbuf, len);
-			    if (zf->flags & ZIP_ZF_EOF == 1) {
-				    if (zf->crc != zf->crc_orig) {
-					    _zip_error_set(&zf->error, ZIP_ER_CRC, 0);
-					    return -1;
-				    }
-
-			    }
-		    }
+		if (zf->flags & ZIP_ZF_CRC)
+		    zf->crc = crc32(zf->crc, (Bytef *)outbuf, len);
 		zf->bytes_left -= len;
 	        return len;
 	    }
diff --git a/ext/zip/lib/zip_open.c b/ext/zip/lib/zip_open.c
index e384019..31e12f4 100644
--- a/ext/zip/lib/zip_open.c
+++ b/ext/zip/lib/zip_open.c
@@ -162,6 +162,7 @@ _zip_readcdir(FILE *fp, unsigned char *buf, unsigned char *eocd, int buflen,
     struct zip_cdir *cd;
     unsigned char *cdp, **bufp;
     int i, comlen, nentry;
+    unsigned int left;
 
     comlen = buf + buflen - eocd - EOCDLEN;
     if (comlen < 0) {
@@ -215,7 +216,6 @@ _zip_readcdir(FILE *fp, unsigned char *buf, unsigned char *eocd, int buflen,
 	}
     }
 
-    cdp = eocd;
     if (cd->size < (unsigned int)(eocd-buf)) {
 	/* if buffer already read in, use it */
 	cdp = eocd - cd->size;
@@ -239,14 +239,23 @@ _zip_readcdir(FILE *fp, unsigned char *buf, unsigned char *eocd, int buflen,
 	}
     }
 
-    for (i=0; i<cd->nentry; i++) {
-	if ((_zip_dirent_read(cd->entry+i, fp, bufp, eocd-cdp, 0,
-			      error)) < 0) {
+    left = cd->size;
+    i=0;
+    do {
+	if (i == cd->nentry && left > 0) {
+	    /* Infozip extension for more than 64k entries:
+	       nentries wraps around, size indicates correct EOCD */
+	    _zip_cdir_grow(cd, cd->nentry+0x10000, error);
+	}
+
+	if ((_zip_dirent_read(cd->entry+i, fp, bufp, &left, 0, error)) < 0) {
 	    cd->nentry = i;
 	    _zip_cdir_free(cd);
 	    return NULL;
 	}
-    }
+	i++;
+	
+    } while (i<cd->nentry);
     
     return cd;
 }
@@ -295,7 +304,7 @@ _zip_checkcons(FILE *fp, struct zip_cdir *cd, struct zip_error *error)
 	    return -1;
 	}
 	
-	if (_zip_dirent_read(&temp, fp, NULL, 0, 1, error) == -1)
+	if (_zip_dirent_read(&temp, fp, NULL, NULL, 1, error) == -1)
 	    return -1;
 	
 	if (_zip_headercomp(cd->entry+i, 0, &temp, 1) != 0) {
diff --git a/ext/zip/lib/zipint.h b/ext/zip/lib/zipint.h
index e7e35e4..d72ed14 100644
--- a/ext/zip/lib/zipint.h
+++ b/ext/zip/lib/zipint.h
@@ -213,13 +213,14 @@ extern const int _zip_err_type[];
 
 int _zip_cdir_compute_crc(struct zip *, uLong *);
 void _zip_cdir_free(struct zip_cdir *);
+int _zip_cdir_grow(struct zip_cdir *, int, struct zip_error *);
 struct zip_cdir *_zip_cdir_new(int, struct zip_error *);
 int _zip_cdir_write(struct zip_cdir *, FILE *, struct zip_error *);
 
 void _zip_dirent_finalize(struct zip_dirent *);
 void _zip_dirent_init(struct zip_dirent *);
-int _zip_dirent_read(struct zip_dirent *, FILE *,
-		     unsigned char **, unsigned int, int, struct zip_error *);
+int _zip_dirent_read(struct zip_dirent *, FILE *, unsigned char **,
+		     unsigned int *, int, struct zip_error *);
 void _zip_dirent_torrent_normalize(struct zip_dirent *);
 int _zip_dirent_write(struct zip_dirent *, FILE *, int, struct zip_error *);
 
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index ab2c4e7..c2d563f 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_zip.c 276389 2009-02-24 23:55:14Z iliaa $ */
+/* $Id: php_zip.c 294817 2010-02-09 17:51:39Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -182,7 +182,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
 			len = spprintf(&file_dirname_fullpath, 0, "%s/%s", dest, file_dirname);
 		}
 
-		php_basename(path_cleaned, path_cleaned_len, NULL, 0, &file_basename, (unsigned int *)&file_basename_len TSRMLS_CC);
+		php_basename(path_cleaned, path_cleaned_len, NULL, 0, &file_basename, (size_t *)&file_basename_len TSRMLS_CC);
 
 		if (OPENBASEDIR_CHECKPATH(file_dirname_fullpath)) {
 			efree(file_dirname_fullpath);
@@ -1637,7 +1637,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
 				file = Z_STRVAL_PP(zval_file);
 				if (remove_all_path) {
 					php_basename(Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file), NULL, 0,
-									&basename, (unsigned int *)&file_stripped_len TSRMLS_CC);
+									&basename, (size_t *)&file_stripped_len TSRMLS_CC);
 					file_stripped = basename;
 				} else if (remove_path && strstr(Z_STRVAL_PP(zval_file), remove_path) != NULL) {
 					file_stripped = Z_STRVAL_PP(zval_file) + remove_path_len + 1;
@@ -2674,7 +2674,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 276389 2009-02-24 23:55:14Z iliaa $");
+	php_info_print_table_row(2, "Extension Version","$Id: php_zip.c 294817 2010-02-09 17:51:39Z 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/php_zip.h b/ext/zip/php_zip.h
index e75c118..92374b0 100644
--- a/ext/zip/php_zip.h
+++ b/ext/zip/php_zip.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_zip.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_zip.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_ZIP_H
 #define PHP_ZIP_H
diff --git a/ext/zip/tests/bug47667.phpt b/ext/zip/tests/bug47667.phpt
index d0a4566..cdbf604 100644
--- a/ext/zip/tests/bug47667.phpt
+++ b/ext/zip/tests/bug47667.phpt
@@ -2,7 +2,7 @@
 Bug #47667 (ZipArchive::OVERWRITE seems to have no effect)
 --SKIPIF--
 <?php
-/* $Id: bug47667.phpt 277253 2009-03-16 10:19:43Z mkoppanen $ */
+/* $Id: bug47667.phpt 294522 2010-02-04 10:09:25Z pajoye $ */
 if(!extension_loaded('zip')) die('skip');
 ?>
 --FILE--
@@ -33,6 +33,7 @@ if ($zip->open($filename, ZipArchive::CREATE) !== true) {
 }
 
 echo "files: " , $zip->numFiles;
+$zip->close();
 
 unlink($filename);
 
diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h
index a427132..adb2f6e 100644
--- a/ext/zlib/php_zlib.h
+++ b/ext/zlib/php_zlib.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_zlib.h 286751 2009-08-03 18:15:30Z jani $ */
+/* $Id: php_zlib.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_ZLIB_H
 #define PHP_ZLIB_H
diff --git a/ext/zlib/tests/bug_40189.phpt b/ext/zlib/tests/bug_40189.phpt
index c4ce13a..aedf061 100644
--- a/ext/zlib/tests/bug_40189.phpt
+++ b/ext/zlib/tests/bug_40189.phpt
@@ -23,5 +23,5 @@ var_dump(file_get_contents(dirname(__FILE__) . '/test.other'));
 ?>
 --EXPECT--
 string(40) "AwCFRi98wqppK23l2/7kIY8AlyEdAgAAAEdCTUI="
-bool(false)
+int(0)
 string(0) ""
diff --git a/ext/zlib/tests/gzencode_variation1-win32.phpt b/ext/zlib/tests/gzencode_variation1-win32.phpt
new file mode 100644
index 0000000..efb223b
--- /dev/null
+++ b/ext/zlib/tests/gzencode_variation1-win32.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test gzencode() function : variation
+--SKIPIF--
+<?php 
+
+if( substr(PHP_OS, 0, 3) != "WIN" ) {
+  die("skip only for Windows");
+}
+
+if (!extension_loaded("zlib")) {
+	print "skip - ZLIB extension not loaded"; 
+}	 
+?> 
+--FILE--
+<?php
+/* Prototype  : string gzencode  ( string $data  [, int $level  [, int $encoding_mode  ]] )
+ * Description: Gzip-compress a string 
+ * Source code: ext/zlib/zlib.c
+ * Alias to functions: 
+ */
+
+include(dirname(__FILE__) . '/data.inc');
+
+echo "*** Testing gzencode() : variation ***\n";
+
+echo "\n-- Testing multiple compression --\n";
+$output = gzencode($data);
+var_dump(bin2hex(gzencode($output)));
+
+?>
+===Done===
+--EXPECT--
+*** Testing gzencode() : variation ***
+
+-- Testing multiple compression --
+string(3658) "1f8b080000000000000b010e07f1f81f8b080000000000000b6d574d6fe4c80dbdeb57d4ad2f3dfe01eb83e1ec22980e309b4562c067b64449159754dafab0b6e7d7e73d96da1e4c72184c4b2ab2c8f7c847fa25baabba98dc1a8b2b7c38bb324b713ee37f757f56cdc5c7f5b17b9d152f923b157c5ae335e0b75fedd0e2d781c6b98ea3a6ee05affe1dfc3a6527f8f09c52dcb38ba38bb5249934d6ecfe1e53a9ab76ff4c342cf2a64ed2028349fc9a8b139755685352acb82b9fbb67f8bade5cdcb698e1fcec94b7ceba3cb897e806cfc8114350dd1ebbdfa35b62d2478b0056d23ed809b9b95d696d91ce2aa97c911e3fa539c43f84c887554a4d125c9e63ff96711cc08c0866263cb37a0bbe2122ae8f6baecb2284abfb4ddf916db8354cddeef37c1afe5fa02fc7afb3db34f5b3acbdf2eb905490d8f38d7468d253a323d5ebb903760d7944d3b2024e834a99ddce77669bdd823cfbb8e899d4ad4c799677452e6029e80023a03b2374005590641f7d3877df2ad09f3c0e82a54d6a5644fd63049a37ed4bc362016fd9f51264f1e5c630727421ae930b7ed416e93e47b7c71a400390361ffbecb7561bb98f69b5da289e91becc27f08b3b724cb8704f9144d366431d0cb870c56b205deaa2e17636063761a911039fb7e4bf9f06c4f0aecd2ec80e8b41831ca7515e31286166458ea3ef71f2ce7cde2ae269c96d60525724a9c9170b713ed5750758f3cd2a361fc8b288fc92358ce884692e8ea0fe59bd969a0da2eed5831b715749eaae7178f3ebd30fb88c92105f367cce2c882955dc6bf8eca0d5d57540b3092894743ba0fd5b2dad021836191f1afc0bba14dde1642cb0b1aa6879c38907dcefa0720082b801bec61417469219175267dfa047df35b0bd1332001c28cdfafd3bcabe91e74368cdd8d8478e494c190e7ee90c67f2bde288e68ab6b15e883c995be4f8feb6c6dda4278e4f38578ddbdc7be36788daf0c3cb1d1819c73822f7000a0d1813fa94153b572315e51343b536bc64977dff163cebfd8418773261f524017e251fccc60ae29a5770ae097594d52e9c1229d87ce967a36401c46b69945afb249d101c9d420ffa9a123e232c20e76467d5d169202a2dd4c582949e013e745df7958d4b0cc4fd4377a737cd4feea7974070000f314d423e0634cb9a618fdf5dc64fd422181fd59c9230c9f6f9d18dc8fc23e9cccbc7188733b04aa57de83ebea0be3633cff5fa1ff83269be7f44f5a8d84550cc703255fd345dd402034d0b3e11a73ec6e3d4a77f4f685b614329f1b3132ae7af33d02e1e55e291fa6574b758d1f0200e7423dbc852211818043a7c9ce80aa9d59fce0401959f5ea2cf71fde90824f8c9192dbe9d329db143794675ddcf257dd7755273b67340414e3ccad12e3f661f8aad9cf9957dc1275d10a51d3934fa81e68dc6768fb8ee23e373936c8e13feab8b0f50d227f7af76f561fb0950f3d099bbc316c3892a42fb36806d8660e800fa4f43fd4b962d2097d71933a54b77ff948677848eb17bb3a88b621682cfb3bbb49cf42fed6b3944124ad8358ca688aa44dd5f2144c7c9ab16f25b9aca9654ef357ec9ad55c40d324d6cc3d9e3920b863c231d31a95d937fb5520f9c816c79b7dcecc593fb9593cc05a51ebb1eeddd5b49eb437769738d0f64adc579d372b8b7f7c0208487ee3915ebf5766e148ebd77cf4e01f3ec285047011e55838968b6494d517fe29224777b24dd3ddf933101695b102e87db805eef291b74dcfd91628fb2a53f93dbd2968ef2e598746c9204f89fba1f0246fc671610a0591806e46a1346f77c40d910a47c5e20ffb23f003c04b648327a4ed98032c1965bd35bb0044f5344248f56fdb99aa61d6451d68e33489a83bffbe6573541b2da5f64681ea12090f778b2075374778810f73965fa3626a9d41f4df2f83f7c34658cec921b5a9bde49dd5007ec882b02adc514f81aa85898b5cc98e1b137733c0a8789b7f5648d2d231b80bf74978f25d61ce08a8abd11801fd8f995e066676307192ff7641f1cc6e0dee68565b8b22ac3889cd067bf732754a6b270af1044c6a8776811a4f6d8bd0477a9f516064201b920b92d7cd4dc7eee13e6b3eb3528a82f9abb3f388ebe6a8f871393461b73816ec54c99d604174bc5a6801de13908f86aea6a7d0fea107d682bcf1ec348b83872e6b8a316ecd02eb8f8dc86a609bf59a2dd03f1dfa4079436d55e24617be1a2854d008b2b2b1705e2078a7f3946318df1c24f6bf70d4b456eca286ec2b585b28262cc048a098c3e2d5f325a92bb36f691afdc14c822da1b116c9c1c07bb362eb0a04b78834c812134230ebf2044ac2e3c0e3ad00f848dc5010f3bf917ec2fc700b7bf26dacea8440620e04f90f4d97d6dd77cfde8a05c7d3930f1e5811fb8ec5c70964dcc8187ec90e32fdd6b64eec7586413b7d55bed65c4cce39a9b6c15e70e9da94e53fc904e6286f01f5b5562c94211befbc23507e01b2a3865e2f45b5d7b591f290087a5605b82495b4e393f31aa5b37211ec40241a746d903c5eebf117a4d3ddb0d000030e1f1820e070000"
+===Done===
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 8fe3142..4d1b30a 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: zlib.c 287423 2009-08-17 17:30:32Z jani $ */
+/* $Id: zlib.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1046,16 +1046,23 @@ static void php_gzip_output_handler(char *output, uint output_len, char **handle
 		do_start = (mode & PHP_OUTPUT_HANDLER_START ? 1 : 0);
 		do_end = (mode & PHP_OUTPUT_HANDLER_END ? 1 : 0);
 
-		if (do_start && !SG(headers_sent) && !SG(request_info).no_headers) {
-			switch (ZLIBG(compression_coding)) {
-				case CODING_GZIP:
-					sapi_add_header_ex(ZEND_STRL("Content-Encoding: gzip"), 1, 1 TSRMLS_CC);
-					break;
-				case CODING_DEFLATE:
-					sapi_add_header_ex(ZEND_STRL("Content-Encoding: deflate"), 1, 1 TSRMLS_CC);
-					break;
+		if (do_start) {
+			if (!SG(headers_sent) && !SG(request_info).no_headers) {
+				switch (ZLIBG(compression_coding)) {
+					case CODING_GZIP:
+						sapi_add_header_ex(ZEND_STRL("Content-Encoding: gzip"), 1, 1 TSRMLS_CC);
+						break;
+					case CODING_DEFLATE:
+						sapi_add_header_ex(ZEND_STRL("Content-Encoding: deflate"), 1, 1 TSRMLS_CC);
+						break;
+				}
+				sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC);
+			} else {
+				/* Disable compression if headers can not be set (Fix for bug #49816) */
+				ZLIBG(output_compression) = 0;
+				*handled_output = NULL;
+				return;
 			}
-			sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC);
 		}
 
 		if (php_deflate_string(output, output_len, handled_output, handled_output_len, do_start, do_end TSRMLS_CC) != SUCCESS) {
diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c
index 45b66a7..bda2d95 100644
--- a/ext/zlib/zlib_filter.c
+++ b/ext/zlib/zlib_filter.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zlib_filter.c 287926 2009-08-31 21:18:55Z jani $ */
+/* $Id: zlib_filter.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_zlib.h"
diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c
index 4656379..66ab30e 100644
--- a/ext/zlib/zlib_fopen_wrapper.c
+++ b/ext/zlib/zlib_fopen_wrapper.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: zlib_fopen_wrapper.c 274034 2009-01-20 15:41:23Z felipe $ */
+/* $Id: zlib_fopen_wrapper.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define _GNU_SOURCE
 
diff --git a/ltmain.sh b/ltmain.sh
index 9e71d27..7e2240e 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -1,8 +1,8 @@
 # ltmain.sh - Provide generalized library-building support services.
 # NOTE: Changing this file will not affect anything until you rerun configure.
 #
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
-# Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
+# 2007, 2008  Free Software Foundation, Inc.
 # Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 #
 # This program is free software; you can redistribute it and/or modify
@@ -43,14 +43,22 @@ EXIT_FAILURE=1
 
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION=1.5.20
-TIMESTAMP=" (1.1220.2.287 2005/08/31 18:54:15)"
-
-# See if we are running on zsh, and set the options which allow our
-# commands through without removal of \ escapes.
-if test -n "${ZSH_VERSION+set}" ; then
+VERSION=1.5.26
+TIMESTAMP=" (1.1220.2.492 2008/01/30 06:40:56)"
+
+# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
 fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
 
 # Check that we have a working $echo.
 if test "X$1" = X--no-reexec; then
@@ -105,11 +113,19 @@ esac
 # These must not be set unconditionally because not all systems understand
 # e.g. LANG=C (notably SCO).
 # We save the old values to restore during execute mode.
-if test "${LC_ALL+set}" = set; then
-  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
-fi
-if test "${LANG+set}" = set; then
-  save_LANG="$LANG"; LANG=C; export LANG
+lt_env=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+  eval "if test \"\${$lt_var+set}\" = set; then
+	  save_$lt_var=\$$lt_var
+	  lt_env=\"$lt_var=\$$lt_var \$lt_env\"
+	  $lt_var=C
+	  export $lt_var
+	fi"
+done
+
+if test -n "$lt_env"; then
+  lt_env="env $lt_env"
 fi
 
 # Make sure IFS has a sensible default
@@ -132,13 +148,54 @@ run=
 show="$echo"
 show_help=
 execute_dlfiles=
+duplicate_deps=no
+preserve_args=
 lo2o="s/\\.lo\$/.${objext}/"
 o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
 
 #####################################
 # Shell function definitions:
 # This seems to be the best place for them
 
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible.  If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+    my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+    if test "$run" = ":"; then
+      # Return a directory name, but don't create it in dry-run mode
+      my_tmpdir="${my_template}-$$"
+    else
+
+      # If mktemp works, use that first and foremost
+      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+      if test ! -d "$my_tmpdir"; then
+	# Failing that, at least try and use $RANDOM to avoid a race
+	my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+	save_mktempdir_umask=`umask`
+	umask 0077
+	$mkdir "$my_tmpdir"
+	umask $save_mktempdir_umask
+      fi
+
+      # If we're not in dry-run mode, bomb out on failure
+      test -d "$my_tmpdir" || {
+        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
+	exit $EXIT_FAILURE
+      }
+    fi
+
+    $echo "X$my_tmpdir" | $Xsed
+}
+
+
 # func_win32_libid arg
 # return the library type of file 'arg'
 #
@@ -157,12 +214,17 @@ func_win32_libid ()
     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
       $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
       win32_nmres=`eval $NM -f posix -A $1 | \
-	sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
-      if test "X$win32_nmres" = "Ximport" ; then
-        win32_libid_type="x86 archive import"
-      else
-        win32_libid_type="x86 archive static"
-      fi
+	$SED -n -e '1,100{
+		/ I /{
+			s,.*,import,
+			p
+			q
+			}
+		}'`
+      case $win32_nmres in
+      import*)  win32_libid_type="x86 archive import";;
+      *)        win32_libid_type="x86 archive static";;
+      esac
     fi
     ;;
   *DLL*)
@@ -289,15 +351,25 @@ func_extract_archives ()
 	*) my_xabs=`pwd`"/$my_xlib" ;;
       esac
       my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
-      my_xdir="$my_gentop/$my_xlib"
+      my_xlib_u=$my_xlib
+      while :; do
+        case " $extracted_archives " in
+	*" $my_xlib_u "*)
+	  extracted_serial=`expr $extracted_serial + 1`
+	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
+	*) break ;;
+	esac
+      done
+      extracted_archives="$extracted_archives $my_xlib_u"
+      my_xdir="$my_gentop/$my_xlib_u"
 
       $show "${rm}r $my_xdir"
       $run ${rm}r "$my_xdir"
       $show "$mkdir $my_xdir"
       $run $mkdir "$my_xdir"
-      status=$?
-      if test "$status" -ne 0 && test ! -d "$my_xdir"; then
-	exit $status
+      exit_status=$?
+      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
+	exit $exit_status
       fi
       case $host in
       *-darwin*)
@@ -352,6 +424,8 @@ func_extract_archives ()
 # Darwin sucks
 eval std_shrext=\"$shrext_cmds\"
 
+disable_libs=no
+
 # Parse our command line options once, thoroughly.
 while test "$#" -gt 0
 do
@@ -414,11 +488,12 @@ do
     ;;
 
   --version)
-    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
-    $echo
-    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
-    $echo "This is free software; see the source for copying conditions.  There is NO"
-    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+    echo "\
+$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
+
+Copyright (C) 2008  Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
     exit $?
     ;;
 
@@ -468,7 +543,11 @@ do
     preserve_args="$preserve_args $arg"
     ;;
 
-  --tag) prevopt="--tag" prev=tag ;;
+  --tag)
+    prevopt="--tag"
+    prev=tag
+    preserve_args="$preserve_args --tag"
+    ;;
   --tag=*)
     set tag "$optarg" ${1+"$@"}
     shift
@@ -500,6 +579,18 @@ if test -n "$prevopt"; then
   exit $EXIT_FAILURE
 fi
 
+case $disable_libs in
+no) 
+  ;;
+shared)
+  build_libtool_libs=no
+  build_old_libs=yes
+  ;;
+static)
+  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+  ;;
+esac
+
 # If this variable is set in any of the actions, the command in it
 # will be execed at the end.  This prevents here-documents from being
 # left over by shells.
@@ -699,9 +790,11 @@ if test -z "$show_help"; then
     *.class) xform=class ;;
     *.cpp) xform=cpp ;;
     *.cxx) xform=cxx ;;
-    *.f90) xform=f90 ;;
+    *.[fF][09]?) xform=[fF][09]. ;;
     *.for) xform=for ;;
     *.java) xform=java ;;
+    *.obj) xform=obj ;;
+    *.sx) xform=sx ;;
     esac
 
     libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
@@ -856,21 +949,22 @@ EOF
       if test ! -d "${xdir}$objdir"; then
 	$show "$mkdir ${xdir}$objdir"
 	$run $mkdir ${xdir}$objdir
-	status=$?
-	if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
-	  exit $status
+	exit_status=$?
+	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
+	  exit $exit_status
 	fi
       fi
 
       if test -z "$output_obj"; then
+	$run $rm "$lobj"
 	# Place PIC objects in $objdir
 	command="$command -o $lobj"
+      else
+	$run $rm "$lobj" "$output_obj"
       fi
 
-      $run $rm "$lobj" "$output_obj"
-
       $show "$command"
-      if $run eval "$command"; then :
+      if $run eval $lt_env "$command"; then :
       else
 	test -n "$output_obj" && $run $rm $removelist
 	exit $EXIT_FAILURE
@@ -942,7 +1036,7 @@ EOF
       command="$command$suppress_output"
       $run $rm "$obj" "$output_obj"
       $show "$command"
-      if $run eval "$command"; then :
+      if $run eval $lt_env "$command"; then :
       else
 	$run $rm $removelist
 	exit $EXIT_FAILURE
@@ -1061,6 +1155,7 @@ EOF
     no_install=no
     objs=
     non_pic_objects=
+    notinst_path= # paths that contain not-installed libtool libraries
     precious_files_regex=
     prefer_static_libs=no
     preload=no
@@ -1074,6 +1169,7 @@ EOF
     thread_safe=no
     vinfo=
     vinfo_number=no
+    single_module="${wl}-single_module"
 
     func_infer_tag $base_compile
 
@@ -1081,22 +1177,32 @@ EOF
     for arg
     do
       case $arg in
-      -all-static | -static)
-	if test "X$arg" = "X-all-static"; then
+      -all-static | -static | -static-libtool-libs)
+	case $arg in
+	-all-static)
 	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
 	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
 	  fi
 	  if test -n "$link_static_flag"; then
 	    dlopen_self=$dlopen_self_static
 	  fi
-	else
+	  prefer_static_libs=yes
+	  ;;
+	-static)
 	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
 	    dlopen_self=$dlopen_self_static
 	  fi
-	fi
+	  prefer_static_libs=built
+	  ;;
+	-static-libtool-libs)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=yes
+	  ;;
+	esac
 	build_libtool_libs=no
 	build_old_libs=yes
-	prefer_static_libs=yes
 	break
 	;;
       esac
@@ -1271,6 +1377,11 @@ EOF
 		  if test -z "$pic_object" || test "$pic_object" = none ; then
 		    arg="$non_pic_object"
 		  fi
+		else
+		  # If the PIC object exists, use it instead.
+		  # $xdir was prepended to $pic_object above.
+		  non_pic_object="$pic_object"
+		  non_pic_objects="$non_pic_objects $non_pic_object"
 		fi
 	      else
 		# Only an error if not doing a dry-run.
@@ -1354,8 +1465,8 @@ EOF
 	  prev=
 	  continue
 	  ;;
-        darwin_framework)
-	  compiler_flags="$compiler_flags $arg"
+	darwin_framework|darwin_framework_skip)
+	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
 	  compile_command="$compile_command $arg"
 	  finalize_command="$finalize_command $arg"
 	  prev=
@@ -1419,13 +1530,17 @@ EOF
 	continue
 	;;
 
-      -framework|-arch)
-        prev=darwin_framework
-        compiler_flags="$compiler_flags $arg"
+      -framework|-arch|-isysroot)
+	case " $CC " in
+	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
+		prev=darwin_framework_skip ;;
+	  *) compiler_flags="$compiler_flags $arg"
+	     prev=darwin_framework ;;
+	esac
 	compile_command="$compile_command $arg"
 	finalize_command="$finalize_command $arg"
-        continue
-        ;;
+	continue
+	;;
 
       -inst-prefix-dir)
 	prev=inst_prefix
@@ -1453,7 +1568,8 @@ EOF
 	  absdir=`cd "$dir" && pwd`
 	  if test -z "$absdir"; then
 	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
-	    exit $EXIT_FAILURE
+	    absdir="$dir"
+	    notinst_path="$notinst_path $dir"
 	  fi
 	  dir="$absdir"
 	  ;;
@@ -1467,10 +1583,15 @@ EOF
 	esac
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$dir:"*) ;;
 	  *) dllsearchpath="$dllsearchpath:$dir";;
 	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
 	  ;;
 	esac
 	continue
@@ -1479,11 +1600,11 @@ EOF
       -l*)
 	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
 	  case $host in
-	  *-*-cygwin* | *-*-pw32* | *-*-beos*)
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
 	    # These systems don't actually have a C or math library (as such)
 	    continue
 	    ;;
-	  *-*-mingw* | *-*-os2*)
+	  *-*-os2*)
 	    # These systems don't actually have a C library (as such)
 	    test "X$arg" = "X-lc" && continue
 	    ;;
@@ -1495,6 +1616,15 @@ EOF
 	    # Rhapsody C and math libraries are in the System framework
 	    deplibs="$deplibs -framework System"
 	    continue
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    test "X$arg" = "X-lc" && continue
+	    ;;
 	  esac
 	elif test "X$arg" = "X-lc_r"; then
 	 case $host in
@@ -1518,13 +1648,18 @@ EOF
 	continue
 	;;
 
-     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
+     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
 	compiler_flags="$compiler_flags $arg"
 	compile_command="$compile_command $arg"
 	finalize_command="$finalize_command $arg"
 	continue
 	;;
 
+      -multi_module)
+	single_module="${wl}-multi_module"
+	continue
+	;;
+
       -module)
 	module=yes
 	continue
@@ -1536,7 +1671,13 @@ EOF
       # +DA*, +DD* enable 64-bit mode on the HP compiler
       # -q* pass through compiler args for the IBM compiler
       # -m* pass through architecture-specific compiler args for GCC
-      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*)
+      # -m*, -t[45]*, -txscale* pass through architecture-specific
+      # compiler args for GCC
+      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
+      # -F/path gives path to uninstalled frameworks, gcc on darwin
+      # @file GCC response files
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
 
 	# Unknown arguments in both finalize_command and compile_command need
 	# to be aesthetically quoted because they are evaled later.
@@ -1548,9 +1689,7 @@ EOF
 	esac
         compile_command="$compile_command $arg"
         finalize_command="$finalize_command $arg"
-        if test "$with_gcc" = "yes" ; then
-          compiler_flags="$compiler_flags $arg"
-        fi
+        compiler_flags="$compiler_flags $arg"
         continue
         ;;
 
@@ -1566,9 +1705,9 @@ EOF
 
       -no-install)
 	case $host in
-	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
 	  # The PATH hackery in wrapper scripts is required on Windows
-	  # in order for the loader to find any dlls it needs.
+	  # and Darwin in order for the loader to find any dlls it needs.
 	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
 	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
 	  fast_install=no
@@ -1627,7 +1766,7 @@ EOF
 	continue
 	;;
 
-      -static)
+      -static | -static-libtool-libs)
 	# The effects of -static are defined in a previous loop.
 	# We used to do the same as -all-static on platforms that
 	# didn't have a PIC flag, but the assumption that the effects
@@ -1788,6 +1927,11 @@ EOF
 	    if test -z "$pic_object" || test "$pic_object" = none ; then
 	      arg="$non_pic_object"
 	    fi
+	  else
+	    # If the PIC object exists, use it instead.
+	    # $xdir was prepended to $pic_object above.
+	    non_pic_object="$pic_object"
+	    non_pic_objects="$non_pic_objects $non_pic_object"
 	  fi
 	else
 	  # Only an error if not doing a dry-run.
@@ -1893,9 +2037,9 @@ EOF
     if test ! -d "$output_objdir"; then
       $show "$mkdir $output_objdir"
       $run $mkdir $output_objdir
-      status=$?
-      if test "$status" -ne 0 && test ! -d "$output_objdir"; then
-	exit $status
+      exit_status=$?
+      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
+	exit $exit_status
       fi
     fi
 
@@ -1958,7 +2102,6 @@ EOF
     newlib_search_path=
     need_relink=no # whether we're linking any uninstalled libtool libraries
     notinst_deplibs= # not-installed libtool libraries
-    notinst_path= # paths that contain not-installed libtool libraries
     case $linkmode in
     lib)
 	passes="conv link"
@@ -2005,7 +2148,7 @@ EOF
 	lib=
 	found=no
 	case $deplib in
-	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
+	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
 	  if test "$linkmode,$pass" = "prog,link"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
@@ -2020,7 +2163,12 @@ EOF
 	    continue
 	  fi
 	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
-	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
+	  if test "$linkmode" = lib; then
+	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+	  else
+	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+	  fi
+	  for searchdir in $searchdirs; do
 	    for search_ext in .la $std_shrext .so .a; do
 	      # Search the libtool library
 	      lib="$searchdir/lib${name}${search_ext}"
@@ -2194,7 +2342,7 @@ EOF
 	esac # case $deplib
 	if test "$found" = yes || test -f "$lib"; then :
 	else
-	  $echo "$modename: cannot find the library \`$lib'" 1>&2
+	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
 	  exit $EXIT_FAILURE
 	fi
 
@@ -2401,7 +2549,9 @@ EOF
 
 	if test "$linkmode,$pass" = "prog,link"; then
 	  if test -n "$library_names" &&
-	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+	     { { test "$prefer_static_libs" = no ||
+		 test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	       test -z "$old_library"; }; then
 	    # We need to hardcode the library path
 	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
 	      # Make sure the rpath contains only unique directories.
@@ -2445,8 +2595,12 @@ EOF
 	fi
 
 	link_static=no # Whether the deplib will be linked statically
+	use_static_libs=$prefer_static_libs
+	if test "$use_static_libs" = built && test "$installed" = yes ; then
+	  use_static_libs=no
+	fi
 	if test -n "$library_names" &&
-	   { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
 	  if test "$installed" = no; then
 	    notinst_deplibs="$notinst_deplibs $lib"
 	    need_relink=yes
@@ -2559,11 +2713,15 @@ EOF
 	      if test "$hardcode_direct" = no; then
 		add="$dir/$linklib"
 		case $host in
-		  *-*-sco3.2v5* ) add_dir="-L$dir" ;;
+		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+		    *-*-unixware7*) add_dir="-L$dir" ;;
 		  *-*-darwin* )
 		    # if the lib is a module then we can not link against
 		    # it, someone is ignoring the new warnings I added
-		    if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
+		    if /usr/bin/file -L $add 2> /dev/null |
+                      $EGREP ": [^:]* bundle" >/dev/null ; then
 		      $echo "** Warning, lib $linklib is a module, not a shared library"
 		      if test -z "$old_library" ; then
 		        $echo
@@ -2806,12 +2964,18 @@ EOF
 		  # we do not want to link against static libs,
 		  # but need to link against shared
 		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  eval deplibdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
 		  if test -n "$deplibrary_names" ; then
 		    for tmp in $deplibrary_names ; do
 		      depdepl=$tmp
 		    done
-		    if test -f "$path/$depdepl" ; then
+		    if test -f "$deplibdir/$depdepl" ; then
+		      depdepl="$deplibdir/$depdepl"
+	      	    elif test -f "$path/$depdepl" ; then
 		      depdepl="$path/$depdepl"
+		    else
+		      # Can't find it, oh well...
+		      depdepl=
 		    fi
 		    # do not add paths which are already there
 		    case " $newlib_search_path " in
@@ -2959,9 +3123,10 @@ EOF
 
     case $linkmode in
     oldlib)
-      if test -n "$deplibs"; then
-	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
-      fi
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 ;;
+      esac
 
       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
 	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
@@ -3089,7 +3254,7 @@ EOF
 	  # which has an extra 1 added just for fun
 	  #
 	  case $version_type in
-	  darwin|linux|osf|windows)
+	  darwin|linux|osf|windows|none)
 	    current=`expr $number_major + $number_minor`
 	    age="$number_minor"
 	    revision="$number_revision"
@@ -3100,9 +3265,10 @@ EOF
 	    age="0"
 	    ;;
 	  irix|nonstopux)
-	    current=`expr $number_major + $number_minor - 1`
+	    current=`expr $number_major + $number_minor`
 	    age="$number_minor"
 	    revision="$number_minor"
+	    lt_irix_increment=no
 	    ;;
 	  esac
 	  ;;
@@ -3161,7 +3327,8 @@ EOF
 	  versuffix="$major.$age.$revision"
 	  # Darwin ld doesn't like 0 for these options...
 	  minor_current=`expr $current + 1`
-	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
 	  ;;
 
 	freebsd-aout)
@@ -3175,8 +3342,11 @@ EOF
 	  ;;
 
 	irix | nonstopux)
-	  major=`expr $current - $age + 1`
-
+	  if test "X$lt_irix_increment" = "Xno"; then
+	    major=`expr $current - $age`
+	  else
+	    major=`expr $current - $age + 1`
+	  fi
 	  case $version_type in
 	    nonstopux) verstring_prefix=nonstopux ;;
 	    *)         verstring_prefix=sgi ;;
@@ -3313,11 +3483,11 @@ EOF
       fi
 
       # Eliminate all temporary directories.
-      for path in $notinst_path; do
-	lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
-	deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
-	dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
-      done
+      #for path in $notinst_path; do
+      #	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
+      #	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
+      #	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
+      #done
 
       if test -n "$xrpath"; then
 	# If the user specified any rpath flags, then add them.
@@ -3369,7 +3539,12 @@ EOF
 	    ;;
 	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
 	    # Do not include libc due to us having libc/libc_r.
-	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
 	    ;;
  	  *)
 	    # Add libc to deplibs on all other systems if necessary.
@@ -3413,13 +3588,12 @@ EOF
 	  int main() { return 0; }
 EOF
 	  $rm conftest
-	  $LTCC -o conftest conftest.c $deplibs
-	  if test "$?" -eq 0 ; then
+	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
 	    ldd_output=`ldd conftest`
 	    for i in $deplibs; do
 	      name=`expr $i : '-l\(.*\)'`
 	      # If $name is empty we are operating on a -L argument.
-              if test "$name" != "" && test "$name" -ne "0"; then
+              if test "$name" != "" && test "$name" != "0"; then
 		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
 		  case " $predeps $postdeps " in
 		  *" $i "*)
@@ -3458,9 +3632,7 @@ EOF
 	      # If $name is empty we are operating on a -L argument.
               if test "$name" != "" && test "$name" != "0"; then
 		$rm conftest
-		$LTCC -o conftest conftest.c $i
-		# Did it work?
-		if test "$?" -eq 0 ; then
+		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
 		  ldd_output=`ldd conftest`
 		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
 		    case " $predeps $postdeps " in
@@ -3492,7 +3664,7 @@ EOF
 		  droppeddeps=yes
 		  $echo
 		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
-		  $echo "***  make it link in!  You will probably need to install it or some"
+		  $echo "*** make it link in!  You will probably need to install it or some"
 		  $echo "*** library that it depends on before this library will be fully"
 		  $echo "*** functional.  Installing it before continuing would be even better."
 		fi
@@ -3705,6 +3877,35 @@ EOF
 	deplibs=$newdeplibs
       fi
 
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      deplibs="$new_libs"
+
+
       # All the library-specific variables (install_libdir is set above).
       library_names=
       old_library=
@@ -3749,7 +3950,10 @@ EOF
 	     test -n "$hardcode_libdirs"; then
 	    libdir="$hardcode_libdirs"
 	    if test -n "$hardcode_libdir_flag_spec_ld"; then
-	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+	      case $archive_cmds in
+	      *\$LD*) eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" ;;
+	      *)      eval dep_rpath=\"$hardcode_libdir_flag_spec\" ;;
+	      esac
 	    else
 	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
 	    fi
@@ -3788,6 +3992,7 @@ EOF
 	fi
 
 	lib="$output_objdir/$realname"
+	linknames=
 	for link
 	do
 	  linknames="$linknames $link"
@@ -4058,9 +4263,10 @@ EOF
       ;;
 
     obj)
-      if test -n "$deplibs"; then
-	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
-      fi
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 ;;
+      esac
 
       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
 	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
@@ -4107,12 +4313,14 @@ EOF
       reload_conv_objs=
       gentop=
       # reload_cmds runs $LD directly, so let us get rid of
-      # -Wl from whole_archive_flag_spec
+      # -Wl from whole_archive_flag_spec and hope we can get by with
+      # turning comma into space..
       wl=
 
       if test -n "$convenience"; then
 	if test -n "$whole_archive_flag_spec"; then
-	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
+	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+	  reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
 	else
 	  gentop="$output_objdir/${obj}x"
 	  generated="$generated $gentop"
@@ -4219,6 +4427,35 @@ EOF
         ;;
       esac
 
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $compile_deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $compile_deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      compile_deplibs="$new_libs"
+
+
       compile_command="$compile_command $compile_deplibs"
       finalize_command="$finalize_command $finalize_deplibs"
 
@@ -4263,10 +4500,15 @@ EOF
 	fi
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$libdir:"*) ;;
 	  *) dllsearchpath="$dllsearchpath:$libdir";;
 	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
 	  ;;
 	esac
       done
@@ -4383,10 +4625,22 @@ extern \"C\" {
 	      export_symbols="$output_objdir/$outputname.exp"
 	      $run $rm $export_symbols
 	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+              case $host in
+              *cygwin* | *mingw* )
+	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+                ;;
+              esac
 	    else
-	      $run eval "${SED} -e 's/\([ ][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
 	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
 	      $run eval 'mv "$nlist"T "$nlist"'
+              case $host in
+              *cygwin* | *mingw* )
+	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+                ;;
+              esac
 	    fi
 	  fi
 
@@ -4503,16 +4757,29 @@ static const void *lt_preloaded_setup() {
 	  esac
 
 	  # Now compile the dynamic symbol file.
-	  $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
-	  $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
 
 	  # Clean up the generated files.
 	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
 	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
 
 	  # Transform the symbol file into the correct name.
-	  compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-	  finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+          case $host in
+          *cygwin* | *mingw* )
+            if test -f "$output_objdir/${outputname}.def" ; then
+              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
+              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
+            else
+              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
+              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
+             fi
+            ;;
+          * )
+            compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
+            finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
+            ;;
+          esac
 	  ;;
 	*)
 	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
@@ -4525,19 +4792,19 @@ static const void *lt_preloaded_setup() {
 	# really was required.
 
 	# Nullify the symbol file.
-	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
-	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
+	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
       fi
 
       if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
 	# Replace the output file specification.
-	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
 	link_command="$compile_command$compile_rpath"
 
 	# We have no uninstalled library dependencies, so finalize right now.
 	$show "$link_command"
 	$run eval "$link_command"
-	status=$?
+	exit_status=$?
 
 	# Delete the generated files.
 	if test -n "$dlsyms"; then
@@ -4545,7 +4812,7 @@ static const void *lt_preloaded_setup() {
 	  $run $rm "$output_objdir/${outputname}S.${objext}"
 	fi
 
-	exit $status
+	exit $exit_status
       fi
 
       if test -n "$shlibpath_var"; then
@@ -4618,7 +4885,7 @@ static const void *lt_preloaded_setup() {
 	if test "$fast_install" != no; then
 	  link_command="$finalize_var$compile_command$finalize_rpath"
 	  if test "$fast_install" = yes; then
-	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP`
 	  else
 	    # fast_install is set to needless
 	    relink_command=
@@ -4655,7 +4922,7 @@ static const void *lt_preloaded_setup() {
 	  fi
 	done
 	relink_command="(cd `pwd`; $relink_command)"
-	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+	relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
       fi
 
       # Quote $echo for shipping.
@@ -4685,10 +4952,12 @@ static const void *lt_preloaded_setup() {
 	esac
 	case $host in
 	  *cygwin* | *mingw* )
-	    cwrappersource=`$echo ${objdir}/lt-${outputname}.c`
-	    cwrapper=`$echo ${output}.exe`
-	    $rm $cwrappersource $cwrapper
-	    trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+            output_name=`basename $output`
+            output_path=`dirname $output`
+            cwrappersource="$output_path/$objdir/lt-$output_name.c"
+            cwrapper="$output_path/$output_name.exe"
+            $rm $cwrappersource $cwrapper
+            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
 
 	    cat > $cwrappersource <<EOF
 
@@ -4713,6 +4982,9 @@ EOF
 #include <malloc.h>
 #include <stdarg.h>
 #include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/stat.h>
 
 #if defined(PATH_MAX)
 # define LT_PATHMAX PATH_MAX
@@ -4723,15 +4995,19 @@ EOF
 #endif
 
 #ifndef DIR_SEPARATOR
-#define DIR_SEPARATOR '/'
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
 #endif
 
 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
   defined (__OS2__)
-#define HAVE_DOS_BASED_FILE_SYSTEM
-#ifndef DIR_SEPARATOR_2
-#define DIR_SEPARATOR_2 '\\'
-#endif
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# ifndef DIR_SEPARATOR_2
+#  define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+#  define PATH_SEPARATOR_2 ';'
+# endif
 #endif
 
 #ifndef DIR_SEPARATOR_2
@@ -4741,17 +5017,32 @@ EOF
         (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
 #endif /* DIR_SEPARATOR_2 */
 
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
 #define XFREE(stale) do { \
   if (stale) { free ((void *) stale); stale = 0; } \
 } while (0)
 
+/* -DDEBUG is fairly common in CFLAGS.  */
+#undef DEBUG
+#if defined DEBUGWRAPPER
+# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
+#else
+# define DEBUG(format, ...)
+#endif
+
 const char *program_name = NULL;
 
 void * xmalloc (size_t num);
 char * xstrdup (const char *string);
-char * basename (const char *name);
-char * fnqualify(const char *path);
+const char * base_name (const char *name);
+char * find_executable(const char *wrapper);
+int    check_executable(const char *path);
 char * strendzap(char *str, const char *pat);
 void lt_fatal (const char *message, ...);
 
@@ -4761,29 +5052,50 @@ main (int argc, char *argv[])
   char **newargz;
   int i;
 
-  program_name = (char *) xstrdup ((char *) basename (argv[0]));
+  program_name = (char *) xstrdup (base_name (argv[0]));
+  DEBUG("(main) argv[0]      : %s\n",argv[0]);
+  DEBUG("(main) program_name : %s\n",program_name);
   newargz = XMALLOC(char *, argc+2);
 EOF
 
-	    cat >> $cwrappersource <<EOF
-  newargz[0] = "$SHELL";
+            cat >> $cwrappersource <<EOF
+  newargz[0] = (char *) xstrdup("$SHELL");
 EOF
 
-	    cat >> $cwrappersource <<"EOF"
-  newargz[1] = fnqualify(argv[0]);
+            cat >> $cwrappersource <<"EOF"
+  newargz[1] = find_executable(argv[0]);
+  if (newargz[1] == NULL)
+    lt_fatal("Couldn't find %s", argv[0]);
+  DEBUG("(main) found exe at : %s\n",newargz[1]);
   /* we know the script has the same name, without the .exe */
   /* so make sure newargz[1] doesn't end in .exe */
   strendzap(newargz[1],".exe");
   for (i = 1; i < argc; i++)
     newargz[i+1] = xstrdup(argv[i]);
   newargz[argc+1] = NULL;
+
+  for (i=0; i<argc+1; i++)
+  {
+    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
+    ;
+  }
+
 EOF
 
-	    cat >> $cwrappersource <<EOF
+            case $host_os in
+              mingw*)
+                cat >> $cwrappersource <<EOF
+  execv("$SHELL",(char const **)newargz);
+EOF
+              ;;
+              *)
+                cat >> $cwrappersource <<EOF
   execv("$SHELL",newargz);
 EOF
+              ;;
+            esac
 
-	    cat >> $cwrappersource <<"EOF"
+            cat >> $cwrappersource <<"EOF"
   return 127;
 }
 
@@ -4804,48 +5116,148 @@ xstrdup (const char *string)
 ;
 }
 
-char *
-basename (const char *name)
+const char *
+base_name (const char *name)
 {
   const char *base;
 
 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
   /* Skip over the disk name in MSDOS pathnames. */
-  if (isalpha (name[0]) && name[1] == ':')
+  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
     name += 2;
 #endif
 
   for (base = name; *name; name++)
     if (IS_DIR_SEPARATOR (*name))
       base = name + 1;
-  return (char *) base;
+  return base;
 }
 
+int
+check_executable(const char * path)
+{
+  struct stat st;
+
+  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
+  if ((!path) || (!*path))
+    return 0;
+
+  if ((stat (path, &st) >= 0) &&
+      (
+        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
+#if defined (S_IXOTH)
+       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
+#endif
+#if defined (S_IXGRP)
+       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
+#endif
+       ((st.st_mode & S_IXUSR) == S_IXUSR))
+      )
+    return 1;
+  else
+    return 0;
+}
+
+/* Searches for the full path of the wrapper.  Returns
+   newly allocated full path name if found, NULL otherwise */
 char *
-fnqualify(const char *path)
+find_executable (const char* wrapper)
 {
-  size_t size;
-  char *p;
+  int has_slash = 0;
+  const char* p;
+  const char* p_next;
+  /* static buffer for getcwd */
   char tmp[LT_PATHMAX + 1];
+  int tmp_len;
+  char* concat_name;
+
+  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
 
-  assert(path != NULL);
+  if ((wrapper == NULL) || (*wrapper == '\0'))
+    return NULL;
 
-  /* Is it qualified already? */
+  /* Absolute path? */
 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  if (isalpha (path[0]) && path[1] == ':')
-    return xstrdup (path);
+  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
+  {
+    concat_name = xstrdup (wrapper);
+    if (check_executable(concat_name))
+      return concat_name;
+    XFREE(concat_name);
+  }
+  else
+  {
+#endif
+    if (IS_DIR_SEPARATOR (wrapper[0]))
+    {
+      concat_name = xstrdup (wrapper);
+      if (check_executable(concat_name))
+        return concat_name;
+      XFREE(concat_name);
+    }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  }
 #endif
-  if (IS_DIR_SEPARATOR (path[0]))
-    return xstrdup (path);
 
-  /* prepend the current directory */
-  /* doesn't handle '~' */
+  for (p = wrapper; *p; p++)
+    if (*p == '/')
+    {
+      has_slash = 1;
+      break;
+    }
+  if (!has_slash)
+  {
+    /* no slashes; search PATH */
+    const char* path = getenv ("PATH");
+    if (path != NULL)
+    {
+      for (p = path; *p; p = p_next)
+      {
+        const char* q;
+        size_t p_len;
+        for (q = p; *q; q++)
+          if (IS_PATH_SEPARATOR(*q))
+            break;
+        p_len = q - p;
+        p_next = (*q == '\0' ? q : q + 1);
+        if (p_len == 0)
+        {
+          /* empty path: current directory */
+          if (getcwd (tmp, LT_PATHMAX) == NULL)
+            lt_fatal ("getcwd failed");
+          tmp_len = strlen(tmp);
+          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
+          memcpy (concat_name, tmp, tmp_len);
+          concat_name[tmp_len] = '/';
+          strcpy (concat_name + tmp_len + 1, wrapper);
+        }
+        else
+        {
+          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
+          memcpy (concat_name, p, p_len);
+          concat_name[p_len] = '/';
+          strcpy (concat_name + p_len + 1, wrapper);
+        }
+        if (check_executable(concat_name))
+          return concat_name;
+        XFREE(concat_name);
+      }
+    }
+    /* not found in PATH; assume curdir */
+  }
+  /* Relative path | not found in path: prepend cwd */
   if (getcwd (tmp, LT_PATHMAX) == NULL)
     lt_fatal ("getcwd failed");
-  size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
-  p = XMALLOC(char, size);
-  sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
-  return p;
+  tmp_len = strlen(tmp);
+  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
+  memcpy (concat_name, tmp, tmp_len);
+  concat_name[tmp_len] = '/';
+  strcpy (concat_name + tmp_len + 1, wrapper);
+
+  if (check_executable(concat_name))
+    return concat_name;
+  XFREE(concat_name);
+  return NULL;
 }
 
 char *
@@ -4889,16 +5301,16 @@ lt_fatal (const char *message, ...)
   va_end (ap);
 }
 EOF
-	  # we should really use a build-platform specific compiler
-	  # here, but OTOH, the wrappers (shell script and this C one)
-	  # are only useful if you want to execute the "real" binary.
-	  # Since the "real" binary is built for $host, then this
-	  # wrapper might as well be built for $host, too.
-	  $run $LTCC -s -o $cwrapper $cwrappersource
-	  ;;
-	esac
-	$rm $output
-	trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
+          # we should really use a build-platform specific compiler
+          # here, but OTOH, the wrappers (shell script and this C one)
+          # are only useful if you want to execute the "real" binary.
+          # Since the "real" binary is built for $host, then this
+          # wrapper might as well be built for $host, too.
+          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
+          ;;
+        esac
+        $rm $output
+        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
 
 	$echo > $output "\
 #! $SHELL
@@ -4917,6 +5329,20 @@ EOF
 Xsed='${SED} -e 1s/^X//'
 sed_quote_subst='$sed_quote_subst'
 
+# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
@@ -5059,7 +5485,7 @@ else
 	  ;;
 	esac
 	$echo >> $output "\
-      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
+      \$echo \"\$0: cannot exec \$program \$*\"
       exit $EXIT_FAILURE
     fi
   else
@@ -5128,9 +5554,9 @@ fi\
 	    $run ${rm}r "$gentop"
 	    $show "$mkdir $gentop"
 	    $run $mkdir "$gentop"
-	    status=$?
-	    if test "$status" -ne 0 && test ! -d "$gentop"; then
-	      exit $status
+	    exit_status=$?
+	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
+	      exit $exit_status
 	    fi
 	  fi
 
@@ -5245,7 +5671,7 @@ fi\
       done
       # Quote the link command for shipping.
       relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
-      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
       if test "$hardcode_automatic" = yes ; then
 	relink_command=
       fi
@@ -5590,9 +6016,9 @@ relink_command=\"$relink_command\""
 
 	  if test -n "$inst_prefix_dir"; then
 	    # Stick the inst_prefix_dir data into the link command.
-	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP`
 	  else
-	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP`
 	  fi
 
 	  $echo "$modename: warning: relinking \`$file'" 1>&2
@@ -5797,22 +6223,11 @@ relink_command=\"$relink_command\""
 	  outputname=
 	  if test "$fast_install" = no && test -n "$relink_command"; then
 	    if test "$finalize" = yes && test -z "$run"; then
-	      tmpdir="/tmp"
-	      test -n "$TMPDIR" && tmpdir="$TMPDIR"
-	      tmpdir="$tmpdir/libtool-$$"
-	      save_umask=`umask`
-	      umask 0077
-	      if $mkdir "$tmpdir"; then
-	        umask $save_umask
-	      else
-	        umask $save_umask
-		$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
-		continue
-	      fi
+	      tmpdir=`func_mktempdir`
 	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
 	      outputname="$tmpdir/$file"
 	      # Replace the output file specification.
-	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+	      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
 
 	      $show "$relink_command"
 	      if $run eval "$relink_command"; then :
@@ -5932,7 +6347,7 @@ relink_command=\"$relink_command\""
     # Exit here if they wanted silent mode.
     test "$show" = : && exit $EXIT_SUCCESS
 
-    $echo "----------------------------------------------------------------------"
+    $echo "X----------------------------------------------------------------------" | $Xsed
     $echo "Libraries have been installed in:"
     for libdir in $libdirs; do
       $echo "   $libdir"
@@ -5965,7 +6380,7 @@ relink_command=\"$relink_command\""
     $echo
     $echo "See any operating system documentation about shared libraries for"
     $echo "more information, such as the ld(1) and ld.so(8) manual pages."
-    $echo "----------------------------------------------------------------------"
+    $echo "X----------------------------------------------------------------------" | $Xsed
     exit $EXIT_SUCCESS
     ;;
 
@@ -6023,8 +6438,10 @@ relink_command=\"$relink_command\""
 	if test -f "$dir/$objdir/$dlname"; then
 	  dir="$dir/$objdir"
 	else
-	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
-	  exit $EXIT_FAILURE
+	  if test ! -f "$dir/$dlname"; then
+	    $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+	    exit $EXIT_FAILURE
+	  fi
 	fi
 	;;
 
@@ -6088,12 +6505,12 @@ relink_command=\"$relink_command\""
       fi
 
       # Restore saved environment variables
-      if test "${save_LC_ALL+set}" = set; then
-	LC_ALL="$save_LC_ALL"; export LC_ALL
-      fi
-      if test "${save_LANG+set}" = set; then
-	LANG="$save_LANG"; export LANG
-      fi
+      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+      do
+	eval "if test \"\${save_$lt_var+set}\" = set; then
+		$lt_var=\$save_$lt_var; export $lt_var
+	      fi"
+      done
 
       # Now prepare to actually exec the command.
       exec_cmd="\$cmd$args"
@@ -6182,9 +6599,17 @@ relink_command=\"$relink_command\""
 	    rmfiles="$rmfiles $objdir/$n"
 	  done
 	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
-	  test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
 
-	  if test "$mode" = uninstall; then
+	  case "$mode" in
+	  clean)
+	    case "  $library_names " in
+	    # "  " in the beginning catches empty $dlname
+	    *" $dlname "*) ;;
+	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
+	    esac
+	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+	    ;;
+	  uninstall)
 	    if test -n "$library_names"; then
 	      # Do each command in the postuninstall commands.
 	      cmds=$postuninstall_cmds
@@ -6217,7 +6642,8 @@ relink_command=\"$relink_command\""
 	      IFS="$save_ifs"
 	    fi
 	    # FIXME: should reinstall the best remaining shared library.
-	  fi
+	    ;;
+	  esac
 	fi
 	;;
 
@@ -6441,9 +6867,9 @@ The following components of LINK-COMMAND are treated specially:
   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
   -export-symbols SYMFILE
-		    try to export only the symbols listed in SYMFILE
+                    try to export only the symbols listed in SYMFILE
   -export-symbols-regex REGEX
-		    try to export only the symbols matching REGEX
+                    try to export only the symbols matching REGEX
   -LLIBDIR          search LIBDIR for required installed libraries
   -lNAME            OUTPUT-FILE requires the installed library libNAME
   -module           build a library that can dlopened
@@ -6457,9 +6883,11 @@ The following components of LINK-COMMAND are treated specially:
   -release RELEASE  specify package release information
   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
-  -static           do not do any dynamic linking of libtool libraries
+  -static           do not do any dynamic linking of uninstalled libtool libraries
+  -static-libtool-libs
+                    do not do any dynamic linking of libtool libraries
   -version-info CURRENT[:REVISION[:AGE]]
-		    specify library version info [each variable defaults to 0]
+                    specify library version info [each variable defaults to 0]
 
 All other options (arguments beginning with \`-') are ignored.
 
@@ -6516,12 +6944,11 @@ exit $?
 # configuration.  But we'll never go from static-only to shared-only.
 
 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
-build_libtool_libs=no
-build_old_libs=yes
+disable_libs=shared
 # ### END LIBTOOL TAG CONFIG: disable-shared
 
 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
-build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
+disable_libs=static
 # ### END LIBTOOL TAG CONFIG: disable-static
 
 # Local Variables:
diff --git a/main/SAPI.c b/main/SAPI.c
index a4a8ed7..e6537fd 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: SAPI.c 287423 2009-08-17 17:30:32Z jani $ */
+/* $Id: SAPI.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <ctype.h>
 #include <sys/stat.h>
diff --git a/main/SAPI.h b/main/SAPI.h
index b978bc4..2e185cb 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: SAPI.h 279522 2009-04-28 21:30:23Z stas $ */
+/* $Id: SAPI.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SAPI_H
 #define SAPI_H
diff --git a/main/build-defs.h.in b/main/build-defs.h.in
index 5be6879..121536e 100644
--- a/main/build-defs.h.in
+++ b/main/build-defs.h.in
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: build-defs.h.in 256027 2008-03-25 02:00:32Z sixd $ */
+/* $Id: build-defs.h.in 292156 2009-12-15 11:17:47Z jani $ */
 
 #define CONFIGURE_COMMAND "@CONFIGURE_COMMAND@"
 #define PHP_ADA_INCLUDE		""
@@ -80,6 +80,7 @@
 #define PHP_EXTENSION_DIR       "@EXPANDED_EXTENSION_DIR@"
 #define PHP_PREFIX              "@prefix@"
 #define PHP_BINDIR              "@EXPANDED_BINDIR@"
+#define PHP_SBINDIR             "@EXPANDED_SBINDIR@"
 #define PHP_LIBDIR              "@EXPANDED_LIBDIR@"
 #define PHP_DATADIR             "@EXPANDED_DATADIR@"
 #define PHP_SYSCONFDIR          "@EXPANDED_SYSCONFDIR@"
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 3d65c85..20fca28 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: fopen_wrappers.c 289428 2009-10-09 17:03:56Z pajoye $ */
+/* $Id: fopen_wrappers.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* {{{ includes
  */
@@ -386,16 +386,16 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC)
 #ifndef PHP_WIN32
 	struct stat st;
 #endif
-	char *path_info, *filename;
+	char *path_info;
+	char *filename = NULL;
+	char *resolved_path = NULL;
 	int length;
 
-	filename = SG(request_info).path_translated;
 	path_info = SG(request_info).request_uri;
 #if HAVE_PWD_H
 	if (PG(user_dir) && *PG(user_dir) && path_info && '/' == path_info[0] && '~' == path_info[1]) {
 		char *s = strchr(path_info + 2, '/');
 
-		filename = NULL;	/* discard the original filename, it must not be used */
 		if (s) {			/* if there is no path name after the file, do not bother */
 			char user[32];			/* to try open the directory */
 			struct passwd *pw;
@@ -426,39 +426,41 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC)
 #endif
 			if (pw && pw->pw_dir) {
 				spprintf(&filename, 0, "%s%c%s%c%s", pw->pw_dir, PHP_DIR_SEPARATOR, PG(user_dir), PHP_DIR_SEPARATOR, s + 1); /* Safe */
-				STR_FREE(SG(request_info).path_translated);
-				SG(request_info).path_translated = filename;
-			}
+			} else {
+				filename = SG(request_info).path_translated;
+			} 
 #if defined(ZTS) && defined(HAVE_GETPWNAM_R) && defined(_SC_GETPW_R_SIZE_MAX)
 			efree(pwbuf);
 #endif
 		}
 	} else
 #endif
-	if (PG(doc_root) && path_info) {
-		length = strlen(PG(doc_root));
-		if (IS_ABSOLUTE_PATH(PG(doc_root), length)) {
-			filename = emalloc(length + strlen(path_info) + 2);
-			if (filename) {
-				memcpy(filename, PG(doc_root), length);
-				if (!IS_SLASH(filename[length - 1])) {	/* length is never 0 */
-					filename[length++] = PHP_DIR_SEPARATOR;
-				}
-				if (IS_SLASH(path_info[0])) {
-					length--;
-				}
-				strcpy(filename + length, path_info);
-				STR_FREE(SG(request_info).path_translated);
-				SG(request_info).path_translated = filename;
+	if (PG(doc_root) && path_info && (length = strlen(PG(doc_root)) &&
+		IS_ABSOLUTE_PATH(PG(doc_root), length))) {
+		filename = emalloc(length + strlen(path_info) + 2);
+		if (filename) {
+			memcpy(filename, PG(doc_root), length);
+			if (!IS_SLASH(filename[length - 1])) {	/* length is never 0 */
+				filename[length++] = PHP_DIR_SEPARATOR;
 			}
+			if (IS_SLASH(path_info[0])) {
+				length--;
+			}
+			strcpy(filename + length, path_info);
 		}
-	} /* if doc_root && path_info */
+	} else {
+		filename = SG(request_info).path_translated;
+	}
+
 
 	if (filename) {
-		filename = zend_resolve_path(filename, strlen(filename) TSRMLS_CC);
+		resolved_path = zend_resolve_path(filename, strlen(filename) TSRMLS_CC);
 	}
 
-	if (!filename) {
+	if (!resolved_path) {
+		if (SG(request_info).path_translated != filename) {
+			STR_FREE(filename);
+		}
 		/* we have to free SG(request_info).path_translated here because
 		 * php_destroy_request_info assumes that it will get
 		 * freed when the include_names hash is emptied, but
@@ -467,7 +469,7 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC)
 		SG(request_info).path_translated = NULL;
 		return FAILURE;
 	}
-	fp = VCWD_FOPEN(filename, "rb");
+	fp = VCWD_FOPEN(resolved_path, "rb");
 
 #ifndef PHP_WIN32
 	/* refuse to open anything that is not a regular file */
@@ -478,15 +480,20 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC)
 #endif
 
 	if (!fp) {
+		if (SG(request_info).path_translated != filename) {
+			STR_FREE(filename);
+		}
 		STR_FREE(SG(request_info).path_translated);	/* for same reason as above */
 		SG(request_info).path_translated = NULL;
 		return FAILURE;
 	}
 
-	file_handle->opened_path = expand_filepath(filename, NULL TSRMLS_CC);
+	file_handle->opened_path = resolved_path;
 
-	STR_FREE(SG(request_info).path_translated);	/* for same reason as above */
-	SG(request_info).path_translated = filename;
+	if (SG(request_info).path_translated != filename) {
+		STR_FREE(SG(request_info).path_translated);	/* for same reason as above */
+		SG(request_info).path_translated = filename;
+	}
 
 	file_handle->filename = SG(request_info).path_translated;
 	file_handle->free_filename = 0;
diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h
index 36db815..a9b1911 100644
--- a/main/fopen_wrappers.h
+++ b/main/fopen_wrappers.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: fopen_wrappers.h 273621 2009-01-16 10:06:10Z pajoye $ */
+/* $Id: fopen_wrappers.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef FOPEN_WRAPPERS_H
 #define FOPEN_WRAPPERS_H
diff --git a/main/getopt.c b/main/getopt.c
index 3eb9ecf..55f75b2 100644
--- a/main/getopt.c
+++ b/main/getopt.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: getopt.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: getopt.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdio.h>
 #include <string.h>
diff --git a/main/internal_functions_nw.c b/main/internal_functions_nw.c
index da63dd4..a508df7 100644
--- a/main/internal_functions_nw.c
+++ b/main/internal_functions_nw.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: internal_functions_nw.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: internal_functions_nw.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* {{{ includes
  */
diff --git a/main/internal_functions_win32.c b/main/internal_functions_win32.c
index f99c16f..ff531ac 100644
--- a/main/internal_functions_win32.c
+++ b/main/internal_functions_win32.c
@@ -2,7 +2,7 @@
 	+----------------------------------------------------------------------+
 	| PHP Version 5                                                        |
 	+----------------------------------------------------------------------+
-	| Copyright (c) 1997-2009 The PHP Group                                |
+	| 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        |
@@ -17,7 +17,7 @@
 	+----------------------------------------------------------------------+
 */
 
-/* $Id: internal_functions_win32.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: internal_functions_win32.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* {{{ includes
  */
diff --git a/main/logos.h b/main/logos.h
index 3c1d55b..04202da 100644
--- a/main/logos.h
+++ b/main/logos.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: logos.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: logos.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define CONTEXT_TYPE_IMAGE_GIF "Content-Type: image/gif"
 
diff --git a/main/main.c b/main/main.c
index acd0f4c..8970d06 100644
--- a/main/main.c
+++ b/main/main.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: main.c 290034 2009-10-28 15:19:32Z pajoye $ */
+/* $Id: main.c 294507 2010-02-04 09:21:02Z pajoye $ */
 
 /* {{{ includes
  */
@@ -244,12 +244,13 @@ static void php_disable_classes(TSRMLS_D)
  */
 static PHP_INI_MH(OnUpdateTimeout)
 {
-	EG(timeout_seconds) = atoi(new_value);
 	if (stage==PHP_INI_STAGE_STARTUP) {
 		/* Don't set a timeout on startup, only per-request */
+		EG(timeout_seconds) = atoi(new_value);
 		return SUCCESS;
 	}
 	zend_unset_timeout(TSRMLS_C);
+	EG(timeout_seconds) = atoi(new_value);
 	zend_set_timeout(EG(timeout_seconds), 0);
 	return SUCCESS;
 }
@@ -847,6 +848,27 @@ PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1,
 }
 /* }}} */
 
+#ifdef PHP_WIN32
+#define PHP_WIN32_ERROR_MSG_BUFFER_SIZE 512
+PHPAPI void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2 TSRMLS_DC) {
+	if (error == 0) {
+		php_error_docref2(NULL TSRMLS_CC, param1, param2, E_WARNING, "%s", strerror(errno));
+	} else {
+		char buf[PHP_WIN32_ERROR_MSG_BUFFER_SIZE + 1];
+		int buf_len;
+
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, buf, PHP_WIN32_ERROR_MSG_BUFFER_SIZE, NULL);
+		buf_len = strlen(buf);
+		if (buf_len >= 2) {
+			buf[buf_len - 1] = '\0';
+			buf[buf_len - 2] = '\0';
+		}
+		php_error_docref2(NULL TSRMLS_CC, param1, param2, E_WARNING, "%s (code: %lu)", (char *)buf, error);
+	}
+}
+#undef PHP_WIN32_ERROR_MSG_BUFFER_SIZE
+#endif
+
 /* {{{ php_html_puts */
 PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
 {
@@ -888,6 +910,9 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
 		if (PG(last_error_file)) {
 			free(PG(last_error_file));
 		}
+		if (!error_filename) {
+			error_filename = "Unknown";
+		}
 		PG(last_error_type) = type;
 		PG(last_error_message) = strdup(buffer);
 		PG(last_error_file) = strdup(error_filename);
@@ -976,6 +1001,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
 			php_log_err(log_buffer TSRMLS_CC);
 			efree(log_buffer);
 		}
+
 		if (PG(display_errors)
 			&& ((module_initialized && !PG(during_request_startup))
 				|| (PG(display_startup_errors) 
@@ -1004,7 +1030,12 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
 					if ((!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi")) &&
 						PG(display_errors) == PHP_DISPLAY_ERRORS_STDERR
 					) {
+#ifdef PHP_WIN32
+						fprintf(stderr, "%s: %s in %s on line%d\n", error_type_str, buffer, error_filename, error_lineno);
+						fflush(stderr);
+#else
 						fprintf(stderr, "%s: %s in %s on line %d\n", error_type_str, buffer, error_filename, error_lineno);
+#endif
 					} else {
 						php_printf("%s\n%s: %s in %s on line %d\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
 					}
@@ -1846,7 +1877,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
 #endif
 	EG(bailout) = NULL;
 	EG(error_reporting) = E_ALL & ~E_NOTICE;
-
+	EG(active_symbol_table) = NULL;
 	PG(header_is_being_sent) = 0;
 	SG(request_info).headers_only = 0;
 	SG(request_info).argv0 = NULL;
@@ -1938,33 +1969,6 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
 		return FAILURE;
 	}
 
-	/* Check for deprecated directives */
-	{
-		static const char *directives[] = {
-			"define_syslog_variables", 
-			"register_globals", 
-			"register_long_arrays", 
-			"safe_mode", 
-			"magic_quotes_gpc", 
-			"magic_quotes_runtime", 
-			"magic_quotes_sybase", 
-			NULL};
-		const char **p = directives;
-		long val;
-
-		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);
-			}
-			++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");
-		}
-	}
-
 	/* Register PHP core ini entries */
 	REGISTER_INI_ENTRIES();
 
@@ -2053,6 +2057,36 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
 #endif
 
 	module_initialized = 1;
+
+	/* Check for deprecated directives */
+	/* NOTE: If you add anything here, remember to add it also in Makefile.global! */
+	{
+		static const char *directives[] = {
+			"define_syslog_variables", 
+			"register_globals", 
+			"register_long_arrays", 
+			"safe_mode", 
+			"magic_quotes_gpc", 
+			"magic_quotes_runtime", 
+			"magic_quotes_sybase", 
+			NULL
+		};
+		const char **p = directives;
+		long val;
+
+		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);
+			}
+			++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");
+		}
+	}
+	
 	sapi_deactivate(TSRMLS_C);
 	module_startup = 0;
 
@@ -2184,6 +2218,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
 		 *   otherwise it will get opened and added to the included_files list in zend_execute_scripts
 		 */
  		if (primary_file->filename &&
+ 		    (primary_file->filename[0] != '-' || primary_file->filename[1] != 0) &&
  			primary_file->opened_path == NULL &&
  			primary_file->type != ZEND_HANDLE_FILENAME
 		) {
@@ -2220,7 +2255,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
 #ifdef PHP_WIN32
 			zend_unset_timeout(TSRMLS_C);
 #endif
-			zend_set_timeout(EG(timeout_seconds), 0);
+			zend_set_timeout(INI_INT("max_execution_time"), 0);
 		}
 		retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 3, prepend_file_p, primary_file, append_file_p) == SUCCESS);
 
diff --git a/main/network.c b/main/network.c
index 0d2f777..542c7cf 100644
--- a/main/network.c
+++ b/main/network.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: network.c 289498 2009-10-10 12:21:08Z pajoye $ */
+/* $Id: network.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
diff --git a/main/output.c b/main/output.c
index 4c9c654..0ebecc4 100644
--- a/main/output.c
+++ b/main/output.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: output.c 289444 2009-10-09 19:13:33Z pajoye $ */
+/* $Id: output.c 294505 2010-02-04 09:13:14Z pajoye $ */
 
 #include "php.h"
 #include "ext/standard/head.h"
@@ -50,6 +50,10 @@ php_output_globals output_globals;
 PHPAPI int php_default_output_func(const char *str, uint str_len TSRMLS_DC)
 {
 	fwrite(str, 1, str_len, stderr);
+/* See http://support.microsoft.com/kb/190351 */
+#ifdef PHP_WIN32
+	fflush(stderr);
+#endif
 	return str_len;
 }
 /* }}} */
diff --git a/main/php.h b/main/php.h
index 6655f3c..08cf293 100644
--- a/main/php.h
+++ b/main/php.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php.h 282827 2009-06-26 15:44:19Z johannes $ */
+/* $Id: php.h 294524 2010-02-04 10:13:54Z pajoye $ */
 
 #ifndef PHP_H
 #define PHP_H
@@ -309,6 +309,9 @@ PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1,
 	PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 4, PHP_ATTR_FMT_OFFSET + 5);
 PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...)
 	PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 5, PHP_ATTR_FMT_OFFSET + 6);
+#ifdef PHP_WIN32
+PHPAPI void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2 TSRMLS_DC);
+#endif
 END_EXTERN_C()
 
 #define php_error_docref php_error_docref0
diff --git a/main/php3_compat.h b/main/php3_compat.h
index 8b994b9..7373929 100644
--- a/main/php3_compat.h
+++ b/main/php3_compat.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php3_compat.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php3_compat.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP3_COMPAT_H
 #define PHP3_COMPAT_H
diff --git a/main/php_compat.h b/main/php_compat.h
index 3c6f592..5381aa3 100644
--- a/main/php_compat.h
+++ b/main/php_compat.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_compat.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_compat.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_COMPAT_H
 #define PHP_COMPAT_H
diff --git a/main/php_config.h.in b/main/php_config.h.in
index e75aad7..4daa3d9 100644
--- a/main/php_config.h.in
+++ b/main/php_config.h.in
@@ -4,7 +4,7 @@
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
+   | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: acconfig.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: acconfig.h 293155 2010-01-05 20:46:53Z sebastian $ */
 
 #if defined(__GNUC__) && __GNUC__ >= 4
 # define ZEND_API __attribute__ ((visibility("default")))
@@ -377,6 +377,9 @@
 /* Define if you have the memmove function.  */
 #undef HAVE_MEMMOVE
 
+/* Define if you have the mempcpy function.  */
+#undef HAVE_MEMPCPY
+
 /* Define if you have the mkfifo function.  */
 #undef HAVE_MKFIFO
 
@@ -545,6 +548,9 @@
 /* Define if you have the strpbrk function.  */
 #undef HAVE_STRPBRK
 
+/* Define if you have the strpncpy function.  */
+#undef HAVE_STRPNCPY
+
 /* Define if you have the strptime function.  */
 #undef HAVE_STRPTIME
 
@@ -620,9 +626,6 @@
 /* Define if you have the <arpa/nameser.h> header file.  */
 #undef HAVE_ARPA_NAMESER_H
 
-/* Define if you have the <arpa/nameser_compat.h> header file.  */
-#undef HAVE_ARPA_NAMESER_COMPAT_H
-
 /* Define if you have the <assert.h> header file.  */
 #undef HAVE_ASSERT_H
 
@@ -1056,15 +1059,6 @@
 #undef HAVE_LIBBIND
 
 /*   */
-#undef HAVE_NANOSLEEP
-
-/*   */
-#undef HAVE_NANOSLEEP
-
-/*   */
-#undef HAVE_LIBRT
-
-/*   */
 #undef HAVE_FOPENCOOKIE
 
 /*   */
@@ -1133,6 +1127,12 @@
 /* Whether struct sockaddr has field sa_len */
 #undef HAVE_SOCKADDR_SA_LEN
 
+/*   */
+#undef HAVE_NANOSLEEP
+
+/*   */
+#undef HAVE_LIBRT
+
 /* Define if you have the getaddrinfo function */
 #undef HAVE_GETADDRINFO
 
@@ -2441,6 +2441,12 @@
 /*   */
 #undef HAVE_CRYPT
 
+/* whether the compiler supports __alignof__ */
+#undef HAVE_ALIGNOF
+
+/* whether the compiler supports __attribute__ ((__aligned__)) */
+#undef HAVE_ATTRIBUTE_ALIGNED
+
 /* Whether PHP has to use its own crypt_r for blowfish, des, ext des and md5 */
 #undef PHP_USE_PHP_CRYPT_R
 
@@ -2453,9 +2459,15 @@
 /* Whether the system supports extended DES salt */
 #undef PHP_EXT_DES_CRYPT
 
-/* Whether the system supports extended DES salt */
+/* Whether the system supports MD5 salt */
 #undef PHP_MD5_CRYPT
 
+/* Whether the system supports SHA512 salt */
+#undef PHP_SHA512_CRYPT
+
+/* Whether the system supports SHA256 salt */
+#undef PHP_SHA256_CRYPT
+
 /* Whether the system supports standard DES salt */
 #undef PHP_STD_DES_CRYPT
 
@@ -2465,6 +2477,12 @@
 /* Whether the system supports extended DES salt */
 #undef PHP_EXT_DES_CRYPT
 
+/* Whether the system supports SHA512 salt */
+#undef PHP_EXT_SHA512_CRYPT
+
+/* Whether the system supports SHA256 salt */
+#undef PHP_EXT_SHA256_CRYPT
+
 /* Whether PHP has to use its own crypt_r for blowfish, des and ext des */
 #undef PHP_USE_PHP_CRYPT_R
 
@@ -2732,8 +2750,8 @@
 /* Whether to build mysqlnd as dynamic module */
 #undef COMPILE_DL_MYSQLND
 
-/* Use mysqlnd internal threading */
-#undef MYSQLND_THREADED
+/* Enable compressed protocol support */
+#undef MYSQLND_COMPRESSION_ENABLED
 
 /* Define if int32_t type is present.  */
 #undef HAVE_INT32_T
diff --git a/main/php_content_types.c b/main/php_content_types.c
index 85bdd69..e38a4c5 100644
--- a/main/php_content_types.c
+++ b/main/php_content_types.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_content_types.c 279522 2009-04-28 21:30:23Z stas $ */
+/* $Id: php_content_types.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "SAPI.h"
diff --git a/main/php_content_types.h b/main/php_content_types.h
index 9d1c910..7547a29 100644
--- a/main/php_content_types.h
+++ b/main/php_content_types.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_content_types.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_content_types.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_CONTENT_TYPES_H
 #define PHP_CONTENT_TYPES_H
diff --git a/main/php_getopt.h b/main/php_getopt.h
index e21d118..34fc3f7 100644
--- a/main/php_getopt.h
+++ b/main/php_getopt.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_getopt.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_getopt.h 294892 2010-02-11 17:24:43Z johannes $ */
 
 #ifndef PHP_GETOPT_H
 #define PHP_GETOPT_H
@@ -41,7 +41,7 @@ typedef struct _opt_struct {
 
 BEGIN_EXTERN_C()
 /* holds the index of the latest fetched element from the opts array */
-PHPAPI int php_optidx;
+extern PHPAPI int php_optidx;
 PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err, int arg_start);
 END_EXTERN_C()
 
diff --git a/main/php_globals.h b/main/php_globals.h
index 5a8942b..dda28f2 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_globals.h 289442 2009-10-09 19:06:10Z pajoye $ */
+/* $Id: php_globals.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_GLOBALS_H
 #define PHP_GLOBALS_H
diff --git a/main/php_ini.c b/main/php_ini.c
index f1918f4..294b8f2 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_ini.c 289668 2009-10-15 13:28:55Z pajoye $ */
+/* $Id: php_ini.c 294449 2010-02-03 20:13:18Z pajoye $ */
 
 #include "php.h"
 #include "ext/standard/info.h"
@@ -807,7 +807,7 @@ PHPAPI void php_ini_activate_per_dir_config(char *path, uint path_len TSRMLS_DC)
 		while ((ptr = strchr(ptr, '/')) != NULL) {
 			*ptr = 0;
 			/* Search for source array matching the path from configuration_hash */
-			if (zend_hash_find(&configuration_hash, path, path_len, (void **) &tmp) == SUCCESS) {
+			if (zend_hash_find(&configuration_hash, path, strlen(path) + 1, (void **) &tmp) == SUCCESS) {
 				php_ini_activate_config(Z_ARRVAL_P(tmp), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE TSRMLS_CC);
 			}
 			*ptr = '/';
diff --git a/main/php_ini.h b/main/php_ini.h
index 3d6cb5d..6440688 100644
--- a/main/php_ini.h
+++ b/main/php_ini.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_ini.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_ini.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_INI_H
 #define PHP_INI_H
diff --git a/main/php_logos.c b/main/php_logos.c
index ae6d69b..10e8218 100644
--- a/main/php_logos.c
+++ b/main/php_logos.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_logos.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_logos.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "logos.h"
diff --git a/main/php_logos.h b/main/php_logos.h
index 644ee16..42c5012 100644
--- a/main/php_logos.h
+++ b/main/php_logos.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_logos.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_logos.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 
 #ifndef _PHP_LOGOS_H
diff --git a/main/php_main.h b/main/php_main.h
index 2d27f92..64a5150 100644
--- a/main/php_main.h
+++ b/main/php_main.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_main.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_main.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_MAIN_H
 #define PHP_MAIN_H
diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h
index 6b17dca..d53cb64 100644
--- a/main/php_memory_streams.h
+++ b/main/php_memory_streams.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_memory_streams.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_memory_streams.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_MEMORY_STREAM_H
 #define PHP_MEMORY_STREAM_H
diff --git a/main/php_network.h b/main/php_network.h
index 51a2071..0c35af8 100644
--- a/main/php_network.h
+++ b/main/php_network.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_network.h 273010 2009-01-07 20:21:46Z felipe $ */
+/* $Id: php_network.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef _PHP_NETWORK_H
 #define _PHP_NETWORK_H
@@ -34,10 +34,16 @@
 #endif
 
 #ifdef PHP_WIN32
-#define EWOULDBLOCK WSAEWOULDBLOCK
-#define EINPROGRESS	WSAEWOULDBLOCK
-#	define fsync _commit
-#	define ftruncate(a, b) chsize(a, b)
+# ifdef EWOULDBLOCK
+#  undef EWOULDBLOCK
+# endif
+# ifdef EINPROGRESS
+#  undef EINPROGRESS
+# endif
+# define EWOULDBLOCK WSAEWOULDBLOCK
+# define EINPROGRESS	WSAEWOULDBLOCK
+# define fsync _commit
+# define ftruncate(a, b) chsize(a, b)
 #endif /* defined(PHP_WIN32) */
 
 #ifndef EWOULDBLOCK
diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index 2862338..583f67a 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_open_temporary_file.c 283130 2009-06-30 12:20:35Z iliaa $ */
+/* $Id: php_open_temporary_file.c 294726 2010-02-07 20:45:46Z pajoye $ */
 
 #include "php.h"
 
@@ -113,6 +113,13 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char **
 		return -1;
 	}
 
+#ifdef PHP_WIN32
+	if (!php_win32_check_trailing_space(pfx, (const int)strlen(pfx))) {
+		SetLastError(ERROR_INVALID_NAME);
+		return -1;
+	}
+#endif
+
 	if (!VCWD_GETCWD(cwd, MAXPATHLEN)) {
 		cwd[0] = '\0';
 	}
@@ -138,12 +145,14 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char **
 	}
 
 #ifdef PHP_WIN32
+
 	if (GetTempFileName(new_state.cwd, pfx, 0, opened_path)) {
 		/* Some versions of windows set the temp file to be read-only,
 		 * which means that opening it will fail... */
 		VCWD_CHMOD(opened_path, 0600);
 		fd = VCWD_OPEN_MODE(opened_path, open_flags, 0600);
 	}
+
 #elif defined(HAVE_MKSTEMP)
 	fd = mkstemp(opened_path);
 #else
@@ -151,6 +160,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char **
 		fd = VCWD_OPEN(opened_path, open_flags);
 	}
 #endif
+
 	if (fd == -1 || !opened_path_p) {
 		efree(opened_path);
 	} else {
diff --git a/main/php_open_temporary_file.h b/main/php_open_temporary_file.h
index 094ebd2..c60e452 100644
--- a/main/php_open_temporary_file.h
+++ b/main/php_open_temporary_file.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_open_temporary_file.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_open_temporary_file.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_OPEN_TEMPORARY_FILE_H
 #define PHP_OPEN_TEMPORARY_FILE_H
diff --git a/main/php_output.h b/main/php_output.h
index 8ad9cf5..964698f 100644
--- a/main/php_output.h
+++ b/main/php_output.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_output.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_output.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_OUTPUT_H
 #define PHP_OUTPUT_H
diff --git a/main/php_reentrancy.h b/main/php_reentrancy.h
index d076a4e..bf2f838 100644
--- a/main/php_reentrancy.h
+++ b/main/php_reentrancy.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_reentrancy.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_reentrancy.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_REENTRANCY_H
 #define PHP_REENTRANCY_H
diff --git a/main/php_scandir.c b/main/php_scandir.c
index d142731..c48cda8 100644
--- a/main/php_scandir.c
+++ b/main/php_scandir.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_scandir.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_scandir.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_scandir.h"
diff --git a/main/php_scandir.h b/main/php_scandir.h
index cf74ddf..f7e6327 100644
--- a/main/php_scandir.h
+++ b/main/php_scandir.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_scandir.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_scandir.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SCANDIR_H
 #define PHP_SCANDIR_H
diff --git a/main/php_sprintf.c b/main/php_sprintf.c
index d6890b6..5cb2ee0 100644
--- a/main/php_sprintf.c
+++ b/main/php_sprintf.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_sprintf.c 280501 2009-05-14 08:21:54Z dmitry $ */
+/* $Id: php_sprintf.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdio.h>
 #include <stdarg.h>
diff --git a/main/php_streams.h b/main/php_streams.h
index 28b9c19..2da3a5f 100755
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_streams.h 279002 2009-04-19 17:10:35Z lbarnaud $ */
+/* $Id: php_streams.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_STREAMS_H
 #define PHP_STREAMS_H
diff --git a/main/php_syslog.h b/main/php_syslog.h
index 71c65ca..971c0fc 100644
--- a/main/php_syslog.h
+++ b/main/php_syslog.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_syslog.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_syslog.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_SYSLOG_H
 #define PHP_SYSLOG_H
diff --git a/main/php_ticks.c b/main/php_ticks.c
index 1d544e4..b0b68e0 100644
--- a/main/php_ticks.c
+++ b/main/php_ticks.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_ticks.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_ticks.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_ticks.h"
diff --git a/main/php_ticks.h b/main/php_ticks.h
index dc7ae67..a23ac06 100644
--- a/main/php_ticks.h
+++ b/main/php_ticks.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_ticks.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_ticks.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_TICKS_H
 #define PHP_TICKS_H
diff --git a/main/php_variables.c b/main/php_variables.c
index 83b6a94..de80b09 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_variables.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_variables.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <stdio.h>
 #include "php.h"
diff --git a/main/php_variables.h b/main/php_variables.h
index 0237a2e..040082b 100644
--- a/main/php_variables.h
+++ b/main/php_variables.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_variables.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_variables.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_VARIABLES_H
 #define PHP_VARIABLES_H
diff --git a/main/php_version.h b/main/php_version.h
index 7adb32e..88ecedc 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 1
+#define PHP_RELEASE_VERSION 2
 #define PHP_EXTRA_VERSION ""
-#define PHP_VERSION "5.3.1"
-#define PHP_VERSION_ID 50301
+#define PHP_VERSION "5.3.2"
+#define PHP_VERSION_ID 50302
diff --git a/main/reentrancy.c b/main/reentrancy.c
index 7d2410a..1ecf3ba 100644
--- a/main/reentrancy.c
+++ b/main/reentrancy.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: reentrancy.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: reentrancy.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include <sys/types.h>
 #include <string.h>
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 31b74c1..f421b23 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -13,17 +13,17 @@
    | license at php.net so we can mail you a copy immediately.               |
    +----------------------------------------------------------------------+
    | Authors: Rasmus Lerdorf <rasmus at php.net>                             |
-   |          Jani Taskinen <sniper at php.net>                              |
+   |          Jani Taskinen <jani at php.net>                                |
    +----------------------------------------------------------------------+
  */
 
-/* $Id: rfc1867.c 290025 2009-10-28 11:03:36Z pajoye $ */
+/* $Id: rfc1867.c 294031 2010-01-25 23:26:15Z johannes $ */
 
 /*
  *  This product includes software developed by the Apache Group
  *  for use in the Apache HTTP server project (http://www.apache.org/).
  *
- */   
+ */
 
 #include <stdio.h>
 #include "php.h"
@@ -32,6 +32,7 @@
 #include "php_globals.h"
 #include "php_variables.h"
 #include "rfc1867.h"
+#include "ext/standard/php_string.h"
 
 #define DEBUG_FILE_UPLOAD ZEND_DEBUG
 
@@ -43,7 +44,7 @@ PHPAPI int (*php_rfc1867_callback)(unsigned int event, void *event_data, void **
 static void safe_php_register_variable(char *var, char *strval, int val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC);
 
 #define SAFE_RETURN { \
-    php_mb_flush_gpc_variables(num_vars, val_list, len_list, array_ptr TSRMLS_CC); \
+	php_mb_flush_gpc_variables(num_vars, val_list, len_list, array_ptr TSRMLS_CC); \
 	if (lbuf) efree(lbuf); \
 	if (abuf) efree(abuf); \
 	if (array_index) efree(array_index); \
@@ -55,7 +56,7 @@ static void safe_php_register_variable(char *var, char *strval, int val_len, zva
 	if (mbuff) efree(mbuff); \
 	return; }
 
-void php_mb_flush_gpc_variables(int num_vars, char **val_list, int *len_list, zval *array_ptr  TSRMLS_DC)
+void php_mb_flush_gpc_variables(int num_vars, char **val_list, int *len_list, zval *array_ptr  TSRMLS_DC) /* {{{ */
 {
 	int i;
 	if (php_mb_encoding_translation(TSRMLS_C)) {
@@ -63,17 +64,18 @@ void php_mb_flush_gpc_variables(int num_vars, char **val_list, int *len_list, zv
 			php_mb_gpc_encoding_detector(val_list, len_list, num_vars, NULL TSRMLS_CC) == SUCCESS) {
 			php_mb_gpc_encoding_converter(val_list, len_list, num_vars, NULL, NULL TSRMLS_CC);
 		}
-		for (i=0; i<num_vars; i+=2){
+		for (i = 0; i<num_vars; i += 2) {
 			safe_php_register_variable(val_list[i], val_list[i+1], len_list[i+1], array_ptr, 0 TSRMLS_CC);
 			efree(val_list[i]);
 			efree(val_list[i+1]);
-		} 
+		}
 		efree(val_list);
 		efree(len_list);
 	}
 }
+/* }}} */
 
-void php_mb_gpc_realloc_buffer(char ***pval_list, int **plen_list, int *num_vars_max, int inc  TSRMLS_DC)
+void php_mb_gpc_realloc_buffer(char ***pval_list, int **plen_list, int *num_vars_max, int inc  TSRMLS_DC) /* {{{ */
 {
 	/* allow only even increments */
 	if (inc & 1) {
@@ -83,15 +85,15 @@ void php_mb_gpc_realloc_buffer(char ***pval_list, int **plen_list, int *num_vars
 	*pval_list = (char **)erealloc(*pval_list, (*num_vars_max+2)*sizeof(char *));
 	*plen_list = (int *)erealloc(*plen_list, (*num_vars_max+2)*sizeof(int));
 }
+/* }}} */
 
-void php_mb_gpc_stack_variable(char *param, char *value, char ***pval_list, int **plen_list, int *num_vars, int *num_vars_max TSRMLS_DC)
+void php_mb_gpc_stack_variable(char *param, char *value, char ***pval_list, int **plen_list, int *num_vars, int *num_vars_max TSRMLS_DC) /* {{{ */
 {
-	char **val_list=*pval_list;
-	int *len_list=*plen_list;
+	char **val_list = *pval_list;
+	int *len_list = *plen_list;
 
-	if (*num_vars>=*num_vars_max){	
-		php_mb_gpc_realloc_buffer(pval_list, plen_list, num_vars_max, 
-								  16 TSRMLS_CC);
+	if (*num_vars >= *num_vars_max) {
+		php_mb_gpc_realloc_buffer(pval_list, plen_list, num_vars_max, 16 TSRMLS_CC);
 		/* in case realloc relocated the buffer */
 		val_list = *pval_list;
 		len_list = *plen_list;
@@ -104,6 +106,7 @@ void php_mb_gpc_stack_variable(char *param, char *value, char ***pval_list, int
 	len_list[*num_vars] = strlen(value);
 	(*num_vars)++;
 }
+/* }}} */
 
 #else
 
@@ -136,7 +139,7 @@ void php_mb_gpc_stack_variable(char *param, char *value, char ***pval_list, int
 #define UPLOAD_ERROR_F    7  /* Failed to write file to disk */
 #define UPLOAD_ERROR_X    8  /* File upload stopped by extension */
 
-void php_rfc1867_register_constants(TSRMLS_D)
+void php_rfc1867_register_constants(TSRMLS_D) /* {{{ */
 {
 	REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_OK",         UPLOAD_ERROR_OK, CONST_CS | CONST_PERSISTENT);
 	REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_INI_SIZE",   UPLOAD_ERROR_A,  CONST_CS | CONST_PERSISTENT);
@@ -147,26 +150,27 @@ void php_rfc1867_register_constants(TSRMLS_D)
 	REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_CANT_WRITE", UPLOAD_ERROR_F,  CONST_CS | CONST_PERSISTENT);
 	REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_EXTENSION",  UPLOAD_ERROR_X,  CONST_CS | CONST_PERSISTENT);
 }
+/* }}} */
 
-static void normalize_protected_variable(char *varname TSRMLS_DC)
+static void normalize_protected_variable(char *varname TSRMLS_DC) /* {{{ */
 {
-	char *s=varname, *index=NULL, *indexend=NULL, *p;
-	
+	char *s = varname, *index = NULL, *indexend = NULL, *p;
+
 	/* overjump leading space */
 	while (*s == ' ') {
 		s++;
 	}
-	
+
 	/* and remove it */
 	if (s != varname) {
 		memmove(varname, s, strlen(s)+1);
 	}
 
-	for (p=varname; *p && *p != '['; p++) {
+	for (p = varname; *p && *p != '['; p++) {
 		switch(*p) {
 			case ' ':
 			case '.':
-				*p='_';
+				*p = '_';
 				break;
 		}
 	}
@@ -175,20 +179,19 @@ static void normalize_protected_variable(char *varname TSRMLS_DC)
 	index = strchr(varname, '[');
 	if (index) {
 		index++;
-		s=index;
+		s = index;
 	} else {
 		return;
 	}
 
 	/* done? */
 	while (index) {
-
 		while (*index == ' ' || *index == '\r' || *index == '\n' || *index=='\t') {
 			index++;
 		}
 		indexend = strchr(index, ']');
 		indexend = indexend ? indexend + 1 : index + strlen(index);
-		
+
 		if (s != index) {
 			memmove(s, index, strlen(index)+1);
 			s += indexend-index;
@@ -201,46 +204,45 @@ static void normalize_protected_variable(char *varname TSRMLS_DC)
 			index = s;
 		} else {
 			index = NULL;
-		}	
+		}
 	}
-
 	*s = '\0';
 }
+/* }}} */
 
-
-static void add_protected_variable(char *varname TSRMLS_DC)
+static void add_protected_variable(char *varname TSRMLS_DC) /* {{{ */
 {
-	int dummy=1;
+	int dummy = 1;
 
 	normalize_protected_variable(varname TSRMLS_CC);
 	zend_hash_add(&PG(rfc1867_protected_variables), varname, strlen(varname)+1, &dummy, sizeof(int), NULL);
 }
+/* }}} */
 
-
-static zend_bool is_protected_variable(char *varname TSRMLS_DC)
+static zend_bool is_protected_variable(char *varname TSRMLS_DC) /* {{{ */
 {
 	normalize_protected_variable(varname TSRMLS_CC);
 	return zend_hash_exists(&PG(rfc1867_protected_variables), varname, strlen(varname)+1);
 }
+/* }}} */
 
-
-static void safe_php_register_variable(char *var, char *strval, int val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC)
+static void safe_php_register_variable(char *var, char *strval, int val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC) /* {{{ */
 {
 	if (override_protection || !is_protected_variable(var TSRMLS_CC)) {
 		php_register_variable_safe(var, strval, val_len, track_vars_array TSRMLS_CC);
 	}
 }
+/* }}} */
 
-
-static void safe_php_register_variable_ex(char *var, zval *val, zval *track_vars_array, zend_bool override_protection TSRMLS_DC)
+static void safe_php_register_variable_ex(char *var, zval *val, zval *track_vars_array, zend_bool override_protection TSRMLS_DC) /* {{{ */
 {
 	if (override_protection || !is_protected_variable(var TSRMLS_CC)) {
 		php_register_variable_ex(var, val, track_vars_array TSRMLS_CC);
 	}
 }
+/* }}} */
 
-
-static void register_http_post_files_variable(char *strvar, char *val, zval *http_post_files, zend_bool override_protection TSRMLS_DC)
+static void register_http_post_files_variable(char *strvar, char *val, zval *http_post_files, zend_bool override_protection TSRMLS_DC) /* {{{ */
 {
 	int register_globals = PG(register_globals);
 
@@ -248,9 +250,9 @@ static void register_http_post_files_variable(char *strvar, char *val, zval *htt
 	safe_php_register_variable(strvar, val, strlen(val), http_post_files, override_protection TSRMLS_CC);
 	PG(register_globals) = register_globals;
 }
+/* }}} */
 
-
-static void register_http_post_files_variable_ex(char *var, zval *val, zval *http_post_files, zend_bool override_protection TSRMLS_DC)
+static void register_http_post_files_variable_ex(char *var, zval *val, zval *http_post_files, zend_bool override_protection TSRMLS_DC) /* {{{ */
 {
 	int register_globals = PG(register_globals);
 
@@ -258,27 +260,24 @@ static void register_http_post_files_variable_ex(char *var, zval *val, zval *htt
 	safe_php_register_variable_ex(var, val, http_post_files, override_protection TSRMLS_CC);
 	PG(register_globals) = register_globals;
 }
+/* }}} */
 
-
-static int unlink_filename(char **filename TSRMLS_DC)
+static int unlink_filename(char **filename TSRMLS_DC) /* {{{ */
 {
 	VCWD_UNLINK(*filename);
 	return 0;
 }
+/* }}} */
 
-
-void destroy_uploaded_files_hash(TSRMLS_D)
+void destroy_uploaded_files_hash(TSRMLS_D) /* {{{ */
 {
 	zend_hash_apply(SG(rfc1867_uploaded_files), (apply_func_t) unlink_filename TSRMLS_CC);
 	zend_hash_destroy(SG(rfc1867_uploaded_files));
 	FREE_HASHTABLE(SG(rfc1867_uploaded_files));
 }
+/* }}} */
 
-
-/*
- *  Following code is based on apache_multipart_buffer.c from libapreq-0.33 package.
- *
- */
+/* {{{ Following code is based on apache_multipart_buffer.c from libapreq-0.33 package. */
 
 #define FILLUNIT (1024 * 5)
 
@@ -297,17 +296,15 @@ typedef struct {
 
 } multipart_buffer;
 
-
 typedef struct {
 	char *key;
 	char *value;
 } mime_header_entry;
 
-
 /*
-  fill up the buffer with client data.
-  returns number of bytes added to buffer.
-*/
+ * Fill up the buffer with client data.
+ * Returns number of bytes added to buffer.
+ */
 static int fill_buffer(multipart_buffer *self TSRMLS_DC)
 {
 	int bytes_to_read, total_read = 0, actual_read = 0;
@@ -343,7 +340,6 @@ static int fill_buffer(multipart_buffer *self TSRMLS_DC)
 	return total_read;
 }
 
-
 /* eof if we are out of bytes, or if we hit the final boundary */
 static int multipart_buffer_eof(multipart_buffer *self TSRMLS_DC)
 {
@@ -354,7 +350,6 @@ static int multipart_buffer_eof(multipart_buffer *self TSRMLS_DC)
 	}
 }
 
-
 /* create new multipart_buffer structure */
 static multipart_buffer *multipart_buffer_new(char *boundary, int boundary_len)
 {
@@ -367,7 +362,7 @@ static multipart_buffer *multipart_buffer_new(char *boundary, int boundary_len)
 	self->bufsize = minsize;
 
 	spprintf(&self->boundary, 0, "--%s", boundary);
-	
+
 	self->boundary_next_len = spprintf(&self->boundary_next, 0, "\n--%s", boundary);
 
 	self->buf_begin = self->buffer;
@@ -376,17 +371,16 @@ static multipart_buffer *multipart_buffer_new(char *boundary, int boundary_len)
 	return self;
 }
 
-
 /*
-  gets the next CRLF terminated line from the input buffer.
-  if it doesn't find a CRLF, and the buffer isn't completely full, returns
-  NULL; otherwise, returns the beginning of the null-terminated line,
-  minus the CRLF.
-
-  note that we really just look for LF terminated lines. this works
-  around a bug in internet explorer for the macintosh which sends mime
-  boundaries that are only LF terminated when you use an image submit
-  button in a multipart/form-data form.
+ * Gets the next CRLF terminated line from the input buffer.
+ * If it doesn't find a CRLF, and the buffer isn't completely full, returns
+ * NULL; otherwise, returns the beginning of the null-terminated line,
+ * minus the CRLF.
+ *
+ * Note that we really just look for LF terminated lines. This works
+ * around a bug in internet explorer for the macintosh which sends mime
+ * boundaries that are only LF terminated when you use an image submit
+ * button in a multipart/form-data form.
  */
 static char *next_line(multipart_buffer *self)
 {
@@ -406,7 +400,7 @@ static char *next_line(multipart_buffer *self)
 		/* bump the pointer */
 		self->buf_begin = ptr + 1;
 		self->bytes_in_buffer -= (self->buf_begin - line);
-	
+
 	} else {	/* no LF found */
 
 		/* buffer isn't completely full, fail */
@@ -422,8 +416,7 @@ static char *next_line(multipart_buffer *self)
 	return line;
 }
 
-
-/* returns the next CRLF terminated line from the client */
+/* Returns the next CRLF terminated line from the client */
 static char *get_line(multipart_buffer *self TSRMLS_DC)
 {
 	char* ptr = next_line(self);
@@ -436,7 +429,6 @@ static char *get_line(multipart_buffer *self TSRMLS_DC)
 	return ptr;
 }
 
-
 /* Free header entry */
 static void php_free_hdr_entry(mime_header_entry *h)
 {
@@ -448,7 +440,6 @@ static void php_free_hdr_entry(mime_header_entry *h)
 	}
 }
 
-
 /* finds a boundary */
 static int find_boundary(multipart_buffer *self, char *boundary TSRMLS_DC)
 {
@@ -467,14 +458,13 @@ static int find_boundary(multipart_buffer *self, char *boundary TSRMLS_DC)
 	return 0;
 }
 
-
 /* parse headers */
 static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header TSRMLS_DC)
 {
 	char *line;
 	mime_header_entry prev_entry, entry;
 	int prev_len, cur_len;
-	
+
 	/* didn't find boundary, abort */
 	if (!find_boundary(self, self->boundary TSRMLS_CC)) {
 		return 0;
@@ -485,10 +475,9 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header T
 	while( (line = get_line(self TSRMLS_CC)) && strlen(line) > 0 )
 	{
 		/* add header to table */
-		
 		char *key = line;
 		char *value = NULL;
-		
+
 		/* space in the beginning means same header */
 		if (!isspace(line[0])) {
 			value = strchr(line, ':');
@@ -512,7 +501,7 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header T
 			entry.value[cur_len + prev_len] = '\0';
 
 			entry.key = estrdup(prev_entry.key);
-			
+
 			zend_llist_remove_tail(header);
 		} else {
 			continue;
@@ -525,7 +514,6 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header T
 	return 1;
 }
 
-
 static char *php_mime_get_hdr_value(zend_llist header, char *key)
 {
 	mime_header_entry *entry;
@@ -533,7 +521,7 @@ static char *php_mime_get_hdr_value(zend_llist header, char *key)
 	if (key == NULL) {
 		return NULL;
 	}
-	
+
 	entry = zend_llist_get_first(&header);
 	while (entry) {
 		if (!strcasecmp(entry->key, key)) {
@@ -541,18 +529,16 @@ static char *php_mime_get_hdr_value(zend_llist header, char *key)
 		}
 		entry = zend_llist_get_next(&header);
 	}
-	
+
 	return NULL;
 }
 
-
 static char *php_ap_getword(char **line, char stop)
 {
 	char *pos = *line, quote;
 	char *res;
 
 	while (*pos && *pos != stop) {
-		
 		if ((quote = *pos) == '"' || quote == '\'') {
 			++pos;
 			while (*pos && *pos != quote) {
@@ -566,7 +552,6 @@ static char *php_ap_getword(char **line, char stop)
 				++pos;
 			}
 		} else ++pos;
-		
 	}
 	if (*pos == '\0') {
 		res = estrdup(*line);
@@ -584,7 +569,6 @@ static char *php_ap_getword(char **line, char stop)
 	return res;
 }
 
-
 static char *substring_conf(char *start, int len, char quote TSRMLS_DC)
 {
 	char *result = emalloc(len + 2);
@@ -615,7 +599,6 @@ static char *substring_conf(char *start, int len, char quote TSRMLS_DC)
 	return result;
 }
 
-
 static char *php_ap_getword_conf(char **line TSRMLS_DC)
 {
 	char *str = *line, *strend, *res, quote;
@@ -677,12 +660,11 @@ look_for_quote:
 	return res;
 }
 
-
 /*
-  search for a string in a fixed-length byte string.
-  if partial is true, partial matches are allowed at the end of the buffer.
-  returns NULL if not found, or a pointer to the start of the first match.
-*/
+ * Search for a string in a fixed-length byte string.
+ * If partial is true, partial matches are allowed at the end of the buffer.
+ * Returns NULL if not found, or a pointer to the start of the first match.
+ */
 static void *php_ap_memstr(char *haystack, int haystacklen, char *needle, int needlen, int partial)
 {
 	int len = haystacklen;
@@ -706,7 +688,6 @@ static void *php_ap_memstr(char *haystack, int haystacklen, char *needle, int ne
 	return ptr;
 }
 
-
 /* read until a boundary condition */
 static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes, int *end TSRMLS_DC)
 {
@@ -750,7 +731,6 @@ static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes, i
 	return len;
 }
 
-
 /*
   XXX: this is horrible memory-usage-wise, but we only expect
   to do this on small pieces of form data.
@@ -766,50 +746,60 @@ static char *multipart_buffer_read_body(multipart_buffer *self, unsigned int *le
 		total_bytes += read_bytes;
 	}
 
-	if (out) out[total_bytes] = '\0';
+	if (out) {
+		out[total_bytes] = '\0';
+	}
 	*len = total_bytes;
 
 	return out;
 }
-
+/* }}} */
 
 /*
  * The combined READER/HANDLER
  *
  */
 
-SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
+SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
 {
-	char *boundary, *s=NULL, *boundary_end = NULL, *start_arr=NULL, *array_index=NULL;
-	char *temp_filename=NULL, *lbuf=NULL, *abuf=NULL;
-	int boundary_len=0, total_bytes=0, cancel_upload=0, is_arr_upload=0, array_len=0;
-	int max_file_size=0, skip_upload=0, anonindex=0, is_anonymous;
-	zval *http_post_files=NULL; HashTable *uploaded_files=NULL;
+	char *boundary, *s = NULL, *boundary_end = NULL, *start_arr = NULL, *array_index = NULL;
+	char *temp_filename = NULL, *lbuf = NULL, *abuf = NULL;
+	int boundary_len = 0, total_bytes = 0, cancel_upload = 0, is_arr_upload = 0, array_len = 0;
+	int max_file_size = 0, skip_upload = 0, anonindex = 0, is_anonymous;
+	zval *http_post_files = NULL;
+	HashTable *uploaded_files = NULL;
 #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
 	int str_len = 0, num_vars = 0, num_vars_max = 2*10, *len_list = NULL;
 	char **val_list = NULL;
 #endif
 	multipart_buffer *mbuff;
 	zval *array_ptr = (zval *) arg;
-	int fd=-1;
+	int fd = -1;
 	zend_llist header;
 	void *event_extra_data = NULL;
 	int llen = 0;
-	char *max_uploads = INI_STR("max_file_uploads");
-	int upload_cnt = 0;
+	int upload_cnt = INI_INT("max_file_uploads");
 
-	if (max_uploads && *max_uploads) {
-		upload_cnt = atoi(max_uploads);
-	}
-
-	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)) {
 		sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size));
 		return;
 	}
 
 	/* Get the boundary */
 	boundary = strstr(content_type_dup, "boundary");
-	if (!boundary || !(boundary=strchr(boundary, '='))) {
+	if (!boundary) {
+		int content_type_len = strlen(content_type_dup);
+		char *content_type_lcase = estrndup(content_type_dup, content_type_len);
+
+		php_strtolower(content_type_lcase, content_type_len);
+		boundary = strstr(content_type_lcase, "boundary");
+		if (boundary) {
+			boundary = content_type_dup + (boundary - content_type_lcase);
+		}
+		efree(content_type_lcase);
+	}
+
+	if (!boundary || !(boundary = strchr(boundary, '='))) {
 		sapi_module.sapi_error(E_WARNING, "Missing boundary in multipart/form-data POST data");
 		return;
 	}
@@ -820,7 +810,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 	if (boundary[0] == '"') {
 		boundary++;
 		boundary_end = strchr(boundary, '"');
-		if (!boundary_end) { 
+		if (!boundary_end) {
 			sapi_module.sapi_error(E_WARNING, "Invalid boundary in multipart/form-data POST data");
 			return;
 		}
@@ -871,8 +861,8 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 	while (!multipart_buffer_eof(mbuff TSRMLS_CC))
 	{
 		char buff[FILLUNIT];
-		char *cd=NULL,*param=NULL,*filename=NULL, *tmp=NULL;
-		size_t blen=0, wlen=0;
+		char *cd = NULL, *param = NULL, *filename = NULL, *tmp = NULL;
+		size_t blen = 0, wlen = 0;
 		off_t offset;
 
 		zend_llist_clean(&header);
@@ -882,16 +872,16 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 		}
 
 		if ((cd = php_mime_get_hdr_value(header, "Content-Disposition"))) {
-			char *pair=NULL;
-			int end=0;
-			
+			char *pair = NULL;
+			int end = 0;
+
 			while (isspace(*cd)) {
 				++cd;
 			}
 
 			while (*cd && (pair = php_ap_getword(&cd, ';')))
 			{
-				char *key=NULL, *word = pair;
+				char *key = NULL, *word = pair;
 
 				while (isspace(*cd)) {
 					++cd;
@@ -899,7 +889,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 
 				if (strchr(pair, '=')) {
 					key = php_ap_getword(&pair, '=');
-					
+
 					if (!strcasecmp(key, "name")) {
 						if (param) {
 							efree(param);
@@ -948,8 +938,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 
 #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
 					if (php_mb_encoding_translation(TSRMLS_C)) {
-						php_mb_gpc_stack_variable(param, value, &val_list, &len_list, 
-												  &num_vars, &num_vars_max TSRMLS_CC);
+						php_mb_gpc_stack_variable(param, value, &val_list, &len_list, &num_vars, &num_vars_max TSRMLS_CC);
 					} else {
 						safe_php_register_variable(param, value, new_val_len, array_ptr, 0 TSRMLS_CC);
 					}
@@ -989,7 +978,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 				sapi_module.sapi_error(E_WARNING, "File Upload Mime headers garbled");
 				goto fileupload_done;
 			}
-			
+
 			if (!param) {
 				is_anonymous = 1;
 				param = emalloc(MAX_SIZE_ANONNAME);
@@ -997,12 +986,12 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 			} else {
 				is_anonymous = 0;
 			}
-			
+
 			/* New Rule: never repair potential malicious user input */
 			if (!skip_upload) {
 				char *tmp = param;
 				long c = 0;
-				
+
 				while (*tmp) {
 					if (*tmp == '[') {
 						c++;
@@ -1017,7 +1006,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 						skip_upload = 1;
 						break;
 					}
-					tmp++;				
+					tmp++;
 				}
 			}
 
@@ -1027,12 +1016,12 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 				/* Handle file */
 				fd = php_open_temporary_fd_ex(PG(upload_tmp_dir), "php", &temp_filename, 1 TSRMLS_CC);
 				upload_cnt--;
-				if (fd==-1) {
+				if (fd == -1) {
 					sapi_module.sapi_error(E_WARNING, "File upload error - unable to create a temporary file");
 					cancel_upload = UPLOAD_ERROR_E;
 				}
 			}
-			
+
 			if (!skip_upload && php_rfc1867_callback != NULL) {
 				multipart_event_file_start event_file_start;
 
@@ -1047,21 +1036,20 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 						}
 						efree(temp_filename);
 					}
-					temp_filename="";
+					temp_filename = "";
 					efree(param);
 					efree(filename);
 					continue;
 				}
 			}
 
-			
 			if (skip_upload) {
 				efree(param);
 				efree(filename);
 				continue;
 			}
 
-			if(strlen(filename) == 0) {
+			if (strlen(filename) == 0) {
 #if DEBUG_FILE_UPLOAD
 				sapi_module.sapi_error(E_NOTICE, "No file uploaded");
 #endif
@@ -1085,8 +1073,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 						continue;
 					}
 				}
-				
-			
+
 				if (PG(upload_max_filesize) > 0 && (total_bytes+blen) > PG(upload_max_filesize)) {
 #if DEBUG_FILE_UPLOAD
 					sapi_module.sapi_error(E_NOTICE, "upload_max_filesize of %ld bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename);
@@ -1098,9 +1085,8 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 #endif
 					cancel_upload = UPLOAD_ERROR_B;
 				} else if (blen > 0) {
-				
 					wlen = write(fd, buff, blen);
-			
+
 					if (wlen == -1) {
 						/* write failed */
 #if DEBUG_FILE_UPLOAD
@@ -1115,11 +1101,10 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 					} else {
 						total_bytes += wlen;
 					}
-					
 					offset += wlen;
-				} 
+				}
 			}
-			if (fd!=-1) { /* may not be initialized if file could not be created */
+			if (fd != -1) { /* may not be initialized if file could not be created */
 				close(fd);
 			}
 			if (!cancel_upload && !end) {
@@ -1129,12 +1114,11 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 				cancel_upload = UPLOAD_ERROR_C;
 			}
 #if DEBUG_FILE_UPLOAD
-			if(strlen(filename) > 0 && total_bytes == 0 && !cancel_upload) {
+			if (strlen(filename) > 0 && total_bytes == 0 && !cancel_upload) {
 				sapi_module.sapi_error(E_WARNING, "Uploaded file size 0 - file [%s=%s] not saved", param, filename);
 				cancel_upload = 5;
 			}
-#endif		
-
+#endif
 			if (php_rfc1867_callback != NULL) {
 				multipart_event_file_end event_file_end;
 
@@ -1153,15 +1137,14 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 					}
 					efree(temp_filename);
 				}
-				temp_filename="";
+				temp_filename = "";
 			} else {
 				zend_hash_add(SG(rfc1867_uploaded_files), temp_filename, strlen(temp_filename) + 1, &temp_filename, sizeof(char *), NULL);
 			}
 
 			/* is_arr_upload is true when name of file upload field
 			 * ends in [.*]
-			 * start_arr is set to point to 1st [
-			 */
+			 * start_arr is set to point to 1st [ */
 			is_arr_upload =	(start_arr = strchr(param,'[')) && (param[strlen(param)-1] == ']');
 
 			if (is_arr_upload) {
@@ -1169,16 +1152,16 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 				if (array_index) {
 					efree(array_index);
 				}
-				array_index = estrndup(start_arr+1, array_len-2);   
+				array_index = estrndup(start_arr + 1, array_len - 2);
 			}
-			
+
 			/* Add $foo_name */
 			if (llen < strlen(param) + MAX_SIZE_OF_INDEX + 1) {
 				llen = strlen(param);
 				lbuf = (char *) safe_erealloc(lbuf, llen, 1, MAX_SIZE_OF_INDEX + 1);
 				llen += MAX_SIZE_OF_INDEX + 1;
 			}
-			
+
 			if (is_arr_upload) {
 				if (abuf) efree(abuf);
 				abuf = estrndup(param, strlen(param)-array_len);
@@ -1189,14 +1172,13 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 
 #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
 			if (php_mb_encoding_translation(TSRMLS_C)) {
-				if (num_vars>=num_vars_max){	
-					php_mb_gpc_realloc_buffer(&val_list, &len_list, &num_vars_max, 
-											  1 TSRMLS_CC);
+				if (num_vars >= num_vars_max) {
+					php_mb_gpc_realloc_buffer(&val_list, &len_list, &num_vars_max, 1 TSRMLS_CC);
 				}
 				val_list[num_vars] = filename;
 				len_list[num_vars] = strlen(filename);
 				num_vars++;
-				if(php_mb_gpc_encoding_detector(val_list, len_list, num_vars, NULL TSRMLS_CC) == SUCCESS) {
+				if (php_mb_gpc_encoding_detector(val_list, len_list, num_vars, NULL TSRMLS_CC) == SUCCESS) {
 					str_len = strlen(filename);
 					php_mb_gpc_encoding_converter(&filename, &str_len, 1, NULL, NULL TSRMLS_CC);
 				}
@@ -1207,13 +1189,12 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 				num_vars--;
 				goto filedone;
 			}
-#endif			
+#endif
 			/* The \ check should technically be needed for win32 systems only where
 			 * it is a valid path separator. However, IE in all it's wisdom always sends
 			 * the full path of the file on the user's filesystem, which means that unless
-			 * the user does basename() they get a bogus file name. Until IE's user base drops 
-			 * to nill or problem is fixed this code must remain enabled for all systems.
-			 */
+			 * the user does basename() they get a bogus file name. Until IE's user base drops
+			 * to nill or problem is fixed this code must remain enabled for all systems. */
 			s = strrchr(filename, '\\');
 			if ((tmp = strrchr(filename, '/')) > s) {
 				s = tmp;
@@ -1229,9 +1210,9 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 #endif
 
 #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
-filedone:			
+filedone:
 #endif
-			
+
 			if (!is_anonymous) {
 				if (s && s > filename) {
 					safe_php_register_variable(lbuf, s+1, strlen(s+1), NULL, 0 TSRMLS_CC);
@@ -1253,11 +1234,11 @@ filedone:
 			}
 			efree(filename);
 			s = NULL;
-	
+
 			/* Possible Content-Type: */
 			if (cancel_upload || !(cd = php_mime_get_hdr_value(header, "Content-Type"))) {
 				cd = "";
-			} else { 
+			} else {
 				/* fix for Opera 6.01 */
 				s = strchr(cd, ';');
 				if (s != NULL) {
@@ -1302,7 +1283,7 @@ filedone:
 					ZVAL_STRING(&zfilename, temp_filename, 1);
 					safe_php_register_variable_ex(param, &zfilename, NULL, 1 TSRMLS_CC);
 				}
-		
+
 				/* Add $foo[tmp_name] */
 				if (is_arr_upload) {
 					snprintf(lbuf, llen, "%s[tmp_name][%s]", abuf, array_index);
@@ -1327,8 +1308,8 @@ filedone:
 				} else {
 					file_size.value.lval = total_bytes;
 					file_size.type = IS_LONG;
-				}	
-	
+				}
+
 				if (is_arr_upload) {
 					snprintf(lbuf, llen, "%s[error][%s]", abuf, array_index);
 				} else {
@@ -1344,7 +1325,7 @@ filedone:
 				}
 				if (!is_anonymous) {
 					safe_php_register_variable_ex(lbuf, &file_size, NULL, 0 TSRMLS_CC);
-				}	
+				}
 
 				/* Add $foo[size] */
 				if (is_arr_upload) {
@@ -1357,16 +1338,18 @@ filedone:
 			efree(param);
 		}
 	}
+
 fileupload_done:
 	if (php_rfc1867_callback != NULL) {
 		multipart_event_end event_end;
-		
+
 		event_end.post_bytes_processed = SG(read_post_bytes);
 		php_rfc1867_callback(MULTIPART_EVENT_END, &event_end, &event_extra_data TSRMLS_CC);
 	}
-	
+
 	SAFE_RETURN;
 }
+/* }}} */
 
 /*
  * Local variables:
diff --git a/main/rfc1867.h b/main/rfc1867.h
index 7038fad..b7f2c92 100644
--- a/main/rfc1867.h
+++ b/main/rfc1867.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: rfc1867.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: rfc1867.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef RFC1867_H
 #define RFC1867_H
diff --git a/main/safe_mode.c b/main/safe_mode.c
index f57626f..9d628d1 100644
--- a/main/safe_mode.c
+++ b/main/safe_mode.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: safe_mode.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: safe_mode.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/main/safe_mode.h b/main/safe_mode.h
index cd52b11..263b83e 100644
--- a/main/safe_mode.h
+++ b/main/safe_mode.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: safe_mode.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: safe_mode.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SAFE_MODE_H
 #define SAFE_MODE_H
diff --git a/main/snprintf.c b/main/snprintf.c
index 0a3f5a4..b0ce203 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: snprintf.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: snprintf.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 
 #include "php.h"
diff --git a/main/snprintf.h b/main/snprintf.h
index 8b21c8a..11e7a59 100644
--- a/main/snprintf.h
+++ b/main/snprintf.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: snprintf.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: snprintf.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
 
diff --git a/main/spprintf.c b/main/spprintf.c
index eb9e469..c6af477 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: spprintf.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spprintf.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* This is the spprintf implementation.
  * It has emerged from apache snprintf. See original header:
diff --git a/main/spprintf.h b/main/spprintf.h
index 7e56614..78e3be1 100644
--- a/main/spprintf.h
+++ b/main/spprintf.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spprintf.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: spprintf.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
 
diff --git a/main/streams/cast.c b/main/streams/cast.c
index f424946..2e9ad81 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: cast.c 279036 2009-04-20 08:28:44Z pajoye $ */
+/* $Id: cast.c 294462 2010-02-03 20:49:03Z pajoye $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -30,7 +30,7 @@
 #include "php_streams_int.h"
 
 /* Under BSD, emulate fopencookie using funopen */
-#if HAVE_FUNOPEN
+#if defined(HAVE_FUNOPEN) && !defined(HAVE_FOPENCOOKIE)
 typedef struct {
 	int (*reader)(void *, char *, int);
 	int (*writer)(void *, const char *, int);
@@ -43,13 +43,14 @@ FILE *fopencookie(void *cookie, const char *mode, COOKIE_IO_FUNCTIONS_T *funcs)
 	return funopen(cookie, funcs->reader, funcs->writer, funcs->seeker, funcs->closer);
 }
 # define HAVE_FOPENCOOKIE 1
+# define PHP_EMULATE_FOPENCOOKIE 1
 # define PHP_STREAM_COOKIE_FUNCTIONS	&stream_cookie_functions
-#elif HAVE_FOPENCOOKIE
+#elif defined(HAVE_FOPENCOOKIE)
 # define PHP_STREAM_COOKIE_FUNCTIONS	stream_cookie_functions
 #endif
 
 /* {{{ STDIO with fopencookie */
-#if HAVE_FUNOPEN
+#if defined(PHP_EMULATE_FOPENCOOKIE)
 /* use our fopencookie emulation */
 static int stream_cookie_reader(void *cookie, char *buffer, int size)
 {
@@ -80,8 +81,7 @@ static int stream_cookie_closer(void *cookie)
 	stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE;
 	return php_stream_close(stream);
 }
-
-#elif HAVE_FOPENCOOKIE
+#elif defined(HAVE_FOPENCOOKIE)
 static ssize_t stream_cookie_reader(void *cookie, char *buffer, size_t size)
 {
 	ssize_t ret;
@@ -96,7 +96,7 @@ static ssize_t stream_cookie_writer(void *cookie, const char *buffer, size_t siz
 	return php_stream_write(((php_stream *)cookie), (char *)buffer, size);
 }
 
-#ifdef COOKIE_SEEKER_USES_OFF64_T
+# ifdef COOKIE_SEEKER_USES_OFF64_T
 static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence)
 {
 	TSRMLS_FETCH();
@@ -107,13 +107,13 @@ static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence)
 		return -1;
 	return 0;
 }
-#else
+# else
 static int stream_cookie_seeker(void *cookie, off_t position, int whence)
 {
 	TSRMLS_FETCH();
 	return php_stream_seek((php_stream *)cookie, position, whence);
 }
-#endif
+# endif
 
 static int stream_cookie_closer(void *cookie)
 {
@@ -124,7 +124,7 @@ static int stream_cookie_closer(void *cookie)
 	stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE;
 	return php_stream_close(stream);
 }
-#endif /* elif HAVE_FOPENCOOKIE */
+#endif /* elif defined(HAVE_FOPENCOOKIE) */
 
 #if HAVE_FOPENCOOKIE
 static COOKIE_IO_FUNCTIONS_T stream_cookie_functions =
diff --git a/main/streams/filter.c b/main/streams/filter.c
index e08efe6..02aaf64 100644
--- a/main/streams/filter.c
+++ b/main/streams/filter.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: filter.c 273087 2009-01-08 17:01:58Z lbarnaud $ */
+/* $Id: filter.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_globals.h"
diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c
index 955aa80..cf59767 100755
--- a/main/streams/glob_wrapper.c
+++ b/main/streams/glob_wrapper.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: glob_wrapper.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: glob_wrapper.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_streams_int.h"
diff --git a/main/streams/memory.c b/main/streams/memory.c
index 0625246..0991947 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: memory.c 289437 2009-10-09 17:45:03Z pajoye $ */
+/* $Id: memory.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define _GNU_SOURCE
 #include "php.h"
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
index 78d8a66..2e75aad 100644
--- a/main/streams/mmap.c
+++ b/main/streams/mmap.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mmap.c 280678 2009-05-17 14:58:10Z lbarnaud $ */
+/* $Id: mmap.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Memory Mapping interface for streams */
 #include "php.h"
diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h
index a45808b..fb24426 100644
--- a/main/streams/php_stream_context.h
+++ b/main/streams/php_stream_context.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_stream_context.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_stream_context.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Stream context and status notification related definitions */
 
diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h
index 4f14770..7eb3693 100644
--- a/main/streams/php_stream_filter_api.h
+++ b/main/streams/php_stream_filter_api.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_stream_filter_api.h 273087 2009-01-08 17:01:58Z lbarnaud $ */
+/* $Id: php_stream_filter_api.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* The filter API works on the principle of "Bucket-Brigades".  This is
  * partially inspired by the Apache 2 method of doing things, although
diff --git a/main/streams/php_stream_glob_wrapper.h b/main/streams/php_stream_glob_wrapper.h
index 63b4cf0..67fd2dd 100755
--- a/main/streams/php_stream_glob_wrapper.h
+++ b/main/streams/php_stream_glob_wrapper.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_stream_glob_wrapper.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_stream_glob_wrapper.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 PHPAPI extern php_stream_wrapper  php_glob_stream_wrapper;
 PHPAPI extern php_stream_ops      php_glob_stream_ops;
diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h
index a3a2dbf..625eae0 100644
--- a/main/streams/php_stream_mmap.h
+++ b/main/streams/php_stream_mmap.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_stream_mmap.h 280678 2009-05-17 14:58:10Z lbarnaud $ */
+/* $Id: php_stream_mmap.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Memory Mapping interface for streams.
  * The intention is to provide a uniform interface over the most common
diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h
index 3603171..a653287 100644
--- a/main/streams/php_stream_plain_wrapper.h
+++ b/main/streams/php_stream_plain_wrapper.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_stream_plain_wrapper.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_stream_plain_wrapper.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* definitions for the plain files wrapper */
 
diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h
index ec32b1e..1cc3786 100644
--- a/main/streams/php_stream_transport.h
+++ b/main/streams/php_stream_transport.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_stream_transport.h 275024 2009-02-02 09:41:46Z pajoye $ */
+/* $Id: php_stream_transport.h 293036 2010-01-03 09:23:27Z sebastian $ */
 #ifdef PHP_WIN32
 #include "config.w32.h"
 #include <Ws2tcpip.h>
diff --git a/main/streams/php_stream_userspace.h b/main/streams/php_stream_userspace.h
index 625c22b..7147a4b 100644
--- a/main/streams/php_stream_userspace.h
+++ b/main/streams/php_stream_userspace.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_stream_userspace.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_stream_userspace.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 
 /* for user-space streams */
diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h
index b0a1f33..113c518 100644
--- a/main/streams/php_streams_int.h
+++ b/main/streams/php_streams_int.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_streams_int.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_streams_int.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 
 #if ZEND_DEBUG
@@ -49,7 +49,10 @@
 #define CHUNK_SIZE	8192
 
 #ifdef PHP_WIN32
-#define EWOULDBLOCK WSAEWOULDBLOCK
+# ifdef EWOULDBLOCK 
+#  undef EWOULDBLOCK
+# endif
+# define EWOULDBLOCK WSAEWOULDBLOCK
 #endif
 
 #ifndef S_ISREG
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 549d382..e7642d9 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: plain_wrapper.c 290578 2009-11-12 15:05:03Z johannes $ */
+/* $Id: plain_wrapper.c 295417 2010-02-23 15:04:29Z pajoye $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -39,6 +39,9 @@
 #include "SAPI.h"
 
 #include "php_streams_int.h"
+#ifdef PHP_WIN32
+# include "win32/winutil.h"
+#endif
 
 #define php_stream_fopen_from_fd_int(fd, mode, persistent_id)	_php_stream_fopen_from_fd_int((fd), (mode), (persistent_id) STREAMS_CC TSRMLS_CC)
 #define php_stream_fopen_from_fd_int_rel(fd, mode, persistent_id)	 _php_stream_fopen_from_fd_int((fd), (mode), (persistent_id) STREAMS_REL_CC TSRMLS_CC)
@@ -387,9 +390,6 @@ static int php_stdiop_close(php_stream *stream, int close_handle TSRMLS_DC)
 #endif
 	
 	if (close_handle) {
-		if (data->lock_flag != LOCK_UN) {
-			php_stream_lock(stream, LOCK_UN);
-		}
 		if (data->file) {
 			if (data->is_process_pipe) {
 				errno = 0;
@@ -866,6 +866,10 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, char
 	dir = VCWD_OPENDIR(path);
 
 #ifdef PHP_WIN32
+	if (!dir) {
+		php_win32_docref2_from_error(GetLastError(), path, path TSRMLS_CC);
+	}
+
 	if (dir && dir->finished) {
 		closedir(dir);
 		dir = NULL;
@@ -1063,6 +1067,17 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
 		return 0;
 	}
 
+#ifdef PHP_WIN32
+	if (!php_win32_check_trailing_space(url_from, strlen(url_from))) {
+		php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to TSRMLS_CC);
+		return 0;
+	}
+	if (!php_win32_check_trailing_space(url_to, strlen(url_to))) {
+		php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to TSRMLS_CC);
+		return 0;
+	}
+#endif
+
 	if ((p = strstr(url_from, "://")) != NULL) {
 		url_from = p + 3;
 	}
@@ -1083,12 +1098,13 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
 	ret = VCWD_RENAME(url_from, url_to);
 
 	if (ret == -1) {
-#ifdef EXDEV
+#ifndef PHP_WIN32
+# ifdef EXDEV
 		if (errno == EXDEV) {
 			struct stat sb;
 			if (php_copy_file(url_from, url_to TSRMLS_CC) == SUCCESS) {
 				if (VCWD_STAT(url_from, &sb) == 0) {
-#if !defined(TSRM_WIN32) && !defined(NETWARE)
+#  if !defined(TSRM_WIN32) && !defined(NETWARE)
 					if (VCWD_CHMOD(url_to, sb.st_mode)) {
 						if (errno == EPERM) {
 							php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
@@ -1107,7 +1123,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
 						php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
 						return 0;
 					}
-#endif
+#  endif
 					VCWD_UNLINK(url_from);
 					return 1;
 				}
@@ -1115,8 +1131,14 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
 			php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
 			return 0;
 		}
+# endif
 #endif
+
+#ifdef PHP_WIN32
+		php_win32_docref2_from_error(GetLastError(), url_from, url_to TSRMLS_CC);
+#else
 		php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
+#endif
         return 0;
 	}
 
@@ -1221,6 +1243,9 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod
 
 static int php_plain_files_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC)
 {
+#if PHP_WIN32
+	int url_len = strlen(url);
+#endif
 	if (PG(safe_mode) &&(!php_checkuid(url, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		return 0;
 	}
@@ -1229,6 +1254,13 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, char *url, int opt
 		return 0;
 	}
 
+#if PHP_WIN32
+	if (!php_win32_check_trailing_space(url, url_len)) {
+		php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(ENOENT));
+		return 0;
+	}
+#endif
+
 	if (VCWD_RMDIR(url) < 0) {
 		php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(errno));
 		return 0;
diff --git a/main/streams/streams.c b/main/streams/streams.c
index c2b4e3f..44843d2 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c 280678 2009-05-17 14:58:10Z lbarnaud $ */
+/* $Id: streams.c 294550 2010-02-05 00:39:31Z pajoye $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -1396,7 +1396,7 @@ PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, s
 	/* we've got at least 1 byte to read. 
 	 * less than 1 is an error */
 
-	if (haveread > 0) {
+	if (haveread > 0 || src->eof) {
 		return SUCCESS;
 	}
 	return FAILURE;
@@ -1858,22 +1858,9 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio
 			php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC,
 					"wrapper does not support stream open");
 		} else {
-			/* refcount++ to make sure the context doesn't get destroyed 
-			 * if open() fails and stream is closed */
-			if (context) {
-				zend_list_addref(context->rsrc_id);
-			}
-
 			stream = wrapper->wops->stream_opener(wrapper,
 				path_to_open, mode, options ^ REPORT_ERRORS,
 				opened_path, context STREAMS_REL_CC TSRMLS_CC);
-
-			/* if open() succeeded and context was not used, do refcount-- 
-			 * XXX if a wrapper didn't actually use context (no way to know that) 
-			 * and open() failed, refcount will stay increased */
-			if (context && stream && !stream->context) {
-				zend_list_delete(context->rsrc_id);
-			}
 		}
 
 		/* if the caller asked for a persistent stream but the wrapper did not
@@ -1974,7 +1961,17 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio
 PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream_context *context)
 {
 	php_stream_context *oldcontext = stream->context;
+	TSRMLS_FETCH();
+
 	stream->context = context;
+
+	if (context) {
+		zend_list_addref(context->rsrc_id);
+	}
+	if (oldcontext) {
+		zend_list_delete(oldcontext->rsrc_id);
+	}
+
 	return oldcontext;
 }
 
diff --git a/main/streams/transports.c b/main/streams/transports.c
index 1ac6677..a35efb2 100644
--- a/main/streams/transports.c
+++ b/main/streams/transports.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: transports.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: transports.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_streams_int.h"
@@ -134,7 +134,7 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int
 			context STREAMS_REL_CC TSRMLS_CC);
 
 	if (stream) {
-		stream->context = context;
+		php_stream_context_set(stream, context);
 
 		if ((flags & STREAM_XPORT_SERVER) == 0) {
 			/* client */
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index 74e2f91..106cfe6 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: userspace.c 280151 2009-05-08 11:35:12Z bjori $ */
+/* $Id: userspace.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_globals.h"
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index 214c011..9b039ca 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: xp_socket.c 289416 2009-10-09 14:20:17Z pajoye $ */
+/* $Id: xp_socket.c 294453 2010-02-03 20:21:40Z pajoye $ */
 
 #include "php.h"
 #include "ext/standard/file.h"
@@ -223,7 +223,11 @@ static int php_sockop_flush(php_stream *stream TSRMLS_DC)
 static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)
 {
 	php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
+#if ZEND_WIN32
+	return 0;
+#else
 	return fstat(sock->socket, &ssb->sb);
+#endif
 }
 
 static inline int sock_sendto(php_netstream_data_t *sock, char *buf, size_t buflen, int flags,
@@ -396,6 +400,10 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
 				}
 #endif
 				
+				case PHP_STREAM_OPTION_WRITE_BUFFER:
+					php_stream_set_chunk_size(stream, (ptrparam ? *(size_t *)ptrparam : PHP_SOCK_CHUNK_SIZE));
+					return PHP_STREAM_OPTION_RETURN_OK;
+
 				default:
 					return PHP_STREAM_OPTION_RETURN_NOTIMPL;
 			}
diff --git a/main/strlcat.c b/main/strlcat.c
index fe4ca42..38218dd 100644
--- a/main/strlcat.c
+++ b/main/strlcat.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: strlcat.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: strlcat.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/main/strlcpy.c b/main/strlcpy.c
index d3b4746..6faa21a 100644
--- a/main/strlcpy.c
+++ b/main/strlcpy.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: strlcpy.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: strlcpy.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/main/win32_internal_function_disabled.h b/main/win32_internal_function_disabled.h
index 6681064..a2cd16e 100644
--- a/main/win32_internal_function_disabled.h
+++ b/main/win32_internal_function_disabled.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: win32_internal_function_disabled.h 273638 2009-01-16 13:52:13Z pajoye $ */
+/* $Id: win32_internal_function_disabled.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* 5 means the min version is 5 (XP/2000), 6 (2k8/vista), etc. */
 
diff --git a/main/win95nt.h b/main/win95nt.h
index 7892945..d88f063 100644
--- a/main/win95nt.h
+++ b/main/win95nt.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: win95nt.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: win95nt.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Defines and types for Windows 95/NT */
 #define HAVE_DECLARED_TIMEZONE
diff --git a/netware/start.c b/netware/start.c
index 4cb4653..43510fc 100644
--- a/netware/start.c
+++ b/netware/start.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/run-tests.php b/run-tests.php
index 81f218b..3eeba95 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -4,7 +4,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5, 6                                                     |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -24,7 +24,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: run-tests.php 286503 2009-07-29 10:06:55Z cellog $ */
+/* $Id: run-tests.php 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* 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
@@ -80,6 +80,13 @@ if (PHP_VERSION_ID < 50300) {
 	}	
 }
 
+// (unicode) is available from 6.0.0
+if (PHP_VERSION_ID < 60000) {
+	define('STRING_TYPE', 'string');
+} else {
+	define('STRING_TYPE', 'unicode');
+}
+
 // If timezone is not set, use UTC.
 if (ini_get('date.timezone') == '') {
 	date_default_timezone_set('UTC');
@@ -355,8 +362,8 @@ function save_or_mail_results()
 			if ($sum_results['FAILED']) {
 				foreach ($PHP_FAILED_TESTS['FAILED'] as $test_info) {
 					$failed_tests_data .= $sep . $test_info['name'] . $test_info['info'];
-					$failed_tests_data .= $sep . file_get_contents(realpath($test_info['output']));
-					$failed_tests_data .= $sep . file_get_contents(realpath($test_info['diff']));
+					$failed_tests_data .= $sep . file_get_contents(realpath($test_info['output']), FILE_BINARY);
+					$failed_tests_data .= $sep . file_get_contents(realpath($test_info['diff']), FILE_BINARY);
 					$failed_tests_data .= $sep . "\n\n";
 				}
 				$status = "failed";
@@ -634,7 +641,7 @@ if (isset($argc) && $argc > 1) {
 					$html_output = is_resource($html_file);
 					break;
 				case '--version':
-					echo '$Revision: 286503 $' . "\n";
+					echo '$Revision: 293036 $' . "\n";
 					exit(1);
 
 				default:
@@ -1130,6 +1137,21 @@ function show_file_block($file, $block, $section = null)
 	}
 }
 
+function binary_section($section)
+{
+	return PHP_MAJOR_VERSION < 6 || 
+		(
+			$section == 'FILE'			||
+	        $section == 'FILEEOF'		||
+			$section == 'EXPECT'		||
+			$section == 'EXPECTF'		||
+			$section == 'EXPECTREGEX'	||
+			$section == 'EXPECTHEADERS'	||
+			$section == 'SKIPIF'		||
+			$section == 'CLEAN'
+		);
+}
+
 //
 //  Run an individual test case.
 //
@@ -1159,7 +1181,7 @@ TEST $file
 	// Load the sections of the test file.
 	$section_text = array('TEST' => '');
 
-	$fp = fopen($file, "rt") or error("Cannot open test file: $file");
+	$fp = fopen($file, "rb") or error("Cannot open test file: $file");
 
 	$borked = false;
 	$bork_info = '';
@@ -1187,28 +1209,42 @@ TEST $file
 	while (!feof($fp)) {
 		$line = fgets($fp);
 
+		if ($line === false) {
+			break;
+		}
+
 		// Match the beginning of a section.
-		if (preg_match('/^--([_A-Z]+)--/', $line, $r)) {
+		if (preg_match(b'/^--([_A-Z]+)--/', $line, $r)) {
 			$section = $r[1];
+			settype($section, STRING_TYPE);
 
 			if (isset($section_text[$section])) {
 				$bork_info = "duplicated $section section";
 				$borked    = true;
 			}
 
-			$section_text[$section] = '';
+			$section_text[$section] = binary_section($section) ? b'' : '';
 			$secfile = $section == 'FILE' || $section == 'FILEEOF' || $section == 'FILE_EXTERNAL';
 			$secdone = false;
 			continue;
 		}
 
+		if (!binary_section($section)) {
+			$line = unicode_decode($line, "utf-8");
+			if ($line == false) {
+				$bork_info = "cannot read test";
+				$borked = true;
+				break;
+			}
+		}
+
 		// Add to the section text.
 		if (!$secdone) {
 			$section_text[$section] .= $line;
 		}
 
 		// End of actual test?
-		if ($secfile && preg_match('/^===DONE===\s*$/', $line)) {
+		if ($secfile && preg_match(b'/^===DONE===\s*$/', $line)) {
 			$secdone = true;
 		}
 	}
@@ -1233,7 +1269,7 @@ TEST $file
 			}
 
 			if (@count($section_text['FILEEOF']) == 1) {
-				$section_text['FILE'] = preg_replace("/[\r\n]+$/", '', $section_text['FILEEOF']);
+				$section_text['FILE'] = preg_replace(b"/[\r\n]+$/", b'', $section_text['FILEEOF']);
 				unset($section_text['FILEEOF']);
 			}
 
@@ -1242,7 +1278,7 @@ TEST $file
 				$section_text['FILE_EXTERNAL'] = dirname($file) . '/' . trim(str_replace('..', '', $section_text['FILE_EXTERNAL']));
 
 				if (file_exists($section_text['FILE_EXTERNAL'])) {
-					$section_text['FILE'] = file_get_contents($section_text['FILE_EXTERNAL']);
+					$section_text['FILE'] = file_get_contents($section_text['FILE_EXTERNAL'], FILE_BINARY);
 					unset($section_text['FILE_EXTERNAL']);
 				} else {
 					$bork_info = "could not load --FILE_EXTERNAL-- " . dirname($file) . '/' . trim($section_text['FILE_EXTERNAL']);
@@ -1426,7 +1462,7 @@ TEST $file
 				$env['USE_ZEND_ALLOC'] = '1';
 			}
 
-			$output = system_with_timeout("$extra $php $pass_options -q $ini_settings $test_skipif", $env);
+			$output = system_with_timeout("$extra $php $pass_options -q $ini_settings -d display_errors=0 $test_skipif", $env);
 
 			if (!$cfg['keep']['skip']) {
 				@unlink($test_skipif);
@@ -1776,7 +1812,9 @@ COMMAND $cmd
 				// quote a non re portion of the string
 				$temp = $temp . preg_quote(substr($wanted_re, $startOffset, ($start - $startOffset)),  b'/');
 				// add the re unquoted.
-				$temp = $temp . b'(' . substr($wanted_re, $start+2, ($end - $start-2)). b')';
+				if ($end > $start) {
+					$temp = $temp . b'(' . substr($wanted_re, $start+2, ($end - $start-2)). b')';
+				}
 				$startOffset = $end + 2;
 			}
 			$wanted_re = $temp;
@@ -1956,7 +1994,7 @@ $output
 function comp_line($l1, $l2, $is_reg)
 {
 	if ($is_reg) {
-		return preg_match((binary) "/^$l1$/s", (binary) $l2);
+		return preg_match(b'/^'. (binary) $l1 . b'$/s', (binary) $l2);
 	} else {
 		return !strcmp((binary) $l1, (binary) $l2);
 	}
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c
index 2cb8048..7cc8cdd 100644
--- a/sapi/aolserver/aolserver.c
+++ b/sapi/aolserver/aolserver.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -22,7 +22,7 @@
  * - CGI/1.1 conformance
  */
 
-/* $Id: aolserver.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: aolserver.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* conflict between PHP and AOLserver headers */
 #define Debug php_Debug
@@ -205,7 +205,7 @@ static void php_info_aolserver(ZEND_MODULE_INFO_FUNC_ARGS)
 	int i;
 	
 	php_info_print_table_start();
-	php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c 272370 2008-12-31 11:15:49Z sebastian $");
+	php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c 293036 2010-01-03 09:23:27Z sebastian $");
 	php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
 	php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
 	php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -245,7 +245,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_aolserver_getallheaders, 0)
 ZEND_END_ARG_INFO()
 /* }}} */
 
-const static zend_function_entry aolserver_functions[] = {
+static const zend_function_entry aolserver_functions[] = {
 	PHP_FE(getallheaders, arginfo_aolserver_getallheaders)
 	{NULL, NULL, NULL}
 };
diff --git a/sapi/apache/libpre.c b/sapi/apache/libpre.c
index 2fc8c2a..ea11f9f 100644
--- a/sapi/apache/libpre.c
+++ b/sapi/apache/libpre.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: libpre.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: libpre.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifdef NETWARE
 
diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c
index ce0f819..68b2d70 100644
--- a/sapi/apache/mod_php5.c
+++ b/sapi/apache/mod_php5.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    | PHP 4.0 patches by Zeev Suraski <zeev at zend.com>                      |
    +----------------------------------------------------------------------+
  */
-/* $Id: mod_php5.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: mod_php5.c 294572 2010-02-05 19:34:47Z pajoye $ */
 
 #include "php_apache_http.h"
 #include "http_conf_globals.h"
@@ -196,6 +196,8 @@ static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_head
 
 			if (!strcasecmp(header_name, "Content-Type")) {
 				r->content_type = pstrdup(r->pool, header_content);
+                       } else if (!strcasecmp(header_name, "Content-Length")) {
+                               ap_set_content_length(r, strtol(header_content, (char **)NULL, 10));
 			} else if (!strcasecmp(header_name, "Set-Cookie")) {
 				table_add(r->headers_out, header_name, header_content);
 			} else if (op == SAPI_HEADER_REPLACE) {
diff --git a/sapi/apache/mod_php5.h b/sapi/apache/mod_php5.h
index 7f7c159..adbb783 100644
--- a/sapi/apache/mod_php5.h
+++ b/sapi/apache/mod_php5.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Rasmus Lerdorf <rasmus at php.net>                              |
    +----------------------------------------------------------------------+
  */
-/* $Id: mod_php5.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: mod_php5.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef MOD_PHP5_H
 #define MOD_PHP5_H
diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c
index 09e8a65..e323bfb 100644
--- a/sapi/apache/php_apache.c
+++ b/sapi/apache/php_apache.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    |          David Sklar <sklar at student.net>                             |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_apache.c 272840 2009-01-05 16:24:26Z iliaa $ */
+/* $Id: php_apache.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_apache_http.h"
 
diff --git a/sapi/apache/php_apache_http.h b/sapi/apache/php_apache_http.h
index 936484a..44d0927 100644
--- a/sapi/apache/php_apache_http.h
+++ b/sapi/apache/php_apache_http.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_apache_http.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_apache_http.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define NO_REGEX_EXTRA_H
 
diff --git a/sapi/apache/sapi_apache.c b/sapi/apache/sapi_apache.c
index dce6e5b..c2d97a5 100644
--- a/sapi/apache/sapi_apache.c
+++ b/sapi/apache/sapi_apache.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    | Stig Bakken <ssb at php.net>                                            |
    +----------------------------------------------------------------------+
  */
-/* $Id: sapi_apache.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sapi_apache.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_apache_http.h"
 
diff --git a/sapi/apache2filter/apache_config.c b/sapi/apache2filter/apache_config.c
index e06b168..b9626cb 100644
--- a/sapi/apache2filter/apache_config.c
+++ b/sapi/apache2filter/apache_config.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: apache_config.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: apache_config.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
diff --git a/sapi/apache2filter/php_apache.h b/sapi/apache2filter/php_apache.h
index 3f54fa7..6ec8c37 100644
--- a/sapi/apache2filter/php_apache.h
+++ b/sapi/apache2filter/php_apache.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_apache.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_apache.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_APACHE_H
 #define PHP_APACHE_H
diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c
index d0b662f..159e5c5 100644
--- a/sapi/apache2filter/php_functions.c
+++ b/sapi/apache2filter/php_functions.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_functions.c 272840 2009-01-05 16:24:26Z iliaa $ */
+/* $Id: php_functions.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c
index 22f368e..0c6c274 100644
--- a/sapi/apache2filter/sapi_apache2.c
+++ b/sapi/apache2filter/sapi_apache2.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sapi_apache2.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sapi_apache2.c 294572 2010-02-05 19:34:47Z pajoye $ */
 
 #include <fcntl.h>
 
@@ -127,6 +127,8 @@ php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_e
 
 			if (!strcasecmp(sapi_header->header, "content-type"))
 				ctx->r->content_type = apr_pstrdup(ctx->r->pool, val);
+                       else if (!strcasecmp(sapi_header->header, "content-length"))
+                               ap_set_content_length(ctx->r, strtol(val, (char **)NULL, 10));
 			else if (op == SAPI_HEADER_REPLACE)
 				apr_table_set(ctx->r->headers_out, sapi_header->header, val);
 			else
diff --git a/sapi/apache2handler/apache_config.c b/sapi/apache2handler/apache_config.c
index 8057050..15e25b5 100644
--- a/sapi/apache2handler/apache_config.c
+++ b/sapi/apache2handler/apache_config.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: apache_config.c 272413 2008-12-31 14:45:14Z bjori $ */
+/* $Id: apache_config.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
diff --git a/sapi/apache2handler/mod_php5.c b/sapi/apache2handler/mod_php5.c
index 038a712..56ec28b 100644
--- a/sapi/apache2handler/mod_php5.c
+++ b/sapi/apache2handler/mod_php5.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mod_php5.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: mod_php5.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
diff --git a/sapi/apache2handler/php_apache.h b/sapi/apache2handler/php_apache.h
index 8573967..a7ad1cc 100644
--- a/sapi/apache2handler/php_apache.h
+++ b/sapi/apache2handler/php_apache.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_apache.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_apache.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_APACHE_H
 #define PHP_APACHE_H
diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c
index 87bed11..8f8dd34 100644
--- a/sapi/apache2handler/php_functions.c
+++ b/sapi/apache2handler/php_functions.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_functions.c 273971 2009-01-19 19:32:40Z scottmac $ */
+/* $Id: php_functions.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c
index 62504af..d54ce4b 100644
--- a/sapi/apache2handler/sapi_apache2.c
+++ b/sapi/apache2handler/sapi_apache2.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sapi_apache2.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sapi_apache2.c 294572 2010-02-05 19:34:47Z pajoye $ */
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
@@ -109,7 +109,7 @@ php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_e
 			ptr = val;
 
 			*val = '\0';
-	
+
 			do {
 				val++;
 			} while (*val == ' ');
@@ -119,6 +119,8 @@ php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_e
 					efree(ctx->content_type);
 				}
 				ctx->content_type = estrdup(val);
+                       } else if (!strcasecmp(sapi_header->header, "content-length")) {
+                               ap_set_content_length(ctx->r, strtol(val, (char **)NULL, 10));
 			} else if (op == SAPI_HEADER_REPLACE) {
 				apr_table_set(ctx->r->headers_out, sapi_header->header, val);
 			} else {
@@ -151,8 +153,8 @@ php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
 			apr_table_set(ctx->r->subprocess_env, "force-response-1.0", "true");
 		}
 	}
-	
-	/*	call ap_set_content_type only once, else each time we call it, 
+
+	/*	call ap_set_content_type only once, else each time we call it,
 		configured output filters for that content type will be added */
 	if (!ctx->content_type) {
 		ctx->content_type = sapi_get_default_content_type(TSRMLS_C);
@@ -192,7 +194,7 @@ php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC)
 		buf += len;
 		len = count_bytes - tlen;
 	}
-	
+
 	return tlen;
 }
 
@@ -238,7 +240,11 @@ php_apache_sapi_getenv(char *name, size_t name_len TSRMLS_DC)
 {
 	php_struct *ctx = SG(server_context);
 	const char *env_var;
-	
+
+	if (ctx == NULL) {
+		return NULL;
+	}
+
 	env_var = apr_table_get(ctx->r->subprocess_env, name);
 
 	return (char *) env_var;
@@ -316,7 +322,8 @@ static void php_apache_sapi_log_message_ex(char *msg, request_rec *r)
 	}
 }
 
-static time_t php_apache_sapi_get_request_time(TSRMLS_D) {
+static time_t php_apache_sapi_get_request_time(TSRMLS_D)
+{
 	php_struct *ctx = SG(server_context);
 	return apr_time_sec(ctx->r->request_time);
 }
@@ -500,12 +507,12 @@ typedef struct {
 		uint str_len;
 		php_conf_rec *c = ap_get_module_config(r->per_dir_config, &php5_module);
 
-		for (zend_hash_internal_pointer_reset(&c->config); 
-				zend_hash_get_current_key_ex(&c->config, &str, &str_len, NULL, 0,  NULL) == HASH_KEY_IS_STRING;
-				zend_hash_move_forward(&c->config)
+		for (zend_hash_internal_pointer_reset(&c->config);
+			zend_hash_get_current_key_ex(&c->config, &str, &str_len, NULL, 0,  NULL) == HASH_KEY_IS_STRING;
+			zend_hash_move_forward(&c->config)
 		) {
 			zend_restore_ini_entry(str, str_len, ZEND_INI_STAGE_SHUTDOWN);
-		}	
+		}
 	}
 	if (p) {
 		((php_struct *)SG(server_context))->r = p;
@@ -555,7 +562,7 @@ normal:
 	}
 
 	/* Give a 404 if PATH_INFO is used but is explicitly disabled in
-	 * the configuration; default behaviour is to accept. */ 
+	 * the configuration; default behaviour is to accept. */
 	if (r->used_path_info == AP_REQ_REJECT_PATH_INFO
 		&& r->path_info && r->path_info[0]) {
 		PHPAP_INI_OFF;
@@ -603,17 +610,17 @@ zend_first_try {
 		if (!parent_req) {
 			parent_req = ctx->r;
 		}
-		if (parent_req && parent_req->handler && 
-				strcmp(parent_req->handler, PHP_MAGIC_TYPE) && 
-				strcmp(parent_req->handler, PHP_SOURCE_MAGIC_TYPE) && 
+		if (parent_req && parent_req->handler &&
+				strcmp(parent_req->handler, PHP_MAGIC_TYPE) &&
+				strcmp(parent_req->handler, PHP_SOURCE_MAGIC_TYPE) &&
 				strcmp(parent_req->handler, PHP_SCRIPT)) {
 			if (php_apache_request_ctor(r, ctx TSRMLS_CC)!=SUCCESS) {
 				zend_bailout();
 			}
 		}
-		
-		/* 
-		 * check if comming due to ErrorDocument 
+
+		/*
+		 * check if comming due to ErrorDocument
 		 * We make a special exception of 413 (Invalid POST request) as the invalidity of the request occurs
 		 * during processing of the request by PHP during POST processing. Therefor we need to re-use the exiting
 		 * PHP instance to handle the request rather then creating a new one.
diff --git a/sapi/apache_hooks/mod_php5.c b/sapi/apache_hooks/mod_php5.c
index 53d38ec..03ded22 100644
--- a/sapi/apache_hooks/mod_php5.c
+++ b/sapi/apache_hooks/mod_php5.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5													      |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group								  |
+   | 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		  |
@@ -17,7 +17,7 @@
    | PHP 4.0 patches by Zeev Suraski <zeev at zend.com>					  |
    +----------------------------------------------------------------------+
  */
-/* $Id: mod_php5.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: mod_php5.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_apache_http.h"
 
diff --git a/sapi/apache_hooks/mod_php5.h b/sapi/apache_hooks/mod_php5.h
index 4bb98ad..229ba3e 100644
--- a/sapi/apache_hooks/mod_php5.h
+++ b/sapi/apache_hooks/mod_php5.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Rasmus Lerdorf <rasmus at php.net>                              |
    +----------------------------------------------------------------------+
  */
-/* $Id: mod_php5.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: mod_php5.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef MOD_PHP5_H
 #define MOD_PHP5_H
diff --git a/sapi/apache_hooks/php_apache.c b/sapi/apache_hooks/php_apache.c
index f263286..4bc0b14 100644
--- a/sapi/apache_hooks/php_apache.c
+++ b/sapi/apache_hooks/php_apache.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    |          David Sklar <sklar at student.net>                             |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_apache.c 277250 2009-03-16 10:13:18Z pajoye $ */
+/* $Id: php_apache.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_apache_http.h"
 
diff --git a/sapi/apache_hooks/sapi_apache.c b/sapi/apache_hooks/sapi_apache.c
index c4a26af..0dbee9d 100644
--- a/sapi/apache_hooks/sapi_apache.c
+++ b/sapi/apache_hooks/sapi_apache.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    | Stig Bakken <ssb at php.net>                                            |
    +----------------------------------------------------------------------+
  */
-/* $Id: sapi_apache.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sapi_apache.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_apache_http.h"
 
diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c
index c1d89a3..4b59c57 100644
--- a/sapi/caudium/caudium.c
+++ b/sapi/caudium/caudium.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: caudium.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: caudium.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #ifdef HAVE_CAUDIUM
@@ -444,7 +444,7 @@ static void php_info_caudium(ZEND_MODULE_INFO_FUNC_ARGS)
 {
   /*  char buf[512]; */
   php_info_print_table_start();
-  php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c 272370 2008-12-31 11:15:49Z sebastian $");
+  php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c 293036 2010-01-03 09:23:27Z sebastian $");
   /*  php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
       php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
       php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index c01dce1..c189d3d 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: cgi_main.c 289795 2009-10-20 12:57:44Z tony2001 $ */
+/* $Id: cgi_main.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -1634,8 +1634,9 @@ int main(int argc, char *argv[])
 			 * in case some server does something different than above */
 			(!CGIG(redirect_status_env) || !getenv(CGIG(redirect_status_env)))
 		) {
-			SG(sapi_headers).http_response_code = 400;
-			PUTS("<b>Security Alert!</b> The PHP CGI cannot be accessed directly.\n\n\
+			zend_try {
+				SG(sapi_headers).http_response_code = 400;
+				PUTS("<b>Security Alert!</b> The PHP CGI cannot be accessed directly.\n\n\
 <p>This PHP CGI binary was compiled with force-cgi-redirect enabled.  This\n\
 means that a page will only be served up if the REDIRECT_STATUS CGI variable is\n\
 set, e.g. via an Apache Action directive.</p>\n\
@@ -1644,7 +1645,8 @@ manual page for CGI security</a>.</p>\n\
 <p>For more information about changing this behaviour or re-enabling this webserver,\n\
 consult the installation file that came with this distribution, or visit \n\
 <a href=\"http://php.net/install.windows\">the manual page</a>.</p>\n");
-
+			} zend_catch {
+			} zend_end_try();
 #if defined(ZTS) && !defined(PHP_DEBUG)
 			/* XXX we're crashing here in msvc6 debug builds at
 			 * php_message_handler_for_zend:839 because
@@ -1922,9 +1924,9 @@ consult the installation file that came with this distribution, or visit \n\
 								SG(request_info).no_headers = 1;
 							}
 #if ZEND_DEBUG
-							php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2009 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
+							php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2010 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
 #else
-							php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2009 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
+							php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2010 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
 #endif
 							php_request_shutdown((void *) 0);
 							exit_status = 0;
@@ -2040,13 +2042,16 @@ consult the installation file that came with this distribution, or visit \n\
 			*/
 			if (cgi || fastcgi || SG(request_info).path_translated) {
 				if (php_fopen_primary_script(&file_handle TSRMLS_CC) == FAILURE) {
-					if (errno == EACCES) {
-						SG(sapi_headers).http_response_code = 403;
-						PUTS("Access denied.\n");
-					} else {
-						SG(sapi_headers).http_response_code = 404;
-						PUTS("No input file specified.\n");
-					}
+					zend_try {
+						if (errno == EACCES) {
+							SG(sapi_headers).http_response_code = 403;
+							PUTS("Access denied.\n");
+						} else {
+							SG(sapi_headers).http_response_code = 404;
+							PUTS("No input file specified.\n");
+						}
+					} zend_catch {
+					} zend_end_try();
 					/* we want to serve more requests if this is fastcgi
 					 * so cleanup and continue, request shutdown is
 					 * handled later */
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c
index 156a689..df2dc31 100644
--- a/sapi/cgi/fastcgi.c
+++ b/sapi/cgi/fastcgi.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: fastcgi.c 287777 2009-08-26 19:17:32Z pajoye $ */
+/* $Id: fastcgi.c 293777 2010-01-20 16:02:28Z johannes $ */
 
 #include "php.h"
 #include "fastcgi.h"
@@ -255,6 +255,9 @@ void fcgi_shutdown(void)
 		zend_hash_destroy(&fcgi_mgmt_vars);
 	}
 	is_fastcgi = 0;
+	if (allowed_clients) {
+		free(allowed_clients);
+	}
 }
 
 #ifdef _WIN32
diff --git a/sapi/cgi/fastcgi.h b/sapi/cgi/fastcgi.h
index c4f62b8..7621737 100644
--- a/sapi/cgi/fastcgi.h
+++ b/sapi/cgi/fastcgi.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: fastcgi.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: fastcgi.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* FastCGI protocol */
 
diff --git a/sapi/cli/php.1.in b/sapi/cli/php.1.in
index 5216197..c800e12 100644
--- a/sapi/cli/php.1.in
+++ b/sapi/cli/php.1.in
@@ -1,4 +1,4 @@
-.TH PHP 1 "2009" "The PHP Group" "Scripting Language"
+.TH PHP 1 "2010" "The PHP Group" "Scripting Language"
 .SH NAME
 .TP 15
 php \- PHP Command Line Interface 'CLI'
@@ -69,7 +69,7 @@ specified by \-F to be executed.
 You can access the input line by \fB$argn\fP. While processing the input lines
 .B $argi 
 contains the number of the actual line being processed. Further more
-the paramters \-B and \-E can be used to execute 
+the parameters \-B and \-E can be used to execute 
 .IR code
 (see \-r) before and
 after all input lines have been processed respectively. Notice that the
@@ -304,6 +304,9 @@ Shows information about extension
 .IR name
 Shows configuration for extension
 .B name
+.TP
+.B \-\-ini
+Show configuration file names
 .SH FILES
 .TP 15
 .B php\-cli.ini
@@ -315,7 +318,7 @@ The standard configuration file will only be used when
 cannot be found.
 .SH EXAMPLES
 .TP 5
-\fIphp -r 'echo "Hello World\\n";'\fP
+\fIphp \-r 'echo "Hello World\\n";'\fP
 This command simply writes the text "Hello World" to standard out.
 .TP
 \fIphp \-r 'print_r(gd_info());'\fP
@@ -339,7 +342,7 @@ configuration information. If you then combine those two
 Using this PHP command you can count the lines being input.
 .TP
 \fIphp \-R '@$l+=count(file($argn));' \-E 'echo "Lines:$l\\n";'\fP
-In this example PHP expects each input line beeing a file. It counts all lines 
+In this example PHP expects each input line being a file. It counts all lines 
 of the files specified by each input line and shows the summarized result. 
 You may combine this with tools like find and change the php scriptlet.
 .TP
@@ -366,7 +369,7 @@ such a first line as shown below:
 .PD 1
 .P
 .SH SEE ALSO
-For a description of PHP see:
+For a more or less complete description of PHP look here:
 .PD 0
 .P
 .B http://www.php.net/manual/
@@ -395,7 +398,7 @@ contributors all around the world.
 .SH VERSION INFORMATION
 This manpage describes \fBphp\fP, version @PHP_VERSION at .
 .SH COPYRIGHT
-Copyright \(co 1997\-2009 The PHP Group
+Copyright \(co 1997\-2010 The PHP Group
 .LP
 This source file is subject to version 3.01 of the PHP license,
 that is bundled with this package in the file LICENSE, and is
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index aeade09..2b37290 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_cli.c 287973 2009-09-02 20:02:17Z pajoye $ */
+/* $Id: php_cli.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -76,8 +76,10 @@
 #endif
 
 #if (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE)
+#if HAVE_LIBEDIT
+#include <editline/readline.h>
+#else
 #include <readline/readline.h>
-#if !HAVE_LIBEDIT
 #include <readline/history.h>
 #endif
 #include "php_cli_readline.h"
@@ -829,7 +831,7 @@ int main(int argc, char *argv[])
 				}
 
 				request_started = 1;
-				php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2009 The PHP Group\n%s",
+				php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2010 The PHP Group\n%s",
 					PHP_VERSION, sapi_module.name, __DATE__, __TIME__,
 #if ZEND_DEBUG && defined(HAVE_GCOV)
 					"(DEBUG GCOV)",
diff --git a/sapi/cli/php_cli_readline.c b/sapi/cli/php_cli_readline.c
index 66010d7..f76f948 100644
--- a/sapi/cli/php_cli_readline.c
+++ b/sapi/cli/php_cli_readline.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_cli_readline.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_cli_readline.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
@@ -49,8 +49,10 @@
 #include <unixlib/local.h>
 #endif
 
+#if HAVE_LIBEDIT
+#include <editline/readline.h>
+#else
 #include <readline/readline.h>
-#if !HAVE_LIBEDIT
 #include <readline/history.h>
 #endif
 
diff --git a/sapi/cli/php_cli_readline.h b/sapi/cli/php_cli_readline.h
index d2fd659..ce68321 100644
--- a/sapi/cli/php_cli_readline.h
+++ b/sapi/cli/php_cli_readline.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_cli_readline.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_cli_readline.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 
diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt
index e322d7e..530bfbd 100644
--- a/sapi/cli/tests/006.phpt
+++ b/sapi/cli/tests/006.phpt
@@ -79,7 +79,7 @@ string(%d) "Extension [ <persistent> extension #%d pcre version <no_version> ] {
       - Parameters [5] {
         Parameter #0 [ <required> $regex ]
         Parameter #1 [ <required> $replace ]
-        Parameter #2 [ <optional> $subject ]
+        Parameter #2 [ <required> $subject ]
         Parameter #3 [ <optional> $limit ]
         Parameter #4 [ <optional> &$count ]
       }
@@ -99,7 +99,7 @@ string(%d) "Extension [ <persistent> extension #%d pcre version <no_version> ] {
       - Parameters [5] {
         Parameter #0 [ <required> $regex ]
         Parameter #1 [ <required> $replace ]
-        Parameter #2 [ <optional> $subject ]
+        Parameter #2 [ <required> $subject ]
         Parameter #3 [ <optional> $limit ]
         Parameter #4 [ <optional> &$count ]
       }
diff --git a/sapi/continuity/capi.c b/sapi/continuity/capi.c
index 250fa14..9e94211 100644
--- a/sapi/continuity/capi.c
+++ b/sapi/continuity/capi.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -110,7 +110,7 @@ PHP_MSHUTDOWN_FUNCTION(continuity)
 PHP_MINFO_FUNCTION(continuity)
 {
         php_info_print_table_start();
-        php_info_print_table_row(2, "Continuity Module Revision", "$Revision: 272370 $");
+        php_info_print_table_row(2, "Continuity Module Revision", "$Revision: 293036 $");
         php_info_print_table_row(2, "Server Version", conFget_build());
 #ifdef CONTINUITY_CDPEXT
 	php_info_print_table_row(2,"CDP Extensions", "enabled");
diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
index e32c3a3..85040b1 100644
--- a/sapi/embed/php_embed.c
+++ b/sapi/embed/php_embed.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Edin Kadribasic <edink at php.net>                              |
    +----------------------------------------------------------------------+
 */
-/* $Id: php_embed.c 286569 2009-07-30 20:20:56Z garretts $ */
+/* $Id: php_embed.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php_embed.h"
 #include "ext/standard/php_standard.h"
diff --git a/sapi/embed/php_embed.h b/sapi/embed/php_embed.h
index 19d1c98..983b1aa 100644
--- a/sapi/embed/php_embed.h
+++ b/sapi/embed/php_embed.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -15,7 +15,7 @@
    | Author: Edin Kadribasic <edink at php.net>                              |
    +----------------------------------------------------------------------+
 */
-/* $Id: php_embed.h 286569 2009-07-30 20:20:56Z garretts $ */
+/* $Id: php_embed.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef _PHP_EMBED_H_
 #define _PHP_EMBED_H_
diff --git a/sapi/isapi/php5isapi.c b/sapi/isapi/php5isapi.c
index 0f44efe..60e37b9 100644
--- a/sapi/isapi/php5isapi.c
+++ b/sapi/isapi/php5isapi.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    |          Ben Mansell <ben at zeus.com> (Zeus Support)                   |
    +----------------------------------------------------------------------+
  */
-/* $Id: php5isapi.c 278022 2009-03-30 14:24:16Z kalle $ */
+/* $Id: php5isapi.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include <httpext.h>
diff --git a/sapi/milter/php_milter.c b/sapi/milter/php_milter.c
index baa62b2..22f58c3 100644
--- a/sapi/milter/php_milter.c
+++ b/sapi/milter/php_milter.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_milter.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_milter.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -1102,7 +1102,7 @@ int main(int argc, char *argv[])
 				}
 				SG(headers_sent) = 1;
 				SG(request_info).no_headers = 1;
-				php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2009 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
+				php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2010 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
 				php_end_ob_buffers(1 TSRMLS_CC);
 				exit(1);
 				break;
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c
index cf088b1..dc6eb40 100644
--- a/sapi/nsapi/nsapi.c
+++ b/sapi/nsapi/nsapi.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: nsapi.c 286722 2009-08-03 10:13:49Z thetaphi $ */
+/* $Id: nsapi.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /*
  * PHP includes
@@ -68,6 +68,12 @@
  */
 #include "nsapi.h"
 
+/* fix for gcc4 visibility issue */
+#ifndef PHP_WIN32
+# undef NSAPI_PUBLIC
+# define NSAPI_PUBLIC PHPAPI
+#endif
+
 #define NSLS_D		struct nsapi_request_context *request_context
 #define NSLS_DC		, NSLS_D
 #define NSLS_C		request_context
@@ -131,14 +137,6 @@ static size_t nsapi_client_size = sizeof(nsapi_client)/sizeof(nsapi_client[0]);
 /* this parameters to "Service"/"Error" are NSAPI ones which should not be php.ini keys and are excluded */
 static char *nsapi_exclude_from_ini_entries[] = { "fn", "type", "method", "directive", "code", "reason", "script", "bucket", NULL };
 
-static char *nsapi_strdup(char *str)
-{
-	if (str != NULL) {
-		return STRDUP(str);
-	}
-	return NULL;
-}
-
 static void nsapi_free(void *addr)
 {
 	if (addr != NULL) {
@@ -314,7 +312,7 @@ PHP_MSHUTDOWN_FUNCTION(nsapi)
 PHP_MINFO_FUNCTION(nsapi)
 {
 	php_info_print_table_start();
-	php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 286722 $");
+	php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 293036 $");
 	php_info_print_table_row(2, "Server Software", system_version());
 	php_info_print_table_row(2, "Sub-requests with nsapi_virtual()",
 	 (nsapi_servact_service)?((zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0))?"not supported with zlib.output_compression":"enabled"):"not supported on this platform" );
@@ -500,7 +498,7 @@ static int php_nsapi_remove_header(sapi_header_struct *sapi_header TSRMLS_DC)
 	nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
 	
 	/* copy the header, because NSAPI needs reformatting and we do not want to change the parameter */
-	header_name = nsapi_strdup(sapi_header->header);
+	header_name = pool_strdup(rc->sn->pool, sapi_header->header);
 
 	/* extract name, this works, if only the header without ':' is given, too */
 	if (p = strchr(header_name, ':')) {
@@ -514,7 +512,7 @@ static int php_nsapi_remove_header(sapi_header_struct *sapi_header TSRMLS_DC)
 	
 	/* remove the header */
 	param_free(pblock_remove(header_name, rc->rq->srvhdrs));
-	nsapi_free(header_name);
+	pool_free(rc->sn->pool, header_name);
 	
 	return ZEND_HASH_APPLY_KEEP;
 }
@@ -538,7 +536,7 @@ static int sapi_nsapi_header_handler(sapi_header_struct *sapi_header, sapi_heade
 		case SAPI_HEADER_ADD:
 		case SAPI_HEADER_REPLACE:
 			/* copy the header, because NSAPI needs reformatting and we do not want to change the parameter */
-			header_name = nsapi_strdup(sapi_header->header);
+			header_name = pool_strdup(rc->sn->pool, sapi_header->header);
 
 			/* split header and align pointer for content */
 			header_content = strchr(header_name, ':');
@@ -561,7 +559,7 @@ static int sapi_nsapi_header_handler(sapi_header_struct *sapi_header, sapi_heade
 				pblock_nvinsert(header_name, header_content, rc->rq->srvhdrs);
 			}
 			
-			nsapi_free(header_name);
+			pool_free(rc->sn->pool, header_name);
 			return SAPI_HEADER_ADD;
 			
 		default:
@@ -734,8 +732,8 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D
 
 	/* DOCUMENT_ROOT */
 	if (value = request_translate_uri("/", rc->sn)) {
-	  	value[strlen(value) - 1] = '\0';
-		php_register_variable("DOCUMENT_ROOT", value, track_vars_array TSRMLS_CC);
+		pos = strlen(value);
+		php_register_variable_safe("DOCUMENT_ROOT", value, pos-1, track_vars_array TSRMLS_CC);
 		nsapi_free(value);
 	}
 
@@ -750,6 +748,8 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D
 
 	/* Create full Request-URI & Script-Name */
 	if (SG(request_info).request_uri) {
+		pos = strlen(SG(request_info).request_uri);
+		
 		if (SG(request_info).query_string) {
 			spprintf(&value, 0, "%s?%s", SG(request_info).request_uri, SG(request_info).query_string);
 			if (value) {
@@ -757,21 +757,16 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D
 				efree(value);
 			}
 		} else {
-			php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array TSRMLS_CC);
+			php_register_variable_safe("REQUEST_URI", SG(request_info).request_uri, pos, track_vars_array TSRMLS_CC);
 		}
 
-		if (value = nsapi_strdup(SG(request_info).request_uri)) {
-			if (rc->path_info) {
-				pos = strlen(SG(request_info).request_uri) - strlen(rc->path_info);
-				if (pos>=0) {
-					value[pos] = '\0';
-				} else {
-					value[0]='\0';
-				}
+		if (rc->path_info) {
+			pos -= strlen(rc->path_info);
+			if (pos<0) {
+				pos = 0;
 			}
-			php_register_variable("SCRIPT_NAME", value, track_vars_array TSRMLS_CC);
-			nsapi_free(value);
 		}
+		php_register_variable_safe("SCRIPT_NAME", SG(request_info).request_uri, pos, track_vars_array TSRMLS_CC);
 	}
 	php_register_variable("SCRIPT_FILENAME", SG(request_info).path_translated, track_vars_array TSRMLS_CC);
 
@@ -1014,21 +1009,25 @@ int NSAPI_PUBLIC php5_execute(pblock *pb, Session *sn, Request *rq)
 		}
 	}
 
-	request_context = (nsapi_request_context *)MALLOC(sizeof(nsapi_request_context));
+	request_context = (nsapi_request_context *)pool_malloc(sn->pool, sizeof(nsapi_request_context));
+	if (!request_context) {
+		log_error(LOG_CATASTROPHE, pblock_findval("fn", pb), sn, rq, "Insufficient memory to process PHP request!");
+		return REQ_ABORTED;
+	}
 	request_context->pb = pb;
 	request_context->sn = sn;
 	request_context->rq = rq;
 	request_context->read_post_bytes = 0;
 	request_context->fixed_script = fixed_script;
 	request_context->http_error = (error_directive) ? rq->status_num : 0;
-	request_context->path_info = nsapi_strdup(path_info);
+	request_context->path_info = path_info;
 
 	SG(server_context) = request_context;
-	SG(request_info).query_string = nsapi_strdup(query_string);
-	SG(request_info).request_uri = nsapi_strdup(uri);
-	SG(request_info).request_method = nsapi_strdup(request_method);
-	SG(request_info).path_translated = nsapi_strdup(path_translated);
-	SG(request_info).content_type = nsapi_strdup(content_type);
+	SG(request_info).query_string = query_string;
+	SG(request_info).request_uri = uri;
+	SG(request_info).request_method = request_method;
+	SG(request_info).path_translated = path_translated;
+	SG(request_info).content_type = content_type;
 	SG(request_info).content_length = (content_length == NULL) ? 0 : strtoul(content_length, 0, 0);
 	SG(sapi_headers).http_response_code = (error_directive) ? rq->status_num : 200;
 	
@@ -1068,14 +1067,7 @@ int NSAPI_PUBLIC php5_execute(pblock *pb, Session *sn, Request *rq)
 		}
 	}
 
-	nsapi_free(request_context->path_info);
-	nsapi_free(SG(request_info).query_string);
-	nsapi_free(SG(request_info).request_uri);
-	nsapi_free((void*)(SG(request_info).request_method));
-	nsapi_free(SG(request_info).path_translated);
-	nsapi_free((void*)(SG(request_info).content_type));
-
-	FREE(request_context);
+	pool_free(sn->pool, request_context);
 	SG(server_context) = NULL;
 
 	return retval;
diff --git a/sapi/phttpd/php_phttpd.h b/sapi/phttpd/php_phttpd.h
index a827d8c..168c58a 100644
--- a/sapi/phttpd/php_phttpd.h
+++ b/sapi/phttpd/php_phttpd.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c
index 2934abf..11df607 100644
--- a/sapi/phttpd/phttpd.c
+++ b/sapi/phttpd/phttpd.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c
index 7af5d50..f6cd9b6 100644
--- a/sapi/pi3web/pi3web_sapi.c
+++ b/sapi/pi3web/pi3web_sapi.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: pi3web_sapi.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pi3web_sapi.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
@@ -57,7 +57,7 @@ static void php_info_pi3web(ZEND_MODULE_INFO_FUNC_ARGS)
 	PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n");
 	PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">Pi3Web Server Information</th></tr>\n");
 	php_info_print_table_header(2, "Information Field", "Value");
-	php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c 272370 2008-12-31 11:15:49Z sebastian $");
+	php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c 293036 2010-01-03 09:23:27Z sebastian $");
 	php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp());
 	snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled());
 	php_info_print_table_row(2, "Debug Enabled", variable_buf);
diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c
index eabe14d..614a89e 100644
--- a/sapi/roxen/roxen.c
+++ b/sapi/roxen/roxen.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: roxen.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: roxen.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #ifdef HAVE_ROXEN
@@ -438,7 +438,7 @@ static void php_info_roxen(ZEND_MODULE_INFO_FUNC_ARGS)
 {
   /*  char buf[512]; */
   php_info_print_table_start();
-  php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c 272370 2008-12-31 11:15:49Z sebastian $");
+  php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c 293036 2010-01-03 09:23:27Z sebastian $");
   /*  php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
       php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
       php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
diff --git a/sapi/thttpd/php_thttpd.h b/sapi/thttpd/php_thttpd.h
index cc6f4f7..43e9ad8 100644
--- a/sapi/thttpd/php_thttpd.h
+++ b/sapi/thttpd/php_thttpd.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c
index 187bddf..f2530ec 100644
--- a/sapi/thttpd/thttpd.c
+++ b/sapi/thttpd/thttpd.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: thttpd.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: thttpd.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "SAPI.h"
diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c
index c94ed08..df66a76 100644
--- a/sapi/tux/php_tux.c
+++ b/sapi/tux/php_tux.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/sapi/webjames/php_webjames.h b/sapi/webjames/php_webjames.h
index eac8b11..a0532c7 100644
--- a/sapi/webjames/php_webjames.h
+++ b/sapi/webjames/php_webjames.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/sapi/webjames/webjames.c b/sapi/webjames/webjames.c
index 6783b5e..bbe5084 100644
--- a/sapi/webjames/webjames.c
+++ b/sapi/webjames/webjames.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/server-tests.php b/server-tests.php
index 42d4399..051a1cf 100755
--- a/server-tests.php
+++ b/server-tests.php
@@ -3,7 +3,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
diff --git a/tests/basic/bug46313-win.phpt b/tests/basic/bug46313-win.phpt
index a851789..1971e80 100644
--- a/tests/basic/bug46313-win.phpt
+++ b/tests/basic/bug46313-win.phpt
@@ -60,6 +60,6 @@ string(12) "o1"
 bool(true)
 string(%d) "%s"
 bool(true)
-PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
-PHP Warning:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
+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/bug46313.phpt b/tests/basic/bug46313.phpt
index 275b267..9241141 100644
--- a/tests/basic/bug46313.phpt
+++ b/tests/basic/bug46313.phpt
@@ -6,6 +6,7 @@ Bug #46313 (Magic quotes broke $_FILES)
 magic_quotes_gpc=1
 file_uploads=1
 register_globals=1
+display_errors=0
 --POST_RAW--
 Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737
 -----------------------------20896060251896012921717172737
diff --git a/tests/basic/bug46759.phpt b/tests/basic/bug46759.phpt
index c5db2b9..d35cd53 100644
--- a/tests/basic/bug46759.phpt
+++ b/tests/basic/bug46759.phpt
@@ -1,6 +1,7 @@
 --TEST--
 Testing magic_quotes_gpc
 --INI--
+display_errors=0
 magic_quotes_gpc=1
 --GET--
 a='&b="&c=\"
diff --git a/tests/classes/interface_constant_inheritance_001.phpt b/tests/classes/interface_constant_inheritance_001.phpt
index ae3e71e..f982a4a 100644
--- a/tests/classes/interface_constant_inheritance_001.phpt
+++ b/tests/classes/interface_constant_inheritance_001.phpt
@@ -14,4 +14,4 @@ echo "Done\n";
 ?>
 --EXPECTF--
 
-Fatal error: Cannot inherit previously-inherited constant FOO from interface I1 in %s on line 6
\ No newline at end of file
+Fatal error: Cannot inherit previously-inherited or override constant FOO from interface I1 in %s on line 6
diff --git a/tests/classes/interface_constant_inheritance_002.phpt b/tests/classes/interface_constant_inheritance_002.phpt
index d5001ba..af4ce69 100644
--- a/tests/classes/interface_constant_inheritance_002.phpt
+++ b/tests/classes/interface_constant_inheritance_002.phpt
@@ -14,4 +14,4 @@ echo "Done\n";
 ?>
 --EXPECTF--
 
-Fatal error: Cannot inherit previously-inherited constant FOO from interface I in %s on line 6
\ No newline at end of file
+Fatal error: Cannot inherit previously-inherited or override constant FOO from interface I in %s on line 6
diff --git a/tests/classes/interface_constant_inheritance_003.phpt b/tests/classes/interface_constant_inheritance_003.phpt
index a3ba815..6b4139b 100644
--- a/tests/classes/interface_constant_inheritance_003.phpt
+++ b/tests/classes/interface_constant_inheritance_003.phpt
@@ -17,4 +17,4 @@ echo "Done\n";
 ?>
 --EXPECTF--
 
-Fatal error: Cannot inherit previously-inherited constant FOO from interface I2 in %s on line 10
+Fatal error: Cannot inherit previously-inherited or override constant FOO from interface I2 in %s on line 10
diff --git a/tests/output/ob_011.phpt b/tests/output/ob_011.phpt
index 996ed39..a90fd56 100644
--- a/tests/output/ob_011.phpt
+++ b/tests/output/ob_011.phpt
@@ -1,8 +1,7 @@
 --TEST--
 output buffering - fatalism
 --XFAIL--
-This test will fail until the fix in version 1.178 of ext/main/output.c
-is backported from php 6
+This test will fail until the fix in revision r214155 is backported from php 6
 --FILE--
 <?php
 function obh($s)
diff --git a/tests/output/ob_start_basic_unerasable_005.phpt b/tests/output/ob_start_basic_unerasable_005.phpt
index 6bfb7ae..7be71e5 100644
--- a/tests/output/ob_start_basic_unerasable_005.phpt
+++ b/tests/output/ob_start_basic_unerasable_005.phpt
@@ -1,5 +1,5 @@
 --TEST--
-ob_start(): Ensure unerasable buffer cannot be flushed by ob_flush().
+ob_start(): Ensure unerasable buffer cannot be flushed by ob_flush()
 --FILE--
 <?php
 function callback($string) {
diff --git a/tests/security/magic_quotes_gpc.phpt b/tests/security/magic_quotes_gpc.phpt
index eb5b842..382ab94 100644
--- a/tests/security/magic_quotes_gpc.phpt
+++ b/tests/security/magic_quotes_gpc.phpt
@@ -1,6 +1,7 @@
 --TEST--
 Test if magic_quotes_gpc works as expected
 --INI--
+display_errors=0
 magic_quotes_gpc=1
 --GET--
 a=abc'"%00123
diff --git a/win32/build/Makefile b/win32/build/Makefile
index 5f63382..837fcc8 100644
--- a/win32/build/Makefile
+++ b/win32/build/Makefile
@@ -14,7 +14,7 @@
 #  | Author: Wez Furlong <wez at thebrainroom.com>                           |
 #  +----------------------------------------------------------------------+
 #
-# $Id: Makefile 289764 2009-10-19 19:05:58Z pajoye $
+# $Id: Makefile 289763 2009-10-19 19:02:12Z pajoye $
 # This is the makefile template for the win32 build
 
 CC="$(CL)"
diff --git a/win32/build/config.w32 b/win32/build/config.w32
index 67b9fe6..5f10c7e 100644
--- a/win32/build/config.w32
+++ b/win32/build/config.w32
@@ -1,5 +1,5 @@
 // vim:ft=javascript
-// $Id: config.w32 289764 2009-10-19 19:05:58Z pajoye $
+// $Id: config.w32 291639 2009-12-03 11:50:32Z kalle $
 // "Master" config file; think of it as a configure.in
 // equivalent.
 
@@ -15,6 +15,7 @@ if (!CL) {
 // 1310 is vs.net 2003
 // 1400 is vs.net 2005
 // 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('.', '');
 STDOUT.WriteLine("  Detected compiler " + VC_VERSIONS[VCVERS]);
@@ -113,13 +114,13 @@ DEFINE("BASE_INCLUDES", "/I . /I main /I Zend /I TSRM /I ext ");
 
 // CFLAGS for building the PHP dll
 DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP5DLLTS_EXPORTS /D PHP_EXPORTS \
-/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=0x400");
+/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=0x500");
 
 DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)');
 
 // General CFLAGS for building objects
 DEFINE("CFLAGS", "/nologo /FD $(BASE_INCLUDES) /D _WINDOWS \
-/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS");
+/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 ");
 
 if (VCVERS < 1400) {
 	// Enable automatic precompiled headers
@@ -147,7 +148,7 @@ if (VCVERS >= 1400) {
 	}
 }
 
-ARG_WITH('mp', 'Tell VC9 use up to [n,auto,disable] processes for compilation', 'auto');
+ARG_WITH('mp', 'Tell VC9+ use up to [n,auto,disable] processes for compilation', 'auto');
 if (VCVERS >= 1500 && PHP_MP != 'disable') {
 		// no from disable-all 
 		if(PHP_MP == 'auto' || PHP_MP == 'no') {
@@ -177,7 +178,7 @@ DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_3
 
 // Set some debug/release specific options
 if (PHP_DEBUG == "yes") {
-	ADD_FLAG("CFLAGS", "/LDd /MDd /Gm /Od /D _DEBUG /D ZEND_DEBUG=1 " +
+	ADD_FLAG("CFLAGS", "/LDd /MDd /W3 /Gm /Od /D _DEBUG /D ZEND_DEBUG=1 " +
 		(X64?"/Zi":"/ZI"));
 	ADD_FLAG("LDFLAGS", "/debug");
 	// Avoid problems when linking to release libraries that use the release
diff --git a/win32/build/config.w32.h.in b/win32/build/config.w32.h.in
index e585e0a..27ff052 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 282624 2009-06-23 06:56:45Z kalle $
+	$Id: config.w32.h.in 291951 2009-12-10 14:08:19Z pajoye $
 */
 
 /* Define the minimum supported version */
@@ -28,6 +28,8 @@
 #define PHP_EXT_DES_CRYPT 1
 #define PHP_MD5_CRYPT 1
 #define PHP_BLOWFISH_CRYPT 1
+#define PHP_SHA512_CRYPT 1
+#define PHP_SHA256_CRYPT 1
 
 /* PHP Runtime Configuration */
 #define PHP_URL_FOPEN 1
diff --git a/win32/build/confutils.js b/win32/build/confutils.js
index 28b5e0d..ed3f242 100644
--- a/win32/build/confutils.js
+++ b/win32/build/confutils.js
@@ -41,6 +41,7 @@ VC_VERSIONS[1300] = 'MSVC7 (Visual C++ 2002)';
 VC_VERSIONS[1310] = 'MSVC7.1 (Visual C++ 2003)';
 VC_VERSIONS[1400] = 'MSVC8 (Visual C++ 2005)';
 VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)';
+VC_VERSIONS[1600] = 'MSVC10 (Visual C++ 2010)';
 
 var VC_VERSIONS_SHORT = new Array();
 VC_VERSIONS_SHORT[1200] = 'VC6';
@@ -48,6 +49,7 @@ VC_VERSIONS_SHORT[1300] = 'VC7';
 VC_VERSIONS_SHORT[1310] = 'VC7.1';
 VC_VERSIONS_SHORT[1400] = 'VC8';
 VC_VERSIONS_SHORT[1500] = 'VC9';
+VC_VERSIONS_SHORT[1600] = 'VC10';
 
 if (PROGRAM_FILES == null) {
 	PROGRAM_FILES = "C:\\Program Files";
diff --git a/win32/build/deplister.c b/win32/build/deplister.c
index f6f1ce5..79191f0 100644
--- a/win32/build/deplister.c
+++ b/win32/build/deplister.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: deplister.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: deplister.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* This little application will list the DLL dependencies for a PE
  * module to it's stdout for use by distro/installer building tools */
diff --git a/win32/globals.c b/win32/globals.c
index f14380a..6f8389e 100755
--- a/win32/globals.c
+++ b/win32/globals.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: globals.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: globals.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #include "php.h"
 #include "php_win32_globals.h"
diff --git a/win32/grp.h b/win32/grp.h
index 2d9c014..fbf226f 100644
--- a/win32/grp.h
+++ b/win32/grp.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: grp.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: grp.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 struct group {
 	char *gr_name;			
diff --git a/win32/php_stdbool.h b/win32/php_stdbool.h
new file mode 100644
index 0000000..83c808f
--- /dev/null
+++ b/win32/php_stdbool.h
@@ -0,0 +1,11 @@
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+#if !defined(__BOOL_DEFINED)
+#  define bool short
+
+/* The other macros must be usable in preprocessor directives.  */
+#  define false 0
+#  define true 1
+#  define __bool_true_false_are_defined 1
+# endif
+#endif /* _STDBOOL_H */
diff --git a/win32/php_stdint.h b/win32/php_stdint.h
index 6eb8ce4..5df1df4 100644
--- a/win32/php_stdint.h
+++ b/win32/php_stdint.h
@@ -238,7 +238,12 @@ typedef uint64_t  uintmax_t;
 #define INTMAX_C   INT64_C
 #define UINTMAX_C  UINT64_C
 
-static __inline int64_t llabs( int64_t i ) { return i >= 0? i: -i; }
+#if _MSC_VER < 1600
+static __inline int64_t llabs(int64_t i)
+{
+	return i >= 0 ? i: -i;
+}
+#endif
 
 #endif // __STDC_CONSTANT_MACROS ]
 
diff --git a/win32/php_win32_globals.h b/win32/php_win32_globals.h
index 9d0d653..d818aac 100755
--- a/win32/php_win32_globals.h
+++ b/win32/php_win32_globals.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_win32_globals.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_win32_globals.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef PHP_WIN32_GLOBALS_H
 #define PHP_WIN32_GLOBALS_H
diff --git a/win32/select.c b/win32/select.c
index 26f7294..b163e3f 100644
--- a/win32/select.c
+++ b/win32/select.c
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -21,7 +21,7 @@
 
 #ifdef PHP_WIN32
 
-/* $Id: select.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: select.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Win32 select() will only work with sockets, so we roll our own implementation here.
  * - If you supply only sockets, this simply passes through to winsock select().
diff --git a/win32/select.h b/win32/select.h
index 7670f57..3f3de9e 100644
--- a/win32/select.h
+++ b/win32/select.h
@@ -2,7 +2,7 @@
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2009 The PHP Group                                |
+  | 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        |
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: select.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: select.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 PHPAPI int php_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv);
 
diff --git a/win32/sockets.c b/win32/sockets.c
index 4b3d274..44764f7 100644
--- a/win32/sockets.c
+++ b/win32/sockets.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sockets.c 274392 2009-01-23 15:49:49Z kalle $ */
+/* $Id: sockets.c 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Code originally from ext/sockets */
 
diff --git a/win32/sockets.h b/win32/sockets.h
index 633137d..3d8bc34 100644
--- a/win32/sockets.h
+++ b/win32/sockets.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sockets.h 274392 2009-01-23 15:49:49Z kalle $ */
+/* $Id: sockets.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 /* Code originally from ext/sockets */
 
diff --git a/win32/syslog.h b/win32/syslog.h
index 1270a95..331ca11 100644
--- a/win32/syslog.h
+++ b/win32/syslog.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: syslog.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: syslog.h 293036 2010-01-03 09:23:27Z sebastian $ */
 
 #ifndef SYSLOG_H
 #define	SYSLOG_H
diff --git a/win32/winutil.c b/win32/winutil.c
index 244ecff..7845f89 100644
--- a/win32/winutil.c
+++ b/win32/winutil.c
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: winutil.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: winutil.c 294726 2010-02-07 20:45:46Z pajoye $ */
 
 #include "php.h"
 
@@ -31,3 +31,18 @@ PHPAPI char *php_win_err(int error)
 
 	return (buf ? (char *) buf : "");
 }
+
+int php_win32_check_trailing_space(const char * path, const int path_len) {
+	if (path_len < 1) {
+		return 1;
+	}
+	if (path) {
+		if (path[0] == ' ' || path[path_len - 1] == ' ') {
+			return 0;
+		} else {
+			return 1;
+		}
+	} else {
+		return 0;
+	}
+}
diff --git a/win32/winutil.h b/win32/winutil.h
index f232d27..8ee7575 100644
--- a/win32/winutil.h
+++ b/win32/winutil.h
@@ -2,7 +2,7 @@
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                                |
+   | 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        |
@@ -19,3 +19,4 @@
 PHPAPI char *php_win_err(int error);
 
 #define php_win_err()	php_win_err(GetLastError())
+int php_win32_check_trailing_space(const char * path, const int path_len);
-- 
1.6.3.3




More information about the Pkg-php-commits mailing list